Free javascript Hosting


jax-min.js

Uploaded on Feb 19 2022 21:18 by me

console.info("Jax: v1.3 | Jax Engine was initialised.");try{btoa}catch{btoa=function(a=""){return Buffer.from(a,"binary").toString("base64")},atob=function(a=""){return Buffer.from(a,"base64").toString()}}function getURLExtension(a){return a.split(/[#?]/)[0].split(".").pop().trim()}function isUrlValid(a){let e;try{e=new URL(a)}catch(f){return!1}return"http:"===e.protocol||"https:"===e.protocol}
var getFromBetween={results:[],string:"",getFromBetween:function(a,e){if(0>this.string.indexOf(a)||0>this.string.indexOf(e))return!1;a=this.string.indexOf(a)+a.length;var f=this.string.substr(0,a),p=this.string.substr(a);e=f.length+p.indexOf(e);return this.string.substring(a,e)},removeFromBetween:function(a,e){if(0>this.string.indexOf(a)||0>this.string.indexOf(e))return!1;a=a+this.getFromBetween(a,e)+e;this.string=this.string.replace(a,"")},getAllResults:function(a,e){if(!(0>this.string.indexOf(a)||
0>this.string.indexOf(e))){var f=this.getFromBetween(a,e);this.results.push(f);this.removeFromBetween(a,e);-1<this.string.indexOf(a)&&-1<this.string.indexOf(e)&&this.getAllResults(a,e)}},get:function(a,e,f){this.results=[];this.string=a;this.getAllResults(e,f);return this.results}},print=(a="")=>console.log(a);function removeBlank(a=""){for(;a.startsWith(" ");)a=a.substring(1,a.length);for(;a.endsWith(" ");)a=a.substring(0,a.length-1);return a}
var Log_Errors=!0,Target="",Transition="",AnimationDuration=1E3,tab="\t",compiled="",compiled_array=[],style="",style_started=!1,comment_started=!1,push_to_head=[],stop_recording_variable=!1,is_string=!1,variables=[],modules=[["Card",{jaxModule:{name:"Cool Card",callingName:"Card",startingElement:"div",css:{"background-color":"red",transition:"all 1s",padding:"5px"},selectors:{":hover":{background:"green","border-radius":"5px"}},"attribute-list":{enabled:!1,required:!0},"class-list":"true false",
innerContent:"This: (|) is the content!",hasClosingTag:!1}}]];
async function Jax(a=""){a.split("\n").forEach(async(d,b)=>{if(d.startsWith(":~")){var h=[],g=d,k="",m=!1,l=g,n="abcdefghijklmnopqrstuvwxyz0123456789_$\u00e9\u00e8".split("");g.split("").forEach((c,q)=>{"@"===c?m=!0:m&&(n.includes(c.toLowerCase())?q===l.split("").length-1?(k+=c,h.push(k),k="",m=!1):k+=c:(h.push(k),k="",m=!1))});h=h.reverse();var w=!0,x="";h.forEach(c=>{variables.forEach(q=>{q[0]===c&&(w=!1,x=q[1])});if(w)throw Log_Errors&&Jax.Console.Error("JaxReferenceError: '"+c+"' is not defined."),
Error("Jax Stopped because of an unhandeled Error...");g=g.replace("@"+c,`<span jxv="${btoa(c).replace(/=/g,"-")}">${x}</span>`)});compiled+=g.substring(2,g.length)}if(d.startsWith("~"))compiled+=d.substring(1,d.length),is_string=!0;else{var t="";b=d;for(var E=0,F=!1;b.endsWith(" ");)b=b.substring(0,b.length-1);b.endsWith(";")&&(F=!0,b=b.substring(0,b.length-1));for(;b.startsWith(tab);)E++,b=b.substring(1,b.length);if(style_started){style+="\n"+d;return}if(b.startsWith("#")){var y="";d=b.substring(1,
b.length-1).split("");n="abcdefghijklmnopqrstuvwxyz0123456789_$\u00e9\u00e8".split("");var G=!1;d.forEach(c=>{n.includes(c.toLowerCase())?G||(y+=c):G=!0});d=b;switch(y){case "include":d=d.substring(y.length+1,b.length);d=removeBlank(d);b=d.match(/(?<=<)(.+?)*(?=>)/)[0];b=removeBlank(b);if(""===b)throw Log_Errors&&Jax.Console.Error("JaxSyntaxError: No Module/Library has been provided after keyword: #include."),Error("Jax Stopped because of an unhandeled Error...");if(b.includes("<")||b.includes(">"))throw Log_Errors&&
Jax.Console.Error("JaxSyntaxError: A Jax Module(Name/Url) or Library cannot contain the characters '<' or '>'"),Error("Jax Stopped because of an unhandeled Error...");if(isUrlValid(b))switch(getURLExtension(b)){case "js":b=Jax.MakeTag("script","","",`src="${b}"`).join(""),push_to_head.push(b)}else try{await fetch("https://api.cdnjs.com/libraries?search="+encodeURI(b)).then(c=>c.json()).then(async c=>{console.log(c.results[0].latest);c=Jax.MakeTag("script","","",`src="${c.results[0].latest}"`).join("");
push_to_head.push(c)})}catch(c){throw Log_Errors&&Jax.Console.Error("JaxLibraryError: The library '"+b+"' was not found in cdnjs, please use a direct URL instead."+c),Error("Jax Stopped because of an unhandeled Error...");}break;case "define":d=d.substring(y.length+1,b.length);d=removeBlank(d);b=getFromBetween.get(d,"<",">")[0];b=removeBlank(b);var H=!1,I=!1,C="",D="";b.split("").forEach(c=>{","===c?H=!0:H?I?D+=c:" "!==c&&(I=!0,D+=c):C+=c});if(variables.includes([C,D]))throw Log_Errors&&Jax.Console.Error(`VariableError: '${C}' is already declared.`),
Error("Jax Stopped because of an unhandeled Error...");variables.push([C,D]);break;default:throw Log_Errors&&Jax.Console.Error(`JaxTypeError: '#${y}' is an invalid keyword!`),Error("Jax Stopped because of an unhandeled Error...");}}else if(!b.startsWith("*")){b=b.split("");var u=!1,z="",A="",B="",v=g="";b.forEach(c=>{if("$"===c)u=!0,v="$",B.endsWith(" ")||""===B||(B+=" ");else if("#"===c)u=!0,v="#",A.endsWith(" ")||""===A||(A+=" ");else if(":"===c)u=!0,v=":",g.endsWith(" ")||""===g||(g+=" ");else if("."===
c)u=!0,v=".",z.endsWith(" ")||""===z||(z+=" ");else if(" "===c)u=!0,v=":",g.endsWith(" ")||""===g||(g+=" ");else if("*"===c)comment_started=!0;else if(!comment_started)if(u)switch(v){case "$":B+=c;break;case "#":A+=c;break;case ".":z+=c;break;case ":":g+=c}else t+=c})}}void 0===g?g="":g;h=[];k="";m=!1;l=g;n="abcdefghijklmnopqrstuvwxyz0123456789_$\u00e9\u00e8".split("");g.split("").forEach((c,q)=>{"@"===c?m=!0:m&&(n.includes(c.toLowerCase())?q===l.split("").length-1?(k+=c,h.push(k),k="",m=!1):k+=c:
(h.push(k),k="",m=!1))});h=h.reverse();w=!0;x="";h.forEach(c=>{variables.forEach(q=>{q[0]===c&&(w=!1,x=q[1])});if(w)throw Log_Errors&&Jax.Console.Error("JaxReferenceError: '"+c+"' is not defined."),Error("Jax Stopped because of an unhandeled Error...");g=g.replace("@"+c,`<span jxv="${btoa(c).replace(/=/g,"-")}">${x}</span>`)});if(!is_string){t=t.replace(/ /g,"");if("style"===t)return style_started=!0;""!==t?(()=>{var c=[...Jax.MakeTag(t,z,A,B,g,!F),E];compiled_array=[...compiled_array,c]})():0}var J=
"";"head"===t&&push_to_head!==[]&&(push_to_head.forEach(c=>{J+=c}),g=J+g);comment_started=!1});var e=0,f=[],p=-1,r=0;compiled_array.forEach((d,b)=>{p++;b=d[0];var h=d[1];d=d[2];d=parseInt(d);if(p===compiled_array.length-1){d=f.length-parseInt(d);for(d;0<=d;d--)compiled+=void 0!==f[d]?f[d]:"",f.pop();compiled+=b+h}else if(d===e)compiled+=void 0!==f[f.length-1]?f[f.length-1]:"",f.pop(),compiled+=b,f.push(h);else if(d<e){e--;d=f.length-parseInt(d);for(d;0<=d;d--)compiled+=void 0!==f[d]?f[d]:"",f.pop();
compiled+=b;f.push(h)}else d>e&&(e++,r++,compiled+=b,f.push(h))});f!==[]&&f.forEach(d=>{compiled+=d});""===style?0:compiled+=`<style>${style}</style>`;compiled.includes("<head>")?compiled=compiled.replace("<head>","<head>"+push_to_head.join("")):compiled.toLowerCase().includes("<!doctype html>")?compiled=compiled.includes("<html>")?compiled.replace("<html>","<html><head>"+push_to_head.join("")+"</head>"):compiled.replace(compiled.includes("<!DOCTYPE html>")?"<!DOCTYPE html>":"<!doctype html>","<head>"+
push_to_head.join("")+"</head>"):(print("<head>"+push_to_head.join("")+"</head>"+compiled),compiled="<head>"+push_to_head.join("")+"</head>"+compiled);try{""!==Target?""!==Transition?(document.querySelector(Target).animate(Transition[0],AnimationDuration/2),document.querySelector(Target).style.opacity="0",await sleep(AnimationDuration/2),document.querySelector(Target).innerHTML=compiled,document.querySelector(Target).animate(Transition[1],AnimationDuration/2),document.querySelector(Target).style.opacity=
"1"):document.querySelector(Target).innerHTML=compiled:document.write(compiled)}catch{print(compiled)}compiled_array=[];compiled="";f=[];push_to_head=[];is_string=!1}
Jax.set=function(a){if("object"!==typeof a)throw Jax.Console.Error("TypeError: Typeof Param[0](config) used in 'Jax.init' is not an Object."),Error("Jax Stopped because of an unhandeled Error...");a.logSystemErrors&&"boolean"===typeof a.logSystemErrors&&(Log_Errors=a.logSystemErrors);a.target&&""!==a.target&&(Target=a.target);a.transition&&"object"==typeof a.transition&&(Transition=a.transition);if(a.transitionDelay){if(0>=parseInt(a.transitionDelay))return Jax.Console.Error('JaxConfigurationError: Key "transitionDelay" cannot be Less or Equal to Zero.');
AnimationDuration=a.transitionDelay}};
Jax.MakeTag=function(a="",e="",f="",p="",r="",d=!0){var b=a;for(a=e;a.startsWith(" ");)a=removeBlank(a);if(b.charAt(0)==b.charAt(0).toUpperCase()&&b.charAt(0).toLowerCase()!=b.charAt(0).toUpperCase()){var h=!1,g;modules.forEach(l=>{l[0]===b&&(h=!0,g=l[1])});if(h){var k="";Object.entries(g.jaxModule["attribute-list"]).forEach(l=>{for(var n=0;n<l.length;n++)0==n%2?k+=k.startsWith(" ")||!k.endsWith('"')?l[n]:" "+l[n]:""!==l[n]&&(k+='="'+l[n]+'"')});b=g.jaxModule.startingElement;a=removeBlank(g.jaxModule["class-list"]);
f=void 0===g.jaxModule.id?"":g.jaxModule.id;p=k;r=g.jaxModule.innerContent.replaceAll("(|)",r);d=g.jaxModule.hasClosingTag;if(g.jaxModule.css){var m=btoa(g.jaxModule.callingName).replace(/=/g,"-");a+=a.endsWith(" ")?m:" "+m;e="."+m+CSS.of(JSON.parse('{"":'+JSON.stringify(g.jaxModule.css)+"}"));style+="\n"+e;g.jaxModule.selectors&&Object.entries(g.jaxModule.selectors).forEach(l=>{style+="."+m+l[0]+CSS.of(JSON.parse('{"":'+JSON.stringify(l[1])+"}"));console.log(typeof l[1],l[1])})}}else if(Log_Errors)throw Jax.Console.Error(`CriticalJaxUnknownModuleError: '${b}' is not found in the Modules list.`),
Error("Jax Stopped because of an unhandeled Error...");}e=[];d=d?`</${b}>`:"";e.push(`<${b}${""!==a?' class="'+a+'"':""}${""!==f?' id="'+f+'"':""}${""!==p?" "+p:""}>${r}`);e.push(d);return e};Jax.Console={};Jax.Transitions={};Jax.Console.Error=a=>{console.log("%cJax Info:","color:indigo;font-size:25px;");console.log(`%c${a}`,"color:red;font-size:15px;")};Jax.Transitions.fade=[[{opacity:1},{opacity:0}],[{opacity:0},{opacity:1}]];
Jax.getElementByVariableName=a=>{try{var e=btoa(a).replace(/=/g,"-");return document.querySelectorAll(`[jxv=${e}]`)}catch{print("You are in a Node Environement, so 'document.querySelectorAll' doesn't work here.")}};Jax.changeVariable=function(a="",e=""){Jax.getElementByVariableName(a).forEach(f=>{f.innerHTML=e})};Jax.createModule=function(a){return a};
Jax.registerModule=function(a){var e=!1;modules.forEach(f=>{f[1].jaxModule.callingName===a.jaxModule.callingName&&(e=!0)});e?Log_Errors&&Jax.Console.Error("ModuleRegistrationError: "+`Module Calling-Name '${a.jaxModule.callingName}' is already taken by another module.`):modules.push([a.jaxModule.callingName,a])};function sleep(a){return new Promise(e=>setTimeout(e,a))}
(function(a){a.image=function(e,f){f=f||1;var p=new Image;p.onload=function(){var r=this.height*f;a.log("%c+","font-size: 1px; padding: "+Math.floor(r/2)+"px "+Math.floor(this.width*f/2)+"px; line-height: "+r+"px;background: url("+e+"); background-size: "+this.width*f+"px "+this.height*f+"px; color: transparent;")};p.src=e}})(console);class CSS{static of(json){const selectors=Object.keys(json);return selectors.map((selector)=>{const definition=json[selector];const rules=Object.keys(definition);const result=rules.map((rule)=>{return `${rule}:${definition[rule]}`}).join(';');return `${selector}{${result}}`}).join('\n')}}

Back to list