-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
393 additions
and
356 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,22 +5,27 @@ To install just `<script src="https://unpkg.com/@c3r38r170/c3tools"></script>`. | |
|
||
Specifying a version is recommended. [More info about unpkg.](https://unpkg.com/) | ||
|
||
By default, `c3tools-min.js` will be loaded (non-module version). You must specify `/c3tools-min.m.js` after the version, for the module version. | ||
|
||
For example: `<script src="https://unpkg.com/@c3r38r170/[email protected]/c3tools-min.m.js"></script>` | ||
|
||
## TO DO | ||
- Make the module version the default. | ||
- Document functions here (with **examples**). | ||
- Better README. | ||
- The "Soon!" stuff. | ||
|
||
## Soon! | ||
`download` function. | ||
|
||
Group functions and variables in logical modules. | ||
|
||
Easy way to add functions to the 'DOMContentLoaded' event. | ||
|
||
Create .js.map files. | ||
|
||
Modal messages with premises. | ||
|
||
Module version. | ||
|
||
Reacting to DOM changes. | ||
|
||
--- | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
var Types={OTHER:-1,NUMBER:0,STRING:1,ARRAY:2,OBJECT:3,BOOLEAN:4,NULL:5};function is(e,t){if(null==e&&t==Types.NULL)return!0;let r={[Types.NUMBER]:["number",Number],[Types.STRING]:["string",String],[Types.BOOLEAN]:["boolean",Boolean]};switch(t){case Types.NUMBER:case Types.STRING:case Types.BOOLEAN:return r[t][0]==typeof e||e instanceof r[t][1];case Types.ARRAY:return Array.isArray(e);case Types.OBJECT:return"object"==typeof e&&!Array.isArray(e)}return t==Types.OTHER}function whatIs(e){switch(typeof e){case"number":return Types.NUMBER;case"string":return Types.STRING;case"object":switch(!0){case Array.isArray(e):return Types.ARRAY;case e instanceof String:return Types.STRING;case e instanceof Number:return Types.NUMBER;case null==e:return Types.NULL;default:return Types.OBJECT}default:return Types.OTHER}}const W=window,D=document,ALL=!0,ONLY_ONE=!1;var B;addEventListener("DOMContentLoaded",(()=>{B=D.body}));const gEt=e=>D.getElementById(e);function SqS(e,{n:t=false,from:r=D}={}){if(e instanceof Node)return e;if(t||(t=1),is(e,Types.STRING)){let n,s=e.slice(1);if(/[ :\[\.#,+~]/.test(s)){if(1===t)return r.querySelector(e);if(!0===t)return[...r.querySelectorAll(e)];n=r.querySelectorAll(e)}else switch(e[0]){case"#":return D.getElementById(s);case".":n=r.getElementsByClassName(s);break;case"[":let t=/^\[name="([^"]*)"\]$/.exec(e);t&&(n=D.getElementsByName(t[1]));break;case":":break;default:n=r.getElementsByTagName(e)}if(1===t)return n?n[0]:r.querySelector(e);{let s=[...n||r.querySelectorAll(e)];return!0===t?s:s.slice(0,t)}}throw new Error("The selector must be a string.")}function createElement(e,t,r){if(!e)throw new Error("Element is required.");let n,s,a;if(is(e,Types.ARRAY)&&([e,t,r]=e),is(e,Types.STRING)){if(!(e=e.trim()))throw new Error("Element is required.");e=D.createElement(e.toUpperCase())}if(!t||!t.nodeType&&is(t,Types.OBJECT)||(r=t,t=null),t)for(let r in t)switch(s=t[r],r){case"class":e.classList.add(s);break;case"classList":for(let t of s)e.classList.add(t);break;case"finalFun":n=s;break;case"children":a=D.createDocumentFragment(),addElement(a,...s);break;default:"on"==r.substring(0,2)&&is(s,Types.STRING)?s.match("[^a-zA-Z0-9_]")?e[r]=new Function(s):e[r]=W[s]:"on"!=r.substring(0,2)&&void 0===e[r]?e.setAttribute(r,s):is(s,Types.OBJECT)?Object.assign(e[r],s):e[r]=s;break}return r&&(a||(a=D.createDocumentFragment()),a.appendChild(r.nodeType?r:createElement(r))),a&&e.appendChild(a),n&&("string"==typeof n?new Function(n):n).call(e),e}function addElement(e,...t){if(!e instanceof HTMLElement)throw new Error("Parent must be an HTMLElement.");let r=[];for(let n of t)n&&r.push(e.appendChild(n.nodeType?n:createElement(n)));return r.length>1?r:r[0]}function sendJSON(e,t,r=null){let n={credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)};return fetch(e,r?Object.assign(n,r):n)}function*JSONAsURLEncodedStringIterator(e,t=null){let r=Array.isArray(e)?e.map((e=>["",e])):Object.entries(e);for(let[e,n]of r)e=t?t+"["+e+"]":e,null!=n&&"object"==typeof n?yield*JSONAsURLEncodedStringIterator(n,e):yield[e,n]}function JSONAsFormData(e){if(!is(e,Types.ARRAY)&&!is(e,Types.OBJECT))throw new Error('"obj" must be an array or object.');let t=new FormData;for(let r in e){let n=e[r];if(null==n||n instanceof File||"object"!=typeof n)t.append(r,n);else for(let e of JSONAsURLEncodedStringIterator(n,r))t.append(...e)}return t}function sendPOST(e,t,{returnType:r,otherOptions:n}={}){t instanceof FormData||(t=JSONAsFormData(t));let s={credentials:"include",method:"POST",body:t};n&&Object.assign(s,n);let a=fetch(e,s);return r?a.then((e=>e[r]())):a}function fetchConCredentials(e,t={},...r){return t.credentials="include",fetch(e,t,...r)} | ||
import*as c3 from"./c3tools.m.js";for(let o in c3)window[o]=c3[o];window.B=D.body; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.