This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
/** | |
* Core method, similar to jQuery (only simpler) | |
* | |
* @param {String|HTMLElement} s The CSS selector to search for or HTML element to wrap with functionality | |
* @param {HTMLElement} root OPTIONAL An HTML element to start the element query from | |
* @return {Array} The collection of elements, wrapped with functionality (see API methods) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="checkbox" class="toggle" checked> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="checkbox" class="toggle" checked> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function $(el) { | |
const type = el.charAt(0); | |
switch (type) { | |
case "#": | |
return document.querySelector(el); | |
break; | |
case ".": | |
return document.querySelectorAll(el); | |
break; | |
default: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="poll"> | |
<div class="question"></div> | |
<div class="answers"></div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function jsonFetch(url, options) { | |
if (options.json) { | |
options.body = JSON.stringify(options.body); | |
options.headers = { | |
...options.headers, | |
"Content-Type": "application/json", | |
}; | |
delete options.json; | |
} | |
return await fetch(url, options); |