Add HTML entity decoding to browser notifications
This commit is contained in:
parent
af3a672570
commit
62a2d0603d
1 changed files with 21 additions and 16 deletions
35
js/main.js
35
js/main.js
|
@ -18,23 +18,28 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openClose(theID) {
|
function openClose(theID) {
|
||||||
if(document.getElementById(theID).style.display == "block") {
|
if(document.getElementById(theID).style.display == "block") {
|
||||||
document.getElementById(theID).style.display = "none"
|
document.getElementById(theID).style.display = "none"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
document.getElementById(theID).style.display = "block"
|
document.getElementById(theID).style.display = "block"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openMenu(theID) {
|
function openMenu(theID) {
|
||||||
document.getElementById(theID).style.display = "block"
|
document.getElementById(theID).style.display = "block"
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeMenu(theID) {
|
function closeMenu(theID) {
|
||||||
document.getElementById(theID).style.display = "none"
|
document.getElementById(theID).style.display = "none"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function decodeHtml(html) {
|
||||||
|
var txt = document.createElement("textarea");
|
||||||
|
txt.innerHTML = html;
|
||||||
|
return txt.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var src = null;
|
var src = null;
|
||||||
|
@ -275,7 +280,7 @@
|
||||||
if (notification_lastitem!== null && notification_id > notification_lastitem) {
|
if (notification_lastitem!== null && notification_id > notification_lastitem) {
|
||||||
if (getNotificationPermission()==="granted") {
|
if (getNotificationPermission()==="granted") {
|
||||||
var notification = new Notification(document.title, {
|
var notification = new Notification(document.title, {
|
||||||
body: e.text().replace('→ ','').format(e.attr('name')),
|
body: decodeHtml(e.text().replace('→ ','').format(e.attr('name'))),
|
||||||
icon: e.attr('photo'),
|
icon: e.attr('photo'),
|
||||||
});
|
});
|
||||||
notification['url'] = e.attr('href');
|
notification['url'] = e.attr('href');
|
||||||
|
|
Loading…
Reference in a new issue