2 //\ overLIB Set On/Off Plugin
3 //\ This file requires overLIB 4.10 or later.
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.
15 // Ignore these lines, configuration is below.
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.');
19 registerCommands('seton, setoff');
21 // END OF CONFIGURATION
22 // Don't change anything below this line, all configuration is above.
26 // Set runtime variables
27 function setOnOffVariables() {
30 // Parses Set On/Off Parameters
31 function parseOnOffExtras(pf
, i
, ar
) {
35 if (ar
[k
] == SETON
||ar
[k
] == SETOFF
) { olSetType
= 1; k
= opt_MULTICOMMANDS(++k
, ar
); return k
; }
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
;
51 // scans for toggle like commands to be forced ON/OFF
52 function scanCommandSet(pf
, args
) {
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
]);
62 // search for SETOFF command
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
]);
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
85 if (olRe
.test(v
)) eval(pf
+ v
+ '=' + ((whichType
&& COMMAND
== AUTOSTATUSCAP
) ? whichType
++ : whichType
));
87 function opt_MULTICOMMANDS(i
, ar
) {
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);
96 // PLUGIN REGISTRATIONS
98 registerRunTimeFunction(setOnOffVariables
);
99 registerCmdLineFunction(parseOnOffExtras
);
100 registerPostParseFunction(scanCommandSet
);