r851 - in trunk: . scripts templates

jeroen at linuxfromscratch.org jeroen at linuxfromscratch.org
Sun Sep 26 06:46:39 PDT 2004


Author: jeroen
Date: 2004-09-26 07:46:37 -0600 (Sun, 26 Sep 2004)
New Revision: 851

Modified:
   trunk/mail.html
   trunk/scripts/styleswitcher.js
   trunk/templates/template.html
Log:
Revert accidental local changes

Modified: trunk/mail.html
===================================================================
--- trunk/mail.html	2004-09-26 13:42:29 UTC (rev 850)
+++ trunk/mail.html	2004-09-26 13:46:37 UTC (rev 851)
@@ -6,9 +6,9 @@
 	<meta name="description" content="Linux From Scratch - build your own Linux distribution from scratch" />
 	<meta name="keywords" content="Linux, LinuxFromScratch, Linux From Scratch, build your own Linux, DIY Linux, do-it-yourself Linux, create your own Linux" />
 	<meta name="MSSmartTagsPreventParsing" content="true" />
-	<link rel="alternate stylesheet" type="text/css" href="style/3columns.css" media="screen" title="Three columns [Navigation | Content | Navigation]" />
-	<link rel="stylesheet" type="text/css" href="style/2columns.css" media="screen" title="Two columns [Content (2 columns) | Navigation]" />
-	<link rel="alternate stylesheet" type="text/css" href="style/2columns-menu.css" media="screen" title="Two columns, menu [Content (2 columns) | Navigation, general navigation as menu]" />
+	<link rel="alternate stylesheet" type="text/css" href="style/3columns.css" media="screen" title="ThreeColumn" />
+	<link rel="stylesheet" type="text/css" href="style/2columns.css" media="screen" title="TwoColumn" />
+	<link rel="alternate stylesheet" type="text/css" href="style/2columns-menu.css" media="screen" title="TwoColumnMenu" />
 	<link rel="stylesheet" type="text/css" href="style/print.css" media="print" />
 	<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
 	<script type="text/javascript" src="scripts/styleswitcher.js"></script>
@@ -36,6 +36,12 @@
 			</p>
 		</form>
 	</div>
+	<ul id="styleselect">
+		<li>Select layout:</li>
+		<li><a href="#" onclick="setActiveStyleSheet('TwoColumn'); return false;" title="Content (2 columns) | Navigation">Two columns</a></li>
+		<li><a href="#" onclick="setActiveStyleSheet('TwoColumnMenu'); return false;" title="Content (2 columns) | Navigation, general navigation as menu">Two columns, Menu</a></li>
+		<li><a href="#" onclick="setActiveStyleSheet('ThreeColumn'); return false;" title="Navigation|Content|Navigation">Three columns</a></li>
+	</ul>
 </div>
 
 <div id="container">

