Fossil

Check-in [c22b71df]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixes to the new script element of skins.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:c22b71dfc823860c4297d4219e341cd05d9bb645783b3d50fc6b252de970e57e
User & Date: drh 2018-09-11 00:52:59
Context
2018-09-11
00:56
The default skin requires 1200px or more before the "wideonly" class is displayed. check-in: 68f4c2b0 user: drh tags: trunk
00:52
Fixes to the new script element of skins. check-in: c22b71df user: drh tags: trunk
00:10
Add a hamburger menu that brings up an overlaid /sitemap to the default skin. check-in: 9c887998 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to skins/default/footer.txt.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<div class="footer">
This page was generated in about
<th1>puts [expr {([utime]+[stime]+1000)/1000*0.001}]</th1>s by
Fossil $release_version $manifest_version $manifest_date
</div>

<th1>
  html "<script nonce='$nonce'>"
  html "  (function() { var home='$home'; "
</th1>
    var panel = document.getElementById("hbdrop");
    if (!panel) return;   // site admin might've nuked it
    var panelBorder = panel.style.border;
    var animate = panel.style.hasOwnProperty('transition');
    var animMS = 400;

    // Calculate panel height despite its being hidden at call time.
    // Based on https://stackoverflow.com/a/29047447/142454
    var panelHeight;  // computed on sitemap load
    function calculatePanelHeight() {
      // Get initial panel styles so we can restore them below.
      var es   = window.getComputedStyle(panel),
          edis = es.display,
          epos = es.position,
          evis = es.visibility;

      // Restyle the panel so we can measure its height while invisible.
      panel.style.visibility = 'hidden';
      panel.style.position   = 'absolute';
      panel.style.display    = 'block';
      panelHeight = panel.offsetHeight + 'px';

      // Revert styles now that job is done.
      panel.style.display    = edis;
      panel.style.position   = epos;
      panel.style.visibility = evis;
    }

    // Show the panel by changing the panel height, which kicks off the
    // slide-open/closed transition set up in the XHR onload handler.
    //
    // Schedule the change for a near-future time in case this is the
    // first call, where the div was initially invisible.  That causes
    // the browser to consider the height change as part of the same
    // state change as the visibility change, so it doesn't see a state
    // *transition*, hence never kicks off the *CSS* transition:
    //
    // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions#JavaScript_examples
    function showPanel() {
      if (animate) {
        setTimeout(function() {
          panel.style.maxHeight = panelHeight;
          panel.style.border    = panelBorder;
        }, 40);   // 25ms is insufficient with Firefox 62
      }
      else {
        panel.style.display = 'block';
      }
    }

    // Return true if the panel is showing.
    function panelShowing() {
      if (animate) {
        return panel.style.maxHeight == panelHeight;
      }
      else {
        return panel.style.display == 'block';
      }
    }

    // Click handler for the hamburger button.
    var needSitemapHTML = true;
    document.querySelector("div.mainmenu > a").onclick = function() {
      if (panelShowing()) {
        // Transition back to hidden state.
        if (animate) {
          panel.style.maxHeight = '0';
          setTimeout(function() {
            // Browsers show a 1px high border line when maxHeight == 0,
            // our "hidden" state, so hide the borders in that state, too.
            panel.style.border = 'none';
          }, animMS);
        }
        else {
          panel.style.display = 'none';
        }
      }
      else if (needSitemapHTML) {
        // Only get it once per page load: it isn't likely to
        // change on us.
        var xhr = new XMLHttpRequest();
        xhr.onload = function() {
          var doc = xhr.responseXML;
          if (doc) {
            var sm = doc.querySelector("ul#sitemap");
            if (sm && xhr.status == 200) {
              // Got sitemap.  Insert it into the drop-down panel.
              needSitemapHTML = false;
              panel.innerHTML = sm.outerHTML;
              if (window.setAllHrefs) {
                setAllHrefs();   // don't need anti-robot defense here
              }

              // Display the panel
              if (animate) {
                // Set up a CSS transition to animate the panel open and
                // closed.  Only needs to be done once per page load.
                // Based on https://stackoverflow.com/a/29047447/142454
                calculatePanelHeight();
                panel.style.transition = 'max-height ' +
                    (animMS / 1000) + 's ease-in-out';
                panel.style.overflowY  = 'hidden';
                panel.style.maxHeight  = '0';
                showPanel();
              }
              panel.style.display = 'block';
            }
          }
          // else, can't parse response as HTML or XML
        }
        xhr.open("GET", home + "/sitemap");
        xhr.responseType = "document";
        xhr.send();
      }
      else {
        showPanel();   // just show what we built above
      }
      return false;  // prevent browser from acting on <a> click
    }
  })();
