diff client/digitallibrary/relato/relato.js @ 223:41de43a00bf8

new relato import
author luginbue
date Fri, 09 Jul 2004 01:55:31 +0200
parents f1631db2ff3d
children
line wrap: on
line diff
--- a/client/digitallibrary/relato/relato.js	Fri Jul 09 01:55:31 2004 +0200
+++ b/client/digitallibrary/relato/relato.js	Fri Jul 09 01:55:31 2004 +0200
@@ -1,10 +1,10 @@
-top.name = 'f'
+top.name = 'f';
 
 if ( !top.focused )
-  top.focused = '';
+  top.focused = new Object();
 
 
-function identity() {
+function identify() {
   return 'Relato v0.1';
 }
 
@@ -14,6 +14,19 @@
 }
 
 
+function frameSelectable(name) {
+  // created by xls
+  var frames = protectedFrames();
+  var selectable = true;
+  for (var i=0; i<frames.length; i++) {
+    if (frames[i] == name) {
+      selectable = false;
+    }
+  }
+  return selectable;
+}
+
+
 function noFrameSelected() {
   alert( "No frame activated at the moment - click on the desired frame to activate it!" );
 }
@@ -29,32 +42,6 @@
 }
 
 
-function hex_color(dec) {
-  var hex = "#";
-  for (i = 6; i > 0; i--) {
-    var pow = Math.pow(16, i);
-    if (pow < dec) {
-      val = parseInt(dec / pow);
-      dec -= val*pow;
-      if (val > 9) {
-        switch (val) {
-          case (10): hex += 'A'; break;
-          case (11): hex += 'B'; break;
-          case (12): hex += 'C'; break;
-          case (13): hex += 'D'; break;
-          case (14): hex += 'E'; break;
-          case (15): hex += 'F'; break;
-        }
-      } else {
-        hex += val;
-      }
-    } else {
-      hex += "0";
-    }
-  } 
-  return hex;
-}
-
 function init() {
   // do the initialisation just if it is top-level relato
   if ( top == window ) {
@@ -71,25 +58,59 @@
       if (!current.frames[i].name) {
         current.frames[i].name = name + i;
       }
-      current.frames[i].addEventListener( 'click', focusListener, true );
+      if (frameSelectable(current.frames[i].name)) {
+        current.frames[i].addEventListener( 'click', focusListener, true );
+        if (current.frames[i].name == nameOfSelectedFrame()) {
+          top.focused = current.frames[i];
+        }
+      } else {
+        if (current.frames[i] == selectedFrameObject()) {
+          top.focused = '';
+        }
+      } 
       current.frames[i].addEventListener( 'unload', unloadListener, true );
-      if (current.frames[i] == selectedFrameObject()) {
-//        var color = current.frames[i].document.bgColor;
-//        if (color.match(/#\d{6}/)) { 
-//          color = parseInt('0x' + color.slice(1)) - parseInt('0x222222');
-//          if (color < 0) {
-//            color = 0;
-//          }
-//          current.frames[i].document.bgColor = hex_color(color);
-//        }
-        current.frames[i].document.bgColor = '#444444';
-      }
       init_rec( current.frames[i], current.frames[i].name );
     }
   }    
 }
 
 
+function listFrames() {
+
+  var frames = new Array();
+
+  function listFrames_rec( current )  {
+
+    if (current.frames.length > 0) {
+      for (var i=0; i < current.frames.length; i++) {
+        listFrames_rec(current.frames[i]);
+      }
+    } else {
+      frames.push(current);
+    }
+  }
+
+  listFrames_rec(top);
+
+  return frames;
+
+}
+
+
+function getXML() {
+  query_string = location.search;
+  query_string.search(/xml=([^\&]*)\&/);
+  return RegExp.$1;
+} 
+
+
+function blink() {
+  orig_color = top.focused.document.bgColor;
+  top.focused.document.bgColor="black";
+  setTimeout('top.focused.document.bgColor="' + orig_color + '"', 100);
+}
+
+
 function focusListener( event ) {
 
   var active = this;
@@ -98,10 +119,13 @@
     active = this.parent;
   }
 
-  markActiveFrame_rec( top, active );
+  // can be used in future to mark several frames 
+  // markActiveFrame_rec( top, active );
 
   top.focused = active;
 
+  blink();
+
   // just debug information
   window.status = top.focused.name;
 }
@@ -111,6 +135,7 @@
   setTimeout('init()', 250);
 }
 
+
 function markActiveFrame_rec(current, active) {
   
   if ( current.frames.length > 0 ) {
@@ -119,14 +144,6 @@
     }
   } else {
     if ( current.name.indexOf(active.name) == 0 ) {
-//      var color = current.document.bgColor;
-//      if (color.match(/#\d{6}/)) {
-//        color = parseInt('0x' + color.slice(1)) - parseInt('0x222222');
-//        if (color < 0) {
-//          color = 0;
-//        }
-//        current.document.bgColor = hex_color(color);
-//      }
       current.document.bgColor = '#444444';
     } else {
       current.document.bgColor = '#666666';