diff --git a/ds2 core.sublime-workspace b/ds2 core.sublime-workspace index 662a4f9..b516375 100644 --- a/ds2 core.sublime-workspace +++ b/ds2 core.sublime-workspace @@ -191,6 +191,25 @@ }, "buffers": [ + { + "file": "src/js/scaffolding.js", + "settings": + { + "buffer_size": 2622, + "line_ending": "Unix" + }, + "undo_stack": + [ + [ + 1, + 1, + "revert", + null, + "AgAAAAAAAAAAAAAAAAAAAAAAAAA+CgAALy8gY29yZSBhbmQgcHJpc20KaW1wb3J0ICogYXMgY29yZSBmcm9tICcuL2NvcmUvX2NvcmUuanMnOwppbXBvcnQgKiBhcyBQcmlzbSBmcm9tICIuLi8uLi9ub2RlX21vZHVsZXMvcHJpc21qcy9wcmlzbSI7CmltcG9ydCAiLi4vLi4vbm9kZV9tb2R1bGVzL3ByaXNtanMvcGx1Z2lucy9saW5lLW51bWJlcnMvcHJpc20tbGluZS1udW1iZXJzIjsKaW1wb3J0ICIuLi8uLi9ub2RlX21vZHVsZXMvcHJpc21qcy9wbHVnaW5zL3Rvb2xiYXIvcHJpc20tdG9vbGJhciI7CmltcG9ydCAnLi4vLi4vbm9kZV9tb2R1bGVzL3ByaXNtanMvY29tcG9uZW50cy9wcmlzbS1qc29uJzsKaW1wb3J0ICcuLi8uLi9ub2RlX21vZHVsZXMvcHJpc21qcy9jb21wb25lbnRzL3ByaXNtLXB1Zyc7CmltcG9ydCAnLi4vLi4vbm9kZV9tb2R1bGVzL3ByaXNtanMvY29tcG9uZW50cy9wcmlzbS1zYXNzJzsKCi8vIGltcG9ydCBwYXR0ZXJuIHN0dWZmLgppbXBvcnQgKiBhcyBzdGlja3lub3RlIGZyb20gIi4uL3BnL3BhdHRlcm5zL2NvcmUvc3RpY2t5LW5vdGUvX3N0aWNreS1ub3RlLmpzIjsKaW1wb3J0ICogYXMgc3d0Y2ggICAgICBmcm9tICIuLi9wZy9wYXR0ZXJucy9jb3JlL3N3aXRjaC9fc3dpdGNoLmpzIjsKaW1wb3J0ICogYXMgdGFicyAgICAgICBmcm9tICIuLi9wZy9wYXR0ZXJucy9jb3JlL3RhYnMvX3RhYnMuanMiOwoKLy8gaW5pdCBjb3JlCmNvcmUuaW5pdCh7CglzdWNjZXNzOiAoYSkgPT4geyAKCQl0YWJzLmluaXQoYSk7CgkJc3d0Y2guaW5pdChhKTsKCQlzdGlja3lub3RlLmluaXQoYSk7Cgl9LAoJbm90Rm91bmQ6IChhLCBwYXRoKSA9PiB7CgkJYS5pbm5lckhUTUwgPSBgJHthLmlubmVySFRNTH08ZGl2IGNsYXNzPSdub3RpZmljYXRpb24tYm94IGVycm9yJz48cD5UaGlzIHBhdHRlcm4gYXBwZWFycyB0byBiZSBtaXNzaW5nLjxicj48c21hbGw+KCR7cGF0aH0gcmV0dXJuZWQgaHR0cCBzdGF0dXMgNDA0KTwvc21hbGw+PC9wPjwvZGl2PmA7Cgl9Cn0pOwoKLy8gZGVwcmVjYXRlZCBzd2l0Y2ggaGFuZGxlcgpjb25zdCBmbGlwSW5mb1N3aXRjaCA9IChlLCBzID0gZS5jdXJyZW50VGFyZ2V0KSA9PiB7CgkKCXN3aXRjaChzLmdldEF0dHJpYnV0ZSgiaWQiKSkgewoKCQljYXNlICJkZXByZWNhdGVkIiA6IAoJCQljb3JlLmNvb2tpZS5zZXQoInNob3ctZGVwcmVjYXRlZCIsIHMuZ2V0QXR0cmlidXRlKCJhcmlhLWNoZWNrZWQiKSwgMzAsICIvIik7CgkJCWRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoIm1haW4iKS5xdWVyeVNlbGVjdG9yQWxsKCJhcnRpY2xlW2RhdGEtc3RhdHVzPWRlcHJlY2F0ZWRdIikuZm9yRWFjaCgoYSkgPT4gewoJCQkJYS5jbGFzc0xpc3RbKCBzLmdldEF0dHJpYnV0ZSgiYXJpYS1jaGVja2VkIikgPT0gInRydWUiID8gImFkZCIgOiAicmVtb3ZlIiApXSgic2hvdy1kZXByZWNhdGVkIik7CgkJCX0pOwoJCWJyZWFrOyAKCgkJY2FzZSAiYnJlYWtwb2ludHMiIDoKCQkJY29uc29sZS5sb2coImhlcmUiKQoJCQljb3JlLmNvb2tpZS5zZXQoInNob3ctYnJlYWtwb2ludHMiLCBzLmdldEF0dHJpYnV0ZSgiYXJpYS1jaGVja2VkIiksIDMwLCAiLyIpOwoJCQlkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCJodG1sIikuY2xhc3NMaXN0Wyggcy5nZXRBdHRyaWJ1dGUoImFyaWEtY2hlY2tlZCIpID09ICJ0cnVlIiA/ICJhZGQiIDogInJlbW92ZSIgKV0oInNob3ctYnJlYWtwb2ludHMiKTsKCQlicmVhazsgCgl9Cgp9CgovLyBjcmVhdGUgYSBwdXJlIEpTIG1vdXNlIGNsaWNrIGV2ZW50CmNvbnN0IGNsaWNrID0gbmV3IE1vdXNlRXZlbnQoJ2NsaWNrJywgewoJdmlldzogd2luZG93LAoJYnViYmxlczogZmFsc2UsCgljYW5jZWxhYmxlOiB0cnVlCn0pOwoKLy8gZ2V0IHRoZSBzd2l0Y2gsIGluaXRpYWxpemUgaXQgYW5kIGFkZCB0aGUgaGFuZGxlcgpsZXQgc3dpdGNoZXMgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCIuaW5mby1zd2l0Y2hlcyIpOwpzd3RjaC5pbml0KHN3aXRjaGVzKTsKCmxldCBkZXByZWNhdGVkID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcigiI2RlcHJlY2F0ZWQiKTsKbGV0IGJyZWFrcG9pbnRzID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcigiI2JyZWFrcG9pbnRzIik7CgpkZXByZWNhdGVkLm9uY2xpY2sgPSBmbGlwSW5mb1N3aXRjaDsKZGVwcmVjYXRlZC5rZXlwcmVzcyA9IGZsaXBJbmZvU3dpdGNoOwpicmVha3BvaW50cy5vbmNsaWNrID0gZmxpcEluZm9Td2l0Y2g7CmJyZWFrcG9pbnRzLmtleXByZXNzID0gZmxpcEluZm9Td2l0Y2g7CgovLyBjaGVjayBhIGNvb2tpZSB0byBnZXQgdGhlIHN3aXRjaCdzIHN0YXRlCmlmIChjb3JlLmNvb2tpZS5nZXQoInNob3ctZGVwcmVjYXRlZCIpID09ICJ0cnVlIikgewoJZGVwcmVjYXRlZC5kaXNwYXRjaEV2ZW50KGNsaWNrKTsKfQppZiAoY29yZS5jb29raWUuZ2V0KCJzaG93LWJyZWFrcG9pbnRzIikgPT0gInRydWUiKSB7CglicmVha3BvaW50cy5kaXNwYXRjaEV2ZW50KGNsaWNrKTsKfQoKLy8ganVzdCBmb3IgZnVuLi4uIFdlJ2xsIHNob3cgZGVwcmVjYXRlZCBpZiB0aGV5IG1hdGNoIHRoZSBwYXRoCi8vIGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoYCMke2NvcmUudXJsLnAucmVwbGFjZSgvXC8vZywgIi0iKX1gKS5jbGFzc0xpc3QuYWRkKCJzaG93LWRlcHJlY2F0ZWQiKTsKAAAAAAAAAAA+CgAAAAAAAAAAAAA", + "AQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPC/" + ] + ] + } ], "build_system": "", "build_system_choices": @@ -281,13 +300,12 @@ "expanded_folders": [ "/Users/am/Desktop/ds2-core", - "/Users/am/Desktop/ds2-core/src", - "/Users/am/Desktop/ds2-core/src/pg", "/Users/am/Desktop/ds2-core/src/pg/patterns", "/Users/am/Desktop/ds2-core/src/pg/patterns/core" ], "file_history": [ + "/Users/am/Desktop/ds2-core/src/js/core/_core.js", "/Users/am/Desktop/ds2-core/src/pg/patterns/core/components/switch/index.pug", "/Users/am/Desktop/ds2-core/src/pg/patterns/core/components/sticky-note/index.pug", "/Users/am/Desktop/ds2-core/src/pg/patterns/core/layouts/breakpoints/index.pug", @@ -414,8 +432,7 @@ "/Users/am/Desktop/my DS2/src/pg/patterns/layouts/main-navigation/index.pug", "/Users/am/Desktop/my DS2/src/pg/patterns/layouts/breakpoints/index.pug", "/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/notifications/index.pug", - "/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/spacing/spacing.css", - "/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/colours/index.pug" + "/Users/am/Desktop/my DS2/src/pg/patterns/visual-design/spacing/spacing.css" ], "find": { @@ -502,6 +519,38 @@ { "sheets": [ + { + "buffer": 0, + "file": "src/js/scaffolding.js", + "selected": true, + "semi_transient": false, + "settings": + { + "buffer_size": 2622, + "regions": + { + }, + "selection": + [ + [ + 0, + 0 + ] + ], + "settings": + { + "syntax": "Packages/JavaScript/JavaScript.sublime-syntax", + "tab_size": 4, + "translate_tabs_to_spaces": false + }, + "translation.x": 0.0, + "translation.y": 365.0, + "zoom_level": 1.0 + }, + "stack_index": 0, + "stack_multiselect": false, + "type": "text" + } ] } ], diff --git a/prepros.config b/prepros.config index ea2aa87..e565ca4 100644 --- a/prepros.config +++ b/prepros.config @@ -1207,6 +1207,9 @@ "concat-js": { "enable": false }, + "babel": { + "enable": true + }, "bundle-js": { "enable": true, "options": { diff --git a/public/assets/scaffolding-min.js b/public/assets/scaffolding-min.js index 596ecef..6f904af 100644 --- a/public/assets/scaffolding-min.js +++ b/public/assets/scaffolding-min.js @@ -4,314 +4,296 @@ /* 1 */ /***/ (function(module) { -const getDate = function(){ - var d = new Date(); - return d.toLocaleDateString(lang, {day: "numeric", month: "long", year: "numeric"}); -} -String.prototype.toTitleCase = function() { - return this.replace(/\w\S*/g, function(txt) { - return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); - }); -} -String.prototype.toSentenceCase = function() { - return this.charAt(0).toUpperCase() + this.substr(1).toLowerCase(); -} -String.prototype.toContent = function() { - return this.replace(/-/g, " "); -} -String.prototype.toPath = function() { - return this.trim().replace(/ /g, "_").replace(/-/g, "_").replace(/[\/\W]/g, "").replace(/_/g, "-"); -} +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +var getDate = function getDate() { + var d = new Date(); + return d.toLocaleDateString(lang, { + day: "numeric", + month: "long", + year: "numeric" + }); +}; +String.prototype.toTitleCase = function () { + return this.replace(/\w\S*/g, function (txt) { + return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); + }); +}; +String.prototype.toSentenceCase = function () { + return this.charAt(0).toUpperCase() + this.substr(1).toLowerCase(); +}; +String.prototype.toContent = function () { + return this.replace(/-/g, " "); +}; +String.prototype.toPath = function () { + return this.trim().replace(/ /g, "_").replace(/-/g, "_").replace(/[\/\W]/g, "").replace(/_/g, "-"); +}; +var font = { + size: 0 +}; +var copyColourFallback = function copyColourFallback(copyInfo, attr) { + console.log("fallback"); + var textArea = document.createElement('textarea'); + textArea.value = copyInfo; -const font = { - size: 0 -} - -const copyColourFallback = (copyInfo, attr) => { - console.log("fallback") - var textArea = document.createElement('textarea'); - textArea.value = copyInfo; - - // Avoid scrolling to bottom - textArea.style.top = '0'; - textArea.style.left = '0'; - textArea.style.position = 'fixed'; - - document.body.appendChild(textArea); - textArea.focus(); - textArea.select(); - - try { - var successful = document.execCommand('copy'); - setTimeout(function () { - if (successful) { - //copyInfo.success(); - showMessage(`Copied ${attr}.`) - } else { - //copyInfo.error(); - showMessage(`Copy failed (${attr}).`, false) - } - }, 1); - } catch (err) { - setTimeout(function () { - showMessage(`Copy failed (${attr}). ${err.Message}`, false); - - //copyInfo.error(err); - }, 1); - } - document.body.removeChild(textArea); -} - -const showMessage = (m, s) => { - s = s == undefined ? true : s; - console.log("Copy success (navigator.clipboard)"); - let status = document.createElement("div"); - status.setAttribute("id", "copystatus"); - // status.style.display = "none"; - status.innerHTML = "
" + m + "
"; - document.querySelector("body").prepend(status) - - status.querySelector("div").style.top = (window.scrollY + 100)+ "px"; - setTimeout( () => { - status.remove(); - }, 1000); -} - -const oneClickSelect = (e, t = e.currentTarget) => { - // In here, "this" is the element - var range, selection; - if (window.getSelection) { - selection = window.getSelection(); - range = document.createRange(); - range.selectNodeContents(t); - selection.removeAllRanges(); - selection.addRange(range); - } else if (document.body.createTextRange) { - range = document.body.createTextRange(); - range.moveToElementText(t); - range.select(); - } -} - -const getURLVars = () => { - var oResult = {}; - if (location.search.length > 0) { - var aQueryString = (location.search.substr(1)).split("&"); - for (var i = 0; i < aQueryString.length; i++) { - var aTemp = aQueryString[i].split("="); - if (aTemp[1].length > 0) { - oResult[aTemp[0]] = decodeURIComponent(aTemp[1].replace(/\+/g, '%20')); - } - } - } - return oResult; -} + // Avoid scrolling to bottom + textArea.style.top = '0'; + textArea.style.left = '0'; + textArea.style.position = 'fixed'; + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + try { + var successful = document.execCommand('copy'); + setTimeout(function () { + if (successful) { + //copyInfo.success(); + showMessage("Copied ".concat(attr, ".")); + } else { + //copyInfo.error(); + showMessage("Copy failed (".concat(attr, ")."), false); + } + }, 1); + } catch (err) { + setTimeout(function () { + showMessage("Copy failed (".concat(attr, "). ").concat(err.Message), false); + //copyInfo.error(err); + }, 1); + } + document.body.removeChild(textArea); +}; +var showMessage = function showMessage(m, s) { + s = s == undefined ? true : s; + console.log("Copy success (navigator.clipboard)"); + var status = document.createElement("div"); + status.setAttribute("id", "copystatus"); + // status.style.display = "none"; + status.innerHTML = "
" + m + "
"; + document.querySelector("body").prepend(status); + status.querySelector("div").style.top = window.scrollY + 100 + "px"; + setTimeout(function () { + status.remove(); + }, 1000); +}; +var oneClickSelect = function oneClickSelect(e) { + var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : e.currentTarget; + // In here, "this" is the element + var range, selection; + if (window.getSelection) { + selection = window.getSelection(); + range = document.createRange(); + range.selectNodeContents(t); + selection.removeAllRanges(); + selection.addRange(range); + } else if (document.body.createTextRange) { + range = document.body.createTextRange(); + range.moveToElementText(t); + range.select(); + } +}; +var getURLVars = function getURLVars() { + var oResult = {}; + if (location.search.length > 0) { + var aQueryString = location.search.substr(1).split("&"); + for (var i = 0; i < aQueryString.length; i++) { + var aTemp = aQueryString[i].split("="); + if (aTemp[1].length > 0) { + oResult[aTemp[0]] = decodeURIComponent(aTemp[1].replace(/\+/g, '%20')); + } + } + } + return oResult; +}; module.exports = { - url: (() => { - var v = {}; - if (location.search.length > 0) { - var qs = (location.search.substr(1)).split("&"); - for (var i = 0; i < qs.length; i++) { - var t = qs[i].split("="); - if (t[1].length > 0) { - v[t[0]] = decodeURIComponent(t[1].replace(/\+/g, '%20')); - } - } - } - return v; - })(), - cookie: { - set: (name, value, expires, path, domain, secure) => { - switch(typeof expires) { - case "number" : - var d = new Date() - expires = d.setTime(d + (expires*24*60*60*1000)); - break; - case "object" : - expires = expires.toGMTString(); - } - document.cookie= name + "=" + escape(value) + - ((expires) ? "; expires=" + expires : "") + - ("; path=/") + - ((domain) ? "; domain=" + domain : "") + - ((secure) ? "; secure" : ""); - }, - get: (cname) => { - var name = cname + "="; - var ca = document.cookie.split(";"); - for(var i = 0; i { - setCookie(cname, "", -1); - }, - }, - colour: { + url: function () { + var v = {}; + if (location.search.length > 0) { + var qs = location.search.substr(1).split("&"); + for (var i = 0; i < qs.length; i++) { + var t = qs[i].split("="); + if (t[1].length > 0) { + v[t[0]] = decodeURIComponent(t[1].replace(/\+/g, '%20')); + } + } + } + return v; + }(), + cookie: { + set: function set(name, value, expires, path, domain, secure) { + switch (_typeof(expires)) { + case "number": + var d = new Date(); + expires = d.setTime(d + expires * 24 * 60 * 60 * 1000); + break; + case "object": + expires = expires.toGMTString(); + } + document.cookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") + "; path=/" + (domain ? "; domain=" + domain : "") + (secure ? "; secure" : ""); + }, + get: function get(cname) { + var name = cname + "="; + var ca = document.cookie.split(";"); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) === " ") { + c = c.substring(1); + } + if (c.indexOf(name) === 0) { + return c.substring(name.length, c.length); + } + } + return ""; + }, + remove: function remove(cnane) { + setCookie(cname, "", -1); + } + }, + colour: { + copy: function copy(w, t) { + var c = t.parentNode.getAttribute("data-" + (w == "var" ? "token" : w)); + c = w == "var" ? "var(".concat(c, ")") : c; + if (navigator.clipboard) { + navigator.clipboard.writeText(c).then(function () { + showMessage("Copied ".concat(w, ".")); + }, function (e) { + copyColourFallback(c, w); + }); + } else { + copyColourFallback(c, w); + } + }, + positionTooltip: function positionTooltip() { + document.querySelectorAll("color-pill > span").forEach(function (ps) { + ps.querySelectorAll("div.tooltip-tc").forEach(function (tip) { + if (font.size * 10 > ps.offsetLeft) { + tip.setAttribute("tip-position", "right"); + } else { + tip.setAttribute("tip-position", "bottom"); + } + }); + }); + } + }, + // getCSS: (el, prop, b = false) { + // return window.getComputedStyle(el, null).getPropertyValue(prop); + // }, + init: function init() { + var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var url = getURLVars(); + font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px", "")); + if (url.p !== undefined) { + document.querySelectorAll("main article:not([data-path^='" + url.p + "'])").forEach(function (a) { + a.remove(); + }); + if (url.p == -1) { + document.querySelector("title").innerHTML = "".concat(url.p.toContent().toTitleCase(), " | ").concat(document.querySelector("title").getAttribute("data-site")); + } else { + var theTitle = document.querySelectorAll("article"); + if (theTitle.length > 0) { + theTitle = theTitle[0].getAttribute("data-name").toContent().toTitleCase(); + if (document.querySelector("article").getAttribute("data-display") !== null) { + theTitle = document.querySelector("article").getAttribute("data-display"); + } + document.querySelector("title").innerHTML = "".concat(theTitle, " | ").concat(document.querySelector("title").getAttribute("data-site")); + } + } + } + if (typeof args.beforeArticleLoad == "function") args.beforeArticleLoad(); + document.querySelectorAll("article").forEach(function (a) { + if (a.getAttribute("data-template") != "none") { + var observer = new IntersectionObserver(function (articles) { + articles.forEach(function (article) { + var a = article.target; - copy: (w, t) => { - let c = t.parentNode.getAttribute("data-" + (w=="var" ? "token" : w)); - c = w == "var" ? `var(${c})` : c; + // console.log("observing: ", { id: a.getAttribute("id"), intersecting: a.isIntersecting } ) + // if (article.intersectionRatio > 0) { + // console.log("Is interesecting: ", { id: article.target.getAttribute("id"), intersecting: article.isIntersecting, ratio: article.intersectionRatio } ) - if (navigator.clipboard) { - navigator.clipboard.writeText(c).then(function() { - showMessage(`Copied ${w}.`); - }, function(e) { - copyColourFallback(c,w); - }); - } else { - copyColourFallback(c, w); - } - }, - - positionTooltip: () => { - document.querySelectorAll("color-pill > span").forEach((ps) => { - ps.querySelectorAll("div.tooltip-tc").forEach((tip) => { - if ( (font.size * 10) > ps.offsetLeft ) { - tip.setAttribute("tip-position", "right"); - } else { - tip.setAttribute("tip-position", "bottom"); - } - }); - }) - } - }, - // getCSS: (el, prop, b = false) { - // return window.getComputedStyle(el, null).getPropertyValue(prop); - // }, - init: (args = {}) => { - const url = getURLVars(); - font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px","")); - if (url.p !== undefined) { - document.querySelectorAll("main article:not([data-path^='" + url.p + "'])").forEach((a) => { - a.remove(); - }); - - if (url.p == -1) { - document.querySelector("title").innerHTML = `${url.p.toContent().toTitleCase()} | ${ document.querySelector("title").getAttribute("data-site") }`; - } else { - document.querySelector("title").innerHTML = `${url.p.substring(url.p.lastIndexOf("/")+1).toContent().toTitleCase()} | ${ document.querySelector("title").getAttribute("data-site") }` - } - } - - if (typeof args.beforeArticleLoad == "function") args.beforeArticleLoad(); - - document.querySelectorAll("article").forEach((a) => { - if ( a.getAttribute("data-template") != "none" ) { - const observer = new IntersectionObserver(articles => { - articles.forEach(article => { - let a = article.target; - - // console.log("observing: ", { id: a.getAttribute("id"), intersecting: a.isIntersecting } ) - // if (article.intersectionRatio > 0) { - // console.log("Is interesecting: ", { id: article.target.getAttribute("id"), intersecting: article.isIntersecting, ratio: article.intersectionRatio } ) - - if (article.isIntersecting == true) { - let path = a.getAttribute("data-path"); - path = "patterns/" + - (a.getAttribute("data-core") == "true" ? - "core/" + path.substring(path.lastIndexOf("/") + 1) : - a.getAttribute("data-path")) - + "/index.html"; - const ASYNC = true; - let ajx = new XMLHttpRequest(); - ajx.onreadystatechange = () => { - if (ajx.readyState == 4) { - observer.unobserve(article.target); - switch (ajx.status) { - case 200: - a.innerHTML = a.innerHTML + ajx.responseText; - a.style.height = "auto" - switch (a.getAttribute("data-template")) { - case "pug": - a.querySelectorAll("pre").forEach((aa) => { - aa.innerHTML = `${aa.innerHTML}`; - }) - break; - case "md": - a.querySelectorAll("code").forEach((aa) => { - aa.classList.add("language-html"); - }) - break; - } - - a.querySelectorAll("code").forEach((c)=> { - c.classList.add("line-numbers"); - c.innerHTML = c.innerHTML.replace(/ { - c.onclick = (e) => { - oneClickSelect(e); - } - }) - - - module.exports.colour.positionTooltip(); - window.onresize = () => { - module.exports.colour.positionTooltip(); - } - - a.querySelectorAll("name > span, color-pill > span").forEach((pill) => { - pill.onclick = (e) => { - e.preventDefault(); - let w = ""; - if (e.metaKey || e.ctrlKey || e.keyCode == 91 || e.keyCode == 224) { - w = "var"; - } else if (e.altKey) { - w = "token" - } else if (e.shiftKey) { - w = "rgb"; - } else { - w = "hex"; - } - module.exports.colour.copy(w, pill); - } - }) - break; - - case 404: - if (typeof args.notFound == "function") args.notFound(a, path); - break; - - default: - console.log("uncaught http error", { status: ajx.status, path: a.getAttribute("data-path") }); - } - - a.style.height = "auto"; - - if (typeof args.done == "function") args.done(a); - - } - }; - ajx.open("GET", path, ASYNC); - ajx.send(); - - } - }) - }, { threshold: 0, rootMargin: "100%" }) - - observer.observe(a); - - } else { - a.style.height = "auto"; - } - }) - - if (typeof args.afterArticleLoad == "function") args.afterArticleLoad(); - } + if (article.isIntersecting == true) { + var path = a.getAttribute("data-path"); + path = "patterns/" + (a.getAttribute("data-core") == "true" ? "core/" + path.substring(path.lastIndexOf("/") + 1) : a.getAttribute("data-path")) + "/index.html"; + var ASYNC = true; + var ajx = new XMLHttpRequest(); + ajx.onreadystatechange = function () { + if (ajx.readyState == 4) { + observer.unobserve(article.target); + switch (ajx.status) { + case 200: + a.innerHTML = a.innerHTML + ajx.responseText; + a.style.height = "auto"; + switch (a.getAttribute("data-template")) { + case "pug": + a.querySelectorAll("pre").forEach(function (aa) { + aa.innerHTML = "").concat(aa.innerHTML, ""); + }); + break; + case "md": + a.querySelectorAll("code").forEach(function (aa) { + aa.classList.add("language-html"); + }); + break; + } + a.querySelectorAll("code").forEach(function (c) { + c.classList.add("line-numbers"); + c.innerHTML = c.innerHTML.replace(/ span, color-pill > span").forEach(function (pill) { + pill.onclick = function (e) { + e.preventDefault(); + var w = ""; + if (e.metaKey || e.ctrlKey || e.keyCode == 91 || e.keyCode == 224) { + w = "var"; + } else if (e.altKey) { + w = "token"; + } else if (e.shiftKey) { + w = "rgb"; + } else { + w = "hex"; + } + module.exports.colour.copy(w, pill); + }; + }); + break; + case 404: + if (typeof args.notFound == "function") args.notFound(a, path); + break; + default: + console.log("uncaught http error", { + status: ajx.status, + path: a.getAttribute("data-path") + }); + } + a.style.height = "auto"; + if (typeof args.done == "function") args.done(a); + } + }; + ajx.open("GET", path, ASYNC); + ajx.send(); + } + }); + }, { + threshold: 0, + rootMargin: "100%" + }); + observer.observe(a); + } else { + a.style.height = "auto"; + } + }); + if (typeof args.afterArticleLoad == "function") args.afterArticleLoad(); + } }; /***/ }), @@ -3028,136 +3010,135 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ init: function() { return /* binding */ init; } /* harmony export */ }); +function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } +function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } +function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } +function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } +function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } //- DS2 core (c) 2024 Alexander McIlwraith //- Licensed under CC BY-SA 4.0 -const font = { - size: 0 -} - -const pos = { - x: 0, - y: 0 -} - +var font = { + size: 0 +}; +var pos = { + x: 0, + y: 0 +}; function drag(sticky) { - sticky.onmousedown = event => { - // get the position within the sticky - pos.x = (event.clientX - sticky.offsetLeft); - pos.y = (event.clientY - sticky.offsetTop); + sticky.onmousedown = function (event) { + // get the position within the sticky + pos.x = event.clientX - sticky.offsetLeft; + pos.y = event.clientY - sticky.offsetTop; - // on mouse move, move the sticky to the position, minus the offset, of the mouse - document.onmousemove = documentEvent => { - sticky.style.top = (documentEvent.clientY - pos.y) + 'px'; - sticky.style.left = (documentEvent.clientX - pos.x) + 'px'; - sticky.setAttribute("moved", "true"); - } - // when done, remove mouse move and mouse up handlers. - document.onmouseup = () => { - document.onmouseup = null; - document.onmousemove = null; - } - } + // on mouse move, move the sticky to the position, minus the offset, of the mouse + document.onmousemove = function (documentEvent) { + sticky.style.top = documentEvent.clientY - pos.y + 'px'; + sticky.style.left = documentEvent.clientX - pos.x + 'px'; + sticky.setAttribute("moved", "true"); + }; + // when done, remove mouse move and mouse up handlers. + document.onmouseup = function () { + document.onmouseup = null; + document.onmousemove = null; + }; + }; } - function waitForElement(selector) { - return new Promise(resolve => { - if (document.querySelector(selector)) { - return resolve(document.querySelector(selector)); - } - - const observer = new MutationObserver(mutations => { - if (document.querySelector(selector)) { - observer.disconnect(); - resolve(document.querySelector(selector)); - } - }); - - // If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336 - observer.observe(document.body, { - childList: true, - subtree: true - }); + return new Promise(function (resolve) { + if (document.querySelector(selector)) { + return resolve(document.querySelector(selector)); + } + var observer = new MutationObserver(function (mutations) { + if (document.querySelector(selector)) { + observer.disconnect(); + resolve(document.querySelector(selector)); + } }); + + // If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336 + observer.observe(document.body, { + childList: true, + subtree: true + }); + }); } - -const checkBottom = (attach) => { - // check if top or bottom - if (attach.y < 0) { - attach.ys = "bottom"; - attach.y = attach.y * -1; - } -} - -const setStickyPostions = (s, attach) => { - // set - s.style[attach.ys] = `${attach.y}px`; - s.style[attach.xs] = `${attach.x}px`; - s.style.display = "grid"; -} - -const css = (el, attr) => { - let st = "" - Object.entries(attr).forEach(val => { - const [key, value] = val; - st += `${key}: ${value}; `; - }) - el.setAttribute("style",st.trim()); -} - - -const calculateStickyPosition = (s) => { - let float = s.getAttribute("float"); - let p = s.parentNode.getBoundingClientRect() - switch (float) { - case "left": - css(s, {left: (p.left * -1) + "px"}) - break; - case "right": - css(s, { left: (Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0) - p.left - s.offsetWidth - (font.size * 2)) + "px" }); - break; - } - - let offset = s.getAttribute("offset"); - if (offset !== null) { - offset = offset.trim().split(" "); - css(s, {top: offset[0], left: offset[1] }) - } -} - -function init(p = document){ - font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px","")); - - p.querySelectorAll("sticky-note").forEach((s) => { - if (s.querySelectorAll("svg").length == 0) { - - let wrapper = document.createElement("sticky-note-wrapper"); - - s.parentNode.insertBefore(wrapper, s); - wrapper.appendChild(s); - - s.setAttribute("content", s.innerHTML.replace(/"/g, "\"")); - s.innerHTML = `
${s.innerHTML}
`; - } - calculateStickyPosition(s); - drag(s); - s.ondblclick = (e) => { - if (e.ctrlKey) { - calculateStickyPosition(s); - } else { - // add one click select - } - } - }) - - - window.onresize = () => { - font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px","")); - let stickies = p.querySelectorAll("sticky-note"); - stickies.forEach((s) => { - calculateStickyPosition(s); - }); - } +var checkBottom = function checkBottom(attach) { + // check if top or bottom + if (attach.y < 0) { + attach.ys = "bottom"; + attach.y = attach.y * -1; + } +}; +var setStickyPostions = function setStickyPostions(s, attach) { + // set + s.style[attach.ys] = "".concat(attach.y, "px"); + s.style[attach.xs] = "".concat(attach.x, "px"); + s.style.display = "grid"; +}; +var css = function css(el, attr) { + var st = ""; + Object.entries(attr).forEach(function (val) { + var _val = _slicedToArray(val, 2), + key = _val[0], + value = _val[1]; + st += "".concat(key, ": ").concat(value, "; "); + }); + el.setAttribute("style", st.trim()); +}; +var calculateStickyPosition = function calculateStickyPosition(s) { + var float = s.getAttribute("float"); + var p = s.parentNode.getBoundingClientRect(); + switch (float) { + case "left": + css(s, { + left: p.left * -1 + "px" + }); + break; + case "right": + css(s, { + left: Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0) - p.left - s.offsetWidth - font.size * 2 + "px" + }); + break; + } + var offset = s.getAttribute("offset"); + if (offset !== null) { + offset = offset.trim().split(" "); + css(s, { + top: offset[0], + left: offset[1] + }); + } +}; +function init() { + var p = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; + font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px", "")); + p.querySelectorAll("sticky-note").forEach(function (s) { + if (s.querySelectorAll("svg").length == 0) { + var wrapper = document.createElement("sticky-note-wrapper"); + s.parentNode.insertBefore(wrapper, s); + wrapper.appendChild(s); + s.setAttribute("content", s.innerHTML.replace(/"/g, "\"")); + s.innerHTML = "
".concat(s.innerHTML, "
"); + } + calculateStickyPosition(s); + drag(s); + s.ondblclick = function (e) { + if (e.ctrlKey) { + calculateStickyPosition(s); + } else { + // add one click select + } + }; + }); + window.onresize = function () { + font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px", "")); + var stickies = p.querySelectorAll("sticky-note"); + stickies.forEach(function (s) { + calculateStickyPosition(s); + }); + }; } /***/ }), @@ -3168,29 +3149,29 @@ function init(p = document){ //- Licensed under CC BY-SA 4.0 function flip(e) { - let sw = e.currentTarget; - switch(sw.getAttribute("aria-checked")) { - case "true": - sw.setAttribute("aria-checked", "false"); - break; - case "false": - sw.setAttribute("aria-checked", "true"); - break; - } -}; - -module.exports = { - init: (p = document) => { - p.querySelectorAll("[role='switch']").forEach((sw) => { - sw.innerHTML = ""; - sw.setAttribute("aria-checked", "false"); - sw.setAttribute("tabindex", "0"); - sw.addEventListener("click", flip, false); - sw.addEventListener("keypress", flip, false); - }) - } + var sw = e.currentTarget; + switch (sw.getAttribute("aria-checked")) { + case "true": + sw.setAttribute("aria-checked", "false"); + break; + case "false": + sw.setAttribute("aria-checked", "true"); + break; + } } - +; +module.exports = { + init: function init() { + var p = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; + p.querySelectorAll("[role='switch']").forEach(function (sw) { + sw.innerHTML = ""; + sw.setAttribute("aria-checked", "false"); + sw.setAttribute("tabindex", "0"); + sw.addEventListener("click", flip, false); + sw.addEventListener("keypress", flip, false); + }); + } +}; /***/ }), /* 10 */ @@ -3206,69 +3187,66 @@ __webpack_require__.r(__webpack_exports__); */ // create a pure JS mouse click event -const click = new MouseEvent('click', { - view: window, - bubbles: false, - cancelable: true +var click = new MouseEvent('click', { + view: window, + bubbles: false, + cancelable: true }); - -function init(p = document, s = true) { - p.querySelectorAll(".tab-group, tabset").forEach(tabGroup => { - - if (tabGroup.querySelector("[role=tablist]") === null) { - const tabgroup = tabGroup.getAttribute("id"); - let tablist = ""; - - Array.from(tabGroup.children).forEach(child => { - const tab = child.getAttribute("tab") || child.getAttribute("data-tab"); - if (tab !== null) { - const tabID = tab.replace(/\W+/g, "-").toLowerCase(); - const tabPanel = document.createElement('div'); - tabPanel.id = `tab-panel-${tabgroup}-${tabID}`; - tabPanel.className = tablist === "" ? "open" : ""; - tabPanel.setAttribute("role", "tabpanel"); - tabPanel.setAttribute("tabindex", "0"); - tabPanel.setAttribute("aria-labelledby", `tab-${tabgroup}-${tabID}`); - tabPanel.appendChild(child.cloneNode(true)); - child.parentNode.replaceChild(tabPanel, child); - tablist += ``; - } else { - child.classList.add("tab-hidden"); - } - }); - - const ul = document.createElement('ul'); - ul.setAttribute("role", "tablist"); - ul.innerHTML = s != true ? `${tablist}` : `${tablist}`; - tabGroup.insertBefore(ul, tabGroup.firstChild); - - tabGroup.querySelectorAll('[role="tab"]').forEach(tab => { - tab.addEventListener("click", () => { - const siblings = Array.from(tab.parentNode.children); - siblings.forEach(sibling => sibling.classList.remove("selected")); - tab.classList.add("selected"); - - const tabPanels = Array.from(tab.parentNode.parentNode.children) - .filter(child => child.getAttribute("role") === "tabpanel"); - tabPanels.forEach(panel => panel.classList.remove("open")); - - const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel"); - document.getElementById(tabPanelId).classList.add("open"); - }); - - - tab.addEventListener("keypress", (e) => { - e.preventDefault(); - if( e.which == 32 || e.which == 13 ) { - e.currentTarget.dispatchEvent(click); - } - }) - }); - } - }); +function init() { + var p = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; + var s = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + p.querySelectorAll(".tab-group, tabset").forEach(function (tabGroup) { + if (tabGroup.querySelector("[role=tablist]") === null) { + var tabgroup = tabGroup.getAttribute("id"); + var tablist = ""; + Array.from(tabGroup.children).forEach(function (child) { + var tab = child.getAttribute("tab") || child.getAttribute("data-tab"); + if (tab !== null) { + var tabID = tab.replace(/\W+/g, "-").toLowerCase(); + var tabPanel = document.createElement('div'); + tabPanel.id = "tab-panel-".concat(tabgroup, "-").concat(tabID); + tabPanel.className = tablist === "" ? "open" : ""; + tabPanel.setAttribute("role", "tabpanel"); + tabPanel.setAttribute("tabindex", "0"); + tabPanel.setAttribute("aria-labelledby", "tab-".concat(tabgroup, "-").concat(tabID)); + tabPanel.appendChild(child.cloneNode(true)); + child.parentNode.replaceChild(tabPanel, child); + tablist += "
  • ").concat(tab, "
  • "); + } else { + child.classList.add("tab-hidden"); + } + }); + var ul = document.createElement('ul'); + ul.setAttribute("role", "tablist"); + ul.innerHTML = s != true ? "".concat(tablist) : "".concat(tablist, "
  • "); + tabGroup.insertBefore(ul, tabGroup.firstChild); + tabGroup.querySelectorAll('[role="tab"]').forEach(function (tab) { + tab.addEventListener("click", function () { + var siblings = Array.from(tab.parentNode.children); + siblings.forEach(function (sibling) { + return sibling.classList.remove("selected"); + }); + tab.classList.add("selected"); + var tabPanels = Array.from(tab.parentNode.parentNode.children).filter(function (child) { + return child.getAttribute("role") === "tabpanel"; + }); + tabPanels.forEach(function (panel) { + return panel.classList.remove("open"); + }); + var tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel"); + document.getElementById(tabPanelId).classList.add("open"); + }); + tab.addEventListener("keypress", function (e) { + e.preventDefault(); + if (e.which == 32 || e.which == 13) { + e.currentTarget.dispatchEvent(click); + } + }); + }); + } + }); } - /***/ }) /******/ ]); /************************************************************************/ @@ -3389,51 +3367,46 @@ __webpack_require__.r(__webpack_exports__); // init core _core_core_js__WEBPACK_IMPORTED_MODULE_0__.init({ - success: (a) => { - _pg_patterns_core_tabs_tabs_js__WEBPACK_IMPORTED_MODULE_9__.init(a); - _pg_patterns_core_switch_switch_js__WEBPACK_IMPORTED_MODULE_8__.init(a); - _pg_patterns_core_sticky_note_sticky_note_js__WEBPACK_IMPORTED_MODULE_7__.init(a); - }, - notFound: (a, path) => { - a.innerHTML = `${a.innerHTML}

    This pattern appears to be missing.
    (${path} returned http status 404)

    `; - } + success: function success(a) { + _pg_patterns_core_tabs_tabs_js__WEBPACK_IMPORTED_MODULE_9__.init(a); + _pg_patterns_core_switch_switch_js__WEBPACK_IMPORTED_MODULE_8__.init(a); + _pg_patterns_core_sticky_note_sticky_note_js__WEBPACK_IMPORTED_MODULE_7__.init(a); + }, + notFound: function notFound(a, path) { + a.innerHTML = "".concat(a.innerHTML, "

    This pattern appears to be missing.
    (").concat(path, " returned http status 404)

    "); + } }); // deprecated switch handler -const flipInfoSwitch = (e, s = e.currentTarget) => { - - switch(s.getAttribute("id")) { - - case "deprecated" : - _core_core_js__WEBPACK_IMPORTED_MODULE_0__.cookie.set("show-deprecated", s.getAttribute("aria-checked"), 30, "/"); - document.querySelector("main").querySelectorAll("article[data-status=deprecated]").forEach((a) => { - a.classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-deprecated"); - }); - break; - - case "breakpoints" : - console.log("here") - _core_core_js__WEBPACK_IMPORTED_MODULE_0__.cookie.set("show-breakpoints", s.getAttribute("aria-checked"), 30, "/"); - document.querySelector("html").classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-breakpoints"); - break; - } - -} +var flipInfoSwitch = function flipInfoSwitch(e) { + var s = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : e.currentTarget; + switch (s.getAttribute("id")) { + case "deprecated": + _core_core_js__WEBPACK_IMPORTED_MODULE_0__.cookie.set("show-deprecated", s.getAttribute("aria-checked"), 30, "/"); + document.querySelector("main").querySelectorAll("article[data-status=deprecated]").forEach(function (a) { + a.classList[s.getAttribute("aria-checked") == "true" ? "add" : "remove"]("show-deprecated"); + }); + break; + case "breakpoints": + console.log("here"); + _core_core_js__WEBPACK_IMPORTED_MODULE_0__.cookie.set("show-breakpoints", s.getAttribute("aria-checked"), 30, "/"); + document.querySelector("html").classList[s.getAttribute("aria-checked") == "true" ? "add" : "remove"]("show-breakpoints"); + break; + } +}; // create a pure JS mouse click event -const click = new MouseEvent('click', { - view: window, - bubbles: false, - cancelable: true +var click = new MouseEvent('click', { + view: window, + bubbles: false, + cancelable: true }); // get the switch, initialize it and add the handler -let switches = document.querySelector(".info-switches"); +var switches = document.querySelector(".info-switches"); _pg_patterns_core_switch_switch_js__WEBPACK_IMPORTED_MODULE_8__.init(switches); - -let deprecated = document.querySelector("#deprecated"); -let breakpoints = document.querySelector("#breakpoints"); - +var deprecated = document.querySelector("#deprecated"); +var breakpoints = document.querySelector("#breakpoints"); deprecated.onclick = flipInfoSwitch; deprecated.keypress = flipInfoSwitch; breakpoints.onclick = flipInfoSwitch; @@ -3441,15 +3414,14 @@ breakpoints.keypress = flipInfoSwitch; // check a cookie to get the switch's state if (_core_core_js__WEBPACK_IMPORTED_MODULE_0__.cookie.get("show-deprecated") == "true") { - deprecated.dispatchEvent(click); + deprecated.dispatchEvent(click); } if (_core_core_js__WEBPACK_IMPORTED_MODULE_0__.cookie.get("show-breakpoints") == "true") { - breakpoints.dispatchEvent(click); + breakpoints.dispatchEvent(click); } // just for fun... We'll show deprecated if they match the path // document.querySelector(`#${core.url.p.replace(/\//g, "-")}`).classList.add("show-deprecated"); - }(); /******/ })() ; \ No newline at end of file diff --git a/src/js/core/_core.js b/src/js/core/_core.js index 7c032fc..9f785b0 100644 --- a/src/js/core/_core.js +++ b/src/js/core/_core.js @@ -192,11 +192,14 @@ module.exports = { if (url.p == -1) { document.querySelector("title").innerHTML = `${url.p.toContent().toTitleCase()} | ${ document.querySelector("title").getAttribute("data-site") }`; } else { - let theTitle = docuemnt.querySelector("article").getAttribute("data-name").toContent().toTitleCase(); - if (docuemnt.querySelector("article").getAttribute("data-display") !== null) { - theTitle = docuemnt.querySelector("article").getAttribute("data-display") + let theTitle = document.querySelectorAll("article"); + if (theTitle.length > 0) { + theTitle = theTitle[0].getAttribute("data-name").toContent().toTitleCase(); + if (document.querySelector("article").getAttribute("data-display") !== null) { + theTitle = document.querySelector("article").getAttribute("data-display") + } + document.querySelector("title").innerHTML = `${theTitle} | ${ document.querySelector("title").getAttribute("data-site") }` } - document.querySelector("title").innerHTML = `${theTitle} | ${ document.querySelector("title").getAttribute("data-site") }` } }