From b9e7cb2cbfdacecd9e61d65a3a0577867c471962 Mon Sep 17 00:00:00 2001 From: rylon Date: Mon, 23 Jun 2014 19:38:10 +0200 Subject: [PATCH] pagestate system, updated system reference --- mojotrollz/page/default_page/js/wizard.js | 67 +++++++++++++++------- mojotrollz/page/wizard_details/details.tpl | 2 +- system | 2 +- 3 files changed, 47 insertions(+), 24 deletions(-) diff --git a/mojotrollz/page/default_page/js/wizard.js b/mojotrollz/page/default_page/js/wizard.js index 110239e..c9fc3c4 100644 --- a/mojotrollz/page/default_page/js/wizard.js +++ b/mojotrollz/page/default_page/js/wizard.js @@ -33,35 +33,53 @@ person.speak(); // alerts "Howdy, my name is Bob" */ -function SYSTEM(endpoint){ +function SYSTEM(endpoint, group){ this.endpoint = endpoint; - this.statedef = null; + this.group = group; + this.pagestates = null; } -SYSTEM.prototype.load_statedef = function(){ - if(!this.statedef){ - $.getJSON(this.endpoint+'?call=statedef', function (data) { - if(data['status']){ - this.statedef = data['result']; - } else { - alert("Problem with the statedef");} +SYSTEM.prototype.load_pagestates = function(){ + result = false; + newps = null; + if(!this.pagestates){ + $.ajax({ + async: false, + dataType: "json", + url: this.endpoint+'?call=pagestates&group='+this.group, + data: {}, + success: function (data) { + if(data['status']){ + newps = data['result']; + console.log('SYSTEM: loaded Pagestates'); + result = true; + } else { + console.log('SYSTEM: Problem with your Pagestates.'); + result = false;} + } }); } -} + this.pagestates = newps; + return result; +}; SYSTEM.prototype.load = function(id){ - this.load_statedef(); + if(!this.load_pagestates()){ + console.log(id+'2'); + return false;} var push = true; - this.statedef.forEach(function(entry) { - if(entry['id'] == id){ + this.pagestates.forEach(function(entry) { + console.log(entry); + if(entry['id'] === id){ if(push){ - window.history.pushState(null, "", id); + window.history.pushState(null, "", '#'+id); push = false;} - var fn = window[settings.entry['function']]; + var fn = window[entry['func']]; if(typeof fn !== 'function') { fn = null;} $(entry['div']).load(entry['url'],fn); } }); -} + return push ? false : true; +}; SYSTEM.prototype.cur_state = function() { var pathName = window.location.pathname, @@ -77,6 +95,16 @@ SYSTEM.prototype.cur_state = function() { } $(document).ready(function() { + register_login(); + $('#start a').click(function() { + load_wizard_details();}); + load_visualisation('mojopulse'); + + sys = new SYSTEM('./api.php',1); + sys.load('default'); +}); + +function register_login(){ $("#login_form input").not("[type=submit]").jqBootstrapValidation({ preventSubmit: true, submitError: function($form, event, errors) {}, @@ -96,12 +124,7 @@ $(document).ready(function() { event.preventDefault(); } }); - - $('#start a').click(function() { - load_wizard_details();}); - - load_visualisation('mojopulse'); -}); +} function load_wizard_details(){ $('#frame_content').load('?action=wizard_details', function (){ diff --git a/mojotrollz/page/wizard_details/details.tpl b/mojotrollz/page/wizard_details/details.tpl index ef09a35..cafefff 100644 --- a/mojotrollz/page/wizard_details/details.tpl +++ b/mojotrollz/page/wizard_details/details.tpl @@ -40,7 +40,7 @@
diff --git a/system b/system index 51b7c68..b196e1c 160000 --- a/system +++ b/system @@ -1 +1 @@ -Subproject commit 51b7c6857ae7efbfdb4652652db527368332308c +Subproject commit b196e1cb7a403e4fabefc8ae686e6597b3f3eee5