Modified: trunk/scripts/styleswitcher.js
===================================================================
--- trunk/scripts/styleswitcher.js	2004-09-26 13:42:29 UTC (rev 850)
+++ trunk/scripts/styleswitcher.js	2004-09-26 13:46:37 UTC (rev 851)
@@ -1,101 +1,17 @@
-function updateStyleSwitcherMarkup() {
-  var styleswitcher = document.createElement("ul");
-  styleswitcher.setAttribute("id", "styleselect");
-
-  var node = document.createElement("li");
-  node.appendChild(document.createTextNode("Select layout:"));
-  styleswitcher.appendChild(node);
-
-  var count = 0;
-  var links = document.getElementsByTagName("link");
-  for (var i = 0; i < links.length; i++) {
-    var link = links[i];
-    var rel = link.getAttribute("rel");
-    var media = link.getAttribute("media");
-    var href = link.getAttribute("href");
-    var title = link.getAttribute("title");
-    if (rel && rel.indexOf("style") != -1
-        && media && media.indexOf("screen") != -1
-        && href
-        && link.disabled
-        && title) {
-      node = document.createElement("a");
-      node.setAttribute("href", "#");
-      var style = fileNameToStyleName(href);
-      node.setAttribute("onclick", "setActiveStyleSheet('" + style + "'); return false;");
-      var linkTitle = createLinkTitleFromStyleTitle(title);
-      if (linkTitle) node.setAttribute("title", linkTitle);
-      var text = createLinkTextFromStyleTitle(title);
-      if (!text) text = style;
-      node.appendChild(document.createTextNode(text));
-      styleswitcher.appendChild(node);
-      count++;
-    }
-  }
-
-  /* Only insert the styleswitcher if there is at least one alternate stylesheet
-   * to choose from. */
-  if (count) {
-    var old = document.getElementById("styleselect");
-    if (old) {
-      old.parentNode.replaceChild(styleswitcher, old);
-    } else {
-      document.getElementById("header").appendChild(styleswitcher);
-    }
-  }
-}
-
-/* Returns a text that can be used as the hyperlink text in the styleswitcher,
- * created from the stylesheet description ('title' attribute of the
- * corresponding 'link' element).
- * If no suitable link text can be created, this function returns null.
- */
-function createLinkTextFromStyleTitle(styleTitle) {
-  if (!styleTitle) return null;
-  var end = styleTitle.indexOf(" [");
-  if (end == -1) end = styleTitle.length;
-  var text = styleTitle.substring(0, end).replace(/^\s*(.*\S)?\s*$/, "$1");
-  if (!text.length) return null;
-  return text;
-}
-
-/* Returns a text that can be used as tooltip for the hyperlink in the
- * styleswitcher, created from the stylesheet description ('title' attribute of
- * the corresponding 'link' element).
- * If no suitable link text can be created, this function returns null.
- */
-function createLinkTitleFromStyleTitle(styleTitle) {
-  if (!styleTitle) return null;
-  var start = styleTitle.indexOf("[") + 1;
-  if (!start) return null;
-  var end = styleTitle.lastIndexOf("]");
-  if (end == -1) end = styleTitle.length;
-  var text = styleTitle.substring(start, end).replace(/^\s*(.*\S)?\s*$/, "$1");
-  if (!text.length) return null;
-  return text;
-}
-
-
 function setActiveStyleSheet(title) {
-  if (!title) return;
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
-    var href = a.getAttribute("href");
-    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")
-       && href) {
-      a.disabled = (href.indexOf(title + ".css") == -1);
-        /* Do not remove the addition of ".css": think of "2columns" and
-         * "2columns-menu". Got it? ;-) */
+    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
+      a.disabled = true;
+      if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
-  updateStyleSwitcherMarkup();
 }
 
 function getActiveStyleSheet() {
   var i, a;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
-    var media = a.getAttribute("media");
-    if(a.getAttribute("rel").indexOf("style") != -1 && media && media.indexOf("screen") != -1 && a.getAttribute("title") && !a.disabled && a.getAttribute("href")) return fileNameToStyleName(a.getAttribute("href"));
+    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
   }
   return null;
 }
@@ -103,55 +19,14 @@
 function getPreferredStyleSheet() {
   var i, a;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
-    var media = a.getAttribute("media");
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("rel").indexOf("alt") == -1
-       && media && media.indexOf("screen") != -1
        && a.getAttribute("title")
-       && a.getAttribute("href")
-       ) return fileNameToStyleName(a.getAttribute("href"));
+       ) return a.getAttribute("title");
   }
   return null;
 }
 
