|
From: <ma...@us...> - 2013-02-02 14:06:01
|
Revision: 1386
http://openautomation.svn.sourceforge.net/openautomation/?rev=1386&view=rev
Author: mayerch
Date: 2013-02-02 14:05:53 +0000 (Sat, 02 Feb 2013)
Log Message:
-----------
First step at forcing a way around the browser cache
Modified Paths:
--------------
CometVisu/trunk/visu/index.html
CometVisu/trunk/visu/lib/compatibility.js
CometVisu/trunk/visu/lib/templateengine.js
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
Modified: CometVisu/trunk/visu/index.html
===================================================================
--- CometVisu/trunk/visu/index.html 2013-02-02 09:14:06 UTC (rev 1385)
+++ CometVisu/trunk/visu/index.html 2013-02-02 14:05:53 UTC (rev 1386)
@@ -13,50 +13,52 @@
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0; webkit-user-select: none;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
-
<script src="dependencies/jquery.js" type="text/javascript"></script>
<script src="lib/compatibility.js" type="text/javascript"></script>
- <script src="dependencies/jquery-ui.js" type="text/javascript"></script>
- <script src="dependencies/strftime.js" type="text/javascript"></script>
- <script src="dependencies/scrollable.js" type="text/javascript"></script>
- <script src="dependencies/jquery.ui.touch-punch.js" type="text/javascript"></script>
- <script src="dependencies/jquery.svg.min.js" type="text/javascript"></script>
- <script src="lib/cometvisu-client.js" type="text/javascript"></script>
- <script src="lib/iconhandler.js" type="text/javascript"></script>
- <!-- Load the widgets: start -->
- <script src="structure/pure/_common.js" type="text/javascript"></script>
- <script src="structure/pure/break.js" type="text/javascript"></script>
- <script src="structure/pure/group.js" type="text/javascript"></script>
- <script src="structure/pure/rgb.js" type="text/javascript"></script>
- <script src="structure/pure/web.js" type="text/javascript"></script>
- <script src="structure/pure/image.js" type="text/javascript"></script>
- <script src="structure/pure/imagetrigger.js" type="text/javascript"></script>
- <script src="structure/pure/include.js" type="text/javascript"></script>
- <script src="structure/pure/info.js" type="text/javascript"></script>
- <script src="structure/pure/infotrigger.js" type="text/javascript"></script>
- <script src="structure/pure/line.js" type="text/javascript"></script>
- <script src="structure/pure/multitrigger.js" type="text/javascript"></script>
- <script src="structure/pure/navbar.js" type="text/javascript"></script>
- <script src="structure/pure/page.js" type="text/javascript"></script>
- <script src="structure/pure/pagejump.js" type="text/javascript"></script>
- <script src="structure/pure/slide.js" type="text/javascript"></script>
- <script src="structure/pure/switch.js" type="text/javascript"></script>
- <script src="structure/pure/text.js" type="text/javascript"></script>
- <script src="structure/pure/toggle.js" type="text/javascript"></script>
- <script src="structure/pure/trigger.js" type="text/javascript"></script>
- <script src="structure/pure/urltrigger.js" type="text/javascript"></script>
- <script src="structure/pure/unknown.js" type="text/javascript"></script>
- <script src="structure/pure/video.js" type="text/javascript"></script>
- <script src="structure/pure/wgplugin_info.js" type="text/javascript"></script>
- <script src="designs/structure_custom.js" type="text/javascript"></script>
- <!-- Load the widgets: end -->
- <script src="lib/templateengine.js" type="text/javascript"></script>
- <script src="transforms/transform_default.js" type="text/javascript"></script>
- <script src="transforms/transform_knx.js" type="text/javascript"></script>
- <script src="transforms/transform_oh.js" type="text/javascript"></script>
- <script src="dependencies/Three.js" type="text/javascript"></script>
- <script src="dependencies/poly2tri.js" type="text/javascript"></script>
- <script src="dependencies/jsfloorplan.js" type="text/javascript"></script>
+ <script type="text/javascript">
+ $.ajaxSetup({ crossDomain: true }); // make scripts debugable
+ $.getOrderedScripts([
+ "dependencies/jquery-ui.js",
+ "dependencies/strftime.js",
+ "dependencies/scrollable.js",
+ "dependencies/jquery.ui.touch-punch.js",
+ "dependencies/jquery.svg.min.js",
+ "lib/cometvisu-client.js",
+ "lib/iconhandler.js",
+ "structure/pure/_common.js",
+ "structure/pure/break.js",
+ "structure/pure/group.js",
+ "structure/pure/rgb.js",
+ "structure/pure/web.js",
+ "structure/pure/image.js",
+ "structure/pure/imagetrigger.js",
+ "structure/pure/include.js",
+ "structure/pure/info.js",
+ "structure/pure/infotrigger.js",
+ "structure/pure/line.js",
+ "structure/pure/multitrigger.js",
+ "structure/pure/navbar.js",
+ "structure/pure/page.js",
+ "structure/pure/pagejump.js",
+ "structure/pure/slide.js",
+ "structure/pure/switch.js",
+ "structure/pure/text.js",
+ "structure/pure/toggle.js",
+ "structure/pure/trigger.js",
+ "structure/pure/urltrigger.js",
+ "structure/pure/unknown.js",
+ "structure/pure/video.js",
+ "structure/pure/wgplugin_info.js",
+ "designs/structure_custom.js",
+ "lib/templateengine.js",
+ "transforms/transform_default.js",
+ "transforms/transform_knx.js",
+ "transforms/transform_oh.js",
+ "dependencies/Three.js",
+ "dependencies/poly2tri.js",
+ "dependencies/jsfloorplan.js"
+ ]);
+ </script>
<style type="text/css">
.loading { display: none; }
</style>
Modified: CometVisu/trunk/visu/lib/compatibility.js
===================================================================
--- CometVisu/trunk/visu/lib/compatibility.js 2013-02-02 09:14:06 UTC (rev 1385)
+++ CometVisu/trunk/visu/lib/compatibility.js 2013-02-02 14:05:53 UTC (rev 1386)
@@ -153,5 +153,15 @@
},
getUrlVar: function(name){
return $.getUrlVars()[name];
+ },
+ // heavily inspired by: http://stackoverflow.com/questions/13066712/how-to-load-a-list-of-javascript-files-and-call-a-callback-after-all-of-them-are
+ getOrderedScripts: function(files, callback) {
+ if( 'object' === typeof files && 0 == files.length && callback )
+ callback();
+ else
+ $.getScript( files.shift(), files.length
+ ? function(){ $.getOrderedScripts(files, callback);}
+ : callback
+ );
}
});
\ No newline at end of file
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2013-02-02 09:14:06 UTC (rev 1385)
+++ CometVisu/trunk/visu/lib/templateengine.js 2013-02-02 14:05:53 UTC (rev 1386)
@@ -44,6 +44,8 @@
function TemplateEngine() {
var thisTemplateEngine = this;
+ this.pageReady = false;
+ this.pluginsReady = false;
this.design = new VisuDesign_Custom();
this.pagePartsHandler = new PagePartsHandler();
@@ -204,7 +206,7 @@
var widthNavbarLeft = $('#navbarLeft').css('display') != 'none' ? $('#navbarLeft').width() : 0;
var widthNavbarRight = $('#navbarRight').css('display') != 'none' ? $('#navbarRight').width() : 0;
var width = $('body').width() - widthNavbarLeft - widthNavbarRight - 1; // remove an additional pixel for Firefox
-
+
var $main = $('#main');
// if (/(android|blackberry|iphone|ipod|series60|symbian|windows ce|palm)/i.test(uagent)) {
var mobileDevice = (/(android|blackberry|iphone|ipod|series60|symbian|windows ce|palm)/i.test(uagent));
@@ -219,7 +221,7 @@
height -= $('#navbarBottom').outerHeight(true) - 1;
}
if ($('#bottom').css('display') != 'none') {
- height -= $('#bottom').outerHeight(true) - 1;
+ height -= $('#bottom').outerHeight(true) - 1;
}
$main.css('width', width).css('height', height);
$('#pageSize').text('.page{width:' + (width - 0) + 'px;height:' + height + 'px;}');
@@ -343,39 +345,17 @@
$('head').append(
'<link rel="stylesheet" type="text/css" href="designs/' + thisTemplateEngine.clientDesign
+ '/custom.css" />');
- $('head').append(
- '<script src="designs/' + thisTemplateEngine.clientDesign
- + '/design_setup.js" type="text/javascript" />');
+ $.getScript( 'designs/' + thisTemplateEngine.clientDesign + '/design_setup.js');
// start with the plugins
- var pluginsToLoad = 0;
+ var pluginsToLoad = [];
$('meta > plugins plugin', xml).each(function(i) {
- pluginsToLoad += 1;
- var name = 'plugins/' + $(this).attr('name') + '/structure_plugin.js';
- if (thisTemplateEngine.forceReload)
- name += '?_=' + (new Date().getTime());
- var html_doc = document.getElementsByTagName('body')[0];
- js = document.createElement('script');
- js.setAttribute('type', 'text/javascript');
- js.setAttribute('src', name);
- html_doc.appendChild(js);
-
- js.onreadystatechange = function() {
- if (js.readyState == 'complete') {
- pluginsToLoad -= 1;
- if (pluginsToLoad <= 0) {
- thisTemplateEngine.setup_page(xml);
- }
- }
- };
-
- js.onload = function() {
- pluginsToLoad -= 1;
- if (pluginsToLoad <= 0) {
- thisTemplateEngine.setup_page(xml);
- }
- };
+ pluginsToLoad.push( 'plugins/' + $(this).attr('name') + '/structure_plugin.js' );
});
+ $.getOrderedScripts( pluginsToLoad, function(){
+ thisTemplateEngine.pluginsReady = true;
+ thisTemplateEngine.setup_page(xml);
+ });
// then the icons
$('meta > icons icon-definition', xml).each(function(i) {
@@ -389,7 +369,7 @@
var dynamic = $this.attr('dynamic');
icons.insert(name, uri, type, flavour, color, styling, dynamic);
});
-
+
// then the mappings
$('meta > mappings mapping', xml).each(function(i) {
var $this = $(this);
@@ -420,7 +400,7 @@
}
});
}
- });
+ });
// then the stylings
$('meta > stylings styling', xml).each(function(i) {
@@ -478,14 +458,18 @@
$('.footer').html($('.footer').html() + text);
});
- if (pluginsToLoad <= 0) {
- thisTemplateEngine.setup_page(xml);
- }
+ thisTemplateEngine.pageReady = true;
+ thisTemplateEngine.setup_page(xml);
};
this.setup_page = function(xml) {
// and now setup the pages
+
+ // check if the page and the plugins are ready now
+ if( !this.pageReady || !this.pluginsReady)
+ return; // we'll be called again...
+
var page = $('pages > page', xml)[0]; // only one page element allowed...
thisTemplateEngine.create_pages(page, 'id_0');
Modified: CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2013-02-02 09:14:06 UTC (rev 1385)
+++ CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2013-02-02 14:05:53 UTC (rev 1386)
@@ -162,6 +162,6 @@
/**
* Include the needed stuff
*/
-$( 'head' ).append( '<script type="text/javascript" src="plugins/colorchooser/farbtastic/farbtastic.js"></script>' );
+$.getScript( 'plugins/colorchooser/farbtastic/farbtastic.js' );
$( 'head' ).append( '<link rel="stylesheet" href="plugins/colorchooser/farbtastic/farbtastic.css" type="text/css" />' );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|