Mercurial > hg > digilib-old
comparison client/digitallibrary/relato/relato.js @ 223:41de43a00bf8
new relato import
author | luginbue |
---|---|
date | Fri, 09 Jul 2004 01:55:31 +0200 |
parents | f1631db2ff3d |
children |
comparison
equal
deleted
inserted
replaced
222:dc38bdeb58d7 | 223:41de43a00bf8 |
---|---|
1 top.name = 'f' | 1 top.name = 'f'; |
2 | 2 |
3 if ( !top.focused ) | 3 if ( !top.focused ) |
4 top.focused = ''; | 4 top.focused = new Object(); |
5 | 5 |
6 | 6 |
7 function identity() { | 7 function identify() { |
8 return 'Relato v0.1'; | 8 return 'Relato v0.1'; |
9 } | 9 } |
10 | 10 |
11 | 11 |
12 function frameSelected() { | 12 function frameSelected() { |
13 return top.focused != ''; | 13 return top.focused != ''; |
14 } | |
15 | |
16 | |
17 function frameSelectable(name) { | |
18 // created by xls | |
19 var frames = protectedFrames(); | |
20 var selectable = true; | |
21 for (var i=0; i<frames.length; i++) { | |
22 if (frames[i] == name) { | |
23 selectable = false; | |
24 } | |
25 } | |
26 return selectable; | |
14 } | 27 } |
15 | 28 |
16 | 29 |
17 function noFrameSelected() { | 30 function noFrameSelected() { |
18 alert( "No frame activated at the moment - click on the desired frame to activate it!" ); | 31 alert( "No frame activated at the moment - click on the desired frame to activate it!" ); |
27 function selectedFrameObject() { | 40 function selectedFrameObject() { |
28 return top.focused; | 41 return top.focused; |
29 } | 42 } |
30 | 43 |
31 | 44 |
32 function hex_color(dec) { | |
33 var hex = "#"; | |
34 for (i = 6; i > 0; i--) { | |
35 var pow = Math.pow(16, i); | |
36 if (pow < dec) { | |
37 val = parseInt(dec / pow); | |
38 dec -= val*pow; | |
39 if (val > 9) { | |
40 switch (val) { | |
41 case (10): hex += 'A'; break; | |
42 case (11): hex += 'B'; break; | |
43 case (12): hex += 'C'; break; | |
44 case (13): hex += 'D'; break; | |
45 case (14): hex += 'E'; break; | |
46 case (15): hex += 'F'; break; | |
47 } | |
48 } else { | |
49 hex += val; | |
50 } | |
51 } else { | |
52 hex += "0"; | |
53 } | |
54 } | |
55 return hex; | |
56 } | |
57 | |
58 function init() { | 45 function init() { |
59 // do the initialisation just if it is top-level relato | 46 // do the initialisation just if it is top-level relato |
60 if ( top == window ) { | 47 if ( top == window ) { |
61 init_rec( top, top.name ); | 48 init_rec( top, top.name ); |
62 } | 49 } |
69 if (current.frames.length > 0) { | 56 if (current.frames.length > 0) { |
70 for ( i=0; i < current.frames.length; i++ ) { | 57 for ( i=0; i < current.frames.length; i++ ) { |
71 if (!current.frames[i].name) { | 58 if (!current.frames[i].name) { |
72 current.frames[i].name = name + i; | 59 current.frames[i].name = name + i; |
73 } | 60 } |
74 current.frames[i].addEventListener( 'click', focusListener, true ); | 61 if (frameSelectable(current.frames[i].name)) { |
62 current.frames[i].addEventListener( 'click', focusListener, true ); | |
63 if (current.frames[i].name == nameOfSelectedFrame()) { | |
64 top.focused = current.frames[i]; | |
65 } | |
66 } else { | |
67 if (current.frames[i] == selectedFrameObject()) { | |
68 top.focused = ''; | |
69 } | |
70 } | |
75 current.frames[i].addEventListener( 'unload', unloadListener, true ); | 71 current.frames[i].addEventListener( 'unload', unloadListener, true ); |
76 if (current.frames[i] == selectedFrameObject()) { | |
77 // var color = current.frames[i].document.bgColor; | |
78 // if (color.match(/#\d{6}/)) { | |
79 // color = parseInt('0x' + color.slice(1)) - parseInt('0x222222'); | |
80 // if (color < 0) { | |
81 // color = 0; | |
82 // } | |
83 // current.frames[i].document.bgColor = hex_color(color); | |
84 // } | |
85 current.frames[i].document.bgColor = '#444444'; | |
86 } | |
87 init_rec( current.frames[i], current.frames[i].name ); | 72 init_rec( current.frames[i], current.frames[i].name ); |
88 } | 73 } |
89 } | 74 } |
75 } | |
76 | |
77 | |
78 function listFrames() { | |
79 | |
80 var frames = new Array(); | |
81 | |
82 function listFrames_rec( current ) { | |
83 | |
84 if (current.frames.length > 0) { | |
85 for (var i=0; i < current.frames.length; i++) { | |
86 listFrames_rec(current.frames[i]); | |
87 } | |
88 } else { | |
89 frames.push(current); | |
90 } | |
91 } | |
92 | |
93 listFrames_rec(top); | |
94 | |
95 return frames; | |
96 | |
97 } | |
98 | |
99 | |
100 function getXML() { | |
101 query_string = location.search; | |
102 query_string.search(/xml=([^\&]*)\&/); | |
103 return RegExp.$1; | |
104 } | |
105 | |
106 | |
107 function blink() { | |
108 orig_color = top.focused.document.bgColor; | |
109 top.focused.document.bgColor="black"; | |
110 setTimeout('top.focused.document.bgColor="' + orig_color + '"', 100); | |
90 } | 111 } |
91 | 112 |
92 | 113 |
93 function focusListener( event ) { | 114 function focusListener( event ) { |
94 | 115 |
96 | 117 |
97 if ( event.ctrlKey ) { | 118 if ( event.ctrlKey ) { |
98 active = this.parent; | 119 active = this.parent; |
99 } | 120 } |
100 | 121 |
101 markActiveFrame_rec( top, active ); | 122 // can be used in future to mark several frames |
123 // markActiveFrame_rec( top, active ); | |
102 | 124 |
103 top.focused = active; | 125 top.focused = active; |
126 | |
127 blink(); | |
104 | 128 |
105 // just debug information | 129 // just debug information |
106 window.status = top.focused.name; | 130 window.status = top.focused.name; |
107 } | 131 } |
108 | 132 |
109 | 133 |
110 function unloadListener( event ) { | 134 function unloadListener( event ) { |
111 setTimeout('init()', 250); | 135 setTimeout('init()', 250); |
112 } | 136 } |
113 | 137 |
138 | |
114 function markActiveFrame_rec(current, active) { | 139 function markActiveFrame_rec(current, active) { |
115 | 140 |
116 if ( current.frames.length > 0 ) { | 141 if ( current.frames.length > 0 ) { |
117 for ( i=0; i < current.frames.length; i++ ) { | 142 for ( i=0; i < current.frames.length; i++ ) { |
118 markActiveFrame_rec( current.frames[i], active ); | 143 markActiveFrame_rec( current.frames[i], active ); |
119 } | 144 } |
120 } else { | 145 } else { |
121 if ( current.name.indexOf(active.name) == 0 ) { | 146 if ( current.name.indexOf(active.name) == 0 ) { |
122 // var color = current.document.bgColor; | |
123 // if (color.match(/#\d{6}/)) { | |
124 // color = parseInt('0x' + color.slice(1)) - parseInt('0x222222'); | |
125 // if (color < 0) { | |
126 // color = 0; | |
127 // } | |
128 // current.document.bgColor = hex_color(color); | |
129 // } | |
130 current.document.bgColor = '#444444'; | 147 current.document.bgColor = '#444444'; |
131 } else { | 148 } else { |
132 current.document.bgColor = '#666666'; | 149 current.document.bgColor = '#666666'; |
133 } | 150 } |
134 } | 151 } |