· 8 years ago · Jul 22, 2017, 05:40 AM
1<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Skype.aspx.cs" Inherits="PlatformAdmin.Skype" %>
2<!DOCTYPE html>
3<%-- xmlns="http://www.w3.org/1999/xhtml" runat="server"--%>
4<html >
5<head >
6 <meta charset="utf-8">
7 <meta http-equiv="X-UA-Compatible" content="IE=edge">
8 <meta name="viewport" content="width=device-width, initial-scale=1">
9 <meta name="description" content="">
10 <meta name="author" content="">
11
12 <title>Oztern</title>
13 <!-- FAVICON -->
14 <link rel="shortcut icon" href="img/favicon.ico">
15
16
17 <!-- the jQuery library written by John Resig (MIT license) -->
18 <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.1.min.js"></script>
19
20 <!-- SkypeWebSDK Bootstrap Libray -->
21 <script src="https://swx.cdn.skype.com/shared/v/1.1.23.0/SkypeBootstrap.min.js"></script>
22
23
24 <!-- Bootstrap Core CSS -->
25 <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
26
27 <!-- Custom Fonts -->
28 <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
29 <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
30 <link href='https://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
31
32 <!-- Plugin CSS -->
33 <link href="vendor/magnific-popup/magnific-popup.css" rel="stylesheet">
34
35 <!-- Theme CSS -->
36 <link href="css/creative.min.css" rel="stylesheet">
37 <link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css" rel="stylesheet">
38 <link href="css/custom.css" rel="stylesheet">
39 <style>
40 input[type=date]::-webkit-inner-spin-button {
41 -webkit-appearance: none;
42 display: none;
43}
44
45 .input {
46border: 1pt solid gray;
47padding: 2pt;
48overflow: hidden;
49white-space: nowrap;
50}
51
52.button {
53border: 1pt solid gray;
54cursor: pointer;
55padding: 2pt 5pt;
56margin-top:5px;
57display: inline-block;
58}
59
60.button:hover {
61 background: lightgray;
62}
63
64.signinframe > .button {
65 margin-top: 8pt;
66}
67
68.userdetails {
69 border: 1pt solid lightgray;
70 padding:5px;
71}
72
73.logoutbox, .loginbox {
74 padding: 5px 0 10px 0;
75}
76 </style>
77
78</head>
79<body>
80
81 <div class="container">
82 <h2>Skype Web SDK Sending an Instant Message</h2>
83 <div id="loginbox" class="loginbox input-group">
84 <div>Login</div>
85 <div id="address" contenteditable="true" class="input form-control"></div>
86 <div>Password</div>
87 <input type="text" id="password" name="password" class="input form-control" />
88 <div id="signin" class="button">Sign In</div>
89 </div>
90 <div id="chatfunctions">
91 <div class="row">
92 <div class="col-md-6 col-sm-6 col-lg-6">
93 <div class="input-group">
94 <div id="the_message" contenteditable="true" class="input form-control"></div>
95 <div id="send_message" class="input-group-addon btn btn-primary">Send</div>
96 </div>
97
98 <br />
99 <div id="startChat" class="button">Start chatService</div>
100 <div id="stopChat" class="button">Stop chatService</div>
101
102 <br /><br />
103 <div class="input-group">
104 <div id="the_participant" contenteditable="true" class="input form-control"></div>
105 <div id="add_participant" class="input-group-addon btn btn-primary">Add Participant</div>
106 </div>
107 <br />
108
109 <div id="signout" class="button">Sign Out</div>
110 </div>
111 <div class="col-md-6 col-sm-6 col-lg-6">
112 </div>
113 </div>
114 </div>
115
116 <div class="small">
117 <b>Event Logs</b><br />
118 <div id="logging_box" contenteditable="false" class="code"></div>
119 </div>
120
121 </div>
122
123 <!-- jQuery -->
124 <script src="vendor/jquery/jquery.min.js"></script>
125
126 <!-- Bootstrap Core JavaScript -->
127 <script src="vendor/bootstrap/js/bootstrap.min.js"></script>
128
129 <!-- Plugin JavaScript -->
130 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
131 <script src="vendor/scrollreveal/scrollreveal.min.js"></script>
132 <script src="vendor/magnific-popup/jquery.magnific-popup.min.js"></script>
133
134 <!-- Theme JavaScript -->
135 <script src="js/creative.min.js"></script>
136
137 <script>
138 $(document).ready(function () {
139 if (parseInt(sessionStorage["UserRole"]) === 1) {
140 $('#menu_report').show();
141 }
142 else {
143 $('#menu_report').hide();
144 }
145
146 if (sessionStorage["UserRole"] === 0)
147 {
148 window.location = "/Login.aspx";
149 }
150 else if (sessionStorage["UserRole"] === undefined) {
151 window.location = "/Login.aspx";
152 }
153 else if (sessionStorage["UserRole"] === "0") {
154 window.location = "/Login.aspx";
155 }
156
157 $(".pop-up-close").click(function () {
158 //$('html, body').css('overflow-y', 'auto');
159 $(".position-login").hide(300);
160 });
161 sessionStorage["Page"] = "/ManageCourse.aspx";
162
163 });
164
165
166
167/*
168 Generic Functions
169*/
170function log(texttolog) {
171 var d = new Date();
172 var time = padLeft(d.getHours(), 2) + ":" + padLeft(d.getMinutes(), 2) + ":" + padLeft(d.getSeconds(), 2) + ":" + padLeft(d.getMilliseconds(), 3);
173 $('#logging_box').prepend(time + ": " + texttolog + "<br>");
174}
175 function padLeft(nr, n, str) {
176 return Array(n - String(nr).length + 1).join(str || '0') + nr;
177 }
178
179 /*
180 How to send an Instant Message using the Skype Web SDK
181 */
182 $(function () {
183 'use strict';
184
185 log("App Loaded");
186 $('#chatfunctions').hide();
187
188 var Application
189 var client;
190 var conversation;
191
192 Skype.initialize({
193 apiKey: 'SWX-BUILD-SDK',
194 }, function (api) {
195 Application = api.application;
196 client = new Application();
197 }, function (err) {
198 log('some error occurred: ' + err);
199 });
200
201 log("Client Created");
202
203 // when the user clicks the "Sign In" button
204 $('#signin').click(function () {
205 $('#signin').hide();
206 log('Signing in...');
207 // and invoke its asynchronous "signIn" method
208 client.signInManager.signIn({
209 username: $('#address').text(),
210 password: $('#password').val()
211 }).then(function () {
212 log('Logged In Succesfully');
213 $('#loginbox').hide();
214 $('#chatfunctions').show();
215
216 //create a new conversation
217 log("Creating a new Conversation");
218 conversation = client.conversationsManager.createConversation();
219
220
221 }).then(null, function (error) {
222 // if either of the operations above fails, tell the user about the problem
223 log(error || 'Oops, Something went wrong.');
224 $('#signin').show()
225 });
226 });
227
228 $('#add_participant').click(function () {
229 var the_participant = $('#the_participant').text();
230 log("Adding the participant " + the_participant);
231 conversation.addParticipant("sip:" + the_participant).then(function () {
232 log(the_participant + " added!");
233 }).then(null, function (error) {
234 log("Error:" + error);
235 });
236 });
237
238 $('#send_message').click(function () {
239 var the_message = $('#the_message').text();
240 if (the_message != "") {
241 log('Sending message: ' + the_message);
242 conversation.chatService.sendMessage(the_message).then(function () {
243 log('Message sent.');
244 }).then(null, function (error) {
245 log('Error:' + error);
246 });
247 } else {
248 log('<b><font color=red>Please enter a message to send!</font></b>');
249 }
250 });
251
252 $('#startChat').click(function () {
253 log('Starting chatService...');
254 conversation.chatService.start().then(function () {
255 log('chatService started!');
256 $('#startChat').hide();
257 }).then(null, function (error) {
258 log('Error:' + error);
259 });
260 });
261
262 $('#stopChat').click(function () {
263 log('Stopping chatService...');
264 conversation.chatService.stop().then(function () {
265 log('chatService stopped.');
266 $('#startChat').show();
267 }).then(null, function (error) {
268 log('Error:' + error);
269 });
270 });
271
272 // when the user clicks on the "Sign Out" button
273 $('#signout').click(function () {
274 // start signing out
275 log("Signing Out");
276 client.signInManager.signOut().then(
277 //onSuccess callback
278 function () {
279 // and report the success
280 log('Signed out');
281 $('#loginbox').show();
282 $('#signin').show();
283 $('#chatfunctions').hide();
284 },
285 //onFailure callback
286 function (error) {
287 // or a failure
288 log(error || 'Cannot Sign Out');
289 });
290 });
291
292 });
293 </script>
294</body>
295</html>