This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var textareas = document.getElementById('user_summary'); | |
| for (var i = textareas.length; i--;) { | |
| if (textareas[i].getAttribute('maxlength') && !textareas[i].maxlength) { | |
| var max = textareas[i].getAttribute('maxlength'); | |
| textareas[i].onkeypress = function(event) { | |
| var k = event ? event.which : window.event.keyCode; | |
| if(this.value.length >= max) if(k>46 && k<112 || k>123) return false; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:(function()%7Bif(typeof%20jQuery%20%3D%3D%20'function')%7Bdelete%20jQuery%3B%7Dvar%20newscript%20%3D%20document.createElement('script')%3Bnewscript.type%20%3D%20'text%2Fjavascript'%3Bnewscript.async%20%3D%20true%3Bnewscript.src%20%3D%20'https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fjquery%2F1%2Fjquery.min.js'%3B(document.getElementsByTagName('head')%5B0%5D%7C%7Cdocument.getElementsByTagName('body')%5B0%5D).appendChild(newscript)%3B%7D)()%3B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.fn.validateImageUpload = function(size){ | |
| //Accepts form file input fields $('input[type=file]').validateImageUpload(); | |
| //Also accepts size validation (in K), default is 700. Set to false in order to skip check | |
| if(typeof size != "number" && size%1 != 0){size = 700} | |
| var validate = function(x){ | |
| var files = $(x).get(0).files, that = x; | |
| for (i = 0; i < files.length; i++){ | |
| if(!files[i].type.match(/(gif|jpg|JPG|jpeg|JPEG|gif|GIF|png|PNG)/)){ | |
| alert('Must be an image file.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Array.prototype.getObjectByAttribute = function(value, attribute){ | |
| var catcher = [], i = 0; | |
| while(!catcher && this[i]){ | |
| if(this[i].attribute == value){ | |
| catcher.push(this[i]); | |
| } | |
| i++; | |
| } | |
| return catcher.length == 1 ? catcher[0] : catcher.length ? catcher : false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.fn.toggleHTML = function(a,b){ | |
| //toggles two HTML values of given object, defaults to A unless equal to A | |
| $(this).html(($(this).html() == a ? b : a)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String.prototype.isCVV = function(){ | |
| return (this.length >= 3 && this.length <=4) && Number(this) ? true : false | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String.prototype.isCreditCard = function() | |
| { | |
| //Credit - https://sites.google.com/site/abapexamples/javascript/luhn-validation | |
| var luhnArr = [[0,2,4,6,8,1,3,5,7,9],[0,1,2,3,4,5,6,7,8,9]], sum = 0; | |
| this.replace(/\D+/g,"").replace(/[\d]/g, function(c, p, o){ | |
| sum += luhnArr[ (o.length-p)&1 ][ parseInt(c,10) ]; | |
| }); | |
| return (sum%10 === 0) && (sum > 0); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var APP_ID = prompt("Input your App Id"); | |
| var APP_SECRET = prompt("Input your App Secret"); | |
| $.ajax({ | |
| url: "https://graph.facebook.com/oauth/access_token?client_id="+APP_ID+"&client_secret="+APP_SECRET+"&grant_type=client_credentials", | |
| type: "GET", | |
| success: function(data){ | |
| window.location = "https://graph.facebook.com/"+APP_ID+"/accounts/test-users?installed=false&locale=en_UK&permissions=read_stream&method=post&access_token="+data.replace('access_token=',''); | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| A collection of useful scripts | |
| */ | |
| //Collect all form data into a string | |
| $.fn.getFormData = function(){ | |
| var str = ""; | |
| var areas = $(this).find('input').not('input[type=submit]').not('input[type=button]').add($(this).find('textarea')).add($(this).find('select')); | |
| areas.each(function(i){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var scripts = {}; | |
| var w3cGeo = {}; | |
| w3cGeo.api = '95b5c8ffb1d0891fe5a1eed66ce0d2d5'; | |
| var gLocalSearch = new GlocalSearch(); | |
| google.load("search", "1"); | |
| google.load("maps", "2", {"callback" : w3cGeo.mapsLoaded}); | |