aboutsummaryrefslogtreecommitdiffstats
path: root/scudcloud-1.0/scudcloud-src.js
blob: faef0816a03422c503417d63d6209b47ea8fce1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var ScudCloud = {
    started: false,
	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) desktop.populate(JSON.stringify({'channels': ScudCloud.listChannels(), 'teams': ScudCloud.listTeams(), 'icon': TS.model.team.icon.image_88}));
	},
    count: function(){
		var total=0;
		$('span.unread_highlight').not('.hidden').each(function(i){ 
			total+= new Number($(this).text().replace('+','')); }
		);
		return total;
    },
	createSnippet: function(){
		return TS.ui.snippet_dialog.start();		
	},
    listChannels: function(){
		return TS.channels.getUnarchivedChannelsForUser();
	},
    listTeams: function(){
		var list = TS.getAllTeams();
		// Fix for current team displaying no icon
		list[0].team_icon = {"image_88":TS.model.team.icon.image_88};
		return list;
	},
    quicklist: function(){
		desktop.quicklist(ScudCloud.listChannels());
	},
	join: function(c){
		return TS.channels.join(c);
	},
	setClipboard: function(data){
		TS.client.ui.file_pasted_sig.dispatch(data, TS.model.shift_key_pressed);
	},
    preferences: function(){
		return TS.ui.prefs_dialog.start();
	},
    addTeam: function(){
		document.location = TS.boot_data.signin_url;
	},
	getCurrentTeam: function(){
		var list = TS.getAllTeams();
		if(list!=null) for(var i=0;list.length;i++){
			if(list[i].team_url==TS.boot_data.team_url){
				return list[i].id;
			}
		}
		return "";
	},
    logout: function(){
		document.location = TS.boot_data.logout_url;
	},
    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 && false == ScudCloud.started){
	document.onpaste = function(e){desktop.pasted(false);};
	ScudCloud.overrideConnect();
	ScudCloud.overrideBanner();
	ScudCloud.started = true;
}