-
Notifications
You must be signed in to change notification settings - Fork 36
/
index.html
237 lines (208 loc) · 9.01 KB
/
index.html
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<!DOCTYPE html>
<html>
<head>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link href='http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic' rel='stylesheet' type='text/css'>
<link href="/css/slack-chat.css" rel="stylesheet" />
<link href="/css/demo.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>SlackChat</title>
<meta name="description" content="Provide your website visitors with help and support from #Slack">
</head>
<body>
<div class='container'>
<div class='page-header'>
<h2>SlackChat
<br><small>A support chat feature for your website that integrates with #Slack</small>
</h2>
</div>
<div class='row rowTop'>
<div class='col-sm-12'>
For instructions on installation, usage, download and issues, head to <a href="https://arjunmat.github.io/slack-chat">https://arjunmat.github.io/slack-chat</a>
<br><br>
To try a demo, enter the following fields and click on Try Now.
</div>
</div>
<div class='row rowTop'>
<div class='col-sm-12'>
<form class="form-horizontal" id="demoForm">
<div class="form-group">
<label for="apiToken" class="col-sm-3 control-label">Slack API Token:</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="apiToken" placeholder="apiToken" required="required" value="" />
<div class="help-text">Generate your Slack token <a href="https://api.slack.com/web" target="_blank">here</a>.</div>
</div>
</div>
<div class="form-group">
<label for="channelId" class="col-sm-3 control-label">Slack Channel ID:</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="channelId" placeholder="Required" required="required" value="">
<div class="help-text"><a href="javascript:void(0);" id="listChannels">Click here</a> to list your channels.</div>
<div class="well channel-list" style="display:none;"></div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<div class="checkbox">
<label>
<input type="checkbox" id="usePrivateChannel"> Use Private Channel <small> | <b>Note: *</b> Bot User does not work with private channels.</small>
</label>
</div>
</div>
</div>
<div class="form-group hide" id="serverApi">
<label for="serverApiGateway" class="col-sm-3 control-label">Server API Gateway:</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="serverApiGateway" placeholder="Required" value="">
</div>
</div>
<div class="form-group hide" id="invitedUsers">
<label for="defaultInvitedUsers" class="col-sm-3 control-label">List of users to Invite:</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="defaultInvitedUsers" placeholder="Optional" value="">
</div>
</div>
<div class="form-group">
<label for="user" class="col-sm-3 control-label">Username:</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="user" placeholder="Required" required="required" value="DemoUser">
</div>
</div>
<div class="form-group">
<label for="sysUser" class="col-sm-3 control-label">Support Name:</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="sysUser" placeholder="Required" required="required" value="SlackChatDemo">
</div>
</div>
<div class="form-group">
<label for="botUser" class="col-sm-3 control-label">Bot User Name:</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="botUser" placeholder="Required" required="required" value="DemoBot">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button class="btn btn-danger btn-md btn-default btn-try">Try Now</button> 
<a class='btn btn-md btn-info' href='https://github.com/arjun-mat/slack-chat/zipball/master'>Download</a>
</div>
</div>
</form>
</div>
</div>
<footer class='center-txt'>
Made with <i class="fa fa-fw fa-heart"></i> by <a href='mailto:arjun.mathai@gmail.com'>Arjun Mathai</a>
</footer>
</div>
<div class="message-box" data-toggle="tooltip" title="Need help?">
<a href="javascript:void(0);" class="message-box-icon">
<i class="fa fa-fw fa-question-circle"></i>
<div class="badge badge-danger slack-message-count"></div>
</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js"></script>
<script type="text/javascript" src="/js/slack-chat.js"></script>
<script>
$(document).ready(function () {
$('.message-box > a').slackChat('destroy');
$('.message-box').hide();
$('[data-toggle=tooltip]').tooltip();
$('.btn-try').on('click', function (e) {
e.preventDefault();
e.stopPropagation();
$('.message-box > a').slackChat('destroy');
$('.message-box').hide();
slackChatOptions = {
apiToken: $('#apiToken').val()
,channelId: $('#channelId').val()
,user: $('#user').val()
,userLink: 'http://www.google.com'
,userId: 'TEST-USER'
,userImg: '/img/user-icon-small.jpg'
,defaultSysImg: '/img/improvi.png'
,defaultSysUser: $('#sysUser').val()
,botUser: $('#botUser').val()
,elementToDisable: $('.message-box')
,disableIfAway: false
,webCache: true
,debug:false
,privateChannel: false
,badgeElement: '.slack-message-count'
,useUserDetails: false
,defaultInvitedUsers: []
};
if($('#usePrivateChannel').prop('checked')) {
slackChatOptions.privateChannel = true;
slackChatOptions.serverApiGateway = $('#serverApiGateway').val();
slackChatOptions.defaultInvitedUsers = $('#defaultInvitedUsers').val().split(",");
}
$('.message-box > a').slackChat(slackChatOptions);
$('.message-box').show();
return false;
});
//load from localStorage
for ( var i = 0, len = localStorage.length; i < len; ++i ) {
if(localStorage.key(i) == 'scParams') {
var scParams = JSON.parse(localStorage.getItem( localStorage.key( i ) ));
if(scParams.apiToken) $('#apiToken').val(scParams.apiToken);
if(scParams.channelId) $('#channelId').val(scParams.channelId);
if(scParams.user) $('#user').val(scParams.user);
if(scParams.defaultSysUser) $('#sysUser').val(scParams.defaultSysUser);
if(scParams.botUser) $('#botUser').val(scParams.botUser);
if(scParams.serverApiGateway) $('#serverApiGateway').val(scParams.serverApiGateway);
if(scParams.defaultInvitedUsers) $('#defaultInvitedUsers').val(scParams.defaultInvitedUsers);
}
}
//load the channels
$('#listChannels').on("click", function () {
$('.channel-list').html('').hide();
if($('#apiToken').val() == '') {
$('.channel-list').html("Invalid Slack API Token").show();
return false;
}
$.ajax({
url: "https://slack.com/api/channels.list"
,type: "POST"
,dataType: "json"
,data: {
token: $('#apiToken').val()
}
,success: function (resp) {
if(resp.ok) {
if(resp.channels.length) {
var html = "<table class='table table-condensed table-striped table-bordered'><tr><th>Channel Name</td><td>Channel ID</td>";
for(var i=0; i< resp.channels.length;i++) {
if(!resp.channels[i].is_archived)
html += "<tr><td>" + resp.channels[i].name + "</td><td><span class='channel-id'>" + resp.channels[i].id + "</span><a class='btn btn-xs btn-danger use-channel pull-right'>Use</a></td>";
}
html += "</table>";
$('.channel-list').html(html).show();
$('.use-channel').off('click');
$('.use-channel').on('click', function () {
$('#channelId').val($(this).parent().find('.channel-id').text());
$('.channel-list').hide();
});
}
else
$('.channel-list').html("No channels found").show();
}
}
});
});
$('#usePrivateChannel').on('change', function () {
if($(this).prop('checked')) {
$("#serverApi").removeClass("hide");
$("#invitedUsers").removeClass("hide");
}
else {
$("#serverApi").addClass("hide");
$("#invitedUsers").addClass("hide");
}
});
});
</script>
</body>
</html>