diff --git a/.gitignore b/.gitignore index b418425..c0baa1f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ public/ -node_modules/ \ No newline at end of file +node_modules/ +.gitconfig \ No newline at end of file diff --git a/javascript/src/zulma_switchcss.js b/javascript/src/zulma_switchcss.js index ad0c1d6..462c1a9 100644 --- a/javascript/src/zulma_switchcss.js +++ b/javascript/src/zulma_switchcss.js @@ -1,4 +1,4 @@ -(function(switch_css) { +(function (switch_css) { //Constants const THEME_KEY = "ZULMA_THEME"; const THEME = localStorage.getItem(THEME_KEY); @@ -7,6 +7,7 @@ //Variables let previousLink = null; + let baseUrl = ""; //Events /* The function called when the css has finished loading */ @@ -56,7 +57,7 @@ var fileref = document.createElement("link"); fileref.rel = "stylesheet"; fileref.type = "text/css"; - fileref.href = `/${themeName}.css`; + fileref.href = `${baseUrl}/${themeName}.css`; fileref.id = themeName; //append it to the head @@ -141,7 +142,8 @@ } //Public Methods - switch_css.init = function() { + switch_css.init = function (url) { + baseUrl = url //if user has selected and theme and it is not the current theme if (THEME && !document.getElementById(THEME)) { //hide the body to stop FOUC @@ -153,11 +155,9 @@ } //when the DOM is loaded, set the dropdown to trigger the theme change window.addEventListener("DOMContentLoaded", () => { - document.getElementById("theme-select").onchange = function() { + document.getElementById("theme-select").onchange = function () { changeTheme(this.value); }; }); }; -})((switch_css = window.switch_css || {})); // eslint-disable-line - -switch_css.init(); // eslint-disable-line +})((switch_css = window.switch_css || {})); // eslint-disable-line \ No newline at end of file diff --git a/static/js/zulma_navbar.js.map b/static/js/zulma_navbar.js.map index 45c4689..6d6fe0f 100644 --- a/static/js/zulma_navbar.js.map +++ b/static/js/zulma_navbar.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/zulma_navbar.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","burger","menu","document","querySelector","dataset","target","addEventListener","classList","toggle"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EAAPE,GAA4B,iBAATF,EAAmB,IAAI,IAAIM,KAAON,EAAOrB,EAAoBU,EAAEe,EAAIE,EAAK,SAASA,GAAO,OAAON,EAAMM,IAAQC,KAAK,KAAMD,IAC9I,OAAOF,GAIRzB,EAAoB6B,EAAI,SAAS1B,GAChC,IAAIS,EAAST,GAAUA,EAAOqB,WAC7B,WAAwB,OAAOrB,EAAgB,SAC/C,WAA8B,OAAOA,GAEtC,OADAH,EAAoBU,EAAEE,EAAQ,IAAKA,GAC5BA,GAIRZ,EAAoBa,EAAI,SAASiB,EAAQC,GAAY,OAAOjB,OAAOkB,UAAUC,eAAe1B,KAAKuB,EAAQC,IAGzG/B,EAAoBkC,EAAI,GAIjBlC,EAAoBA,EAAoBmC,EAAI,G,gBClFrD,IACQC,EACAC,EADAD,EAASE,SAASC,cAAc,WAChCF,EAAOC,SAASC,cAAc,IAAMH,EAAOI,QAAQC,QACvDL,EAAOM,iBAAiB,SAAS,WAC7BN,EAAOO,UAAUC,OAAO,aACxBP,EAAKM,UAAUC,OAAO","file":"zulma_navbar.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","(function () {\n var burger = document.querySelector('.burger');\n var menu = document.querySelector('#' + burger.dataset.target);\n burger.addEventListener('click', function () {\n burger.classList.toggle('is-active');\n menu.classList.toggle('is-active');\n });\n})();"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/zulma_navbar.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","burger","menu","document","querySelector","dataset","target","addEventListener","classList","toggle"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,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,EAAoBa,EAAI,SAASiB,EAAQC,GAAY,OAAOjB,OAAOkB,UAAUC,eAAe1B,KAAKuB,EAAQC,IAGzG/B,EAAoBkC,EAAI,GAIjBlC,EAAoBA,EAAoBmC,EAAI,G,gBClFrD,IACQC,EACAC,EADAD,EAASE,SAASC,cAAc,WAChCF,EAAOC,SAASC,cAAc,IAAMH,EAAOI,QAAQC,QACvDL,EAAOM,iBAAiB,SAAS,WAC7BN,EAAOO,UAAUC,OAAO,aACxBP,EAAKM,UAAUC,OAAO","file":"zulma_navbar.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","(function () {\r\n var burger = document.querySelector('.burger');\r\n var menu = document.querySelector('#' + burger.dataset.target);\r\n burger.addEventListener('click', function () {\r\n burger.classList.toggle('is-active');\r\n menu.classList.toggle('is-active');\r\n });\r\n})();"],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/zulma_search.js.map b/static/js/zulma_search.js.map index e25f42f..6c755fb 100644 --- a/static/js/zulma_search.js.map +++ b/static/js/zulma_search.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/zulma_search.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","formatSearchResultItem","item","terms","ref","doc","title","body","stemmedTerms","map","w","elasticlunr","stemmer","toLowerCase","termFound","index","weighted","sentences","split","words","j","word","length","k","startsWith","push","windowWeights","windowSize","Math","min","curSum","maxSumIndex","maxFound","teaser","startIndex","substring","join","makeTeaser","initSearch","func","wait","timeout","$searchInput","document","getElementById","$searchResults","querySelector","$searchResultsItems","options","bool","fields","boost","Index","load","window","searchIndex","addEventListener","term","trim","style","display","innerHTML","results","search","createElement","appendChild","context","this","args","arguments","clearTimeout","setTimeout","apply","readyState","documentElement","doScroll"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAM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OC,aAE1Cb,EAAac,iBAAiB,SAtJdjB,EAsJgC,WAC9C,IAAIkB,EAAOf,EAAaxD,MAAMwE,OAC9B,GAAK3C,IAGL8B,EAAec,MAAMC,QAAmB,KAATH,EAAc,OAAS,QACtDV,EAAoBc,UAAY,GACnB,KAATJ,GAAJ,CAIA,IAAIK,EAAU/C,EAAMgD,OAAON,EAAMT,GACjC,GAAuB,IAAnBc,EAAQxC,OAAZ,CAKcmC,EACd,IAAK,IAAIxF,EAAI,EAAGA,EAAI2D,KAAKC,IAAIiC,EAAQxC,OAlCvB,IAkC2CrD,IAAK,CAC5D,IAAIiC,EAAOyC,SAASqB,cAAc,MAClC9D,EAAK2D,UAAY5D,EAAuB6D,EAAQ7F,GAAIwF,EAAKvC,MAAM,MAC/D6B,EAAoBkB,YAAY/D,SARhC2C,EAAec,MAAMC,QAAU,SAnKbpB,EA6KnB,IA1KI,WACL,IAAI0B,EAAUC,KACVC,EAAOC,UACXC,aAAa7B,GAEbA,EAAU8B,YAAW,WACnB9B,EAAU,KACVF,EAAKiC,MAAMN,EAASE,KACnB5B,MAsKqB,aAAxBG,SAAS8B,YACc,YAAxB9B,SAAS8B,aAA6B9B,SAAS+B,gBAAgBC,SAEhErC,IAEAK,SAASa,iBAAiB,mBAAoBlB","file":"zulma_search.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","/* eslint-disable */\n\nfunction debounce(func, wait) {\n var timeout;\n\n return function () {\n var context = this;\n var args = arguments;\n clearTimeout(timeout);\n\n timeout = setTimeout(function () {\n timeout = null;\n func.apply(context, args);\n }, wait);\n };\n}\n\n// Taken from mdbook\n// The strategy is as follows:\n// First, assign a value to each word in the document:\n// Words that correspond to search terms (stemmer aware): 40\n// Normal words: 2\n// First word in a sentence: 8\n// Then use a sliding window with a constant number of words and count the\n// sum of the values of the words within the window. Then use the window that got the\n// maximum sum. If there are multiple maximas, then get the last one.\n// Enclose the terms in .\nfunction makeTeaser(body, terms) {\n var TERM_WEIGHT = 40;\n var NORMAL_WORD_WEIGHT = 2;\n var FIRST_WORD_WEIGHT = 8;\n var TEASER_MAX_WORDS = 30;\n\n var stemmedTerms = terms.map(function (w) {\n return elasticlunr.stemmer(w.toLowerCase());\n });\n var termFound = false;\n var index = 0;\n var weighted = []; // contains elements of [\"word\", weight, index_in_document]\n\n // split in sentences, then words\n var sentences = body.toLowerCase().split(\". \");\n\n for (var i in sentences) {\n var words = sentences[i].split(\" \");\n var value = FIRST_WORD_WEIGHT;\n\n for (var j in words) {\n var word = words[j];\n\n if (word.length > 0) {\n for (var k in stemmedTerms) {\n if (elasticlunr.stemmer(word).startsWith(stemmedTerms[k])) {\n value = TERM_WEIGHT;\n termFound = true;\n }\n }\n weighted.push([word, value, index]);\n value = NORMAL_WORD_WEIGHT;\n }\n\n index += word.length;\n index += 1; // ' ' or '.' if last word in sentence\n }\n\n index += 1; // because we split at a two-char boundary '. '\n }\n\n if (weighted.length === 0) {\n return body;\n }\n\n var windowWeights = [];\n var windowSize = Math.min(weighted.length, TEASER_MAX_WORDS);\n // We add a window with all the weights first\n var curSum = 0;\n for (var i = 0; i < windowSize; i++) {\n curSum += weighted[i][1];\n }\n windowWeights.push(curSum);\n\n for (var i = 0; i < weighted.length - windowSize; i++) {\n curSum -= weighted[i][1];\n curSum += weighted[i + windowSize][1];\n windowWeights.push(curSum);\n }\n\n // If we didn't find the term, just pick the first window\n var maxSumIndex = 0;\n if (termFound) {\n var maxFound = 0;\n // backwards\n for (var i = windowWeights.length - 1; i >= 0; i--) {\n if (windowWeights[i] > maxFound) {\n maxFound = windowWeights[i];\n maxSumIndex = i;\n }\n }\n }\n\n var teaser = [];\n var startIndex = weighted[maxSumIndex][2];\n for (var i = maxSumIndex; i < maxSumIndex + windowSize; i++) {\n var word = weighted[i];\n if (startIndex < word[2]) {\n // missing text from index to start of `word`\n teaser.push(body.substring(startIndex, word[2]));\n startIndex = word[2];\n }\n\n // add around search terms\n if (word[1] === TERM_WEIGHT) {\n teaser.push(\"\");\n }\n startIndex = word[2] + word[0].length;\n teaser.push(body.substring(word[2], startIndex));\n\n if (word[1] === TERM_WEIGHT) {\n teaser.push(\"\");\n }\n }\n teaser.push(\"…\");\n return teaser.join(\"\");\n}\n\nfunction formatSearchResultItem(item, terms) {\n return '
' +\n `${item.doc.title}` +\n `
${makeTeaser(item.doc.body, terms)}
` +\n '
';\n}\n\nfunction initSearch() {\n var $searchInput = document.getElementById(\"search\");\n var $searchResults = document.querySelector(\".search-results\");\n var $searchResultsItems = document.querySelector(\".search-results__items\");\n var MAX_ITEMS = 10;\n\n var options = {\n bool: \"AND\",\n fields: {\n title: {\n boost: 2\n },\n body: {\n boost: 1\n },\n }\n };\n var currentTerm = \"\";\n var index = elasticlunr.Index.load(window.searchIndex);\n\n $searchInput.addEventListener(\"keyup\", debounce(function () {\n var term = $searchInput.value.trim();\n if (!index) {\n return;\n }\n $searchResults.style.display = term === \"\" ? \"none\" : \"block\";\n $searchResultsItems.innerHTML = \"\";\n if (term === \"\") {\n return;\n }\n\n var results = index.search(term, options);\n if (results.length === 0) {\n $searchResults.style.display = \"none\";\n return;\n }\n\n currentTerm = term;\n for (var i = 0; i < Math.min(results.length, MAX_ITEMS); i++) {\n var item = document.createElement(\"li\");\n item.innerHTML = formatSearchResultItem(results[i], term.split(\" \"));\n $searchResultsItems.appendChild(item);\n }\n }, 150));\n}\n\n\nif (document.readyState === \"complete\" ||\n (document.readyState !== \"loading\" && !document.documentElement.doScroll)\n) {\n initSearch();\n} else {\n document.addEventListener(\"DOMContentLoaded\", initSearch);\n}"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/zulma_search.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","formatSearchResultItem","item","terms","ref","doc","title","body","stemmedTerms","map","w","elasticlunr","stemmer","toLowerCase","termFound","index","weighted","sentences","split","words","j","word","length","k","startsWith","push","windowWeights","windowSize","Math","min","curSum","maxSumIndex","maxFound","teaser","startIndex","substring","join","makeTeaser","initSearch","func","wait","timeout","$searchInput","document","getElementById","$searchResults","querySelector","$searchResultsItems","options","bool","fields","boost","Index","load","window","searchIndex","addEventListener","term","trim","style","display","innerHTML","results","search","createElement","appendChild","context","this","args","arguments","clearTimeout","setTimeout","apply","readyState","documentElement","doScroll"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,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AK,IAMTC,CAAWnC,EAAKG,IAAIE,KAAMJ,GAF7B,UAGL,SAGJ,SAASmC,IACP,IAnIgBC,EAAMC,EAClBC,EAkIAC,EAAeC,SAASC,eAAe,UACvCC,EAAiBF,SAASG,cAAc,mBACxCC,EAAsBJ,SAASG,cAAc,0BAG7CE,EAAU,CACZC,KAAM,MACNC,OAAQ,CACN5C,MAAO,CACL6C,MAAO,GAET5C,KAAM,CACJ4C,MAAO,KAKTpC,EAAQJ,YAAYyC,MAAMC,KAAKC,OAAOC,aAE1Cb,EAAac,iBAAiB,SAtJdjB,EAsJgC,WAC9C,IAAIkB,EAAOf,EAAaxD,MAAMwE,OAC9B,GAAK3C,IAGL8B,EAAec,MAAMC,QAAmB,KAATH,EAAc,OAAS,QACtDV,EAAoBc,UAAY,GACnB,KAATJ,GAAJ,CAIA,IAAIK,EAAU/C,EAAMgD,OAAON,EAAMT,GACjC,GAAuB,IAAnBc,EAAQxC,OAAZ,CAKcmC,EACd,IAAK,IAAIxF,EAAI,EAAGA,EAAI2D,KAAKC,IAAIiC,EAAQxC,OAlCvB,IAkC2CrD,IAAK,CAC5D,IAAIiC,EAAOyC,SAASqB,cAAc,MAClC9D,EAAK2D,UAAY5D,EAAuB6D,EAAQ7F,GAAIwF,EAAKvC,MAAM,MAC/D6B,EAAoBkB,YAAY/D,SARhC2C,EAAec,MAAMC,QAAU,SAnKbpB,EA6KnB,IA1KI,WACL,IAAI0B,EAAUC,KACVC,EAAOC,UACXC,aAAa7B,GAEbA,EAAU8B,YAAW,WACnB9B,EAAU,KACVF,EAAKiC,MAAMN,EAASE,KACnB5B,MAsKqB,aAAxBG,SAAS8B,YACc,YAAxB9B,SAAS8B,aAA6B9B,SAAS+B,gBAAgBC,SAEhErC,IAEAK,SAASa,iBAAiB,mBAAoBlB","file":"zulma_search.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","/* eslint-disable */\r\n\r\nfunction debounce(func, wait) {\r\n var timeout;\r\n\r\n return function () {\r\n var context = this;\r\n var args = arguments;\r\n clearTimeout(timeout);\r\n\r\n timeout = setTimeout(function () {\r\n timeout = null;\r\n func.apply(context, args);\r\n }, wait);\r\n };\r\n}\r\n\r\n// Taken from mdbook\r\n// The strategy is as follows:\r\n// First, assign a value to each word in the document:\r\n// Words that correspond to search terms (stemmer aware): 40\r\n// Normal words: 2\r\n// First word in a sentence: 8\r\n// Then use a sliding window with a constant number of words and count the\r\n// sum of the values of the words within the window. Then use the window that got the\r\n// maximum sum. If there are multiple maximas, then get the last one.\r\n// Enclose the terms in .\r\nfunction makeTeaser(body, terms) {\r\n var TERM_WEIGHT = 40;\r\n var NORMAL_WORD_WEIGHT = 2;\r\n var FIRST_WORD_WEIGHT = 8;\r\n var TEASER_MAX_WORDS = 30;\r\n\r\n var stemmedTerms = terms.map(function (w) {\r\n return elasticlunr.stemmer(w.toLowerCase());\r\n });\r\n var termFound = false;\r\n var index = 0;\r\n var weighted = []; // contains elements of [\"word\", weight, index_in_document]\r\n\r\n // split in sentences, then words\r\n var sentences = body.toLowerCase().split(\". \");\r\n\r\n for (var i in sentences) {\r\n var words = sentences[i].split(\" \");\r\n var value = FIRST_WORD_WEIGHT;\r\n\r\n for (var j in words) {\r\n var word = words[j];\r\n\r\n if (word.length > 0) {\r\n for (var k in stemmedTerms) {\r\n if (elasticlunr.stemmer(word).startsWith(stemmedTerms[k])) {\r\n value = TERM_WEIGHT;\r\n termFound = true;\r\n }\r\n }\r\n weighted.push([word, value, index]);\r\n value = NORMAL_WORD_WEIGHT;\r\n }\r\n\r\n index += word.length;\r\n index += 1; // ' ' or '.' if last word in sentence\r\n }\r\n\r\n index += 1; // because we split at a two-char boundary '. '\r\n }\r\n\r\n if (weighted.length === 0) {\r\n return body;\r\n }\r\n\r\n var windowWeights = [];\r\n var windowSize = Math.min(weighted.length, TEASER_MAX_WORDS);\r\n // We add a window with all the weights first\r\n var curSum = 0;\r\n for (var i = 0; i < windowSize; i++) {\r\n curSum += weighted[i][1];\r\n }\r\n windowWeights.push(curSum);\r\n\r\n for (var i = 0; i < weighted.length - windowSize; i++) {\r\n curSum -= weighted[i][1];\r\n curSum += weighted[i + windowSize][1];\r\n windowWeights.push(curSum);\r\n }\r\n\r\n // If we didn't find the term, just pick the first window\r\n var maxSumIndex = 0;\r\n if (termFound) {\r\n var maxFound = 0;\r\n // backwards\r\n for (var i = windowWeights.length - 1; i >= 0; i--) {\r\n if (windowWeights[i] > maxFound) {\r\n maxFound = windowWeights[i];\r\n maxSumIndex = i;\r\n }\r\n }\r\n }\r\n\r\n var teaser = [];\r\n var startIndex = weighted[maxSumIndex][2];\r\n for (var i = maxSumIndex; i < maxSumIndex + windowSize; i++) {\r\n var word = weighted[i];\r\n if (startIndex < word[2]) {\r\n // missing text from index to start of `word`\r\n teaser.push(body.substring(startIndex, word[2]));\r\n startIndex = word[2];\r\n }\r\n\r\n // add around search terms\r\n if (word[1] === TERM_WEIGHT) {\r\n teaser.push(\"\");\r\n }\r\n startIndex = word[2] + word[0].length;\r\n teaser.push(body.substring(word[2], startIndex));\r\n\r\n if (word[1] === TERM_WEIGHT) {\r\n teaser.push(\"\");\r\n }\r\n }\r\n teaser.push(\"…\");\r\n return teaser.join(\"\");\r\n}\r\n\r\nfunction formatSearchResultItem(item, terms) {\r\n return '
' +\r\n `${item.doc.title}` +\r\n `
${makeTeaser(item.doc.body, terms)}
` +\r\n '
';\r\n}\r\n\r\nfunction initSearch() {\r\n var $searchInput = document.getElementById(\"search\");\r\n var $searchResults = document.querySelector(\".search-results\");\r\n var $searchResultsItems = document.querySelector(\".search-results__items\");\r\n var MAX_ITEMS = 10;\r\n\r\n var options = {\r\n bool: \"AND\",\r\n fields: {\r\n title: {\r\n boost: 2\r\n },\r\n body: {\r\n boost: 1\r\n },\r\n }\r\n };\r\n var currentTerm = \"\";\r\n var index = elasticlunr.Index.load(window.searchIndex);\r\n\r\n $searchInput.addEventListener(\"keyup\", debounce(function () {\r\n var term = $searchInput.value.trim();\r\n if (!index) {\r\n return;\r\n }\r\n $searchResults.style.display = term === \"\" ? \"none\" : \"block\";\r\n $searchResultsItems.innerHTML = \"\";\r\n if (term === \"\") {\r\n return;\r\n }\r\n\r\n var results = index.search(term, options);\r\n if (results.length === 0) {\r\n $searchResults.style.display = \"none\";\r\n return;\r\n }\r\n\r\n currentTerm = term;\r\n for (var i = 0; i < Math.min(results.length, MAX_ITEMS); i++) {\r\n var item = document.createElement(\"li\");\r\n item.innerHTML = formatSearchResultItem(results[i], term.split(\" \"));\r\n $searchResultsItems.appendChild(item);\r\n }\r\n }, 150));\r\n}\r\n\r\n\r\nif (document.readyState === \"complete\" ||\r\n (document.readyState !== \"loading\" && !document.documentElement.doScroll)\r\n) {\r\n initSearch();\r\n} else {\r\n document.addEventListener(\"DOMContentLoaded\", initSearch);\r\n}"],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/zulma_switchcss.js b/static/js/zulma_switchcss.js index b22fdc6..070123e 100644 --- a/static/js/zulma_switchcss.js +++ b/static/js/zulma_switchcss.js @@ -1,2 +1,2 @@ -!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}({2:function(e,t){!function(e){var t="ZULMA_THEME",n=localStorage.getItem(t),o="stop-blink",r="stylesheet",c=null,l=function e(t){var n=t.currentTarget;n.removeEventListener("load",e),n.removeEventListener("error",i),a(),n.className+=r,c=null,d()},i=function e(n){var o=n.currentTarget;o.removeEventListener("load",l),o.removeEventListener("error",e),localStorage.removeItem(t),s(o.id,!1),o.remove(),c&&document.getElementsByTagName("head")[0].appendChild(c),s(document.querySelectorAll(".".concat(r))[0].id,!0),d()};function u(e,n){var o=document.createElement("link");o.rel="stylesheet",o.type="text/css",o.href="/".concat(e,".css"),o.id=e;var u=document.getElementsByTagName("head")[0].appendChild(o);u.addEventListener("load",l),u.addEventListener("error",i),n&&(c=document.querySelectorAll(".".concat(r))[0],a()),function(e){localStorage.setItem(t,e)}(e)}function a(){document.querySelectorAll(".".concat(r)).forEach((function(e){e.remove()}))}function d(){var e=document.getElementById(o);e&&e.remove()}function s(e,t){var n=document.querySelectorAll("#theme-select>option");n.length?n.forEach((function(n){n.value===e&&(t?n.selected="selected":n.remove())})):window.addEventListener("DOMContentLoaded",(function(){s(e,t)}))}e.init=function(){var e,t,r;n&&!document.getElementById(n)&&(e=document.getElementsByTagName("head")[0],t=document.createElement("style"),r="body{visibility:hidden;}",t.id=o,t.setAttribute("type","text/css"),t.styleSheet?t.styleSheet.cssText=r:t.appendChild(document.createTextNode(r)),e.appendChild(t),u(n,!0),s(n,!0)),window.addEventListener("DOMContentLoaded",(function(){document.getElementById("theme-select").onchange=function(){u(this.value)}}))}}(switch_css=window.switch_css||{}),switch_css.init()}}); +!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}({2:function(e,t){!function(e){var t="ZULMA_THEME",n=localStorage.getItem(t),o="stop-blink",r="stylesheet",c=null,l="",i=function e(t){var n=t.currentTarget;n.removeEventListener("load",e),n.removeEventListener("error",u),d(),n.className+=r,c=null,s()},u=function e(n){var o=n.currentTarget;o.removeEventListener("load",i),o.removeEventListener("error",e),localStorage.removeItem(t),m(o.id,!1),o.remove(),c&&document.getElementsByTagName("head")[0].appendChild(c),m(document.querySelectorAll(".".concat(r))[0].id,!0),s()};function a(e,n){var o=document.createElement("link");o.rel="stylesheet",o.type="text/css",o.href="".concat(l,"/").concat(e,".css"),o.id=e;var a=document.getElementsByTagName("head")[0].appendChild(o);a.addEventListener("load",i),a.addEventListener("error",u),n&&(c=document.querySelectorAll(".".concat(r))[0],d()),function(e){localStorage.setItem(t,e)}(e)}function d(){document.querySelectorAll(".".concat(r)).forEach((function(e){e.remove()}))}function s(){var e=document.getElementById(o);e&&e.remove()}function m(e,t){var n=document.querySelectorAll("#theme-select>option");n.length?n.forEach((function(n){n.value===e&&(t?n.selected="selected":n.remove())})):window.addEventListener("DOMContentLoaded",(function(){m(e,t)}))}e.init=function(e){var t,r,c;l=e,n&&!document.getElementById(n)&&(t=document.getElementsByTagName("head")[0],r=document.createElement("style"),c="body{visibility:hidden;}",r.id=o,r.setAttribute("type","text/css"),r.styleSheet?r.styleSheet.cssText=c:r.appendChild(document.createTextNode(c)),t.appendChild(r),a(n,!0),m(n,!0)),window.addEventListener("DOMContentLoaded",(function(){document.getElementById("theme-select").onchange=function(){a(this.value)}}))}}(switch_css=window.switch_css||{})}}); //# sourceMappingURL=zulma_switchcss.js.map \ No newline at end of file diff --git a/static/js/zulma_switchcss.js.map b/static/js/zulma_switchcss.js.map index 6f54e05..784310a 100644 --- a/static/js/zulma_switchcss.js.map +++ b/static/js/zulma_switchcss.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/zulma_switchcss.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","switch_css","THEME_KEY","THEME","localStorage","getItem","STOP_BLINK_CSS_ID","STYLESHEET_CLASSNAME","previousLink","onLinkLoad","event","link","currentTarget","removeEventListener","onLinkError","removeStylesheets","className","showBody","removeItem","updateThemeSelect","id","remove","document","getElementsByTagName","appendChild","querySelectorAll","changeTheme","themeName","firstLoad","fileref","createElement","rel","type","href","addEventListener","setItem","saveTheme","forEach","el","css","getElementById","theme","setSelected","elements","length","element","selected","window","init","head","style","setAttribute","styleSheet","cssText","createTextNode","onchange","this"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAA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EAAWrB,SAASG,iBAAiB,wBAErCkB,EAASC,OACXD,EAASN,SAAQ,SAAAQ,GACXA,EAAQ3D,QAAUuD,IAChBC,EACFG,EAAQC,SAAW,WAEnBD,EAAQxB,aAMd0B,OAAOb,iBAAiB,oBAAoB,WAC1Cf,EAAkBsB,EAAOC,MAM/BzC,EAAW+C,KAAO,WA9ClB,IACMC,EACAC,EACAX,EA6CApC,IAAUmB,SAASkB,eAAerC,KA/ClC8C,EAAO3B,SAASC,qBAAqB,QAAQ,GAC7C2B,EAAQ5B,SAASQ,cAAc,SAC/BS,EAAM,2BAEVW,EAAM9B,GAAKd,EACX4C,EAAMC,aAAa,OAAQ,YAEvBD,EAAME,WACRF,EAAME,WAAWC,QAAUd,EAE3BW,EAAM1B,YAAYF,SAASgC,eAAef,IAE5CU,EAAKzB,YAAY0B,GAuCfxB,EAAYvB,GAAO,GAEnBgB,EAAkBhB,GAAO,IAG3B4C,OAAOb,iBAAiB,oBAAoB,WAC1CZ,SAASkB,eAAe,gBAAgBe,SAAW,WACjD7B,EAAY8B,KAAKtE,YA5JzB,CAgKIe,WAAa8C,OAAO9C,YAAc,IAEtCA,WAAW+C","file":"zulma_switchcss.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","(function(switch_css) {\n //Constants\n const THEME_KEY = \"ZULMA_THEME\";\n const THEME = localStorage.getItem(THEME_KEY);\n const STOP_BLINK_CSS_ID = \"stop-blink\";\n const STYLESHEET_CLASSNAME = \"stylesheet\";\n\n //Variables\n let previousLink = null;\n\n //Events\n /* The function called when the css has finished loading */\n const onLinkLoad = event => {\n //remove event listeners\n let link = event.currentTarget;\n link.removeEventListener(\"load\", onLinkLoad);\n link.removeEventListener(\"error\", onLinkError);\n //remove the previous stylesheet(s)\n removeStylesheets();\n //add stylesheet class\n link.className += STYLESHEET_CLASSNAME;\n //everything is good, so we don't need this\n previousLink = null;\n //make body visible again if it was hidden\n showBody();\n };\n\n const onLinkError = event => {\n //remove event listeners\n let link = event.currentTarget;\n link.removeEventListener(\"load\", onLinkLoad);\n link.removeEventListener(\"error\", onLinkError);\n //remove theme from localstorage\n clearTheme();\n //remove theme from dropdown list\n updateThemeSelect(link.id, false);\n //remove link from page\n link.remove();\n //re-add the previous stylesheet (if any)\n if (previousLink) {\n document.getElementsByTagName(\"head\")[0].appendChild(previousLink);\n }\n //set the theme select to the previous stylesheet\n updateThemeSelect(\n document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`)[0].id,\n true\n );\n //make body visible again if it was hidden\n showBody();\n };\n\n //Private Methods\n /* Called when the theme is changed */\n function changeTheme(themeName, firstLoad) {\n //create the css link element\n var fileref = document.createElement(\"link\");\n fileref.rel = \"stylesheet\";\n fileref.type = \"text/css\";\n fileref.href = `/${themeName}.css`;\n fileref.id = themeName;\n\n //append it to the head\n let link = document.getElementsByTagName(\"head\")[0].appendChild(fileref);\n\n //when it's loaded, call onLinkLoad\n link.addEventListener(\"load\", onLinkLoad);\n //if it errors, call onLinkError\n link.addEventListener(\"error\", onLinkError);\n\n //if this is the first load of the page, remove the current stylesheet early to avoid flash of wrongly styled content\n if (firstLoad) {\n //keep the old link in case something goes wrong\n previousLink = document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`)[0];\n removeStylesheets();\n }\n\n saveTheme(themeName);\n }\n\n /* Removes all current stylesheets on the page */\n function removeStylesheets() {\n document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`).forEach(el => {\n el.remove();\n });\n }\n\n /* Saves the current theme in localstorage */\n function saveTheme(themeName) {\n localStorage.setItem(THEME_KEY, themeName);\n }\n\n /* Clears the current theme in localstorage */\n function clearTheme() {\n localStorage.removeItem(THEME_KEY);\n }\n\n /* Hides the body of the page */\n function hideBody() {\n let head = document.getElementsByTagName(\"head\")[0];\n let style = document.createElement(\"style\");\n let css = \"body{visibility:hidden;}\";\n\n style.id = STOP_BLINK_CSS_ID;\n style.setAttribute(\"type\", \"text/css\");\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n head.appendChild(style);\n }\n\n /* Shows the body of the page */\n function showBody() {\n let css = document.getElementById(STOP_BLINK_CSS_ID);\n if (css) css.remove();\n }\n\n /* Either sets the theme selection to the given theme, or removes it from the list */\n function updateThemeSelect(theme, setSelected) {\n //get all select options\n let elements = document.querySelectorAll(\"#theme-select>option\");\n //if there are elements, the page is loaded and continue\n if (elements.length) {\n elements.forEach(element => {\n if (element.value === theme) {\n if (setSelected) {\n element.selected = \"selected\";\n } else {\n element.remove();\n }\n }\n });\n } else {\n //if there are no elements, the page is not yet loaded; wait for loaded event and try again.\n window.addEventListener(\"DOMContentLoaded\", () => {\n updateThemeSelect(theme, setSelected);\n });\n }\n }\n\n //Public Methods\n switch_css.init = function() {\n //if user has selected and theme and it is not the current theme\n if (THEME && !document.getElementById(THEME)) {\n //hide the body to stop FOUC\n hideBody();\n //change the theme\n changeTheme(THEME, true);\n //when the DOM is loaded, change the select to their current choice\n updateThemeSelect(THEME, true);\n }\n //when the DOM is loaded, set the dropdown to trigger the theme change\n window.addEventListener(\"DOMContentLoaded\", () => {\n document.getElementById(\"theme-select\").onchange = function() {\n changeTheme(this.value);\n };\n });\n };\n})((switch_css = window.switch_css || {})); // eslint-disable-line\n\nswitch_css.init(); // eslint-disable-line\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/zulma_switchcss.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","switch_css","THEME_KEY","THEME","localStorage","getItem","STOP_BLINK_CSS_ID","STYLESHEET_CLASSNAME","previousLink","baseUrl","onLinkLoad","event","link","currentTarget","removeEventListener","onLinkError","removeStylesheets","className","showBody","removeItem","updateThemeSelect","id","remove","document","getElementsByTagName","appendChild","querySelectorAll","changeTheme","themeName","firstLoad","fileref","createElement","rel","type","href","addEventListener","setItem","saveTheme","forEach","el","css","getElementById","theme","setSelected","elements","length","element","selected","window","init","url","head","style","setAttribute","styleSheet","cssText","createTextNode","onchange","this"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iB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b,iBAAiB,oBAAoB,WAC1CZ,SAASkB,eAAe,gBAAgBgB,SAAW,WACjD9B,EAAY+B,KAAKxE,YA9JzB,CAkKIe,WAAa+C,OAAO/C,YAAc","file":"zulma_switchcss.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","(function (switch_css) {\r\n //Constants\r\n const THEME_KEY = \"ZULMA_THEME\";\r\n const THEME = localStorage.getItem(THEME_KEY);\r\n const STOP_BLINK_CSS_ID = \"stop-blink\";\r\n const STYLESHEET_CLASSNAME = \"stylesheet\";\r\n\r\n //Variables\r\n let previousLink = null;\r\n let baseUrl = \"\";\r\n\r\n //Events\r\n /* The function called when the css has finished loading */\r\n const onLinkLoad = event => {\r\n //remove event listeners\r\n let link = event.currentTarget;\r\n link.removeEventListener(\"load\", onLinkLoad);\r\n link.removeEventListener(\"error\", onLinkError);\r\n //remove the previous stylesheet(s)\r\n removeStylesheets();\r\n //add stylesheet class\r\n link.className += STYLESHEET_CLASSNAME;\r\n //everything is good, so we don't need this\r\n previousLink = null;\r\n //make body visible again if it was hidden\r\n showBody();\r\n };\r\n\r\n const onLinkError = event => {\r\n //remove event listeners\r\n let link = event.currentTarget;\r\n link.removeEventListener(\"load\", onLinkLoad);\r\n link.removeEventListener(\"error\", onLinkError);\r\n //remove theme from localstorage\r\n clearTheme();\r\n //remove theme from dropdown list\r\n updateThemeSelect(link.id, false);\r\n //remove link from page\r\n link.remove();\r\n //re-add the previous stylesheet (if any)\r\n if (previousLink) {\r\n document.getElementsByTagName(\"head\")[0].appendChild(previousLink);\r\n }\r\n //set the theme select to the previous stylesheet\r\n updateThemeSelect(\r\n document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`)[0].id,\r\n true\r\n );\r\n //make body visible again if it was hidden\r\n showBody();\r\n };\r\n\r\n //Private Methods\r\n /* Called when the theme is changed */\r\n function changeTheme(themeName, firstLoad) {\r\n //create the css link element\r\n var fileref = document.createElement(\"link\");\r\n fileref.rel = \"stylesheet\";\r\n fileref.type = \"text/css\";\r\n fileref.href = `${baseUrl}/${themeName}.css`;\r\n fileref.id = themeName;\r\n\r\n //append it to the head\r\n let link = document.getElementsByTagName(\"head\")[0].appendChild(fileref);\r\n\r\n //when it's loaded, call onLinkLoad\r\n link.addEventListener(\"load\", onLinkLoad);\r\n //if it errors, call onLinkError\r\n link.addEventListener(\"error\", onLinkError);\r\n\r\n //if this is the first load of the page, remove the current stylesheet early to avoid flash of wrongly styled content\r\n if (firstLoad) {\r\n //keep the old link in case something goes wrong\r\n previousLink = document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`)[0];\r\n removeStylesheets();\r\n }\r\n\r\n saveTheme(themeName);\r\n }\r\n\r\n /* Removes all current stylesheets on the page */\r\n function removeStylesheets() {\r\n document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`).forEach(el => {\r\n el.remove();\r\n });\r\n }\r\n\r\n /* Saves the current theme in localstorage */\r\n function saveTheme(themeName) {\r\n localStorage.setItem(THEME_KEY, themeName);\r\n }\r\n\r\n /* Clears the current theme in localstorage */\r\n function clearTheme() {\r\n localStorage.removeItem(THEME_KEY);\r\n }\r\n\r\n /* Hides the body of the page */\r\n function hideBody() {\r\n let head = document.getElementsByTagName(\"head\")[0];\r\n let style = document.createElement(\"style\");\r\n let css = \"body{visibility:hidden;}\";\r\n\r\n style.id = STOP_BLINK_CSS_ID;\r\n style.setAttribute(\"type\", \"text/css\");\r\n\r\n if (style.styleSheet) {\r\n style.styleSheet.cssText = css;\r\n } else {\r\n style.appendChild(document.createTextNode(css));\r\n }\r\n head.appendChild(style);\r\n }\r\n\r\n /* Shows the body of the page */\r\n function showBody() {\r\n let css = document.getElementById(STOP_BLINK_CSS_ID);\r\n if (css) css.remove();\r\n }\r\n\r\n /* Either sets the theme selection to the given theme, or removes it from the list */\r\n function updateThemeSelect(theme, setSelected) {\r\n //get all select options\r\n let elements = document.querySelectorAll(\"#theme-select>option\");\r\n //if there are elements, the page is loaded and continue\r\n if (elements.length) {\r\n elements.forEach(element => {\r\n if (element.value === theme) {\r\n if (setSelected) {\r\n element.selected = \"selected\";\r\n } else {\r\n element.remove();\r\n }\r\n }\r\n });\r\n } else {\r\n //if there are no elements, the page is not yet loaded; wait for loaded event and try again.\r\n window.addEventListener(\"DOMContentLoaded\", () => {\r\n updateThemeSelect(theme, setSelected);\r\n });\r\n }\r\n }\r\n\r\n //Public Methods\r\n switch_css.init = function (url) {\r\n baseUrl = url\r\n //if user has selected and theme and it is not the current theme\r\n if (THEME && !document.getElementById(THEME)) {\r\n //hide the body to stop FOUC\r\n hideBody();\r\n //change the theme\r\n changeTheme(THEME, true);\r\n //when the DOM is loaded, change the select to their current choice\r\n updateThemeSelect(THEME, true);\r\n }\r\n //when the DOM is loaded, set the dropdown to trigger the theme change\r\n window.addEventListener(\"DOMContentLoaded\", () => {\r\n document.getElementById(\"theme-select\").onchange = function () {\r\n changeTheme(this.value);\r\n };\r\n });\r\n };\r\n})((switch_css = window.switch_css || {})); // eslint-disable-line"],"sourceRoot":""} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 2886980..14f5406 100644 --- a/templates/index.html +++ b/templates/index.html @@ -20,6 +20,9 @@ {% if config.extra.zulma_allow_theme_selection %} + {% endif %} {% if config.generate_rss %}