diff --git a/static/js/index.js b/static/js/index.js index b12bf9d..f9b1cbf 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -171,65 +171,33 @@ function loadMoreResults(){ } } -var searchGroups = []; -var currentSearchGroup = 0; - +var searchGroups = $("div#search-groups"); // Create a new search group. -$("div#add-group").click(function(){ - storeSearchGroup(); - currentSearchGroup = searchGroups.length; - $("span#current, span#total").text(currentSearchGroup + 1); -}); - -// Save the current's search group's values, and load the previous one. -$("div#previous-group").click(function(){ - console.log(currentSearchGroup); - if(0 < currentSearchGroup){ - storeSearchGroup(); - currentSearchGroup--; - loadSearchGroup(); - $("span#current").text(currentSearchGroup + 1); - } -}); - -// Save the current's search group's values, and load the next one. -$("div#next-group").click(function(){ - console.log(currentSearchGroup); - if(currentSearchGroup < searchGroups.length - 1){ - storeSearchGroup(); - currentSearchGroup++; - loadSearchGroup(); - $("span#current").text(currentSearchGroup + 1); - } +$("button#add-group").click(function(){ + var searchGroup = $("
", {class : "search-group"}); + searchGroups.append(searchGroup.append(createSearchGroupInput("language"))); }); -/* - * Store the advanced search form's values into the currently selected search - * group object. - */ -function storeSearchGroup(){ - var searchGroup = {}; - var inputs = $("div#advanced-search input[type='text']"); - - for(var input = 0; input < inputs.length; input++) - if(inputs[input].value.length > 0){ - searchGroup[inputs[input].id] = inputs[input].value; - inputs[input].value = ""; - } - - if(currentSearchGroup < searchGroups.length) - searchGroups[currentSearchGroup] = searchGroup; +$("div#advanced-search #sidebar input[type=checkbox]").click(function(){ + var fieldId = $(this).attr("id"); + if($(this).is(":checked")) + $("div.search-group#selected").append( + $.parseHTML(createSearchGroupInput(fieldId))); else - searchGroups.push(searchGroup); -} + $("div.search-group#selected #" + fieldId).remove() +}) /* - * Load the values belonging to the currently selected search group object into - * the advanced search form. + * Return an HTML string representing a new input field div in a search group. + * + * @param fieldId The id of the input field div, and its child elements. */ -function loadSearchGroup(groupNumber){ - for(var inputId in searchGroups[currentSearchGroup]){ - var selector = "div#advanced-search input[type='text']#" + inputId; - $(selector).val(searchGroups[currentSearchGroup][inputId]); - } +function createSearchGroupInput(fieldId){ + return [ + "
", + "
" + fieldId + "
", + "", + "Regex", + "
" + ].join(""); } diff --git a/static/sass/index.sass b/static/sass/index.sass index 75ecc54..c50eb83 100644 --- a/static/sass/index.sass +++ b/static/sass/index.sass @@ -70,8 +70,6 @@ div#search-field font-style: italic form#search-bar - min-width: 510px - input[type="text"], button @extend .t3 @include vendor(box-sizing, border-box) @@ -114,6 +112,8 @@ div#search-field div#advanced-search background-color: white border: 1px solid $baseColor3 + font-size: 96% + min-width: 490px padding-top: 0px overflow-x: auto height: 400px @@ -150,7 +150,6 @@ div#search-field background-color: $lightGray border: none - font-size: 96% padding: 3% width: 85% @@ -176,21 +175,29 @@ div#search-field background-color: $lightBlue border: none color: white - font-weight: bold height: 40px margin-bottom: 10% + overflow: hidden + white-space: nowrap width: 40px + span + font-size: 150% + font-weight: bold + margin-left: 6px + margin-right: 10px + &:hover @extend .t3 background-color: $blue cursor: pointer + width: 90% #search-groups margin-top: 2% max-height: 93% - overflow-y: scroll + overflow-y: auto width: 75% .search-group @@ -212,6 +219,12 @@ div#search-field input[type=checkbox] margin-left: 2% + &:checked + span + @extend .t2 + + color: green + font-weight: bold + span font-size: 80% diff --git a/templates/index.html b/templates/index.html index c2f3c68..cb4f366 100644 --- a/templates/index.html +++ b/templates/index.html @@ -40,7 +40,7 @@
-
-
-
Authors
- - Regex? -
-
-
Language
- - Regex? +
+
+
language
+ + Regex
-
Hello, world. 2
-
Hello, world. 3
-
Hello, world. 4
-
Hello, world. 5
-
Hello, world. 6
-
Hello, world. 7
-
Hello, world. 8
-
Hello, world. 9
-
Hello, world. 10
-
Hello, world. 11
-
Hello, world. 12
-
Hello, world. 13
-
Hello, world. 14
-
Hello, world. 15
-
Hello, world. 16
-
Hello, world. 17
-
Hello, world. 18
-
Hello, world. 19
-
Hello, world. 20
-
Hello, world. 21
-
Hello, world. 22