Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
facd183304 fav.js: handle undefined favorites 2025-02-12 23:09:22 +01:00
40bbda5027 fav.js: minor trim 2025-02-12 23:08:11 +01:00

View file

@ -23,20 +23,20 @@ function addBoard(){
add_favorites();
} //This adds the text inside the textbox to favorites, localStorage.favorites and the page
var favorites = JSON.parse(localStorage.favorites);
var favorites = localStorage.favorites ? JSON.parse(localStorage.favorites) : [];
Options.add_tab('fav-tab','star',_("Favorites"));
//Pregenerating list of boards
//Pregenerating list of boards
var favList = $('<div id="sortable" style="cursor: pointer; display: inline-block">');
for(var i=0; i<favorites.length; i++){
favList.append( $('<div>'+favorites[i]+'</div>') );
}
}
//Creating list of minus symbols to remove unwanted boards
var minusList = $('<div id="minusList" style="color: #0000FF; display: inline-block">');
for(var i=0; i<favorites.length; i++){
minusList.append( $('<div data-board="'+i+'" style="cursor: pointer; margin-right: 5px">-</div>').on('click', function(e){removeBoard($(this).data('board'));}) );
}
}
//Help message so people understand how sorting boards works
$("<span>"+_("Drag the boards to sort them.")+"</span><br><br>").appendTo(Options.get_tab('fav-tab').content);
@ -65,7 +65,7 @@ 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();
favorites = generateList();
localStorage.favorites = JSON.stringify(favorites);
add_favorites();
});