Created
August 9, 2014 04:04
-
-
Save cat-in-136/956353fffd720ce66328 to your computer and use it in GitHub Desktop.
サイボウズLiveのWeb Notification API勝手に対応ハック
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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