浏览代码

Implements functionality that forces the user to enter display name.

j8
hristoterezov 10 年前
父节点
当前提交
47b6355d66
共有 5 个文件被更改,包括 109 次插入21 次删除
  1. 1
    0
      config.js
  2. 2
    2
      index.html
  3. 2
    1
      lang/main.json
  4. 52
    9
      libs/app.bundle.js
  5. 52
    9
      modules/UI/UI.js

+ 1
- 0
config.js 查看文件

@@ -32,6 +32,7 @@ var config = {
32 32
     enableWelcomePage: true,
33 33
     enableSimulcast: false, // blocks FF support
34 34
     logStats: false, // Enable logging of PeerConnection stats via the focus
35
+//    requireDisplayName: true,//Forces the participants that doesn't have display name to enter it when they enter the room.
35 36
 //    startAudioMuted: 10, //every participant after the Nth will start audio muted
36 37
 //    startVideoMuted: 10, //every participant after the Nth will start video muted
37 38
 //    defaultLanguage: "en",

+ 2
- 2
index.html 查看文件

@@ -13,7 +13,7 @@
13 13
     <script src="libs/jquery-2.1.1.min.js"></script>
14 14
     <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
15 15
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jsSHA/1.5.0/sha.js"></script>
16
-    <script src="config.js?v=10"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->
16
+    <script src="config.js?v=11"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->
17 17
     <script src="libs/strophe/strophe.min.js?v=1"></script>
18 18
     <script src="libs/strophe/strophe.disco.min.js?v=1"></script>
19 19
     <script src="libs/strophe/strophe.caps.jsonly.min.js?v=1"></script>
@@ -22,7 +22,7 @@
22 22
     <script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
23 23
     <script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
24 24
     <script src="interface_config.js?v=5"></script>
25
-    <script src="libs/app.bundle.js?v=94"></script>
25
+    <script src="libs/app.bundle.js?v=95"></script>
26 26
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
27 27
     <link rel="stylesheet" href="css/font.css?v=7"/>
28 28
     <link rel="stylesheet" href="css/toastr.css?v=1">

+ 2
- 1
lang/main.json 查看文件

@@ -194,7 +194,8 @@
194 194
         "reservationErrorMsg": "Error code: __code__, message: __msg__",
195 195
         "password": "password",
196 196
         "userPassword": "user password",
197
-        "token": "token"
197
+        "token": "token",
198
+        "displayNameRequired": "Please enter your display name:"
198 199
     },
199 200
     "email":
