Coding Support
Would you like to react to this message? Create an account in a few clicks or log in to continue.

[CODE] Scarlet's Library

Go down

[CODE] Scarlet's Library Empty [CODE] Scarlet's Library

Post by Scarlet 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.
Scarlet
Scarlet
Admin

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

https://codingsupport.darkbb.com

Back to top Go down

Back to top


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