</script>





<
<
|
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

1
2
3
4
5


6

7
























































































































8
<div class="footer">
This page was generated in about
<th1>puts [expr {([utime]+[stime]+1000)/1000*0.001}]</th1>s by
Fossil $release_version $manifest_version $manifest_date
</div>


<script nonce="$nonce">

<th1>styleScript</th1>
























































































































</script>

Name change from skins/default/script.txt to skins/default/js.txt.

1
2
3
4
5
6
7
8
9
...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
(function() {
  var home='$home'; "
  var panel = document.getElementById("hbdrop");
  if (!panel) return;   // site admin might've nuked it
  var panelBorder = panel.style.border;
  var animate = panel.style.hasOwnProperty('transition');
  var animMS = 400;

  // Calculate panel height despite its being hidden at call time.
................................................................................
              showPanel();
            }
            panel.style.display = 'block';
          }
        }
        // else, can't parse response as HTML or XML
      }
      xhr.open("GET", home + "/sitemap");
      xhr.responseType = "document";
      xhr.send();
    }
    else {
      showPanel();   // just show what we built above
    }
    return false;  // prevent browser from acting on <a> click
  }
})();

|







 







|

|







1
2
3
4
5
6
7
8
9
...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
(function() {
  var home='$home';
  var panel = document.getElementById("hbdrop");
  if (!panel) return;   // site admin might've nuked it
  var panelBorder = panel.style.border;
  var animate = panel.style.hasOwnProperty('transition');
  var animMS = 400;

  // Calculate panel height despite its being hidden at call time.
................................................................................
              showPanel();
            }
            panel.style.display = 'block';
          }
        }
        // else, can't parse response as HTML or XML
      }
      xhr.open("POST", home + "/sitemap");
      xhr.responseType = "document";
      xhr.send("popup=1");
    }
    else {
      showPanel();   // just show what we built above
    }
    return false;  // prevent browser from acting on <a> click
  }
})();

Changes to src/main.mk.

176
177
178
179
180
181
182

183
184
185
186
187
188
189
  $(SRCDIR)/../skins/bootstrap/details.txt \
  $(SRCDIR)/../skins/bootstrap/footer.txt \
  $(SRCDIR)/../skins/bootstrap/header.txt \
  $(SRCDIR)/../skins/default/css.txt \
  $(SRCDIR)/../skins/default/details.txt \
  $(SRCDIR)/../skins/default/footer.txt \
  $(SRCDIR)/../skins/default/header.txt \

  $(SRCDIR)/../skins/eagle/css.txt \
  $(SRCDIR)/../skins/eagle/details.txt \
  $(SRCDIR)/../skins/eagle/footer.txt \
  $(SRCDIR)/../skins/eagle/header.txt \
  $(SRCDIR)/../skins/enhanced1/css.txt \
  $(SRCDIR)/../skins/enhanced1/details.txt \
  $(SRCDIR)/../skins/enhanced1/footer.txt \







