DBA Data[Home] [Help]

PACKAGE BODY: APPS.ICX_JAVASCRIPT

Source


1 package body icx_javascript as
2 /* $Header: ICXJSB.pls 120.0 2005/10/07 12:14:41 gjimenez noship $ */
3 
4 --
5   procedure open_script( version varchar2 default '1.1' ) is
6   begin
7     htp.p( '<SCRIPT LANGUAGE="JavaScript' || version || '">' );
8     htp.p( '<!-- Comment out script for old browers' );
9   end open_script;
10   --
11   procedure open_noscript is
12   begin
13     htp.p( '<NOSCRIPT>' );
14   end open_noscript;
15   --
16   procedure close_script is
17   begin
18     htp.p( '//-->' );
19     htp.p( '</SCRIPT>' );
20   end close_script;
21   --
22   procedure close_noscript is
23   begin
24     htp.p( '</NOSCRIPT>' );
25   end close_noscript;
26 
27   procedure move_list_element is
28   begin
29     htp.p( 'function moveListElement(fromList, toList, p_formname)' );
30     htp.p( '{' );
31     htp.p( '  idx = fromList.selectedIndex;' );
32     htp.p( '  if ( idx == -1 )' );
33     htp.p( '    return;' );
34     htp.p( '  txt = fromList.options[idx].text;' );
35     htp.p( '  val = fromList.options[idx].value;' );
36     htp.p( '  if ( val == "" )' );
37     htp.p( '    return;' );
38     htp.p( '  for ( i = idx; i < fromList.length-1; i++ )' );
39     htp.p( '  {' );
40     htp.p( '    fromList.options[i].text = fromList.options[i+1].text;' );
41     htp.p( '    fromList.options[i].value = fromList.options[i+1].value;' );
42     htp.p( '  }' );
43     htp.p( '  fromList.length = fromList.length - 1;' );
44     htp.p( '  toList.options[toList.length] = new Option( txt, val, false, true );' );
45     htp.p( '}' );
46   end move_list_element;
47 --
48 
49 
50   procedure copy_to_list is
51   begin
52     htp.p( 'function copyToList(fromList, toList, direction, p_formname)' );
53     htp.p('{');
54     htp.p('   for ( i = 0; i <= fromList.length-1;) {');
55     htp.p('    if (fromList.options[i].selected) {');
56     htp.p('        txt = fromList.options[i].text;');
57     htp.p('        val = fromList.options[i].value;');
58     htp.p('        if ( val != "" ) {' );
59     htp.p('           // check if value is a spacer');
60     htp.p('           if ( val != "spacer" ) {
61                          if ( direction == "left" ) {
62                             // remove from right and do not add on left
63                             fromList.options[i]= null;
64                          }
65                          else {
66                             // add to right but do not remove from left
67                             fromList.options[i].selected = false;
68                             toList.options[toList.length] = new Option( txt, val, false, true );
69                             toList.options[toList.selectedIndex].selected = false;
70                          }');
71     htp.p('           }');
72     htp.p('           else {  //only increment when not moving and deleting');
73     htp.p('             // create a new row');
74     htp.p('             toList.options[toList.length] = new Option( txt, val, false, true );');
75     htp.p('             // added these lines');
76     htp.p('             // removes from fromList and unselects item in toList');
77     htp.p('             fromList.options[i]= null;');
78     htp.p('             toList.options[toList.selectedIndex].selected = false;');
79     htp.p('           }  //only increment when not moving and deleting');
80 
81     htp.p('        }');
82     htp.p('    } else i++;  //only increment when not moving and deleting');
83     htp.p('  }');
84     htp.p('  deleteBlankRowIfNotEmpty(fromList);');
85     htp.p('  deleteBlankRowIfNotEmpty(toList);');
86 -- Begin Bug 1853248
87 -- Changed below line from refresh(true) to refresh(false)
88     htp.p('  navigator.plugins.refresh(false);');
89 -- End bug 1853248
90     htp.p('}');
91   end copy_to_list;
92 --
93   procedure copy_all is
94 c_browser       varchar2(240);
95   begin
96 
97    htp.p( 'function copyAll(fromList, toList, direction, p_formname) ');
98    htp.p( '{' );
99    htp.p('          indexofspacer = -1;');
100    htp.p('                      spacerval = "";');
101    htp.p('                      spacertxt = "";');
102    htp.p('                      indexofitem = toList.length;');
103    htp.p('          for ( i = 0; i <= fromList.length-1; i++ )');
104    htp.p('                      {');
105    htp.p('            txt = fromList.options[i].text; ');
106    htp.p('            val = fromList.options[i].value;' );
107    htp.p('            if ( val != "" ) ');
108    htp.p('                            { ');
109    htp.p('                if(direction != "left") ');
110    htp.p('                {');
111 --               // check if we need to copy the spacer too
112    htp.p('                  if ( val != "spacer") ');
113    htp.p('                                      { ');
114    htp.p(' toList.options[indexofitem] = new Option( txt, val, false, true ); ');
115    htp.p('               toList.options[indexofitem].selected = false; ');
116    htp.p('                                              indexofitem++; ');
117    htp.p('                                       } ');
118    htp.p('                                       else '); --// found a spacer
119    htp.p('                                       { ');
120    htp.p('                                              indexofspacer = i; ');
121    htp.p('                                              spacerval = val; ');
122    htp.p('                                              spacertxt = txt; ');
123    htp.p('                                       }');
124    htp.p('                 }');
125    htp.p('                         }');
126    htp.p('           }  ');
127    htp.p('             if (indexofspacer != -1 && direction == "right" ) ');
128  --// let the spacer be on the from list
129    htp.p('                            fromList.length = 1;');
130    htp.p('             else');
131    htp.p('           if(direction == "left")');
132    htp.p('             clearList(fromList); ');
133 
134    htp.p('           deleteBlankRowIfNotEmpty(toList);');
135    htp.p('           unSelectAll(toList);');
136 
137     htp.p('          navigator.plugins.refresh(false); ');
138 
139      htp.p('}');
140 
141   end copy_all;
142 
143   procedure delete_list_element is
144   begin
145     htp.p( 'function deleteListElement(fromList)' );
146     htp.p( '{' );
147     htp.p( '  idx = fromList.selectedIndex;' );
148     htp.p( '  if ( idx == -1 )' );
149     htp.p( '    return;' );
150     htp.p( '  for ( i = idx; i < fromList.length-1; i++ )' );
151     htp.p( '  {' );
152     htp.p( '    fromList.options[i].text = fromList.options[i+1].text;' );
153     htp.p( '    fromList.options[i].value = fromList.options[i+1].value;' );
154     htp.p( '  }' );
155     htp.p( '  fromList.length = fromList.length - 1;' );
156     htp.p( '}' );
157   end delete_list_element;
158 --
159   procedure select_all is
160   begin
161     htp.p( 'function selectAll(fromList)' );
162     htp.p( '{' );
163     htp.p( '  for ( i = 0; i <= fromList.length-1; i++ )' );
164     htp.p( '    fromList.options[i].selected = true;' );
165     htp.p( '  return true;' );
166     htp.p( '}' );
167   end select_all;
168 --
169   procedure unselect_all is
170   begin
171     htp.p( 'function unSelectAll(fromList)' );
172     htp.p( '{' );
173     htp.p( '  for ( i = 0; i <= fromList.length-1; i++ )' );
174     htp.p( '    fromList.options[i].selected = false;' );
175     htp.p( '  return true;' );
176     htp.p( '}' );
177   end unselect_all;
178 --
179   procedure clear_list is
180   begin
181     htp.p( 'function clearList(fromList)' );
182     htp.p( '{' );
183     htp.p( '  fromList.length = 0;' );
184     htp.p( '}' );
185   end clear_list;
186 --
187 -- append a value to a list, maintaining unique values in the list
188   procedure append_to_list is
189   begin
190         htp.p( 'function appendToList(theValue, toList)' );
191         htp.p( '{' );
192         htp.p( '  if (theValue == "") return;' );
193         htp.p( '  for (i=0;i<toList.length;i++)' );
194         htp.p( '  {' );
195         htp.p( '    if (toList.options[i].value == theValue)' );
196         htp.p( '      return;' );
197         htp.p( '  }' );
198         htp.p( '  toList.options[toList.length] = new Option(theValue,theValue);' );
199         htp.p( '}' );
200   end append_to_list;
201 -- delete a given value from a select list
202   procedure delete_from_list is
203   begin
204         htp.p( 'function deleteFromList(theValue, fromList)' );
205         htp.p( '{' );
206         htp.p( '  for (i=0;i<fromList.length;i++)' );
207         htp.p( '  {' );
208         htp.p( '    if (fromList.options[i].value == theValue)' );
209         htp.p( '      fromList.options[i] = null;' );
210         htp.p( '  }' );
211         htp.p( '  history.go(0);' );
212         htp.p( '}' );
213   end delete_from_list;
214 --
215   procedure swap is
216   begin
217     htp.p ('function swap(e1, e2)');
218     htp.p ('{');
219     htp.p ('  ttext = e1.text;');
220     htp.p ('  tvalue = e1.value;');
221     htp.p ('  e1.text = e2.text;');
222     htp.p ('  e1.value = e2.value;');
223     htp.p ('  e2.text = ttext;');
224     htp.p ('  e2.value = tvalue;');
225     htp.p ('} ');
226   end swap;
227 --
228   procedure move_element_up is
229   begin
230     htp.p(' function moveElementUp(toList, p_formname)
231          {    // go through the list and get all selected items
232               for ( i = 0; i <= toList.length-1; i++)
233               { // if the item is selected then swap it
234                 if (toList.options[i].selected)
235                 {   // check if it is not the first item
236                     if (i != 0)
237                     {
238                         swap(toList.options[i], toList.options[i - 1]);
239                         toList.options[i - 1].selected = true;
240                         toList.options[i].selected = false;
241                     }
242                 }
243               }
244          }');
245   end move_element_up;
246 
247 --
248   procedure move_element_top is
249   begin
250     htp.p(' function moveElementTop(toList, p_formname)
251          {    // get the first item selected which needs to move to top
252               iSelected = toList.selectedIndex;
253               if (iSelected == 0)
254                  return;
255               // now run the moveup loop
256               for ( iMoveTop = 1; iMoveTop <= iSelected; iMoveTop++)
257                  moveElementUp(toList);
258          }');
259   end move_element_top;
260 --
261   procedure move_element_down is
262   begin
263     htp.p(' function moveElementDown(toList, p_formname)
264          {    // go through the list and get all selected items
265               for ( i = toList.length-1; i >= 0; i--)
266               { // if the item is selected then swap it
267                 if (toList.options[i].selected)
268                 {   // check if it is not the first item
269                     if (i != toList.length-1)
270                     {
271                         swap(toList.options[i], toList.options[i + 1]);
272                         toList.options[i + 1].selected = true;
273                         toList.options[i].selected = false;
274                     }
275                 }
276               }
277          }');
278   end move_element_down;
279 
280 --
281   procedure move_element_bottom is
282   begin
283     htp.p(' function moveElementBottom(toList, p_formname)
284          {    // get the last item selected which needs to move to bottom
285               for ( i = 0; i <= toList.length-1; i++)
286               { // if the item is selected then swap it
287                 if (toList.options[i].selected)
288                     iSelected = i;
289               }
290               if (iSelected == toList.length-1)
291                  return;
292               iSelected = toList.length - 1 - iSelected;
293               // now run the movedown loop
294               for ( iMoveDown = 1; iMoveDown <= iSelected; iMoveDown++)
295                  moveElementDown(toList);
296          }');
297   end move_element_bottom;
298 
299 
300     procedure delete_blank_row is
301   begin
302     htp.p('function deleteBlankRowIfNotEmpty(toList)');
303     htp.p('{');
304     htp.p('   var idx = -1;');
305     htp.p('   var val = "";');
306     htp.p('// find a blank row in table ');
307     htp.p('   for (i = 0; i < toList.length; i++){ ');
308     htp.p('        val = toList.options[i].value;');
309     htp.p('        if (val == "") {');
310     htp.p('           idx = i;');
311     htp.p('           break;');
312     htp.p('        }');
313     htp.p('   } ');
314     htp.p('   if (idx >= 0 && (toList.length > 1))');
315     htp.p('      toList.options[idx] = null;');
316     htp.p('}');
317   end delete_blank_row;
318 
319   procedure show_main_help
320   as
321   begin
322      open_script;
323 
324      htp.p('function show_main_help() {');
325      htp.p('   newWindow = window.open("' ||
326         'pob_help_menu_tree.show_tree' ||
327         '", "HelpPage", "menubar=1,toolbar=yes,scrollbars=1,resizable=1,width=600,height=400");');
328      htp.p('}');
329 
330      close_script;
331 
332   end show_main_help;
333 
334   procedure show_context_sens_help
335   as
336   begin
337      open_script;
338 
339      htp.p('function show_context_sens_help(helpFileName) {');
340      htp.p('   newWindow = window.open("' ||
341        'pob_help_renderer.render_context_sensitive' ||
342        '?the_filename=" + helpFileName' ||
343         ', "HelpPage", "menubar=1,toolbar=yes,scrollbars=1,resizable=1,width=600,height=400");');
344      htp.p('}');
345 
346      close_script;
347 
348   end show_context_sens_help;
349 
350 end icx_javascript;