diff --git a/Firefox/popup/notifier_popup.css b/Firefox/popup/notifier_popup.css index b50077a..2dc9c0d 100644 --- a/Firefox/popup/notifier_popup.css +++ b/Firefox/popup/notifier_popup.css @@ -1,10 +1,14 @@ +html { + height: 100px; +} + body { + height: 100px; margin: 0; padding: 0; color: white; background-color: #0c4863; - border-bottom: 3px solid #f8ad32; font-family: 'Source Sans Pro', Fallback, sans-serif; } @@ -16,8 +20,10 @@ body #notconnected { + font-size: 1.2em; margin-top: 20px; text-align: center; + width: 200px; } #home_clem img @@ -63,11 +69,16 @@ a background: #396a81; } +#button +{ + border-bottom: 3px solid #f8ad32; +} + #notification { font-size:13px; height: 50px; - width: 385px; + width: 350px; border-bottom: #154e69 1px solid; } @@ -80,7 +91,7 @@ a #notification #blocNotif { float:right; - width: 335px; + width: 300px; height: 50px; overflow: hidden; text-overflow: ellipsis; @@ -88,7 +99,7 @@ a #notification #pseudo { - width:40%; + width:50%; max-height: 18px; overflow-y: hidden; text-overflow: ellipsis; @@ -102,7 +113,7 @@ a max-height: 13px; float:right; text-align:right; - padding-right:20px; + padding-right:10px; color: #77b8d5; } diff --git a/Google Chrome/background.js b/Google Chrome/background.js deleted file mode 100644 index 994137a..0000000 --- a/Google Chrome/background.js +++ /dev/null @@ -1,887 +0,0 @@ -/** - * OpenClassrooms Notificateur - * @author Eskimon & Sandhose - * @licence under MIT Licence - * @version 2.2.0 - * ====== - * background.js - * Main background script - */ - - -/** - * Notificateur - Main class - * @constructor - */ -var Notificateur = function() { - this.init.apply(this, arguments); -}; - -Notificateur.prototype = { - /** - * ZdS URL - */ - url: "http://zestedesavoir.com", - - /** - * If logged in last check - */ - logged: true, - - /** - * Current notifications - */ - notifications: [], - - /** - * Options - */ - default_options: { - updateInterval: 5, - openListe: true, - openInNewTab: true, - showAllNotifButton: true, - showDesktopNotif: true, - notifPriority: 0, - mpPriority: 0, - playSon: false, - ZdSLink: false, - autoclosePopup: true, - useDetailedNotifs: false, - archiveAllLink: false - }, - - options: {}, - - _optionsTypes: { // Je l'ai quand meme fait ^^ - updateInterval: Number, - openListe: Boolean, - openInNewTab: Boolean, - showAllNotifButton: Boolean, - showDesktopNotif: Boolean, - notifPriority: Number, - mpPriority: Number, - playSon: Boolean, - ZdSLink: Boolean, - autoclosePopup: Boolean, - useDetailedNotifs: Boolean, - archiveAllLink: Boolean - }, - - /** - * Use fake data for debug - */ - useFakeData: false, - - /** - * Check en cours - */ - checkPending: false, - - /** - * chrome.storage - */ - storage: chrome.storage.sync, - - /** - * Init - */ - init: function() { - this.initialized = false; - this.notifications = []; //tableau stockant les notifs - this.alertTabId = []; - this.MPs = []; //tableau stockant les MPs - chrome.browserAction.enable(); //sinon un concours de circonstance pourrait nous faire démarrer avec une icone disable - this.loadOptions(function() { - //action lorsqu'on click sur le bouton (affichage liste ou chargement ZdS - if(!this.options.openListe) { //soit on ouvre le ZdS - chrome.browserAction.setPopup({ popup: "" }); - chrome.browserAction.onClicked.addListener(this.listeners.toolbarClick.bind(this)); - } else { //sinon on ouvre une popup avec le contenu des notifs - chrome.browserAction.setPopup({ popup: "popup/popup.html" }); - } - - chrome.alarms.create('refresh', {periodInMinutes: parseInt(this.options.updateInterval)}); - - this.loadSounds(function() { - this.loadSoundpack(this.soundpack); - }.bind(this)); - - this.initialized = true; - - this.check(); - - }.bind(this)); - - this.initListeners(); - }, - - /* Add events listeners */ - initListeners: function() { - chrome.runtime.onInstalled.addListener(this.listeners.install.bind(this)); - - if(chrome.tabs) { - chrome.tabs.onUpdated.addListener(this.listeners.tabUpdate.bind(this)); - chrome.tabs.onCreated.addListener(this.listeners.tabCreate.bind(this)); - } - - if(chrome.alarms) { - chrome.alarms.onAlarm.addListener(this.listeners.alarm.bind(this)); - } - - if(chrome.notifications) { - chrome.notifications.onButtonClicked.addListener(this.listeners.notifButtonClick.bind(this)); - chrome.notifications.onClicked.addListener(this.listeners.notifClick.bind(this)); - chrome.notifications.onClosed.addListener(this.listeners.notifClose.bind(this)); - } - }, - - /** - * Listeners - */ - listeners: { - /** - * Extension install - */ - - install: function(details) { - if(details.reason == "install") { - chrome.tabs.create({ - 'url': chrome.runtime.getURL("welcome/welcome.html"), - 'active': true - }); - } - }, - - /** - * Tab Update - */ - tabUpdate: function(tabId, changeInfo, tab) { - if(tab.url !== undefined && tab.url.indexOf("zestedesavoir.com") != -1 && tab.url.indexOf("zestedesavoir.com") < 14 && changeInfo.status == "complete") { - if(tab.url.indexOf("/forum/sujet/") != -1) {//cas d'une notif de type forum -> il faut faire l'injection - if(this.alertTabId.indexOf(tabId) == -1) { //ne se déclenche pas si on arrive via une alerte de modo - //on garde le inject juste pour le plaisir du konami code :D - chrome.tabs.executeScript(tabId, { - file: "injected.js" - }); - } else { - this.alertTabId.splice(this.alertTabId.indexOf(tabId),1); - } - //on attend une seconde pour que le script soit injecté puis on check de nouveau les notifs pour mettre à jour le numero - this.check(); - } else if(tab.url.indexOf("/mp/") != -1) { //cas des MP - this.check(); - } - } - }, - - /** - * Tab create - */ - tabCreate: function(tab) { - if(tab.url !== undefined && tab.url.indexOf("zestedesavoir.com") != -1 && tab.url.indexOf("zestedesavoir.com") < 14) { - this.check(); - } - }, - - /** - * Toolbar Click - */ - toolbarClick: function() { - chrome.tabs.create({ - url: this.url, - active: true - }); - }, - - /** - * Alarm - */ - alarm: function(alarm) { - if (alarm.name == "refresh") { - this.check(); - } - }, - - /** - * Notification button click - */ - notifButtonClick: function(notifId, button) { - var notif = this.getNotification(notifId); - if(button == 0) { // Open last message - if(notif) { - switch(notif.type) { - case "forum": //normal - this.openZdS(notif.link); - this.archiveNotification(notif.id); - break; - case "mp": //MP - this.openZdS(notif.link); - break; - case "alerte": //alerte - this.openZdS(notif.link); - break; - } - } - - chrome.notifications.clear(notifId, function() { - - }); - } - else if(button == 1) { // Open thread - if(notif) { - this.openZdS("/forum/sujet/" + notif.id); - this.archiveNotification(notif.id); - } - - chrome.notifications.clear(notifId, function() { - - }); - } - }, - - /** - * Notif Click - */ - notifClick: function(notifId) { - var notif = this.getNotification(notifId); - if(notif) { - switch(notif.type) { - case "forum": //normal - this.openZdS(notif.link); - this.archiveNotification(notif.id); - break; - case "mp": //MP - this.openZdS(notif.link); - break; - case "alerte": //alerte - this.openZdS(notif.link, true); - break; - } - } - - chrome.notifications.clear(notifId, function() { - - }); - }, - - /** - * Notif close - */ - notifClose: function(notifId) { - // A la fermeture de la notif - } - }, - - /** - * Check for new Notifications - */ - check: function() { - var self = this; - if(this.checkPending || !this.initialized) { // Si l'extension n'est pas (encore) initialisee ou un check est deja en cours - return; - } - - this.checkPending = true; - self = this; - chrome.browserAction.setIcon({ "path": "icons/icone_38_parsing.png" }); - - var url = this.useFakeData ? chrome.runtime.getURL("fake-data.html") : this.url; - - new AjaxRequest(url, this.loadCallback.bind(this), function() { - //si jamais la requete plante (pas d'internet, 404 ou autre 500...) - chrome.browserAction.setBadgeText({text: "err"}); - chrome.browserAction.setIcon({"path":"icons/icone_38_logout.png"}); - chrome.browserAction.disable(); - self.logged = false; - self.checkPending = false; - }); - - return; - }, - - /** - * Get notifications by id - * @param {String} [id] Notification ID - * @returns {Array|Object} A notifications if ID is set, or an array of all Notifications - */ - getNotification: function(id) { - if(!id) { - return this.notifications; - } - for(var i=0, nb=this.notifications.length; i>"); - - // On récupère un DOM que l'on peut manipuler - var doc = document.implementation.createHTMLDocument("xhr_result"); - doc.documentElement.innerHTML = event.target.responseText.trim(); - - if (!doc.body) { - return false; - } - - console.dir(doc); - - var contenu = doc.querySelector("div.logbox"); - - var hasNewNotif = { - notification: false, - mp: false - }; - - console.dir(contenu); - - if (!contenu) { - chrome.browserAction.setBadgeText({text: "err"}); - chrome.browserAction.setIcon({"path":"icons/icone_38_logout.png"}); - chrome.browserAction.disable(); - self.logged = false; - self.checkPending = false; - return; - } - - //on est pas connecté ! - if(contenu.classList.contains("unlogged") && !this.useFakeData) { - if(this.logged) { - chrome.browserAction.setBadgeText({ text: "log" }); - chrome.browserAction.setIcon({ "path": "icons/icone_38_logout.png" }); - chrome.browserAction.enable(); - this.logged = false; - } - return; - } else { - if(!this.logged) { - chrome.browserAction.setIcon({ "path": "icons/icone_38.png" }); - chrome.browserAction.setBadgeText({ text: "" }); - chrome.browserAction.enable(); - this.logged = true; - } - } - - //récupere les deux listes, celle des MP (0) et celle des notifs (1) - contenu = contenu.querySelectorAll("div.notifs-links ul.dropdown-list"); - - // Check les notifications --------------------------------------- - var notifications = contenu[1].querySelectorAll("li"), - newNotifs = [], // Liste des nouvelles notifications - oldNotifs = this.notifications, // Ancienne liste - removedNotifs = [], // Notifs enlevées - notifsList = []; // Nouvelle liste - - if(!notifications[0].classList.contains("dropdown-empty-message")) { - for(var i=0, nb=notifications.length; i/ig, "\n").replace(/(<([^>]+)>)/ig, "").substr(0, 140) + "...\n" + notif.date, - priority: parseInt(this.options.notifPriority), - buttons: [{ title: "Voir le message" }, { title: "Voir le début du thread" }] - }, function() {}); - } - else { - var boutons = new Array(); - var priority = 0; - var icone = ""; - switch(notif.type) { - case "forum": - boutons[0] = { title: "Voir le message" }; - boutons[1] = { title: "Voir le début du thread" }; - icone = "icons/big_message.png"; - priority = this.options.notifPriority; - break; - case "mp": - boutons[0] = { title: "Voir le MP" }; - icone = "icons/big_mp.png"; - priority = this.options.mpPriority; - break; - case "alerte": - boutons[0] = { title: "Voir l'alerte" }; - icone = "icons/big_alerte.png"; - priority = this.options.notifPriority; - break; - } - var notifOptions = { // Options des notifications - type: "basic", - iconUrl: icone, - title: notif.title, - message: notif.date, - buttons: boutons, - priority: parseInt(priority) - }; - - chrome.notifications.create(""+notif.id, notifOptions, function() {}); - } - } - }, - - /** - * Clear desktops notifications - * @param {Array} notifs Array of notifications to clear - */ - clearDesktopNotifs: function(notifs) { - if(chrome.notifications) { - for(var i = 0; i < notifs.length; i++) { - chrome.notifications.clear(''+notifs[i].id, function() {}); - } - } - }, - - /** - * Fetch notifications details (forum posts only) - * @param {Object|Array} notif A notifications or an Array of notifications - * @param {Function} callback The callback when the details are fetched - */ - // TODO - fetchNotificationDetails: function(notif, callback) { - if(Object.prototype.toString.call(notif) == "[object Array]") { - for(var i = 0; i < notif.length; i++) { - this.fetchNotificationDetails(notif[i], function(newNotif) { - callback && callback(newNotif, i); - }); - } - - return; - } - - $.get(this.url + notif.link, function(_data) { - var data = _data.replace(/src=/ig, "data-src=").replace(/href=/ig, "data-href="); // <-- pas forcement la meilleur methode... marche pas si qqn a un nom/avatar avec src=/href= dans le nom - //data = data.replace(/]*>(.*?)<\/img>/ig,''); - //data = data.replace(/]*>(.*?)<\/head>/ig,''); - //var xmlDoc = new DOMParser().parseFromString(data, "text/xml"); <-- Le parser bug... - var $data = $(data); - var post = $data.find("#message-" + notif.messageId).parent(); - if(post.length == 1) { - var authorElem = post.find(".avatar .author a"); - var author = $.trim(authorElem.text()); - var authorUrl = authorElem.attr("data-href"); // URL de l'auteur sans le /membres/ - var avatarUrl = post.find(".avatar img[alt=\"avatar\"]").attr("data-src"); - var postContent = post.find(".content .markdown").text(); - var threadTitle = $(data.match(/[\n\r\s]*(.*)[\n\r\s]*<\/title>/gmi)[0]).text() // <-- Un peu hard, je sais ^^ - notif.author = author; - notif.avatarUrl = avatarUrl; - notif.authorUrl = authorUrl; - notif.postContent = postContent; - notif.threadTitle = threadTitle; - notif.detailed = true; - - if(!notif.avatarUrl.indexOf("http") == 0) { // <-- URL relative - notif.avatarUrl = "http://zestedesavoir.com" + notif.avatarUrl; - } - } - else { - notif.detailed = false; - } - - callback && callback(notif); - }, "text"); - }, - - /** - * Get options - * @param {String} [key] Option key - * @returns {Object} The options value or all options - */ - getOptions: function(key) { - if(key) { - return this.options[key]; - } - else { - return this.options; - } - }, - - /** - * Set options - * @param {Object} changes Object of options changes - * @param {Function} [callback] - */ - setOptions: function(changes, callback) { - callback = callback || function() { console.log("Options saved"); }; - - var oldOptions = this.options; - for(var key in changes) { - if(this.options.hasOwnProperty(key)) { - // Conversion des donnees dans le bon type - if(this._optionsTypes[key] == Number) { - changes[key] = parseInt(changes[key]); - } - else if(this._optionsTypes[key] == Boolean) { - changes[key] = !!changes[key]; - } - else if(this._optionsTypes[key] == String) { - changes[key] = changes[key].toString(); - } - - this.options[key] = changes[key]; - } - } - - changes.timestamp = Date.now(); - - console.log("Options changes from", oldOptions, "to", this.options); - this.storage.set(changes, callback); - this.updateOptions(); - }, - - /** - * Reset options - */ - resetOptions: function() { - var defaults = this.default_options; - delete defaults["lastEdit"]; - this.setOptions(defaults); - }, - - /** - * Load options from chrome.storage - * @param {Function} [callback] Callback when options are loaded - */ - loadOptions: function(callback) { // Charge les options depuis le chrome.storage - this.options.extend(this.default_options); - - var keys = Object.keys(this.options); - - this.storage.get(keys, function(items) { - for(var key in items) { - if(this.options.hasOwnProperty(key)) { - this.options[key] = items[key]; - } - } - - (typeof callback == "function") && callback(); - }.bind(this)); - }, - - /** - * Update options - */ - updateOptions: function() { - // Update interval - chrome.alarms.create('refresh', { periodInMinutes: parseInt(this.options.updateInterval) }); - - //action lorsqu'on click sur le bouton (affichage liste ou chargement ZdS - if(!this.options.openListe) { //soit on ouvre le ZdS - chrome.browserAction.setPopup({ popup: "" }); - chrome.browserAction.onClicked.addListener(this.listeners.toolbarClick.bind(this)); - } else { //sinon on ouvre une popup avec le contenu des notifs - chrome.browserAction.onClicked.removeListener(this.listeners.toolbarClick); - chrome.browserAction.setPopup({ popup: "popup/popup.html" }); - } - }, - - /** - * Load soundpacks - * @param {Function} [callback] Callback fired when soundpacks are loaded - */ - loadSounds: function(callback) { - new AjaxRequest(chrome.extension.getURL("/sounds/packs.json"), function(data) { - try{ - data = JSON.parse(data); - } - catch (e) { - console.log("Error parsing JSON"); - return false; - } - if (!data) { - return false; - } - this.soundpacks = data; - if(this.soundpacks.sounds[this.options.soundpack]) { - this.soundpack = this.soundpacks.sounds[this.options.soundpack]; - } - else { - this.soundpack = this.soundpacks.sounds[this.soundpacks.default_soundpack]; - } - - callback && callback(); - }.bind(this)); - }, - - /** - * Load a specific soundpack - * @param {Object} soundpack The soundpack to load - */ - loadSoundpack: function(soundpack) { - var soundsList = document.getElementById("sound_list") || document.createElement("div"); - soundsList.id = "sound_list"; - document.body.appendChild(soundsList); - soundsList.innerHTML = ""; - - ["notif_mp_new", "notif_new", "mp_new"].forEach(function(element) { - //debugger; - var exists = document.getElementById("audio_" + element) !== null, - sound = exists ? document.getElementById("audio_" + element) : new Audio(); - sound.src = chrome.extension.getURL("/sounds/" + soundpack.folder + "/" + soundpack.sounds[element]); - sound.id = "audio_" + element; - sound.autoplay = false; - sound.load(); - !exists && soundsList.appendChild(sound); - }, this); - }, - - /** - * Play sound - * @param {Object} options Which sound should be played? - */ - playSound: function(options) { - var sound; - if(options.notification && options.mp) { - sound = document.getElementById("audio_notif_mp_new"); - } - else if(options.notification) { - sound = document.getElementById("audio_notif_new"); - } - else if(options.mp) { - sound = document.getElementById("audio_mp_new"); - } - else { - return; - } - - if(sound) { - sound.pause(); - sound.currentTime = 0; - sound.play(); - } - }, - - /** - * Set new notif callback - * @param {Function} callback - */ - setNewNotifCallback: function(callback) { - if(typeof callback == "function") { - this.newNotifCallback = callback; - } - else { - this.newNotifCallback = undefined; - } - }, - - /** - * Set remove notif callback - * @param {Function} callback - */ - setRemoveNotifCallback: function(callback) { - if(typeof callback == "function") { - this.removeNotifCallback = callback; - } - else { - this.removeNotifCallback = undefined; - } - }, - - /** - * Update badge - */ - updateBadge: function() { - var notifs = this.notifications, - len = notifs.length, - totMP = 0; - for (var i=0; i<len; i++) { - if (notifs[i].type == "mp") { - totMP++; - } - } - - var badgeTexte = (totMP > 0) ? totMP.toString() + " - " : ""; - badgeTexte += (len-totMP > 0) ? (len-totMP).toString() : ((totMP > 0) ? "0" : ""); - chrome.browserAction.setBadgeText({text: badgeTexte}); - chrome.browserAction.enable(); - }, - - /** - * Open a ZdS page - * @param {String} _url The url to open - * @param {Boolean} remember - */ - openZdS: function(_url, remember) { - var url = this.url + _url, - self = this; - - chrome.windows.getCurrent({ populate:true }, function(currentWindow) { - var tab = false; - for(var i in currentWindow.tabs) { - if(currentWindow.tabs[i].active) { - tab = currentWindow.tabs[i]; - break; - } - } - - if(!self.getOptions("openInNewTab") && tab && tab.url !== undefined && tab.url.indexOf("zestedesavoir.com") != -1 && tab.url.indexOf("zestedesavoir.com") < 14) { - if(remember) { - self.alertTabId.push(tab.id); //on ajout l'id du tab - } - chrome.tabs.update(tab.id, { url: url }); - } - else { - chrome.tabs.create({ - 'url': url, - 'active': false - }, function(tab){ - if(remember) { - self.alertTabId.push(tab.id); //on ajout l'id du tab - } - }); - } - }); - } -}; - - -/** @global */ -window.theNotificator = new Notificateur(); \ No newline at end of file diff --git a/Google Chrome/common.js b/Google Chrome/common.js deleted file mode 100644 index c10b332..0000000 --- a/Google Chrome/common.js +++ /dev/null @@ -1,106 +0,0 @@ - -/** - * Prototypes - */ -Object.prototype.extend = function(obj) { - for(i in obj) { - if (typeof obj[i] === "object") { - if (!this[i]) { - this[i] = {}; - } - this[i].extend(obj[i]); - } - else { - this[i] = obj[i]; - } - } -}; - - - - - -var AjaxRequest = function() { - if (typeof arguments[0] == 'string') { - this.url = arguments[0]; - } - else { - this.url = arguments[0].url; - } - - if (arguments[1] && typeof arguments[1] == 'string') { - this.postData = arguments[1]; - } - else if (arguments[1] && typeof arguments[1] == 'object') { - this.postData = arguments[1]; - } - else { - this.postData = arguments[0].data || null; - } - - if (this.postData && arguments[2] && typeof arguments[2] == 'function') { - this.successCallback = arguments[2]; - } - else if (!this.postData && arguments[1] && typeof arguments[1] == 'function') { - this.successCallback = arguments[1]; - } - else { - this.successCallback = arguments[0].success || null; - } - - if (this.postData && typeof arguments[3] == 'function') { - this.errorCallback = arguments[3]; - } - else if (!this.postData && arguments[2] && typeof arguments[2] == 'function') { - this.errorCallback = arguments[2]; - } - else { - this.errorCallback = arguments[0].error || null; - } - - if (this.postData && typeof arguments[4] == 'boolean' || arguments[0].cache != undefined) { - this.date = new Date(); - this.timestamp = this.date.getTime(); - this.cache = arguments[4] == 'boolean' || arguments[0].cache; - } - else if (!this.postData && typeof arguments[3] == 'boolean' || arguments[0].cache != undefined) { - this.date = new Date(); - this.timestamp = this.date.getTime(); - this.cache = arguments[3] == 'boolean' || arguments[0].cache; - } - else { - this.cache = true; - } - - var XHR = new XMLHttpRequest(); - - XHR.onreadystatechange = function (e) { - if (this.readyState == 4 && this.status == 200) { - if(this._successCallback) - this._successCallback(e); - } - else if (this.readyState == 4) { - console.dir(this); - if(this._errorCallback) - this._errorCallback(e); - } - } - - XHR._successCallback = this.successCallback || null; - XHR._errorCallback = this.errorCallback || null; - - - if (this.postData) { - XHR.open('POST', this.url+(this.cache ? '' : '?timestamp='+this.timestamp), true); - XHR.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - XHR.setRequestHeader('Content-type','application/x-www-form-urlencoded'); - XHR.send(typeof this.postData == 'string' ? this.postData : objectToQueryString(this.postData)); - } - else { - XHR.open('GET', this.url+(this.cache ? '' : '?timestamp='+this.timestamp), true); - XHR.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - XHR.send(); - } - - return this; -} \ No newline at end of file diff --git a/Google Chrome/fake-data.html b/Google Chrome/fake-data.html deleted file mode 100644 index e267ae0..0000000 --- a/Google Chrome/fake-data.html +++ /dev/null @@ -1,88 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title> - - - - - - \ No newline at end of file diff --git a/Google Chrome/icons/alerte.png b/Google Chrome/icons/alerte.png deleted file mode 100644 index 657c986..0000000 Binary files a/Google Chrome/icons/alerte.png and /dev/null differ diff --git a/Google Chrome/icons/alerte_white.png b/Google Chrome/icons/alerte_white.png deleted file mode 100644 index 4d85692..0000000 Binary files a/Google Chrome/icons/alerte_white.png and /dev/null differ diff --git a/Google Chrome/icons/badge.png b/Google Chrome/icons/badge.png deleted file mode 100644 index 46c122f..0000000 Binary files a/Google Chrome/icons/badge.png and /dev/null differ diff --git a/Google Chrome/icons/badge_white.png b/Google Chrome/icons/badge_white.png deleted file mode 100644 index a03dabe..0000000 Binary files a/Google Chrome/icons/badge_white.png and /dev/null differ diff --git a/Google Chrome/icons/big_alerte.png b/Google Chrome/icons/big_alerte.png deleted file mode 100644 index e7b6274..0000000 Binary files a/Google Chrome/icons/big_alerte.png and /dev/null differ diff --git a/Google Chrome/icons/big_badge.png b/Google Chrome/icons/big_badge.png deleted file mode 100644 index 10d98ad..0000000 Binary files a/Google Chrome/icons/big_badge.png and /dev/null differ diff --git a/Google Chrome/icons/big_message.png b/Google Chrome/icons/big_message.png deleted file mode 100644 index df9a345..0000000 Binary files a/Google Chrome/icons/big_message.png and /dev/null differ diff --git a/Google Chrome/icons/big_mp.png b/Google Chrome/icons/big_mp.png deleted file mode 100644 index 205ab20..0000000 Binary files a/Google Chrome/icons/big_mp.png and /dev/null differ diff --git a/Google Chrome/icons/big_roadmap.png b/Google Chrome/icons/big_roadmap.png deleted file mode 100644 index fdc1097..0000000 Binary files a/Google Chrome/icons/big_roadmap.png and /dev/null differ diff --git a/Google Chrome/icons/bulle.png b/Google Chrome/icons/bulle.png deleted file mode 100644 index c0265c5..0000000 Binary files a/Google Chrome/icons/bulle.png and /dev/null differ diff --git a/Google Chrome/icons/bulle_white.png b/Google Chrome/icons/bulle_white.png deleted file mode 100644 index 790f1fd..0000000 Binary files a/Google Chrome/icons/bulle_white.png and /dev/null differ diff --git a/Google Chrome/icons/clem_pas_contente.png b/Google Chrome/icons/clem_pas_contente.png deleted file mode 100644 index 8389d72..0000000 Binary files a/Google Chrome/icons/clem_pas_contente.png and /dev/null differ diff --git a/Google Chrome/icons/favicon.png b/Google Chrome/icons/favicon.png deleted file mode 100644 index 3caf94a..0000000 Binary files a/Google Chrome/icons/favicon.png and /dev/null differ diff --git a/Google Chrome/icons/icone_128.png b/Google Chrome/icons/icone_128.png deleted file mode 100644 index b324f06..0000000 Binary files a/Google Chrome/icons/icone_128.png and /dev/null differ diff --git a/Google Chrome/icons/icone_16.png b/Google Chrome/icons/icone_16.png deleted file mode 100644 index d2ecc00..0000000 Binary files a/Google Chrome/icons/icone_16.png and /dev/null differ diff --git a/Google Chrome/icons/icone_19.png b/Google Chrome/icons/icone_19.png deleted file mode 100644 index 140cd11..0000000 Binary files a/Google Chrome/icons/icone_19.png and /dev/null differ diff --git a/Google Chrome/icons/icone_24.png b/Google Chrome/icons/icone_24.png deleted file mode 100644 index 613c974..0000000 Binary files a/Google Chrome/icons/icone_24.png and /dev/null differ diff --git a/Google Chrome/icons/icone_32.png b/Google Chrome/icons/icone_32.png deleted file mode 100644 index e5ebbe4..0000000 Binary files a/Google Chrome/icons/icone_32.png and /dev/null differ diff --git a/Google Chrome/icons/icone_38.png b/Google Chrome/icons/icone_38.png deleted file mode 100644 index 9f4da11..0000000 Binary files a/Google Chrome/icons/icone_38.png and /dev/null differ diff --git a/Google Chrome/icons/icone_38_logout.png b/Google Chrome/icons/icone_38_logout.png deleted file mode 100644 index 5db5783..0000000 Binary files a/Google Chrome/icons/icone_38_logout.png and /dev/null differ diff --git a/Google Chrome/icons/icone_38_parsing.png b/Google Chrome/icons/icone_38_parsing.png deleted file mode 100644 index 38dfa53..0000000 Binary files a/Google Chrome/icons/icone_38_parsing.png and /dev/null differ diff --git a/Google Chrome/icons/icone_48.png b/Google Chrome/icons/icone_48.png deleted file mode 100644 index 38e0c4f..0000000 Binary files a/Google Chrome/icons/icone_48.png and /dev/null differ diff --git a/Google Chrome/icons/logo-zds.png b/Google Chrome/icons/logo-zds.png deleted file mode 100644 index 2d963b7..0000000 Binary files a/Google Chrome/icons/logo-zds.png and /dev/null differ diff --git a/Google Chrome/icons/mp.png b/Google Chrome/icons/mp.png deleted file mode 100644 index 4e60226..0000000 Binary files a/Google Chrome/icons/mp.png and /dev/null differ diff --git a/Google Chrome/icons/mp_white.png b/Google Chrome/icons/mp_white.png deleted file mode 100644 index 7289d65..0000000 Binary files a/Google Chrome/icons/mp_white.png and /dev/null differ diff --git a/Google Chrome/icons/original.png b/Google Chrome/icons/original.png deleted file mode 100644 index a87f280..0000000 Binary files a/Google Chrome/icons/original.png and /dev/null differ diff --git a/Google Chrome/icons/roadmap.png b/Google Chrome/icons/roadmap.png deleted file mode 100644 index 5e145aa..0000000 Binary files a/Google Chrome/icons/roadmap.png and /dev/null differ diff --git a/Google Chrome/icons/roadmap_white.png b/Google Chrome/icons/roadmap_white.png deleted file mode 100644 index b063408..0000000 Binary files a/Google Chrome/icons/roadmap_white.png and /dev/null differ diff --git a/Google Chrome/injected.js b/Google Chrome/injected.js deleted file mode 100644 index 2b48ae8..0000000 --- a/Google Chrome/injected.js +++ /dev/null @@ -1,54 +0,0 @@ -/* PLUS NECESSAIRE MAINTENANT QUE L'ON SAIT ARCHIVER ! - -var url = document.URL; -if((url.indexOf("/membres/") == -1) && (url.indexOf("#badges") == -1)) //si on est pas sur la page pour les badges - url = url.slice(0,url.indexOf("?")) + "/" + url.slice(url.lastIndexOf("-")+1); -var container = document.getElementById("lastNotifications"); //on restreint juste aux notifications -var els = container.getElementsByTagName("a"); -var len = els.length; -var target = false; -for (var i = 0; i < len; i++) { - var el = els[i]; - if (el.href === url) { - target = els[i+1]; - break; - } -} -target && target.click(); -*/ -/* -// Je suspecte ce bout de code de faire remonter la page tout en haut plutot que rester sur le lien qui va bien -// Update du nombre de notifs -var elem = document.getElementById("notifications"); -elem.click(); -elem.click(); -*/ - -// KONAMI! -var keys = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65], - current = 0; - -document.addEventListener("keydown", function(e) { - if(e.which == keys[current]) { - current++; - } - else { - current = 0; - } - - if(current >= keys.length) { - setInterval(function() { - var i = document.createElement("img"), - h = window.innerHeight, - w = window.innerWidth; - i.src = "http://www.siteduzero.com/uploads/fr/ftp/iphone/zozor.png"; - i.style.position = "fixed"; - i.style.top = (Math.floor(Math.random() * (h - 480))) + "px"; - i.style.right = (Math.floor(Math.random() * (w - 320))) + "px"; - i.style.zIndex = 2000; - document.body.appendChild(i); - console.log("Konami"); - }, 100); - current = 0; - } -}, false); diff --git a/Google Chrome/manifest.json b/Google Chrome/manifest.json index 9180cb9..258240f 100644 --- a/Google Chrome/manifest.json +++ b/Google Chrome/manifest.json @@ -1,30 +1,31 @@ { - "name": "ZdS Notificateur", - "version": "1.1.1", - "manifest_version": 2, - "description": "Extensions pour Google Chrome pour connaitre le nombre de notifications ou MP de ZesteDeSavoir sans avoir besoin d'ouvrir le site", - "offline_enabled": false, - "icons": { - "16": "icons/icone_16.png", - "48": "icons/icone_48.png", - "128": "icons/icone_128.png" - }, - "permissions": [ - "http://*.zestedesavoir.com/*", - "http://www.gravatar.com/*", - "tabs", - "alarms", - "notifications", - "storage" - ], - "options_page": "options/options.html", - "browser_action": { - "default_icon": "icons/icone_38.png", - "default_title": "ZdS Notificateur", - "default_popup": "popup/popup.html" + "manifest_version": 2, + "name": "Zds-Notificateur", + "version": "2.0", + "homepage_url": "https://zestedesavoir.com", + "description": "Une extension pour connaitre le nombre de notifications et de MP de ZesteDeSavoir sans avoir besoin d'ouvrir le site", + + "icons": { + "48": "icons/clem_48.png" + }, + + "permissions": [ + "http://useragentstring.com/*", "*://*.zestedesavoir.com/*", "notifications", "storage" + ], + + "options_ui": { + "page": "options/options.html" + }, + + "background": { + "scripts": ["notifier.js"] + }, + + "browser_action": { + "default_icon": { + "48": "icons/clem_48.png" }, - "background": { - "scripts": ["common.js", "background.js"], - "persistent": true - } + "default_title": "Zds-Notificateur", + "default_popup": "popup/notifier_popup.html" + } } diff --git a/Google Chrome/options/options.css b/Google Chrome/options/options.css deleted file mode 100644 index 827e67a..0000000 --- a/Google Chrome/options/options.css +++ /dev/null @@ -1,214 +0,0 @@ -* { - padding: 0; - margin: 0; -} - -body, html, .content { - height: 100%; -} - -body { - background: #F7F7F7; - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -} - -.pull-right { - float: right; -} - -.pull-left { - float: left; -} - -.clear { - clear: both; - height: 0!important; -} - -header { - background: #084561; - border-bottom: 3px solid #F8AD32; - color: white; - padding: 30px 0; - /* La belle ombre :D */ - /*box-shadow: 0 0 14px rgba(0, 0, 0, 0.7); */ - position:relative; - z-index:1; -} - -.container { - margin: auto; - width: 600px; -} - -.champ { - padding: 5px 0; - -webkit-transition: color .1s ease-in-out; -} - -.disabled .champ { - color: #CCC; -} - -.options { - background-color: white; - padding: 20px; - /*box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);*/ - border-bottom: solid 3px #4D4D4D; - margin : 20px 0; -} - -body > .content { - min-height: 100%; - height: auto; -} - -.form-buttons { - float: right; -} - -input[type="button"] { - color: #DDD; - padding: 0 15px; - border: none; - float: right; - text-decoration: none; - margin-left: 1px; - outline: 0; - height: 40px; - line-height: 40px; - cursor: pointer; -} - -input[type="button"]:hover { - -webkit-transition: background-color .2s; - opacity: 0.95; -} - -#reset { - background: #c0392b; -} - -#enregistrer { - background: #396A81; -} - -input[type="number"] { - border: solid 1px #CCC; - background-color: white; - /*display: block;*/ - padding: 2px 5px; - margin: 2px 0; - box-shadow: inset 0 1px 2px #EEE; -} - -input[type="number"]:focus { - outline: none; - border-color: #6bb4bf; -} - -input[type="checkbox"] { - margin: 4px 4px 0 0; - float: left; -} - -.complement { - color: #999; - font-size: 10px; - display: block; -} - -.sub { - border-left: solid 4px #ddd; - padding: 1px 10px; - margin-bottom: 10px; -} - -.hidden { - display: none; -} - -.experimental { - color: #df3716; - font-weight: bold; - -webkit-transition: color .1s ease-in-out; -} - -.disabled .experimental { - color: #e09f92; -} - -.priority > div { - height: 32px; -} - -.priority .value { - line-height: 32px; - font-size: 11px; - float: right; - width: 100px; -} - -.priority .pull-right { - width: 240px; - height: 32px; -} - -.priority input[type="range"] { - height: 32px; - width: 130px; -} - -footer { - background-color: #f8f8f4; - padding: 15px 0; - font-weight: bold; - color: #454545; - font-size: 12px; - text-align: right; - border-top: solid 2px #D4D4D4; - position: relative; - height: 45px; - margin-top: -76px; - clear: both; -} - -footer a { - text-decoration: none; - color: #03638b; -} - -footer a:hover { - color: #065070; -} - -footer p { - margin: 5px 10px; -} - -.footerSubstitutor { - height: 96px; - width: 100%; -} - -#connecteComme { - margin-bottom: 0; -} - -#connecteComme a { - text-decoration: none; - color: black; - display: block; -} - -#connecteComme img { - margin-top: 10px; - display: block; - margin-left: auto; - margin-right: auto; - padding:8px; - border:solid; - border-color: #dddddd #aaaaaa #aaaaaa #dddddd; - border-width: 1px 2px 2px 1px; - background-color:white; -} \ No newline at end of file diff --git a/Google Chrome/options/options.html b/Google Chrome/options/options.html index b8c67f8..79e3242 100644 --- a/Google Chrome/options/options.html +++ b/Google Chrome/options/options.html @@ -1,120 +1,19 @@ - + + - - - ZdS Notificateur — Options - - - - -
-
-
-

Options de l'extension

-
-
-
-
-
- - -
-
- - Sinon, un clic ouvrira l'accueil de ZdS -
-
-
- - Les notifications s'ouvrent de toute façon dans un nouvel onglet si la page courante n'est pas une page de ZdS -
-
- -
- -
- - La popup se fermera automatiquement lors d'un clic sur une notification -
- -
-
- - Attention, cette option a un comportement incomplet sur Linux et Mac (limitation de Chrome) -
-
- -
-
- - Les notifications seront plus ou moins visibles -
-
- -
-
-
-
-
-
- - Les notifications seront plus ou moins visibles -
-
- -
-
-
-
-
-
- - Un son sera joué pour vous alerter d'une nouvelle notification -
- + + + + + +
+
+ Options: +
+ +
+
+ + -
- - -
-
-
- -
- -
-
- - - - diff --git a/Google Chrome/options/options.js b/Google Chrome/options/options.js index 66f081e..495b914 100644 --- a/Google Chrome/options/options.js +++ b/Google Chrome/options/options.js @@ -1,223 +1,14 @@ -/** - * Notificator Options - * @namespace - */ - -var NotificatorOptions = { - /** - * Init options - */ - init: function(_notificator) { - this.notificator = _notificator; - - this.elems = { - updateInterval: document.getElementById('interval'), - openListe: document.getElementById('openListe'), - openInNewTab: document.getElementById("newTab"), - showAllNotifButton: document.getElementById("allNotifs"), - showDesktopNotif: document.getElementById("notifNative"), - notifPriority: document.getElementById("priorityNotif"), - mpPriority: document.getElementById("priorityMP"), - playSon: document.getElementById("playSon"), - tweet: document.getElementById("tweet"), - // ZdSLink: document.getElementById("ZdSLink"), - autoclosePopup: document.getElementById("autoclosePopup"), - //useDetailedNotifs: document.getElementById("detailedNotifs"), - //archiveAllLink: document.getElementById("archiveAllLink") - }; - - document.getElementById("enregistrer").addEventListener("click", this.save.bind(this)); - document.getElementById("reset").addEventListener("click", this.reset.bind(this)); - this.elems["updateInterval"].addEventListener("keyup", this.checkInput.bind(this)); - this.elems["openListe"].addEventListener("click", this.toggle.bind(this)); - this.elems["showDesktopNotif"].addEventListener("click", this.toggle.bind(this)); - - this.load(); - }, - - oldValue: 5, - - /** - * Check inputs - * @param {Object} [evt] JS Event - */ - checkInput: function(evt) { - var val = this.elems["updateInterval"].value; - if(val == '') - this.elems["updateInterval"].value = this.oldValue; - else { - if(parseInt(val) > 60) { - this.elems["updateInterval"].value = 60; - this.oldValue = 60; - } else { - this.oldValue = val; - } - } - }, - - /** - * Reset options - */ - reset: function() { - var c = confirm("Voulez vous réellement remettre à zéro les options ?"); - if(c) { - this.notificator.resetOptions(); - window.location.reload(); - } - }, - - /** - * Save options - */ - save: function() { - this.notificator.setOptions(this.getValues(), function() { - window.close(); - }); - }, - - /** - * Load options - */ - load: function() { - this.options = this.notificator.getOptions(); - for(var key in this.elems) { - if(this.options[key] !== undefined) { - if(this.elems[key].type == "checkbox") { - this.elems[key].checked = this.options[key]; - } - else { - this.elems[key].value = this.options[key]; - } - } - } - this.toggle(); - this.oldValue = this.elems['updateInterval'].value; - this.checkAvatar(); - }, - - /** - * Get inputs value - * @returns {Object} The input values - */ - getValues: function() { - var obj = {}; - for(var key in this.elems) { - var val = this.elems[key].type == "checkbox" ? this.elems[key].checked : parseInt(this.elems[key].value); - obj[key] = val; - } - return obj; - }, - - /** - * Toggle inputs - */ - toggle: function() { - if(this.elems['showDesktopNotif'].checked) { - Array.prototype.forEach.call(document.querySelectorAll(".subNotifFields"), function(elem) { - elem.classList.remove("disabled"); - - Array.prototype.forEach.call(elem.querySelectorAll("input"), function(input) { - input.removeAttribute("disabled"); - }); - }); - } - else { - Array.prototype.forEach.call(document.querySelectorAll(".subNotifFields"), function(elem) { - elem.classList.add("disabled"); - - Array.prototype.forEach.call(elem.querySelectorAll("input"), function(input) { - input.setAttribute("disabled", true); - }); - }); - } - - if(this.elems['openListe'].checked) { - Array.prototype.forEach.call(document.querySelectorAll(".subPopupFields"), function(elem) { - elem.classList.remove("disabled"); - - Array.prototype.forEach.call(elem.querySelectorAll("input"), function(input) { - input.removeAttribute("disabled"); - }); - }); - } - else { - Array.prototype.forEach.call(document.querySelectorAll(".subPopupFields"), function(elem) { - elem.classList.add("disabled"); - - Array.prototype.forEach.call(elem.querySelectorAll("input"), function(input) { - input.setAttribute("disabled", true); - }); - }); - } - - Array.prototype.forEach.call(document.querySelectorAll(".priority input"), function(input) { - input.addEventListener("input", onPriorityInputChange, false); - onPriorityInputChange.call(input, null); - }); - // $(".priority input").on("change", ).trigger("change"); - function onPriorityInputChange(event) { - var value = "Erreur"; - - switch(parseInt(this.value)) { - case -2: - value = "Pas important"; - break; - case -1: - value = "Peu important"; - break; - case 0: - value = "Normale"; - break; - case 1: - value = "Important"; - break; - case 2: - value = "Très important"; - break; - } - this.parentNode.querySelector(".value").textContent = value; - } - }, - - /** - * Check avatar - */ - checkAvatar: function() { - new AjaxRequest("http://zestedesavoir.com", this.loadCallback.bind(this), "text"); - }, - - /** - * Callback when page loaded - */ - loadCallback: function(event) { - var doc = document.implementation.createHTMLDocument("xhr_result"); - doc.documentElement.innerHTML = event.target.responseText.trim(); - - var leDiv = document.getElementById("connecteComme"); - //on est pas connecté ! - if(!this.notificator.logged) { - leDiv.querySelector("a").setAttribute("href", "http://zestedesavoir.com/membres/connexion/"); - leDiv.querySelector("strong").textContent = "Non connecté !"; - } else { - var link = doc.getElementById("my-account"); - var profileLink = link.getAttribute("href"); - var profileName = link.querySelector("span.username").textContent; - var avatarImgSrc = link.querySelector("img").getAttribute("src").replace(/^\/\/(.*)/, "http://$1"); - leDiv.querySelector("a").setAttribute("href", "http://zestedesavoir.com" + profileLink/* + profileName*/); - - leDiv.querySelector("strong").textContent = profileName; - leDiv.querySelector("img").setAttribute("src", avatarImgSrc); - } - } -}; - -document.addEventListener('DOMContentLoaded', function () { - chrome.runtime.getBackgroundPage(function(bgWindow) { - var notificator = bgWindow.theNotificator; - if(notificator) { - NotificatorOptions.init.call(NotificatorOptions, notificator); - } else { - console.log("Can't fetch the background :("); - } - }); -}); +function saveOptions(e) { + chrome.storage.local.set({ + notify: document.querySelector("#notify").checked + }); +} + +function restoreOptions() { + chrome.storage.local.get('notify', (res) => { + document.querySelector("#notify").checked = res.notify || false; + }); +} + +document.addEventListener('DOMContentLoaded', restoreOptions); +document.querySelector("form").addEventListener("submit", saveOptions); diff --git a/Google Chrome/popup/popup.css b/Google Chrome/popup/popup.css deleted file mode 100644 index 9aa16d4..0000000 --- a/Google Chrome/popup/popup.css +++ /dev/null @@ -1,128 +0,0 @@ -* { - padding: 0; - margin: 0; -} - -body { - font-family: "Source Sans Pro","Segoe UI","Trebuchet MS",Helvetica,"Helvetica Neue",Arial,sans-serif; - font-size: 14px; - line-height: 1.7em; - min-width: 25em; - max-width: 30em; - min-height: 7em; - background-color: #f7f7f7; - color: #222; -} - -a { - text-decoration: none; - color: inherit; - transition-duration: .15s; - outline-color: #f8ad32; -} - -#header{ - text-align: center; - background-color: #084561; - color: #fff; - border-bottom: 3px solid #f8ad32; -} -#header>h1{ - /*font-size: 1.25em;*/ - font-size: 1em; - font-weight: normal; - text-transform: small-caps; - padding: 0; - margin: 0; -} -#logo{ - display: block; - padding: 1.25em; - background: url(../icons/logo-zds.png) no-repeat center; - background-size: contain; -} -#logo:hover{ - opacity: .7; -} -#logo>span{ - font: 0/0 a; - text-shadow: none; - color: transparent; -} - - -.notification { - display: block; - padding: .5em; - vertical-align: middle; -} -.notification::after{ - content: ''; - display: block; - clear: both; -} -.notification:nth-child(2n){ - background-color: #f0f0f0; -} -.notification:hover{ - background-color: #fff; -} -.notification:focus{ - outline: none; - box-shadow: inset 0 0 .5em #c4c4c4; -} -.notification .user-avatar { - float: left; - height: 4em; - width: 4em; -} -.notification .user-name { - display: block; - float: left; - max-width: 50%; - color: #777; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -.notification .details { - position: relative; - padding-left: 4.5em; -} -.notification .date { - display: block; - float: right; - max-width: 50%; - color: #ee8709; - transition-property: color; -} -.notification .title { - display: block; - font-size: 1.2em; - padding: .5em 0 0; - width: 100%; - color: #0e7aa8; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - - -.noNotifs, .notConnected { - padding: 1em .5em; - text-align: center; -} - - -.allNotifs{ - display: block; - padding: 1em; - text-align: center; - background-color: #084561; - color: #fff; - border-top: 3px solid #f8ad32; -} -.allNotifs:hover, .allNotifs:focus{ - outline: none; - background-color: #396a81; -} \ No newline at end of file diff --git a/Google Chrome/popup/popup.html b/Google Chrome/popup/popup.html deleted file mode 100644 index acade41..0000000 --- a/Google Chrome/popup/popup.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - ZdS Notificateur - - - - -
-
- - - - \ No newline at end of file diff --git a/Google Chrome/popup/popup.js b/Google Chrome/popup/popup.js deleted file mode 100644 index d1e72ac..0000000 --- a/Google Chrome/popup/popup.js +++ /dev/null @@ -1,213 +0,0 @@ -var notificator; - -var urlZdS = "http://zestedesavoir.com"; - -var linkListener = function(notificator, event) { - var url = this.href; - if(url === "#") - return; - - event.preventDefault(); - - var link = this; - var isShortcut = this.classList.contains("allNotifs"); - if(!isShortcut) { - var id = parseInt(this.dataset.notificationId, 10); - var isAlerte = this.classList.contains("alerte"); - var isNotification = this.classList.contains("notification"); - } - - chrome.windows.getCurrent({ populate: true }, function(currentWindow) { - var tab = false; - for(var i in currentWindow.tabs) { - if(currentWindow.tabs[i].active) { - tab = currentWindow.tabs[i]; - break; - } - } - if(!notificator.getOptions("openInNewTab") && tab && tab.url !== undefined && tab.url.indexOf("zestedesavoir.com") != -1 && tab.url.indexOf("zestedesavoir.com") < 14) { - if(isAlerte) { - notificator.alertTabId.push(tab.id); - } - chrome.tabs.update(tab.id, { url: url }); - } - else { - chrome.tabs.create({ - 'url': url, - 'active': false - }, function(tab){ - if(isAlerte) { - notificator.alertTabId.push(tab.id); //on ajout l'id du tab - } - }); - } - - if(notificator.getOptions("autoclosePopup")) { - window.close(); - return; - } - - if (isNotification) { - var notification = notificator.getNotification(id); - - if (notification && notification.constructor.name === "Object") { - var notif_index = notificator.notifications.indexOf(notification); - - if (notif_index !== -1) { - notificator.notifications.splice(notif_index, 1); - - setNotifsList(); - notificator.updateBadge(); - } - } - else { - console.log('Notif non trouvée'); - } - - notificator.check(); - } - }); -} - -var createNotif = function(notif) { - var notif_link = document.createElement("a"); - - notif_link.href = urlZdS + notif.link; - - notif_link.classList.add("notification", notif.type); - - notif_link.id = "notif-" + notif.id; - notif_link.dataset.notificationId = notif.id; - - var notif_answerer = document.createElement("div"); - notif_answerer.className = "user"; - - var notif_avatar = document.createElement("img"); - notif_avatar.src = notif.answerer.avatar; - notif_avatar.className = "user-avatar"; - notif_avatar.alt = "Avatar de " + notif.answerer.username; - - notif_answerer.appendChild(notif_avatar); - - notif_link.appendChild(notif_answerer); - - - - var notif_details = document.createElement("div"); - notif_details.className = "details"; - - var notif_pseudo = document.createElement("span"); - notif_pseudo.className = "user-name"; - notif_pseudo.textContent = notif.answerer.username; - - notif_details.appendChild(notif_pseudo); - - var notif_date = document.createElement("time"); - notif_date.className = "date"; - notif_date.textContent = notif.date; - - notif_details.appendChild(notif_date); - - - var notif_title = document.createElement("span"); - notif_title.className = "title"; - notif_title.textContent = notif.title; - - notif_details.appendChild(notif_title); - - notif_link.appendChild(notif_details); - - return notif_link; -}; - -var setNotifsList = function() { - var content = document.getElementById("content"); - var notifs = notificator.notifications; - - while (content.firstChild) { - content.removeChild(content.firstChild); - } - - if(notificator.logged || notificator.useFakeData) { - var len = notifs.length; - - var notifList = document.createElement("div"); - notifList.classList.add("notifList"); - - if(len === 0) { - var no_notifs_elem = document.createElement("div"); - no_notifs_elem.classList.add("element", "other", "noNotifs"); - - var no_notifs_text = document.createElement("span"); - no_notifs_text.textContent = "Aucune nouvelle notification"; - - no_notifs_elem.appendChild(no_notifs_text); - content.appendChild(no_notifs_elem); - } else { - for(var i = 0; i < len; i++) { - var n = createNotif(notifs[i]); - notifList.appendChild(n); - } - - content.appendChild(notifList); - } - - //ligne "Afficher toute les notifications" - if(notificator.getOptions("showAllNotifButton")) { - var all_notifs_link = document.createElement("a"); - all_notifs_link.classList.add("element", "other", "allNotifs"); - all_notifs_link.href = urlZdS + "/forums/notifications"; - all_notifs_link.textContent = "Toutes les notifications"; - - content.appendChild(all_notifs_link); - } - - var liens = document.querySelectorAll("#content a"); - for (var i = 0; i < liens.length; i++) { - liens[i].addEventListener("click", linkListener.bind(liens[i], notificator), false); - } - - notificator.setNewNotifCallback(function(notif) { - var no_notifs_elem = document.querySelector(".noNotifs"); - if (no_notifs_elem) { - no_notifs_elem.parentNode.removeChild(no_notifs_elem); - } - - var n = createNotif(notif); - - var liens = n.getElementsByTagName("a"); - - for (var i = 0; i < liens.length; i++) { - liens[i].addEventListener("click", linkListener.bind(liens[i], notificator), false); - } - - notifList.appendChild(n); - }); - } - else { - var not_logged_in_elem = document.createElement("div"); - not_logged_in_elem.classList.add("element", "other", "notConnected"); - not_logged_in_elem.textContent = "Vous n'êtes pas connecté !"; - - content.appendChild(not_logged_in_elem); - } -} - -var backgroundLoaded = function(bgWindow) { - if(!bgWindow || !bgWindow.theNotificator) { - console.error("ZdSNotificator : Failed to load background"); - return; - } - notificator = bgWindow.theNotificator; - - var logo = document.getElementById("logo"); - logo.href = urlZdS; - - logo.addEventListener("click", linkListener.bind(logo, notificator), false); - - setNotifsList(); -}; - -chrome.runtime.getBackgroundPage(function(bgWindow) { - backgroundLoaded(bgWindow); -}); diff --git a/Google Chrome/sounds/packs.json b/Google Chrome/sounds/packs.json deleted file mode 100644 index 33682b6..0000000 --- a/Google Chrome/sounds/packs.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "sounds": { - "standard": { - "name": "Pack Standard", - "folder": "standard", - "sounds": { - "notif_new": "Ting.wav", - "mp_new": "Ting.wav", - "notif_mp_new": "Ting.wav" - } - } - }, - "default_soundpack": "standard" -} \ No newline at end of file diff --git a/Google Chrome/sounds/standard/Ting.wav b/Google Chrome/sounds/standard/Ting.wav deleted file mode 100644 index 957026c..0000000 Binary files a/Google Chrome/sounds/standard/Ting.wav and /dev/null differ diff --git a/Google Chrome/welcome/welcome.css b/Google Chrome/welcome/welcome.css deleted file mode 100644 index 7f2e78b..0000000 --- a/Google Chrome/welcome/welcome.css +++ /dev/null @@ -1,136 +0,0 @@ -html, body, h1, h2, h3, h4, h5, h6, p { - margin: 0; - padding: 0; -} - -* { - -webkit-box-sizing: border-box; -} - -body { - background: #ECECEC; - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - color: #333; -} - -a { - text-decoration: none; - color: #084561; -} - -a:hover { - text-decoration: underline; -} - -.clearfix:after { - clear: both; - height: 1px; - width: 1px; - content: " "; - display: block; -} - -.container { - width: 800px; - margin: auto; -} - -header { - padding: 40px 0; -} - -.logo { - width: 128px; - margin: auto; -} - -header h1 { - line-height: 40px; - font-size: 2em; - padding: 82px 0 6px 142px; - color: rgb(9,33,49); -} - -section { - margin: 20px; - font-size: 1.2em; - line-height: 1.4em; -} - -.github-btns { - margin-top: 30px; -} - -.github-btns .wrapper { - width: 50%; - float: left; -} - -.github-btns .wrapper .button { - margin: auto; - width: 80px; -} - -.links { - border-top: solid 1px #E3E3E3; - border-bottom: solid 1px #E3E3E3; - height: 62px; - line-height: 20px; - background-color: #f8f8f4; - padding: 20px; - color: #707070; - text-align: center; -} - -.links a { -} - -.authors { -} - -.authors .author { - width: 45%; - margin-top: 40px; - margin-left: 10%; - padding: 6px; - background-color: white; - border-bottom: solid 2px #4D4D4D; -} - -.authors .author:nth-child(2n+1) { - float: left; - margin-left: 0; -} - -.authors .author:nth-child(2n) { - float: right; -} - -.avatar { - height: 96px; - width: 96px; - background-position: center; - background-size: contain; - background-repeat: no-repeat; -} - -.author .avatar { - float: left; - margin: 5px; -} - -.author .avatar img { - padding: 2px; -} - -.author .text { - margin: 5px; - padding-left: 116px; - font-size: 0.9em; - color: #454545; -} - -.author .text h3 { - color: #222; - margin: 2px 0; -} diff --git a/Google Chrome/welcome/welcome.html b/Google Chrome/welcome/welcome.html deleted file mode 100644 index 08b5944..0000000 --- a/Google Chrome/welcome/welcome.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - - Merci d'avoir installé le ZdS Notificateur! - - - -
-
- -

Merci d'avoir installé le ZdS Notificateur!

-
-
- -
-
-

- Cette extension vous permet d'être averti lorsque vous recevez un nouveau message ou une nouvelle notification sur Zeste de Savoir. -

-

- Elle récupère à intervalle régulier les dernières notifications sur ZesteDeSavoir. -

-

- De nombreux paramètres sont réglables sur la page des options. -

- -
-
-
- -
-
-
-
- -
-
-
-
-
- - - -
-
-
-
-
-

Eskimon

-

Codeur de la première heure, Eskimon est à l'origine de l'idée.

-

Twitter - Profil ZdS

-
-
-
-
-
-

Sandhose

-

Horrifié par le code d'Eskimon, Sandhose a décidé de filer un coup de patte à Eskimon.

-

Twitter - Profil ZdS

-
-
-
-
-
-

viki53

-

Après une bose dose d'agrumes, il fallait utiliser toute cette énergie pour une bonne cause !

-

Twitter - Profil ZdS

-
-
-
-
- -