Skip to content

Commit

Permalink
Re-factor some functionality, new top-bar icon
Browse files Browse the repository at this point in the history
  • Loading branch information
tevfik6 committed Oct 12, 2017
1 parent 01d5d09 commit fd99f02
Show file tree
Hide file tree
Showing 6 changed files with 2,037 additions and 308 deletions.
72 changes: 33 additions & 39 deletions custom.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,46 @@
var $tev = require("jquery");
var ipcR = require('electron').ipcRenderer
var debounceTimer;
var updateDockNum;
$(function(){
// console.log("defaultSettings", defaultSettings);

var wasApp = {
messageCount: 0,
$tev(function() {
var wasApp = {
settings: defaultSettings
};
// console.log("wasApp", wasApp);

var changeSettings = function (key, value) {
var changeSettings = function(key, value) {
// console.log(key, value);
wasApp.settings[key] = value;
wasApp['changedSettings'] = {};
wasApp['changedSettings'][key] = value;
wasApp['changedSettings'] = {};
wasApp['changedSettings'][key] = value;
// console.log("wasApp", wasApp);
document.title = JSON.stringify(wasApp);
wasApp.changedSettings = 1;
delete wasApp.changedSettings;
// console.log("wasApp", wasApp);
wasApp.changedSettings = 1;
delete wasApp.changedSettings;
// console.log("wasApp", wasApp);
};

updateDockNum = function () {
updateDockNum = function() {
// console.log( "updateDockNum is running" );
wasApp.messageCount = 0;
$(".unread-count").each(function(i, v){
var $this = $(this);
// console.log($this.html(), $this.text(), $this);
wasApp.messageCount += parseInt( $this.text() );
var selector = ".chat.unread"
var messageCount = 0;
var elementCount = $tev(selector).length;
// console.log( "elementCount is", elementCount);
$tev(selector).each(function(i, v) {
var $this = $tev(this).find(".chat-secondary .chat-meta > span > div > span");
if ($this.length > 0) {
// console.log($this.html(), $this.text(), $this);
messageCount += parseInt($this.text());
}
if(i == elementCount-1){
// console.log("Message count sent", messageCount);
ipcR.send('message-count', messageCount)
}
});
setTimeout(function() {
// console.log(wasApp, JSON.stringify(wasApp));
document.title = JSON.stringify(wasApp);
}, 25)
if(elementCount == 0){
ipcR.send('no-message');
}
};

$(document).delegate('.chat-meta', 'DOMSubtreeModified', function(event) {
updateDockNum();
$tev(document).delegate('.chat-meta', 'DOMSubtreeModified', function(event) {
clearTimeout(debounceTimer);
debounceTimer = setTimeout("updateDockNum()", 250);
});

var trialCount = 3;
function updateDockNumRecursive() {
setTimeout( function () {
// console.log( "trialCount", trialCount );
if( trialCount >= 0 ){
updateDockNum();
updateDockNumRecursive();
};
}, 1000 );
trialCount--;
};
});
});
Binary file modified icons/icon_menubar_alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/icon_menubar_alert@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit fd99f02

Please sign in to comment.