2017-10-03 12:17:14 +02:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
(function(){
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const {createCollapser, createActionButtons} = require("./gui");
|
|
|
|
|
|
|
|
const actions = [];
|
|
|
|
const addAction = function addAction(action){
|
|
|
|
actions.push(action);
|
|
|
|
};
|
|
|
|
|
|
|
|
class Notification{
|
|
|
|
constructor(data){
|
|
|
|
Object.entries(data).forEach(function(entry){
|
|
|
|
const [key, value] = entry;
|
|
|
|
this[key] = value;
|
|
|
|
}, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
node(){
|
|
|
|
const node = document.createElement("li");
|
|
|
|
|
2017-10-14 12:24:53 +02:00
|
|
|
node.appendChild(document.createTextNode(this.timestamp.toLocaleString() + ": "));
|
|
|
|
node.appendChild(this.textNode());
|
2017-10-03 12:17:14 +02:00
|
|
|
if (this.dataURL){
|
2018-08-22 22:16:49 +02:00
|
|
|
node.className = "notification collapsible collapsed";
|
2017-10-14 12:24:53 +02:00
|
|
|
node.appendChild(document.createElement("br"));
|
2017-10-03 12:17:14 +02:00
|
|
|
createCollapser(node);
|
|
|
|
const img = document.createElement("img");
|
|
|
|
img.src = this.dataURL;
|
2017-10-14 12:24:53 +02:00
|
|
|
img.className = "fakedCanvasContent collapsing";
|
2017-10-03 12:17:14 +02:00
|
|
|
node.appendChild(img);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.node = function(){
|
|
|
|
return node;
|
|
|
|
};
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2017-10-14 12:24:53 +02:00
|
|
|
textNode(){
|
|
|
|
const node = document.createElement("span");
|
|
|
|
node.className = "text hasHiddenActions";
|
|
|
|
this.textNode = function(){
|
|
|
|
return node;
|
|
|
|
};
|
|
|
|
node.textContent = this.functionName;
|
|
|
|
node.title = this.url.href;
|
|
|
|
node.appendChild(this.actionsNode());
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2017-10-03 12:17:14 +02:00
|
|
|
actionsNode(){
|
|
|
|
const node = document.createElement("div");
|
|
|
|
|
|
|
|
node.className = "actions";
|
|
|
|
createActionButtons(node, actions, this);
|
|
|
|
|
|
|
|
if (this.dataURL){
|
|
|
|
node.classList.add("imageAvailable");
|
|
|
|
}
|
|
|
|
|
|
|
|
this.actionsNode = function(){
|
|
|
|
return node;
|
|
|
|
};
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
update(){}
|
|
|
|
}
|
|
|
|
Notification.addAction = addAction;
|
2019-04-08 00:02:29 +02:00
|
|
|
|
|
|
|
if ((typeof module) !== "undefined"){
|
|
|
|
module.exports = Notification;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
require.register("./Notification", Notification);
|
|
|
|
}
|
2017-10-03 12:17:14 +02:00
|
|
|
}());
|