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 if (!this.node) throw('Could not find element ' + id);
9 if (this.node.nodeName != 'deck') throw(id + ' is not a deck');
14 util.deck.prototype = {
16 'find_index' : function (url) {
18 var nodes = this.node.childNodes;
19 for (var i in nodes) {
20 if (nodes[i].getAttribute('src') == url) idx = i;
25 'set_iframe' : function (url) {
26 var idx = this.find_index(url);
28 this.node.selectedIndex = idx;
36 'reset_iframe' : function (url) {
37 this.remove_iframe(url);
41 'new_iframe' : function (url) {
42 var idx = this.find_index(url);
43 if (idx>-1) throw('An iframe already exists in deck with url = ' + url);
45 var iframe = document.createElement('iframe');
46 iframe.setAttribute('src',url);
47 iframe.setAttribute('flex','1');
48 this.node.appendChild( iframe );
49 //this.node.selectedIndex = this.node.childNodes.length - 1;
52 'remove_iframe' : function (url) {
53 var idx = this.find_index(url);
55 this.node.removeChild( this.node.childNodes[ idx ] );
60 dump('exiting util/deck.js\n');