PageSourceSearch

http://amisdethorigny.com/pub/skins/atowiki2/skin.js

js amisdethorigny.com collected 2026-10-02 11:32:05 UTC 2,732 bytes, 78 lines download raw bytes

1/***********************************************************************
2**  skin.js
3**  Copyright 2016-2017 Petko Yotov www.pmwiki.org/petko
4**  
5**  This file is part of PmWiki; you can redistribute it and/or modify
6**  it under the terms of the GNU General Public License as published
7**  by the Free Software Foundation; either version 2 of the License, or
8**  (at your option) any later version.  See pmwiki.php for full details.
9**  
10**  This script fixes the styles of some elements when some directives
11**  like (:noleft:) are used in a page.
12***********************************************************************/
13(function(){
14  var W = window, D = document;
15  function $(x) { // returns element from id
16    return D.getElementById(x);
17  }
18  function hide(id) { // hides element
19    var el = $(id);
20    if(el) el.style.display = 'none'; 
21  }
22  function cname(id, c) { // set element className
23    var el = $(id);
24    if(el) el.className = c;
25  }
26  var wsb = $('wikisidebar');
27  if(! wsb) { // (:noleft:)
28    hide('wikileft-toggle-label')
29    cname('wikifoot', 'nosidebar');
30  }
31  else { 
32    var sbcontent = wsb.textContent || wsb.innerText;
33    if(! sbcontent.replace(/\s+/, '').length) // empty sidebar, eg. protected
34      hide('wikileft-toggle-label');
35  }
36  var wcmd = $('wikicmds');
37  if(wcmd) { // page actions
38    var pacontent = wcmd.textContent || wcmd.innerText;
39    if(! pacontent.replace(/\s+/, '').length) // empty, eg. protected
40      hide('wikicmds-toggle-label');
41  }
42  if(! $('wikihead-searchform')) // no search form, eg. custom header
43    hide('wikihead-search-toggle-label');
44  var overlay = $('wikioverlay');
45  if(overlay) {
46    overlay.addEventListener('click', function(){
47      $('wikicmds-toggle').checked = false;
48      $('wikihead-search-toggle').checked = false;
49      $('wikileft-toggle').checked = false;
50    });
51  }
52  var scrolltables = function() {
53    // This function "wraps" large tables in a scrollable div
54    // and "unwraps" narrow tables from the scrollable div 
55    // allowing table alignement
56    var tables = D.getElementsByTagName('table');
57    for(var i=0; i<tables.length; i++) {
58      var t = tables[i];
59      var pn = t.parentNode;
60      if(pn.className == 'scrollable') {
61        var gp = pn.parentNode;
62        if(t.offsetWidth < gp.offsetWidth) {
63          gp.insertBefore(t, pn);
64          gp.removeChild(pn);
65        }
66      }
67      else  {
68        if(t.offsetWidth > pn.offsetWidth) {
69          var nn = D.createElement('div');
70          pn.insertBefore(nn, t).className = 'scrollable';
71          nn.appendChild(t);
72        }
73      }
74    }
75  }
76  W.addEventListener('resize', scrolltables, false);
77  D.addEventListener('DOMContentLoaded', scrolltables, false);
78})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.