7 KB front-end framework with many common features
github.com
github.com
function getURLParameters(url) {
var res = {},
re = /[?&]([^?&]+)=([^?&]+)/g;
url.replace(re, function(_,k,v) {
res[k] = v;
});
return res;
}
Then use it like "getURLParameters(window.location)".Also just a tip in general, if you're up for some more constructive criticism I'll rewrite your "hasclass" function following conventions. So it goes from this:
function hasclass (el, className) {
if (el.classList)
return el.classList.contains(className);
else
return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
}
To this: function hasClass(el, className) {
if (el.classList) {
return el.classList.contains(className);
}
return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
}
Notice the camel casing in "hasClass", the braces around "if", and the early return.