Initial rework of Cordova branch
This commit is contained in:
parent
e7fdf05890
commit
6de8bdc41a
5 changed files with 73 additions and 12 deletions
13
bower.json
13
bower.json
|
@ -14,7 +14,16 @@
|
||||||
"angular-mocks": "1.5.x",
|
"angular-mocks": "1.5.x",
|
||||||
"html5-boilerplate": "~4.3.0",
|
"html5-boilerplate": "~4.3.0",
|
||||||
"underscore": "~1.8",
|
"underscore": "~1.8",
|
||||||
"bootstrap": "~3.1",
|
"bootstrap": "~3.3",
|
||||||
"emojione": "~2.2"
|
"emojione": "~2.2"
|
||||||
}
|
},
|
||||||
|
"keywords": [
|
||||||
|
"weechat",
|
||||||
|
"irc"
|
||||||
|
],
|
||||||
|
"ignore": [
|
||||||
|
"**/.*",
|
||||||
|
"node_modules",
|
||||||
|
"bower_components"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
5
js/app.js
Normal file
5
js/app.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
document.addEventListener("deviceready", function () {
|
||||||
|
if (navigator.splashscreen !== undefined) {
|
||||||
|
navigator.splashscreen.hide();
|
||||||
|
}
|
||||||
|
}, false);
|
|
@ -234,7 +234,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
$scope.notifications = notifications.unreadCount('notification');
|
$scope.notifications = notifications.unreadCount('notification');
|
||||||
$scope.unread = notifications.unreadCount('unread');
|
$scope.unread = notifications.unreadCount('unread');
|
||||||
|
|
||||||
if (settings.useFavico && $rootScope.favico) {
|
if (cordova === undefined && settings.useFavico && $rootScope.favico) {
|
||||||
notifications.updateFavico();
|
notifications.updateFavico();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -250,6 +250,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
$scope.connectbutton = 'Connect';
|
$scope.connectbutton = 'Connect';
|
||||||
$scope.connectbuttonicon = 'glyphicon-chevron-right';
|
$scope.connectbuttonicon = 'glyphicon-chevron-right';
|
||||||
bufferResume.reset();
|
bufferResume.reset();
|
||||||
|
|
||||||
|
if (window.plugin !== undefined && window.plugin.notification !== undefined && window.plugin.notification.local !== undefined) {
|
||||||
|
window.plugin.notification.local.cancelAll();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
$scope.connectbutton = 'Connect';
|
$scope.connectbutton = 'Connect';
|
||||||
$scope.connectbuttonicon = 'glyphicon-chevron-right';
|
$scope.connectbuttonicon = 'glyphicon-chevron-right';
|
||||||
|
@ -369,6 +373,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
if (!$rootScope.connected) {
|
if (!$rootScope.connected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cordova !== undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (useFavico) {
|
if (useFavico) {
|
||||||
notifications.updateFavico();
|
notifications.updateFavico();
|
||||||
} else {
|
} else {
|
||||||
|
@ -382,7 +391,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
// This also fires when the page is loaded if enabled.
|
// This also fires when the page is loaded if enabled.
|
||||||
// Note that this says MathJax but we switched to KaTeX
|
// Note that this says MathJax but we switched to KaTeX
|
||||||
settings.addCallback('enableMathjax', function(enabled) {
|
settings.addCallback('enableMathjax', function(enabled) {
|
||||||
if (enabled && !$rootScope.mathjax_init) {
|
if (cordova === undefined && enabled && !$rootScope.mathjax_init) {
|
||||||
// Load MathJax only once
|
// Load MathJax only once
|
||||||
$rootScope.mathjax_init = true;
|
$rootScope.mathjax_init = true;
|
||||||
|
|
||||||
|
@ -803,7 +812,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
if ($rootScope.connected) {
|
if ($rootScope.connected) {
|
||||||
$scope.disconnect();
|
$scope.disconnect();
|
||||||
}
|
}
|
||||||
$scope.favico.reset();
|
|
||||||
|
if (cordova !== undefined) {
|
||||||
|
$scope.favico.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,21 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu
|
||||||
$log.info('Service Worker err:', err);
|
$log.info('Service Worker err:', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener('deviceready', function() {
|
||||||
|
// Add cordova local notification click handler
|
||||||
|
if (cordova !== null && cordova.plugins !== undefined && cordova.plugins.notification !== undefined &&
|
||||||
|
cordova.plugins.notification.local !== undefined) {
|
||||||
|
cordova.plugins.notification.local.on("click", function (notification) {
|
||||||
|
// go to buffer
|
||||||
|
var data = JSON.parse(notification.data);
|
||||||
|
models.setActiveBuffer(data.buffer);
|
||||||
|
window.focus();
|
||||||
|
// clear this notification
|
||||||
|
cordova.plugins.notification.local.clear(notification.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var showNotification = function(buffer, title, body) {
|
var showNotification = function(buffer, title, body) {
|
||||||
|
@ -66,7 +81,7 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu
|
||||||
|
|
||||||
toastNotifier.show(toast);
|
toastNotifier.show(toast);
|
||||||
|
|
||||||
} else {
|
} else if (typeof Notification !== 'undefined') {
|
||||||
|
|
||||||
var notification = new Notification(title, {
|
var notification = new Notification(title, {
|
||||||
body: body,
|
body: body,
|
||||||
|
@ -97,6 +112,22 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu
|
||||||
delete notifications[this.id];
|
delete notifications[this.id];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} else if (cordova !== undefined && cordova.plugins !== undefined && cordova.plugins.notification !== undefined && cordova.plugins.notification.local !== undefined) {
|
||||||
|
// Cordova local notification
|
||||||
|
// Calculate notification id from buffer ID
|
||||||
|
// Needs to be unique number, but we'll only ever have one per buffer
|
||||||
|
var id = parseInt(buffer.id, 16);
|
||||||
|
|
||||||
|
// Cancel previous notification for buffer (if there was one)
|
||||||
|
cordova.plugins.notification.local.clear(id);
|
||||||
|
|
||||||
|
// Send new notification
|
||||||
|
cordova.plugins.notification.local.schedule({
|
||||||
|
id: id,
|
||||||
|
text: body,
|
||||||
|
title: title,
|
||||||
|
data: { buffer: buffer.id } // remember buffer id for when the notification is clicked
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -135,6 +166,10 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu
|
||||||
};
|
};
|
||||||
|
|
||||||
var updateFavico = function() {
|
var updateFavico = function() {
|
||||||
|
if (cordova !== undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var notifications = unreadCount('notification');
|
var notifications = unreadCount('notification');
|
||||||
if (notifications > 0) {
|
if (notifications > 0) {
|
||||||
$rootScope.favico.badge(notifications, {
|
$rootScope.favico.badge(notifications, {
|
||||||
|
@ -200,7 +235,7 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu
|
||||||
|
|
||||||
showNotification(buffer, title, body);
|
showNotification(buffer, title, body);
|
||||||
|
|
||||||
if (settings.soundnotification) {
|
if (cordova === undefined && settings.soundnotification) {
|
||||||
// TODO fill in a sound file
|
// TODO fill in a sound file
|
||||||
var audioFile = "assets/audio/sonar";
|
var audioFile = "assets/audio/sonar";
|
||||||
var soundHTML = '<audio autoplay="autoplay"><source src="' + audioFile + '.ogg" type="audio/ogg" /><source src="' + audioFile + '.mp3" type="audio/mpeg" /></audio>';
|
var soundHTML = '<audio autoplay="autoplay"><source src="' + audioFile + '.ogg" type="audio/ogg" /><source src="' + audioFile + '.mp3" type="audio/mpeg" /></audio>';
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "Glowing Bear",
|
"name": "Glowing Bear",
|
||||||
"description": "WeeChat Web frontend",
|
"description": "WeeChat Web frontend",
|
||||||
"launch_path": "/glowing-bear/index.html",
|
"launch_path": "/index.html",
|
||||||
"icons": {
|
"icons": {
|
||||||
"128": "/glowing-bear/assets/img/glowing_bear_128x128.png",
|
"128": "/assets/img/glowing_bear_128x128.png",
|
||||||
"60": "/glowing-bear/assets/img/glowing_bear_60x60.png",
|
"60": "/assets/img/glowing_bear_60x60.png",
|
||||||
"90": "/glowing-bear/assets/img/glowing_bear_90x90.png",
|
"90": "/assets/img/glowing_bear_90x90.png",
|
||||||
"32": "/glowing-bear/assets/img/favicon.png"
|
"32": "/assets/img/favicon.png"
|
||||||
},
|
},
|
||||||
"installs_allowed_from": [
|
"installs_allowed_from": [
|
||||||
"*"
|
"*"
|
||||||
|
|
Loading…
Reference in a new issue