|
347 | 347 | $('#messages').append($li); |
348 | 348 | $('#list').animate({scrollTop: $('#messages').height()}, 'fast'); |
349 | 349 | break; |
| 350 | + case 'session-timeout': |
| 351 | + $li = $("<li />"); |
| 352 | + $li.html("System Notification:\t" + $data.user + " left from this conversation."); |
| 353 | + $('#messages').append($li); |
| 354 | + $('#list').animate({scrollTop: $('#messages').height()}, 'fast'); |
| 355 | + break; |
| 356 | + case 'expired': |
| 357 | + $li = $("<li />"); |
| 358 | + $li.html("System Notification:\tIt's an expired conversation, you have to refresh the current page or request a new meeting code."); |
| 359 | + $('#messages').append($li); |
| 360 | + $('#list').animate({scrollTop: $('#messages').height()}, 'fast'); |
| 361 | + break; |
350 | 362 | default: |
351 | 363 | timer.setAction(function(){ |
352 | 364 | document.title = $_user + " is typing" + dotted; |
|
369 | 381 | data: { cmd: cmd } |
370 | 382 | }).done(function( msg ) { |
371 | 383 | if(msg.error == "missing user") { |
372 | | - if (user) { |
373 | | - $.ajax({ |
374 | | - type: "POST", |
375 | | - url: "[%LINK:talk/start%]/"+ user |
376 | | - }).done(function( msg ) {}); |
377 | | - } |
378 | | - else { |
379 | | - $("#modal").modal(); |
380 | | - } |
381 | | - } |
382 | | - |
383 | | - if(msg.error == "expired") { |
384 | | - if(confirm("The conversation is expired, Do you want to reload the conversation?")) { |
385 | | - $.ajax({ |
386 | | - type: "POST", |
387 | | - url: $('#link').text() |
388 | | - }).done(function( msg ) {}); |
389 | | - } |
390 | | - } |
| 384 | + if (user) { |
| 385 | + $.ajax({ |
| 386 | + type: "POST", |
| 387 | + url: "[%LINK:talk/start%]/"+ user |
| 388 | + }).done(function( msg ) {}); |
| 389 | + } |
| 390 | + else { |
| 391 | + $("#modal").modal(); |
| 392 | + } |
| 393 | + } |
391 | 394 | }).fail(function( msg ) { |
| 395 | + switch(msg.responseJSON.error) { |
| 396 | + case 'session-timeout': |
| 397 | + $li = $("<li />"); |
| 398 | + $li.html("System Notification:\t" + $data.user + " left from this conversation."); |
| 399 | + $('#messages').append($li); |
| 400 | + $('#list').animate({scrollTop: $('#messages').height()}, 'fast'); |
| 401 | + |
| 402 | + if(confirm("Your session is timed out, Do you want to reload the conversation?")) { |
| 403 | + $.ajax({ |
| 404 | + type: "POST", |
| 405 | + url: $('#link').text() |
| 406 | + }).done(function( msg ) {}); |
| 407 | + } |
| 408 | + break; |
| 409 | + case 'expired': |
| 410 | + $li = $("<li />"); |
| 411 | + $li.html("System Notification:\tIt's an expired conversation, you have to refresh the current page or request a new meeting code."); |
| 412 | + $('#messages').append($li); |
| 413 | + $('#list').animate({scrollTop: $('#messages').height()}, 'fast'); |
| 414 | + break; |
| 415 | + default:break; |
| 416 | + } |
| 417 | + |
392 | 418 | console.log('Fail.'); |
393 | 419 | console.log(msg); |
394 | 420 | }); |
|
413 | 439 | $.getJSON( "[%LINK:talk/update%]/{%meeting_code%}/{%session_id%}", function(data) { |
414 | 440 | update(data); |
415 | 441 | is_running = false; |
416 | | - }).done(function() { |
| 442 | + }).done(function( msg ) { |
417 | 443 | autoupdate(); |
418 | 444 | is_running = false; |
419 | 445 | }).fail(function( msg ) { |
420 | | - connection_timer.start(); |
421 | | - is_running = false; |
422 | | - console.log(msg); |
| 446 | + msg = msg.responseJSON; |
| 447 | + if(msg.error == "expired") { |
| 448 | + command("expired"); |
| 449 | + } |
| 450 | + else if(msg.error == "session-timeout") { |
| 451 | + command("session-timeout"); |
| 452 | + } |
| 453 | + else { |
| 454 | + connection_timer.start(); |
| 455 | + is_running = false; |
| 456 | + console.log(msg); |
| 457 | + } |
423 | 458 | }); |
424 | 459 | } |
425 | 460 | } |
|
630 | 665 | <input id="attachment" name="attachment" type="file" class="file-loading btn-default" multiple="true" /> |
631 | 666 | <br /> |
632 | 667 | <input type="button" id="button" value="Send" class="btn btn-primary" /> |
633 | | - <!--<input type="button" id="test" value="Test" class="btn btn-secondary" />--> |
| 668 | + <input type="button" id="test" value="Test" class="btn btn-secondary" /> |
634 | 669 | </form> |
635 | 670 | </div> |
636 | 671 |
|
|
673 | 708 |
|
674 | 709 | <footer class="footer"> |
675 | 710 | <div class="container"> |
676 | | - <p class="text-muted"> © 2016 </p> |
| 711 | + <p class="text-muted"> © 2017 </p> |
677 | 712 | </div> |
678 | 713 | </footer> |
679 | 714 |
|
|
0 commit comments