about summary refs log tree commit diff
diff options
context:
space:
mode:
authorzsloan2021-06-21 20:29:26 +0000
committerzsloan2021-06-21 20:29:26 +0000
commitef49a5bf5b1b2b010c71f77394c5b178c00b8942 (patch)
tree52c046b8620d1c42fd9b7cec88174eccd0e226b8
parent53ee6cd16a3791fd1cb32f758f6799d87c10f4c0 (diff)
downloadgenenetwork2-ef49a5bf5b1b2b010c71f77394c5b178c00b8942.tar.gz
Fixed indentation in table_functions.js
-rw-r--r--wqflask/wqflask/static/new/javascript/table_functions.js181
1 files changed, 88 insertions, 93 deletions
diff --git a/wqflask/wqflask/static/new/javascript/table_functions.js b/wqflask/wqflask/static/new/javascript/table_functions.js
index e24b3e03..745563c2 100644
--- a/wqflask/wqflask/static/new/javascript/table_functions.js
+++ b/wqflask/wqflask/static/new/javascript/table_functions.js
@@ -1,93 +1,88 @@
-recheck_rows = function(the_table, checked_rows){

-    //ZS: This is meant to recheck checkboxes after columns are resized

-    check_cells = the_table.column(0).nodes().to$();

-    for (let i = 0; i < check_cells.length; i++) {

-      if (checked_rows.includes(i)){

-        check_cells[i].childNodes[0].checked = true;

-      }

-    }

-

-    check_rows = trait_table.rows().nodes();

-    for (let i =0; i < check_rows.length; i++) {

-      if (checked_rows.includes(i)){

-        check_rows[i].classList.add("selected")

-      }

-    }

-  }

-

-get_checked_rows = function(table_id){

-    let checked_rows = []

-    $("#" + table_id + " input").each(function(index){

-      if ($(this).prop("checked") == true){

-        checked_rows.push(index);

-      }

-    });

-

-    return checked_rows

-}

-

-function setUserColumnsDefWidths(table_id) {

-    var userColumnDef;

-

-    // Get the settings for this table from localStorage

-    var userColumnDefs = JSON.parse(localStorage.getItem(table_id)) || [];

-

-    if (userColumnDefs.length === 0 ) return;

-

-    columnDefs.forEach( function(columnDef) {

-

-      // Check if there is a width specified for this column

-      userColumnDef = userColumnDefs.find( function(column) {

-        return column.targets === columnDef.targets;

-      });

-

-      // If there is, set the width of this columnDef in px

-      if ( userColumnDef ) {

-

-        columnDef.sWidth = userColumnDef.width + 'px';

-        columnDef.width = userColumnDef.width + 'px';

-

-        $('.toggle-vis').each(function(){

-          if ($(this).attr('data-column') == columnDef.targets){

-            if ($(this).hasClass("active")){

-              columnDef.bVisible = false

-            } else {

-              columnDef.bVisible = true

-            }

-          }

-        })

-      }

-    });

-}

-

-function saveColumnSettings(table_id, trait_table) {

-var userColumnDefs = JSON.parse(localStorage.getItem(table_id)) || [];

-

-var width, header, existingSetting; 

-

-trait_table.columns().every( function ( targets ) {

-

-    // Check if there is a setting for this column in localStorage

-    existingSetting = userColumnDefs.findIndex( function(column) { return column.targets === targets;});

-

-    // Get the width of this column

-    header = this.header();

-    width = $(header).width();

-

-    if ( existingSetting !== -1 ) {

-    // Update the width

-    userColumnDefs[existingSetting].width = width;

-    } else {

-

-    // Add the width for this column

-    userColumnDefs.push({

-        targets: targets,

-        width:  width,

-    });

-

-    }

-});

-

-// Save (or update) the settings in localStorage

-localStorage.setItem(table_id, JSON.stringify(userColumnDefs));

-}
\ No newline at end of file
+recheck_rows = function(the_table, checked_rows){
+  //ZS: This is meant to recheck checkboxes after columns are resized
+  check_cells = the_table.column(0).nodes().to$();
+  for (let i = 0; i < check_cells.length; i++) {
+    if (checked_rows.includes(i)){
+      check_cells[i].childNodes[0].checked = true;
+    }
+  }
+
+  check_rows = trait_table.rows().nodes();
+  for (let i =0; i < check_rows.length; i++) {
+    if (checked_rows.includes(i)){
+      check_rows[i].classList.add("selected")
+    }
+  }
+}
+
+get_checked_rows = function(table_id){
+  let checked_rows = []
+  $("#" + table_id + " input").each(function(index){
+    if ($(this).prop("checked") == true){
+      checked_rows.push(index);
+    }
+  });
+
+  return checked_rows
+}
+
+function setUserColumnsDefWidths(table_id) {
+  var userColumnDef;
+
+  // Get the settings for this table from localStorage
+  var userColumnDefs = JSON.parse(localStorage.getItem(table_id)) || [];
+
+  if (userColumnDefs.length === 0 ) return;
+
+  columnDefs.forEach( function(columnDef) {
+    // Check if there is a width specified for this column
+    userColumnDef = userColumnDefs.find( function(column) {
+      return column.targets === columnDef.targets;
+    });
+
+    // If there is, set the width of this columnDef in px
+    if ( userColumnDef ) {
+
+      columnDef.sWidth = userColumnDef.width + 'px';
+      columnDef.width = userColumnDef.width + 'px';
+
+      $('.toggle-vis').each(function(){
+        if ($(this).attr('data-column') == columnDef.targets){
+          if ($(this).hasClass("active")){
+            columnDef.bVisible = false
+          } else {
+            columnDef.bVisible = true
+          }
+        }
+      })
+    }
+  });
+}
+
+function saveColumnSettings(table_id, trait_table) {
+  var userColumnDefs = JSON.parse(localStorage.getItem(table_id)) || [];
+  var width, header, existingSetting; 
+
+  trait_table.columns().every( function ( targets ) {
+    // Check if there is a setting for this column in localStorage
+    existingSetting = userColumnDefs.findIndex( function(column) { return column.targets === targets;});
+
+    // Get the width of this column
+    header = this.header();
+    width = $(header).width();
+
+    if ( existingSetting !== -1 ) {
+    // Update the width
+    userColumnDefs[existingSetting].width = width;
+    } else {
+      // Add the width for this column
+      userColumnDefs.push({
+          targets: targets,
+          width:  width,
+      });
+    }
+  });
+
+  // Save (or update) the settings in localStorage
+  localStorage.setItem(table_id, JSON.stringify(userColumnDefs));
+}