src/js/utils.js
branchpopcorn-port
changeset 656 404f876827ad
parent 640 a6b64eeeb76d
child 650 54ad76d6f9fe
equal deleted inserted replaced
655:b1e2dfc7a740 656:404f876827ad
    99     return count;
    99     return count;
   100 };
   100 };
   101 
   101 
   102 // conversion de couleur Decimal vers HexaDecimal || 000 si fff
   102 // conversion de couleur Decimal vers HexaDecimal || 000 si fff
   103 IriSP.DEC_HEXA_COLOR = function (dec) {
   103 IriSP.DEC_HEXA_COLOR = function (dec) {
   104 	 var hexa='0123456789ABCDEF';
   104   var val = +dec;
   105    var hex='';
   105   var str = val.toString(16);
   106 	 var tmp;
   106   var zeroes = "";
   107 	 while (dec>15){
   107   if (str.length < 6) {
   108 		  tmp = dec-(Math.floor(dec/16))*16;
   108     for (var i = 0; i < 6 - str.length; i++)
   109 		  hex = hexa.charAt(tmp)+hex;
   109       zeroes += "0";
   110 		  dec = Math.floor(dec/16);
   110   }
   111 	 }
   111   return zeroes + str;
   112 	 hex = hexa.charAt(dec)+hex;	 
       
   113 	 return(hex);
       
   114 };
   112 };
   115 
   113 
   116 /* shortcut to have global variables in templates */
   114 /* shortcut to have global variables in templates */
   117 IriSP.templToHTML = function(template, values) {
   115 IriSP.templToHTML = function(template, values) {
   118   var params = IriSP.jQuery.extend(IriSP.default_templates_vars, values);
   116   var params = IriSP.jQuery.extend(IriSP.default_templates_vars, values);
   146 /** returns an url to share on google + */
   144 /** returns an url to share on google + */
   147 IriSP.mkGplusUrl = function(url) {
   145 IriSP.mkGplusUrl = function(url) {
   148   return "";
   146   return "";
   149 };
   147 };
   150 
   148 
       
   149 /** test if a value is null or undefined */
       
   150 IriSP.null_or_undefined = function(val) {
       
   151   return (typeof(val) === "undefined" || val === null);
       
   152 }
   151 /* for ie compatibility
   153 /* for ie compatibility
   152 if (Object.prototype.__defineGetter__&&!Object.defineProperty) {
   154 if (Object.prototype.__defineGetter__&&!Object.defineProperty) {
   153    Object.defineProperty=function(obj,prop,desc) {
   155    Object.defineProperty=function(obj,prop,desc) {
   154       if ("get" in desc) obj.__defineGetter__(prop,desc.get);
   156       if ("get" in desc) obj.__defineGetter__(prop,desc.get);
   155       if ("set" in desc) obj.__defineSetter__(prop,desc.set);
   157       if ("set" in desc) obj.__defineSetter__(prop,desc.set);