pagestate system, updated system reference

This commit is contained in:
Ulf Gebhardt 2014-06-23 19:38:10 +02:00
parent ff8a8f5fe9
commit b9e7cb2cbf
3 changed files with 47 additions and 24 deletions

View File

@ -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) {
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']){
this.statedef = data['result'];
newps = data['result'];
console.log('SYSTEM: loaded Pagestates');
result = true;
} else {
alert("Problem with the statedef");}
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 (){

View File

@ -40,7 +40,7 @@
<a class="dwarf human fadein info" info="class_paladin" cclass="paladin" href="#" style="padding-left:30px;"><img src="${WOWICONS}paladin.png" /></a>
</div>
<div class="lifecraft link-color" id="details_info" style="float: left; margin-top: 15px; width: 190px; height: 300px; overflow-y: hidden; padding: 8px; font-size: 14px; background: url(${PICPATH}infotext_background.png) no-repeat;">
<h3 style="padding-left: 20px;"><img src="${WOWICONS}help_questionmark.png" width="25px"/>&nbsp;&nbsp;Info</h3>
<h3><img src="${WOWICONS}help_questionmark.png" width="25px"/>&nbsp;&nbsp;Info</h3>
<div id="info_content">${infotext_default}</div>
</div>
<div class="clear"></div>

2
system

@ -1 +1 @@
Subproject commit 51b7c6857ae7efbfdb4652652db527368332308c
Subproject commit b196e1cb7a403e4fabefc8ae686e6597b3f3eee5