aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorZachary Sloan2012-10-18 17:21:50 -0500
committerZachary Sloan2012-10-18 17:21:50 -0500
commit99a5ce8abf6ddc7a0f3bea2189bf68a5ac10d171 (patch)
treefd75a8b2e80f6baf763f1b3b8f69221f0b594a20 /wqflask
parentd69349809e2ba039802c5a817ea7e0f8a9140966 (diff)
downloadgenenetwork2-99a5ce8abf6ddc7a0f3bea2189bf68a5ac10d171.tar.gz
Tried to make sense of existing code in select_dataset_menu.js/coffee, decided to make data structure reasonable and rewrite coffeescript
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/wqflask/static/new/javascript/dataset_select_items.js10
-rw-r--r--wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee45
-rw-r--r--wqflask/wqflask/static/new/javascript/dataset_select_menu.js40
3 files changed, 64 insertions, 31 deletions
diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_items.js b/wqflask/wqflask/static/new/javascript/dataset_select_items.js
index 11be18cc..33ff34cb 100755
--- a/wqflask/wqflask/static/new/javascript/dataset_select_items.js
+++ b/wqflask/wqflask/static/new/javascript/dataset_select_items.js
@@ -1,4 +1,4 @@
-var sArr = [
+window.sArr = [
{txt:'',val:''},
{txt:'Human',val:'human'},
{txt:'Macaque monkey',val:'macaque monkey'},
@@ -11,7 +11,7 @@ var sArr = [
{txt:'Tomato',val:'tomato'},
{txt:'All Species',val:'All Species'}];
-var gArr = [
+window.gArr = [
{txt:'',val:''},
{txt:'AD Cases & Controls (Liang)',val:'AD-cases-controls'},
{txt:'AD Cases & Controls (Myers)',val:'AD-cases-controls-Myers'},
@@ -51,7 +51,7 @@ var gArr = [
{txt:'SXM',val:'SXM'},
{txt:'All Groups',val:'all groups'}];
-var tArr = [
+window.tArr = [
{txt:'',val:''},
{txt:'Adipose mRNA',val:'Adipose'},
{txt:'Adrenal Gland mRNA',val:'Adrenal Gland'},
@@ -114,7 +114,7 @@ var tArr = [
{txt:'Phenotypes',val:'Phenotypes'},
{txt:'Genotypes',val:'Genotypes'}];
-var dArr = [
+window.dArr = [
{txt:'',val:''},
{txt:'GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv',val:'GSE15222_F_A_RI_0409'},
{txt:'GSE15222 Human Brain Normal Myers (Apr09) RankInv',val:'GSE15222_F_N_RI_0409'},
@@ -442,7 +442,7 @@ var dArr = [
{txt:'LXP Published Phenotypes',val:'LXPPublish'},
{txt:'All Phenotypes',val:'_allPublish'}];
-var lArr = [
+window.lArr = [
null,
[1,1,4,79],
[1,1,4,80],
diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee b/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee
index 93bf9a07..e2f11845 100644
--- a/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee
+++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu.coffee
@@ -4,6 +4,15 @@
#
$ ->
+ sArr = window.sArr # species
+ gArr = window.gArr # group
+ tArr = window.tArr
+ dArr = window.dArr
+ lArr = window.lArr
+
+ console.log("sArr is now [jersey]:", sArr)
+ console.log("gArr is now [jersey]:", gArr)
+
initialDatasetSelection = ->
defaultSpecies = getDefaultValue("species")
defaultSet = getDefaultValue("cross")
@@ -133,8 +142,10 @@ $ ->
#* output: null
#
fillOptions = (selectObjId) ->
+ console.log("[vacuum] selectObjId:", selectObjId)
unless selectObjId?
speciesObj = document.getElementById("species")
+ console.log("speciesObj:", speciesObj)
len = sArr.length
i = 1
@@ -142,20 +153,24 @@ $ ->
# setting Species' option
speciesObj.options[i - 1] = new Option(sArr[i].txt, sArr[i].val)
+ console.log("speciesObj.options:", speciesObj.options[i - 1])
i++
- updateChocie "species"
+ updateChoice "species"
else if selectObjId is "species"
speciesObj = document.getElementById("species")
+ console.log("speciesObj:", speciesObj)
groupObj = document.getElementById("cross")
+ console.log("groupObj:", groupObj)
len = lArr.length
arr = []
idx = 0
i = 1
-
+
while i < len
-
#get group(cross) info from lArr
- arr[idx++] = lArr[i][1] if lArr[i][0] is (getIndexByValue("species", speciesObj.value)).toString() and not Contains(arr, lArr[i][1])
+ index_value = getIndexByValue("species", speciesObj.value).toString()
+ if lArr[i][0] is (index_value and not Contains(arr, lArr[i][1]))
+ arr[idx++] = lArr[i][1]
i++
idx = 0
len = arr.length
@@ -163,11 +178,10 @@ $ ->
i = 0
while i < len
-
# setting Group's option
groupObj.options[idx++] = new Option(gArr[arr[i]].txt, gArr[arr[i]].val)
i++
- updateChocie "cross"
+ updateChoice "cross"
else if selectObjId is "cross"
speciesObj = document.getElementById("species")
groupObj = document.getElementById("cross")
@@ -192,7 +206,7 @@ $ ->
# setting Type's option
typeObj.options[idx++] = new Option(tArr[arr[i]].txt, tArr[arr[i]].val)
i++
- updateChocie "tissue"
+ updateChoice "tissue"
else if selectObjId is "tissue"
speciesObj = document.getElementById("species")
groupObj = document.getElementById("cross")
@@ -218,7 +232,7 @@ $ ->
# setting Database's option
databaseObj.options[idx++] = new Option(dArr[arr[i]].txt, dArr[arr[i]].val)
i++
- updateChocie "database"
+ updateChoice "database"
#
#* input: arr (targeted array); obj (targeted value)
@@ -281,7 +295,10 @@ $ ->
#* output: return true if selected status has been set, otherwise return false.
#
setChoice = (objId, val) ->
+ console.log("objId:", objId)
+ console.log("val:", val)
Obj = document.getElementById(objId)
+ console.log("Obj:", Obj)
idx = -1
i = 0
while i < Obj.options.length
@@ -290,7 +307,7 @@ $ ->
break
i++
if idx >= 0
-
+
#setting option's selected status
Obj.options[idx].selected = true
@@ -301,7 +318,7 @@ $ ->
fillOptions objId
# setting option's selected status based on default setting or cookie setting for Species, Group, Type and Database select menu in the main search page http://www.genenetwork.org/
- updateChocie = (selectObjId) ->
+ updateChoice = (selectObjId) ->
if selectObjId is "species"
defaultSpecies = getDefaultValue("species")
@@ -364,10 +381,10 @@ $ ->
setCookie "defaultType", defaultType, 10
defaultDB = thisform.database.value
setCookie "defaultDB", defaultDB, 10
- updateChocie "species"
- updateChocie "cross"
- updateChocie "tissue"
- updateChocie "database"
+ updateChoice "species"
+ updateChoice "cross"
+ updateChoice "tissue"
+ updateChoice "database"
alert "The current settings are now your default"
else
alert "You need to enable Cookies in your browser."
diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu.js
index f0e5fa89..eb04839c 100644
--- a/wqflask/wqflask/static/new/javascript/dataset_select_menu.js
+++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu.js
@@ -2,7 +2,14 @@
(function() {
$(function() {
- var Contains, fillOptions, fillOptionsForIE, getDefaultValue, getIndexByValue, initialDatasetSelection, removeOptions, setChoice, setDefault, updateChocie;
+ var Contains, dArr, fillOptions, fillOptionsForIE, gArr, getDefaultValue, getIndexByValue, initialDatasetSelection, lArr, removeOptions, sArr, setChoice, setDefault, tArr, updateChoice;
+ sArr = window.sArr;
+ gArr = window.gArr;
+ tArr = window.tArr;
+ dArr = window.dArr;
+ lArr = window.lArr;
+ console.log("sArr is now [jersey]:", sArr);
+ console.log("gArr is now [jersey]:", gArr);
initialDatasetSelection = function() {
var dOptions, defaultDB, defaultSet, defaultSpecies, defaultType, gOptions, menu0, menu1, menu2, menu3, sOptions, tOptions;
defaultSpecies = getDefaultValue("species");
@@ -120,25 +127,31 @@
return options;
};
fillOptions = function(selectObjId) {
- var arr, databaseObj, groupObj, i, idx, len, speciesObj, typeObj;
+ var arr, databaseObj, groupObj, i, idx, index_value, len, speciesObj, typeObj;
+ console.log("[vacuum] selectObjId:", selectObjId);
if (selectObjId == null) {
speciesObj = document.getElementById("species");
+ console.log("speciesObj:", speciesObj);
len = sArr.length;
i = 1;
while (i < len) {
speciesObj.options[i - 1] = new Option(sArr[i].txt, sArr[i].val);
+ console.log("speciesObj.options:", speciesObj.options[i - 1]);
i++;
}
- return updateChocie("species");
+ return updateChoice("species");
} else if (selectObjId === "species") {
speciesObj = document.getElementById("species");
+ console.log("speciesObj:", speciesObj);
groupObj = document.getElementById("cross");
+ console.log("groupObj:", groupObj);
len = lArr.length;
arr = [];
idx = 0;
i = 1;
while (i < len) {
- if (lArr[i][0] === (getIndexByValue("species", speciesObj.value)).toString() && !Contains(arr, lArr[i][1])) {
+ index_value = getIndexByValue("species", speciesObj.value).toString();
+ if (lArr[i][0] === (index_value && !Contains(arr, lArr[i][1]))) {
arr[idx++] = lArr[i][1];
}
i++;
@@ -151,7 +164,7 @@
groupObj.options[idx++] = new Option(gArr[arr[i]].txt, gArr[arr[i]].val);
i++;
}
- return updateChocie("cross");
+ return updateChoice("cross");
} else if (selectObjId === "cross") {
speciesObj = document.getElementById("species");
groupObj = document.getElementById("cross");
@@ -174,7 +187,7 @@
typeObj.options[idx++] = new Option(tArr[arr[i]].txt, tArr[arr[i]].val);
i++;
}
- return updateChocie("tissue");
+ return updateChoice("tissue");
} else if (selectObjId === "tissue") {
speciesObj = document.getElementById("species");
groupObj = document.getElementById("cross");
@@ -198,7 +211,7 @@
databaseObj.options[idx++] = new Option(dArr[arr[i]].txt, dArr[arr[i]].val);
i++;
}
- return updateChocie("database");
+ return updateChoice("database");
}
};
Contains = function(arr, obj) {
@@ -262,7 +275,10 @@
};
setChoice = function(objId, val) {
var Obj, i, idx;
+ console.log("objId:", objId);
+ console.log("val:", val);
Obj = document.getElementById(objId);
+ console.log("Obj:", Obj);
idx = -1;
i = 0;
while (i < Obj.options.length) {
@@ -280,7 +296,7 @@
return fillOptions(objId);
}
};
- updateChocie = function(selectObjId) {
+ updateChoice = function(selectObjId) {
var defaultDB, defaultSet, defaultSpecies, defaultType;
if (selectObjId === "species") {
defaultSpecies = getDefaultValue("species");
@@ -342,10 +358,10 @@
setCookie("defaultType", defaultType, 10);
defaultDB = thisform.database.value;
setCookie("defaultDB", defaultDB, 10);
- updateChocie("species");
- updateChocie("cross");
- updateChocie("tissue");
- updateChocie("database");
+ updateChoice("species");
+ updateChoice("cross");
+ updateChoice("tissue");
+ updateChoice("database");
return alert("The current settings are now your default");
} else {
return alert("You need to enable Cookies in your browser.");