A minimalistic javascript for the jquery babied...
It uses querySelectorAll or getElementById to get a DOM-Node.
| Date | Version | Info |
|---|---|---|
| 14.12.2018 | 1.2 | merged some changes from smdQS, cleanup |
| 08.03.2018 | 1.1 | merged changes from smdQS, added demo files |
| 15.01.2018 | 1.0 | initial fork of smdQS, dropped nativeOS code |
- ajax() call:
sQS().ajax({
url: "/testscript.php", //required
method: "GET",
data: {},
callback: function( returnData ) { //required
console.log(returnData);
},
errorCallback: function( XMLHttpRequest ) {
console.log(XMLHttpRequest);
}
}); - ready() - Execute something on document ready:
sQS().ready(function() {
console.log("document is ready");
}- requireJS() - load an other js:
sQS().requireJS("/js/somejsfile.js", function() {
console.log("js file is loaded.");
}- requireCSS() - load an other css:
sQS().requireCSS("/css/somecssfile.css", function() {
console.log("css file is loaded.");
}- working with classes and selectors:
var myNode = smdQS("#idOfMyNode");
if (myNode.hasClass("aNiceClass")) {
myNode.removeClass("aNiceClass");
}- working with a array of nodes:
var aListOfNodes = smdQS(".btn");
if (aListOfNodes !== null) {
var isAList = aListOfNodes.isList;
//...
aListOfNodes.forEach(function(oneOfThisNodes, index, array)
{
oneOfThisNodes.removeAttribute("onclick");
oneOfThisNodes.addEventListener("click", function()
{
console.log("You have clicked on the button with the index " + index);
});
});
} If the javascript variable sQS_jsHost is set, sQS().ajax() uses it as hostname to call all requests to. If a url has already a hostname the variable is ignored.
This version includes a forked version of docReady (https://github.com/jfriend00/docReady)
Matthias Weiß