//---------------------------------------------------------------------------------------------- // Libreria js_fmlib.txt IL FILE MASTER é in C:\INETPUB\WWROOT\IMPARO // é referenziato da giaccherosse equestrian, fiseaa, fisevda, ipms ecc // // includila nella // // ecc // // Tutte le funzioni devono iniziare con L_ // Tienile in ordine albabetico //_____________________________________________________________- function L_ADDBOOKM(uurrll,titolo) { window.external.AddFavorite(uurrll,titolo); // es: Javascript:L_ADDBOOKM('http://tosnw127/IPMS','I.P.M.S.'); } //_______________________________________________________ function L_BARRA_STATO(testo) { window.status=testo; } //_______________________________________________________ function L_BISESTILE(anno) { if (anno%4==0 && anno%400!=0) return -1 else return 0; } //---------------------------------------------------------------- function L_CLAS(CL) { //_ copiato dalla libreria HJD var xxx=' '; if (parseInt(CL) < 9000) { return parseInt(CL);} if (parseInt(CL) == 9998) {xxx='N.P.';} if (parseInt(CL) == 9999) {xxx='Canc.';} if (parseInt(CL) == 9896) {xxx='Elim.';} if (parseInt(CL) == 9897) {xxx='Rit.';} if (parseInt(CL) == 9898) {xxx='?';} if (parseInt(CL) == 0) {xxx=' ';} return xxx; } //_______________________________________________________________________________ function L_DateTimeAdd(date, tipo, valore) { // // Questa routine é inaffidabile perchè, inspiegabilmente, qualche volta // dice addInterval non definito // var data; (typeof(date)=="number") ? 1==1 : data = new Date(date.getFullYear(),date.getMonth(),date.getDate(),date.getHours(),date.getMinutes(),date.getSeconds(),0); switch(tipo) { case "s": si = L_Div(data.getSeconds() + valore, 60); s = (data.getSeconds() + valore) % 60; si ? addInterval(data.setSeconds(s), "m", si) : data.setSeconds(s); break; case "m": mi = L_Div(data.getMinutes() + valore, 60); m = (data.getMinutes() + valore) % 60; mi ? addInterval(data.setMinutes(m), "h", mi) : data.setMinutes(m); break; case "h": hi = L_Div(data.getHours() + valore, 24); h = (data.getHours() + valore) % 24; hi ? addInterval(data.setHours(h), "dd", hi) : data.setHours(h); break; case "dd": mod = L_GetDaysInMonth(data); ddi = L_Div(data.getDate() + valore, mod); dd = (data.getDate() + valore) % mod; ddi ? addInterval(data.setDate(dd), "mm", ddi) : data.setDate(dd); break; case "mm": mmi = L_Div(data.getMonth() + valore, 12); mm = (data.getMonth() + valore) % 12; mmi ? addInterval(data.setMonth(mm), "yy", mmi) : data.setMonth(mm); break; case "yy": yy = (data.getFullYear() + valore); data.setFullYear(yy); break; default: } return data; } //__________________________________________________________________________ function L_daysInFebruary (year){ // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); } //_________________________________________________________ function L_DaysArray(n) { for (var i = 1; i <= n; i++) { this[i] = 31 if (i==4 || i==6 || i==9 || i==11) {this[i] = 30} if (i==2) {this[i] = 29} } return this } //_________________________________________________________ function L_Div(op1, op2) { return (op1 / op2 - op1 % op2 / op2) } //_________________________________________________________ function L_Erroreasp(sMsg) { var strData; var strFeatures; //Se gli ultimi caratteri sono '\n' li butto via while (sMsg.substr(sMsg.length - 1, 1)=='\n') sMsg = sMsg.substr(0, sMsg.length - 1); sParam='errore.asp?Msg=' + sMsg strFeatures = 'dialogWidth:450px;dialogHeight:300px;'; strFeatures = strFeatures + 'help:no;center:yes;border:thin;status:no;'; strFeatures = strFeatures + 'toolbar=auto;menubar=no;'; strData = window.showModalDialog(sParam, '', strFeatures); } //--------------------------------------------------------------------------------- function L_fixedBackground(url) { var backgroundset=false; // do not change, for internal use only if(!backgroundset) { document.body.style.overflow = 'hidden'; document.body.style.padding = '0px'; document.body.style.margin = '0px'; var overlay = document.createElement('DIV'); overlay.style.position = 'absolute'; overlay.style.top = '0px'; overlay.style.left = '0px'; overlay.style.height = '100%'; overlay.style.width = '100%'; overlay.style.overflow = 'auto'; overlay.innerHTML = document.body.innerHTML; document.body.innerHTML = ''; document.body.appendChild(overlay); backgroundset=true; } else { background.src=url; } } //--------------------------------------------------------------------------------- function L_GETCOOKIE(Name) { // vedi legenda in L_SETCOOKIE var search = Name + "=" if (document.cookie.length > 0) { // if there are any cookies offset = document.cookie.indexOf(search) if (offset != -1) { // if cookie exists offset += search.length // set index of beginning of value end = document.cookie.indexOf(";", offset) // set index of end of cookie value if (end == -1) end = document.cookie.length return unescape(document.cookie.substring(offset, end)) } } } //_______________________________________________________ function L_GetDaysInMonth(aDate){ var m = new Number(aDate.getMonth()); var y = new Number(aDate.getYear()); var tmpDate = new Date(y, m, 28); var checkMonth = tmpDate.getMonth(); var lastDay = 27; while(lastDay <= 31){ temp = tmpDate.setDate(lastDay + 1); if(checkMonth != tmpDate.getMonth()) break; lastDay++ } return lastDay; } //_____________________________________________________________________________________________ function L_getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; } //_______________________________________________________________________________________________ function L_getUrlParam(parameter, defaultvalue){ var urlparameter = defaultvalue; if(window.location.href.indexOf(parameter) > -1){ urlparameter = L_getUrlVars()[parameter]; } return urlparameter; } //_______________________________________________________ function L_GIORNO() { var xxx= ' '; var ggg = new Array("Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"); var time = new Date(); xxx = ggg[time.getDay()] ; return xxx ; } //_________________________________________________________ function L_GIOSET(nnn) { var xxx= ' '; var ggg = new Array("Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"); xxx = ggg[nnn] ; return xxx ; } //________________________________________________________ function L_HHMM() { // restituisce hh:mm dove HH=Ore MM=Minuti xxx=L_WriteTime(1,":") return xxx ; } //__________________________________________________________ function L_IFPP(pagina) { if (L_PP(pagina) == false) FL_WINKO(); } // ___________________________________________________________ function L_isDate(dtStr,xseq) { // funziona, called cavaliere_upd di concorso_sef // stStr la data da controllare // xseq dichiara il formato della data in dtStr deve essere GG/MM/AAAA oppure MM/GG/AAAA var dtCh= "/"; var minYear=1900; var maxYear=2100; var daysInMonth = L_DaysArray(12) var pos1=dtStr.indexOf(dtCh) var pos2=dtStr.indexOf(dtCh,pos1+1) var wseq = xseq.toUpperCase(); // il formato data l ha aggiunto Mario if (wseq == "MM/GG/AAAA" || wseq == "MM/DD/YYYY") { var strMonth=dtStr.substring(0,pos1) var strDay=dtStr.substring(pos1+1,pos2) } else if (wseq == "GG/MM/AAAA" || wseq == "DD/MM/YYYY") { var strDay=dtStr.substring(0,pos1) var strMonth=dtStr.substring(pos1+1,pos2) } else { alert("Formato data non gestito in L_isDate.") return false } var strYear=dtStr.substring(pos2+1) strYr=strYear if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1) if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1) for (var i = 1; i <= 3; i++) { if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1) } month=parseInt(strMonth) day=parseInt(strDay) year=parseInt(strYr) if (pos1==-1 || pos2==-1){ alert("Formato non corretto (mi aspetto dd/mm/yyyy or mm/dd/yyyy") return false } if (strMonth.length<1 || month<1 || month>12){ alert("Please enter a valid month") return false } if (strDay.length<1 || day<1 || day>31 || (month==2 && day>L_daysInFebruary(year)) || day > daysInMonth[month]){ alert("Please enter a valid day") return false } if (strYear.length != 4 || year==0 || yearmaxYear){ alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear) return false } if (dtStr.indexOf(dtCh,pos2+1)!=-1 || L_isInteger(L_stripCharsInBag(dtStr, dtCh))==false){ alert("Please enter a valid date") return false } return true } //__________________________________________________________ function L_IsNullString(strValue) { if (strValue != null) { var i; for (i = 0; i < strValue.length; ++i) { if (strValue.charAt(i) != ' ') return 0; } } return 1; } //__________________________________________________________ function L_IsValidCF(icf) { // per info leggi http://it.wikipedia.org/wiki/Codice_fiscale var cf = icf.toUpperCase(); var cfReg = /^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/; if (!cfReg.test(cf)) return (false); var set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ"; var setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX"; var s = 0; for( i = 1; i <= 13; i += 2 ) s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) ))); for( i = 0; i <= 14; i += 2 ) s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) ))); if ( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) ) return (false); return (true); } //_____________________________________________________________ function L_isInteger(s){ var i; for (i = 0; i < s.length; i++){ // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } //__________________________________________________________ function L_LCASE(stringa) { stringa=stringa.toLowerCase(); return stringa; } //__________________________________________________________ function L_MANCANO_GIORNI(yr,m,d) { var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") var today=new Date() var todayy=today.getYear() if (todayy < 1000) { todayy+=1900; } var todaym=today.getMonth() var todayd=today.getDate() var todaystring=montharray[todaym]+" "+todayd+", "+todayy var futurestring=montharray[m-1]+" "+d+", "+yr var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1) return difference; } //_________________________________________________________ function L_MAKEARRAY() { var lngth = L_MAKEARRAY.arguments.length; var L_I = 0; for ( L_I = 0 ; L_I 1) { alert("Troppi punti decimali nel campo "+campo); return (false); } return (true); } //___________________________________________________________ function L_NUMGIORNIMESE(m,a) { // m da 1 a 12 if (m==2) { if (L_BISESTILE(a)) return 28; else return 29; } if (m==4 || m==6 || m==9 || m==11) return 30; return 31; } //___________________________________________________________ function L_OGGI1() { var time = new Date(); var rrcc=' '; rrcc=time.getDate(); rrcc=rrcc + ' ' + L_MESE3(time.getMonth()+1) + ' ' + time.getYear() ; return rrcc ; } //___________________________________________________________ function L_PICV(flus,fit,max) { // es: onClick="L_PICV(this.src)" | onClick="L_PICV('nomeimg.jpg','YES',?YES')" // La foto g // questa chiamata usa i form PICV.asp e PICVE.asp //alert(arguments.length) ; // num di argomenti var wfit = "YES" ; var wmax = "YES" ; if (arguments.length == 3) { wfit = fit ; wmax = max ; } if ((wfit != "YES") && (wfit !="NO")) { wfit = "YES"; } if ((wmax != "YES") && (wmax !="NO")) { wmax = "YES"; } var ppp="picv.asp?img="+flus +"&fit=" + wfit +"&max=" + wmax ; var attributi = ""; if (wfit == "YES") { attributi = attributi +"resizable=no,scrollbars=no" } window.open(ppp,"",attributi); } //___________________________________________________________ function L_PP(stringa) { // cerca la stringa se in document.referrer var l_i = 0 ; var xxx = false ; var ppn= ' ' ; ppn = document.referrer ; ppn = ppn.toUpperCase() ; stringa=stringa.toUpperCase(); for (var l_i=0; l_i= 12) { AMorPM = "PM"; whichHour = whichHour - 12; } else AMorPM = "AM"; if (whichHour < 1) whichHour = 12; if (whichSecond < 10) whichSecond = "" + "0" + whichSecond; if (whichMinute < 10) whichMinute = "" + "0" + whichMinute; if (m==0) xxx=whichHour + sep + whichMinute + sep + whichSecond + " " + AMorPM; if (m==1) xxx=dateNow.getHours() + sep + whichMinute + sep + whichSecond; if (m==2) xxx=milHour + whichMinute + " hours"; return xxx ; } // esempio document.write(L_WriteTime(1,":")); //___________________________________________________________ function L_WriteDate(m,sep) { // m=tipo formattazione sep=carattere separatore // esempio L_WriteDate(4,"-") ottiene 18-2-2003 dateNow = new Date(); whichDay = L_GIOSET(dateNow.getDay()); whichMonth = L_MESE(dateNow.getMonth()+1); whichDate = dateNow.getDate(); whichYear = dateNow.getYear(); if (whichYear < 2000) {whichYear = whichYear + 1900;} whichYear = "" + whichYear; if (m==0) document.writeln(whichDay + ", " + whichMonth + " " + whichDate + ", " + whichYear); if (m==1) document.writeln((dateNow.getMonth()+1) + sep + whichDate + sep + whichYear.substring(2,4)); if (m==2) document.writeln(whichDate + sep + (dateNow.getMonth()+1) + sep + whichYear.substring(2,4)); if (m==3) document.writeln((dateNow.getMonth()+1) + sep + whichDate + sep + whichYear); if (m==4) document.writeln(whichDate + sep + (dateNow.getMonth()+1) + sep + whichYear); if (m==5) document.writeln(whichDate + sep + whichMonth + sep + whichYear); if (m==6) document.writeln(whichDay); if (m==7) document.writeln(whichMonth); if (m==8) document.writeln(dateNow.getMonth()+1); if (m==9) document.writeln(whichDate); if (m==10) document.writeln(whichYear); } //__________________________________________________________ function L_ZOOM(flus,ww,hh) { // esempio onClick="L_ZOOM(this.src,160,80)" // flus=picture name ww=pic width hh= pic height var ppp=' '; var sino="no"; var winh=0+hh; var winw=0+ww; if (hh > screen.height) { winh=(screen.height-90) sino="yes"; } if (ww > screen.width) { winw=(screen.width-45) sino="yes"; } if (sino=="yes") { winw=winw+18; } winh=winh+4; ppp="__zoom.htm?p="+flus+"&w="+ww+"&h="+hh+"&x=none"; window.open(ppp,"","resizable="+sino+",scrollbars="+sino+ ",width=" + winw + ",height=" + winh + ",top=" + parseInt((screen.height-(winh+40))/2) + ",left=" + parseInt((screen.width-winw)/2)); } //________________________________________________________ //_____________________ Fine js_fmlib.js ______________________ //________________________________________________________