aboutsummaryrefslogtreecommitdiffstats
path: root/scudcloud-1.0/scudcloud-src.js
diff options
context:
space:
mode:
Diffstat (limited to 'scudcloud-1.0/scudcloud-src.js')
-rw-r--r--scudcloud-1.0/scudcloud-src.js122
1 files changed, 87 insertions, 35 deletions
diff --git a/scudcloud-1.0/scudcloud-src.js b/scudcloud-1.0/scudcloud-src.js
index c16a0b9..4cf759b 100644
--- a/scudcloud-1.0/scudcloud-src.js
+++ b/scudcloud-1.0/scudcloud-src.js
@@ -1,33 +1,90 @@
-var ScudCloud = {
- overrideNotifications: function(){
- TS.ui.growls.no_notifications = false;
- TS.ui.growls.checkPermission = function() { return true; };
- TS.ui.growls.getPermissionLevel = function() { return 'granted'; };
- TS.ui.growls.show = function(j,f,o,p){ desktop.sendMessage(j,f); };
- TS.ui.banner.close();
- },
- overrideConnect: function(){
- TS.ms.connected_sig.add(function(){ScudCloud.connect(true);});
- TS.ms.disconnected_sig.add(function(){ScudCloud.connect(false);});
- },
- overrideBanner: function(){
- ScudCloud.showBanner = TS.ui.banner.show;
- TS.ui.banner.show = function(){ ScudCloud.showBanner(); ScudCloud.overrideNotifications(); };
- },
- connect: function(b){
- desktop.enableMenus(b);
- if(b){
- ScudCloud.overrideNotifications();
- desktop.populate(JSON.stringify({'channels': ScudCloud.listChannels(), 'teams': ScudCloud.listTeams(), 'icon': TS.model.team.icon.image_44}));
+ScudCloud = {
+ // App functions
+ hasPreference: function(name){
+ return ScudCloud.na("hasPreference");
+ },
+ getPreference: function(name){
+ return ScudCloud.na("getPreference");
+ },
+ setPreference: function(name, value){
+ return ScudCloud.na("setPreference");
+ },
+ canShowHtmlNotifications: function(){
+ return ScudCloud.na("canShowHtmlNotifications");
+ },
+ // TSSSB.call
+ call: function(name, args){
+ ScudCloud.log(name);
+ switch(name){
+ case "reload":
+ return ScudCloud.reload();
+ case "didStartLoading":
+ return ScudCloud.didStartLoading();
+ case "didFinishLoading":
+ return ScudCloud.didFinishLoading();
+ case "setConnectionStatus":
+ return ScudCloud.setConnectionStatus(args);
+ case "notify":
+ return ScudCloud.notify(args);
+ case "setBadgeCount":
+ return ScudCloud.setBadgeCount(args);
+ case "displayTeam":
+ return ScudCloud.displayTeam(args);
+ case "getModifierKeys":
+ case "updateTitleBarColor":
+ case "disableSecureInput":
+ case "setImage":
+ case "listWindows":
+ case "focusWindow":
+ case "openWindow":
+ case "closeWindow":
+ case "getGeometryForWindow":
+ case "startDownload":
+ case "supportsOpenFileAtPath":
+ case "cancelDownloadWithToken":
+ case "openFileAtPath":
+ case "retryDownloadWithToken":
+ case "pruneTokensFromHistory":
+ case "metadataForDownloads":
+ case "readFindString":
+ }
+ return false;
+ },
+ // TSSSB.call implementations
+ reload: function(){
+ window.location.reload();
+ },
+ didStartLoading: function(){
+ },
+ didFinishLoading: function(){
+ ScudCloud.populate();
+ },
+ setConnectionStatus: function(status){
+ // "online", "connecting", "offline"
+ switch(status){
+ case "online": desktop.enableMenus(true); break;
+ default: desktop.enableMenus(false);
}
},
- count: function(){
- var total=0;
- $('span.unread_highlight').not('.hidden').each(function(i){
- total+= new Number($(this).text().replace('+','')); }
- );
- return total;
- },
+ notify: function(args){
+ desktop.sendMessage(args.title, args.content);
+ },
+ setBadgeCount: function(args){
+ desktop.setBadgeCount(args.all_unread_highlights_cnt, args.all_unread_cnt);
+ },
+ displayTeam: function(id){
+ },
+ // ScudCloud internal functions
+ na: function(name){
+ ScudCloud.log(name);
+ return false;
+ },
+ log: function(name){
+ console.log("ScudCloud."+name);
+ },
+ populate: function(){
+ desktop.populate(JSON.stringify({'channels': ScudCloud.listChannels(), 'teams': ScudCloud.listTeams(), 'icon': TS.model.team.icon.image_44}));
+ },
createSnippet: function(){
return TS.ui.snippet_dialog.start();
},
@@ -69,14 +126,9 @@ var ScudCloud = {
},
help: function(){
return TS.help_dialog.start();
- },
- isConnected: function(){
- return "undefined" != typeof TS && "undefined" != typeof TS.model && TS.model.ms_connected;
- }
+ }
};
if("undefined" != typeof TS){
document.onpaste = function(e){desktop.pasted(false);};
- ScudCloud.overrideNotifications();
- ScudCloud.overrideConnect();
- ScudCloud.overrideBanner();
+ window.winssb = TSSSB = ScudCloud;
}