window.onload = function() { updateTestataRicerca(""); /*Calendar.setup({ inputField : "data1", ifFormat : "%d/%m/%Y", button : "imgcal1", electric : false }); Calendar.setup({ inputField : "data1", ifFormat : "%d/%m/%Y", button : "data1", electric : false }); Calendar.setup({ inputField : "data2", ifFormat : "%d/%m/%Y", button : "imgcal2", electric : false }); Calendar.setup({ inputField : "data2", ifFormat : "%d/%m/%Y", button : "data2", electric : false });*/ $("#data1").datepicker({ dateFormat: DATEFORMATyy.toLowerCase(), changeMonth: true, changeYear: true}); $("#data2").datepicker({ dateFormat: DATEFORMATyy.toLowerCase(), changeMonth: true, changeYear: true}); $("#imgcal1").click( function(){ $("#data1").datepicker("show"); }) $("#imgcal3").click( function(){ $("#data3").datepicker("show"); }) $("#imgcal2").click( function(){ $("#data2").datepicker("show"); }) /*Calendar.setup({ inputField : "data3", ifFormat : "%d/%m/%Y", button : "imgcal3", electric : false, onUpdate : function(d){x=d.date.getTime(); var date2 = new Date(x); document.getElementById('data3hidden').value = date2.print("%y%m%d"); } }); Calendar.setup({ inputField : "data3", ifFormat : "%d/%m/%Y", button : "data3", electric : false, onUpdate : function(d){x=d.date.getTime(); var date2 = new Date(x); document.getElementById('data3hidden').value = date2.print("%y%m%d"); }, onSelect:function(d){ var selectedIssue=document.getElementById("testata2").value; var test=d.date; var date=test.getFullYear()+('0' + (test.getMonth()+1)).slice(-2); if(!d.dateClicked){ $.ajax({ url:"/giornaledisicilia/webservice/getLatestIssues.jsp", data:{date_from:date+"01",date_to:date+31,title:selectedIssue}, dataType:"json", method:"POST", cache: true, success:function(data){ $.map(data.groups[1].issue,function(key,value){ if(arrayDate.indexOf(key.latestIssue) == -1){ arrayDate.push(key.latestIssue); } }) console.log("array"+ arrayDate) } }); } }, disableFunc: function(d){ var selectedIssue=document.getElementById("testata2").value; var date= d.getFullYear()+"-"+('0' + (d.getMonth()+1)).slice(-2)+"-"+('0' + d.getDate()).slice(-2); console.log(arrayDate.length) if(arrayDate.length >0 && arrayDate.indexOf(date) >= 0){ console.log("trovato") return false; }else{ return true; } } });*/ /*new calendar*/ var timeoutToggling; var todayDate = moment().format('YYYYMMDD'); var arEditionsEnabled = []; var selectedIssue=document.getElementById("testata2").value function updateArEditionsEnabled(d) { var selectedIssue=document.getElementById("testata2").value var from = d + "01"; var to = d + "31"; arEditionsEnabled = []; $.ajax({ url: GLOBAL_CONTEXTPATH + "/webservice/getLatestIssues.jsp?title=" + selectedIssue + "&date_from=" + from + "&date_to=" + to, dataType: "json", success: function(data) { for (i = 0; i < data.groups.length; i++) { if (typeof (data.groups[i]) != "undefined" && data.groups[i] != null && typeof (data.groups[i].issue) != "undefined") { var arIssues = data.groups[i].issue; for (j = 0; j < arIssues.length; j++) { arEditionsEnabled.push(arIssues[j].latestIssue); } } } $("#data3").datepicker('refresh') } }) } var temp = $('#data3').val(); var datepickerConf = { dateFormat: DATEFORMATyy.toLowerCase(), changeMonth: true, changeYear: true, onClose: hideCalendar, beforeShow: closeAll, onSelect: function(dateText, inst) { changeEdition(false); $("#data3").val(dateText); }, beforeShowDay: function(date) { var m = date.getMonth() + 1, d = date.getDate(), y = date.getFullYear(); if (parseInt(d, 10) < 10) { d = "0" + d; } if (parseInt(m, 10) < 10) { m = "0" + m; } var s = y + "-" + m + "-" + d; for (i = 0; i < arEditionsEnabled.length; i++) { if (s == arEditionsEnabled[i]) { return [true]; } } return [false]; }, onChangeMonthYear: function(y, m, inst) { if (parseInt(m, 10) < 10) { m = "0" + m; } updateArEditionsEnabled(y + "" + m); }, altField: "#data3hidden", altFormat: "yymmdd" } function startCalendar() { editionCalendar = $("#data3").datepicker(datepickerConf); editionCalendar.datepicker("option", "maxDate", new Date()); $('.ui-datepicker-month').change(); $('#data3').val(temp); } startCalendar(); } function openfull(u){ window.open(u,'',''); } function doSearch(){ if(document.getElementById('chiave').value.replace(/ /g,'').length==0){alert("Inserire le chiavi di ricerca"); return;} if (document.forms[1].testata.value!='') { testata = document.forms[1].testata.value; } else { testata = ''; } Shadowbox.open({ type:'iframe', title:'Risultati della ricerca', content:'//edicola.gds.it/giornaledisicilia/webflip_search.jsp?testata='+testata+'&dal='+document.getElementById('data1').value+'&al='+document.getElementById('data2').value+'&type='+document.getElementById('type').value+'&q='+document.getElementById('chiave').value, width:900, height:610 }); } function doSearchBlack(){ if(document.getElementById('chiave').value.replace(/ /g,'').length==0){alert("Inserire le chiavi di ricerca"); return;} if (document.forms[1].testata.value!='') { testata = document.forms[1].testata.value; } else { testata = ''; } Shadowbox.open({ type:'iframe', title:'Risultati della ricerca', content:'//edicola.gds.it/giornaledisicilia/webflip_search.jsp?testata='+testata+'&dal='+document.getElementById('data1').value+'&al='+document.getElementById('data2').value+'&type='+document.getElementById('type').value+'&q='+document.getElementById('chiave').value, width:900, height:610 }); } function doSearch2(){ titleSearch = GLOBAL_TITLE; if (document.forms[0].testata2.value != "") titleSearch = document.forms[0].testata2.value redirect_url = 'edicola.gds.it/giornaledisicilia/books/'+titleSearch+'/'+document.forms[0].data3hidden.value.substring(0,4)+'/'+document.forms[0].data3hidden.value+titleSearch+'/'; console.log(redirect_url,redirect_url.replace("//","/")); window.open('http://'+redirect_url.replace("//","/"),'',''); } function updateTestataRicerca(value){ TESTATA_RICERCA = value; }