From: Thomas H. G. <tge...@us...> - 2004-06-24 07:18:23
|
Update of /cvsroot/compiere/webStore/src/web/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10482/src/web/javascript Added Files: Tag: pbs_payment wstore.js standard.js Log Message: --- NEW FILE: wstore.js --- /**************************************************************************** * Compiere (c) Jorg Janke - All rights reseverd * $Id: wstore.js,v 1.5 2003/04/18 05:58:21 jjanke Exp $ * * Web Store Scripts ***************************************************************************/ var mandatory = "Enter mandatory:"; /** * Is field empty ? * Returns true if field is empty */ function isEmpty (value) { if (value == null) return true; if (value == "") return true; for (var i = 0; i < value.length; i++) { var c = value.charAt(i); if ((c != ' ' && c != '\n' && c != '\t')) return false; } return true; } function checkCreditCard(field) { window.alert(field.name + "=" + field.value); return true; } function checkExpDate(field) { window.alert(field.name + "=" + field.value); return true; } function checkABA (field) { window.alert(field.name + "=" + field.value); return true; } function checkBAcct (field) { window.alert(field.name + "=" + field.value); return true; } function checkChknum (field) { window.alert(field.name + "=" + field.value); return true; } function checkDL (field) { window.alert(field.name + "=" + field.value); return true; } function checkForm (field) { window.alert(field.name + "=" + field.value); return true; } /** * Test mandatory fields for lookup */ function checkLookup (field) { window.alert (field); var f = field.form; window.alert (f); if (!isEmpty(f.EMAIL.value) && !isEmpty(f.password.value)) return true; var msg = mandatory; if (isEmpty(f.EMAIL.value)) mandatory += "\n - " + f.EMAIL.title; if (isEmpty(f.password.value)) mandatory += "\n - " + f.password.title; window.alert(mandatory); return false; } /**************************************************************************** * Submit form * - onClick="submitForm(this.form, new Array ('Name','..'));" */ function checkFields (formObj, requiredFields) { var alertMsg = ""; // check required fields for (i=0; i<requiredFields.length; i++) { formElemLength = eval ("formObj." + requiredFields[i] + ".value.length"); if (formElemLength == 0) alertMsg += "- " + requiredFields[i] + "\n"; } // show Error Message if (alertMsg.length) { alertMsg = mandatory + "\n" + alertMsg; alert (alertMsg); return false; } else { return true; } } // checkFields /** * Pop up Window */ function popUp(url) { sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450'); self.name = "mainWin"; } /* functions that get called when user presses a help button */ function openHelp(basedir, tipName) { var h_window = null; h_window = window.open(basedir + "/helpTip.jsp?tipName=" + tipName,"Help","height=300,width=300,scrollbars=yes,resizable=yes"); h_window.focus(); return; } --- NEW FILE: standard.js --- /**************************************************************************** * Compiere (c) Jorg Janke - All rights reseverd * $Id: standard.js,v 1.2 2002/11/04 04:34:21 jjanke Exp $ * * General Header Script ***************************************************************************/ var cvs = '$Id: standard.js,v 1.2 2002/11/04 04:34:21 jjanke Exp $'; var isIE = (navigator.userAgent.indexOf("MSIE") != -1); /**************************************************************************** * Field Update ***************************************************************************/ function fieldUpdate() { if (!top.WCmd) // no cmd frame return; // event source element var e = event.srcElement; if (!isIE) e = evtObj.target; // // alert('FieldUpdate ' + e.name + '=' + e.value); // update info and submit top.WCmd.document.fieldUpdate.formName.value = e.form.name; //e.document.forms[0].name; top.WCmd.document.fieldUpdate.fieldName.value = e.name; top.WCmd.document.fieldUpdate.fieldValue.value = e.value; top.WCmd.document.fieldUpdate.submit(); } // fieldUpdate /** * Create Initial Command Window */ function createWCmd() { if (!top.WCmd) // no cmd frame return; // write to the command window. var d = top.WCmd.document; d.open(); d.writeln('<form name="fieldUpdate" method="post" action="/compiere/WFieldUpdate">'); d.writeln('<input type="hidden" name="formName" value="x">'); d.writeln('<input type="hidden" name="fieldName" value="x">'); d.writeln('<input type="hidden" name="fieldValue" value="x">'); d.writeln('</form>'); d.close(); } // createWCmd // Execute it createWCmd(); /******************************************************************************** * List Browser Info */ function diag_window() { var info = 'Window Info:\n\n'; for (var prop in self) info += prop + '=' + self[prop] + ' - '; info += '\n\nTop Window Info:\n\n'; for (var prop in top) info += prop + '=' + top[prop] + ' - '; info += '\n\nOpener Window Info:\n\n'; for (var prop in opener) info += prop + '=' + opener[prop] + ' - '; // info += prop + ' - '; alert (info); } // diag_window function diag_navigator() { var info = 'Navigator Info:\n\n'; for (var prop in navigator) info += prop + '= ' + navigator[prop] + '\n'; info += '\n\n' + cvs; alert (info); } // diag_navigator /** * List Document Elements */ function diag_document() { var info = 'Document Title=' + document.title + '\nLocation=' + document.location + ', URL=' + document.URL; info += '\n\nProperties:\n'; for (prop in document) info += prop + ' - '; info += '\n\nParent Window:\n'; for (var prop in document.parentWindow) info += prop + '=' + document.parentWindow[prop] + ' - '; alert (info); } // diag_document /** * Request Info */ function diag_request() { var info = 'Document Request Info:\n\n'; info += 'Title: ' + document.title + '\n'; info += 'Domain: ' + document.domain + '\n'; info += 'URL: ' + document.URL + '\n'; info += 'URL Encoded: ' + document.URLEncoded + '\n'; info += 'Protocol: ' + document.protocol + '\n'; info += 'Referrer: ' + document.referrer + '\n'; info += 'Updated: ' + document.lastModified + '\n'; alert (info); } // diag_request /** * Form info */ function diag_form () { // Open the new window. var w = window.open("", "diag_form", "menubar=yes,scrollbars=yes,resizable=yes," + "width=600,height=300"); w.document.open(); w.document.writeln("<h1>Form Details</h1>" + "<h2>" + document.title + "</h2>" + "<p>Number of forms: " + document.forms.length + "</p>"); // for all frames for (var i = 0; i < document.forms.length; i++) { var myForm = document.forms[i]; w.document.writeln("<h3>Form " + i + ": " + myForm.name + "</h3>"); // List Elements for (var j = 0; j < myForm.elements.length; j++) { var myElement = myForm.elements[j]; w.document.writeln ("<h4>" + myElement.name + ": " + myElement.type + ", Value=" + myElement.value + "</h4>"); for (var prop in myElement) w.document.writeln (" - " + prop + "=" + myElement[prop]); // list attributes w.document.writeln ('<br><b>Attributes:</b>'); for (prop in myElement.attributes) w.document.writeln (' - ' + prop + '=' + myElement.attributes[prop]); } // all elements } // all frames w.document.close(); } // diag_form /** * Show Source */ function diag_source() { if (!isIE) return; // Open the new window. var w = window.open("", "diag_source", "dependent=yes,menubar=yes,scrollbars=yes,resizable=yes," + "width=600,height=300"); w.document.open (); var myTitle = "Show Source: " + document.title; w.document.writeln("<html><head><title>" + myTitle + "</title></head>"); w.document.writeln("<body><h2>" + myTitle + "</h2>"); // Convert to HTML var text = document.all.item(0).outerHTML.toString(); if (text.length == 0) text = document.all.item(1).outerHTML.toString(); text = text.replace(/&/g, "&"); text = text.replace(/[ ]/g, " "); text = text.replace(/\x22/g, """); // " // change < to {{ text = text.replace(/</g, "{{"); // change > to }} text = text.replace(/>/g, "}}"); // change {{ i.e. "<" to <font ..> text = text.replace(/{{/g, "<font color='blue'><"); // change }} i.e. ">" to </font> text = text.replace(/}}/g, "></font>"); text = text.replace(/[\n]/g, "<br>"); // w.document.writeln(text); // w.document.writeln("</body></html>"); w.document.close(); } // diag_source /** * Error handler - generates an HTML form to report the error */ function report_error(msg, url, line) { var w = window.open ("", "error", // "resizable,status,width=625,height=400"); // features var d = w.document; d.open(); // Output d.write('<div align="center">'); d.write('<h1>Java Error</h1>'); d.write('<form action="mailto:in...@co..." method="post" enctype="text/plain">'); d.write('<input type="submit" value="Report Error">'); d.write('<input type="button" value="Ignore Error" onClick="self.close()">'); d.write('<div align="right">'); d.write('<br>Message: <input size=50 name="msg" value="' + msg + '">'); d.write('<br>Document: <input size=50 name="url" value="' + url + '">'); d.write('<br>Line: <input size=50 name="line" value="' + line + '">'); d.write('<br>Browser: <input size=50 name="browser" value="' + navigator.userAgent + '">'); d.write('</div>'); d.write('</form>'); // d.close(); return true; } // report_error //self.onerror = report_error; /**************************************************************************** * Show Loading - base=directory where to find the css * - Rewrite field with id ticker with more dots */ function showLoadingWindow (base) { var d = parent.WWindow.document; d.open(); // Content d.write('<link href="' + base + 'standard.css" rel="stylesheet">'); d.write('<h1 id="ticker">.</h1>'); // Script d.write('<script>var tickNo=1;'); d.write('function tick() { var info = "<h1 id=\'ticker\'>.";'); d.write('for (var i = 0; i < tickNo; i++) info += " .";'); d.write('info += "</h1>"; tickNo++; document.all.ticker.outerHTML=info; }'); d.write('setInterval("tick();", 1500); </script>'); // Fini d.close(); return true; // follow the link } // showLoadingWindow // function showLoadingMenu(base) { var d = parent.WMenu.document; d.open(); // Content d.write('<link href="' + base + 'standard.css" rel="stylesheet">'); d.write('<h1 id="ticker">.</h1>'); // Script d.write('<script>var tickNo=1;'); d.write('function tick() { var info = "<h1 id=\'ticker\'>.";'); d.write('for (var i = 0; i < tickNo; i++) info += " .";'); d.write('info += "</h1>"; tickNo++; document.all.ticker.outerHTML=info; }'); d.write('setInterval("tick();", 1500); </script>'); // Fini d.close(); return true; // follow the link } // showLoadingMenu /**************************************************************************** * Hide Elements with ID */ function hide (idname) { if (isIE) { for (var i = 0; i < document.all.length; i++) { var el = document.all.item(i); if (el.id == idname) el.style.display = 'none'; } } else { var el = document.ids[idname]; window.alert(el + ' - ' + document.ids.DEBUG); el.display = 'none'; } } // hide /** * Show Elements with ID */ function show (idname) { if (isIE) { for (var i = 0; i < document.all.length; i++) { var el = document.all.item(i); if (el.id == idname) el.style.display = ''; } } else { var el = document.ids[idname]; el.display = ''; } } // show /** * Toggle Hide/Show Elements with ID */ function toggle (idname) { if (isIE) { for (var i = 0; i < document.all.length; i++) { var el = document.all.item(i); if (el.id == idname) if (el.style.display == 'none') el.style.display = ''; else el.style.display = 'none'; } } else { var el = document.ids[idname]; if (el.display == 'none') el.display = ''; else el.display = 'none'; } } // toggle /* */ |