Added LinuxChix theme
[moodle-linuxchix.git] / lib / overlib / overlib_setonoff.js
blob3d28eaf8f350951edf0a8b807be3fe1a87eb068d
1 //\/////
2 //\ overLIB Set On/Off Plugin
3 //\ This file requires overLIB 4.10 or later.
4 //\
5 //\ overLIB 4.10 - You may not remove or change this notice.
6 //\ Copyright Erik Bosrup 1998-2003. All rights reserved.
7 //\ Contributors are listed on the homepage.
8 //\ See http://www.bosrup.com/web/overlib/ for details.
9 // $Revision$ $Date$
11 //\/////
12 //\mini
13 ////////
14 // PRE-INIT
15 // Ignore these lines, configuration is below.
16 ////////
17 if (typeof olInfo == 'undefined' || typeof olInfo.meets == 'undefined' || !olInfo.meets(4.10)) alert('overLIB 4.10 or later is required for the Set On/Off Plugin.');
18 else {
19 registerCommands('seton, setoff');
20 var olSetType;
21 // END OF CONFIGURATION
22 // Don't change anything below this line, all configuration is above.
23 ////////
24 // PLUGIN FUNCTIONS
25 ////////
26 // Set runtime variables
27 function setOnOffVariables() {
28 olSetType = 0;
30 // Parses Set On/Off Parameters
31 function parseOnOffExtras(pf, i, ar) {
32 var k = i, v;
34 if (k < ar.length) {
35 if (ar[k] == SETON||ar[k] == SETOFF) { olSetType = 1; k = opt_MULTICOMMANDS(++k, ar); return k; }
38 return -1;
40 ///////
41 // HELPER FUNCTIONS
42 ///////
43 // searches arg list for COMMAND;
44 function hasCommand(istrt, args, COMMAND) {
45 for (var i = istrt; i < args.length; i++) {
46 if (typeof args[i] == 'number' && args[i] == COMMAND) return i;
49 return -1;
51 // scans for toggle like commands to be forced ON/OFF
52 function scanCommandSet(pf, args) {
53 var k = -1, j, je;
55 if (olSetType) {
56 // search for SETON command
57 while ((k = hasCommand(++k, args, SETON)) < args.length && k > -1) {
58 je = opt_MULTICOMMANDS(k + 1, args);
59 for (j = k + 1; j < (k + je); j++) setNoParamCommand(1, pf, args[j]);
60 k += (je - 1);
62 // search for SETOFF command
63 k = -1;
64 while ((k = hasCommand(++k, args, SETOFF)) < args.length && k > -1) {
65 je = opt_MULTICOMMANDS(k + 1, args);
66 for (j = k + 1; j < (k + je); j++) setNoParamCommand(0, pf, args[j]);
67 k += (je - 1);
71 return true;
73 var olRe;
74 // set command according to whichType (0 or 1)
75 function setNoParamCommand(whichType, pf, COMMAND) {
76 var v = pms[COMMAND - 1 - pmStart];
78 if(pmt && !olRe) olRe = eval('/' + pmt.split(',').join('|') + '/');
79 if (pf != 'ol_' && /capturefirst/.test(v)) return; // no o3_capturefirst variable
80 if (pf != 'ol_' && /wrap/.test(v) && eval(pf + 'wrap') && (whichType == 0)) {
81 nbspCleanup(); // undo wrap effects since checked after all parsing
82 o3_width = ol_width;
85 if (olRe.test(v)) eval(pf + v + '=' + ((whichType && COMMAND == AUTOSTATUSCAP) ? whichType++ : whichType));
87 function opt_MULTICOMMANDS(i, ar) {
88 var k = i;
90 while (k < ar.length && typeof ar[k] == 'number' && ar[k] > pmStart) {k++; if (ar[k - 1] == 'SETON'||ar[k - 1] == 'SETOFF') break;}
91 k -= (k < ar.length ? 2 : 1);
93 return k;
95 ////////
96 // PLUGIN REGISTRATIONS
97 ////////
98 registerRunTimeFunction(setOnOffVariables);
99 registerCmdLineFunction(parseOnOffExtras);
100 registerPostParseFunction(scanCommandSet);