

7 KB front-end framework with many common features - rado
https://github.com/radogado/natuive

======
devwebee
TBH, it doesn't look too good. The syntax is all over the place, bad
indentation, missing semicolons, a loop variable is leaking, it doesn't follow
common conventions... But don't give up, keep improving your skills. Here's a
replacement for that monstrous "getURLParameters" to pique your curiosity that
can save you a few more lines:

    
    
      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.

~~~
rado
Thanks for the great reply!

