Pārlūkot izejas kodu

Cleaned up head.html and client.js a little bit. Fixed issue where rooms would sometimes say there are users in a room.

Kris 9 gadi atpakaļ
vecāks
revīzija
231879256a
3 mainītis faili ar 651 papildinājumiem un 460 dzēšanām
  1. 622 439
      app/client/client.js
  2. 20 20
      app/client/head.html
  3. 9 1
      app/server/server.js

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 622 - 439
app/client/client.js


+ 20 - 20
app/client/head.html

@@ -31,6 +31,7 @@
     <script src="/bootstrap-slider.min.js"></script>
     <script src="/bootstrap-slider.min.js"></script>
     <script src="/jquery.textcomplete.min.js"></script>
     <script src="/jquery.textcomplete.min.js"></script>
     <script src="/emojidropdown.js"></script>
     <script src="/emojidropdown.js"></script>
+    <script src="https://connect.soundcloud.com/sdk-2.0.0.js"></script>
     <script type="application/javascript">
     <script type="application/javascript">
         addEventListener("load", function() {
         addEventListener("load", function() {
             setTimeout(hideURLbar, 0);
             setTimeout(hideURLbar, 0);
@@ -39,27 +40,8 @@
         function hideURLbar() {
         function hideURLbar() {
             window.scrollTo(0, 1);
             window.scrollTo(0, 1);
         }
         }
-    </script>
-    <script src="https://connect.soundcloud.com/sdk-2.0.0.js"></script>
-    <script>
-        function init() {
-            SC.initialize({
-                client_id: "577d3fbbdb5fe05bb4af698d686508fe"
-            });
-        }
-        init();
-    </script>
-    <script>
-        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
-                    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
-                m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
-        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
-
-        ga('create', 'UA-69432115-1', 'auto');
-        ga('send', 'pageview');
 
 
-    </script>
-    <script type="text/javascript">
+        // Doorbell Initialising
         window.doorbellOptions = {
         window.doorbellOptions = {
             strings: {
             strings: {
                 'email-input-placeholder': 'Your email address (optional)'
                 'email-input-placeholder': 'Your email address (optional)'
@@ -70,10 +52,28 @@
             var g = d.createElement(t);g.id = 'doorbellScript';g.type = 'text/javascript';g.async = true;g.src = 'https://embed.doorbell.io/button/2408?t='+(new Date().getTime());(d.getElementsByTagName('head')[0]||d.getElementsByTagName('body')[0]).appendChild(g);
             var g = d.createElement(t);g.id = 'doorbellScript';g.type = 'text/javascript';g.async = true;g.src = 'https://embed.doorbell.io/button/2408?t='+(new Date().getTime());(d.getElementsByTagName('head')[0]||d.getElementsByTagName('body')[0]).appendChild(g);
         }(document, 'script'));
         }(document, 'script'));
 
 
+        // YouTube Iniialising
         Session.set("YTLoaded", false);
         Session.set("YTLoaded", false);
 
 
         function onYouTubeIframeAPIReady() {
         function onYouTubeIframeAPIReady() {
             Session.set("YTLoaded", true);
             Session.set("YTLoaded", true);
         }
         }
+
+        // Google Analytics Initialising
+        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+                    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+                m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+        ga('create', 'UA-69432115-1', 'auto');
+        ga('send', 'pageview');
+
+        // SoundCloud initialising
+        function init() {
+            SC.initialize({
+                client_id: "577d3fbbdb5fe05bb4af698d686508fe"
+            });
+        }
+        init();
     </script>
     </script>
 </head>
 </head>

+ 9 - 1
app/server/server.js

@@ -69,11 +69,19 @@ function checkUsersPR() {
         //not sure what these are, i count none in my tests
         //not sure what these are, i count none in my tests
         //var usubs = connection._meteorSession._universalSubs;
         //var usubs = connection._meteorSession._universalSubs;
     });
     });
+    var emptyStations = [];
+    stations.forEach(function(station) {
+        emptyStations.push(station);
+    });
     for (var key in output) {
     for (var key in output) {
-        getStation(key, function() {
+        getStation(key, function(station) {
+            emptyStations.splice(emptyStations.indexOf(station), 1);
             Rooms.update({type: key}, {$set: {users: output[key]}});
             Rooms.update({type: key}, {$set: {users: output[key]}});
         });
         });
     }
     }
+    emptyStations.forEach(function(emptyStation) {
+        Rooms.update({type: emptyStation.type}, {$set: {users: 0}});
+    });
     return output;
     return output;
 }
 }
 
 

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels