From 501b9a6181f704f272ae72bb3d4384a969025fd5 Mon Sep 17 00:00:00 2001 From: Harry Hackett Date: Wed, 11 Mar 2015 20:15:45 +1300 Subject: [PATCH 1/4] Create fav.js --- js/options/fav.js | 94 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 js/options/fav.js diff --git a/js/options/fav.js b/js/options/fav.js new file mode 100644 index 00000000..f8d12bf3 --- /dev/null +++ b/js/options/fav.js @@ -0,0 +1,94 @@ +//Setting global variables +var favorites = JSON.parse(localStorage.favorites); +Options.add_tab('fav-tab','star',_("Favorites")); + +//Creating functions +var generateList = function(){ + var favStor = []; + for(var i=1; i div:nth-child("+i+")").html()); + } + return JSON.stringify(favStor); +} //This will generate a list of boards based off of the list on the screen +function removeBoard(boardNumber){ + favorites.splice(boardNumber, 1); + localStorage.favorites = JSON.stringify(favorites); + $("#sortable > div:nth-child("+(boardNumber+1)+")").remove(); + $("#minusList > div:nth-child("+(favorites.length+1)+")").remove(); +} //This removes a board from favorites, localStorage.favorites and the page +function addBoard(){ + $("#sortable").append("
"+($("#plusBox").val())+"
"); + $("#minusList").append("
-
"); + favorites.push($("#plusBox").val()); + localStorage.favorites = JSON.stringify(favorites); + $("#space").remove(); + $("#plusBox").remove(); //Refreshing the last 3 elements to move the box down + $("#plus").remove(); + $("#submitFavorites").remove(); + $("

").appendTo(Options.get_tab('fav-tab').content); + $("").appendTo(Options.get_tab('fav-tab').content); + $("#plusBox").keydown(function( event ) { + if(event.keyCode == 13){ + $("#plus").click(); + } + }); //Adding enter to submit + document.getElementById("plusBox").value = ""; //Removing text from textbox + $("#plusBox").focus(); //Moving cursor into text box again after refresh + $("
+
").css({ + cursor: "pointer", + color: "#0000FF" + }).appendTo(Options.get_tab('fav-tab').content); //Adding the plus to the tab + $("").css({ + height: 25, bottom: 5, + width: "calc(100% - 10px)", + left: 5, right: 5 + }).appendTo(Options.get_tab('fav-tab').content); //Adding button to the tab +} //This adds the text inside the textbox to favorites, localStorage.favorites and the page + +//Making as many functions and variables non-global +$(document).ready(function(){ + +//Pregenerating list of boards +var favList = ['
']; +for(var i=0; i'; +} +favList += '
'; + +//Creating list of minus symbols to remove unwanted boards +var minusList = ['
']; +for(var i=0; i-
'; +} +minusList += ""; + +//Help message so people understand how sorting boards works +$("Drag the boards to sort them.

").appendTo(Options.get_tab('fav-tab').content); + +//Adding list of boards and minus symbols to remove boards with +$(favList).appendTo(Options.get_tab('fav-tab').content); //Adding the list of favorite boards to the tab +$(minusList).appendTo(Options.get_tab('fav-tab').content); //Adding the list of minus symbols to the tab + +//Adding spacing and text box to right boards into +$("

").appendTo(Options.get_tab('fav-tab').content); +$("").appendTo(Options.get_tab('fav-tab').content); +$("#plusBox").keydown(function( event ) { + if(event.keyCode == 13){ + $("#plus").click(); + } +}); + +//Adding plus symbol to use to add board +$("
+
").css({ + cursor: "pointer", + color: "#0000FF" +}).appendTo(Options.get_tab('fav-tab').content); //Adding the plus button +$("").css({ + height: 25, bottom: 5, + width: "calc(100% - 10px)", + left: 5, right: 5 +}).appendTo(Options.get_tab('fav-tab').content); //Adding submit button to the tab + +$("#sortable").sortable(); //Making boards with sortable id use the sortable jquery function + +}); From aee9cd845594e6543c21e4024cbe3f5bec16d438 Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Sun, 15 Mar 2015 17:40:27 +0800 Subject: [PATCH 2/4] Better organize auto-update options --- js/auto-reload.js | 2 +- js/auto-scroll.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/auto-reload.js b/js/auto-reload.js index 528dd68d..32b58b86 100644 --- a/js/auto-reload.js +++ b/js/auto-reload.js @@ -38,7 +38,7 @@ $(document).ready(function(){ localStorage.auto_thread_update = 'true'; //default value } if (window.Options && Options.get_tab('general')) { - Options.extend_tab("general", "
"+_("Auto update")+"" + Options.extend_tab("general", "
"+_("Auto update")+"" + ('') + ('') + ('') diff --git a/js/auto-scroll.js b/js/auto-scroll.js index b8343f5e..5c253499 100644 --- a/js/auto-scroll.js +++ b/js/auto-scroll.js @@ -1,7 +1,7 @@ $('document').ready(function () { var autoScroll = localStorage['autoScroll'] ? true : false; if (window.Options && Options.get_tab('general')){ - Options.extend_tab('general',''); + $('#auto-update-fs').append(''); $('#autoScroll').find('input').prop('checked', autoScroll); } $('#autoScroll').on('change', function() { @@ -15,7 +15,7 @@ $('document').ready(function () { $('input.auto-scroll').prop('checked', autoScroll); }); if (active_page == 'thread') { - $('span[id="updater"]').children('a').after(' ( Scroll to New posts)'); + $('span[id="updater"]').children('a').after(' ( '+_('Scroll to new posts')+')'); $('input.auto-scroll').prop('checked', autoScroll); $(document).on('new_post', function (e, post) { if ($('input.auto-scroll').prop('checked')) From 4e65041615167026c76fe9fa4d23422de561d302 Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Sun, 15 Mar 2015 17:41:38 +0800 Subject: [PATCH 3/4] Make Youtube size inputs look a little nicer --- stylesheets/style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stylesheets/style.css b/stylesheets/style.css index 84107a07..52d02473 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -1177,3 +1177,7 @@ div.mix { display: none !important; } } + +#youtube-size input { + width: 50px; +} From 86d99b332b4ac83e5211ebf26d5c52ae3a8a1e2c Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Sun, 15 Mar 2015 19:56:28 +0800 Subject: [PATCH 4/4] Make js/options/favs.js actually usable I pretty much had to rework this completely to get it into a usable state Reference ctrlcctrlv/infinity#424 --- inc/instance-config.php | 3 +- js/options/fav.js | 76 +++++++++++++++-------------------------- 2 files changed, 29 insertions(+), 50 deletions(-) diff --git a/inc/instance-config.php b/inc/instance-config.php index 4d463751..a2dad456 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -116,6 +116,7 @@ $config['additional_javascript'][] = 'js/auto-reload.js'; $config['additional_javascript'][] = 'js/options/user-css.js'; $config['additional_javascript'][] = 'js/options/user-js.js'; + $config['additional_javascript'][] = 'js/options/fav.js'; $config['additional_javascript'][] = 'js/forced-anon.js'; $config['additional_javascript'][] = 'js/toggle-locked-threads.js'; $config['additional_javascript'][] = 'js/toggle-images.js'; @@ -152,7 +153,7 @@ $config['additional_javascript'][] = 'js/wPaint/plugins/file/wPaint.menu.main.file.min.js'; $config['additional_javascript'][] = 'js/wpaint.js'; // Code tags (fix because we no longer have different scripts for each board) - $config['additional_javascript'][] = 'js/code_tags/run_prettify.js'; + //$config['additional_javascript'][] = 'js/code_tags/run_prettify.js'; //$config['font_awesome_css'] = '/netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'; diff --git a/js/options/fav.js b/js/options/fav.js index f8d12bf3..17ccb337 100644 --- a/js/options/fav.js +++ b/js/options/fav.js @@ -1,94 +1,72 @@ -//Setting global variables -var favorites = JSON.parse(localStorage.favorites); -Options.add_tab('fav-tab','star',_("Favorites")); - +$(document).ready(function(){ //Creating functions var generateList = function(){ var favStor = []; for(var i=1; i div:nth-child("+i+")").html()); } - return JSON.stringify(favStor); + return favStor; } //This will generate a list of boards based off of the list on the screen function removeBoard(boardNumber){ favorites.splice(boardNumber, 1); localStorage.favorites = JSON.stringify(favorites); $("#sortable > div:nth-child("+(boardNumber+1)+")").remove(); $("#minusList > div:nth-child("+(favorites.length+1)+")").remove(); + add_favorites(); } //This removes a board from favorites, localStorage.favorites and the page function addBoard(){ $("#sortable").append("
"+($("#plusBox").val())+"
"); - $("#minusList").append("
-
"); + $("#minusList").append( $('
-
').on('click', function(e){removeBoard($(this).data('board'));}) ); favorites.push($("#plusBox").val()); localStorage.favorites = JSON.stringify(favorites); - $("#space").remove(); - $("#plusBox").remove(); //Refreshing the last 3 elements to move the box down - $("#plus").remove(); - $("#submitFavorites").remove(); - $("

