src/js/utils.js
branchpopcorn-port
changeset 656 404f876827ad
parent 640 a6b64eeeb76d
child 650 54ad76d6f9fe
--- a/src/js/utils.js	Mon Jan 16 18:49:45 2012 +0100
+++ b/src/js/utils.js	Mon Jan 16 18:50:30 2012 +0100
@@ -101,16 +101,14 @@
 
 // conversion de couleur Decimal vers HexaDecimal || 000 si fff
 IriSP.DEC_HEXA_COLOR = function (dec) {
-	 var hexa='0123456789ABCDEF';
-   var hex='';
-	 var tmp;
-	 while (dec>15){
-		  tmp = dec-(Math.floor(dec/16))*16;
-		  hex = hexa.charAt(tmp)+hex;
-		  dec = Math.floor(dec/16);
-	 }
-	 hex = hexa.charAt(dec)+hex;	 
-	 return(hex);
+  var val = +dec;
+  var str = val.toString(16);
+  var zeroes = "";
+  if (str.length < 6) {
+    for (var i = 0; i < 6 - str.length; i++)
+      zeroes += "0";
+  }
+  return zeroes + str;
 };
 
 /* shortcut to have global variables in templates */
@@ -148,6 +146,10 @@
   return "";
 };
 
+/** test if a value is null or undefined */
+IriSP.null_or_undefined = function(val) {
+  return (typeof(val) === "undefined" || val === null);
+}
 /* for ie compatibility
 if (Object.prototype.__defineGetter__&&!Object.defineProperty) {
    Object.defineProperty=function(obj,prop,desc) {