/[cvs]/nfo/php/libs/net.php.pear/HTML/TreeMenu.js
ViewVC logotype

Contents of /nfo/php/libs/net.php.pear/HTML/TreeMenu.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Wed Jul 7 02:21:09 2004 UTC (20 years ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +59 -26 lines
File MIME type: application/javascript
updated to HTML_TreeMenu-1.1.9 (PEAR)

1 // +-----------------------------------------------------------------------+
2 // | Copyright (c) 2002-2003, Richard Heyes, Harald Radi |
3 // | All rights reserved. |
4 // | |
5 // | Redistribution and use in source and binary forms, with or without |
6 // | modification, are permitted provided that the following conditions |
7 // | are met: |
8 // | |
9 // | o Redistributions of source code must retain the above copyright |
10 // | notice, this list of conditions and the following disclaimer. |
11 // | o Redistributions in binary form must reproduce the above copyright |
12 // | notice, this list of conditions and the following disclaimer in the |
13 // | documentation and/or other materials provided with the distribution.|
14 // | o The names of the authors may not be used to endorse or promote |
15 // | products derived from this software without specific prior written |
16 // | permission. |
17 // | |
18 // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 // | |
30 // +-----------------------------------------------------------------------+
31 // | Author: Richard Heyes <richard@phpguru.org> |
32 // | Harald Radi <harald.radi@nme.at> |
33 // +-----------------------------------------------------------------------+
34 //
35 // Id: TreeMenu.js,v 1.18 2003/12/20 13:33:09 richard Exp
36 // $Id: TreeMenu.js,v 1.18 2003/12/20 13:33:09 richard Exp $
37
38 /**
39 * Function to create copies of objects which are
40 * normally passed around by references (Arrays for example)
41 */
42 function arrayCopy(input)
43 {
44 var output = new Array(input.length);
45
46 for (i in input) {
47 if (typeof(input[i]) == 'array') {
48 output[i] = arrayCopy(input[i]);
49 } else {
50 output[i] = input[i];
51 }
52 }
53
54 return output;
55 }
56
57 /**
58 * TreeMenu class
59 */
60 function TreeMenu(iconpath, myname, linkTarget, defaultClass, usePersistence, noTopLevelImages)
61 {
62 // Properties
63 this.iconpath = iconpath;
64 this.myname = myname;
65 this.linkTarget = linkTarget;
66 this.defaultClass = defaultClass;
67 this.usePersistence = usePersistence;
68 this.noTopLevelImages = noTopLevelImages;
69 this.n = new Array();
70 this.output = '';
71
72 this.nodeRefs = new Array();
73 this.branches = new Array();
74 this.branchStatus = new Array();
75 this.layerRelations = new Array();
76 this.childParents = new Array();
77 this.cookieStatuses = new Array();
78
79 this.preloadImages();
80 }
81
82 /**
83 * Adds a node to the tree
84 */
85 TreeMenu.prototype.addItem = function (newNode)
86 {
87 newIndex = this.n.length;
88 this.n[newIndex] = newNode;
89
90 return this.n[newIndex];
91 }
92
93 /**
94 * Preload images hack for Mozilla
95 */
96 TreeMenu.prototype.preloadImages = function ()
97 {
98 var plustop = new Image; plustop.src = this.iconpath + '/plustop.gif';
99 var plusbottom = new Image; plusbottom.src = this.iconpath + '/plusbottom.gif';
100 var plus = new Image; plus.src = this.iconpath + '/plus.gif';
101
102 var minustop = new Image; minustop.src = this.iconpath + '/minustop.gif';
103 var minusbottom = new Image; minusbottom.src = this.iconpath + '/minusbottom.gif';
104 var minus = new Image; minus.src = this.iconpath + '/minus.gif';
105
106 var branchtop = new Image; branchtop.src = this.iconpath + '/branchtop.gif';
107 var branchbottom = new Image; branchbottom.src = this.iconpath + '/branchbottom.gif';
108 var branch = new Image; branch.src = this.iconpath + '/branch.gif';
109
110 var linebottom = new Image; linebottom.src = this.iconpath + '/linebottom.gif';
111 var line = new Image; line.src = this.iconpath + '/line.gif';
112 }
113
114 /**
115 * Main function that draws the menu and assigns it
116 * to the layer (or document.write()s it)
117 */
118 TreeMenu.prototype.drawMenu = function ()// OPTIONAL ARGS: nodes = [], level = [], prepend = '', expanded = false, visbility = 'inline', parentLayerID = null
119 {
120 /**
121 * Necessary variables
122 */
123 var output = '';
124 var modifier = '';
125 var layerID = '';
126 var parentLayerID = '';
127
128 /**
129 * Parse any optional arguments
130 */
131 var nodes = arguments[0] ? arguments[0] : this.n
132 var level = arguments[1] ? arguments[1] : [];
133 var prepend = arguments[2] ? arguments[2] : '';
134 var expanded = arguments[3] ? arguments[3] : false;
135 var visibility = arguments[4] ? arguments[4] : 'inline';
136 var parentLayerID = arguments[5] ? arguments[5] : null;
137
138 var currentlevel = level.length;
139
140 for (var i=0; i<nodes.length; i++) {
141
142 level[currentlevel] = i+1;
143 layerID = this.myname + '_' + 'node_' + this.implode('_', level);
144
145 /**
146 * Store this object in the nodeRefs array
147 */
148 this.nodeRefs[layerID] = nodes[i];
149
150 /**
151 * Store the child/parent relationship
152 */
153 this.childParents[layerID] = parentLayerID;
154
155 /**
156 * Gif modifier
157 */
158 if (i == 0 && parentLayerID == null) {
159 modifier = nodes.length > 1 ? "top" : 'single';
160 } else if(i == (nodes.length-1)) {
161 modifier = "bottom";
162 } else {
163 modifier = "";
164 }
165
166 /**
167 * Single root branch is always expanded
168 */
169 if (!this.doesMenu() || (parentLayerID == null && (nodes.length == 1 || this.noTopLevelImages))) {
170 expanded = true;
171
172 } else if (nodes[i].expanded) {
173 expanded = true;
174
175 } else {
176 expanded = false;
177 }
178
179 /**
180 * Make sure visibility is correct based on parent status
181 */
182 visibility = this.checkParentVisibility(layerID) ? visibility : 'none';
183
184 /**
185 * Setup branch status and build an indexed array
186 * of branch layer ids
187 */
188 if (nodes[i].n.length > 0) {
189 this.branchStatus[layerID] = expanded;
190 this.branches[this.branches.length] = layerID;
191 }
192
193 /**
194 * Setup toggle relationship
195 */
196 if (!this.layerRelations[parentLayerID]) {
197 this.layerRelations[parentLayerID] = new Array();
198 }
199 this.layerRelations[parentLayerID][this.layerRelations[parentLayerID].length] = layerID;
200
201 /**
202 * Branch images
203 */
204 var gifname = nodes[i].n.length && this.doesMenu() && nodes[i].isDynamic ? (expanded ? 'minus' : 'plus') : 'branch';
205 var iconName = expanded && nodes[i].expandedIcon ? nodes[i].expandedIcon : nodes[i].icon;
206 var iconimg = nodes[i].icon ? this.stringFormat('<img src="{0}/{1}" width="20" height="20" align="top" id="icon_{2}">', this.iconpath, iconName, layerID) : '';
207
208 /**
209 * Add event handlers
210 */
211 var eventHandlers = "";
212 for (j in nodes[i].events) {
213 eventHandlers += this.stringFormat('{0}="{1}" ', j, nodes[i].events[j]);
214 }
215
216 /**
217 * Build the html to write to the document
218 * IMPORTANT:
219 * document.write()ing the string: '<div style="display:...' will screw up nn4.x
220 */
221 var layerTag = this.doesMenu() ? this.stringFormat('<div id="{0}" style="display: {1}" class="{2}">', layerID, visibility, (nodes[i].cssClass ? nodes[i].cssClass : this.defaultClass)) : this.stringFormat('<div class="{0}">', nodes[i].cssClass ? nodes[i].cssClass : this.defaultClass);
222 var onMDown = this.doesMenu() && nodes[i].n.length && nodes[i].isDynamic ? this.stringFormat('onmousedown="{0}.toggleBranch(\'{1}\', true)" style="cursor: pointer; cursor: hand"', this.myname, layerID) : '';
223 var imgTag = this.stringFormat('<img src="{0}/{1}{2}.gif" width="20" height="20" align="top" border="0" name="img_{3}" {4}>', this.iconpath, gifname, modifier, layerID, onMDown);
224 var linkTarget= nodes[i].linkTarget ? nodes[i].linkTarget : this.linkTarget;
225 var linkStart = nodes[i].link ? this.stringFormat('<a href="{0}" target="{1}">', nodes[i].link, linkTarget) : '';
226
227 var linkEnd = nodes[i].link ? '</a>' : '';
228
229 this.output += this.stringFormat('{0}<nobr>{1}{2}{3}{4}<span {5}>{6}</span>{7}</nobr><br></div>',
230 layerTag,
231 prepend,
232 parentLayerID == null && (nodes.length == 1 || this.noTopLevelImages) ? '' : imgTag,
233 iconimg,
234 linkStart,
235 eventHandlers,
236 nodes[i].title,
237 linkEnd);
238
239 /**
240 * Traverse sub nodes ?
241 */
242 if (nodes[i].n.length) {
243 /**
244 * Determine what to prepend. If there is only one root
245 * node then the prepend to pass to children is nothing.
246 * Otherwise it depends on where we are in the tree.
247 */
248 if (parentLayerID == null && (nodes.length == 1 || this.noTopLevelImages)) {
249 var newPrepend = '';
250
251 } else if (i < (nodes.length - 1)) {
252 var newPrepend = prepend + this.stringFormat('<img src="{0}/line.gif" width="20" height="20" align="top">', this.iconpath);
253
254 } else {
255 var newPrepend = prepend + this.stringFormat('<img src="{0}/linebottom.gif" width="20" height="20" align="top">', this.iconpath);
256 }
257
258 this.drawMenu(nodes[i].n,
259 arrayCopy(level),
260 newPrepend,
261 nodes[i].expanded,
262 expanded ? 'inline' : 'none',
263 layerID);
264 }
265 }
266 }
267
268 /**
269 * Writes the output generated by drawMenu() to the page
270 */
271 TreeMenu.prototype.writeOutput = function ()
272 {
273 document.write(this.output);
274 }
275
276 /**
277 * Toggles a branches visible status. Called from resetBranches()
278 * and also when a +/- graphic is clicked.
279 */
280 TreeMenu.prototype.toggleBranch = function (layerID, updateStatus) // OPTIONAL ARGS: fireEvents = true
281 {
282 var currentDisplay = this.getLayer(layerID).style.display;
283 var newDisplay = (this.branchStatus[layerID] && currentDisplay == 'inline') ? 'none' : 'inline';
284 var fireEvents = arguments[2] != null ? arguments[2] : true;
285
286 for (var i=0; i<this.layerRelations[layerID].length; i++) {
287
288 if (this.branchStatus[this.layerRelations[layerID][i]]) {
289 this.toggleBranch(this.layerRelations[layerID][i], false);
290 }
291
292 this.getLayer(this.layerRelations[layerID][i]).style.display = newDisplay;
293 }
294
295 if (updateStatus) {
296 this.branchStatus[layerID] = !this.branchStatus[layerID];
297
298 /**
299 * Persistence
300 */
301 if (this.doesPersistence() && !arguments[2] && this.usePersistence) {
302 this.setExpandedStatusForCookie(layerID, this.branchStatus[layerID]);
303 }
304
305 /**
306 * Fire custom events
307 */
308 if (fireEvents) {
309 nodeObject = this.nodeRefs[layerID];
310
311 if (nodeObject.ontoggle != null) {
312 eval(nodeObject.ontoggle);
313 }
314
315 if (newDisplay == 'none' && nodeObject.oncollapse != null) {
316 eval(nodeObject.oncollapse);
317 } else if (newDisplay == 'inline' && nodeObject.onexpand != null){
318 eval(nodeObject.onexpand);
319 }
320 }
321
322 // Swap image
323 this.swapImage(layerID);
324 }
325
326 // Swap icon
327 this.swapIcon(layerID);
328 }
329
330 /**
331 * Swaps the plus/minus branch images
332 */
333 TreeMenu.prototype.swapImage = function (layerID)
334 {
335 var imgSrc = document.images['img_' + layerID].src;
336
337 var re = /^(.*)(plus|minus)(bottom|top|single)?.gif$/
338 if (matches = imgSrc.match(re)) {
339
340 document.images['img_' + layerID].src = this.stringFormat('{0}{1}{2}{3}',
341 matches[1],
342 matches[2] == 'plus' ? 'minus' : 'plus',
343 matches[3] ? matches[3] : '',
344 '.gif');
345 }
346 }
347
348 /**
349 * Swaps the icon for the expanded icon if one
350 * has been supplied.
351 */
352 TreeMenu.prototype.swapIcon = function (layerID)
353 {
354 if (document.images['icon_' + layerID]) {
355 var imgSrc = document.images['icon_' + layerID].src;
356
357 if (this.nodeRefs[layerID].icon && this.nodeRefs[layerID].expandedIcon) {
358 var newSrc = (imgSrc.indexOf(this.nodeRefs[layerID].expandedIcon) == -1 ? this.nodeRefs[layerID].expandedIcon : this.nodeRefs[layerID].icon);
359
360 document.images['icon_' + layerID].src = this.iconpath + '/' + newSrc;
361 }
362 }
363 }
364
365 /**
366 * Can the browser handle the dynamic menu?
367 */
368 TreeMenu.prototype.doesMenu = function ()
369 {
370 return (is_ie4up || is_nav6up || is_gecko || is_opera7);
371 }
372
373 /**
374 * Can the browser handle save the branch status
375 */
376 TreeMenu.prototype.doesPersistence = function ()
377 {
378 return (is_ie4up || is_gecko || is_nav6up || is_opera7);
379 }
380
381 /**
382 * Returns the appropriate layer accessor
383 */
384 TreeMenu.prototype.getLayer = function (layerID)
385 {
386 if (is_ie4) {
387 return document.all(layerID);
388
389 } else if (document.getElementById(layerID)) {
390 return document.getElementById(layerID);
391
392 } else if (document.all(layerID)) {
393 return document.all(layerID);
394 }
395 }
396
397 /**
398 * Save the status of the layer
399 */
400 TreeMenu.prototype.setExpandedStatusForCookie = function (layerID, expanded)
401 {
402 this.cookieStatuses[layerID] = expanded;
403 this.saveCookie();
404 }
405
406 /**
407 * Load the status of the layer
408 */
409 TreeMenu.prototype.getExpandedStatusFromCookie = function (layerID)
410 {
411 if (this.cookieStatuses[layerID]) {
412 return this.cookieStatuses[layerID];
413 }
414
415 return false;
416 }
417
418 /**
419 * Saves the cookie that holds which branches are expanded.
420 * Only saves the details of the branches which are expanded.
421 */
422 TreeMenu.prototype.saveCookie = function ()
423 {
424 var cookieString = new Array();
425
426 for (var i in this.cookieStatuses) {
427 if (this.cookieStatuses[i] == true) {
428 cookieString[cookieString.length] = i;
429 }
430 }
431
432 document.cookie = 'TreeMenuBranchStatus=' + cookieString.join(':');
433 }
434
435 /**
436 * Reads cookie parses it for status info and
437 * stores that info in the class member.
438 */
439 TreeMenu.prototype.loadCookie = function ()
440 {
441 var cookie = document.cookie.split('; ');
442
443 for (var i=0; i < cookie.length; i++) {
444 var crumb = cookie[i].split('=');
445 if ('TreeMenuBranchStatus' == crumb[0] && crumb[1]) {
446 var expandedBranches = crumb[1].split(':');
447 for (var j=0; j<expandedBranches.length; j++) {
448 this.cookieStatuses[expandedBranches[j]] = true;
449 }
450 }
451 }
452 }
453
454 /**
455 * Reset branch status
456 */
457 TreeMenu.prototype.resetBranches = function ()
458 {
459 if (!this.doesPersistence()) {
460 return false;
461 }
462
463 this.loadCookie();
464
465 for (var i=0; i<this.branches.length; i++) {
466 var status = this.getExpandedStatusFromCookie(this.branches[i]);
467 // Only update if it's supposed to be expanded and it's not already
468 if (status == true && this.branchStatus[this.branches[i]] != true) {
469 if (this.checkParentVisibility(this.branches[i])) {
470 this.toggleBranch(this.branches[i], true, false);
471 } else {
472 this.branchStatus[this.branches[i]] = true;
473 this.swapImage(this.branches[i]);
474 }
475 }
476 }
477 }
478
479 /**
480 * Checks whether a branch should be open
481 * or not based on its parents' status
482 */
483 TreeMenu.prototype.checkParentVisibility = function (layerID)
484 {
485 if (this.in_array(this.childParents[layerID], this.branches)
486 && this.branchStatus[this.childParents[layerID]]
487 && this.checkParentVisibility(this.childParents[layerID]) ) {
488
489 return true;
490
491 } else if (this.childParents[layerID] == null) {
492 return true;
493 }
494
495 return false;
496 }
497
498 /**
499 * New C# style string formatter
500 */
501 TreeMenu.prototype.stringFormat = function (strInput)
502 {
503 var idx = 0;
504
505 for (var i=1; i<arguments.length; i++) {
506 while ((idx = strInput.indexOf('{' + (i - 1) + '}', idx)) != -1) {
507 strInput = strInput.substring(0, idx) + arguments[i] + strInput.substr(idx + 3);
508 }
509 }
510
511 return strInput;
512 }
513
514 /**
515 * Also much adored, the PHP implode() function
516 */
517 TreeMenu.prototype.implode = function (seperator, input)
518 {
519 var output = '';
520
521 for (var i=0; i<input.length; i++) {
522 if (i == 0) {
523 output += input[i];
524 } else {
525 output += seperator + input[i];
526 }
527 }
528
529 return output;
530 }
531
532 /**
533 * Aah, all the old favourites are coming out...
534 */
535 TreeMenu.prototype.in_array = function (item, arr)
536 {
537 for (var i=0; i<arr.length; i++) {
538 if (arr[i] == item) {
539 return true;
540 }
541 }
542
543 return false;
544 }
545
546 /**
547 * TreeNode Class
548 */
549 function TreeNode(title, icon, link, expanded, isDynamic, cssClass, linkTarget, expandedIcon)
550 {
551 this.title = title;
552 this.icon = icon;
553 this.expandedIcon = expandedIcon;
554 this.link = link;
555 this.expanded = expanded;
556 this.isDynamic = isDynamic;
557 this.cssClass = cssClass;
558 this.linkTarget = linkTarget;
559 this.n = new Array();
560 this.events = new Array();
561 this.handlers = null;
562 this.oncollapse = null;
563 this.onexpand = null;
564 this.ontoggle = null;
565 }
566
567 /**
568 * Adds a node to an already existing node
569 */
570 TreeNode.prototype.addItem = function (newNode)
571 {
572 newIndex = this.n.length;
573 this.n[newIndex] = newNode;
574
575 return this.n[newIndex];
576 }
577
578 /**
579 * Sets an event for this particular node
580 */
581 TreeNode.prototype.setEvent = function (eventName, eventHandler)
582 {
583 switch (eventName.toLowerCase()) {
584 case 'onexpand':
585 this.onexpand = eventHandler;
586 break;
587
588 case 'oncollapse':
589 this.oncollapse = eventHandler;
590 break;
591
592 case 'ontoggle':
593 this.ontoggle = eventHandler;
594 break;
595
596 default:
597 this.events[eventName] = eventHandler;
598 }
599 }
600
601 /**
602 * That's the end of the tree classes. What follows is
603 * the browser detection code.
604 */
605
606
607 //<!--
608 // Ultimate client-side JavaScript client sniff. Version 3.03
609 // (C) Netscape Communications 1999-2001. Permission granted to reuse and distribute.
610 // Revised 17 May 99 to add is_nav5up and is_ie5up (see below).
611 // Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up
612 // also added support for IE5.5 Opera4&5 HotJava3 AOLTV
613 // Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4,
614 // correct Opera 5 detection
615 // add support for winME and win2k
616 // synch with browser-type-oo.js
617 // Revised 26 Mar 01 to correct Opera detection
618 // Revised 02 Oct 01 to add IE6 detection
619
620 // Everything you always wanted to know about your JavaScript client
621 // but were afraid to ask. Creates "is_" variables indicating:
622 // (1) browser vendor:
623 // is_nav, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV
624 // (2) browser version number:
625 // is_major (integer indicating major version number: 2, 3, 4 ...)
626 // is_minor (float indicating full version number: 2.02, 3.01, 4.04 ...)
627 // (3) browser vendor AND major version number
628 // is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_ie3,
629 // is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up,
630 // is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up
631 // (4) JavaScript version number:
632 // is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
633 // (5) OS platform and version:
634 // is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98, is_winme, is_win2k
635 // is_os2
636 // is_mac, is_mac68k, is_macppc
637 // is_unix
638 // is_sun, is_sun4, is_sun5, is_suni86
639 // is_irix, is_irix5, is_irix6
640 // is_hpux, is_hpux9, is_hpux10
641 // is_aix, is_aix1, is_aix2, is_aix3, is_aix4
642 // is_linux, is_sco, is_unixware, is_mpras, is_reliant
643 // is_dec, is_sinix, is_freebsd, is_bsd
644 // is_vms
645 //
646 // See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
647 // http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
648 // for detailed lists of userAgent strings.
649 //
650 // Note: you don't want your Nav4 or IE4 code to "turn off" or
651 // stop working when new versions of browsers are released, so
652 // in conditional code forks, use is_ie5up ("IE 5.0 or greater")
653 // is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera5
654 // to check version in code which you want to work on future
655 // versions.
656
657 /**
658 * Severly curtailed all this as only certain elements
659 * are required by TreeMenu, specifically:
660 * o is_ie4up
661 * o is_nav6up
662 * o is_gecko
663 */
664
665 // convert all characters to lowercase to simplify testing
666 var agt=navigator.userAgent.toLowerCase();
667
668 // *** BROWSER VERSION ***
669 // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
670 var is_major = parseInt(navigator.appVersion);
671 var is_minor = parseFloat(navigator.appVersion);
672
673 // Note: Opera and WebTV spoof Navigator. We do strict client detection.
674 // If you want to allow spoofing, take out the tests for opera and webtv.
675 var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
676 && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
677 && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
678 var is_nav6up = (is_nav && (is_major >= 5));
679 var is_gecko = (agt.indexOf('gecko') != -1);
680
681
682 var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
683 var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
684 var is_ie4up = (is_ie && (is_major >= 4));
685
686 var is_opera = (agt.indexOf("opera") != -1);
687 var is_opera7 = is_opera && (agt.indexOf("opera 7") != -1);
688
689 // Patch from Harald Fielker
690 if (agt.indexOf('konqueror') != -1) {
691 var is_nav = false;
692 var is_nav6up = false;
693 var is_gecko = false;
694 var is_ie = true;
695 var is_ie4 = true;
696 var is_ie4up = true;
697 }
698 //--> end hide JavaScript

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed