OSDN Git Service

Execute embedded scripts on overlay-page load.
authorKeith Marshall <keith@users.osdn.me>
Sat, 11 Sep 2021 23:19:40 +0000 (00:19 +0100)
committerKeith Marshall <keith@users.osdn.me>
Sat, 11 Sep 2021 23:19:40 +0000 (00:19 +0100)
* site.js (no_break, update_page_content_header): Delete them.
(set_page): New page-load helper function; it supports page title and
subtitle updates, when called from embedded scripts on overlay-pages.
(load_page) [status == 200]: Scan for, and execute embedded scripts.

* index.html [masthead] (h1, h2): Change identifiers from...
(as-page-title, as-page-subtitle): ...these respectively, to...
(page-title, page-subtitle): ...these; add hidden placeholder content.

* about.html contact.html fdl.html mailing.html missing.html
* terms.html [masthead] (dl): Delete hidden element; replace it with
script, to assign effective HTML content to each of...
(page-title, page-subtitle): ...these.

* fdl.html mailing.html (ol, ul): Do not override CSS styles.

* site.css [masthead]: Do not assume that final element is...
(dl): ...this; define style for immediately following paragraph, on
the basis that the final masthead element may be anything.

about.html
contact.html
fdl.html
index.html
mailing.html
missing.html
site.css
site.js
terms.html

index 8937505..42566ac 100644 (file)
  *    &#8221;   right (closing) typographic double quote
  *
 -->
  *    &#8221;   right (closing) typographic double quote
  *
 -->
-<dl class="masthead"><!-- hidden for masthead class -->
-<!-- FIXME: is there a better way to do this?  We need to propagate
- content to the "as-page-title" and "as-page-subtitle" place-holders,
- within the "page-content" div of "index.html"; our javascript page
- loader will explicitly look for these hidden elements, and copy
- their content into the corresponding visible place-holders.
--->
- <dt id="page-title">Welcome to MinGW.OSDN</dt>
- <dt id="page-subtitle">Home of the MinGW and MSYS Projects</dt>
-</dl><!-- masthead -->
+<script class="masthead">
+/* Script fragment, to assign titles specific to this page; this is
+ * encapsulated within the "masthead", where such titles are displayed,
+ * to ensure that whatever page content may follow will be correctly
+ * positioned, relative to the masthead content.
+ */
+ set_page( "title", "Welcome to MinGW.OSDN" );
+ set_page( "subtitle", "Home of the MinGW and MSYS Projects" );
+</script><!-- masthead -->
 <p><strong>MinGW</strong>,
 a contraction of &#8220;Minimalist GNU for Windows&#8221;,
 is a minimalist development environment
 <p><strong>MinGW</strong>,
 a contraction of &#8220;Minimalist GNU for Windows&#8221;,
 is a minimalist development environment
index 3ea29c8..3fcc1d0 100644 (file)
  *    &#8221;   right (closing) typographic double quote
  *
 -->
  *    &#8221;   right (closing) typographic double quote
  *
 -->
-<dl class="masthead"><!-- hidden for masthead class -->
-<!-- FIXME: is there a better way to do this?  We need to propagate
- content to the "as-page-title" and "as-page-subtitle" place-holders,
- within the "page-content" div of "index.html"; our javascript page
- loader will explicitly look for these hidden elements, and copy
- their content into the corresponding visible place-holders.
--->
- <dt id="page-title">Contacting MinGW.OSDN</dt>
- <dt id="page-subtitle">When a Web-Search Fails to Resolve your Issue</dt>
-</dl><!-- masthead -->
+<script class="masthead"><!-- hidden for masthead class -->
+/* Script fragment, to assign titles specific to this page; this is
+ * encapsulated within the "masthead", where such titles are displayed,
+ * to ensure that whatever page content may follow will be correctly
+ * positioned, relative to the masthead content.
+ */
+ set_page("title", "Contacting MinGW.OSDN");
+ set_page("subtitle", "When a Web-Search Fails to Resolve your Issue");
+</script><!-- masthead -->
 <p>If you have exhausted all of the web&#8209;site resources,
 and you have searched all of the
 <a href="index.html?page=mailing.html"
 <p>If you have exhausted all of the web&#8209;site resources,
 and you have searched all of the
 <a href="index.html?page=mailing.html"
index 912e54e..2381676 100644 (file)
--- a/fdl.html
+++ b/fdl.html
  *    &#8221;   right (closing) typographic double quote
  *
 -->
  *    &#8221;   right (closing) typographic double quote
  *
 -->
-<dl class="masthead"><!-- hidden for masthead class -->
-<!-- FIXME: is there a better way to do this?  We need to propagate
- content to the "as-page-title" and "as-page-subtitle" place-holders,
- within the "page-content" div of "index.html"; our javascript page
- loader will explicitly look for these hidden elements, and copy
- their content into the corresponding visible place-holders.
--->
- <dt id="page-title">MinGW.OSDN Licensing</dt>
- <dt id="page-subtitle">The MinGW Free Documentation Licence</dt>
-</dl><!-- masthead -->
+<script class="masthead">
+/* Script fragment, to assign titles specific to this page; this is
+ * encapsulated within the "masthead", where such titles are displayed,
+ * to ensure that whatever page content may follow will be correctly
+ * positioned, relative to the masthead content.
+ */
+ set_page("title", "MinGW.OSDN Licensing");
+ set_page("subtitle", "The MinGW Free Documentation Licence");
+</script><!-- masthead -->
 <p>Copyright &copy; 2020, MinGW.OSDN Project
 </p>
 <p>Redistribution and use in source and &#8216;compiled&#8217; forms
 (SGML, HTML, PDF, PostScript, RTF, etc.) with or without modification,
 are permitted provided that the following conditions are met:&mdash;
 </p>
 <p>Copyright &copy; 2020, MinGW.OSDN Project
 </p>
 <p>Redistribution and use in source and &#8216;compiled&#8217; forms
 (SGML, HTML, PDF, PostScript, RTF, etc.) with or without modification,
 are permitted provided that the following conditions are met:&mdash;
 </p>
-<ol style="margin: 0.2em 0 0 0;">
+<ol>
   <li style="padding-bottom: 0.2em;">
       Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer as
   <li style="padding-bottom: 0.2em;">
       Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer as
index c013fb9..45eb993 100644 (file)
@@ -8,7 +8,7 @@
 -->
 <html lang="en">
  <head>
 -->
 <html lang="en">
  <head>
-  <meta charset="utf-8" />
+  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
   <title>Welcome to MinGW.OSDN</title>
   <!--
    * $Id$
   <title>Welcome to MinGW.OSDN</title>
   <!--
    * $Id$
   <div id="header"></div>
   <div class="page-view">
    <div class="masthead">
   <div id="header"></div>
   <div class="page-view">
    <div class="masthead">
-    <h1 id="as-page-title"></h1>
-    <h2 id="as-page-subtitle"></h2>
+    <!-- The HTML specification disallows empty headings -->
+    <!-- so, insert invisible place-holders, which we may -->
+    <!-- override later, by overlay page scripting -->
+    <h1 id="page-title"><span style="display:none">:</span></h1>
+    <h2 id="page-subtitle"><span style="display:none">:</span></h2>
    </div><!-- masthead --><hr />
    <div id="page-content"></div>
   </div><!-- page-view -->
    </div><!-- masthead --><hr />
    <div id="page-content"></div>
   </div><!-- page-view -->
index efbad45..0b4d68e 100644 (file)
  *    &#8221;   right (closing) typographic double quote
  *
 -->
  *    &#8221;   right (closing) typographic double quote
  *
 -->
-<dl class="masthead"><!-- hidden for masthead class -->
-<!-- FIXME: is there a better way to do this?  We need to propagate
- content to the "as-page-title" and "as-page-subtitle" place-holders,
- within the "page-content" div of "index.html"; our javascript page
- loader will explicitly look for these hidden elements, and copy
- their content into the corresponding visible place-holders.
--->
- <dt id="page-title">MinGW.OSDN Mailing-Lists</dt>
- <dt id="page-subtitle">Mailing-Lists and Mail Archives Operated by MinGW.OSDN</dt>
-</dl><!-- masthead -->
+<script class="masthead">
+/* Script fragment, to assign titles specific to this page; this is
+ * encapsulated within the "masthead", where such titles are displayed,
+ * to ensure that whatever page content may follow will be correctly
+ * positioned, relative to the masthead content.
+ */
+ set_page("title", "MinGW.OSDN Mailing-Lists");
+ set_page("subtitle", "Mailing-Lists and Mail Archives Operated by MinGW.OSDN");
+</script><!-- masthead -->
 <p>MinGW.OSDN&#8217;s preferred method for communication,
 between users and the project team, is by way of mailing&#8209;lists.
 Historically, there were several topic&#8209;specific lists, originally
 <p>MinGW.OSDN&#8217;s preferred method for communication,
 between users and the project team, is by way of mailing&#8209;lists.
 Historically, there were several topic&#8209;specific lists, originally
@@ -261,7 +260,7 @@ in your posts being ignored by a number of knowledgeable people,
 and repeated offenses may even lead to your posts being vetted,
 and potentially rejected, by the list moderator.
 </p>
 and repeated offenses may even lead to your posts being vetted,
 and potentially rejected, by the list moderator.
 </p>
-<ul style="padding-right: 1em">
+<ul>
 <li>The language of the lists is <em><strong>English</strong></em>&hairsp;;
 if you post in any other language, you are unlikely to elicit a response.
 </li>
 <li>The language of the lists is <em><strong>English</strong></em>&hairsp;;
 if you post in any other language, you are unlikely to elicit a response.
 </li>
index 523de03..16ba5b6 100644 (file)
  *    &#8221;   right (closing) typographic double quote
  *
 -->
  *    &#8221;   right (closing) typographic double quote
  *
 -->
-<dl class="masthead"><!-- hidden for masthead class -->
-<!-- FIXME: is there a better way to do this?  We need to propagate
- content to the "as-page-title" and "as-page-subtitle" place-holders,
- within the "page-content" div of "index.html"; our javascript page
- loader will explicitly look for these hidden elements, and copy
- their content into the corresponding visible place-holders.
--->
- <dt id="page-title">MinGW.OSDN Server Error</dt>
- <dt id="page-subtitle">HTTP Status 404 &mdash; Requested Page Not Found</dt>
-</dl><!-- masthead -->
+<script class="masthead">
+/* Script fragment, to assign titles specific to this page; this is
+ * encapsulated within the "masthead", where such titles are displayed,
+ * to ensure that whatever page content may follow will be correctly
+ * positioned, relative to the masthead content.
+ */
+ set_page("title", "MinGW.OSDN Server Error");
+ set_page("subtitle", "HTTP Status 404 &mdash; Requested Page Not Found");
+</script><!-- masthead -->
 <p>The requested URL,
 &#8220;<span id="e404-missing-page"></span>&#8221;,
 cannot be resolved.
 <p>The requested URL,
 &#8220;<span id="e404-missing-page"></span>&#8221;,
 cannot be resolved.
index 713a0d4..9b95aed 100644 (file)
--- a/site.css
+++ b/site.css
@@ -244,7 +244,7 @@ dl.masthead
    */
   display: none;
 }
    */
   display: none;
 }
-dl.masthead+p
+.masthead+p
 { /* The masthead section is separated from the remaining page
    * content, by a horizontal rule; to keep white space balanced,
    * above and below this rule, when it is immediately followed
 { /* The masthead section is separated from the remaining page
    * content, by a horizontal rule; to keep white space balanced,
    * above and below this rule, when it is immediately followed
diff --git a/site.js b/site.js
index 4a5f9ad..17599e4 100644 (file)
--- a/site.js
+++ b/site.js
@@ -37,25 +37,18 @@ function set_content( item, value )
    */
   var element = document.getElementById( item );
   if( element ) element.innerHTML = value;
    */
   var element = document.getElementById( item );
   if( element ) element.innerHTML = value;
+  return element;
 }
 
 }
 
