|
From: <ma...@us...> - 2011-02-13 21:35:08
|
Revision: 296
http://openautomation.svn.sourceforge.net/openautomation/?rev=296&view=rev
Author: mayerch
Date: 2011-02-13 21:35:02 +0000 (Sun, 13 Feb 2011)
Log Message:
-----------
Added a sprintf funtion - copied from http://www.webtoolkit.info/
Modified Paths:
--------------
CometVisu/trunk/visu/lib/compatibility.js
Modified: CometVisu/trunk/visu/lib/compatibility.js
===================================================================
--- CometVisu/trunk/visu/lib/compatibility.js 2011-02-13 16:55:20 UTC (rev 295)
+++ CometVisu/trunk/visu/lib/compatibility.js 2011-02-13 21:35:02 UTC (rev 296)
@@ -2,4 +2,136 @@
if (typeof (console) == "undefined") {
console = {};
console.log = console.debug = console.info = console.warn = console.error = function() {}
-}
\ No newline at end of file
+}
+
+/**
+ *
+ * Javascript sprintf
+ * http://www.webtoolkit.info/
+ *
+ *
+ **/
+
+sprintfWrapper = {
+
+ init : function () {
+
+ if (typeof arguments == "undefined") { return null; }
+ if (arguments.length < 1) { return null; }
+ if (typeof arguments[0] != "string") { return null; }
+ if (typeof RegExp == "undefined") { return null; }
+
+ var string = arguments[0];
+ var exp = new RegExp(/(%([%]|(\-)?(\+|\x20)?(0)?(\d+)?(\.(\d)?)?([bcdfosxX])))/g);
+ var matches = new Array();
+ var strings = new Array();
+ var convCount = 0;
+ var stringPosStart = 0;
+ var stringPosEnd = 0;
+ var matchPosEnd = 0;
+ var newString = '';
+ var match = null;
+
+ while (match = exp.exec(string)) {
+ if (match[9]) { convCount += 1; }
+
+ stringPosStart = matchPosEnd;
+ stringPosEnd = exp.lastIndex - match[0].length;
+ strings[strings.length] = string.substring(stringPosStart, stringPosEnd);
+
+ matchPosEnd = exp.lastIndex;
+ matches[matches.length] = {
+ match: match[0],
+ left: match[3] ? true : false,
+ sign: match[4] || '',
+ pad: match[5] || ' ',
+ min: match[6] || 0,
+ precision: match[8],
+ code: match[9] || '%',
+ negative: parseInt(arguments[convCount]) < 0 ? true : false,
+ argument: String(arguments[convCount])
+ };
+ }
+ strings[strings.length] = string.substring(matchPosEnd);
+
+ if (matches.length == 0) { return string; }
+ if ((arguments.length - 1) < convCount) { return null; }
+
+ var code = null;
+ var match = null;
+ var i = null;
+
+ for (i=0; i<matches.length; i++) {
+
+ if (matches[i].code == '%') { substitution = '%' }
+ else if (matches[i].code == 'b') {
+ matches[i].argument = String(Math.abs(parseInt(matches[i].argument)).toString(2));
+ substitution = sprintfWrapper.convert(matches[i], true);
+ }
+ else if (matches[i].code == 'c') {
+ matches[i].argument = String(String.fromCharCode(parseInt(Math.abs(parseInt(matches[i].argument)))));
+ substitution = sprintfWrapper.convert(matches[i], true);
+ }
+ else if (matches[i].code == 'd') {
+ matches[i].argument = String(Math.abs(parseInt(matches[i].argument)));
+ substitution = sprintfWrapper.convert(matches[i]);
+ }
+ else if (matches[i].code == 'f') {
+ matches[i].argument = String(Math.abs(parseFloat(matches[i].argument)).toFixed(matches[i].precision ? matches[i].precision : 6));
+ substitution = sprintfWrapper.convert(matches[i]);
+ }
+ else if (matches[i].code == 'o') {
+ matches[i].argument = String(Math.abs(parseInt(matches[i].argument)).toString(8));
+ substitution = sprintfWrapper.convert(matches[i]);
+ }
+ else if (matches[i].code == 's') {
+ matches[i].argument = matches[i].argument.substring(0, matches[i].precision ? matches[i].precision : matches[i].argument.length)
+ substitution = sprintfWrapper.convert(matches[i], true);
+ }
+ else if (matches[i].code == 'x') {
+ matches[i].argument = String(Math.abs(parseInt(matches[i].argument)).toString(16));
+ substitution = sprintfWrapper.convert(matches[i]);
+ }
+ else if (matches[i].code == 'X') {
+ matches[i].argument = String(Math.abs(parseInt(matches[i].argument)).toString(16));
+ substitution = sprintfWrapper.convert(matches[i]).toUpperCase();
+ }
+ else {
+ substitution = matches[i].match;
+ }
+
+ newString += strings[i];
+ newString += substitution;
+
+ }
+ newString += strings[i];
+
+ return newString;
+
+ },
+
+ convert : function(match, nosign){
+ if (nosign) {
+ match.sign = '';
+ } else {
+ match.sign = match.negative ? '-' : match.sign;
+ }
+ var l = match.min - match.argument.length + 1 - match.sign.length;
+ var pad = new Array(l < 0 ? 0 : l).join(match.pad);
+ if (!match.left) {
+ if (match.pad == "0" || nosign) {
+ return match.sign + pad + match.argument;
+ } else {
+ return pad + match.sign + match.argument;
+ }
+ } else {
+ if (match.pad == "0" || nosign) {
+ return match.sign + match.argument + pad.replace(/0/g, ' ');
+ } else {
+ return match.sign + match.argument + pad;
+ }
+ }
+ }
+}
+
+sprintf = sprintfWrapper.init;
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-26 15:27:02
|
Revision: 609
http://openautomation.svn.sourceforge.net/openautomation/?rev=609&view=rev
Author: mayerch
Date: 2011-12-26 15:26:55 +0000 (Mon, 26 Dec 2011)
Log Message:
-----------
Bug fix: numbers between -1 and 0 didn't show a negative sign when the format string was used.
Fix as shown in http://knx-user-forum.de/198589-post10.html
Modified Paths:
--------------
CometVisu/trunk/visu/lib/compatibility.js
Modified: CometVisu/trunk/visu/lib/compatibility.js
===================================================================
--- CometVisu/trunk/visu/lib/compatibility.js 2011-12-26 15:12:18 UTC (rev 608)
+++ CometVisu/trunk/visu/lib/compatibility.js 2011-12-26 15:26:55 UTC (rev 609)
@@ -48,7 +48,7 @@
min: match[6] || 0,
precision: match[8],
code: match[9] || '%',
- negative: parseInt(arguments[convCount]) < 0 ? true : false,
+ negative: parseFloat(arguments[convCount]) < 0 ? true : false,
argument: String(arguments[convCount])
};
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2013-02-03 20:20:06
|
Revision: 1404
http://openautomation.svn.sourceforge.net/openautomation/?rev=1404&view=rev
Author: mayerch
Date: 2013-02-03 20:19:59 +0000 (Sun, 03 Feb 2013)
Log Message:
-----------
Show warning alert if the user is using Internet Explorer as a browser
(see also feature request https://sourceforge.net/tracker/?func=detail&aid=3445353&group_id=296426&atid=1251144)
Modified Paths:
--------------
CometVisu/trunk/visu/lib/compatibility.js
Modified: CometVisu/trunk/visu/lib/compatibility.js
===================================================================
--- CometVisu/trunk/visu/lib/compatibility.js 2013-02-03 19:28:51 UTC (rev 1403)
+++ CometVisu/trunk/visu/lib/compatibility.js 2013-02-03 20:19:59 UTC (rev 1404)
@@ -1,3 +1,26 @@
+/* compatability.js (c) 2013 by Christian Mayer [CometVisu at ChristianMayer dot de]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @module Compatability
+ * @title CometVisu helper functions for compatability issues
+ */
+if( /(msie)/i.test(navigator.userAgent.toLowerCase()) )
+{
+ alert( 'Sorry, but Internet Explorer is not supported!' );
+}
if (typeof (console) == "undefined") {
console = {};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2013-02-05 21:27:39
|
Revision: 1432
http://openautomation.svn.sourceforge.net/openautomation/?rev=1432&view=rev
Author: mayerch
Date: 2013-02-05 21:27:29 +0000 (Tue, 05 Feb 2013)
Log Message:
-----------
temporary fix till a better solution could be implemented for script loading order
Modified Paths:
--------------
CometVisu/trunk/visu/lib/compatibility.js
Modified: CometVisu/trunk/visu/lib/compatibility.js
===================================================================
--- CometVisu/trunk/visu/lib/compatibility.js 2013-02-05 21:09:59 UTC (rev 1431)
+++ CometVisu/trunk/visu/lib/compatibility.js 2013-02-05 21:27:29 UTC (rev 1432)
@@ -189,10 +189,21 @@
if( 'object' === typeof files && 0 == files.length && callback )
callback();
else
+ /*
$.getScript( files.shift(), files.length
? function(){ $.getOrderedScripts(files, callback);}
: callback
);
+ */
+ // temporary fix till a better solution could be implemented:
+ $.ajax({
+ url: files.shift(),
+ dataType: 'script',
+ async: false,
+ success: files.length
+ ? function(){ $.getOrderedScripts(files, callback);}
+ : callback
+ });
},
// inspired by http://stackoverflow.com/questions/2685614/load-external-css-file-like-scripts-in-jquery-which-is-compatible-in-ie-also
getCSS: function( url, parameters ) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2013-02-10 20:32:09
|
Revision: 1464
http://openautomation.svn.sourceforge.net/openautomation/?rev=1464&view=rev
Author: mayerch
Date: 2013-02-10 20:32:02 +0000 (Sun, 10 Feb 2013)
Log Message:
-----------
Little bug fix for the cases when an hash tag is in the URL
Modified Paths:
--------------
CometVisu/trunk/visu/lib/compatibility.js
Modified: CometVisu/trunk/visu/lib/compatibility.js
===================================================================
--- CometVisu/trunk/visu/lib/compatibility.js 2013-02-10 20:19:34 UTC (rev 1463)
+++ CometVisu/trunk/visu/lib/compatibility.js 2013-02-10 20:32:02 UTC (rev 1464)
@@ -165,13 +165,14 @@
$.extend({
getUrlVars: function(){
var vars = [], hash;
- var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
+ var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('#')[0].split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
+ console.log( vars );
return vars;
},
getUrlVar: function(name){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2013-02-10 20:46:57
|
Revision: 1465
http://openautomation.svn.sourceforge.net/openautomation/?rev=1465&view=rev
Author: mayerch
Date: 2013-02-10 20:46:50 +0000 (Sun, 10 Feb 2013)
Log Message:
-----------
Remove debuging message
Modified Paths:
--------------
CometVisu/trunk/visu/lib/compatibility.js
Modified: CometVisu/trunk/visu/lib/compatibility.js
===================================================================
--- CometVisu/trunk/visu/lib/compatibility.js 2013-02-10 20:32:02 UTC (rev 1464)
+++ CometVisu/trunk/visu/lib/compatibility.js 2013-02-10 20:46:50 UTC (rev 1465)
@@ -172,7 +172,6 @@
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
- console.log( vars );
return vars;
},
getUrlVar: function(name){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|