1 dump('entering util/deck.js\n');
3 if (typeof util == 'undefined') util = {};
4 util.deck = function (id) {
6 this.node = document.getElementById(id);
8 JSAN.use('util.error'); this.error = new util.error();
11 var error = 'util.deck: Could not find element ' + id;
12 this.error.sdump('D_ERROR',error);
15 if (this.node.nodeName != 'deck') {
16 var error = 'util.deck: ' + id + 'is not a deck' + "\nIt's a " + this.node.nodeName;
17 this.error.sdump('D_ERROR',error);
24 util.deck.prototype = {
26 'find_index' : function (url) {
28 var nodes = this.node.childNodes;
29 for (var i = 0; i < nodes.length; i++) {
30 if (nodes[i].getAttribute('src') == url) idx = i;
35 'set_iframe' : function (url,params,content_params) {
36 this.error.sdump('D_TRACE','util.deck.set_iframe: url = ' + url);
37 var idx = this.find_index(url);
39 this.node.selectedIndex = idx;
41 var iframe = this.node.childNodes[idx];
45 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
46 this.error.sdump('D_DECK', 'set_iframe\nurl = ' + url + '\nframe.contentWindow = ' + iframe.contentWindow + '\n' + 'content_params = ' + js2JSON(content_params) );
47 iframe.contentWindow.IAMXUL = true;
48 iframe.contentWindow.xulG = content_params;
50 this.error.sdump('D_ERROR','E: ' + E + '\n');
56 return this.new_iframe(url,params,content_params);
61 'reset_iframe' : function (url,params,content_params) {
62 this.remove_iframe(url);
63 return this.new_iframe(url,params,content_params);
66 'new_iframe' : function (url,params,content_params) {
67 var idx = this.find_index(url);
68 if (idx>-1) throw('An iframe already exists in deck with url = ' + url);
70 var iframe = document.createElement('iframe');
71 iframe.setAttribute('src',url);
72 //iframe.setAttribute('flex','1');
73 //iframe.setAttribute('style','overflow: scroll');
74 //iframe.setAttribute('style','border: solid thin red');
75 this.node.appendChild( iframe );
76 this.node.selectedIndex = this.node.childNodes.length - 1;
79 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
80 this.error.sdump('D_DECK', 'new_iframe\nurl = ' + url + '\nframe.contentWindow = ' + iframe.contentWindow + '\n' + 'content_params = ' + js2JSON(content_params) );
81 iframe.contentWindow.IAMXUL = true;
82 iframe.contentWindow.xulG = content_params;
84 this.error.sdump('D_ERROR','E: ' + E + '\n');
90 'remove_iframe' : function (url) {
91 var idx = this.find_index(url);
93 this.node.removeChild( this.node.childNodes[ idx ] );
98 dump('exiting util/deck.js\n');