diff --git a/searchapp/static/home.css b/searchapp/static/home.css index 0a0577f..1aac2b4 100644 --- a/searchapp/static/home.css +++ b/searchapp/static/home.css @@ -17,11 +17,12 @@ #grid{ grid-row-gap:70px; } -.button{ +.typeInfo{ outline:none; }/* Style the links inside the navigation bar */ -.button a { +.typeInfo button{ outline:0; + background-color: transparent; font-weight:800; color:black; text-align: center; @@ -37,10 +38,11 @@ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; } -.button a:hover { +.typeInfo button:hover { color: black; + cursor: pointer; } -.button a:active{ +.typeInfo button:active{ outline:0; border:none; -moz-outline-style:none; @@ -50,4 +52,4 @@ background:black; color:white; border-radius:5px; -} +} \ No newline at end of file diff --git a/searchapp/static/home.js b/searchapp/static/home.js new file mode 100644 index 0000000..45d6a92 --- /dev/null +++ b/searchapp/static/home.js @@ -0,0 +1,9 @@ +$(document).ready(function(){ + function set_worksheet_type(type){ + window.location.href="student_view" + "?type=" + type; + } + + $('.selectType').click(function(){ + set_worksheet_type($(this).attr('id')); + }); +}); diff --git a/searchapp/static/student_view.js b/searchapp/static/student_view.js index 5d799d4..c49f1ce 100644 --- a/searchapp/static/student_view.js +++ b/searchapp/static/student_view.js @@ -1,27 +1,27 @@ $(document).ready(function(){ // on selecting type of worksheet - $('#worksheetType').dropdown({ - onChange: function (value, text, $selectedItem) { - if(value == 'test') { - $("#test-div").show(); - $("#generic-div").hide(); - $("#customized-div").hide(); - } else if(value == 'generic') { - $("#test-div").hide(); - $("#generic-div").show(); - $("#customized-div").hide(); - } else if(value == 'customized') { - $("#test-div").hide(); - $("#generic-div").hide(); - $("#customized-div").show(); - } - }, - }); + function display_form_sections (value) { + if(value == 'test') { + $('#worksheetType').text('Test Paper'); + $("#test-div").show(); + $("#generic-div").hide(); + $("#customized-div").hide(); + } else if(value == 'generic') { + $('#worksheetType').text('Generic Paper'); + $("#test-div").hide(); + $("#generic-div").show(); + $("#customized-div").hide(); + } else if(value == 'customized') { + $('#worksheetType').text('Customized Paper'); + $("#test-div").hide(); + $("#generic-div").hide(); + $("#customized-div").show(); + } + } // function called when submit button clicked function submit_click(e) { - let worksheetType = $("#worksheetType").dropdown('get value'); if (worksheetType == 'test') { let subject = $("#test-subject").dropdown('get value'); let chapters = $('#test-chapter').dropdown('get values'); @@ -122,7 +122,6 @@ $(document).ready(function(){ } function upload_click(e) { - let worksheetType = $("#worksheetType").dropdown('get value'); if (worksheetType == 'customized') { let subject = $("#customized-subject").dropdown('get value'); let file_data = $('#realfile').prop("files")[0]; @@ -166,7 +165,6 @@ function upload_click(e) { } function populate_grades(value,text, $selectedItem) { - let worksheetType = document.getElementById("worksheetType") ? $("#worksheetType").dropdown('get value') : 'paper'; let boardData = { "board": $(`#${worksheetType}-board`).dropdown('get value') }; @@ -188,7 +186,6 @@ function populate_grades(value,text, $selectedItem) { } function populate_subjects(value,text, $selectedItem) { - let worksheetType = document.getElementById("worksheetType") ? $("#worksheetType").dropdown('get value') : 'paper'; let gradeData = { "grade": $(`#${worksheetType}-grade`).dropdown('get value') }; @@ -210,7 +207,6 @@ function populate_subjects(value,text, $selectedItem) { } function populate_chapters(value, text, $selectedItem) { - let worksheetType = document.getElementById("worksheetType") ? $("#worksheetType").dropdown('get value') : 'paper'; let formData = { "subject": $(`#${worksheetType}-subject`).dropdown('get value'), "board": $(`#${worksheetType}-board`).dropdown('get value') @@ -580,6 +576,15 @@ function populate_subjects(value,text, $selectedItem) { }, }); + var worksheetType; + if(window.location.pathname == "/student_view"){ + const urlParams = new URLSearchParams(window.location.search); + worksheetType = urlParams.get('type'); + if(['test','generic','customized'].includes(worksheetType)) + display_form_sections(worksheetType); + else window.location.href="/"; + } + $('#upload').click(upload_click); $("#submit").click(submit_click); $("#add-chapter-button").click(add_chapter); diff --git a/searchapp/static/student_view_style.css b/searchapp/static/student_view_style.css index 93a3783..e6c8d1c 100644 --- a/searchapp/static/student_view_style.css +++ b/searchapp/static/student_view_style.css @@ -2,8 +2,10 @@ margin-top:2%; margin-left:auto; margin-right:auto; - width:50%; - display:block; + text-align:center; + font-size: 17px; + color: black; + font-weight: 800; } #subject_splits { diff --git a/searchapp/templates/home.html b/searchapp/templates/home.html index ce661b0..03f890e 100644 --- a/searchapp/templates/home.html +++ b/searchapp/templates/home.html @@ -20,25 +20,25 @@