]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Using localStorage to keep the play/pause state of RealtimeUpdate
authorSarven Capadisli <csarven@status.net>
Mon, 7 Dec 2009 11:44:43 +0000 (11:44 +0000)
committerSarven Capadisli <csarven@status.net>
Mon, 7 Dec 2009 11:44:43 +0000 (11:44 +0000)
plugins/Realtime/realtimeupdate.js

index 577499bf7f7086c4cf93ac07ebcdcc83735431e3..13b72358923ce62b347611a018775a5be657b4e8 100644 (file)
@@ -201,12 +201,19 @@ RealtimeUpdate = {
 
      initPlayPause: function()
      {
-        RealtimeUpdate.showPause();
+        if (typeof(localStorage) != 'undefined') {
+            if (localStorage.getItem('RealtimeUpdate_paused') === 'true') {
+                RealtimeUpdate.showPlay();
+            }
+            else {
+                RealtimeUpdate.showPause();
+            }
+        }
      },
 
      showPause: function()
      {
-        RealtimeUpdate._paused = false;
+        RealtimeUpdate.setPause(false);
         RealtimeUpdate.showQueuedNotices();
         RealtimeUpdate.addNoticesHover();
 
@@ -222,8 +229,7 @@ RealtimeUpdate = {
 
      showPlay: function()
      {
-        RealtimeUpdate._paused = true;
-
+        RealtimeUpdate.setPause(true);
         $('#realtime_playpause').remove();
         $('#realtime_actions').prepend('<li id="realtime_playpause"><span id="queued_counter"></span> <button id="realtime_play" class="play" title="Play">Play</button></li>');
 
@@ -233,6 +239,14 @@ RealtimeUpdate = {
         });
      },
 
+     setPause: function(state)
+     {
+        RealtimeUpdate._paused = state;
+        if (typeof(localStorage) != 'undefined') {
+            localStorage.setItem('RealtimeUpdate_paused', RealtimeUpdate._paused);
+        }
+     },
+
      showQueuedNotices: function()
      {
         $.each(RealtimeUpdate._queuedNotices, function(i, n) {