From 5bbee1e1d7719180bf0a44210e90c8305be9b7d1 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Wed, 23 Oct 2019 11:27:05 +0200 Subject: [PATCH] fix some more minor javascript issues --- htdocs/lib/AprsMarker.js | 4 ++-- htdocs/lib/BookmarkBar.js | 30 +++++++++++++++--------------- htdocs/openwebrx.js | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/lib/AprsMarker.js b/htdocs/lib/AprsMarker.js index aa3210a..d31dadd 100644 --- a/htdocs/lib/AprsMarker.js +++ b/htdocs/lib/AprsMarker.js @@ -8,7 +8,7 @@ AprsMarker.prototype.draw = function() { if (!div || !overlay) return; if (this.symbol) { - var tableId = this.symbol.table == '/' ? 0 : 1; + var tableId = this.symbol.table === '/' ? 0 : 1; div.style.background = 'url(/aprs-symbols/aprs-symbols-24-' + tableId + '@2x.png)'; div.style['background-size'] = '384px 144px'; div.style['background-position-x'] = -(this.symbol.index % 16) * 24 + 'px'; @@ -25,7 +25,7 @@ AprsMarker.prototype.draw = function() { div.style.transform = null; } - if (this.symbol.table != '/' && this.symbol.table != '\\') { + if (this.symbol.table !== '/' && this.symbol.table !== '\\') { overlay.style.display = 'block'; overlay.style['background-position-x'] = -(this.symbol.tableindex % 16) * 24 + 'px'; overlay.style['background-position-y'] = -Math.floor(this.symbol.tableindex / 16) * 24 + 'px'; diff --git a/htdocs/lib/BookmarkBar.js b/htdocs/lib/BookmarkBar.js index 43f7213..4edac8e 100644 --- a/htdocs/lib/BookmarkBar.js +++ b/htdocs/lib/BookmarkBar.js @@ -31,7 +31,7 @@ function BookmarkBar() { me.loadLocalBookmarks(); }); - var $bookmarkButton = $('#openwebrx-panel-receiver .openwebrx-bookmark-button'); + var $bookmarkButton = $('#openwebrx-panel-receiver').find('.openwebrx-bookmark-button'); if (typeof(Storage) !== 'undefined') { $bookmarkButton.show(); } else { @@ -56,10 +56,10 @@ function BookmarkBar() { BookmarkBar.prototype.position = function(){ var range = get_visible_freq_range(); - $('#openwebrx-bookmarks-container .bookmark').each(function(){ + $('#openwebrx-bookmarks-container').find('.bookmark').each(function(){ $(this).css('left', scale_px_from_freq($(this).data('frequency'), range)); }); -} +}; BookmarkBar.prototype.loadLocalBookmarks = function(){ var bwh = bandwidth / 2; @@ -69,7 +69,7 @@ BookmarkBar.prototype.loadLocalBookmarks = function(){ return b.frequency >= start && b.frequency <= end; }); this.replace_bookmarks(bookmarks, 'local', true); -} +}; BookmarkBar.prototype.replace_bookmarks = function(bookmarks, source, editable) { editable = !!editable; @@ -80,13 +80,13 @@ BookmarkBar.prototype.replace_bookmarks = function(bookmarks, source, editable) }); this.bookmarks[source] = bookmarks; this.render(); -} +}; BookmarkBar.prototype.render = function(){ var bookmarks = Object.values(this.bookmarks).reduce(function(l, v){ return l.concat(v); }); bookmarks = bookmarks.sort(function(a, b){ return a.frequency - b.frequency; }); var elements = bookmarks.map(function(b){ - $bookmark = $( + var $bookmark = $( '
' + '
' + '
' + @@ -101,7 +101,7 @@ BookmarkBar.prototype.render = function(){ this.$container.find('.bookmark').remove(); this.$container.append(elements); this.position(); -} +}; BookmarkBar.prototype.showEditDialog = function(bookmark) { var $form = this.$dialog.find("form"); @@ -118,7 +118,7 @@ BookmarkBar.prototype.showEditDialog = function(bookmark) { this.$dialog.data('id', bookmark.id); this.$dialog.show(); this.$dialog.find('#name').focus(); -} +}; BookmarkBar.prototype.storeBookmark = function() { var me = this; @@ -146,31 +146,31 @@ BookmarkBar.prototype.storeBookmark = function() { } } - bookmarks = bookmarks.filter(function(b) { return b.id != bookmark.id; }); + bookmarks = bookmarks.filter(function(b) { return b.id !== bookmark.id; }); bookmarks.push(bookmark); me.localBookmarks.setBookmarks(bookmarks); me.loadLocalBookmarks(); me.$dialog.hide(); -} +}; BookmarkLocalStorage = function(){ -} +}; BookmarkLocalStorage.prototype.getBookmarks = function(){ return JSON.parse(window.localStorage.getItem("bookmarks")) || []; -} +}; BookmarkLocalStorage.prototype.setBookmarks = function(bookmarks){ window.localStorage.setItem("bookmarks", JSON.stringify(bookmarks)); -} +}; BookmarkLocalStorage.prototype.deleteBookmark = function(data) { if (data.id) data = data.id; var bookmarks = this.getBookmarks(); - bookmarks = bookmarks.filter(function(b) { return b.id != data; }); + bookmarks = bookmarks.filter(function(b) { return b.id !== data; }); this.setBookmarks(bookmarks); -} +}; diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index c89ebf9..317b261 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1946,7 +1946,7 @@ function initProgressBars() { audioOutputProgressBar = new AudioOutputProgressBar($('#openwebrx-bar-audio-output'), audioEngine.getSampleRate()); clientProgressBar = new ClientsProgressBar($('#openwebrx-bar-clients')); cpuProgressBar = new CpuProgressBar($('#openwebrx-bar-server-cpu')); -}; +} function updateNetworkStats() { var elapsed = (new Date() - debug_ws_time_start) / 1000;