-function no_break( text )
-{ /* Helper function to replace all occurrences of ASCII hyphen-minus,
-   * within "text", by substitution of HTML non-breaking hyphen.
+function set_page( title, text )
+{ /* Helper function, for use in overlay page scripts, to update
+   * the "title" and "subtitle" fields within the page header; note
+   * that "text" may, and should, use ASCII hyphen-minus where any
+   * hyphen is to be represented; these will be replaced by HTML
+   * non-breaking hyphen entities, on header field assignment.
    */
    */
-  return text.replace( /-/g, "&#8209;" );
-}
-
-function update_page_content_header( tag )
-{ /* Update the "page-title" and "page-subtitle" content-header text,
-   * by substitution into the "as-page-title" and "as-page-subtitle"
-   * place-holder elements, respectively.
-   */
-  var element = document.getElementById( "page-".concat( tag ));
-  if( element )
-  { if( tag == "title" ) document.title = element.innerHTML;
-    set_content( "as-page-".concat( tag ), no_break( element.innerHTML ));
-  }
+  if( title == "title" ) document.title = text;
+  set_content( "page-".concat( title ), text.replace( /-/g, "&#8209;" ));
 }
 
 function load_content( container, src )
 }
 
 function load_content( container, src )
@@ -69,10 +62,13 @@ function load_content( container, src )
   { if( this.readyState == this.DONE )
       switch( this.status )
       { case 200:
   { if( this.readyState == this.DONE )
       switch( this.status )
       { case 200:
-         set_content( container, this.responseText );
-         update_page_content_header( "title" );
-         update_page_content_header( "subtitle" );
+         var element = set_content( container, this.responseText );
+         var idx; element = element.getElementsByTagName( "script" );
          set_content( "e404-missing-page", document.URL );
          set_content( "e404-missing-page", document.URL );
+         for( idx = 0; idx < element.length; idx++ )
+         { var onload_action = Function( element[idx].innerHTML );
+           onload_action();
+         }
          if( src.includes("#") )
          { src = src.substring( src.indexOf("#") + 1, src.length );
            element = document.getElementById( src );
          if( src.includes("#") )
          { src = src.substring( src.indexOf("#") + 1, src.length );
            element = document.getElementById( src );
index 481933d..7863dc9 100644 (file)
  *    &#8221;   right (closing) typographic double quote
  *
 -->
  *    &#8221;   right (closing) typographic double quote
  *
 -->
-<dl class="masthead"><!-- hidden for masthead class -->
-<!-- FIXME: is there a better way to do this?  We need to propagate
- content to the "as-page-title" and "as-page-subtitle" place-holders,
- within the "page-content" div of "index.html"; our javascript page
- loader will explicitly look for these hidden elements, and copy
- their content into the corresponding visible place-holders.
--->
- <dt id="page-title">MinGW.OSDN Licensing</dt>
- <dt id="page-subtitle">Terms of Use for MinGW.OSDN Products and Resources</dt>
-</dl><!-- masthead -->
+<script class="masthead">
+/* Script fragment, to assign titles specific to this page; this is
+ * encapsulated within the "masthead", where such titles are displayed,
+ * to ensure that whatever page content may follow will be correctly
+ * positioned, relative to the masthead content.
+ */
+ set_page("title", "MinGW.OSDN Licensing");
+ set_page("subtitle", "Terms of Use for MinGW.OSDN Products and Resources");
+</script><!-- masthead -->
 <div class="h3-numbered">
 <p>Each of the various packages,
 which are distributed by MinGW.OSDN,
 <div class="h3-numbered">
 <p>Each of the various packages,
 which are distributed by MinGW.OSDN,