X-Git-Url: https://mop.ddnsfree.com/gitweb/?p=xynt.git;a=blobdiff_plain;f=web%2Fxynt%2Fxynt-commons.js;h=550cc281e9b4ec8e8f3c14950d494e7c06ba0722;hp=cb8076f7e0fe1de2a28c9c3b3f262b636abd9ade;hb=1716e67da8e78da7de463d5224baeaaaca1cf2ff;hpb=9f0cbf62feaea515635cfc85bddd5292b2170440 diff --git a/web/xynt/xynt-commons.js b/web/xynt/xynt-commons.js index cb8076f..550cc28 100644 --- a/web/xynt/xynt-commons.js +++ b/web/xynt/xynt-commons.js @@ -1,3 +1,5 @@ +var cookiepath = "/xynt/"; + function $(id) { return document.getElementById(id); } function getStyle(x,IEstyleProp, MozStyleProp) @@ -91,9 +93,121 @@ function getStyle(x,IEstyleProp, MozStyleProp) return y; } + + function doSomething(e) { if (!e) var e = window.event // handle event e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); -} \ No newline at end of file +} + +/* + * GESTIONE DEI COOKIES + */ +function createCookie(name,value,hours,path) { + if (hours) { + var date = new Date(); + date.setTime(date.getTime()+(hours*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value+expires+"; path="+path; +} + +function readCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + } + return null; +} + +function eraseCookie(name) { + createCookie(name,"",-1); +} + +function url_append_arg(url, name, value) +{ + var pos, sep, pref, rest; + + if ((pos = url.indexOf('?'+name+'=')) == -1) { + pos = url.indexOf('&'+name+'='); + } + if (pos == -1) { + if ((pos = url.indexOf('?')) != -1) + sep = '&'; + else + sep = '?'; + + return (url+sep+name+"="+encodeURIComponent(value)); + } + else { + pref = url.substring(0, pos+1); + rest = url.substring(pos+1); + // alert("rest: "+rest+" pos: "+pos); + if ((pos = rest.indexOf('&')) != -1) { + rest = rest.substring(pos); + } + else { + rest = ""; + } + return (pref+name+"="+encodeURIComponent(value)+rest); + } +} + +function url_append_args(url) +{ + var i, ret; + + ret = url; + for (i = 1 ; i < arguments.length-1 ; i+= 2) { + ret = url_append_arg(ret, arguments[i], arguments[i+1]); + } + + return (ret); +} + +function url_complete(parent, url) +{ + var p, p2, rest; + var host = "", path = ""; + + // host extraction + p = parent.indexOf("://"); + if (p > -1) { + rest = parent.substring(p+3); + p2 = rest.indexOf("/"); + if (p2 > -1) { + host = parent.substring(0, p+3+p2); + rest = parent.substring(p+3+p2); + } + else { + host = rest; + rest = ""; + } + } + else { + rest = parent; + } + + // path extraction + p = rest.lastIndexOf("/"); + if (p > -1) { + path = rest.substring(0, p+1); + } + + // alert("host: ["+host+"] path: ["+path+"]"); + if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/') { + return (url); + } + else if (url.substring(0,1) == '/') { + return (host+url); + } + else { + return (host+path+url); + } +}