From e8f9e94749fa5022ffab56d5001bfe2db54bf72c Mon Sep 17 00:00:00 2001 From: mrdrogdrog <tilman.vatteroth@udo.edu> Date: Wed, 30 Sep 2015 20:06:45 +0200 Subject: [PATCH] =?UTF-8?q?=C3=84nderungen=20am=20Less-Compiler=20um=20Dat?= =?UTF-8?q?ei-Einbindung=20zu=20korrieren=20ConfigurationComponent.php=20e?= =?UTF-8?q?ntfernt.=20Warum=20war=20die=20noch=20da=20O.o=20Stylesheets=20?= =?UTF-8?q?werden=20=C3=BCber=20link=20geladen=20anstatt=20per=20style-blo?= =?UTF-8?q?ck?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ajax/ConfigurationComponent.php | 58 --------------------------------- config/config.php | 2 +- index.html | 1 - js/panelAPI.js | 34 +++++++++++-------- less/style.php | 4 +-- 5 files changed, 23 insertions(+), 76 deletions(-) delete mode 100755 ajax/ConfigurationComponent.php diff --git a/ajax/ConfigurationComponent.php b/ajax/ConfigurationComponent.php deleted file mode 100755 index 0df7bb1..0000000 --- a/ajax/ConfigurationComponent.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php - - namespace App\Controller\Component; - - use Cake\Controller\Component; - use Cake\Filesystem\File; - - class ConfigurationComponent extends Component { - - private $session = NULL; - private $folder = null; - - public function initialize(array $config) { - $this->session = $this->request->session(); - } - - public function getConfiguration($session_key, $config_name = '', $config_type = 'panel') { - if (!is_string($session_key) - || !is_string($config_name) - || !is_string($config_type) - || empty($session_key)) { - return FALSE; - } - // load data from session or reload data to session? - /* if ($this->session->check($session_key)) { - // return configuration - return $this->session->read($session_key); - } else {*/ - // reload configuration - return $this->getReloadedConfiguration($session_key, $config_name, $config_type); - // } - } - - public function getReloadedConfiguration($session_key, $config_name = '', $config_type = 'panel') { - if (!is_string($session_key) - || !is_string($config_name) - || !is_string($config_type) - || (strpos($config_type, "..")) - || empty($config_name) - || empty($session_key)) { - return FALSE; - } - // get filename for configuration - $file = new File(ROOT.'/config/'.$config_type.'/'.$config_name.'.json'); - // can we get our configuration? - if ($file->exists() && $file->readable() - && !(($file_content = $file->read()) === false)) { - // decode, save and return configuration - $result = json_decode($file_content,true); - $this->session->write($session_key, $result); - return $result; - } else { - // ERROR! - return FALSE; - } - } - - } diff --git a/config/config.php b/config/config.php index 02f58f3..163f2a6 100644 --- a/config/config.php +++ b/config/config.php @@ -1,3 +1,3 @@ <?php -const ROOT_DIR="/"; +const ROOT_DIR="/infoscreen"; ?> diff --git a/index.html b/index.html index 5661ca3..2888bf7 100755 --- a/index.html +++ b/index.html @@ -13,7 +13,6 @@ <script type="text/javascript" src="js/marquee.js"></script> <script type="text/javascript" src="js/panelAPI.js"></script> <script type="text/javascript" src="js/webfontloader.js"></script> - <script type="text/javascript" src="js/loader.js"></script> <script type="text/javascript" src="js/starter.js"></script> </head> <body> diff --git a/js/panelAPI.js b/js/panelAPI.js index 245da40..300427d 100755 --- a/js/panelAPI.js +++ b/js/panelAPI.js @@ -34,11 +34,10 @@ layout.processLayout = function(json, container) { } layout.insertTemplate = function(name, panel) { - var tmp = null; - for (ti in layout.templates) { - if (layout.templates[ti].name == name) + for (var tmp in layout.templates) { + if (layout.templates[tmp].name == name) { - layout.templates[ti].panels.push(panel); + layout.templates[tmp].panels.push(panel); return; } @@ -65,10 +64,6 @@ layout.insertTemplate = function(name, panel) { doStuff = null; } - if (e.css!=null) { - t.css = $("<style>").attr("type","text/css").attr("data-template",t.name).text(e.css); - $("body").append(t.css); - } t.template = $.parseHTML(e.template); for (p in t.panels) { @@ -99,14 +94,27 @@ layout.insertTemplate = function(name, panel) { layout.error("get fail of template " + n ); }); - $.get("panels/" + n + "/style.less", function(k) { - console.log("get success of style " + n) + + t.css = $("<link>").attr("rel","stylesheet").attr("href", "panels/" + n + "/style.less").attr("data-template",t.name); + + + t.css.on("load",function() { + console.log("get success of style " + n); + e.css= t.css; + doMore(); + }); + + + /*.fail(function() { + layout.error("get fail of style " + n); + });*/ + + $("head").append(t.css); + /*$.get("panels/" + n + "/style.less", function(k) { e.css=k; doMore(); },"text") - .fail(function() { - layout.error("get fail of style " + n); - }); + */ $.get("panels/" + n + "/script.js", function(k){ diff --git a/less/style.php b/less/style.php index 2dc8a02..ca41f72 100644 --- a/less/style.php +++ b/less/style.php @@ -53,7 +53,7 @@ if (!file_exists($cache_file)) { $parser->parse(" [data-template=$panel] { @import \"$less_file\"; - }"); + }", "/panels/$panel"); } $content = $parser->getCss(); }catch(Exception $e) { @@ -76,5 +76,3 @@ if ($debug) { header("Location: ".ROOT_DIR."/$cache_file"); } - -?> -- GitLab