Skip to content

Instantly share code, notes, and snippets.

@JustDravee
Created November 23, 2020 13:01
Show Gist options
  • Save JustDravee/b4a09efb331097edc0750242c3057b79 to your computer and use it in GitHub Desktop.
Save JustDravee/b4a09efb331097edc0750242c3057b79 to your computer and use it in GitHub Desktop.
$(function () {
$('#tri-alpha').click(function () {
chrome.storage.sync.get(['textList'], function (data) {
data.textList.sort();
chrome.storage.sync.set({ 'textList': data.textList }, function () {
var notifOptions = {
type: 'basic',
iconUrl: 'icon48.png',
title: 'Tri alphabétique croissant',
message: "La liste a été triée alphabétiquement"
};
chrome.notifications.create(/*id*/ 'triAlpha', notifOptions);
});
})
});
$('#tri-long').click(function () {
chrome.storage.sync.get(['textList'], function (data) {
data.textList.sort(function (a, b) {
// ASC -> a.length - b.length
// DESC -> b.length - a.length
return b.length - a.length;
});
chrome.storage.sync.set({ 'textList': data.textList }, function () {
var notifOptions = {
type: 'basic',
iconUrl: 'icon48.png',
title: 'Tri en longueur décroissant',
message: "La liste a été triée par longueur décroissante"
};
chrome.notifications.create(/*id*/ 'triLong', notifOptions);
});
})
});
$('#reset').click(function () {
chrome.storage.sync.set({ 'textList': [] }, function () {
var notifOptions = {
type: 'basic',
iconUrl: 'icon48.png',
title: 'Tout supprimer',
message: 'Tout a été supprimé'
};
chrome.notifications.create(/*id*/ 'supprimerTout', notifOptions);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment