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 var cw = iframe.contentWindow;
48 if (typeof iframe.contentWindow.wrappedJSObject != 'undefined') cw = iframe.contentWindow.wrappedJSObject;
49 cw.IAMXUL = true; cw.xulG = content_params;
50 setTimeout( function() { if (typeof cw.default_focus == 'function') cw.default_focus(); }, 0 );
52 this.error.sdump('D_ERROR','E: ' + E + '\n');
58 return this.new_iframe(url,params,content_params);
63 'reset_iframe' : function (url,params,content_params) {
64 this.remove_iframe(url);
65 return this.new_iframe(url,params,content_params);
68 'new_iframe' : function (url,params,content_params) {
69 var idx = this.find_index(url);
70 if (idx>-1) throw('An iframe already exists in deck with url = ' + url);
72 var iframe = document.createElement('iframe');
73 iframe.setAttribute('src',url);
74 //iframe.setAttribute('flex','1');
75 //iframe.setAttribute('style','overflow: scroll');
76 //iframe.setAttribute('style','border: solid thin red');
77 this.node.appendChild( iframe );
78 this.node.selectedIndex = this.node.childNodes.length - 1;
81 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
82 this.error.sdump('D_DECK', 'new_iframe\nurl = ' + url + '\nframe.contentWindow = ' + iframe.contentWindow + '\n' + 'content_params = ' + js2JSON(content_params) );
83 var cw = iframe.contentWindow;
84 if (typeof iframe.contentWindow.wrappedJSObject != 'undefined') cw = iframe.contentWindow.wrappedJSObject;
85 cw.IAMXUL = true; cw.xulG = content_params;
86 this.error.sdump('D_DECK', 'cw = ' + cw + ' cw.xulG = ' + js2JSON(cw.xulG) );
87 setTimeout( function() { if (typeof cw.default_focus == 'function') cw.default_focus(); }, 0 );
89 this.error.sdump('D_ERROR','E: ' + E + '\n');
95 'remove_iframe' : function (url) {
96 var idx = this.find_index(url);
98 this.node.removeChild( this.node.childNodes[ idx ] );
102 /* FIXME -- consider all the browser stuff broken.. very weird behavior in new_browser */
104 'set_browser' : function (url,params,content_params) {
105 this.error.sdump('D_TRACE','util.deck.set_browser: url = ' + url);
106 var idx = this.find_index(url);
108 this.node.selectedIndex = idx;
110 var browser = this.node.childNodes[idx];
112 if (content_params) {
113 /* FIXME -- we'd need to reach in and change the passthru_content_params for the browser, as well as the xulG for the content */
114 alert("we're in set_browser, content_params = true");
119 return this.new_browser(url,params,content_params);
124 'reset_browser' : function (url,params,content_params) {
125 this.remove_browser(url);
126 return this.new_browser(url,params,content_params);
129 'new_browser' : function (url,params,content_params) {
131 alert('in new_browser.. typeof xulG == ' + typeof xulG);
132 alert('in new_browser.. typeof content_params == ' + typeof content_params);
134 var idx = this.find_index(url);
135 if (idx>-1) throw('A browser already exists in deck with url = ' + url);
137 var browser = document.createElement('browser');
139 browser.setAttribute('type','content');
140 browser.setAttribute('id','frame_'+obj.id_incr);
141 browser.setAttribute('src',url);
142 this.node.appendChild( browser );
143 alert('after append');
144 this.node.selectedIndex = this.node.childNodes.length - 1;
145 dump('creating browser with src = ' + url + '\n');
146 alert('content_params = ' + content_params);
147 JSAN.use('util.browser');
148 var b = new util.browser();
154 'browser_id' : 'frame_'+obj.id_incr,
155 'passthru_content_params' : content_params,
164 'remove_browser' : function (url) {
165 var idx = this.find_index(url);
167 this.node.removeChild( this.node.childNodes[ idx ] );
174 dump('exiting util/deck.js\n');