MCPcopy Index your code
hub / github.com/devote/HTML5-History-API / initialize

Function initialize

history.ielte7.js:1004–1111  ·  view source on GitHub ↗

* Library initialization * * @return {Boolean} return true if all is well, otherwise return false value

()

Source from the content-addressed store, hash-verified

1002 * @return {Boolean} return true if all is well, otherwise return false value
1003 */
1004 function initialize() {
1005 /**
1006 * Get custom settings from the query string
1007 */
1008 var scripts = document.getElementsByTagName('script');
1009 var src = (scripts[scripts.length - 1] || {}).src || '';
1010 var arg = src.indexOf('?') !== -1 ? src.split('?').pop() : '';
1011 arg.replace(/(\w+)(?:=([^&]*))?/g, function(a, key, value) {
1012 settings[key] = (value || '').replace(/^(0|false)$/, '');
1013 });
1014
1015 /**
1016 * Includes support for IE6+
1017 */
1018 ie6DriverStart();
1019
1020 /**
1021 * hang up the event handler to listen to the events hashchange
1022 */
1023 addEvent(eventNamePrefix + 'hashchange', onHashChange, false);
1024
1025 // a list of objects with pairs of descriptors/object
1026 var data = [locationDescriptors, locationObject, eventsDescriptors, global, historyDescriptors, historyObject];
1027
1028 // if browser support object 'state' in interface 'History'
1029 if (isSupportStateObjectInHistory) {
1030 // remove state property from descriptor
1031 delete historyDescriptors['state'];
1032 }
1033
1034 // initializing descriptors
1035 for(var i = 0; i < data.length; i += 2) {
1036 for(var prop in data[i]) {
1037 if (data[i].hasOwnProperty(prop)) {
1038 if (typeof data[i][prop] !== 'object') {
1039 // If the descriptor is a simple function, simply just assign it an object
1040 data[i + 1][prop] = data[i][prop];
1041 } else {
1042 // prepare the descriptor the required format
1043 var descriptor = prepareDescriptorsForObject(data[i], prop, data[i][prop]);
1044 // try to set the descriptor object
1045 if (!redefineProperty(data[i + 1], prop, descriptor, function(n, o) {
1046 // is satisfied if the failed override property
1047 if (o === historyObject) {
1048 // the problem occurs in Safari on the Mac
1049 global.history = historyObject = data[i + 1] = n;
1050 }
1051 })) {
1052 // if there is no possibility override.
1053 // This browser does not support descriptors, such as IE7
1054
1055 // remove previously hung event handlers
1056 removeEvent(eventNamePrefix + 'hashchange', onHashChange, false);
1057
1058 // fail to initialize :(
1059 return false;
1060 }
1061

Callers 1

history.ielte7.jsFile · 0.70

Calls 6

ie6DriverStartFunction · 0.85
redefinePropertyFunction · 0.70
storageInitializeFunction · 0.70
onLoadFunction · 0.70
parseURLFunction · 0.70

Tested by

no test coverage detected