[CODE] Scarlet's Library

View previous topic View next topic Go down

[CODE] Scarlet's Library

Post by Scarlet on Sun Apr 26, 2015 10:45 am

So, this is a total amount of my JS library. Remember, this is not a framework. But this is a library that I have. Simple but maybe useful.

[SNIPPET] Sort Variables

Code:
function sortVar(variable) {
 arr = [];
 arr.push(variable);
}

This function would sort variables. So, in the code above, I'll insert a variable containing an empty array, then add the value in the empty array. So an example to this might be :

Code:
var scarlet = "Scarlet";
var wasgreat = scarlet + " was great";
sortVar(scarlet, wasgreat);

So, my task for this function is, improve the code and build more larger codes with it.

[SNIPPET] Check Input

This little snippet would check for inputs.

Code:
var inp = document.getElementsByTagName('input');

Basically I've using the getElementsByTagName method. So, this method would get elements from every <input> HTMLCollection. So, with using this, you'll have a possibility to check for <input> HTML. Even you can build a code which allows you to alert something when there's something in the input.

Code:
var inp = document.getElementsByTagName('input');
for(var i=0;i<inp.length;i++) {
 // well sometimes window.close didn't really works but this is just an example
 var close = window.close();
 if(close) {
  if(i => 1) {
   alert("you're about exit");
  }
 }
}

Remember, window.close(); sometimes didn't really work.
So, that's all of snippets I have. I'll think for another one.
avatar
Scarlet
Admin

Member Title : Classy Person
Posts : 28
Join date : 2015-04-16

View user profile http://codingsupport.topicboards.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum