This file contains 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.htmlEntities = function( reverse = 0 ){ | |
let thisString = this; | |
let entities = [' ', '<', '>', '"', '\'', '¢', '£', '¥', '€', '©', '®']; | |
let htmlEntities = [' ', '<', '>', '"', ''', '¢', '£', '¥', '€', '©', '®']; | |
if( reverse == 0 ){ | |
thisString = thisString.replace(/&/g, 'ΠπϖⲠⲡhE'); | |
for(let i = 0; i < 11; i++){ | |
thisString = thisString.replace( new RegExp( entities[i] , 'g'), htmlEntities[i] ).replace(/ΠπϖⲠⲡhE/g, '&'); |
This file contains 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
//jQuery_if_landscape.js | |
let landscape = $(window).innerWidth() >= $(window).innerHeight() ? true : false; |
This file contains 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
//input: jsonToArray({a: 1, b: 2 , c: 3}); | |
//output: [ ['a', 'b', 'c'], [1, 2, 3] ]; | |
function jsonToArray(obj){ | |
let returnArray = []; | |
let key = []; | |
let values = []; | |
for( let thisKey in obj ){ | |
//console.log( thisKey + ': ' + obj[thisKey] ); | |
key.push( thisKey ); | |
values.push( obj[thisKey] ); |
This file contains 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
<!doctype html> | |
<html lang="pt-BR"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>align center with table-container</title> | |
<style> | |
body{ | |
margin: 0; | |
padding: 0; | |
border: 0; |
This file contains 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
let array = ['a', 'b', 'c']; | |
array.forEach(function( item, index ){ | |
console.log( item, index ); | |
}); |
This file contains 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
function mouseMoving(element, movementSpeed = 1) { | |
if (typeof element == 'string') { | |
element = $(element); | |
}; | |
element.css({ | |
'position': 'relative' | |
}); | |
$(document).on('mousemove', function(event) { | |
let x = event.pageX * 100 / $(document).innerWidth(); | |
let y = event.pageY * 100 / $(document).innerHeight(); |
This file contains 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
//phone | |
let SPMaskBehavior=function(s){return 11===s.replace(/\D/g,'').length?'(00) 00000-0000':'(00) 0000-00009'},spOptions={onKeyPress:function(s,a,e,n){e.mask(SPMaskBehavior.apply({},arguments),n)}};$('.sp_celphones').mask(SPMaskBehavior,spOptions); |
This file contains 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
//jquery-mask-latin-characters | |
$('input[name="nome"]').mask( | |
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', | |
{translation:{'A':{pattern:/[ \.a-zA-ZÀÁÂÃÄÅàáâãäåÈÉÊËèéêëÌÍÎÏìíîïÒÓÔÕÖòóôõöÙÚÛÜùúûüÇçÑñ]/,optional:true}}} | |
); |
This file contains 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
function ajaxGetStatusOfLinks(arrayOfLinks) { | |
if (typeof arrayOfLinks == 'string') { | |
arrayOfLinks = [arrayOfLinks]; | |
}; | |
let returnObjs = []; | |
arrayOfLinks.forEach(function(link, i) { | |
let xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.status == 200 && this.readyState == 4) { | |
returnObjs.push({ |
This file contains 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
function waitBy(byThis, diffThis = 'undefined', maxWait = 10000){ | |
return new Promise(function(resolve, reject){ | |
if( typeof byThis == 'string' ){ | |
let waitPromise = setInterval(function(){ | |
if( typeof top[byThis] != diffThis ){ | |
clearInterval(waitPromise); | |
resolve(true); | |
}; | |
}, 10); | |
let waitPromiseReject = setTimeout(function(){ |
OlderNewer