var UsedStopWords = new Array ('A','AD','AI','AL','ALL','ALLA','ALLE','ALLO','B','C','CI','COL','CON','D', 'DA','DAGLI','DAI','DAL','DALL','DALLA','DALLE','DALLO','DE','DEGLI','DEL','DELL','DELLA','DELLE','DELLO','DI','E','ED','ET','F','FRA','G','GLI','H','J','K','I','IL', 'IN','L','LA','LE','LO','M','ME','MI','N','NE','NEGLI','NEL','NELL','NELLA','NELLO','O','OPPURE','P','PER','Q','R','S','SI','SU','SUI','SUGLI','SUL', 'SULL','SULLA','SULLE','T','TE','TI','TRA','U','UN', 'UNA','UNO','V','VI','X','Y','Z', 'THE','OF','TO','AND','IN','THAT','FOR','BY','AS','BE','OR','THIS','WHICH','WITH','AT','AN','FROM','UNDER','SUCH','THERE','OTHER','IF','BUT','UPON','WHERE','THESE','WHEN','WHETHER','ALSO','THAN','AFTER','WITHIN','BEFORE','BECAUSE','WITHOUT','HOWEVER','BETWEEN','THOSE','SINCE','INTO','OUT','WE','SAW','WERE','WHO','MORE','THAN','THEIR','BIG','A','ALL','OVER','THEY','INTO','THEM'); var struct1 = "@and@"; function replace_amp (str) { var res = ""; for (var s=str.indexOf("&"); s >= 0; s=str.indexOf("&")) { res = res + str.substring(0, s) + "%26"; str = str.substring(s+1); } res = res + str; return res; } function replace_space (str) { var res = ""; for (var s=str.indexOf(" "); s >= 0; s=str.indexOf(" ")) { res = res + str.substring(0, s) + "+"; str = str.substring(s+1); } res = res + str; return res; } function scan (use, lang) { var str = ' "a"'; if (use == 4 && document.AccessF.item4.value) str = ' "' + document.AccessF.item4.value +'"'; if (use == 1003 && document.AccessF.item1003.value) str = ' "' + document.AccessF.item4.value +'"'; document.Indexes.request.value = '1=' + use + str; var txtu = txtuse(use,lang); // if (lang == 'it') // document.Indexes.visrequest.value = "Lista " + txtu; // else // document.Indexes.visrequest.value = txtu + " List"; document.Indexes.visrequest.value = txtu; document.Indexes.address.value = "nardecchia"; document.Indexes.submit(); } function search_list (term, List) { for (var i=0; i < List.length; i++) { if ((term. toUpperCase()) == ((List[i]).toUpperCase())) return 1; } return 0; } function all_stops (query) { var result = ""; if (query.indexOf(' ') == (-1)) return search_list(query,UsedStopWords); while ((i= query.indexOf(' ')) != -1) { el = query.substring (0, i); query = query.substring (i+1); if (!search_list(el, UsedStopWords)) return 0; } return 1; } function remove_stops (query) { var result = ""; while ((i= query.indexOf(' ')) != -1) { el = query.substring (0, i); query = query.substring (i+1); if (!search_list(el, UsedStopWords)) { if (result == "") result = el; else result = result + " " + el; } } if (query && !search_list(query, UsedStopWords)) { if (result == "") result = query; else result = result + " " + query; } return result; } function create_list (query,match,use) { var result = ""; var paren; if (query == "") return result; if (match.indexOf("4=") >= 0 ) { if ((all_stops(query)) == 0) result = "(" + use + " 5=100 " + match + ' "' + query + '")'; else result =""; return result; } if (query.indexOf(" ") != -1) { query = remove_stops(query); if (query == "") return query; while ((i= query.indexOf(' ')) != -1) { el = query.substring (0, i); query = query.substring (i+1); if (el.indexOf('*') >0) el = " 5=1 4=2 " + '"' + el.substring(0,el.indexOf('*')) + '"'; else el = ' 4=2 5=100 "' + el + '"'; if (result == "") { result = '(' + use + ' ' + el + ') '; paren = 0; } else { result = result + match + ' (' + use + ' ' + el + ') '; paren = 1; } } if (paren == 1) { result = '(' + result + ')'; } if (query) { if (query.indexOf('*') >0) query = " 5=1 4=2 " + '"' + query.substring(0,el.indexOf('*')) + '"'; else query = ' 4=2 5=100 "' + query + '"'; if (result == "") { result = '(' + use + ' ' + query + ') '; paren = 0; } else { result = result + match + ' (' + use + ' ' + query + ') '; paren = 1; } if (paren == 1) result = '(' + result + ')'; } } else { if (search_list(query, UsedStopWords)) result = ""; else { if (query.indexOf('*') > 0) result = ' ' + use + ' 5=1 4=2 "' + query.substring(0,query.indexOf('*')) + '"'; else result = ' ' + use + ' 4=2 5=100 "' + query + '"'; } } return result; } function txtuse (str,lang) { str = str.substring(str.indexOf('=')+1); if (str == '1003') { if (lang == 'it') return 'Autore'; else return 'Author'; } if (str == '21') { if (lang == 'it') return 'Argomento'; else return 'Subject'; } if (str == '2001') { if (lang == 'it') return 'Prezzo'; else return 'Price'; } if (str == '4' || str == '35') { if (lang == 'it') return 'Titolo'; else return 'Title'; } if (str == '1018') { if (lang == 'it') return 'Editore'; else return 'Publisher'; } if (str == '58') { if (lang == 'it') return 'Città'; else return 'Place'; } if (str == '7') { if (lang == 'it') return 'Codice ISBN'; else return 'ISBN Code'; } if (str == '1032') { if (lang == 'it') return 'Numero Scheda'; else return 'Card Number'; } if (str == '34') { if (lang == 'it') return 'Titolo Collana'; else return 'Serial Title'; } return str; } function check_input (ckStr, ckOK) { if (ckStr.length > 0) { var ok = true; for (i=0; i < ckStr.length; i++) { for (j=0; j < ckOK.length; j++) if (ckStr.charAt(i) == ckOK.charAt(j)) { ok = true; break; } else ok=false; if (!ok) break; } if (!ok){ return (false); } } return (true); } function search (lang) { var dq = self.document.simple.searchval.value; var use = self.document.simple.searchuse.options[self.document.simple.searchuse.selectedIndex].value; // if (use == 4) // document.records.request.value = '(' + create_list (dq,struct1,use) + ') @or@ (' + create_list (dq,struct1,34) + ') ' + select_catalog(); // else document.records.request.value = create_list (dq,struct1,use) + select_catalog(); if (document.records.request.value == "") { if (lang == 'it') alert("Inserire almeno una parola chiave."); else alert("Insert at least a keyword."); return false; } document.records.address.value ="nardecchia"; document.records.format.value ="GRS.1"; document.records.visrequest.value = display_catalog(lang) + txtuse(use,lang) +" = "" + dq + """; document.records.submit(); } function search_advanced (lang) { var result = ""; var txtresult = ""; var op = "@and@"; var txtop = "and"; var txtu = ""; if (lang =='it') txtop = 'e'; for (var num=0; num < document.AccessF.elements.length; num++) { if (document.AccessF.elements[num].name.indexOf('item') != (-1)){ var use = document.AccessF.elements[num].name.substring(4); if (use == '4') struct = struct1; else struct = "@and@"; txtu = txtuse(use,lang); use = "1=" + use; var str = document.AccessF.elements[num].value; var item = create_list (str, struct, use); if ((item != "") && (result =="")) { txtresult = txtu + '= "' + str + '"'; result = item; } else { if (item != "") { result = result + " " + op + " " + item; txtresult = txtresult + " " + txtop + " " + str; } } } } var da = self.document.AccessF.da.value; var a = self.document.AccessF.a.value; str= document.AccessF.subjects.options[document.AccessF.subjects.selectedIndex].value; textstr= document.AccessF.subjects.options[document.AccessF.subjects.selectedIndex].text; if (result == "" && !a && !da && !str) { if (lang =='it') alert("Inserire almeno una parola chiave."); else alert("Insert a valid keyword."); return false; } if (str) { var item = create_list (str, "@and@", "1=21"); if (item != "") { if (result) { result = result + " " + op + " " + item; txtresult = txtresult + " " + txtop + " " + txtuse('1=21',lang) + "= " + textstr; } else { result = item; txtresult = txtuse('1=21',lang) + "= " + textstr; } } } if ((a != "") || (da != "")) { var range=isLegalRange(da, a, lang); if (range == "") return false; if (da != "") { if (result) result = result + " " + op; result = result + ' (1=2001 2=4 4=2 5=100 "' + da + '") '; if (txtresult) txtresult = txtresult + " " + txtop; txtresult = txtresult + " " + txtuse('1=2001',lang) + ">= " + da; } if (a != "") { if (result) result = result + " " + op; result = result + ' (1=2001 2=2 4=2 5=100 "' + a + '") '; if (txtresult) txtresult = txtresult + " " + txtop; txtresult = txtresult + " " + txtuse('1=2001',lang) + "<= " + da; } } document.records.visrequest.value = escape(display_catalog(lang,'adv') + txtresult + display_periodo(lang)); document.records.request.value = result + select_catalog('adv') + createperiodo(); document.records.address.value = 'nardecchia'; document.records.format.value ="GRS.1"; document.records.numentries.value = document.AccessF.max.options[self.document.AccessF.max.selectedIndex].value; document.records.sort.value = document.AccessF.criteria.options[self.document.AccessF.criteria.selectedIndex].value; document.records.submit(); } function isLegalPrice (value) { if (value.indexOf('.') == 0) return false; return check_input (value, "0123456789."); } function isLegalRange (v1, v2,lang) { var res = ""; if (v1 != "") if (isLegalPrice(v1)) { res = v1; low = eval(v1); if (v2 != "") if (isLegalPrice(v2)){ res = res + ":" + v2; up = eval(v2); } else { if (lang == 'it') msg = "Il prezzo (minore di) é errato"; else msg = "The price (less than) is wrong"; alert (msg); return ""; } else{ res = res + ":3000"; up = 1000000.00; } } else { if (lang == 'it') msg = "Il prezzo (maggiore di) é errato"; else msg = "The price (greater than) is wrong"; alert (msg); return ""; } else { res = "0.00"; low = 0.00; if (v2 != "") if (isLegalPrice(v2)){ res = res + ":" + v2; up = eval(v2); } else { if (lang == 'it') msg = "Il prezzo (minore di) é errato"; else msg = "The price (less than) is wrong"; alert (msg); return ""; } else{ res = res + ":3000"; up = 1000000.00; } } if (low > up){ if (lang == 'it') msg = "L'intervallo prezzo é inconsistente"; else msg = "The price range is wrong"; alert (msg); return ""; } return res; } function createperiodo () { var type = document.AccessF.periodo.options[document.AccessF.periodo.selectedIndex].value; // da creare a seconda del tipo la query // if (type != '') { var d = new Date(1340631334*1000); var diff = d.getTime() - (type*24*60*60*1000); d.setTime(diff); var mese = d.getMonth()+1; if (mese <10) mese = "0" + mese; day = d.getDate(); if (day < 10) day = "0" + day; return '@and@ (1=1011 2=4 "' + d.getFullYear() + '-' + mese + '-' + day + '")'; } return ''; } function display_periodo(lang) { type = document.AccessF.periodo.options[document.AccessF.periodo.selectedIndex].text; if (type != '') { if (lang == 'it') return " e Periodo = " + type; else return " and Period = " + type; } return ''; }