Skip to content

Instantly share code, notes, and snippets.

@cat-in-136
Created August 9, 2014 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cat-in-136/956353fffd720ce66328 to your computer and use it in GitHub Desktop.
Save cat-in-136/956353fffd720ce66328 to your computer and use it in GitHub Desktop.
サイボウズLiveのWeb Notification API勝手に対応ハック
Notification.requestPermission(function(status) {
var NotificationCount = require("common/cbaToolMenu").NotificationCount;
var doSuccess_orig = NotificationCount.doSuccess;
NotificationCount.doSuccess = function (e) {
doSuccess_orig(e);
var text = "";
if (e.updateCount > 0) { text += "新着情報x" + e.updateCount + "\n"; }
if (e.goodCount > 0) { text += "いいね!x" + e.goodCount + "\n"; }
if (e.enqueteCount > 0) { text += "アンケートx" + e.enqueteCount + "\n"; }
if (e.taskCount > 0) { text += "未完了TODOx" + e.taskCount + "\n"; }
if (e.starCount > 0) { text += "お気に入りx" + e.starCount + "\n"; }
if (text != "") {
new Notification(document.title, {body: text});
}
};
NotificationCount.displayChatNotification = function (e){
var n = new CbAries.Ajax();
n.initialize({
method: "GET",
requestUrl: CbAries.Global.setPortalRelative("/mpChat/chatNotificationAjax"),
requestData: {notificationIds: e.join(",")}
});
n.doSuccess = function(e) {
var t = $("<div>").html(e);
var n =$("div.chatNotification", t);
if (n.length > 0) {
require("common/chatNotification").appendChatNotification(n);
}
};
n.request();
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment