Browse Source

Merge 7783ca47c0 into 3c20f55e85

pull/92/merge
Eduard Mayer 9 years ago committed by GitHub
parent
commit
bcfd7e8f22
  1. 5
      app/Application.js
  2. 15
      app/util/Format.js
  3. 24
      app/ux/WebView.js
  4. 2
      bootstrap.json
  5. 2
      sass/example/bootstrap.json

5
app/Application.js

@ -1,5 +1,8 @@
Ext.define('Rambox.Application', {
extend: 'Ext.app.Application'
,requires: [
'Rambox.util.Format'
]
,name: 'Rambox'
@ -101,7 +104,7 @@ Ext.define('Rambox.Application', {
,updateTotalNotifications: function( newValue, oldValue ) {
newValue = parseInt(newValue);
if ( newValue > 0 ) {
document.title = 'Rambox (' + newValue + ')';
document.title = 'Rambox (' + Rambox.util.Format.formatNumber(newValue) + ')';
} else {
document.title = 'Rambox';
}

15
app/util/Format.js

@ -0,0 +1,15 @@
/**
* Created by vsxed on 7/11/2016.
*/
Ext.define('Rambox.util.Format', {
singleton: true,
formatNumber: function(n) {
return n.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
},
stripNumber: function(n) {
return (typeof n == "number") ? n : parseInt(n.match(/\d+/g).join(""));
}
});

24
app/ux/WebView.js

@ -4,6 +4,9 @@
Ext.define('Rambox.ux.WebView',{
extend: 'Ext.panel.Panel'
,xtype: 'webview'
,requires: [
'Rambox.util.Format'
]
// private
,notifications: 0
@ -67,8 +70,12 @@ Ext.define('Rambox.ux.WebView',{
,onBadgeTextChange: function( tab, badgeText, oldBadgeText ) {
if ( oldBadgeText === null ) oldBadgeText = 0;
oldBadgeText = Rambox.util.Format.stripNumber(oldBadgeText);
badgeText = Rambox.util.Format.stripNumber(badgeText);
var actualNotifications = Rambox.app.getTotalNotifications();
Rambox.app.setTotalNotifications(actualNotifications - parseInt(oldBadgeText) + parseInt(badgeText));
Rambox.app.setTotalNotifications(actualNotifications - oldBadgeText + badgeText);
}
,onAfterRender: function() {
@ -120,9 +127,12 @@ Ext.define('Rambox.ux.WebView',{
webview.addEventListener("page-title-updated", function(e) {
var count = e.title.match(/\(([^)]+)\)/); // Get text between (...)
count = count ? count[1] : '0';
count = count.match(/\d+/g); // Some services have special characters. Example: (•)
count = count ? parseInt(count[0]) : 0;
count = count ? count[1] : '0';
count = count.match(/\d+/g).join(""); // Some services have special characters. Example: (•)
count = count ? parseInt(count) : 0;
var formattedCount = Rambox.util.Format.formatNumber(count);
switch ( me.type ) {
case 'messenger':
@ -130,7 +140,7 @@ Ext.define('Rambox.ux.WebView',{
me.notifications = count;
}
if ( count || e.title === 'Messenger' ) {
me.tab.setBadgeText(count);
me.tab.setBadgeText(formattedCount);
}
if ( e.title === 'Messenger' ) me.notifications = 0;
break;
@ -139,12 +149,12 @@ Ext.define('Rambox.ux.WebView',{
me.notifications = count;
}
if ( count || e.title === 'Google Hangouts' ) {
me.tab.setBadgeText(count);
me.tab.setBadgeText(formattedCount);
}
if ( e.title === 'Google Hangouts' ) me.notifications = 0;
break;
default:
me.tab.setBadgeText(count);
me.tab.setBadgeText(formattedCount);
me.notifications = count;
break;
}

2
bootstrap.json

File diff suppressed because one or more lines are too long

2
sass/example/bootstrap.json

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save