Do not display notifications when popup is open (and remove traces)

This commit is contained in:
fermin831 2017-11-27 19:14:31 +01:00
parent 0b3c42bb03
commit 5c9822111d
3 changed files with 11 additions and 13 deletions

View File

@ -65,11 +65,16 @@ function getEvents(reply){
// Discriminate the new events // Discriminate the new events
newEvents=fetchNewEvents(fetchedEvents,storedEvents); newEvents=fetchNewEvents(fetchedEvents,storedEvents);
// Display the notifications // Display the notifications only if popup is not showing
for(var k=0;k<newEvents.length;k++){ var views = chrome.extension.getViews({ type: "popup" });
localStorage["new_events"]++; if (views.length == 0) {
displayNotification (newEvents[k]) for(var k=0;k<newEvents.length;k++){
alertsSound(newEvents[k]); localStorage["new_events"]++;
displayNotification (newEvents[k])
alertsSound(newEvents[k]);
}
} else {
localStorage["new_events"] = 0;
} }
storedEvents = fetchedEvents; storedEvents = fetchedEvents;
@ -114,6 +119,7 @@ function parseReplyEvents (reply) {
for(var i=0;i<e_array.length;i++){ for(var i=0;i<e_array.length;i++){
// Avoid to parse empty lines // Avoid to parse empty lines
if (e_array[i].length == 0) continue; if (e_array[i].length == 0) continue;
var event=e_array[i].split(";"); var event=e_array[i].split(";");
fetchedEvents.push({ fetchedEvents.push({
'id' : event[0], 'id' : event[0],

View File

@ -92,12 +92,6 @@ function disable(state){
} }
} }
function windowClose() {
//window.close();
console.log("close");
}
//Add callbacks to elements //Add callbacks to elements
$(document).ready (function () { $(document).ready (function () {
@ -167,5 +161,4 @@ $(document).ready (function () {
$("#close").click (function () { $("#close").click (function () {
window.close(); window.close();
}); });
}); });

View File

@ -64,7 +64,6 @@ function showError(text){
function showEvents(){ function showEvents(){
clearError(); clearError();
console.log("showEvents!!");
$('#events').empty(); $('#events').empty();
var e_refr = document.getElementById('event_temp'); var e_refr = document.getElementById('event_temp');
if(e_refr){ if(e_refr){