>







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
  $(SRCDIR)/../skins/bootstrap/details.txt \
  $(SRCDIR)/../skins/bootstrap/footer.txt \
  $(SRCDIR)/../skins/bootstrap/header.txt \
  $(SRCDIR)/../skins/default/css.txt \
  $(SRCDIR)/../skins/default/details.txt \
  $(SRCDIR)/../skins/default/footer.txt \
  $(SRCDIR)/../skins/default/header.txt \
  $(SRCDIR)/../skins/default/js.txt \
  $(SRCDIR)/../skins/eagle/css.txt \
  $(SRCDIR)/../skins/eagle/details.txt \
  $(SRCDIR)/../skins/eagle/footer.txt \
  $(SRCDIR)/../skins/eagle/header.txt \
  $(SRCDIR)/../skins/enhanced1/css.txt \
  $(SRCDIR)/../skins/enhanced1/details.txt \
  $(SRCDIR)/../skins/enhanced1/footer.txt \

Changes to src/sitemap.c.

29
30
31
32
33
34
35

36
37
38
39
40
41
42
43
44
45
46







47

48
49

50
51
52
53
54
55
56
...
208
209
210
211
212
213
214

215
216

** That is, this page is designed to hold links that are omitted from
** the main menu due to lack of space.
*/
void sitemap_page(void){
  int srchFlags;
  int inSublist = 0;
  int i;

  const struct {
    const char *zTitle;
    const char *zProperty;
  } aExtra[] = {
    { "Documentation",  "sitemap-docidx" },
    { "Download",       "sitemap-download" },
    { "License",        "sitemap-license" },
    { "Contact",        "sitemap-contact" },
  };

  login_check_credentials();







  srchFlags = search_restrict(SRCH_ALL);

  style_header("Site Map");
  style_adunit_config(ADUNIT_RIGHT_OK);

  @ <ul id="sitemap" class="columns" style="column-width:20em">
  @ <li>%z(href("%R/home"))Home Page</a>
  for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){
    char *z = db_get(aExtra[i].zProperty,0);
    if( z==0 || z[0]==0 ) continue;
    if( !inSublist ){
      @ <ul>
................................................................................
    @   <li>%z(href("%R/test-rename-list"))List of file renames</a></li>
  }
  @   <li>%z(href("%R/hash-color-test"))Page to experiment with the automatic
  @       colors assigned to branch names</a>
  @   <li>%z(href("%R/test-captcha"))Random ASCII-art Captcha image</a></li>
  @   </ul></li>
  @ </ul>

  style_footer();
}








>











>
>
>
>
>
>
>

>
|
|
>







 







>
|
|
>
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
...
218
219
220
221
222
223
224
225
226
227
228
** That is, this page is designed to hold links that are omitted from
** the main menu due to lack of space.
*/
void sitemap_page(void){
  int srchFlags;
  int inSublist = 0;
  int i;
  int isPopup = 0;         /* This is an XMLHttpRequest() for /sitemap */
  const struct {
    const char *zTitle;
    const char *zProperty;
  } aExtra[] = {
    { "Documentation",  "sitemap-docidx" },
    { "Download",       "sitemap-download" },
    { "License",        "sitemap-license" },
    { "Contact",        "sitemap-contact" },
  };

  login_check_credentials();
  if( P("popup")!=0 && cgi_csrf_safe(1) ){
    /* If this is a POST from the same origin with the popup=1 parameter,
    ** then disable anti-robot defenses */
    isPopup = 1;
    g.perm.Hyperlink = 1;
    g.javascriptHyperlink = 0;
  }
  srchFlags = search_restrict(SRCH_ALL);
  if( !isPopup ){
    style_header("Site Map");
    style_adunit_config(ADUNIT_RIGHT_OK);
  }
  @ <ul id="sitemap" class="columns" style="column-width:20em">
  @ <li>%z(href("%R/home"))Home Page</a>
  for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){
    char *z = db_get(aExtra[i].zProperty,0);
    if( z==0 || z[0]==0 ) continue;
    if( !inSublist ){
      @ <ul>
................................................................................
    @   <li>%z(href("%R/test-rename-list"))List of file renames</a></li>
  }
  @   <li>%z(href("%R/hash-color-test"))Page to experiment with the automatic
  @       colors assigned to branch names</a>
  @   <li>%z(href("%R/test-captcha"))Random ASCII-art Captcha image</a></li>
  @   </ul></li>
  @ </ul>
  if( !isPopup ){
    style_footer();
  }
}

Changes to win/Makefile.mingw.

598
599
600
601
602
603
604

605
606
607
608
609
610
611
  $(SRCDIR)/../skins/bootstrap/details.txt \
  $(SRCDIR)/../skins/bootstrap/footer.txt \
  $(SRCDIR)/../skins/bootstrap/header.txt \
  $(SRCDIR)/../skins/default/css.txt \
  $(SRCDIR)/../skins/default/details.txt \
  $(SRCDIR)/../skins/default/footer.txt \
  $(SRCDIR)/../skins/default/header.txt \

  $(SRCDIR)/../skins/eagle/css.txt \
  $(SRCDIR)/../skins/eagle/details.txt \
  $(SRCDIR)/../skins/eagle/footer.txt \
  $(SRCDIR)/../skins/eagle/header.txt \
  $(SRCDIR)/../skins/enhanced1/css.txt \
  $(SRCDIR)/../skins/enhanced1/details.txt \
  $(SRCDIR)/../skins/enhanced1/footer.txt \







>







598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
  $(SRCDIR)/../skins/bootstrap/details.txt \
  $(SRCDIR)/../skins/bootstrap/footer.txt \
  $(SRCDIR)/../skins/bootstrap/header.txt \
  $(SRCDIR)/../skins/default/css.txt \
  $(SRCDIR)/../skins/default/details.txt \
  $(SRCDIR)/../skins/default/footer.txt \
  $(SRCDIR)/../skins/default/header.txt \
  $(SRCDIR)/../skins/default/js.txt \
  $(SRCDIR)/../skins/eagle/css.txt \
  $(SRCDIR)/../skins/eagle/details.txt \
  $(SRCDIR)/../skins/eagle/footer.txt \
  $(SRCDIR)/../skins/eagle/header.txt \
  $(SRCDIR)/../skins/enhanced1/css.txt \
  $(SRCDIR)/../skins/enhanced1/details.txt \
  $(SRCDIR)/../skins/enhanced1/footer.txt \

Changes to win/Makefile.msc.

539
540
541
542
543
544
545

546
547
548
549
550
551
552
        $(SRCDIR)\..\skins\bootstrap\details.txt \
        $(SRCDIR)\..\skins\bootstrap\footer.txt \
        $(SRCDIR)\..\skins\bootstrap\header.txt \
        $(SRCDIR)\..\skins\default\css.txt \
        $(SRCDIR)\..\skins\default\details.txt \
        $(SRCDIR)\..\skins\default\footer.txt \
        $(SRCDIR)\..\skins\default\header.txt \

        $(SRCDIR)\..\skins\eagle\css.txt \
        $(SRCDIR)\..\skins\eagle\details.txt \
        $(SRCDIR)\..\skins\eagle\footer.txt \
        $(SRCDIR)\..\skins\eagle\header.txt \
        $(SRCDIR)\..\skins\enhanced1\css.txt \
        $(SRCDIR)\..\skins\enhanced1\details.txt \
        $(SRCDIR)\..\skins\enhanced1\footer.txt \







>







539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
        $(SRCDIR)\..\skins\bootstrap\details.txt \
        $(SRCDIR)\..\skins\bootstrap\footer.txt \
        $(SRCDIR)\..\skins\bootstrap\header.txt \
        $(SRCDIR)\..\skins\default\css.txt \
        $(SRCDIR)\..\skins\default\details.txt \
        $(SRCDIR)\..\skins\default\footer.txt \
        $(SRCDIR)\..\skins\default\header.txt \
        $(SRCDIR)\..\skins\default\js.txt \
        $(SRCDIR)\..\skins\eagle\css.txt \
        $(SRCDIR)\..\skins\eagle\details.txt \
        $(SRCDIR)\..\skins\eagle\footer.txt \
        $(SRCDIR)\..\skins\eagle\header.txt \
        $(SRCDIR)\..\skins\enhanced1\css.txt \
        $(SRCDIR)\..\skins\enhanced1\details.txt \
        $(SRCDIR)\..\skins\enhanced1\footer.txt \