Descrizione
cartuccia per Epson Expression Home XP-102 XP-202 XP-205 XP-212 XP-215 XP-225 {
// Update the UI to include the received message.
appendMessage(payload);
});
// Update the UI when the user grants permissions.
function uiRequest() {
// Get registration token. Initially this makes a network call, once retrieved
// subsequent calls to getToken will return from cache.
messaging.getToken({vapidKey: vapidKey}).then((currentToken) => {
if (currentToken) {
sendTokenToServer(currentToken);
} else {
// Show permission request.
console.log('No registration token available. Request permission to generate one.');
// Show permission UI.
setTokenSentToServer(false);
}
}).catch((err) => {
console.log('An error occurred while retrieving token. ', err);
setTokenSentToServer(false);
});
}
// Send the registration token your application server, so that it can:
// - send messages back to this app
// - subscribe/unsubscribe the token from topics
function sendTokenToServer(currentToken) {
if (!isTokenSentToServer(currentToken)) {
// Send the current token to server.
jQuery.ajax({
type: "post",
dataType: "json",
url: '/wp-admin/admin-ajax.php',
data: {token: currentToken, action: 'storefirebasetoken'},
success: function(msg){
// Token is stored or was already stored
return true;
},
error: function (err){
console.log(err);
}
});
setTokenSentToServer(currentToken);
} else {
console.log('Token already sent to server so won\'t send it again ' +
'unless it changes');
}
}
//Start watching this note treed
function watchNote(){
// Send the current note iD to server.
jQuery.ajax({
type: "post",
dataType: "json",
url: '/wp-admin/admin-ajax.php',
data: {note: getCommunityID(), action: 'watchnote'},
success: function(resp){
let message = resp.success ? resp.data.message : resp.data.error;
__notyMessage(message, false);
},
error: function (err){
__notyMessage(err.data.error, false);
}
});
}
// Stop watching this note treed
function unwatchNote(){
// Send the current note ID to server.
jQuery.ajax({
type: "post",
dataType: "json",
url: '/wp-admin/admin-ajax.php',
data: {note: getCommunityID(), action: 'unwatchnote'},
success: function(resp){
let message = resp.success ? resp.data.message : resp.data.error;
__notyMessage(message, false);
},
error: function (err){
__notyMessage(err.data.error, false);
}
});
}
function isTokenSentToServer(token) {
return window.localStorage.getItem('sentToServer') === token;
}
function setTokenSentToServer(sentToken) {
window.localStorage.setItem('sentToServer', sentToken ? sentToken : '0');
}
// Add a message to the messages element.
function appendMessage(payload) {
let noticeTitle = payload.notification.title;
// If i didn't add a comment, show the notification
if ( Cookies.get("firebase_user_custom_id") !== payload.data.firebase_user_custom_id){
__notyMessage(noticeTitle, payload.data.post_url);
}
}
// Create noty message with, or not, hyperlink button
function __notyMessage(noticeTitle, showLink ){
let message = ' ';
}else {
message += noticeTitle +' .