2332 lines
59 KiB
JavaScript
2332 lines
59 KiB
JavaScript
/*ver. 5.0.10
|
|
01-07-2016 clrField gestisce i checkbox
|
|
04-06-2015 submitaj con cahce false
|
|
30-04-2015 corretto F1 per tornare indietro Su windows sarà alt+f1
|
|
24-04-2015 gestione campo indietro focusnextoncr e rendiprevnext
|
|
21-01-2015 corretto title su submitAj
|
|
10-01-2015 gestione caricamento immagini tramite ajax
|
|
08-01-2015 nextPage e prevPage DETAIL
|
|
27-11-2014 checkBoxes e checkradio non obbligatori
|
|
17-11-2014 copiato fetch qui con Ab.fetch
|
|
15-09-2014 inizio creazione variabile globare Ab. in stile jquery
|
|
16-07-2014 focusNextOnCr(e,nextField) se nextField non c'è, va al campo successivo
|
|
02-05-2014 spostato showVersiono su sidebar.js
|
|
29-04-2014 aggiornato showVersion con jquery
|
|
12-04-2014 aggiunto _callType per capire come comportarti in caso di caduta sessione
|
|
29-03-2014 executeProcess per fetch e submitaj o dove servir
|
|
18-03-2014 fetch asincrona
|
|
04-03-2014 sostituito controllo CR nella funzione help
|
|
28-02-2014 aggiunto setfocus in clrField
|
|
12-02-2014 sostituito form. dettaglio e ricerca con main . form.menu rimane...
|
|
10-02-2014 corretto submitAj
|
|
07-02-2014 rendiNextField con parametro num campo successivo. setFocus con jquery
|
|
29/01/2014 aggiunto saveNextFocus e rendiNextField
|
|
21/11/2013 modificata apply con call per la chiamata con parametri in executeFunctionByName per passaggio parametri
|
|
29/10/2013 aggiunto split e decommentato args in executeFunctionByName per passaggio parametri
|
|
13/05/2013 aggiunto goPageDetail2
|
|
09/05/2013 aggiustaInputText
|
|
25/04/2013 allineamento funzioni aggiunte nella v.2 e non riportate nella v.3
|
|
01/09/2011 adattamento nuovi template 3.0. spostamento main-menu qui dentro e utilizzao main-menu per menu personalizzati
|
|
04/10/2012 validateForm3 per le lingue
|
|
24/09/2012 gestione tymymcE
|
|
22/05/2012 gestito help su maschere di ricerca. in pratica aggiunge _CR al valore della action page
|
|
28/12/2011 aggiustato rilevazione firefox 9
|
|
30/06/2011 corretto closeHW
|
|
27/06/2011 aggiunto executeFunctionByName
|
|
03/06/2011 corretto openViewWindow
|
|
09/06/2010 identificazione ie7 ie8
|
|
27/04/2010 gestione webapp indipendente. gestione help
|
|
20/04/2010 aggiunto f.flgReport.value=""; su gestione salto pagina
|
|
09/02/2010 corretto helpW
|
|
27/01/2010 setCheckboxvalue... gestisce il caso in cui i checkbox non sono visibili
|
|
27-10-2009 aggiunto printPdf per stampe su window iframe
|
|
07-10-2009 buildSitemap
|
|
24-09-2009 spostato formatNumber e stringToNumber su numberInput.js. Gestione inpunt numerno con checkNumber(i, delKey,direction)
|
|
modificato main-menu.js con nuildSM
|
|
18-09-2009 inizio supporto google chrome
|
|
10-06-2009 gestione windows
|
|
20-04-2009 navContainerSmall e navContainerXSmall su hideTabs
|
|
18-03-2009 getValId
|
|
19-01-2009 aggiornato nextPageDetail, prevPageDatail, goPageDetail per finestre bean con tab vari
|
|
corretto e prevede la ricompilazione di tutte le adminSimple e adminSimpleEncType a causa del id mancante su pageNumber
|
|
goPageS() diventa obsoleto... da levare
|
|
02-12-2008 riaggirnato setRadioButtonValue che non funzionava
|
|
17-11-2008 aggiornato setRadioButtonValue e setChekBoxValue per firefox
|
|
09-11-2008 levato alert su formatNumber. aggiunto stringToNumber da script stan-accettazione
|
|
27-10-2008 aggiunto prendiElementoDaId (ajax)
|
|
16-10-2008 aggiunto submitForm(evt) per gestione submit su tutti i form (firefox ok). corretto setFocus per i select
|
|
10-10-2008 modificato showTab per gestire i next focus su show tab. aggiunto setFocus
|
|
08-10-2008 aggiunto formatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
|
|
06-05-2008 ri-aggiunto openViewWindow (ciatti). Gestione TABS automatica. . aggiunte funzioni leftTrim, rightTrim e trim
|
|
02-04-2008 automatismi inserminento form: focusNext + Time du dateInput.js
|
|
24-02-2008 clrField: adesso cancella n campi invece di 2
|
|
15-01-08 corretto flag!=null su setChekBoxValue e setRadioButtonValue
|
|
28/12/2007 aggiunto funzione setRadioButtonValue(formName,flgName) e setChekBoxValue(formName,flgName,ckValue,unckValue). Aggiornati script template
|
|
14/11/07 aggiornato anche getBrowserLang e redirectLang. Testato con firefox per le lingue adesso funziona davvero
|
|
09/11/07 modificato funzioni goPage(l_pageNumber) goPage() goPage2() nextPagformate() prevPage()
|
|
e' necessario creare due funzioni anche vuote checkRadioCR(); checkBoxesCR(); sullo script del tipo pkg-theBean.js
|
|
13/10/2006 inserito redirectLang() funzionante
|
|
10/10/2007 inserito getBrowserLang
|
|
12/09/07 gestito isNumKey in checkFields
|
|
01-08-07 inserito showVersion
|
|
*/
|
|
//webApp="/nomewebapp";
|
|
//var webApp="/miser";
|
|
//var webApp=""
|
|
|
|
var locale="IT";
|
|
var helpWin;
|
|
var helpWinW;
|
|
//**************** DETECT BROWSER **************************************************
|
|
//CS1.1
|
|
|
|
var exclude=1;
|
|
var agt=navigator.userAgent.toLowerCase();
|
|
|
|
var win=0;var mac=0;var lin=1;
|
|
if(agt.indexOf('win')!=-1){win=1;lin=0;}
|
|
if(agt.indexOf('mac')!=-1){mac=1;lin=0;}
|
|
var lnx=0;if(lin){lnx=1;}
|
|
var ice=0;
|
|
var ie=0;var ie4=0;var ie5=0;var ie6=0;var com=0;var dcm;var ie7=0;var ie8=0;
|
|
var op5=0;var op6=0;var op7=0;
|
|
var ns4=0;var ns6=0;var ns7=0;var mz7=0;var kde=0;var saf=0;; var chro=0;
|
|
if(typeof navigator.vendor!="undefined" && navigator.vendor=="KDE"){
|
|
var thisKDE=agt;
|
|
var splitKDE=thisKDE.split("konqueror/");
|
|
var aKDE=splitKDE[1].split("; ");
|
|
var KDEn=parseFloat(aKDE[0]);
|
|
if(KDEn>=2.2){
|
|
kde=1;
|
|
ns6=1;
|
|
exclude=0;
|
|
}
|
|
}
|
|
else if(typeof navigator.vendor!="undefined" && navigator.vendor.indexOf('Google')!=-1){
|
|
chro=1;
|
|
}
|
|
else if(agt.indexOf('webtv')!=-1){exclude=1;}
|
|
else if(typeof window.opera!="undefined"){
|
|
exclude=0;
|
|
if(/opera[\/ ][5]/.test(agt)){op5=1;}
|
|
if(/opera[\/ ][6]/.test(agt)){op6=1;}
|
|
if(/opera[\/ ][7-9]/.test(agt)){op7=1;}
|
|
}
|
|
else if(typeof document.all!="undefined"&&!kde){
|
|
exclude=0;
|
|
ie=1;
|
|
if(typeof document.getElementById!="undefined"){
|
|
ie5=1;
|
|
if(agt.indexOf("msie 6")!=-1){
|
|
ie6=1;
|
|
dcm=document.compatMode;
|
|
if(dcm!="BackCompat"){com=1;}
|
|
}
|
|
if(agt.indexOf("msie 7")!=-1){
|
|
ie7=1;
|
|
dcm=document.compatMode;
|
|
if(dcm!="BackCompat"){com=1;}
|
|
}
|
|
if(agt.indexOf("msie 8")!=-1){
|
|
ie8=1;
|
|
dcm=document.compatMode;
|
|
if(dcm!="BackCompat"){com=1;}
|
|
}
|
|
}
|
|
else{ie4=1;}
|
|
}
|
|
else if(typeof document.getElementById!="undefined"){
|
|
exclude=0;
|
|
if(agt.indexOf("netscape/6")!=-1||agt.indexOf("netscape6")!=-1){ns6=1;}
|
|
else if(agt.indexOf("netscape/7")!=-1||agt.indexOf("netscape7")!=-1){ns6=1;ns7=1;}
|
|
else if(agt.indexOf("gecko")!=-1){ns6=1;mz7=1;}
|
|
else if(agt.indexOf("safari")!=-1 || (typeof document.childNodes!="undefined" && typeof document.all=="undefined" && typeof navigator.taintEnabled=="undefined")){mz7=0;ns6=1;saf=1;}
|
|
}
|
|
else if((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)){
|
|
exclude=0;
|
|
ns4=1;
|
|
if(typeof navigator.mimeTypes['*']=="undefined"){
|
|
exclude=1;
|
|
ns4=0;
|
|
}
|
|
}
|
|
if(agt.indexOf('escape')!=-1){exclude=1;ns4=0;}
|
|
if(typeof navigator.__ice_version!="undefined"){exclude=1;ie4=0;}
|
|
|
|
|
|
//alert("ns44 "+ns4 +" ie5 "+ie5+" mozz "+mz7+" chro "+chro+" ie6"+ie6+" ie7"+ie7+" ie8"+ie8);
|
|
//********************************************************
|
|
//********************************************************
|
|
|
|
|
|
//********************************************************
|
|
//********************************************************
|
|
// S T A R T
|
|
//********************************************************
|
|
//********************************************************
|
|
//********************************************************
|
|
|
|
var Ab={};
|
|
|
|
|
|
Ab.prototype={
|
|
version:5.0,
|
|
//coordinate x e y del mouse
|
|
coordx:0,
|
|
coordy:0
|
|
|
|
};
|
|
|
|
// javascript main menu
|
|
//********************************************************
|
|
//********************************************************
|
|
// MENU
|
|
//********************************************************
|
|
//********************************************************
|
|
//********************************************************
|
|
Ab.menu=function()
|
|
{
|
|
//FACCIO IL SUBMIT
|
|
var f = document.menu;
|
|
f.action=webApp+"/admin/menu/Menu.abl";
|
|
f.cmd.value="";
|
|
f.submit();
|
|
};
|
|
//********************************************************
|
|
//********************************************************
|
|
// BUILD SITEMAP
|
|
//********************************************************
|
|
//********************************************************
|
|
//********************************************************
|
|
Ab.buildSitemap= function buildSitemap()
|
|
{
|
|
|
|
var f = document.main;
|
|
//f.action=webApp+"/admin/menu/Menu.abl";
|
|
f.cmd.value="buildSM";
|
|
f.fileName.value=prompt("Inserisci nome file per sitemap",f.fileName.value);
|
|
f.submit();
|
|
|
|
}
|
|
|
|
|
|
//********************************************************
|
|
//********************************************************
|
|
// P R I N T
|
|
//********************************************************
|
|
//********************************************************
|
|
//********************************************************
|
|
Ab.printW= function ()
|
|
{
|
|
window.print();
|
|
return true;
|
|
|
|
}
|
|
//////////////////////////////////////////////////////////
|
|
/// controlli salvataggi e cancellazione//////////////////
|
|
|
|
/////////////////////////////////////////////////////////
|
|
Ab.confirmDelete=function ()
|
|
{
|
|
return confirm("I dati saranno cancellati. Vuoi continuare?")
|
|
|
|
|
|
}
|
|
/////////////////////////////////////////////////////
|
|
// gestione preve e next nelle liste con paginazione
|
|
/////////////////////////////////////////////////////
|
|
|
|
//caso maschere di ricerca
|
|
Ab.prevPage=function ()
|
|
{
|
|
|
|
var f = document.main;
|
|
//richiamo anche un metodo che carica i checkBox e i checkRadio
|
|
if(typeof checkRadioCR == 'function')
|
|
checkRadioCR();
|
|
if(typeof checkBoxesCR == 'function')
|
|
checkBoxesCR();
|
|
f.action=f.actionPage.value;
|
|
f.cmd.value="search";
|
|
f.flgReport.value="";
|
|
f.pageNumber.value=f.pageNumber.value-1;
|
|
f.target="" ;
|
|
Ab.submitAj('main');
|
|
//f.submit();
|
|
}
|
|
|
|
Ab.nextPage=function ()
|
|
{
|
|
var f = document.main;
|
|
//richiamo anche un metodo che carica i checkBox e i checkRadio
|
|
if(typeof checkRadioCR == 'function')
|
|
checkRadioCR();
|
|
if(typeof checkBoxesCR == 'function')
|
|
checkBoxesCR();
|
|
f.action=f.actionPage.value;
|
|
f.cmd.value="search";
|
|
f.flgReport.value="";
|
|
f.pageNumber.value=eval(f.pageNumber.value)+1;
|
|
f.target="" ;
|
|
|
|
//alert(f.pageNumber.value);
|
|
//f.submit();
|
|
Ab.submitAj('main');
|
|
}
|
|
|
|
Ab.goPage=function (l_pageNumber)
|
|
{aler('verificare quando viene chiamata!!!');
|
|
//richiamo anche un metodo che carica i checkBox e i checkRadio
|
|
if(typeof checkRadioCR == 'function')
|
|
checkRadioCR();
|
|
if(typeof checkBoxesCR == 'function')
|
|
checkBoxesCR();
|
|
var f = document.main;
|
|
f.action=f.actionPage.value;
|
|
f.cmd.value="search";
|
|
f.flgReport.value="";
|
|
f.pageNumber.value=l_pageNumber;
|
|
f.target="" ;
|
|
Ab.submitAj('main');
|
|
//f.submit();
|
|
}
|
|
|
|
Ab.goPage=function ()
|
|
{
|
|
//richiamo anche un metodo che carica i checkBox e i checkRadio
|
|
if(typeof checkRadioCR == 'function')
|
|
checkRadioCR();
|
|
if(typeof checkBoxesCR == 'function')
|
|
checkBoxesCR();
|
|
Ab.goPageMod(document.main);
|
|
}
|
|
|
|
Ab.goPage2 =function ()
|
|
{
|
|
//richiamo anche un metodo che carica i checkBox e i checkRadio
|
|
if(typeof checkRadioCR == 'function')
|
|
checkRadioCR();
|
|
if(typeof checkBoxesCR == 'function')
|
|
checkBoxesCR();
|
|
Ab.goPageMod2(document.main);
|
|
}
|
|
|
|
Ab.goPageS= function ()
|
|
{alert('obsoleto');
|
|
//per le pagine di tipo simple
|
|
Ab.goPageMod(document.main);
|
|
}
|
|
|
|
Ab.goPageMod=function (f)
|
|
{
|
|
//var f = document.main;
|
|
if(parseFloat(f.pageNumberGo.value)<= parseFloat(f.totPageNumber.value))
|
|
{
|
|
f.action=f.actionPage.value;
|
|
f.cmd.value="search";
|
|
f.pageNumber.value=f.pageNumberGo.value;
|
|
f.target="" ;
|
|
Ab.submitAj(f.name);
|
|
//f.submit();
|
|
}
|
|
else
|
|
alert('Errore!!');
|
|
|
|
}
|
|
|
|
|
|
Ab.goPageMod2= function (f)
|
|
{
|
|
//var f = document.main;
|
|
if(parseFloat(f.pageNumberGo2.value)<= parseFloat(f.totPageNumber.value))
|
|
{
|
|
f.action=f.actionPage.value;
|
|
f.cmd.value="search";
|
|
f.pageNumber.value=f.pageNumberGo2.value;
|
|
f.target="" ;
|
|
Ab.submitAj(f.name);
|
|
//f.submit();
|
|
}
|
|
else
|
|
alert('Errore!!');
|
|
}
|
|
|
|
|
|
//caso finestre secondarie di ricerca
|
|
|
|
Ab.prevPageSW= function ()
|
|
{
|
|
|
|
var f = document.main;
|
|
f.act.value="sw";
|
|
prevPage();
|
|
}
|
|
|
|
Ab.nextPageSW= function ()
|
|
{
|
|
|
|
|
|
var f = document.main;
|
|
f.act.value="sw";
|
|
nextPage();
|
|
}
|
|
|
|
Ab.goPageSW=function (l_pageNumber)
|
|
{
|
|
|
|
var f = document.main;
|
|
f.action=f.actionPage.value;
|
|
f.act.value="sw";
|
|
goPage(l_pageNumber);
|
|
}
|
|
|
|
//caso maschere di dettaglio per liste secondarie
|
|
Ab.prevPageDetail=function (searchType)
|
|
{
|
|
var f = document.main;
|
|
f.action=f.actionPage.value;
|
|
f.cmd.value="md";
|
|
f.act.value=searchType;
|
|
var pn;
|
|
if(typeof searchType=="undefined"){
|
|
pn= Ab.prendiElementoDaId("pageNumber");}
|
|
else
|
|
pn= Ab.prendiElementoDaId("pageNumber_"+searchType);
|
|
pn.value=eval(pn.value)-1;
|
|
Ab.submitAj('main');
|
|
|
|
}
|
|
|
|
Ab.nextPageDetail=function (searchType)
|
|
{
|
|
var f = document.main;
|
|
f.action=f.actionPage.value;
|
|
f.cmd.value="md";
|
|
f.act.value=searchType;
|
|
var pn;
|
|
if(typeof searchType=="undefined"){
|
|
pn= Ab.prendiElementoDaId("pageNumber");}
|
|
else
|
|
pn= Ab.prendiElementoDaId("pageNumber_"+searchType);
|
|
pn.value=eval(pn.value)+1;
|
|
Ab.submitAj('main');
|
|
}
|
|
|
|
Ab.goPageDetail=function (searchType)
|
|
{
|
|
var f = document.main;
|
|
f.action=f.actionPage.value;
|
|
f.cmd.value="md";
|
|
if(typeof searchType=="undefined"){
|
|
var pn= Ab.prendiElementoDaId("pageNumber");
|
|
var pnN=Ab.prendiElementoDaId("pageNumberGo");
|
|
var totPage=Ab.prendiElementoDaId("totPageNumber");
|
|
}
|
|
else
|
|
{
|
|
var pn= Ab.prendiElementoDaId("pageNumber_"+searchType);
|
|
var pnN=Ab.prendiElementoDaId("pageNumberGo_"+searchType);
|
|
var totPage=Ab.prendiElementoDaId("totPageNumber_"+searchType);
|
|
}
|
|
if(parseFloat(pnN.value)<= parseFloat(totPage.value))
|
|
{ pn.value=pnN.value;
|
|
Ab.submitAj('main');
|
|
}
|
|
else
|
|
{
|
|
alert('Errore!!');
|
|
}
|
|
|
|
}
|
|
|
|
Ab.goPageDetail2=function (searchType)
|
|
{
|
|
var f = document.main;
|
|
f.action=f.actionPage.value;
|
|
f.cmd.value="md";
|
|
if(typeof searchType=="undefined"){
|
|
var pn= Ab.prendiElementoDaId("pageNumber");
|
|
var pnN=Ab.prendiElementoDaId("pageNumberGo2");
|
|
var totPage=Ab.prendiElementoDaId("totPageNumber");
|
|
}
|
|
else
|
|
{
|
|
var pn= Ab.prendiElementoDaId("pageNumber_"+searchType);
|
|
var pnN=Ab.prendiElementoDaId("pageNumberGo2_"+searchType);
|
|
var totPage=Ab.prendiElementoDaId("totPageNumber_"+searchType);
|
|
}
|
|
if(parseFloat(pnN.value)<= parseFloat(totPage.value))
|
|
{ pn.value=pnN.value;
|
|
Ab.submitAj('main');
|
|
}
|
|
else
|
|
{
|
|
alert('Errore!!');
|
|
}
|
|
|
|
}
|
|
//////////////////////////////////////////////////////////
|
|
/// gestione layers ///////////////////7//////////////////
|
|
/////////////////////////////////////////////////////////
|
|
Ab.bkgMenu=function (menuName,color) {
|
|
if (ns4 || mz7 || chro) {
|
|
screenWidth = window.innerWidth;
|
|
document.layers[menuName].background = color;
|
|
} else {
|
|
screenWidth = document.body.clientWidth;
|
|
document.all[menuName].style.background = color;
|
|
|
|
}
|
|
|
|
}
|
|
///////////////////////////////////////////////
|
|
///////////////////////////////////////////////
|
|
Ab.popUp=function (menuName,left,top) {
|
|
///////////////////////////////////////////////
|
|
///////////////////////////////////////////////
|
|
toleft =typeof left;
|
|
totop =typeof top;
|
|
if (ns4==1) {
|
|
screenWidth = window.innerWidth;
|
|
if (left!=0 && toleft != "undefined")
|
|
{
|
|
// document.layers[menuName].left = left;
|
|
}
|
|
if(top!=0 && totop != "undefined")
|
|
{
|
|
//document.layers[menuName].top = top;
|
|
}
|
|
|
|
|
|
// alert(document.layers[menuName].visibility );
|
|
document.layers[menuName].visibility = "show";
|
|
//alert(document.layers[menuName].visibility );
|
|
|
|
} else {
|
|
screenWidth = document.body.clientWidth;
|
|
if(left!=0 && toleft != "undefined")
|
|
{//alert('l='+left);
|
|
document.getElementById(menuName).style.pixelLeft = left;
|
|
}
|
|
|
|
if(top!=0 && totop != "undefined")
|
|
{//alert('pio2');
|
|
document.getElementById(menuName).style.pixelTop = top;
|
|
}
|
|
|
|
document.getElementById(menuName).style.visibility = "visible";
|
|
|
|
|
|
}
|
|
//registrazione di current tab
|
|
// if ((ct=findObj('currentTab'))!=null)
|
|
// {
|
|
// ct.value=menuName;
|
|
//alert(menuName);
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
Ab.popDown=function (menuName)
|
|
{
|
|
if (ns4 ) {
|
|
document.layers[menuName].visibility = "hide";
|
|
} else {
|
|
//alert("down"+document.getElementById(menuName).style.visibility);
|
|
document.getElementById(menuName).style.visibility = "hidden";
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////
|
|
//determinazione delle coordinate del mouse
|
|
//////////////////////////////////////////////
|
|
grabXY=function (ev){
|
|
|
|
if (ns4 || mz7 || chro) {
|
|
Ab.coordx=ev.pageX;
|
|
Ab.coordy=ev.pageY
|
|
} else {
|
|
Ab.coordx=event.clientX;
|
|
Ab.coordy=event.clientY;
|
|
}
|
|
}
|
|
|
|
Ab.motionListener =function (){
|
|
|
|
if (ns4 || mz7 || chro) {
|
|
|
|
window.addEventListener(Event.MOUSEMOVE,grabXY,true);
|
|
//window.onmousemove = grabXY;
|
|
} else {
|
|
// document.attachEvent(Event.MOUSEMOVE, modifyText);
|
|
document.onmousemove = grabXY;
|
|
}
|
|
}
|
|
//non mi ricordo a che serve questa roba
|
|
Ab.motionListener();
|
|
|
|
|
|
|
|
|
|
Ab.openWin=function (URL){
|
|
aWindow=window.open(URL,"listwindow", "resizable=yes,scrollbars=yes,status=0,width=200,height=100");
|
|
}
|
|
|
|
Ab.newWindow=function (mypage, myname, w, h, scroll) {
|
|
var winl = (screen.width - w) / 2;
|
|
var wint = (screen.height - h) / 2;
|
|
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';
|
|
//alert (mypage+" "+myname+" "+ winprops);
|
|
win = window.open(mypage, myname, winprops);
|
|
|
|
if (parseInt(navigator.appVersion) >= 4)
|
|
{
|
|
win.window.focus();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////7
|
|
/////////////////////////////////////////7
|
|
Ab.leftCenter= function (menuName)
|
|
/////////////////////////////////////////7
|
|
/////////////////////////////////////////7
|
|
{
|
|
left=0;
|
|
|
|
if (ns4 || mz7 || chro) {
|
|
|
|
screenWidth = window.innerWidth;
|
|
//alert('ns mnuname'+menuName);
|
|
layerWidth=parseInt(document.layers[menuName].clip.width);
|
|
|
|
//alert('dopowidth');
|
|
|
|
} else {
|
|
|
|
screenWidth = document.body.clientWidth;
|
|
layerWidth=parseInt(document.getElementById(menuName).style.width);
|
|
}
|
|
|
|
// alert('lw='+layerWidth);
|
|
// alert(screenWidth);
|
|
|
|
// alert('left='+left);
|
|
left=(screenWidth -layerWidth)/2;
|
|
if (left<=0)
|
|
{
|
|
//alert('left;'+left);
|
|
left=1;
|
|
}
|
|
return left;
|
|
|
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////
|
|
/// swap image ///////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////
|
|
Ab.preloadImages= function ()
|
|
{ //v3.0
|
|
|
|
var d=document;
|
|
if(d.images)
|
|
{
|
|
if(!d.MM_p) d.MM_p=new Array();
|
|
var i,j=d.MM_p.length,a=preloadImages.arguments;
|
|
for(i=0; i<a.length; i++)
|
|
if (a[i].indexOf("#")!=0)
|
|
{
|
|
d.MM_p[j]=new Image;
|
|
//alert('loading:'+a[i]);
|
|
d.MM_p[j++].src=a[i];
|
|
}
|
|
}
|
|
}
|
|
|
|
Ab.swapImgRestore=function ()
|
|
{ //v3.0
|
|
var i,x,a=document.sr;
|
|
for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
|
|
x.src=x.oSrc;
|
|
}
|
|
|
|
|
|
|
|
Ab.swapImage=function ()
|
|
{ //v3.0
|
|
var i,j=0,x,a=swapImage.arguments;
|
|
document.sr=new Array;
|
|
for(i=0;i<(a.length-2);i+=3)
|
|
{
|
|
if ((x=Ab.findObj(a[i]))!=null)
|
|
{
|
|
|
|
document.sr[j++]=x;
|
|
if(!x.oSrc)
|
|
x.oSrc=x.src;
|
|
x.src=a[i+2];
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////
|
|
/// valida form //////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////
|
|
Ab.findObj=function (n, d)
|
|
{ //v3.0
|
|
|
|
var p,i,x;
|
|
if(!d)
|
|
d=document;
|
|
if((p=n.indexOf("?"))>0&&parent.frames.length)
|
|
{
|
|
d=parent.frames[n.substring(p+1)].document;
|
|
n=n.substring(0,p);
|
|
}
|
|
if(!(x=d[n])&&d.all)
|
|
x=d.all[n];
|
|
for (i=0;!x&&i<d.forms.length;i++)
|
|
x=d.forms[i][n];
|
|
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
|
|
x=Ab.findObj(n,d.layers[i].document);
|
|
return x;
|
|
}
|
|
|
|
Ab.validateForm2=function () { //v3.0
|
|
//R per required
|
|
//isNum per numerico
|
|
//isNumKey una chiave.. uguale a isNum>0 ma cambio il messaggio
|
|
//isNum>x per numerico maggiore di x
|
|
//isNum<x per numerico minore di x
|
|
//isEmail per indirizzo email
|
|
//inRange1:10 per ..
|
|
//3 stringhe
|
|
//1: nome del field
|
|
//2: se '' visualizza il nome del field, altrimenti questo campo
|
|
//3: R/N+''/isNum/isEmail/inRangea:b
|
|
//
|
|
//esempi
|
|
// validateForm2('nomeform,'textfield','','R','textfield2','','NisNum','textfield3','','NisEmail','textfield4','','RinRange2:10')
|
|
//
|
|
var i,p,q,nm,nf,desc,test,testN,num,min,max,errors='',args=Ab.validateForm2.arguments;
|
|
nf=args[0];
|
|
|
|
var setfoc="";
|
|
|
|
//alert('forms'+nf);
|
|
for (i=1; i<(args.length-2); i+=3)
|
|
{
|
|
test=args[i+2];
|
|
//val=Ab.findObj(args[i]);
|
|
val=document[nf][args[i]];
|
|
|
|
if(args[i+1]=="")
|
|
desc=val.name;
|
|
else
|
|
desc=args[i+1];
|
|
|
|
if (val) { nm=val.name; if ((val=val.value)!="")
|
|
{
|
|
if (test.indexOf('isEmail')!=-1)
|
|
{
|
|
p=val.indexOf('@');
|
|
if (p<1 || p==(val.length-1)) {
|
|
errors+='- '+desc+' non un indirizzo valido.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
|
|
}
|
|
else if (test!='R')
|
|
{
|
|
//alert(val);
|
|
if(locale=="IT")
|
|
{
|
|
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(',','.');
|
|
//tolgo gli zeri finali
|
|
var dotIdx=val.indexOf('.');
|
|
//alert("dotidx0"+dotIdx);
|
|
if(dotIdx!=-1)
|
|
{
|
|
var j=val.length-1;
|
|
/* while(val.charAt(i)!='.' && val.charAt(i)=='0' ) NON FUNZIONA.. forse perche' usavo i invece di j!!*/
|
|
while(val.charAt(j)!='.' )
|
|
{
|
|
//alert("j="+j+" val charat(j):"+val.charAt(j));
|
|
if(val.charAt(j)=='0')
|
|
{
|
|
val=val.substr(0,j);
|
|
j--;
|
|
}
|
|
else j=dotIdx;
|
|
}
|
|
if(val.charAt(val.length-1)=='.')
|
|
val=val.substr(0,val.length-1);
|
|
}
|
|
}
|
|
else if(locale=="US" || locale=="UK")
|
|
{
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace('.',',');
|
|
//tolgo gli zeri finali
|
|
var dotIdx=val.indexOf(',');
|
|
if(dotIdx!=-1){
|
|
var j=val.length-1;
|
|
while(val.charAt(j)!=',')
|
|
{
|
|
if(val.charAt(j)=='0')
|
|
{
|
|
val=val.substr(0,j);
|
|
j--;
|
|
}
|
|
else
|
|
j=dotIdx;
|
|
}
|
|
if(val.charAt(val.length-1)==',')
|
|
val=val.substr(0,val.length-1);
|
|
}
|
|
//alert("US:"+val);
|
|
}
|
|
|
|
|
|
//da correggere il caso 33,40 Non mi accetta lo 0 finale!!!'
|
|
|
|
num = parseFloat(val);
|
|
//alert('num:'+num);
|
|
|
|
// if (val!=''+num && val!=''+num +'0'&& val!=''+num +'00'&& val!=''+num +'000' ) errors+='- '+desc+' non numerico.\n';
|
|
if (val!=''+num) {
|
|
errors+='- '+desc+' non numerico.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
|
|
if(test.search(/[><]/) != -1 )
|
|
{
|
|
if (test.charAt(0) == 'R')
|
|
{
|
|
testN=test.substring(7,test.length);
|
|
}
|
|
else
|
|
{
|
|
testN=test.substring(6,test.length);
|
|
}
|
|
//alert('test:'+test+' tn: '+testN+" num: "+num +" pftn: "+parseFloat(testN));
|
|
if(test.indexOf('>') !=-1 && num <= parseFloat(testN)) {
|
|
errors+='- '+desc+' <= '+testN+'.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
|
|
if(test.indexOf('<') !=-1 && num >= parseFloat(testN)) {
|
|
errors+='- '+desc+' >= '+testN+'.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
|
|
}
|
|
//alert('test:'+test+' tn: '+testN);
|
|
if (test.indexOf('isNumKey') != -1)
|
|
{
|
|
if(num <= 0) {
|
|
errors+='- '+desc+' obbligatorio.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
}
|
|
if (test.indexOf('inRange') != -1)
|
|
{
|
|
p=test.indexOf(':');
|
|
min=test.substring(8,p);
|
|
max=test.substring(p+1);
|
|
if (num<min || max<num) {
|
|
errors+='- '+desc+' deve essere un numero tra '+min+' e '+max+'.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (test.charAt(0) == 'R') {
|
|
errors += '- '+desc+' obbligatorio.\n';
|
|
//alert(i + " - " + errors);
|
|
|
|
if(setfoc==="") {
|
|
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (errors) alert('Il form contiene i seguenti errori:\n'+errors);
|
|
|
|
if(setfoc!=="") {
|
|
//alert(setfoc);
|
|
Ab.setFocus(setfoc);
|
|
}
|
|
|
|
return (errors == '');
|
|
}
|
|
|
|
|
|
Ab.validateForm= function () { //v3.0 23/07/2002
|
|
//R per required
|
|
//isNum per numerico
|
|
//isNumKey una chiave.. uguale a isNum>0 ma cambio il messaggio
|
|
//isNum>x per numerico maggiore di x
|
|
//isNum<x per numerico minore di x
|
|
//isEmail per indirizzo email
|
|
//inRange1:10 per ..
|
|
//3 stringhe
|
|
//1: nome del field
|
|
//2: se '' visualizza il nome del field, altrimenti questo campo
|
|
//3: R/N+''/isNum/isEmail/inRangea:b
|
|
//
|
|
//esempi
|
|
// validateForm('textfield','','R','textfield2','','NisNum','textfield3','','NisEmail','textfield4','','RinRange2:10')
|
|
//
|
|
var i,p,q,nm,desc,test,testN,num,min,max,errors='',args=Ab.validateForm.arguments;
|
|
|
|
/*
|
|
var out = '';
|
|
for (var i in args) {
|
|
out += i + ": " + args[i] + "\n";
|
|
}
|
|
alert(out);
|
|
*/
|
|
|
|
var setfoc="";
|
|
|
|
for (i=0; i<(args.length-2); i+=3)
|
|
{
|
|
test=args[i+2];
|
|
val=Ab.findObj(args[i]);
|
|
|
|
if(args[i+1]=="")
|
|
desc=val.name;
|
|
else
|
|
desc=args[i+1];
|
|
|
|
if (val) { nm=val.name; if ((val=val.value)!="")
|
|
{
|
|
if (test.indexOf('isEmail')!=-1)
|
|
{
|
|
p=val.indexOf('@');
|
|
if (p<1 || p==(val.length-1)) {
|
|
errors+='- '+desc+' non un indirizzo valido.\n';
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
}
|
|
else if (test!='R')
|
|
{
|
|
//alert(val);
|
|
if(locale=="IT")
|
|
{
|
|
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(',','.');
|
|
//tolgo gli zeri finali
|
|
var dotIdx=val.indexOf('.');
|
|
//alert("dotidx0"+dotIdx);
|
|
if(dotIdx!=-1)
|
|
{
|
|
var j=val.length-1;
|
|
/* while(val.charAt(i)!='.' && val.charAt(i)=='0' ) NON FUNZIONA.. forse perche' usavo i invece di j!!*/
|
|
while(val.charAt(j)!='.' )
|
|
{
|
|
//alert("j="+j+" val charat(j):"+val.charAt(j));
|
|
if(val.charAt(j)=='0')
|
|
{
|
|
val=val.substr(0,j);
|
|
j--;
|
|
}
|
|
else j=dotIdx;
|
|
}
|
|
if(val.charAt(val.length-1)=='.')
|
|
val=val.substr(0,val.length-1);
|
|
}
|
|
}
|
|
else if(locale=="US" || locale=="UK")
|
|
{
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace('.',',');
|
|
//tolgo gli zeri finali
|
|
var dotIdx=val.indexOf(',');
|
|
if(dotIdx!=-1){
|
|
var j=val.length-1;
|
|
while(val.charAt(j)!=',')
|
|
{
|
|
if(val.charAt(j)=='0')
|
|
{
|
|
val=val.substr(0,j);
|
|
j--;
|
|
}
|
|
else
|
|
j=dotIdx;
|
|
}
|
|
if(val.charAt(val.length-1)==',')
|
|
val=val.substr(0,val.length-1);
|
|
}
|
|
//alert("US:"+val);
|
|
}
|
|
|
|
|
|
//da correggere il caso 33,40 Non mi accetta lo 0 finale!!!'
|
|
|
|
num = parseFloat(val);
|
|
//alert('num:'+num);
|
|
|
|
// if (val!=''+num && val!=''+num +'0'&& val!=''+num +'00'&& val!=''+num +'000' ) errors+='- '+desc+' non numerico.\n';
|
|
if (val!=''+num) {
|
|
errors+='- '+desc+' non numerico.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
|
|
if(test.search(/[><]/) != -1 )
|
|
{
|
|
if (test.charAt(0) == 'R')
|
|
{
|
|
testN=test.substring(7,test.length);
|
|
}
|
|
else
|
|
{
|
|
testN=test.substring(6,test.length);
|
|
}
|
|
//alert('test:'+test+' tn: '+testN+" num: "+num +" pftn: "+parseFloat(testN));
|
|
if(test.indexOf('>') !=-1 && num <= parseFloat(testN)) {
|
|
errors+='- '+desc+' <= '+testN+'.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
if(test.indexOf('<') !=-1 && num >= parseFloat(testN)) {
|
|
errors+='- '+desc+' >= '+testN+'.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
}
|
|
if (test.indexOf('isNumKey') != -1)
|
|
{
|
|
if(num <= 0) {
|
|
errors+='- '+desc+' obbligatorio.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
}
|
|
if (test.indexOf('inRange') != -1)
|
|
{
|
|
p=test.indexOf(':');
|
|
min=test.substring(8,p);
|
|
max=test.substring(p+1);
|
|
if (num<min || max<num) {
|
|
errors+='- '+desc+' deve essere un numero tra '+min+' e '+max+'.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (test.charAt(0) == 'R') {
|
|
errors += '- '+desc+' obbligatorio.\n';
|
|
|
|
if(setfoc==="") {
|
|
setfoc=args[i];
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
if (errors) alert('Il form contiene i seguenti errori:\n'+errors);
|
|
|
|
if(setfoc!=="") {
|
|
//alert(setfoc);
|
|
Ab.setFocus(setfoc);
|
|
}
|
|
return (errors == '');
|
|
|
|
}
|
|
//ckAll per combobox
|
|
Ab.checkAll= function (f,ckAll)
|
|
{
|
|
for (var i=0;i<f.elements.length;i++)
|
|
{
|
|
var e = f.elements[i];
|
|
if (e.name != ckAll)
|
|
e.checked = f[ckAll].checked;
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////
|
|
//funzioni di menu
|
|
//////////////////////////////////
|
|
Ab.callSvlt= function (theSvlt)
|
|
{ var f = document.menu;
|
|
if (theSvlt.charAt(0)=="/")
|
|
{ //path assoluto
|
|
theSvlt=webApp+theSvlt;
|
|
}
|
|
f.action=theSvlt+".Svlt";
|
|
f.cmd.value="search";
|
|
f.submit();
|
|
}
|
|
|
|
Ab.callAbl4=function (theSvlt,theCmd,theAct)
|
|
{
|
|
var f = document.menu;
|
|
//default
|
|
var cmd="search";
|
|
var act="";
|
|
if(theCmd!=null)
|
|
cmd=theCmd;
|
|
if(theAct!=null)
|
|
act=theAct;
|
|
if (theSvlt.charAt(0)=="/")
|
|
{//path assoluto
|
|
theSvlt=webApp+theSvlt;
|
|
}
|
|
|
|
f.action=theSvlt+".abl";
|
|
alert(f.action);
|
|
f.cmd.value=cmd;
|
|
f.act.value=act;
|
|
//f.submit();
|
|
Ab.submitAj("menu",null,"mainContent");
|
|
}
|
|
|
|
Ab.closeWindow=function ()
|
|
{
|
|
if(confirm("Vuoi chiudere la finestra? (il record NON sar aggiornato)"))
|
|
window.close();
|
|
}
|
|
|
|
Ab.getVal =function (field)
|
|
{
|
|
var val=Ab.findObj(field);
|
|
if (val)
|
|
val=val.value;
|
|
else
|
|
val="";
|
|
return val;
|
|
}
|
|
////////////////////////////////
|
|
//change language
|
|
////////////////////////////////
|
|
Ab.lang =function (code)
|
|
{
|
|
var hrf=location.href;
|
|
//alert (hrf);
|
|
var f = document.menu;
|
|
f.action="Lang.abl";
|
|
f.hrf.value=hrf;
|
|
f.lang.value=code;
|
|
f.submit();
|
|
}
|
|
|
|
////////////////////////////////
|
|
//clrfield (pulisce l'elenco dei campi passati come parametri
|
|
////////////////////////////////
|
|
Ab.clrField= function ()
|
|
{
|
|
var args=Ab.clrField.arguments;
|
|
var f = document[args[0]];
|
|
|
|
var length = args.length;
|
|
///che senso ha questo???
|
|
//if(args.length % 2 == 0)
|
|
//{
|
|
// length = length - 1;
|
|
//}
|
|
|
|
for (i=1; i<(length); i++)
|
|
{
|
|
if (f[args[i]].type == "checkbox")
|
|
{
|
|
f[args[i]].checked = false;
|
|
}
|
|
else
|
|
{
|
|
f[args[i]].value="";
|
|
}
|
|
}
|
|
// se c'è un primo campo (penso ci sia sempre) ci metto il focus
|
|
if(args[2].length>0){
|
|
//$('#'+args[1]).select();
|
|
//$('#'+args[1]).focus();
|
|
Ab.setFocus(args[2]);
|
|
//alert(args[1].length + " " + args[1]);
|
|
}
|
|
|
|
if(args.length % 2 == 0)
|
|
{
|
|
Ab.executeProcess(args[length], "");
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////
|
|
// SCELTA AUTOMATICA LINGUA DEL BROWSER
|
|
//////////////////////////////////////////
|
|
Ab.getBrowserLang=function (){
|
|
var lang;
|
|
if(typeof navigator.userLanguage != "undefined"){
|
|
lang=navigator.userLanguage.toLowerCase();
|
|
}
|
|
else if(typeof navigator.language != "undefined"){
|
|
lang=navigator.language.toLowerCase();
|
|
}
|
|
else{
|
|
lang=locale.toLowerCase;
|
|
}
|
|
if(lang.length>2)
|
|
lang=lang.substring(0,2);
|
|
return lang;
|
|
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
// REDIRET LANG
|
|
/*
|
|
funzione per fare il redirect della stessa pagina ma con la lingua del browser.
|
|
Subito dopo function.js iserire
|
|
<form name="langForm"><input name="hrf" type="hidden" /><input name="lang" type="hidden" value="<%=lang%>" /></form><script language="JavaScript1.2" >if(document.langForm.lang.value=="")redirectLang();</script>
|
|
*/
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
Ab.redirectLang= function ()
|
|
{
|
|
code=getBrowserLang();
|
|
var hrf=location.href;
|
|
//alert (hrf);
|
|
var f = document.langForm;
|
|
f.action="Lang.abl";
|
|
f.hrf.value=hrf;
|
|
//devo verificare il parametro lang....
|
|
//se non sepcificato scelgo inglese
|
|
//alert("redlang "+code);
|
|
//##############################
|
|
// QUESTA PARTE POTREBBE VARIARE A SECONDA DELLE LINGUE SUPPORTATE DAL SITO
|
|
//##################################################
|
|
if(code=="" || code =="it" || code =="en")
|
|
f.lang.value=code;
|
|
else
|
|
f.lang.value="en";
|
|
|
|
f.submit();
|
|
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
// GESTIONE ELEMENTI DEI FORM
|
|
//////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////
|
|
// radio button
|
|
//////////////////////////////////////////////////////
|
|
Ab.setRadioButtonValue= function (formName,flgName)
|
|
{
|
|
//imposta un campo hidden di none flgName al valore del radio button 'rb'+flgname selezionato
|
|
//es: setRadioButtonValue("dettaglio","flgPlaAntPos");
|
|
//var f = document.form[formName];
|
|
var f = document.getElementById(formName);
|
|
var flag=document.getElementById(flgName);
|
|
if(flag!=null)
|
|
{
|
|
var radioGrp=f['rb'+flgName];
|
|
//var radioGrp=document.getElementById('rb'+flgName);
|
|
|
|
flag.value="";
|
|
for (var i = 0; i< radioGrp.length; i++)
|
|
{
|
|
if (radioGrp[i].checked) {
|
|
flag.value=radioGrp[i].value;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
// CHECK BOX
|
|
//////////////////////////////////////////////////////
|
|
Ab.setChekBoxValue=function (formName,flgName,ckValue,unckValue)
|
|
{
|
|
//imposta un campo hidden di none flgName al valore del ckValue se checked, unckValue se unchecked
|
|
//es: setChekBoxValue("dettaglio","flgSommaCRL","1","0");
|
|
//var f = document.form[formName];
|
|
var f = document.getElementById(formName);
|
|
//alert('flgName: '+flgName);
|
|
var flag=document.getElementById(flgName);
|
|
if(flag!=null)
|
|
{
|
|
//var ckbox=f['ck'+flgName];
|
|
var ckbox=document.getElementById('ck'+flgName);
|
|
if(ckbox!=null){
|
|
if (ckbox.checked)flag.value=ckValue;else flag.value=unckValue;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
// open viewwindow.... non credo di utilizzarlo più
|
|
//////////////////////////////////////////////////////
|
|
Ab.openViewWindow= function () {
|
|
// usare openViewWindow(comando, larghezza, altezza);
|
|
windowWidth=500;
|
|
windowHeigth=200;
|
|
searchSvlt = arguments[0];
|
|
//campo di ritorno completo
|
|
|
|
//larghezza finestra di ricerca
|
|
if (arguments[1]!=null)
|
|
{
|
|
windowWidth=arguments[1];
|
|
}
|
|
//altezza finestra di ricerca
|
|
if (arguments[2]!=null)
|
|
{
|
|
windowHeigth=arguments[2];
|
|
}
|
|
if (searchSvlt.charAt(0)=="/")
|
|
{//path assoluto
|
|
searchSvlt=webApp+searchSvlt;
|
|
}
|
|
if(searchSvlt.indexOf("?")>0)
|
|
swcmd="&cmd=view";
|
|
else
|
|
swcmd="?cmd=view";
|
|
if(debug==false)
|
|
{
|
|
|
|
|
|
ggWinView = window.open(searchSvlt+swcmd, "View_Window","width="+windowWidth+",height="+windowHeigth+",status=no,resizable=yes,top=100,left=100,scrollbars=yes");
|
|
}
|
|
else
|
|
{
|
|
ggWinView = window.open(searchSvlt+swcmd);
|
|
}
|
|
|
|
ggWinView.opener = self;
|
|
|
|
|
|
|
|
}
|
|
|
|
/////////////////////////////////////////////////
|
|
// GESTIONE FORM INSERIMENTO PER AUTOMATISMI
|
|
//
|
|
// UTILIZZARE SU CAMPI
|
|
// onFocus="this.select();" onKeyDown="focusNextOnCr(event,'XXXXX');" onKeyUp="return focusNext(this,event,'XXXX',NN);"
|
|
// SE ICLUSO ANCHE dateInput.js
|
|
// PER I CAMPI DATA
|
|
//// onFocus="this.select();" onChange="checkDate(this);printDate(this,'giorno')" onKeyDown="if(event.keyCode==13) {focusNextOnCr(event,'XXXXX');} else {formatDate(this, window.event.keyCode,'down')}" onKeyUp="formatDate(this, window.event.keyCode,'up');focusNext(this,event,'XXXX',10);"
|
|
// PER I CAMPI TIME
|
|
// onFocus="this.select();" onChange="" onKeyDown="if(event.keyCode==13) {focusNextOnCr(event,'XXXX');} else {formatTime(this, window.event.keyCode,'down')}" onKeyUp="formatTime(this, window.event.keyCode,'up');focusNext(this,event,'XXX',5);"
|
|
/////////////////////////////////////////////////
|
|
Ab.focusNextOnCr= function (e,nextField)
|
|
{
|
|
var field = e.target.id;
|
|
|
|
//F1==112
|
|
//ctrlKey
|
|
//shiftKey
|
|
//altKey
|
|
|
|
//utlilizzare
|
|
//onKeyDown="focusNextOnCr(event,nextField);"
|
|
var keyCode = e.keyCode;
|
|
//alert(e.shiftKey+" "+e.ctrlKey+" "+e.altKey+" "+keyCode);
|
|
if(keyCode==13) {
|
|
if(nextField=="")
|
|
{
|
|
Ab.rendiNextField(this);
|
|
}
|
|
else
|
|
{
|
|
document.getElementById(nextField).focus();
|
|
}
|
|
}
|
|
//else if(keyCode>=112 && keyCode<=124)
|
|
else if((e.altKey && keyCode==112) || keyCode==112)
|
|
{
|
|
e.preventDefault();
|
|
var value = $('[nextField="' + field + '"]').val();
|
|
|
|
console.dir(value);
|
|
|
|
if ($('[nextField="' + field + '"]').val() != undefined)
|
|
{
|
|
$('[nextField="' + field + '"]').focus();
|
|
}
|
|
else
|
|
{
|
|
var prev = Ab.rendiPrevField(field);
|
|
|
|
$('[name="' + prev + '"]').focus();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
Ab.focusNext= function (input,e,nextField,len)
|
|
{
|
|
//utilizzare onKeyUp="return focusNext(this,event,'field',nn);
|
|
//var keyCode = (isNN) ? e.which : e.keyCode;
|
|
// var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
|
|
|
|
var keyCode = e.keyCode;
|
|
var filter = [0,8,9,16,17,18,37,38,39,40,46];
|
|
var f = document.main;
|
|
//if(event.keyCode==13) {document.getElementById('codiceTS').focus();
|
|
if(keyCode!=13 && input.value.length >= len && !containsElement(filter,keyCode)) {
|
|
input.value = input.value.slice(0, len);
|
|
//elemento successivo
|
|
//input.form[(getIndex(input)+1) % input.form.length].focus();
|
|
document.getElementById(nextField).focus()
|
|
}
|
|
|
|
function containsElement(arr, ele) {
|
|
var found = false, index = 0;
|
|
while(!found && index < arr.length)
|
|
if(arr[index] == ele)
|
|
found = true;
|
|
else
|
|
index++;
|
|
return found;
|
|
}
|
|
|
|
function getIndex(input) {
|
|
var index = -1, i = 0, found = false;
|
|
while (i < input.form.length && index == -1)
|
|
if (input.form[i] == input)index = i;
|
|
else i++;
|
|
return index;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
//funzioni trim stringa
|
|
//////////////////////////////////////
|
|
Ab.leftTrim =function (stringa)
|
|
{
|
|
while (stringa.substring(0,1) == ' ')
|
|
{
|
|
stringa = stringa.substring(1, stringa.length);
|
|
}
|
|
return stringa;
|
|
}
|
|
|
|
|
|
Ab.rightTrim= function (stringa)
|
|
{
|
|
while (stringa.substring(stringa.length-1, stringa.length) == ' ')
|
|
{
|
|
stringa = stringa.substring(0,stringa.length-1);
|
|
}
|
|
return stringa;
|
|
}
|
|
|
|
|
|
Ab.trim =function (stringa)
|
|
{
|
|
while (stringa.substring(0,1) == ' ')
|
|
{
|
|
stringa = stringa.substring(1, stringa.length);
|
|
}
|
|
while (stringa.substring(stringa.length-1, stringa.length) == ' ')
|
|
{
|
|
stringa = stringa.substring(0,stringa.length-1);
|
|
}
|
|
return stringa;
|
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////
|
|
//// focus
|
|
//////////////////////////////////////////////////
|
|
Ab.setFocus=function (theField)
|
|
{
|
|
//alert(theField);
|
|
if($("#"+theField).val()!=undefined)
|
|
{
|
|
$("#"+theField).select();
|
|
$("#"+theField).focus();
|
|
}
|
|
//document.getElementById(theField).focus();
|
|
//if(document.getElementById(theField).type!='select-one')
|
|
// document.getElementById(theField).select();
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
// funzione per prendere un elemento con id univoco
|
|
// con jquery è praticamente inutile
|
|
//////////////////////////////////////////////////
|
|
Ab.prendiElementoDaId= function (id_elemento) {
|
|
var elemento;
|
|
if(document.getElementById)
|
|
elemento = document.getElementById(id_elemento);
|
|
else
|
|
elemento = document.all[id_elemento];
|
|
return elemento;
|
|
}
|
|
|
|
Ab.getValId= function (id_elemento){
|
|
return Ab.prendiElementoDaId(id_elemento).value;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////
|
|
// lancio l'help
|
|
////////////////////////////////////////////////////////
|
|
Ab.help= function (cod)
|
|
{
|
|
if(cod==null){
|
|
cod=getValId("actionPage");
|
|
cod=cod.substring(0,cod.length-4);
|
|
//alert(document.main)
|
|
if($('#pageType').val()=='R')
|
|
cod=cod+"_CR";
|
|
//alert(cod);
|
|
}
|
|
//theAction=webApp+"/admin/help/v/H.abl?cmd=view&cod="+cod;
|
|
theMainHelpPage=webApp+"/admin/help/v/index.jsp?cod="+cod;
|
|
//debug
|
|
//helpWin=window.open(theMainHelpPage);
|
|
//NO DEBUG
|
|
helpWin=window.open(theMainHelpPage, "HELP","width=1020,height=700,status=yes,resizable=yes,top=0,left=0,scrollbars=yes");
|
|
//helpWin=dhtmlwindow.open('helpBox', 'ajax', 'external.htm', 'Help - '+id, 'width=650px,height=400px,left=300px,top=100px,resize=0,scrolling=1');
|
|
|
|
|
|
}
|
|
|
|
Ab.helpW=function (titolo, pagina, ww, hh )
|
|
{
|
|
//help del bean definito da actionPage
|
|
//alert(tableName);
|
|
helpWinW=dhtmlwindow.open('helpBox', 'ajax', pagina, 'Help - '+titolo, 'width='+ww+'px,height='+hh+'px,left=300px,top=100px,resize=1,scrolling=1');
|
|
}
|
|
|
|
Ab.closeHW=function()
|
|
{
|
|
if(typeof(helpWinW)!= "undefined")
|
|
helpWinW.close();
|
|
else
|
|
{
|
|
|
|
window.close();
|
|
}
|
|
|
|
}
|
|
|
|
////////////////////////////////////////////////////////
|
|
// build sitemat è in tutte le servlet
|
|
////////////////////////////////////////////////////////
|
|
Ab.buildSitemap= function ()
|
|
{
|
|
|
|
if(confirm("Vuoi creare la sitemap?"))
|
|
{
|
|
var f = document.main;
|
|
f.action=f.actionPage.value;
|
|
f.fileName.value=prompt("Inserisci nome file (vuoto per nome file default)",f.fileName.value);
|
|
//alert('pio_'+f.eMail.value);
|
|
if(f.fileName.value!='null')
|
|
{
|
|
//popUp("ELAB");
|
|
f.cmd.value="buildSM";
|
|
f.submit();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
// executeFunctionByName
|
|
////////////////////////////////////////////////////////////////////////
|
|
Ab.executeFunctionByName=function (functionName, context, args) {
|
|
//var args = Array.prototype.slice.call(arguments).splice(2);
|
|
var namespaces = functionName.split(".");
|
|
var func = namespaces.pop();
|
|
|
|
//luca
|
|
//var arg = args.split(',');
|
|
|
|
for(var i = 0; i < namespaces.length; i++) {
|
|
context = context[namespaces[i]];
|
|
}
|
|
|
|
//alert('Function: executeFunctionByName');
|
|
//alert(func + " - " + args);
|
|
|
|
// la call vuole i paramtri divisi da virgola come fosse una chiamata normale
|
|
return context[func].call(this, args);
|
|
|
|
// la apply vuole i parametri come vettore
|
|
//return context[func].apply(this, arg);
|
|
}
|
|
|
|
//////////////////////////////////////////////
|
|
//per aggiungere l'editor html all'elemento
|
|
////////////////////////////////////////////
|
|
|
|
/********************************************************/
|
|
/********** == validate form 2 + gestisce le lingue ***/
|
|
/********************************************************/
|
|
|
|
Ab.validateForm3= function () { //v3.0
|
|
//R per required
|
|
//isNum per numerico
|
|
//isNumKey una chiave.. uguale a isNum>0 ma cambio il messaggio
|
|
//isNum>x per numerico maggiore di x
|
|
//isNum<x per numerico minore di x
|
|
//isEmail per indirizzo email
|
|
//inRange1:10 per ..
|
|
//3 stringhe
|
|
//1: nome del field
|
|
//2: se '' visualizza il nome del field, altrimenti questo campo
|
|
//3: R/N+''/isNum/isEmail/inRangea:b
|
|
//
|
|
//esempi
|
|
// validateForm3('en','nomeform,'textfield','','R','textfield2','','NisNum','textfield3','','NisEmail','textfield4','','RinRange2:10')
|
|
//
|
|
var i,p,q,nm,nf,lang,desc,test,testN,num,min,max,errors='',args=Ab.validateForm3.arguments;
|
|
//default
|
|
var langIdx=0;
|
|
lang=args[0];
|
|
//per aumentare le lingue....
|
|
if(lang=="en")
|
|
langIdx=1;
|
|
nf=args[1];
|
|
//messaggi. Arrei in lingua. 1 italiano, 2 inglese
|
|
msg_mail = [" non un indirizzo valido.\n", " is not a valid email address.\n"];
|
|
msg_number = [" non numerico.\n", " is not a number.\n"];
|
|
msg_mand = [" obbligatorio.\n", " is a mandatory field.\n"];
|
|
msg_err = ["Il form contiene i seguenti errori:\n", "Errors founds on the form:\n"];
|
|
msg_betw = [" deve essere un numero tra ", " the number must be betwen "];
|
|
msg_betwAnd = [" e "," and "];
|
|
|
|
|
|
for (i=2; i<(args.length-2); i+=3)
|
|
{
|
|
test=args[i+2];
|
|
//val=Ab.findObj(args[i]);
|
|
val=document[nf][args[i]];
|
|
|
|
if(args[i+1]=="")
|
|
desc=val.name;
|
|
else
|
|
desc=args[i+1];
|
|
|
|
if (val) { nm=val.name; if ((val=val.value)!="")
|
|
{
|
|
if (test.indexOf('isEmail')!=-1)
|
|
{
|
|
p=val.indexOf('@');
|
|
if (p<1 || p==(val.length-1)) errors+='- '+desc+msg_mail[langIdx];
|
|
}
|
|
else if (test!='R')
|
|
{
|
|
//alert(val);
|
|
if(locale=="IT")
|
|
{
|
|
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(/[.]/,'');
|
|
val=val.replace(',','.');
|
|
//tolgo gli zeri finali
|
|
var dotIdx=val.indexOf('.');
|
|
//alert("dotidx0"+dotIdx);
|
|
if(dotIdx!=-1)
|
|
{
|
|
var j=val.length-1;
|
|
/* while(val.charAt(i)!='.' && val.charAt(i)=='0' ) NON FUNZIONA.. forse perche' usavo i invece di j!!*/
|
|
while(val.charAt(j)!='.' )
|
|
{
|
|
//alert("j="+j+" val charat(j):"+val.charAt(j));
|
|
if(val.charAt(j)=='0')
|
|
{
|
|
val=val.substr(0,j);
|
|
j--;
|
|
}
|
|
else j=dotIdx;
|
|
}
|
|
if(val.charAt(val.length-1)=='.')
|
|
val=val.substr(0,val.length-1);
|
|
}
|
|
}
|
|
else if(locale=="US" || locale=="UK")
|
|
{
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace(/[,]/,'');
|
|
val=val.replace('.',',');
|
|
//tolgo gli zeri finali
|
|
var dotIdx=val.indexOf(',');
|
|
if(dotIdx!=-1){
|
|
var j=val.length-1;
|
|
while(val.charAt(j)!=',')
|
|
{
|
|
if(val.charAt(j)=='0')
|
|
{
|
|
val=val.substr(0,j);
|
|
j--;
|
|
}
|
|
else
|
|
j=dotIdx;
|
|
}
|
|
if(val.charAt(val.length-1)==',')
|
|
val=val.substr(0,val.length-1);
|
|
}
|
|
//alert("US:"+val);
|
|
}
|
|
|
|
|
|
//da correggere il caso 33,40 Non mi accetta lo 0 finale!!!'
|
|
|
|
num = parseFloat(val);
|
|
//alert('num:'+num);
|
|
|
|
// if (val!=''+num && val!=''+num +'0'&& val!=''+num +'00'&& val!=''+num +'000' ) errors+='- '+desc+' non numerico.\n';
|
|
if (val!=''+num) errors+='- '+desc+msg_number[langIdx];
|
|
if(test.search(/[><]/) != -1 )
|
|
{
|
|
if (test.charAt(0) == 'R')
|
|
{
|
|
testN=test.substring(7,test.length);
|
|
}
|
|
else
|
|
{
|
|
testN=test.substring(6,test.length);
|
|
}
|
|
//alert('test:'+test+' tn: '+testN+" num: "+num +" pftn: "+parseFloat(testN));
|
|
if(test.indexOf('>') !=-1 && num <= parseFloat(testN)) errors+='- '+desc+' <= '+testN+'.\n';
|
|
if(test.indexOf('<') !=-1 && num >= parseFloat(testN)) errors+='- '+desc+' >= '+testN+'.\n';
|
|
|
|
}
|
|
//alert('test:'+test+' tn: '+testN);
|
|
if (test.indexOf('isNumKey') != -1)
|
|
{
|
|
if(num <= 0) errors+='- '+desc+msg_mand[langIdx];
|
|
}
|
|
if (test.indexOf('inRange') != -1)
|
|
{
|
|
p=test.indexOf(':');
|
|
min=test.substring(8,p);
|
|
max=test.substring(p+1);
|
|
if (num<min || max<num) errors+='- '+desc+msg_betw[langIdx]+min+msg_betwAnd[langIdx];+max+'.\n';
|
|
}
|
|
}
|
|
}
|
|
else if (test.charAt(0) == 'R') errors += '- '+desc+msg_mand[langIdx]; }
|
|
}
|
|
if (errors) alert(msg_err[langIdx]+errors);
|
|
return (errors == '');
|
|
|
|
|
|
}
|
|
|
|
////////////////////////////////////////////////
|
|
// aggiusta i campi euro e "
|
|
/////////////////////////////////////////////
|
|
Ab.aggiustaInputText= function (campo)
|
|
{
|
|
//var f = document.main;
|
|
campo.value=campo.value.replace(/\u20ac/g,"€");
|
|
campo.value=campo.value.replace("\"",""");
|
|
|
|
}
|
|
|
|
////////////////////////////////////////////////
|
|
//gestione submit per form dettaglio e ricerca
|
|
////////////////////////////////////////////////
|
|
Ab.submitForm= function (evt)
|
|
{
|
|
if($("#pageType").val()=="D")
|
|
{
|
|
//dettaglio
|
|
saveCommand();
|
|
}
|
|
else if($("#pageType").val()=="R")
|
|
{
|
|
//ricerca
|
|
searching();
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////
|
|
// utilizzata per il salvataggio di una pagina
|
|
// e riposizionamento sul campo successivo
|
|
// di solito con
|
|
// jsDateInputS
|
|
// jsTimeInputS
|
|
// jsNumberInputS
|
|
// jsCrS
|
|
//////////////////////////////////////////////////
|
|
Ab.saveNextFocus=function (evt,nextFocus)
|
|
{
|
|
$("#currentFocus").val(nextFocus);
|
|
Ab.submitForm(evt);
|
|
}
|
|
|
|
////////////////////////////////
|
|
//rendiNextField(field,[num])
|
|
//restituisce il primo campo successivo a field
|
|
// oppure num campo successivo
|
|
////////////////////////////////
|
|
Ab.rendiNextField= function () {
|
|
var args=Ab.rendiNextField.arguments,
|
|
field=args[0],
|
|
num=1,
|
|
name="";
|
|
//alert(args.length);
|
|
if(args.length==2)
|
|
num=args[1];
|
|
//alert("num:"+num);
|
|
var allInputs = $("input, textarea, select");
|
|
var ret = "";
|
|
//alert("1:"+field.name);
|
|
|
|
if (field.name != undefined)
|
|
{
|
|
name = field.name;
|
|
}
|
|
else
|
|
{
|
|
name = $("#"+field).attr("name");
|
|
}
|
|
|
|
for (var i = 0; i < allInputs.length; i++) {
|
|
|
|
if (allInputs[i].name == name) {
|
|
ret = allInputs[i + num].name;
|
|
}
|
|
}
|
|
//alert("2:"+ret);
|
|
return ret;
|
|
}
|
|
|
|
////////////////////////////////
|
|
//rendiPrevField(field,[num])
|
|
//restituisce il primo campo precedente a field
|
|
// oppure num campo successivo
|
|
////////////////////////////////
|
|
Ab.rendiPrevField= function () {
|
|
var args=Ab.rendiPrevField.arguments,
|
|
field=args[0],
|
|
num=1,
|
|
name="";
|
|
//alert(args.length);
|
|
if(args.length==2)
|
|
num=args[1];
|
|
var allInputs = $("input, textarea, select");
|
|
var ret = "";
|
|
|
|
if (field.name != undefined)
|
|
{
|
|
name = field.name;
|
|
}
|
|
else
|
|
{
|
|
name = $("#"+field).attr("name");
|
|
}
|
|
|
|
for (var i = allInputs.length - 1; i > 0; i--) {
|
|
if(allInputs[i].type != "hidden" && allInputs[i].type != "")
|
|
{
|
|
if (allInputs[i].name == name) {
|
|
ret = allInputs[i - num].name;
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
//alert("2:"+ret);
|
|
return ret;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////
|
|
// esegue una funzione che pu avere o meno i parametri
|
|
// quindi
|
|
// xxx()
|
|
// oppure
|
|
// xx(arg1,arg2,...)
|
|
//////////////////////////////////////////////////////
|
|
Ab.executeProcess=function (postProcess, ppArgs)
|
|
{
|
|
if(postProcess!=null){
|
|
var idx1=postProcess.indexOf("(");
|
|
var func=postProcess.substring(0,idx1);
|
|
//verifico se ci sono argomenti
|
|
//se ho argomenti uso quelli come parametri
|
|
//altrimenti eseguo la funziona passando
|
|
//il parametro successivo
|
|
var idx2=postProcess.lastIndexOf(")");
|
|
if((idx2-idx1)==1){
|
|
//non ci sono parametri
|
|
if(ppArgs === undefined || ppArgs==null)
|
|
Ab.executeFunctionByName(func,window);
|
|
else
|
|
Ab.executeFunctionByName(func,window,ppArgs);
|
|
}
|
|
else{
|
|
//ci sono parametri....
|
|
//alert('con parm');
|
|
var args=postProcess.substring(idx1+1,idx2);
|
|
//alert(func+" x"+args+"xx");
|
|
Ab.executeFunctionByName(func,window,args);
|
|
}
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////
|
|
// funzione che mi sottomette un form
|
|
// e ricarica l'intero body
|
|
//si potrebbe anche passare un altro parametro
|
|
//che mi indica l'id da ricaricare....
|
|
//////////////////////////////////////////////
|
|
Ab.submitAj=function (theForm, cmd, target,postProcess,async)
|
|
{
|
|
//gestione async
|
|
if(async!= undefined && async!=null){
|
|
$("#_async").val(async);
|
|
}
|
|
else
|
|
{
|
|
$("#_async").val("");
|
|
}
|
|
//mi serve per capire se faccio una chiamata ajax
|
|
//per gestire la caduta della sessione?
|
|
//tipo chiamata
|
|
if(target != undefined && target!=null){
|
|
$("#_callType").val("_target");
|
|
}
|
|
else
|
|
{
|
|
$("#_callType").val("_body");
|
|
}
|
|
//
|
|
if(cmd != undefined && cmd!=null){
|
|
$("#"+theForm+" input[id=cmd]").val(cmd);
|
|
}
|
|
//
|
|
$.ajax({
|
|
type: "POST",
|
|
url: $("#"+theForm).attr("action"),
|
|
data: $("#"+theForm).serialize(),
|
|
dataType: 'html',
|
|
cache:'false',
|
|
success: function (response) {
|
|
$("#_async").val("");
|
|
/////////////////////
|
|
// var $frag=$(response);
|
|
// console.log( $frag.filter('form').get());
|
|
//
|
|
//regex che mi tira fuori tutto c' che c'
|
|
//dentro il body
|
|
//var bodyHtml = /<body.*?>([\s\S]*)<\/body>/.exec(response)[1];
|
|
if(target === undefined || target==null){
|
|
//sostituisco il body
|
|
//$("html").html(response);
|
|
var bodyHtml = /<body>([\s\S]*)<\/body>/.exec(response)[1];
|
|
//ricarico tutto il body
|
|
$("body").html(bodyHtml);
|
|
//titolo
|
|
var title = /<title>([\s\S]*)<\/title>/.exec(response)[1];
|
|
//alert(window.parent.document);
|
|
//ricarico il titolo
|
|
//if(window.parent.document != "undefined")
|
|
$( window.parent.document ).prop('title',title);
|
|
//else
|
|
// $(document ).prop('title',title);
|
|
Ab.setFocus($("#currentFocus").val());
|
|
}
|
|
else
|
|
{
|
|
//non riesco a capire se ho la
|
|
//sessione scaduta!!!!!!!!!!!
|
|
//DA TESTARE
|
|
$("#"+target).html(response);
|
|
}
|
|
|
|
//postprocess
|
|
if(postProcess != undefined && postProcess!=null){
|
|
Ab.executeProcess(postProcess);
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////
|
|
//
|
|
///////////////////////////////////////////////
|
|
Ab.printPdf= function (titolo, pagina, ww, hh )
|
|
{
|
|
var w=500, h=400;
|
|
if(ww!=null)
|
|
w=ww;
|
|
if(hh!=null)
|
|
h=hh;
|
|
//
|
|
window.open(pagina, titolo,"width="+w+",height="+h+",status=yes,resizable=yes,top=0,left=0,scrollbars=yes");
|
|
|
|
//dhtmlwindow.open('Pdf print', 'iframe', pagina, ' '+titolo, 'width='+w+'px,height='+h+'px,left=300px,top=100px,resize=1,scrolling=1');
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
// fetch
|
|
// chiama la servlet passandogli i comandi e ritorna un valore che viene inserito o nella divList
|
|
// oppure passato come parametro alla funzione postProcess
|
|
// DA TESTARE A FONDO...
|
|
//////////////////////////////////////////////////////
|
|
Ab.fetch=function (servlet, command, divList, postProcess, async, type) {
|
|
//gestione chiamate asincrone
|
|
if(async!= undefined && async!=null){
|
|
$("#_async").val(async);
|
|
//imposto una immagine di attesa
|
|
$("#"+divList).html("<img src='"+webApp+"/admin/_V3/_img/attesa.gif' width='16' height='16'>");
|
|
//alert('pio');
|
|
}
|
|
else
|
|
{
|
|
$("#_async").val("");
|
|
}
|
|
|
|
if (async==undefined) {
|
|
async=true;
|
|
}
|
|
|
|
if (type==undefined) {
|
|
type = "html";
|
|
}
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: servlet,
|
|
data: command,
|
|
dataType: type,
|
|
async: async,
|
|
success: function(msg)
|
|
{
|
|
$("#_async").val("");
|
|
if ("#"+divList!=null){
|
|
$("#"+divList).html(msg);
|
|
if(postProcess!=null){
|
|
Ab.executeProcess(postProcess,msg);
|
|
}
|
|
}
|
|
else if(postProcess!=null){
|
|
Ab.executeProcess(postProcess, msg);
|
|
}
|
|
},
|
|
error: function()
|
|
{
|
|
$("#"+divList).html("Chiamata fallita, si prega di riprovare...");
|
|
//alert("Chiamata fallita, si prega di riprovare...");
|
|
$("#_async").val("");
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////
|
|
// salva l'immagine tramite ajax
|
|
////////////////////////////////////////
|
|
Ab.saveImage =function (id,codImage)
|
|
{
|
|
//grab all form data
|
|
// $('#cmd').val("loadImg");
|
|
//var formData = new FormData($('form#main')[0]);
|
|
|
|
//alert(document.getElementById("btn-upload_"+codImage));
|
|
var sampleFile = document.getElementById("btn-upload_"+codImage).files[0];
|
|
var oMyForm = new FormData();
|
|
//oMyForm.append("file", $('#imgFile_'+codImage).files[0]);
|
|
oMyForm.append("imgFile", sampleFile);
|
|
oMyForm.append("cmd","loadImg");
|
|
oMyForm.append("totImgNumber",$("#totImgNumber").val());
|
|
oMyForm.append("codImage",codImage);
|
|
oMyForm.append("id",id);
|
|
// oMyForm.append("nomeOriginale",id);
|
|
//alert(sampleFile);
|
|
if(typeof sampleFile!="undefined")
|
|
{
|
|
$("#imgNew_"+codImage).attr("src", "../_V3/_img/wait.gif");
|
|
|
|
var action = "";
|
|
|
|
if($("#actionPage", "#main"))
|
|
{
|
|
action = $("#actionPage", "#main").val();
|
|
}
|
|
else
|
|
{
|
|
action = $("#main").attr("action");
|
|
}
|
|
|
|
$.ajax({
|
|
url: action,
|
|
type: 'POST',
|
|
data: oMyForm,
|
|
chache: false,
|
|
async: true,
|
|
processData: false, // tell jQuery not to process the data
|
|
contentType: false, // tell jQuery not to set contentType
|
|
//xhr: opt.progress,
|
|
beforeSend : function (){},
|
|
success: function(response){
|
|
var result = $.parseJSON(response);
|
|
//
|
|
//alert(result[0].message);
|
|
$('#messaggi').fadeIn(100);
|
|
$('#messaggi').html(result[0].message);
|
|
//cancello msg dopo il timeout
|
|
if($('#messaggi').length>0)
|
|
msgInterval=setTimeout( "$('#messaggi').fadeOut(200);msgGone=true",10000 );
|
|
//carico l'immagine
|
|
//alert(result[0].imgPath);
|
|
|
|
Ab.showImgBtnArea(codImage);
|
|
$('#imgNew_'+codImage).attr("src", result[0].imgPath).load(function(){
|
|
this.width;
|
|
// Note: $(this).width() will not work for in memory images
|
|
});
|
|
|
|
|
|
|
|
},
|
|
error: function() {
|
|
$("#imgNew_"+codImage).attr("src", "../_V3/_img/placeHold.gif");
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////
|
|
// cancella l'immagine annuncio tramite ajax
|
|
//////////////////////////////////////////
|
|
Ab.deleteImage=function (id,codImage)
|
|
{
|
|
//grab all form data
|
|
// $('#cmd').val("loadImg");
|
|
//var formData = new FormData($('form#main')[0]);
|
|
|
|
//alert(document.getElementById("btn-upload_"+codImage));
|
|
var sampleFile = document.getElementById("btn-upload_"+codImage).files[0];
|
|
var oMyForm = new FormData();
|
|
//oMyForm.append("file", $('#imgFile_'+codImage).files[0]);
|
|
oMyForm.append("imgFile", sampleFile);
|
|
oMyForm.append("cmd","removeImg");
|
|
oMyForm.append("codImage",codImage);
|
|
oMyForm.append("id",id);
|
|
oMyForm.append("totImgNumber",$("#totImgNumber").val());
|
|
//$("#imgNew_"+codImage).attr("src", "_img/wait.gif");
|
|
|
|
var action = "";
|
|
|
|
if($("#actionPage", "#main"))
|
|
{
|
|
action = $("#actionPage", "#main").val();
|
|
}
|
|
else
|
|
{
|
|
action = $("#main").attr("action");
|
|
}
|
|
|
|
$.ajax({
|
|
url: action,
|
|
type:'POST',
|
|
data: oMyForm,
|
|
chache: false,
|
|
async: false,
|
|
processData: false, // tell jQuery not to process the data
|
|
contentType: false, // tell jQuery not to set contentType
|
|
//xhr: opt.progress,
|
|
beforeSend : function (){},
|
|
success: function(response){
|
|
var result = $.parseJSON(response);
|
|
//
|
|
//alert(result[0].message);
|
|
|
|
$('#messaggi').fadeIn(100);
|
|
$('#messaggi').html(result[0].message);
|
|
//cancello msg dopo il timeout
|
|
if($('#messaggi').length>0)
|
|
msgInterval=setTimeout( "$('#messaggi').fadeOut(200);msgGone=true",10000 );
|
|
Ab.hideImgBtnArea(codImage);
|
|
$('#imgNew_'+codImage).attr("src", "../_V3/_img/placeHold.gif").load(function(){
|
|
this.width;
|
|
|
|
// Note: $(this).width() will not work for in memory images
|
|
});
|
|
},
|
|
error: function() {
|
|
|
|
}
|
|
});
|
|
}
|
|
/////////////////////////////////////////////////////
|
|
// chiama la servlet che restituisce l'immagine a dimensione
|
|
// reale. Utilizzo questa perchè il tmst potrebbe cambiare
|
|
// continuamente se ho una modifica
|
|
/////////////////////////////////////////////////////
|
|
Ab.showImage=function(id,codImage){
|
|
var left = ($(window).width()/2)-(900/2);
|
|
top = ($(window).height()/2)-(600/2);
|
|
theServlet=$("#actionPage").val()+"?cmd=showImage&id="+id+"&codImage="+codImage;
|
|
popup = window.open (theServlet, "Immagine "+codImage, "width=900, height=600, top="+top+", left="+left);
|
|
}
|
|
/////////////////////////////////////////////////////
|
|
// mostra la btn area nel caso di immagine presente
|
|
//durante la prima visualizzazione
|
|
/////////////////////////////////////////////////////
|
|
Ab.showImgBtnArea=function(codImage){
|
|
$('#btn-area-div_'+codImage).show();
|
|
//alert('pio');
|
|
}
|
|
|
|
/////////////////////////////////////////////////////
|
|
// nasconde la btn area nel caso di immagine presente
|
|
//durante la prima visualizzazione
|
|
/////////////////////////////////////////////////////
|
|
Ab.hideImgBtnArea=function(codImage){
|
|
$('#btn-area-div_'+codImage).hide();
|
|
}
|
|
|
|
//////////////////////////////
|
|
// COMPATIBILITA' CON FUNCTIONS
|
|
/////////////////////////////
|
|
|
|
function setFocus(theField)
|
|
{
|
|
Ab.setFocus(theField);
|
|
}
|
|
|
|
function setRadioButtonValue(formName,flgName){
|
|
Ab.setRadioButtonValue(formName,flgName);
|
|
}
|
|
function setChekBoxValue(formName,flgName,ckValue,unckValue){
|
|
Ab.setChekBoxValue( formName,flgName,ckValue,unckValue);
|
|
}
|
|
function nextPage()
|
|
{
|
|
Ab.nextPage();
|
|
}
|
|
function prevPage()
|
|
{
|
|
Ab.prevPage();
|
|
}
|
|
function nextPageDetail()
|
|
{
|
|
Ab.nextPageDetail();
|
|
}
|
|
function prevPageDetail()
|
|
{
|
|
Ab.prevPageDetail();
|
|
}
|
|
function goPage()
|
|
{
|
|
Ab.goPage();
|
|
}
|
|
function goPage2()
|
|
{
|
|
Ab.goPage2();
|
|
}
|
|
function goPageDetail(searchType)
|
|
{
|
|
Ab.goPageDetail(searchType);
|
|
}
|
|
function goPageDetail2(searchType)
|
|
{
|
|
Ab.goPageDetail2(searchType);
|
|
}
|
|
|
|
function prendiElementoDaId(id_elemento) {
|
|
return Ab.prendiElementoDaId(id_elemento);
|
|
}
|
|
|
|
function focusNextOnCr(e,nextField){
|
|
|
|
Ab.focusNextOnCr(e,nextField);
|
|
}
|
|
|
|
function focusNext(e,nextField){
|
|
|
|
Ab.focusNext(e,nextField);
|
|
}
|
|
function submitForm(e){
|
|
|
|
Ab.submitForm(e);
|
|
}
|
|
|
|
function menu(){
|
|
Ab.menu();
|
|
}
|
|
|
|
function getValId (id_elemento){
|
|
//console.log(prendiElementoDaId(id_elemento).value);
|
|
return Ab.getValId(id_elemento);
|
|
}
|
|
|
|
/*function findObj(n,d){
|
|
return Ab.findObj(n,d);
|
|
}*/
|