Skip to content

Commit

Permalink
convert from cookie to local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
octatone committed Apr 19, 2012
1 parent 9a2ea6d commit 2c41a2f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 97 deletions.
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -12,7 +12,7 @@

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery.escapify.js" type="text/javascript"></script>
<script src="js/jquery.cookie.js" type="text/javascript"></script>
<script src="js/jstorage.min.js" type="text/javascript"></script>
<script src="js/jquery.scrollTo-1.4.2-min.js" type="text/javascript"></script>
<script src="js/jquery.lazyload.min.js" type="text/javascript"></script>
<script src="js/jquery.mousewheel.js" type="text/javascript"></script>
Expand Down
89 changes: 0 additions & 89 deletions js/jquery.cookie.js

This file was deleted.

8 changes: 8 additions & 0 deletions js/jstorage.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions js/tv.js
Expand Up @@ -89,12 +89,12 @@ $().ready(function(){
});
$('#auto').click(function() {
Globals.auto = ($('#auto').is(':checked')) ? true : false;
$.cookie('auto', Globals.auto, {expires: 7});
$.jStorage.set('auto', Globals.auto);
});
$('#shuffle').click(function() {
Globals.shuffle = ($('#shuffle').is(':checked')) ? true : false;
Globals.shuffled = []; //reset
$.cookie('shuffle', Globals.shuffle, {expires: 7});
$.jStorage.set('shuffle', Globals.shuffle);
});
$('#sfw').click(function() {
Globals.sfw = ($('#sfw').is(':checked')) ? true : false;
Expand All @@ -104,7 +104,7 @@ $().ready(function(){
Globals.sfw = true;
}
}
$.cookie('sfw', Globals.sfw, {expires: 7});
$.jStorage.set('sfw', Globals.sfw);
showHideNsfwThumbs(Globals.sfw, Globals.cur_chan);
});
$('#fill').click(function() {
Expand Down Expand Up @@ -173,7 +173,11 @@ $().ready(function(){

/* Main Functions */
function loadSettings() {
var channels_cookie = $.parseJSON($.cookie('user_channels')), auto_cookie = $.cookie('auto'), sfw_cookie = $.cookie('sfw'), theme_cookie = $.cookie('theme'), shuffle_cookie = $.cookie('shuffle');
var channels_cookie = $.jStorage.get('user_channels'),
auto_cookie = $.jStorage.get('auto'),
sfw_cookie = $.jStorage.get('sfw'),
theme_cookie = $.jStorage.get('theme'),
shuffle_cookie = $.jStorage.get('shuffle');

if(auto_cookie !== null && auto_cookie !== Globals.auto){
Globals.auto = (auto_cookie === 'true') ? true : false;
Expand All @@ -200,7 +204,7 @@ function loadSettings() {

function loadTheme(id) {
$('#theme').attr('href', 'css/theme_' + id + '.css');
$.cookie('theme', id, {expires: 7});
$.jStorage.set('theme', id);
}

function displayChannels() {
Expand Down Expand Up @@ -783,7 +787,7 @@ function addChannel(subreddit){
Globals.channels.push(c_data);
Globals.user_channels.push(c_data);

$.cookie('user_channels', JSON.stringify(Globals.user_channels));
$.jStorage.set('user_channels', Globals.user_channels);

var x = Globals.channels.length - 1;
displayChannel(x);
Expand All @@ -805,7 +809,7 @@ function removeChan(chan){ //by index (integer)
$('#channel-'+chan).remove();
Globals.user_channels.splice(idx, 1);

$.cookie('user_channels', JSON.stringify(Globals.user_channels));
$.jStorage('user_channels', Globals.user_channels);
//free some memory bitches
Globals.channels[chan] = {channel: '', feed: ''};
Globals.videos[chan] = undefined;
Expand Down

0 comments on commit 2c41a2f

Please sign in to comment.