-/* Extracts the stylesheet name from a filename (part of a URL).
- * This makes the names look nicer, but keep in mind that we therefore can't use
- * stylesheets with the same name in different directories.
- */
-function fileNameToStyleName(filename) {
-  if (!filename) return null;
-
-  var start = filename.lastIndexOf("/") + 1;
-  var end = filename.length;
-  if (filename.substring(end - 4, end) == ".css") end -= 4;
-    /* This is a fallback to avoid crashing on unusual file names.
-     * But function 'setActiveStylesheet' can't handle stylesheets which end in
-     * something else but ".css", so always name them "stylename.css"! */
-
-  return filename.substring(start, end);
-}
-
-/* Translates old stylesheet names (used before 2004-09-20) to the new ones (as
- * of 2004-09-20), so that existing cookies will continue to work. This function
- * should be removed once we switch the website to the Wiki if we are going to
- * break existing cookies anyway.
- */
-function translateStyleName(oldName) {
-  if (!oldName) return oldName;
-
-  switch (oldName) {
-    case "ThreeColumn":
-      return "3columns";
-    case "TwoColumn":
-      return "2columns";
-    case "TwoColumnMenu":
-      return "2columns-menu";
-  }
-
-  return oldName;
-}
-
-
 function createCookie(name,value,days) {
   if (days) {
     var date = new Date();
@@ -173,10 +48,9 @@
   return null;
 }
 
-
 window.onload = function(e) {
   var cookie = readCookie("style");
-  var title = cookie ? translateStyleName(cookie) : getPreferredStyleSheet();
+  var title = cookie ? cookie : getPreferredStyleSheet();
   setActiveStyleSheet(title);
 }
 
@@ -184,3 +58,7 @@
   var title = getActiveStyleSheet();
   createCookie("style", title, 365);
 }
+
+var cookie = readCookie("style");
+var title = cookie ? cookie : getPreferredStyleSheet();
+setActiveStyleSheet(title);
\ No newline at end of file

Modified: trunk/templates/template.html
===================================================================
--- trunk/templates/template.html	2004-09-26 13:42:29 UTC (rev 850)
+++ trunk/templates/template.html	2004-09-26 13:46:37 UTC (rev 851)
@@ -6,9 +6,9 @@
 	<meta name="description" content="Linux From Scratch - build your own Linux distribution from scratch" />
 	<meta name="keywords" content="Linux, LinuxFromScratch, Linux From Scratch, build your own Linux, DIY Linux, do-it-yourself Linux, create your own Linux" />
 	<meta name="MSSmartTagsPreventParsing" content="true" />
-	<link rel="alternate stylesheet" type="text/css" href="style/3columns.css" media="screen" title="Three columns [Navigation | Content | Navigation]" />
-	<link rel="stylesheet" type="text/css" href="style/2columns.css" media="screen" title="Two columns [Content (2 columns) | Navigation]" />
-	<link rel="alternate stylesheet" type="text/css" href="style/2columns-menu.css" media="screen" title="Two columns, menu [Content (2 columns) | Navigation, general navigation as menu]" />
+	<link rel="alternate stylesheet" type="text/css" href="style/3columns.css" media="screen" title="ThreeColumn" />
+	<link rel="stylesheet" type="text/css" href="style/2columns.css" media="screen" title="TwoColumn" />
+	<link rel="alternate stylesheet" type="text/css" href="style/2columns-menu.css" media="screen" title="TwoColumnMenu" />
 	<link rel="stylesheet" type="text/css" href="style/print.css" media="print" />
 	<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
 	<script type="text/javascript" src="scripts/styleswitcher.js"></script>
@@ -36,6 +36,12 @@
 			</p>
 		</form>
 	</div>
+	<ul id="styleselect">
+		<li>Select layout:</li>
+		<li><a href="#" onclick="setActiveStyleSheet('TwoColumn'); return false;" title="Content (2 columns) | Navigation">Two columns</a></li>
+		<li><a href="#" onclick="setActiveStyleSheet('TwoColumnMenu'); return false;" title="Content (2 columns) | Navigation, general navigation as menu">Two columns, Menu</a></li>
+		<li><a href="#" onclick="setActiveStyleSheet('ThreeColumn'); return false;" title="Navigation|Content|Navigation">Three columns</a></li>
+	</ul>
 </div>
 
 <div id="container">




More information about the website mailing list