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
| /** | |
| * Creates a new HTML element. | |
| * @author Christoph Zager | |
| * @license CC0-1.0 | |
| * @param {string} definition The tag of the desired HTML element and optionally an Id and css classes, in a _query selector_ like notation (i.e. `"div#id.class1.class2"`). | |
| * @param {...string | number | HTMLElement | {[key: string]: string | number | boolean | Function} } [content] Content (or children) to be created on/in the HTML element. This may be text content, child HTML elements or a record of attributes or event handlers. | |
| * @returns {HTMLElement} Returns the newly created HTML element with all its content and children. | |
| */ | |
| function makeElement (definition, ...content) | |
| { |
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
| function stringHash (string) | |
| { | |
| /* This is based on https://github.com/darkskyapp/string-hash | |
| Since the basic code is public domain, this function is public domain as well. | |
| */ | |
| let hash, i = string.length; | |
| while (i) | |
| { | |
| hash = (hash * 33) ^ string.charCodeAt(--i); | |
| }; |
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
| /** | |
| * Returns a hash code for a string. | |
| * (Compatible to Java's String.hashCode()) | |
| * | |
| * The hash code for a string object is computed as | |
| * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] | |
| * using number arithmetic, where s[i] is the i th character | |
| * of the given string, n is the length of the string, | |
| * and ^ indicates exponentiation. | |
| * (The hash value of the empty string is zero.) |