From 189296c5a0130c151bed5e96367bcf33e7ac1b2f Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 7 Dec 2009 11:44:43 +0000 Subject: Using localStorage to keep the play/pause state of RealtimeUpdate --- plugins/Realtime/realtimeupdate.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 577499bf7..13b723589 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -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('
  • '); @@ -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) { -- cgit v1.2.3-54-g00ecf