function Subscriber() { // some application vars var i=0, displayDiv = document.getElementById("currentState"); // the sole public method to manipulate this application this.loadNextBookmark = function(z) { // update display content displayDiv.innerHTML = displayDiv.innerHTML+i+":"+z+"
"; // do the stuff that changes the state i++; // set the new history hash unFocus.History.addHistory(z); }; // create history listener this.historyListener = function(historyHash) { //i=historyHash; // update display content //displayDiv.innerHTML = displayDiv.innerHTML+i+":"+historyHash+"
"; // update document title //document.title = "unFocus History Keeper - Current History: " + historyHash; var historyLocation = historyHash.split(":"); var el = document.getElementById(historyLocation[1]); var elTab = document.getElementById(historyLocation[1]+"Tab"); //need to keep track of how many history actions since page refresh if(historyLocation[0] == "select") { jslog.warning("select "+historyLocation[1]+" with title "+historyLocation[2]); if(el){ //hide all contentboxes but the one passed to the function hideContent(historyLocation[1]); //remove selected class from all other tabs removeSelected(); } } if(historyLocation[0] == "create") { jslog.warning("make "+historyLocation[1]+" with title "+historyLocation[2]); makeTab(historyLocation[1], historyLocation[3].substr(5, historyLocation[3].length), historyLocation[2]); } if(historyLocation[0] == "remove") { jslog.warning("remove "+historyLocation[1]); if($(el) && $(elTab)){ $(el).parentNode.removeChild($(el)); $(elTab).parentNode.removeChild($(elTab)); } } }; // add the listener to unFocus.History unFocus.History.addEventListener('historyChange', this.historyListener); // do initialization this.historyListener(unFocus.History.getCurrent()); }; function loadHistory() { // instantiate and inialize the app var jsHistory = new Subscriber(); };