From 2fb2e09bb24340a7cc33ae30037f45125791131c Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 10 May 2018 17:15:14 +0200 Subject: androidz --- .../platforms/android/assets/www/js/vendor/util.js | 209 +++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100755 StoneIsland/platforms/android/assets/www/js/vendor/util.js (limited to 'StoneIsland/platforms/android/assets/www/js/vendor/util.js') diff --git a/StoneIsland/platforms/android/assets/www/js/vendor/util.js b/StoneIsland/platforms/android/assets/www/js/vendor/util.js new file mode 100755 index 00000000..27bdf008 --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/vendor/util.js @@ -0,0 +1,209 @@ +if (window.$) { + $.fn.int = function() { return parseInt($(this).val(),10) } + $.fn.float = function() { return parseFloat($(this).val()) } + $.fn.string = function() { return trim($(this).val()) } + $.fn.enable = function() { return $(this).attr("disabled",null) } + $.fn.disable = function() { return $(this).attr("disabled","disabled") } + $.fn.sanitize = function(s) { return trim(sanitize($(this).val())) } + $.fn.stripHTML = function(s) { return trim(stripHTML($(this).val())) } + $.fn.sanitizeName = function(s) { return trim(sanitizeName($(this).val())) } + $.fn.htmlSafe = function(s) { return $(this).html(sanitize(s)) } + $.fn.toDollars = function(i) { return $(this).html((i/100).toFixed(2)) } +} + +function trim (s){ return s.replace(/^\s+/,"").replace(/\s+$/,"") } +function sanitize (s){ return (s || "").replace(new RegExp("[<>&]", 'g'), "") } +function sanitizeName (s){ return (s || "").replace(new RegExp("[^-_a-zA-Z0-9]", 'g'), "") } +function stripHTML (s){ return (s || "").replace(/<[^>]+>/g, "") } +function sanitizeHTML (s){ return (s || "").replace(/&/g, "&").replace(//g, ">") } +function capitalize (s){ return s.split(" ").map(capitalizeWord).join(" ") } +function capitalizeWord (s){ return s.charAt(0).toUpperCase() + s.slice(1) } +function slugify (s){ return (s || "").toLowerCase().replace(/\s/g,"-").replace(/[^-_a-zA-Z0-9]/g, '-').replace(/-+/g,"-") } +function rgb_string (rgb) { return "rgb(" + rgb.map(Math.round).join(",") + ")" } +function rgba_string (rgb,a) { return "rgba(" + rgb.map(Math.round).join(",") + "," + a + ")" } +function hex_string (rgb) { return "#" + rgb.map(Math.round).map(function(n){ var s = n.toString(16); return s.length == 1 ? "0"+s : s }).join("") } +function parse_rgba_string (s) { return s.match(/(\d+)/g).slice(0,3) } + +function title_case (str) { + return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); +} +function pluralize (n,s,ss) { return n + " " + s + ( n == 1 ? "" : (ss || "s") ) } +function as_cash(n){ + var cents = ((n*100) % 100); + if (cents < 10) { cents = "0" + (cents|0) } + else { cents = cents|0 } + return "$" + (n|0) + "." + cents +} + +var E = Math.E +var PI = Math.PI +var PHI = (1+Math.sqrt(5))/2 +var TWO_PI = PI*2 +var HALF_PI = PI/2 +var LN10 = Math.LN10 +function clamp(n,a,b){ return n