User:Cap123/qaz.js

/* * QAZ v0.1 (build 1b1) * Copyright Cap123 2013. All rights reserved. */

function qaz(settings) { var settings = settings || { credits: true; }; var d = settings.debug; if (!settings.credits) { qaz.crfe(true); } else { qaz.crfe(false); } function $(element) { var e = element.charAt(0); // # (ID), .(Class) or A-Z (HTML Tag) var el = element.substring(1); // Element Name

if (e = '#') { return document.getElementById(el); } else if (e = '.') { return document.getElementByClassName(el); } else { return document.getElementByTagName(element); } } qaz.prototype.newElement = function (element, html, aC) { var s = document.createElement(element'); s.innerHTML = html; $(aC).appendChild('s'); } qaz.prototype.crfe = function (c) { if (!c) { credits = function { alert('QAZ v0.1 (build 1b1)\nCopyright Cap123 2013. All rights reserved.'); } } else { return; } qaz.prototype.ajax = function (o) { var // XHR: Base xhr = (window.XMLHttpRequest) ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP"); // Options System o = o || {}, // Values values = '?';

for (var k in o.data) { values+= encodeURIComponent(k) + '=' + encodeURIComponent(o.data[k]) + '&'; } if (o.method == 'get') { url+=values; values = null; } else if (o.method == 'post') { values=values.substring(1,values.length-1); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } xhr.open(o.method, o.url, o.async); xhr.send(o.values); if (o.loading) { o.loading; } xhr.onReadyStatChange = function { if (xhr.readyState == 4) { switch(xhr.status) { case 200: if (o.success) o.success(xhr); break; case 403, 404, 503 : if (o.error) o.error(myxhr); break; default: o.error(xhr); } } } }