[LON-CAPA-cvs] cvs: loncom /html/res/adm/pages menu.html

www lon-capa-cvs@mail.lon-capa.org
Fri, 06 Sep 2002 17:05:27 -0000


www		Fri Sep  6 13:05:27 2002 EDT

  Modified files:              
    /loncom/html/res/adm/pages	menu.html 
  Log:
  Logic on is_editable was reversed.
  Substituted regular expressions and "replace" with pedestrian "split" and
  "join" to work with older browsers.
  
  
Index: loncom/html/res/adm/pages/menu.html
diff -u loncom/html/res/adm/pages/menu.html:1.68 loncom/html/res/adm/pages/menu.html:1.69
--- loncom/html/res/adm/pages/menu.html:1.68	Fri Sep  6 11:18:23 2002
+++ loncom/html/res/adm/pages/menu.html	Fri Sep  6 13:05:27 2002
@@ -4,7 +4,7 @@
 Remote Control
 
 //
-// $Id: menu.html,v 1.68 2002/09/06 15:18:23 www Exp $
+// $Id: menu.html,v 1.69 2002/09/06 17:05:27 www Exp $
 //
 // Copyright Michigan State University Board of Trustees
 //
@@ -235,12 +235,16 @@
 }
 
 function is_editable_resource (url) {
+// figure out if this a specific resource version
    var Chunks = url.split('.');
    var tmp = Chunks[Chunks.length-1];
    if ((Chunks.length > 1) && (Math.floor(tmp) == tmp)) {
-       return true;
-   } 
-   return false;
+       return false;
+   }
+// see if this is actually in resource space
+   var SlashChunks=url.split('/');
+   if (SlashChunks[1]!='res') { return false; } 
+   return true;
 }
 
 function cstrgo(currenturl,defaulturl) {
@@ -251,14 +255,14 @@
        (! is_editable_resource(currenturl))) {
       url = defaulturl;
    } else {
-      url = currenturl;
-      var res_pattern     = /^\/res\/[A-z0-p]+\//;
-      if (res_pattern.test(url)) {
-         // map /res/103/turtle to /priv/turtle
-         url = url.replace(/^\/res\/[A-z0-9]+\//,'/priv/');
-      } else {
-         url = defaulturl;
+      var SlashChunks=currenturl.split('/');
+      SlashChunks[1]='priv';
+      var i;
+      for (i=2;i<SlashChunks.length;i++) {
+          SlashChunks[i]=SlashChunks[i+1];
       }
+      SlashChunks.length--;
+      url=SlashChunks.join('/');
    }
    this.document['led'].src="ledsend.gif";
    if (url != '') {