Advertisement
Temporelucis

util.js

Jun 27th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var util = {
  2.   trim : function (arr2) {
  3.     arr1 = new Array();
  4.     for(j = 0; j < arr2.length; j++)
  5.         if(arr2[j] != "")
  6.             arr1[arr1.length] = arr2[j];
  7.     arr2.length = arr1.length;
  8.     for(j = 0; j < arr1.length; j++)
  9.         arr2[j] = arr1[j];
  10.     return arr2;
  11.   },
  12.   isNumber : function (n) {
  13.     return !isNaN(parseFloat(n)) && isFinite(n);
  14.   },
  15.   escapeHTML : function (unsafe) {
  16.     return unsafe
  17.       .replace(/&/g, "&amp;")
  18.       .replace(/</g, "&lt;")
  19.       .replace(/>/g, "&gt;")
  20.       .replace(/"/g, "&quot;")
  21.       .replace(/'/g, "&#039;");
  22.   }
  23. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement