summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-12-02 10:46:09 +0300
committerAndrew Dolgov <[email protected]>2018-12-02 10:46:09 +0300
commitaa2f119eb656cc2064da691328239010f51afb98 (patch)
tree2a87fc458c4de0d3bf2d7d74f095f42203eb9fd5 /js
parent874560db547f718b82d77657dc019d840c30e0ed (diff)
remove getSelectedTableRowIds (Tables.getSelected)
Diffstat (limited to 'js')
-rwxr-xr-xjs/functions.js35
-rwxr-xr-xjs/prefs.js6
2 files changed, 21 insertions, 20 deletions
diff --git a/js/functions.js b/js/functions.js
index 033933794..6e61f4c9f 100755
--- a/js/functions.js
+++ b/js/functions.js
@@ -62,14 +62,30 @@ const Lists = {
}
};
+// noinspection JSUnusedGlobalSymbols
const Tables = {
onRowChecked: function(elem) {
// account for dojo checkboxes
elem = elem.domNode || elem;
elem.up("tr").toggleClassName("Selected");
+ },
+ getSelected: function(elemId) {
+ const rv = [];
+
+ $(elemId).select("tr").each((row) => {
+ if (row.hasClassName("Selected")) {
+ // either older prefix-XXX notation or separate attribute
+ const rowId = row.getAttribute("data-row-id") || row.id.replace(/^[A-Z]*?-/, "");
+
+ if (!isNaN(rowId))
+ rv.push(parseInt(rowId));
+ }
+ });
+
+ return rv;
}
-}
+};
const Utils = {
_rpc_seq: 0,
@@ -526,7 +542,7 @@ const CommonDialogs = {
title: __("Feeds with update errors"),
style: "width: 600px",
getSelectedFeeds: function () {
- return getSelectedTableRowIds("prefErrorFeedList");
+ return Tables.getSelected("prefErrorFeedList");
},
removeSelected: function () {
const sel_rows = this.getSelectedFeeds();
@@ -1570,21 +1586,6 @@ function selectTableRows(id, mode) {
}
}
-function getSelectedTableRowIds(id) {
- const rows = [];
-
- const elem_rows = $(id).rows;
-
- for (let i = 0; i < elem_rows.length; i++) {
- if (elem_rows[i].hasClassName("Selected")) {
- const bare_id = elem_rows[i].id.replace(/^[A-Z]*?-/, "");
- rows.push(bare_id);
- }
- }
-
- return rows;
-}
-
// noinspection JSUnusedGlobalSymbols
function label_to_feed_id(label) {
return _label_base_index - 1 - Math.abs(label);
diff --git a/js/prefs.js b/js/prefs.js
index f12c31441..3b9e090cc 100755
--- a/js/prefs.js
+++ b/js/prefs.js
@@ -314,7 +314,7 @@ function getSelectedLabels() {
}
function getSelectedUsers() {
- return getSelectedTableRowIds("prefUserList");
+ return Tables.getSelected("prefUserList");
}
function getSelectedFeeds() {
@@ -832,7 +832,7 @@ function showInactiveFeeds() {
title: __("Feeds without recent updates"),
style: "width: 600px",
getSelectedFeeds: function () {
- return getSelectedTableRowIds("prefInactiveFeedList");
+ return Tables.getSelected("prefInactiveFeedList");
},
removeSelected: function () {
const sel_rows = this.getSelectedFeeds();
@@ -922,7 +922,7 @@ function editProfiles() {
title: __("Settings Profiles"),
style: "width: 600px",
getSelectedProfiles: function () {
- return getSelectedTableRowIds("prefFeedProfileList");
+ return Tables.getSelected("prefFeedProfileList");
},
removeSelected: function () {
const sel_rows = this.getSelectedProfiles();