").appendTo(Options.get_tab('fav-tab').content); - $("").appendTo(Options.get_tab('fav-tab').content); - $("#plusBox").keydown(function( event ) { - if(event.keyCode == 13){ - $("#plus").click(); - } - }); //Adding enter to submit - document.getElementById("plusBox").value = ""; //Removing text from textbox - $("#plusBox").focus(); //Moving cursor into text box again after refresh - $("
+
").css({ - cursor: "pointer", - color: "#0000FF" - }).appendTo(Options.get_tab('fav-tab').content); //Adding the plus to the tab - $("").css({ - height: 25, bottom: 5, - width: "calc(100% - 10px)", - left: 5, right: 5 - }).appendTo(Options.get_tab('fav-tab').content); //Adding button to the tab + $("#plusBox").val(""); //Removing text from textbox + add_favorites(); } //This adds the text inside the textbox to favorites, localStorage.favorites and the page -//Making as many functions and variables non-global -$(document).ready(function(){ +var favorites = JSON.parse(localStorage.favorites); +Options.add_tab('fav-tab','star',_("Favorites")); //Pregenerating list of boards -var favList = ['
']; +var favList = $('
'); for(var i=0; i'; + favList.append( $('
'+favorites[i]+'
') ); } -favList += '
'; //Creating list of minus symbols to remove unwanted boards -var minusList = ['
']; +var minusList = $('
'); for(var i=0; i-
'; + minusList.append( $('
-
').on('click', function(e){removeBoard($(this).data('board'));}) ); } -minusList += "
"; //Help message so people understand how sorting boards works -$("Drag the boards to sort them.

").appendTo(Options.get_tab('fav-tab').content); +$(""+_("Drag the boards to sort them.")+"

").appendTo(Options.get_tab('fav-tab').content); //Adding list of boards and minus symbols to remove boards with -$(favList).appendTo(Options.get_tab('fav-tab').content); //Adding the list of favorite boards to the tab $(minusList).appendTo(Options.get_tab('fav-tab').content); //Adding the list of minus symbols to the tab +$(favList).appendTo(Options.get_tab('fav-tab').content); //Adding the list of favorite boards to the tab //Adding spacing and text box to right boards into -$("

").appendTo(Options.get_tab('fav-tab').content); -$("").appendTo(Options.get_tab('fav-tab').content); -$("#plusBox").keydown(function( event ) { +var addDiv = $("
"); + +var plusBox = $("").appendTo(addDiv); +plusBox.keydown(function( event ) { if(event.keyCode == 13){ $("#plus").click(); } }); //Adding plus symbol to use to add board -$("
+
").css({ +$("
+
").css({ cursor: "pointer", color: "#0000FF" -}).appendTo(Options.get_tab('fav-tab').content); //Adding the plus button -$("").css({ - height: 25, bottom: 5, - width: "calc(100% - 10px)", - left: 5, right: 5 -}).appendTo(Options.get_tab('fav-tab').content); //Adding submit button to the tab +}).on('click', function(e){addBoard()}).appendTo(addDiv); -$("#sortable").sortable(); //Making boards with sortable id use the sortable jquery function +addDiv.appendTo(Options.get_tab('fav-tab').content); //Adding the plus button +favList.sortable(); //Making boards with sortable id use the sortable jquery function +favList.on('sortstop', function() { + favorites = generateList(); + localStorage.favorites = JSON.stringify(favorites); + add_favorites(); +}); });