200 201
     {

+ 52
- 9
libs/app.bundle.js 查看文件

@@ -1552,6 +1552,51 @@ var eventEmitter = new EventEmitter();
1552 1552
 var roomName = null;
1553 1553
 
1554 1554
 
1555
+function promptDisplayName() {
1556
+    var message = '<h2 data-i18n="dialog.displayNameRequired">';
1557
+    message += APP.translation.translateString(
1558
+        "dialog.displayNameRequired");
1559
+    message += '</h2>' +
1560
+        '<input name="displayName" type="text" data-i18n=' +
1561
+        '"[placeholder]defaultNickname" placeholder="' +
1562
+        APP.translation.translateString(
1563
+            "defaultNickname", {name: "Jane Pink"}) +
1564
+        '" autofocus>';
1565
+
1566
+    var buttonTxt
1567
+        = APP.translation.generateTranslatonHTML("dialog.Ok");
1568
+    var buttons = [];
1569
+    buttons.push({title: buttonTxt, value: "ok"});
1570
+
1571
+    messageHandler.openDialog(null, message,
1572
+        true,
1573
+        buttons,
1574
+        function (e, v, m, f) {
1575
+            if (v == "ok") {
1576
+                var displayName = f.displayName;
1577
+                if (displayName) {
1578
+                    VideoLayout.inputDisplayNameHandler(displayName);
1579
+                    return true;
1580
+                }
1581
+            }
1582
+            e.preventDefault();
1583
+        },
1584
+        function () {
1585
+            var form  = $.prompt.getPrompt();
1586
+            var input = form.find("input[name='displayName']");
1587
+            var button = form.find("button");
1588
+            button.attr("disabled", "disabled");
1589
+            input.keyup(function () {
1590
+                if(!input.val())
1591
+                    button.attr("disabled", "disabled");
1592
+                else
1593
+                    button.removeAttr("disabled");
1594
+            });
1595
+        }
1596
+    );
1597
+}
1598
+
1599
+
1555 1600
 function notifyForInitialMute()
1556 1601
 {
1557 1602
     messageHandler.notify(null, "notify.mutedTitle", "connected",
@@ -1882,17 +1927,15 @@ UI.start = function (init) {
1882 1927
 
1883 1928
     document.getElementById('largeVideo').volume = 0;
1884 1929
 
1885
-    if (!$('#settings').is(':visible')) {
1886
-        console.log('init');
1887
-        init();
1888
-    } else {
1889
-        loginInfo.onsubmit = function (e) {
1890
-            if (e.preventDefault) e.preventDefault();
1891
-            $('#settings').hide();
1892
-            init();
1893
-        };
1930
+    if(config.requireDisplayName) {
1931
+        var currentSettings = Settings.getSettings();
1932
+        if (!currentSettings.displayName) {
1933
+            promptDisplayName();
1934
+        }
1894 1935
     }
1895 1936
 
1937
+    init();
1938
+
1896 1939
     toastr.options = {
1897 1940
         "closeButton": true,
1898 1941
         "debug": false,

+ 52
- 9
modules/UI/UI.js 查看文件

@@ -32,6 +32,51 @@ var eventEmitter = new EventEmitter();
32 32
 var roomName = null;
33 33
 
34 34
 
35
+function promptDisplayName() {
36
+    var message = '<h2 data-i18n="dialog.displayNameRequired">';
37
+    message += APP.translation.translateString(
38
+        "dialog.displayNameRequired");
39
+    message += '</h2>' +
40
+        '<input name="displayName" type="text" data-i18n=' +
41
+        '"[placeholder]defaultNickname" placeholder="' +
42
+        APP.translation.translateString(
43
+            "defaultNickname", {name: "Jane Pink"}) +
44
+        '" autofocus>';
45
+
46
+    var buttonTxt
47
+        = APP.translation.generateTranslatonHTML("dialog.Ok");
48
+    var buttons = [];
49
+    buttons.push({title: buttonTxt, value: "ok"});
50
+
51
+    messageHandler.openDialog(null, message,
52
+        true,
53
+        buttons,
54
+        function (e, v, m, f) {
55
+            if (v == "ok") {
56
+                var displayName = f.displayName;
57
+                if (displayName) {
58
+                    VideoLayout.inputDisplayNameHandler(displayName);
59
+                    return true;
60
+                }
61
+            }
62
+            e.preventDefault();
63
+        },
64
+        function () {
65
+            var form  = $.prompt.getPrompt();
66
+            var input = form.find("input[name='displayName']");
67
+            var button = form.find("button");
68
+            button.attr("disabled", "disabled");
69
+            input.keyup(function () {
70
+                if(!input.val())
71
+                    button.attr("disabled", "disabled");
72
+                else
73
+                    button.removeAttr("disabled");
74
+            });
75
+        }
76
+    );
77
+}
78
+
79
+
35 80
 function notifyForInitialMute()
36 81
 {
37 82
     messageHandler.notify(null, "notify.mutedTitle", "connected",
@@ -362,17 +407,15 @@ UI.start = function (init) {
362 407
 
363 408
     document.getElementById('largeVideo').volume = 0;
364 409
 
365
-    if (!$('#settings').is(':visible')) {
366
-        console.log('init');
367
-        init();
368
-    } else {
369
-        loginInfo.onsubmit = function (e) {
370
-            if (e.preventDefault) e.preventDefault();
371
-            $('#settings').hide();
372
-            init();
373
-        };
410
+    if(config.requireDisplayName) {
411
+        var currentSettings = Settings.getSettings();
412
+        if (!currentSettings.displayName) {
413
+            promptDisplayName();
414
+        }
374 415
     }
375 416
 
417
+    init();
418
+
376 419
     toastr.options = {
377 420
         "closeButton": true,
378 421
         "debug": false,

正在加载...
取消
保存