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
$('#form').submit(function (e) { | |
e.preventDefault(); | |
let data = new FormData(this); | |
$.ajax({ | |
url: '/route', | |
data: data, | |
processData: false, | |
contentType: 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
// you need import sweetalert 2 library | |
function toast(message, type = 'success', timer = '2500', position = 'bottom-end') { | |
const Toast = Swal.mixin({ | |
toast: true, | |
position: position, | |
showConfirmButton: false, | |
timer: timer | |
}) |
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
// service worker | |
self.addEventListener('push', event => { | |
//console.log(JSON.parse(event.data.text())); | |
if (!(self.Notification && self.Notification.permission === 'granted')) { | |
return; | |
} | |
const sendNotification = (title, message, url) => { |
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
/* | |
// 1. verifico que el navegador soporte serviceWorker | |
// 2. registro el service worker | |
// 3. genero la subscripcion ( | |
// - pido permiso al cliente | |
// - genero datos de subscription | |
// - verifico que no haya otra subcripcion anterior | |
// - si no hay subscription guardo sino retorno la existente | |
// ) | |
*/ |
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 makeid(length) { | |
var result = ''; | |
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | |
var charactersLength = characters.length; | |
for ( var i = 0; i < length; i++ ) { | |
result += characters.charAt(Math.floor(Math.random() * charactersLength)); | |
} | |
return result; | |
} |
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
$data = json_decode(Storage::get('public/folder/mifile.json'), 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
const formDataToJson = form => { | |
let unindexed_array = form.serializeArray(); | |
let indexed_array = {}; | |
$.map(unindexed_array, (n, i) => { | |
indexed_array[n['name']] = n['value']; | |
}); | |
return indexed_array; | |
} |
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
$.ajax({ | |
url: "/route", | |
type: "get", | |
async: false, // wait for res this request | |
success: res => { | |
}, | |
error: err => { | |
console.log(err); | |
} |
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
var delayTimer; | |
function doSearch(text) { | |
clearTimeout(delayTimer); | |
delayTimer = setTimeout(function() { | |
// Do the ajax stuff | |
}, 1000); // Will do the ajax stuff after 1000 ms, or 1 s | |
} |
OlderNewer