|
|
@ -158,7 +158,8 @@ Ext.define('Rambox.ux.WebView',{ |
|
|
|
,autosize: 'on' |
|
|
|
,autosize: 'on' |
|
|
|
,disablewebsecurity: 'on' |
|
|
|
,disablewebsecurity: 'on' |
|
|
|
,blinkfeatures: 'ApplicationCache,GlobalCacheStorage' |
|
|
|
,blinkfeatures: 'ApplicationCache,GlobalCacheStorage' |
|
|
|
,useragent: Ext.getStore('ServicesList').getById(me.record.get('type')).get('userAgent') |
|
|
|
,useragent: Ext.getStore('ServicesList').getById(me.record.get('type')).get('userAgent'), |
|
|
|
|
|
|
|
preload: './resources/js/rambox-service-api.js' |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -296,6 +297,45 @@ Ext.define('Rambox.ux.WebView',{ |
|
|
|
webview.executeJavaScript('document.body.scrollTop=0;'); |
|
|
|
webview.executeJavaScript('document.body.scrollTop=0;'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
webview.addEventListener('ipc-message', function(event) { |
|
|
|
|
|
|
|
var channel = event.channel; |
|
|
|
|
|
|
|
switch (channel) { |
|
|
|
|
|
|
|
case 'rambox.setUnreadCount': |
|
|
|
|
|
|
|
handleSetUnreadCount(event); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'rambox.clearUnreadCount': |
|
|
|
|
|
|
|
handleClearUnreadCount(event); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Handles 'rambox.clearUnreadCount' messages. |
|
|
|
|
|
|
|
* Clears the unread count. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
function handleClearUnreadCount() { |
|
|
|
|
|
|
|
me.tab.setBadgeText(''); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Handles 'rambox.setUnreadCount' messages. |
|
|
|
|
|
|
|
* Sets the badge text if the event contains an integer as first argument. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param event |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
function handleSetUnreadCount(event) { |
|
|
|
|
|
|
|
if (Array.isArray(event.args) === true && event.args.length > 0) { |
|
|
|
|
|
|
|
var count = event.args[0]; |
|
|
|
|
|
|
|
if (count === parseInt(count, 10)) { |
|
|
|
|
|
|
|
me.tab.setBadgeText(Rambox.util.Format.formatNumber(count)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Register page title update event listener only for services that don't prevent it by setting 'dont_update_unread_from_title' to true. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
if (Ext.getStore('ServicesList').getById(me.record.get('type')).get('dont_update_unread_from_title') !== true) { |
|
|
|
webview.addEventListener("page-title-updated", function(e) { |
|
|
|
webview.addEventListener("page-title-updated", function(e) { |
|
|
|
var count = e.title.match(/\(([^)]+)\)/); // Get text between (...)
|
|
|
|
var count = e.title.match(/\(([^)]+)\)/); // Get text between (...)
|
|
|
|
count = count ? count[1] : '0'; |
|
|
|
count = count ? count[1] : '0'; |
|
|
@ -304,6 +344,7 @@ Ext.define('Rambox.ux.WebView',{ |
|
|
|
|
|
|
|
|
|
|
|
me.tab.setBadgeText(Rambox.util.Format.formatNumber(count)); |
|
|
|
me.tab.setBadgeText(Rambox.util.Format.formatNumber(count)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
webview.addEventListener('did-get-redirect-request', function( e ) { |
|
|
|
webview.addEventListener('did-get-redirect-request', function( e ) { |
|
|
|
if ( e.isMainFrame ) webview.loadURL(e.newURL); |
|
|
|
if ( e.isMainFrame ) webview.loadURL(e.newURL); |
|
|
|