state js/css ideas(wrong ideas)
This commit is contained in:
parent
548040ec3c
commit
4550496102
@ -14,6 +14,10 @@ class api_system extends api_login{
|
|||||||
|
|
||||||
public static function call_pagestates($group){
|
public static function call_pagestates($group){
|
||||||
return \SYSTEM\PAGE\State::get($group);}
|
return \SYSTEM\PAGE\State::get($group);}
|
||||||
|
public static function call_pagestates_flag_js($group){
|
||||||
|
return \SYSTEM\PAGE\State::get_js($group);}
|
||||||
|
public static function call_pagestates_flag_css($group){
|
||||||
|
return \SYSTEM\PAGE\State::get_css($group);}
|
||||||
|
|
||||||
public static function static__lang($lang){
|
public static function static__lang($lang){
|
||||||
\SYSTEM\locale::set($lang);}
|
\SYSTEM\locale::set($lang);}
|
||||||
|
|||||||
@ -22,6 +22,10 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
|
|||||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (40, 42, 2, 10, 'text', 'request', 'STRING');
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (40, 42, 2, 10, 'text', 'request', 'STRING');
|
||||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (41, 42, 2, 40, 'text', 'lang', 'LANG');
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (41, 42, 2, 40, 'text', 'lang', 'LANG');
|
||||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (50, 42, 2, 10, 'pagestates', 'group', 'UINT');
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (50, 42, 2, 10, 'pagestates', 'group', 'UINT');
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (51, 42, 1, 50, NULL, 'js', NULL);
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (52, 42, 2, 51, NULL, 'group', 'UINT');
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (55, 42, 1, 50, NULL, 'css', NULL);
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (56, 42, 2, 55, NULL, 'group', 'UINT');
|
||||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (90, 42, 4, -1, NULL, '_lang', 'LANG');
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (90, 42, 4, -1, NULL, '_lang', 'LANG');
|
||||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (91, 42, 4, -1, NULL, '_result', 'RESULT');
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (91, 42, 4, -1, NULL, '_result', 'RESULT');
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,10 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
|
|||||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (41, 0, 2, 10, 'text', 'lang', 'LANG');
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (41, 0, 2, 10, 'text', 'lang', 'LANG');
|
||||||
|
|
||||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (50, 0, 2, 10, 'pagestates', 'group', 'UINT');
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (50, 0, 2, 10, 'pagestates', 'group', 'UINT');
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (51, 0, 1, 50, NULL, 'js', NULL);
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (52, 0, 2, 50, NULL, 'group', 'UINT');
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (55, 0, 1, 50, NULL, 'css', NULL);
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (56, 0, 2, 55, NULL, 'group', 'UINT');
|
||||||
|
|
||||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (90, 42, 4, -1, NULL, '_lang', 'LANG');
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (90, 42, 4, -1, NULL, '_lang', 'LANG');
|
||||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (91, 42, 4, -1, NULL, '_result', 'RESULT');
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (91, 42, 4, -1, NULL, '_result', 'RESULT');
|
||||||
@ -1,2 +1,2 @@
|
|||||||
<?php
|
<?php
|
||||||
\SYSTEM\FILES\files::registerFolder(dirname(__FILE__).'/sys_js','sys_js');
|
\SYSTEM\FILES\files::registerFolder(dirname(__FILE__).'/sys_js/','sys_js');
|
||||||
74
files/sys_js/system.js
Normal file
74
files/sys_js/system.js
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
//mother object
|
||||||
|
function SYSTEM(endpoint, group){
|
||||||
|
this.endpoint = endpoint;
|
||||||
|
this.group = group;
|
||||||
|
this.pagestates = null;
|
||||||
|
}
|
||||||
|
//internal function to handle pagestate result
|
||||||
|
SYSTEM.prototype.handle_call_pagestates = 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;}
|
||||||
|
}
|
||||||
|
//send a call to the endpoint
|
||||||
|
SYSTEM.prototype.call = function(call,success,data,data_type,async){
|
||||||
|
$.ajax({
|
||||||
|
async: async,
|
||||||
|
data: data,
|
||||||
|
dataType: data_type,
|
||||||
|
url: this.endpoint+'?'+call,
|
||||||
|
success: success,
|
||||||
|
error: function(XMLHttpRequest, textStatus, errorThrown){console.log(call);}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//get the pagestates and save em
|
||||||
|
SYSTEM.prototype.load_pagestates = function(){
|
||||||
|
result = false;
|
||||||
|
newps = this.pagestates;
|
||||||
|
if(!this.pagestates){
|
||||||
|
this.call('call=pagestates&group='+this.group,this.handle_call_pagestates,{},"json",false);
|
||||||
|
} else { result = true;}
|
||||||
|
this.pagestates = newps;
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
//load a pagestatewith given id
|
||||||
|
SYSTEM.prototype.load = function(id){
|
||||||
|
console.log('Load Pagestate: '+id);
|
||||||
|
if(!this.load_pagestates()){
|
||||||
|
return false;}
|
||||||
|
var push = true;
|
||||||
|
this.pagestates.forEach(function(entry) {
|
||||||
|
if(entry['id'] === id){
|
||||||
|
if(push){
|
||||||
|
window.history.pushState(null, "", '#'+id);
|
||||||
|
push = false;}
|
||||||
|
$.ajax({
|
||||||
|
async: false,
|
||||||
|
data: {},
|
||||||
|
dataType: 'html',
|
||||||
|
url: entry['url'],
|
||||||
|
success: function(data){$(entry['div']).html(data); var fn = window[entry['func']]; if(typeof fn === 'function'){fn()};},
|
||||||
|
error: function(XMLHttpRequest, textStatus, errorThrown){console.log(errorThrown);}
|
||||||
|
});
|
||||||
|
//$(entry['div']).load(entry['url'],fn);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return push ? false : true;
|
||||||
|
};
|
||||||
|
//what?
|
||||||
|
SYSTEM.prototype.cur_state = function() {
|
||||||
|
var pathName = window.location.href;
|
||||||
|
if (pathName.indexOf('#') != -1) {
|
||||||
|
return pathName.split('#').pop();}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
SYSTEM.prototype.go_state = function(default_state){
|
||||||
|
pageName = this.cur_state();
|
||||||
|
this.load(pageName ? pageName : default_state);
|
||||||
|
}
|
||||||
@ -4,4 +4,6 @@ namespace SYSTEM\PAGE;
|
|||||||
|
|
||||||
abstract class Page {
|
abstract class Page {
|
||||||
abstract public function html();
|
abstract public function html();
|
||||||
|
//abstract public function js();
|
||||||
|
//abstract public function css();
|
||||||
}
|
}
|
||||||
@ -4,4 +4,10 @@ namespace SYSTEM\PAGE;
|
|||||||
class State {
|
class State {
|
||||||
public static function get($group){
|
public static function get($group){
|
||||||
return \SYSTEM\LOG\JsonResult::toString(\SYSTEM\DBD\SYS_PAGESTATES_GROUP::QA(array($group)));}
|
return \SYSTEM\LOG\JsonResult::toString(\SYSTEM\DBD\SYS_PAGESTATES_GROUP::QA(array($group)));}
|
||||||
|
public static function get_js($group){
|
||||||
|
|
||||||
|
}
|
||||||
|
public static function get_css($group){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -27,6 +27,9 @@ class HEADER {
|
|||||||
public static function GIF(){
|
public static function GIF(){
|
||||||
if(self::checkHeader()){
|
if(self::checkHeader()){
|
||||||
header('content-type:image/gif;');}}
|
header('content-type:image/gif;');}}
|
||||||
|
public static function JS(){
|
||||||
|
if(self::checkHeader()){
|
||||||
|
header('content-type:application/javascript;');}}
|
||||||
|
|
||||||
public static function FILE($filename){
|
public static function FILE($filename){
|
||||||
header("Content-type: application/octet-stream");
|
header("Content-type: application/octet-stream");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user