From 5c87d98c0b3383c7ad63f0b69e36110b915e36c2 Mon Sep 17 00:00:00 2001 From: Robert Zorko Date: Tue, 22 Sep 2015 18:13:31 +0200 Subject: enabled buttons in the navigation header (at least buttons on the left side of the bar), renamed stateMachine to navigation --- js/codeq/language.js | 19 +++++++- js/codeq/login.js | 10 +++++ js/codeq/navigation.js | 104 ++++++++++++++++++++++++++++++++++++++++++++ js/codeq/problem.js | 23 ++++++++++ js/codeq/prolog.js | 15 ++++++- js/codeq/python.js | 15 ++++++- js/codeq/stateMachine.js | 32 -------------- js/jquery/jquery.history.js | 1 + 8 files changed, 184 insertions(+), 35 deletions(-) create mode 100644 js/codeq/navigation.js delete mode 100644 js/codeq/stateMachine.js create mode 100644 js/jquery/jquery.history.js (limited to 'js') diff --git a/js/codeq/language.js b/js/codeq/language.js index 2864098..d4b6ee4 100644 --- a/js/codeq/language.js +++ b/js/codeq/language.js @@ -5,14 +5,31 @@ (function(){ codeq.globalStateMachine.register('language',{ 'enter': function(){ - $("#screen_language").css('display', ''); $('#submit_language').on('click',function(){ codeq.globalStateMachine.transition('problem',$('#language').val()); + //var lan = $('#language').val(); + //codeq.activateState('problem',{'lan':lan}); }); + + $('#navigation-login').css('display', ''); + /*$('#navigation-login').on('click', function(){ + codeq.globalStateMachine.transition('login'); + //codeq.activateState('login'); + });*/ + $("#navigation-language").addClass("active"); + $('#navigation-language').css('display', ''); + + $("#screen_language").css('display', ''); }, 'exit' : function(){ $("#submit_language").off(); $("#screen_language").css('display', 'none'); + + $('#navigation-login').css('display', 'none'); + //$('#navigation-login').off(); + $('#navigation-language').css('display', 'none'); + $("#navigation-language").removeClass("active"); + $('#language').val("prolog");//reset to the default value } }); diff --git a/js/codeq/login.js b/js/codeq/login.js index 11a4900..bb92325 100644 --- a/js/codeq/login.js +++ b/js/codeq/login.js @@ -15,24 +15,34 @@ $('#disabled').css('cursor', ''); if (data.code !== 0) throw new Error('Login failed, code: ' + data.code + ', message: ' + data.message); codeq.globalStateMachine.transition('language'); + //codeq.activateState('language'); }) .fail(function (reason) { $('#disabled').css('display', 'none'); $('#disabled').css('cursor', ''); codeq.log.error('Login failed: ' + reason, reason); alert('Login request failed: ' + reason); + $('#disabled').css('display', 'none'); }) .done(); }; codeq.globalStateMachine.register('login',{ 'enter': function(){ $("#submit").on('click', loginFun); + + $("#navigation-login").addClass("active"); + $('#navigation-login').css('display', ''); + $("#screen_login").css('display', ''); $('#disabled').css('display', 'none'); }, 'exit' : function(){ $("#submit").off('click', loginFun); $("#screen_login").css('display', 'none'); + $("#password").val(''); + + $('#navigation-login').css('display', 'none'); + $("#navigation-login").removeClass("active"); } }); })(); \ No newline at end of file diff --git a/js/codeq/navigation.js b/js/codeq/navigation.js new file mode 100644 index 0000000..4445a3d --- /dev/null +++ b/js/codeq/navigation.js @@ -0,0 +1,104 @@ +/** + * Created by robert on 9/15/15. + */ +(function() { + codeq.makeStateMachine = function (def) { + var currState = null; + return { + 'transition': function (name) { + var newState = def[name]; + if (!newState) { + codeq.log.error('Cannot transition to state ' + name + ': it is not defined'); + return; + } + if (newState === currState) { + codeq.log.info('Will not transition between identical states: ' + name); + return; + } + if (currState !== null) currState.exit(); + currState = newState; + currState.enter.apply(currState, Array.prototype.slice.apply(arguments, [1])); + }, + 'destroy': function () { + if (currState !== null) currState.exit(); + currState = null; + }, + 'register': function (name, state) { + if (name in def) codeq.log.error('The state ' + name + ' is already registered, overriding'); + def[name] = state; + } + } + }; + + + //the global state machine is a bit different - so it'll be implemented here + var makeGlobalStateMachine = function (def) { + var currState = null; + var stateChangeFun = function historyStateChangeHandler() { + var historyState = History.getState(); + codeq.globalStateMachine.actualTransition.apply(codeq.globalStateMachine, $.merge([historyState.data.state] ,historyState.data.params)); + }; + History.Adapter.bind(window, 'statechange', stateChangeFun); + //prepare the history state change listener + return { + 'transition': function (name) { + var newState = def[name]; + if (!newState) { + codeq.log.error('Cannot transition to state ' + name + ': it is not defined'); + return; + } + if (newState === currState) { + codeq.log.info('Will not transition between identical states: ' + name); + return; + } + + if(History.getState().data.state === name) codeq.globalStateMachine.actualTransition.apply(codeq.globalStateMachine,Array.prototype.slice.apply(arguments, [0]));//special case which happens if the user refreshes while in the login screen (history state doesn't change because it goes from login to login and the above listener doesn't trigger) + try { + History.pushState({'state': name, 'params': Array.prototype.slice.apply(arguments, [1])}, null, '?s=' + name); + } + catch (e) { + codeq.log.error('init: History.pushState() failed for new state ' + name+'. Error:'+e); + } + }, + 'destroy': function () { + if (currState !== null) currState.exit(); + currState = null; + History.Adapter.unbind(window, 'statechange', stateChangeFun); + }, + 'register': function (name, state) { + if (name in def) codeq.log.error('The state ' + name + ' is already registered, overriding'); + def[name] = state; + }, + 'actualTransition': function (name) { + var newState = def[name];//if the newState is not the same as the old or if it doesn't exist at all is already checked at this point + if (currState) currState.exit(); + currState = newState; + currState.enter.apply(currState, Array.prototype.slice.apply(arguments, [1])); + } + } + }; + codeq.globalStateMachine = makeGlobalStateMachine({}); + + + //setup all the buttons in the banner + $('#navigation-login').on('click', function(e){ + codeq.globalStateMachine.transition('login'); + e.preventDefault();//prevent this since we'll trigger a page reload otherwise + }); + $('#navigation-language').on('click', function(e){ + codeq.globalStateMachine.transition('language'); + e.preventDefault(); + }); + $('#navigation-problem').on('click', function(e){ + codeq.globalStateMachine.transition('problem'); + e.preventDefault(); + }); + $('#navigation-python').on('click', function(e){ + codeq.globalStateMachine.transition('python'); + e.preventDefault(); + }); + $('#navigation-prolog').on('click', function(e){ + codeq.globalStateMachine.transition('prolog'); + e.preventDefault(); + }); +})(); \ No newline at end of file diff --git a/js/codeq/problem.js b/js/codeq/problem.js index 6debf6d..f19cbd4 100644 --- a/js/codeq/problem.js +++ b/js/codeq/problem.js @@ -7,10 +7,26 @@ */ (function(){ + var lastLanguage; codeq.globalStateMachine.register('problem',{ 'enter': function(language){ + if(language)lastLanguage = language; + else language = lastLanguage;//This happens when we hit this with the back button + $('#disabled').css('display', ''); $('#disabled').css('cursor', 'wait'); + + $('#navigation-login').css('display', ''); + /*$('#navigation-login').on('click', function(){ + codeq.globalStateMachine.transition('login'); + });*/ + $('#navigation-language').css('display', ''); + /*$('#navigation-language').on('click', function(){ + codeq.globalStateMachine.transition('language'); + });*/ + $("#navigation-problem").addClass("active"); + $('#navigation-problem').css('display', ''); + codeq.comms.send({'action': 'list_problems', 'language':language}) .then( function success(data) { @@ -99,6 +115,13 @@ $("#problem_group option").remove();//empty the selects $("#problems option").remove(); $("#screen_problem").css('display', 'none'); + + $('#navigation-login').css('display', 'none'); + //$('#navigation-login').off(); + $('#navigation-language').css('display', 'none'); + //$('#navigation-language').off(); + $('#navigation-problem').css('display', 'none'); + $("#navigation-problem").removeClass("active"); } }); })(); \ No newline at end of file diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js index e339fea..d01cc54 100644 --- a/js/codeq/prolog.js +++ b/js/codeq/prolog.js @@ -67,6 +67,12 @@ var prologHandler; //created when we enter the prolog state and destroyed once we leave it codeq.globalStateMachine.register('prolog', { 'enter': function (data) { + $('#navigation-login').css('display', ''); + $('#navigation-language').css('display', ''); + $('#navigation-problem').css('display', ''); + $("#navigation-prolog").addClass("active"); + $('#navigation-prolog').css('display', ''); + jqScreen.css('display', '');//we have to show the screen now so the code editor shows its initial values correctly prologHandler = createPrologHandler(data.data); subScreens = codeq.makeStateMachine(substates); @@ -91,7 +97,13 @@ prologHandler = null; subScreens.destroy(); subScreens = null; - jqScreen.addClass('.block1'); + jqScreen.addClass('block1'); + + $('#navigation-login').css('display', 'none'); + $('#navigation-language').css('display', 'none'); + $('#navigation-problem').css('display', 'none'); + $("#navigation-prolog").removeClass("active"); + $('#navigation-prolog').css('display', 'none'); } }); @@ -327,6 +339,7 @@ return { destroy: function () { + $('#title').text('');//empty the title text jqAllButtons.off(); editor.off('change'); hinter.destroy(); diff --git a/js/codeq/python.js b/js/codeq/python.js index e5b59c2..66f0371 100644 --- a/js/codeq/python.js +++ b/js/codeq/python.js @@ -69,6 +69,12 @@ var pythonHandler; //created when we enter the python state and destroyed once we leave it codeq.globalStateMachine.register('python', { 'enter': function (data) { + $('#navigation-login').css('display', ''); + $('#navigation-language').css('display', ''); + $('#navigation-problem').css('display', ''); + $("#navigation-python").addClass("active"); + $('#navigation-python').css('display', ''); + jqScreen.css('display', '');//we have to show the screen now so the code editor shows its initial values correctly pythonHandler = createPythonHandler(data.data); subScreens = codeq.makeStateMachine(substates); @@ -93,7 +99,13 @@ pythonHandler = null; subScreens.destroy(); subScreens = null; - jqScreen.addClass('.block1'); + jqScreen.addClass('block1'); + + $('#navigation-login').css('display', 'none'); + $('#navigation-language').css('display', 'none'); + $('#navigation-problem').css('display', 'none'); + $("#navigation-python").removeClass("active"); + $('#navigation-python').css('display', 'none'); } }); @@ -268,6 +280,7 @@ return { destroy: function () { + $('#title').text('');//empty the title text jqAllButtons.off(); editor.off('change'); codeq.comms.off('terminal_output'); // stop listening for the terminal events from server diff --git a/js/codeq/stateMachine.js b/js/codeq/stateMachine.js deleted file mode 100644 index dff89d5..0000000 --- a/js/codeq/stateMachine.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Created by robert on 9/15/15. - */ - -codeq.makeStateMachine = function(def){ - var currState = null; - return { - 'transition': function(name){ - var newState = def[name]; - if (!newState) { - codeq.log.error('Cannot transition to state ' + name + ': it is not defined'); - return; - } - if (newState === currState) { - codeq.log.info('Will not transition between identical states: ' + name); - return; - } - if(currState !== null) currState.exit(); - currState = newState; - currState.enter.apply(currState,Array.prototype.slice.apply(arguments,[1])); - }, - 'destroy': function(){ - if(currState !== null) currState.exit(); - currState = null; - }, - 'register': function(name,state){ - if (name in def) codeq.log.error('The state ' + name + ' is already registered, overriding'); - def[name] = state; - } - } -}; -codeq.globalStateMachine = codeq.makeStateMachine({}); \ No newline at end of file diff --git a/js/jquery/jquery.history.js b/js/jquery/jquery.history.js new file mode 100644 index 0000000..8d4edcd --- /dev/null +++ b/js/jquery/jquery.history.js @@ -0,0 +1 @@ +window.JSON||(window.JSON={}),function(){function f(a){return a<10?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c")&&c[0]);return a>4?a:!1}();return a},m.isInternetExplorer=function(){var a=m.isInternetExplorer.cached=typeof m.isInternetExplorer.cached!="undefined"?m.isInternetExplorer.cached:Boolean(m.getInternetExplorerMajorVersion());return a},m.emulated={pushState:!Boolean(a.history&&a.history.pushState&&a.history.replaceState&&!/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(e.userAgent)&&!/AppleWebKit\/5([0-2]|3[0-2])/i.test(e.userAgent)),hashChange:Boolean(!("onhashchange"in a||"onhashchange"in d)||m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8)},m.enabled=!m.emulated.pushState,m.bugs={setHash:Boolean(!m.emulated.pushState&&e.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),safariPoll:Boolean(!m.emulated.pushState&&e.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),ieDoubleCheck:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<7)},m.isEmptyObject=function(a){for(var b in a)return!1;return!0},m.cloneObject=function(a){var b,c;return a?(b=k.stringify(a),c=k.parse(b)):c={},c},m.getRootUrl=function(){var a=d.location.protocol+"//"+(d.location.hostname||d.location.host);if(d.location.port||!1)a+=":"+d.location.port;return a+="/",a},m.getBaseHref=function(){var a=d.getElementsByTagName("base"),b=null,c="";return a.length===1&&(b=a[0],c=b.href.replace(/[^\/]+$/,"")),c=c.replace(/\/+$/,""),c&&(c+="/"),c},m.getBaseUrl=function(){var a=m.getBaseHref()||m.getBasePageUrl()||m.getRootUrl();return a},m.getPageUrl=function(){var a=m.getState(!1,!1),b=(a||{}).url||d.location.href,c;return c=b.replace(/\/+$/,"").replace(/[^\/]+$/,function(a,b,c){return/\./.test(a)?a:a+"/"}),c},m.getBasePageUrl=function(){var a=d.location.href.replace(/[#\?].*/,"").replace(/[^\/]+$/,function(a,b,c){return/[^\/]$/.test(a)?"":a}).replace(/\/+$/,"")+"/";return a},m.getFullUrl=function(a,b){var c=a,d=a.substring(0,1);return b=typeof b=="undefined"?!0:b,/[a-z]+\:\/\//.test(a)||(d==="/"?c=m.getRootUrl()+a.replace(/^\/+/,""):d==="#"?c=m.getPageUrl().replace(/#.*/,"")+a:d==="?"?c=m.getPageUrl().replace(/[\?#].*/,"")+a:b?c=m.getBaseUrl()+a.replace(/^(\.\/)+/,""):c=m.getBasePageUrl()+a.replace(/^(\.\/)+/,"")),c.replace(/\#$/,"")},m.getShortUrl=function(a){var b=a,c=m.getBaseUrl(),d=m.getRootUrl();return m.emulated.pushState&&(b=b.replace(c,"")),b=b.replace(d,"/"),m.isTraditionalAnchor(b)&&(b="./"+b),b=b.replace(/^(\.\/)+/g,"./").replace(/\#$/,""),b},m.store={},m.idToState=m.idToState||{},m.stateToId=m.stateToId||{},m.urlToId=m.urlToId||{},m.storedStates=m.storedStates||[],m.savedStates=m.savedStates||[],m.normalizeStore=function(){m.store.idToState=m.store.idToState||{},m.store.urlToId=m.store.urlToId||{},m.store.stateToId=m.store.stateToId||{}},m.getState=function(a,b){typeof a=="undefined"&&(a=!0),typeof b=="undefined"&&(b=!0);var c=m.getLastSavedState();return!c&&b&&(c=m.createStateObject()),a&&(c=m.cloneObject(c),c.url=c.cleanUrl||c.url),c},m.getIdByState=function(a){var b=m.extractId(a.url),c;if(!b){c=m.getStateString(a);if(typeof m.stateToId[c]!="undefined")b=m.stateToId[c];else if(typeof m.store.stateToId[c]!="undefined")b=m.store.stateToId[c];else{for(;;){b=(new Date).getTime()+String(Math.random()).replace(/\D/g,"");if(typeof m.idToState[b]=="undefined"&&typeof m.store.idToState[b]=="undefined")break}m.stateToId[c]=b,m.idToState[b]=a}}return b},m.normalizeState=function(a){var b,c;if(!a||typeof a!="object")a={};if(typeof a.normalized!="undefined")return a;if(!a.data||typeof a.data!="object")a.data={};b={},b.normalized=!0,b.title=a.title||"",b.url=m.getFullUrl(m.unescapeString(a.url||d.location.href)),b.hash=m.getShortUrl(b.url),b.data=m.cloneObject(a.data),b.id=m.getIdByState(b),b.cleanUrl=b.url.replace(/\??\&_suid.*/,""),b.url=b.cleanUrl,c=!m.isEmptyObject(b.data);if(b.title||c)b.hash=m.getShortUrl(b.url).replace(/\??\&_suid.*/,""),/\?/.test(b.hash)||(b.hash+="?"),b.hash+="&_suid="+b.id;return b.hashedUrl=m.getFullUrl(b.hash),(m.emulated.pushState||m.bugs.safariPoll)&&m.hasUrlDuplicate(b)&&(b.url=b.hashedUrl),b},m.createStateObject=function(a,b,c){var d={data:a,title:b,url:c};return d=m.normalizeState(d),d},m.getStateById=function(a){a=String(a);var c=m.idToState[a]||m.store.idToState[a]||b;return c},m.getStateString=function(a){var b,c,d;return b=m.normalizeState(a),c={data:b.data,title:a.title,url:a.url},d=k.stringify(c),d},m.getStateId=function(a){var b,c;return b=m.normalizeState(a),c=b.id,c},m.getHashByState=function(a){var b,c;return b=m.normalizeState(a),c=b.hash,c},m.extractId=function(a){var b,c,d;return c=/(.*)\&_suid=([0-9]+)$/.exec(a),d=c?c[1]||a:a,b=c?String(c[2]||""):"",b||!1},m.isTraditionalAnchor=function(a){var b=!/[\/\?\.]/.test(a);return b},m.extractState=function(a,b){var c=null,d,e;return b=b||!1,d=m.extractId(a),d&&(c=m.getStateById(d)),c||(e=m.getFullUrl(a),d=m.getIdByUrl(e)||!1,d&&(c=m.getStateById(d)),!c&&b&&!m.isTraditionalAnchor(a)&&(c=m.createStateObject(null,null,e))),c},m.getIdByUrl=function(a){var c=m.urlToId[a]||m.store.urlToId[a]||b;return c},m.getLastSavedState=function(){return m.savedStates[m.savedStates.length-1]||b},m.getLastStoredState=function(){return m.storedStates[m.storedStates.length-1]||b},m.hasUrlDuplicate=function(a){var b=!1,c;return c=m.extractState(a.url),b=c&&c.id!==a.id,b},m.storeState=function(a){return m.urlToId[a.url]=a.id,m.storedStates.push(m.cloneObject(a)),a},m.isLastSavedState=function(a){var b=!1,c,d,e;return m.savedStates.length&&(c=a.id,d=m.getLastSavedState(),e=d.id,b=c===e),b},m.saveState=function(a){return m.isLastSavedState(a)?!1:(m.savedStates.push(m.cloneObject(a)),!0)},m.getStateByIndex=function(a){var b=null;return typeof a=="undefined"?b=m.savedStates[m.savedStates.length-1]:a<0?b=m.savedStates[m.savedStates.length+a]:b=m.savedStates[a],b},m.getHash=function(){var a=m.unescapeHash(d.location.hash);return a},m.unescapeString=function(b){var c=b,d;for(;;){d=a.unescape(c);if(d===c)break;c=d}return c},m.unescapeHash=function(a){var b=m.normalizeHash(a);return b=m.unescapeString(b),b},m.normalizeHash=function(a){var b=a.replace(/[^#]*#/,"").replace(/#.*/,"");return b},m.setHash=function(a,b){var c,e,f;return b!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.setHash,args:arguments,queue:b}),!1):(c=m.escapeHash(a),m.busy(!0),e=m.extractState(a,!0),e&&!m.emulated.pushState?m.pushState(e.data,e.title,e.url,!1):d.location.hash!==c&&(m.bugs.setHash?(f=m.getPageUrl(),m.pushState(null,null,f+"#"+c,!1)):d.location.hash=c),m)},m.escapeHash=function(b){var c=m.normalizeHash(b);return c=a.escape(c),m.bugs.hashEscape||(c=c.replace(/\%21/g,"!").replace(/\%26/g,"&").replace(/\%3D/g,"=").replace(/\%3F/g,"?")),c},m.getHashByUrl=function(a){var b=String(a).replace(/([^#]*)#?([^#]*)#?(.*)/,"$2");return b=m.unescapeHash(b),b},m.setTitle=function(a){var b=a.title,c;b||(c=m.getStateByIndex(0),c&&c.url===a.url&&(b=c.title||m.options.initialTitle));try{d.getElementsByTagName("title")[0].innerHTML=b.replace("<","<").replace(">",">").replace(" & "," & ")}catch(e){}return d.title=b,m},m.queues=[],m.busy=function(a){typeof a!="undefined"?m.busy.flag=a:typeof m.busy.flag=="undefined"&&(m.busy.flag=!1);if(!m.busy.flag){h(m.busy.timeout);var b=function(){var a,c,d;if(m.busy.flag)return;for(a=m.queues.length-1;a>=0;--a){c=m.queues[a];if(c.length===0)continue;d=c.shift(),m.fireQueueItem(d),m.busy.timeout=g(b,m.options.busyDelay)}};m.busy.timeout=g(b,m.options.busyDelay)}return m.busy.flag},m.busy.flag=!1,m.fireQueueItem=function(a){return a.callback.apply(a.scope||m,a.args||[])},m.pushQueue=function(a){return m.queues[a.queue||0]=m.queues[a.queue||0]||[],m.queues[a.queue||0].push(a),m},m.queue=function(a,b){return typeof a=="function"&&(a={callback:a}),typeof b!="undefined"&&(a.queue=b),m.busy()?m.pushQueue(a):m.fireQueueItem(a),m},m.clearQueue=function(){return m.busy.flag=!1,m.queues=[],m},m.stateChanged=!1,m.doubleChecker=!1,m.doubleCheckComplete=function(){return m.stateChanged=!0,m.doubleCheckClear(),m},m.doubleCheckClear=function(){return m.doubleChecker&&(h(m.doubleChecker),m.doubleChecker=!1),m},m.doubleCheck=function(a){return m.stateChanged=!1,m.doubleCheckClear(),m.bugs.ieDoubleCheck&&(m.doubleChecker=g(function(){return m.doubleCheckClear(),m.stateChanged||a(),!0},m.options.doubleCheckInterval)),m},m.safariStatePoll=function(){var b=m.extractState(d.location.href),c;if(!m.isLastSavedState(b))c=b;else return;return c||(c=m.createStateObject()),m.Adapter.trigger(a,"popstate"),m},m.back=function(a){return a!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.back,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.back(!1)}),n.go(-1),!0)},m.forward=function(a){return a!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.forward,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.forward(!1)}),n.go(1),!0)},m.go=function(a,b){var c;if(a>0)for(c=1;c<=a;++c)m.forward(b);else{if(!(a<0))throw new Error("History.go: History.go requires a positive or negative integer passed.");for(c=-1;c>=a;--c)m.back(b)}return m};if(m.emulated.pushState){var o=function(){};m.pushState=m.pushState||o,m.replaceState=m.replaceState||o}else m.onPopState=function(b,c){var e=!1,f=!1,g,h;return m.doubleCheckComplete(),g=m.getHash(),g?(h=m.extractState(g||d.location.href,!0),h?m.replaceState(h.data,h.title,h.url,!1):(m.Adapter.trigger(a,"anchorchange"),m.busy(!1)),m.expectedStateId=!1,!1):(e=m.Adapter.extractEventData("state",b,c)||!1,e?f=m.getStateById(e):m.expectedStateId?f=m.getStateById(m.expectedStateId):f=m.extractState(d.location.href),f||(f=m.createStateObject(null,null,d.location.href)),m.expectedStateId=!1,m.isLastSavedState(f)?(m.busy(!1),!1):(m.storeState(f),m.saveState(f),m.setTitle(f),m.Adapter.trigger(a,"statechange"),m.busy(!1),!0))},m.Adapter.bind(a,"popstate",m.onPopState),m.pushState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(e!==!1&&m.busy())return m.pushQueue({scope:m,callback:m.pushState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.pushState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0},m.replaceState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(e!==!1&&m.busy())return m.pushQueue({scope:m,callback:m.replaceState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.replaceState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0};if(f){try{m.store=k.parse(f.getItem("History.store"))||{}}catch(p){m.store={}}m.normalizeStore()}else m.store={},m.normalizeStore();m.Adapter.bind(a,"beforeunload",m.clearAllIntervals),m.Adapter.bind(a,"unload",m.clearAllIntervals),m.saveState(m.storeState(m.extractState(d.location.href,!0))),f&&(m.onUnload=function(){var a,b;try{a=k.parse(f.getItem("History.store"))||{}}catch(c){a={}}a.idToState=a.idToState||{},a.urlToId=a.urlToId||{},a.stateToId=a.stateToId||{};for(b in m.idToState){if(!m.idToState.hasOwnProperty(b))continue;a.idToState[b]=m.idToState[b]}for(b in m.urlToId){if(!m.urlToId.hasOwnProperty(b))continue;a.urlToId[b]=m.urlToId[b]}for(b in m.stateToId){if(!m.stateToId.hasOwnProperty(b))continue;a.stateToId[b]=m.stateToId[b]}m.store=a,m.normalizeStore(),f.setItem("History.store",k.stringify(a))},m.intervalList.push(i(m.onUnload,m.options.storeInterval)),m.Adapter.bind(a,"beforeunload",m.onUnload),m.Adapter.bind(a,"unload",m.onUnload));if(!m.emulated.pushState){m.bugs.safariPoll&&m.intervalList.push(i(m.safariStatePoll,m.options.safariPollInterval));if(e.vendor==="Apple Computer, Inc."||(e.appCodeName||"")==="Mozilla")m.Adapter.bind(a,"hashchange",function(){m.Adapter.trigger(a,"popstate")}),m.getHash()&&m.Adapter.onDomLoad(function(){m.Adapter.trigger(a,"hashchange")})}},m.init()}(window) \ No newline at end of file -- cgit v1.2.1