This file contains hidden or 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
| var countries = { | |
| AF: 'Afghanistan', | |
| AX: 'Aland Islands', | |
| AL: 'Albania', | |
| DZ: 'Algeria', | |
| AS: 'American Samoa', | |
| AD: 'Andorra', | |
| AO: 'Angola', | |
| AI: 'Anguilla', | |
| AQ: 'Antarctica', |
This file contains hidden or 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
| const closest = (elem, className) => { | |
| if (elem==null || elem.classList==null) return null | |
| return (elem.classList.contains(className) ? elem : closest(elem.parentNode, className)) | |
| } |
This file contains hidden or 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
| const each = (data, fn) => { | |
| if (data==null) return false | |
| if ((data).constructor===Object) return Array.prototype.forEach.call(Object.keys(data), (key) => fn(data[key], key, data)) | |
| else return Array.prototype.forEach.call(data, (item, i) => fn(item, i, data)) | |
| } |
This file contains hidden or 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
| const type = (data) => { | |
| return Object.prototype.toString.call(data).replace(/^\[object (.+)\]$/, "$1").toLowerCase() | |
| } |
This file contains hidden or 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
| const ajaxform = (form, next) => { | |
| let url = form.action | |
| let xhr = new XMLHttpRequest() | |
| let data = new FormData(form) | |
| xhr.open('POST', url) | |
| xhr.onload = () => next(form, xhr) | |
| xhr.send(data) |
This file contains hidden or 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
| html = (literalSections, ...substs) => { | |
| // Use raw literal sections: We don’t want | |
| // backslashes (\n etc.) to be interpreted | |
| let raw = literalSections.raw, | |
| let result = '' | |
| substs.forEach((subst, i) => { | |
| // Retrieve the literal section preceding |
This file contains hidden or 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
| escapeHTML = (html = '') => { | |
| // Ensure that html is a string | |
| html += '' | |
| // Escape all critical characters | |
| html = html.replace(/&/g, '&') | |
| .replace(/</g, '<') | |
| .replace(/>/g, '>') | |
| .replace(/"/g, '"') |
This file contains hidden or 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
| const scrollroot = (() => { | |
| if ('scrollingElement' in document) return document.scrollingElement | |
| const initial = document.documentElement.scrollTop | |
| document.documentElement.scrollTop = initial + 1 | |
| const updated = document.documentElement.scrollTop | |
| document.documentElement.scrollTop = initial | |
This file contains hidden or 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
| const stopEvent = (e = {}) => { | |
| if (typeof e.stopPropagation==='function') e.stopPropagation() | |
| if (typeof e.preventDefault==='function') e.preventDefault() | |
| } |
This file contains hidden or 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
| const limit = (min, max, num) => Math.min(Math.max(num, min), max) |
OlderNewer