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 @@