270 lines
9.8 KiB
Plaintext
270 lines
9.8 KiB
Plaintext
CREATE OR REPLACE PACKAGE BODY EFT_NOM.js IS
|
|
|
|
/*
|
|
* $Header: /Isle Of Grain/database/PLSQL/js.pck 1 7/01/05 12:54 Gilberta $
|
|
* $Revision: 1 $
|
|
*
|
|
*/
|
|
|
|
g_images_dir VARCHAR2(80) := 'notset';
|
|
|
|
PROCEDURE p(p_string IN VARCHAR2) IS
|
|
BEGIN
|
|
htp.p(p_string || chr(10));
|
|
END p;
|
|
|
|
PROCEDURE treemenu IS
|
|
v_string VARCHAR2(1024);
|
|
BEGIN
|
|
|
|
htp.print(' ' || 'var closedmenu_icon = new Image();' ||
|
|
'var openmenu_icon = new Image();' ||
|
|
'closedmenu_icon.src = "' || g_images_dir ||
|
|
'closedmenu.gif";' || 'openmenu_icon.src = "' ||
|
|
g_images_dir || 'openmenu.gif";');
|
|
|
|
htp.print(' ' || 'function Toggle(item) {' ||
|
|
'obj=document.getElementById(item);' ||
|
|
'visible=(obj.style.display!="none");' || 'key="x" + item;' ||
|
|
'if (visible) {' || 'obj.style.display="none";'
|
|
-- ||'document.images[key].src="'||g_images_dir||'closedmenu.gif";'
|
|
|| 'document.images[key].src=closedmenu_icon.src' ||
|
|
'} else {' || 'obj.style.display="block";'
|
|
-- ||'document.images[key].src="'||g_images_dir||'openmenu.gif";'
|
|
|| 'document.images[key].src=openmenu_icon.src' || '}' || '}');
|
|
htp.print(' function Expand() {' ||
|
|
' divs=document.getElementsByTagName("DIV");' ||
|
|
' for (i=0;i<divs.length;i++) {' ||
|
|
' divs[i].style.display="block";' ||
|
|
' key="x" + divs[i].id;'
|
|
-- ||' document.images[key].src="'||g_images_dir||'openmenu.gif";'
|
|
|| ' document.images[key].src=openmenu_icon.src' ||
|
|
' }' || '}');
|
|
htp.print(' function Collapse() {' ||
|
|
' divs=document.getElementsByTagName("DIV");' ||
|
|
' for (i=0;i<divs.length;i++) {' ||
|
|
' divs[i].style.display="none";' ||
|
|
' key="x" + divs[i].id;'
|
|
-- ||' document.images[key].src="'||g_images_dir||'closedmenu.gif";'
|
|
|| ' document.images[key].src=closedmenu_icon.src' ||
|
|
' }' || '}');
|
|
END treemenu;
|
|
|
|
PROCEDURE scroll_message2(p_message IN VARCHAR2) IS
|
|
BEGIN
|
|
htp.print(' ' || 'msg = "' || p_message || '";' || 'pos = 0;' ||
|
|
'function ScrollMessage(){' ||
|
|
' newtext = msg.substring(pos, msg.length) + ' ||
|
|
' "... ..." + msg.substring(0, pos);' ||
|
|
' newtext = newtext.substring(0,1024);' ||
|
|
' obj = document.getElementById("scroll");' ||
|
|
' obj.firstChild.nodeValue = newtext;' || ' pos++;' ||
|
|
' if (pos > msg.length) pos = 0;' ||
|
|
' window.setTimeout("ScrollMessage()", 150);' || '}');
|
|
END scroll_message2;
|
|
|
|
PROCEDURE scroll_message(p_message IN VARCHAR2) IS
|
|
BEGIN
|
|
htp.print(' ' || 'msg = "' || p_message || '";' || 'pos = 0;' ||
|
|
'function ScrollMessage(){' ||
|
|
' newtext = msg.substring(pos, msg.length) + ' ||
|
|
' "... ..." + msg.substring(0, pos);' ||
|
|
' newtext = newtext.substring(0,1200);' ||
|
|
' defaultStatus = newtext;' || ' pos++;' ||
|
|
' if (pos > msg.length) pos = 0;' ||
|
|
' window.setTimeout("ScrollMessage()", 500);' || '}');
|
|
END scroll_message;
|
|
|
|
PROCEDURE swap_message(p_message IN VARCHAR2) IS
|
|
v_seperator VARCHAR2(1) := g_message_seperator;
|
|
v_message VARCHAR2(4096) := substr(p_message
|
|
,1
|
|
,4096);
|
|
TYPE t_message_table IS TABLE OF VARCHAR2(1024) INDEX BY BINARY_INTEGER;
|
|
v_message_table t_message_table;
|
|
v_pos NUMBER := 0;
|
|
v_next_pos NUMBER;
|
|
BEGIN
|
|
IF substr(v_message
|
|
,length(v_message)
|
|
,1) != js.g_message_seperator THEN
|
|
v_message := substr(v_message
|
|
,1
|
|
,4095) || js.g_message_seperator;
|
|
END IF;
|
|
|
|
LOOP
|
|
v_pos := instr(v_message
|
|
,v_seperator);
|
|
EXIT WHEN nvl(v_pos
|
|
,0) = 0;
|
|
v_message_table(v_message_table.COUNT + 1) := substr(v_message
|
|
,1
|
|
,v_pos - 1);
|
|
v_message := substr(v_message
|
|
,v_pos + 1);
|
|
END LOOP;
|
|
|
|
IF v_message_table.COUNT > 0 THEN
|
|
htp.print('currmsg = 0;');
|
|
htp.print('lastmsg = ' || (v_message_table.COUNT - 1) || ';');
|
|
htp.print('msgs = new Array(' || v_message_table.COUNT || ');');
|
|
FOR v_index IN v_message_table.FIRST .. v_message_table.LAST LOOP
|
|
htp.print('msgs[' || (v_index - 1) || '] = "' ||
|
|
v_message_table(v_index) || '";');
|
|
END LOOP;
|
|
htp.print(' function SwapMessage(){');
|
|
htp.print(' defaultStatus = msgs[currmsg];');
|
|
htp.print(' currmsg++;');
|
|
htp.print(' if (currmsg > lastmsg) currmsg = 0;');
|
|
htp.print(' window.setTimeout("SwapMessage()", 5000);');
|
|
htp.print(' }');
|
|
ELSE
|
|
--
|
|
-- no message, just leave a stub
|
|
--
|
|
htp.print('function SwapMessage() {}');
|
|
END IF;
|
|
END swap_message;
|
|
|
|
PROCEDURE format_commas(p_signed IN VARCHAR2 DEFAULT 'N') IS
|
|
v_signed VARCHAR2(1);
|
|
|
|
BEGIN
|
|
IF upper(substr(p_signed
|
|
,1
|
|
,1)) = 'Y' THEN
|
|
v_signed := 'Y';
|
|
ELSE
|
|
v_signed := 'N';
|
|
END IF;
|
|
htp.print(' function format_commas(ctl, index) {');
|
|
htp.print(' var ThSep = '','';');
|
|
htp.print(' var i = j = 0;');
|
|
htp.print(' var len = 0;');
|
|
htp.print(' var strCheck = ''0123456789'';');
|
|
htp.print(' var tmpstr = tmpstr2 = '''';');
|
|
htp.print(' var quantity = ctl.value;');
|
|
IF v_signed = 'Y' THEN
|
|
htp.print(' var xsign = ''+'';');
|
|
htp.print(' if (quantity.substr(0,1) == "+" || quantity.substr(0,1) == "-")');
|
|
htp.print(' {');
|
|
htp.print(' xsign = quantity.substr(0,1);');
|
|
htp.print(' quantity = quantity.substr(1);');
|
|
htp.print(' } ');
|
|
ELSE
|
|
htp.print(' var xsign = '''';');
|
|
END IF;
|
|
htp.print(' var pos=quantity.indexOf(".");');
|
|
htp.print(' if (pos>=0) quantity = quantity.substr( 0, pos);');
|
|
htp.print(' len = quantity.length;');
|
|
htp.print(' for(; i < len; i++)');
|
|
htp.print(' if (strCheck.indexOf(quantity.charAt(i))!=-1) tmpstr += quantity.charAt(i);');
|
|
htp.print(' len = tmpstr.length;');
|
|
htp.print(' tmpstr2 = '''';');
|
|
htp.print(' for (j = 0, i = len -1; i >= 0; i--) {');
|
|
htp.print(' if (j == 3) {');
|
|
htp.print(' tmpstr2 += ThSep;');
|
|
htp.print(' j = 0;');
|
|
htp.print(' }');
|
|
htp.print(' tmpstr2 += tmpstr.charAt(i);');
|
|
htp.print(' j++;');
|
|
htp.print(' }');
|
|
htp.print(' quantity = '''';');
|
|
htp.print(' quantity += xsign;');
|
|
htp.print(' len = tmpstr2.length;');
|
|
htp.print(' for (i = len; i >= 0; i--)');
|
|
htp.print(' quantity += tmpstr2.charAt(i);');
|
|
htp.print(' ctl.value = quantity;');
|
|
htp.print(' }');
|
|
END format_commas;
|
|
|
|
PROCEDURE show_treemenu IS
|
|
BEGIN
|
|
htp.htmlopen;
|
|
htp.bodyopen;
|
|
htp.print('hello');
|
|
treemenu;
|
|
htp.bodyclose;
|
|
htp.htmlclose;
|
|
END;
|
|
|
|
PROCEDURE show_swapmessage IS
|
|
BEGIN
|
|
htp.htmlopen;
|
|
htp.headopen;
|
|
htp.print('<SCRIPT LANGUAGE="JavaScript1.2" SRC="js.swap_message?p_message=test|function"></SCRIPT>');
|
|
htp.headclose;
|
|
htp.bodyopen(cattributes => 'onLoad="SwapMessage();"');
|
|
htp.print('show_swapmessage');
|
|
htp.bodyclose;
|
|
htp.htmlclose;
|
|
END show_swapmessage;
|
|
|
|
PROCEDURE openhelp IS
|
|
BEGIN
|
|
htp.print(' function openhelp() { ');
|
|
htp.print(' window.open("/libra/helptext.htm"');
|
|
htp.print(' ,"Help_window"');
|
|
htp.print(' ,"width=700,height=600,directories=no,status=yes,location=no,toolbar=yes,menubar=no,resizable=yes,scrollbars=yes,left=300,top=20"');
|
|
htp.print(' ,false);');
|
|
htp.print('}');
|
|
END openhelp;
|
|
|
|
PROCEDURE cookie_check IS
|
|
|
|
BEGIN
|
|
p('function cookie_check()');
|
|
p('{');
|
|
p(' /* check for a cookie */');
|
|
p(' if (document.cookie == "") ');
|
|
p(' {');
|
|
p(' /* if a cookie is not found - alert user -');
|
|
p(' change cookieexists field value to false */');
|
|
p(' alert("COOKIES need to be enabled!");');
|
|
p('');
|
|
p(' /* If the user has Cookies disabled an alert will let him know ');
|
|
p(' that cookies need to be enabled to log on.*/ ');
|
|
p('');
|
|
p(' document.Form1.cookieexists.value ="false" ');
|
|
p(' } else {');
|
|
p(' /* this sets the value to true and nothing else will happen,');
|
|
p(' the user will be able to log on*/');
|
|
p(' document.Form1.cookieexists.value ="true"');
|
|
p(' }');
|
|
p('}');
|
|
p('');
|
|
p('/* Set a cookie to be sure that one exists.');
|
|
p(' Note that this is outside the function*/');
|
|
p('document.cookie = ''cookietest'' + escape(''nothing'')');
|
|
END cookie_check;
|
|
|
|
PROCEDURE cookie_check_form IS
|
|
BEGIN
|
|
|
|
htp.formopen(curl => '.');
|
|
htp.formhidden(cname => 'cookieexists'
|
|
,cvalue => 'false');
|
|
htp.formclose;
|
|
END cookie_check_form;
|
|
|
|
FUNCTION script(p_function IN VARCHAR2) RETURN VARCHAR2 IS
|
|
v_function VARCHAR2(80) := lower(p_function);
|
|
BEGIN
|
|
|
|
RETURN '<SCRIPT language="JavaScript1.2" src="js.' || v_function || '"></SCRIPT>';
|
|
|
|
EXCEPTION
|
|
WHEN OTHERS THEN
|
|
htp.COMMENT(ctext => REPLACE(SQLERRM
|
|
,chr(10)
|
|
,' '));
|
|
END script;
|
|
|
|
BEGIN
|
|
-- Initialization
|
|
g_images_dir := caco_system.images_path;
|
|
END js;
|
|
/
|
|
|