223
|
1 top.name = 'f';
|
212
|
2
|
|
3 if ( !top.focused )
|
223
|
4 top.focused = new Object();
|
212
|
5
|
|
6
|
223
|
7 function identify() {
|
212
|
8 return 'Relato v0.1';
|
|
9 }
|
|
10
|
|
11
|
|
12 function frameSelected() {
|
|
13 return top.focused != '';
|
|
14 }
|
|
15
|
|
16
|
223
|
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;
|
|
27 }
|
|
28
|
|
29
|
212
|
30 function noFrameSelected() {
|
|
31 alert( "No frame activated at the moment - click on the desired frame to activate it!" );
|
|
32 }
|
|
33
|
|
34
|
|
35 function nameOfSelectedFrame() {
|
|
36 return top.focused.name;
|
|
37 }
|
|
38
|
|
39
|
|
40 function selectedFrameObject() {
|
|
41 return top.focused;
|
|
42 }
|
|
43
|
|
44
|
|
45 function init() {
|
|
46 // do the initialisation just if it is top-level relato
|
|
47 if ( top == window ) {
|
|
48 init_rec( top, top.name );
|
|
49 }
|
|
50 return true;
|
|
51 }
|
|
52
|
|
53
|
|
54 function init_rec( current, name ) {
|
|
55
|
|
56 if (current.frames.length > 0) {
|
|
57 for ( i=0; i < current.frames.length; i++ ) {
|
|
58 if (!current.frames[i].name) {
|
|
59 current.frames[i].name = name + i;
|
|
60 }
|
223
|
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 }
|
212
|
71 current.frames[i].addEventListener( 'unload', unloadListener, true );
|
|
72 init_rec( current.frames[i], current.frames[i].name );
|
|
73 }
|
|
74 }
|
|
75 }
|
|
76
|
|
77
|
223
|
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);
|
|
111 }
|
|
112
|
|
113
|
212
|
114 function focusListener( event ) {
|
|
115
|
|
116 var active = this;
|
|
117
|
|
118 if ( event.ctrlKey ) {
|
|
119 active = this.parent;
|
|
120 }
|
|
121
|
223
|
122 // can be used in future to mark several frames
|
|
123 // markActiveFrame_rec( top, active );
|
212
|
124
|
|
125 top.focused = active;
|
|
126
|
223
|
127 blink();
|
|
128
|
212
|
129 // just debug information
|
|
130 window.status = top.focused.name;
|
|
131 }
|
|
132
|
|
133
|
|
134 function unloadListener( event ) {
|
|
135 setTimeout('init()', 250);
|
|
136 }
|
|
137
|
223
|
138
|
212
|
139 function markActiveFrame_rec(current, active) {
|
|
140
|
|
141 if ( current.frames.length > 0 ) {
|
|
142 for ( i=0; i < current.frames.length; i++ ) {
|
|
143 markActiveFrame_rec( current.frames[i], active );
|
|
144 }
|
|
145 } else {
|
|
146 if ( current.name.indexOf(active.name) == 0 ) {
|
|
147 current.document.bgColor = '#444444';
|
|
148 } else {
|
|
149 current.document.bgColor = '#666666';
|
|
150 }
|
|
151 }
|
|
152 }
|
|
153
|
|
154
|
|
155 function loadFocusedFrame(url) {
|
|
156
|
|
157 if (frameSelected()) {
|
|
158 top.focused.location.href = url;
|
|
159 setTimeout( 'top.init()', 1000 );
|
|
160 } else {
|
|
161 noFrameSelected();
|
|
162 }
|
|
163 }
|
|
164
|
|
165
|
|
166 function loadNamedFrame(url, framename) {
|
|
167
|
|
168 desired = loadNamedFrame_rec(top, framename);
|
|
169 if ( desired ) {
|
|
170 desired.location.href = url;
|
|
171 setTimeout( 'top.init()', 1000 );
|
|
172 } else {
|
|
173 alert( "Error - a frame with this name does not exist!" );
|
|
174 }
|
|
175 }
|
|
176
|
|
177 function loadNamedFrame_rec(current, framename) {
|
|
178
|
|
179 if ( current.frames.length > 0 ) {
|
|
180 for ( i=0; i < current.frames.length; i++ ) {
|
|
181 thisone = loadNamedFrame_rec(current.frames[i], framename);
|
|
182 if (thisone) {
|
|
183 return thisone;
|
|
184 }
|
|
185 }
|
|
186 } else {
|
|
187 if (current.name == framename) {
|
|
188 return current;
|
|
189 } else {
|
|
190 return null;
|
|
191 }
|
|
192 }
|
|
193 }
|