Skip to content

Commit

Permalink
Clash try (#54)
Browse files Browse the repository at this point in the history
* remove clash by deselcting courses

* clash unselect

* Data added

* duplicate prof in json, bug

* clash

Co-authored-by: Shreya <[email protected]>
Co-authored-by: Shreya Singh <[email protected]>
  • Loading branch information
3 people authored May 26, 2020
1 parent 0f27651 commit 452d042
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 66 deletions.
12 changes: 10 additions & 2 deletions course_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
{
"Name" : "Core",
"Courses" : [
"CS101"
"CS101",
"CS304"
]
},
{
"Name" : "Data Science",
"Courses" : [
"DS101"
"DS101",
"DS601"
]
},
{
"Name" : "Networks",
"Courses" : [
"NC101"
]
},
{
"Name" : "HSS",
"Courses" :[
"HSS101"
]
}
]
9 changes: 7 additions & 2 deletions courses.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
{"Name": "DS101: Computer Vision",
"Data": {"Faculty": "DBJ", "Credits": "4", "Slot": "E4", "Room": "R204"}},
{"Name": "NC101: Advanced Computer Networks",
"Data": {"Faculty": "Debabrata Das", "Credits": "4", "Slot": "E4", "Room": "NC342"}}

"Data": {"Faculty": "Debabrata Das", "Credits": "4", "Slot": "F4", "Room": "NC342"}},
{"Name": "DS601: Data Modelling",
"Data": {"Faculty": "R Chandrashekhar", "Credits": "4", "Slot": "N2", "Room": "R103"}},
{"Name": "HSS101: Ethics",
"Data": {"Faculty": "Chetan Parikh", "Credits": "4", "Slot": "A1", "Room": "R108"}},
{"Name": "CS304: Automata Theory",
"Data": {"Faculty": "Shrisha Rao", "Credits": "4", "Slot": "S3", "Room": "R105"}}
]
2 changes: 1 addition & 1 deletion logstash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ filter {
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "whatslot2"
index => "iiitbtt"
}
stdout { codec => rubydebug }
}
9 changes: 5 additions & 4 deletions slots.1.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
A1 03 20 30 41
A2 00 01
A3 00 01 14
B2 10 11
Expand All @@ -10,10 +11,10 @@ D3 04 12 13
D4 04 12 13 30
E2 41 42
E3 24 33 41
E4 24 33 41 42
E4 04 33 41 42
F2 43 44
F3 22 31 43
F4 22 31 43 44
F4 24 33 41 42
G3 23 34 40
H2 17 18
H3 05 17 18
Expand All @@ -22,12 +23,12 @@ J 05 06 07
K 12 13 14
L 15 16 17
M 32 33 34
N 35 36 37
N2 30 12 41
O 42 43 44
P 45 46 47
Q 02 03 04
R 22 23 24
S3 08 38 48
S3 04 34 44
U2 06 07
U3 06 07 16
U4 06 07 15 16
Expand Down
5 changes: 5 additions & 0 deletions static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -788,3 +788,8 @@ select.form-control:focus::-ms-value {
margin-bottom: 1rem;
}

.hidden {
display: none!important;
visibility: hidden!important;
}

186 changes: 130 additions & 56 deletions static/mainScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ function getTimeTable(){
}
}
}
console.log(timetable)
return timetable
}

Expand All @@ -94,67 +93,132 @@ function addToCalendar(){

};

function sdCallback(data, id, course) {
console.log("yo")
if (typeof data['Name'] !== "undefined") {
if (id === undefined) {
var details = "";
var x = 0;
details += "<b>Name: </b>" + data['Name'] + " <br>";
courseData = data['Data'];
for (var key in courseData) {
if(key != 'Slot'){
console.log(key)
details += "<b>" + key + ": </b>" + courseData[key] + " <br>";
function sdCallback(data, id, course, clear_var) {
if(clear_var == 0){
if (typeof data['Name'] !== "undefined") {
if (id === undefined) {
var details = "";
var x = 0;
details += "<b>Name: </b>" + data['Name'] + " <br>";
courseData = data['Data'];
for (var key in courseData) {
if(key != 'Slot'){
details += "<b>" + key + ": </b>" + courseData[key] + " <br>";
}
}
}
var old_name = []
for (var slot in courseData['Slot']) {
$('#' + courseData['Slot'][slot]).addClass('border border-danger');
if($('#' + courseData['Slot'][slot]).hasClass('table-danger')){
$('#' + courseData['Slot'][slot]).removeClass('table-danger');
$('#' + courseData['Slot'][slot]).addClass('table-clash');
curr_name = $('#' + courseData['Slot'][slot]).html()
if(curr_name.length == 0)
curr_name = "your occupied slot";
if(old_name.includes(curr_name) == 0)
old_name.push(curr_name)
x = 1;
var old_name = []
for (var slot in courseData['Slot']) {
if($('#' + courseData['Slot'][slot]).hasClass('table-danger') || $('#' + courseData['Slot'][slot]).hasClass('table-clash')){
if($('#' + courseData['Slot'][slot]).hasClass('table-danger')){
$('#' + courseData['Slot'][slot]).removeClass('table-danger');
$('#' + courseData['Slot'][slot]).addClass('table-clash');
}
var temp_list = ($('#' + '9' + courseData['Slot'][slot]).html().split(":"));
var cnt = parseInt(temp_list[0]);
cnt = cnt + 1
temp_list[0] = cnt
temp_list.push(data['Name'].split(":")[0])
console.log(cnt)
$('#9' + courseData['Slot'][slot]).html(temp_list.join(":"))
curr_name = $('#' + courseData['Slot'][slot]).html()
if(curr_name.length == 0)
curr_name = "your occupied slot";
if(old_name.includes(curr_name) == 0)
old_name.push(curr_name)
x = 1;
}
}
if(x == 0){
$('#details-div').html("");
$('#details-div').html(details);
for (var slot in courseData['Slot']) {
$('#' + courseData['Slot'][slot]).addClass('border border-danger');
$('#' + courseData['Slot'][slot]).addClass('table-danger');
$('#' + courseData['Slot'][slot]).html(data['Name'].split(':')[0])
$('#' + '9' + courseData['Slot'][slot]).html("1" + ":" + data['Name'].split(':')[0])
}
}
else{
for (var slot in courseData['Slot']) {
if($('#' + courseData['Slot'][slot]).hasClass('table-danger') == 0 && $('#' + courseData['Slot'][slot]).hasClass('table-clash') == 0){
$('#' + courseData['Slot'][slot]).addClass('border border-danger');
$('#' + courseData['Slot'][slot]).addClass('table-danger');
$('#' + courseData['Slot'][slot]).html(data['Name'].split(':')[0])
$('#' + '9' + courseData['Slot'][slot]).html("1" + ":" + data['Name'].split(':')[0])
}
}
$('#details-div').html("");
details = "<b> Warning!! </b><br> Course " + data['Name'] + " clashes with "
var i = 0
for(i = 0; i < old_name.length; i++){
if(i > 0 && i < old_name.length - 1)
details += ", ";
else if(i >0 && i == old_name.length - 1)
details += "and ";
details += old_name[i]
}
details += ".<br>";
details += "Unselect one of the clashing courses to continue."
$('#details-div').html(details);
}
}
if(x == 0){
else {
$('#details-div').html("");
$('#details-div').html(details);
parentList = document.getElementById(id);
var item = document.createElement('li');
item.className = "course";
item.setAttribute("onclick", "searchData(this)");
item.innerHTML = course;
parentList.appendChild(item);
}
}
}
else{
if (typeof data['Name'] !== "undefined") {
if (id === undefined) {
var details = "";
courseData = data['Data'];
for (var slot in courseData['Slot']) {
$('#' + courseData['Slot'][slot]).addClass('border border-danger');
$('#' + courseData['Slot'][slot]).addClass('table-danger');
$('#' + courseData['Slot'][slot]).html(data['Name'].split(':')[0])
if($('#' + courseData['Slot'][slot]).hasClass('table-danger')){
if((data['Name'].split(':')[0].toString().localeCompare($('#' + courseData['Slot'][slot]).html().toString())) == 0) {
$('#' + courseData['Slot'][slot]).removeClass('table-danger');
$('#' + courseData['Slot'][slot]).removeClass('border border-danger');
$('#' + courseData['Slot'][slot]).html("")
$('#9' + courseData['Slot'][slot]).html(":")
}
}
else if($('#' + courseData['Slot'][slot]).hasClass('table-clash')){
var temp_list = ($('#' + '9' + courseData['Slot'][slot]).html().split(":"));
var cnt = parseInt(temp_list[0]);
cnt = cnt - 1;
console.log(cnt)
var index = temp_list.indexOf(data['Name'].split(":")[0])
console.log(temp_list)
if(index > 0){
temp_list.splice(index, 1)
}
console.log(temp_list)
temp_list[0] = cnt
if(cnt == 1){
$('#' + courseData['Slot'][slot]).removeClass('table-clash');
$('#' + courseData['Slot'][slot]).addClass('table-danger');
}
$('#' + courseData['Slot'][slot]).html(temp_list[1])
$('#9' + courseData['Slot'][slot]).html(temp_list.join(":"))
}
}
$('#details-div').html("");
}
else{
else {
$('#details-div').html("");
details = "<b> Warning!! </b><br> Course " + data['Name'] + " clashes with "
var i = 0
for(i = 0; i < old_name.length; i++){
if(i > 0 && i < old_name.length - 1)
details += ", ";
else if(i >0 && i == old_name.length - 1)
details += "and ";
details += old_name[i]
}
details += ".";
$('#details-div').html(details);
parentList = document.getElementById(id);
var item = document.createElement('li');
item.className = "course";
item.setAttribute("onclick", "searchData(this)");
item.innerHTML = course;
parentList.appendChild(item);
}
}
else {
$('#details-div').html("");
parentList = document.getElementById(id);
var item = document.createElement('li');
item.className = "course";
item.setAttribute("onclick", "searchData(this)");
item.innerHTML = course;
parentList.appendChild(item);
}
}
}

Expand All @@ -164,13 +228,17 @@ function clearSelected() {


function searchData(q = $("#search-bar").val(), id = undefined) {
clear_var = 0
if(typeof q.className !== "undefined" && q.className.length == 13){
return;
clear_var = 1;
}
var searchString = "";
if (typeof q !== "string") {
searchString = q.innerHTML; // Get list item's name
q.className += ' active';
if(clear_var == 0)
q.className += ' active';
else
q.className = 'course'
}
else {
searchString = q;
Expand All @@ -180,7 +248,7 @@ function searchData(q = $("#search-bar").val(), id = undefined) {
"query": searchString
},
function (data) {
sdCallback(data, id, searchString);
sdCallback(data, id, searchString, clear_var);
},
"json"
);
Expand Down Expand Up @@ -257,20 +325,26 @@ setTimeout(

function toggle(el) {
element = $(el);
element_id = element.attr('id')
if(element.hasClass('table-clash')){
return;
}
if (element.hasClass('table-danger')){
if(element.html().length == 0){
element.removeClass('table-danger');
element.removeClass('border-border-danger');
element.removeClass('border border-danger');
details = "You clearerd an occupied slot";
$('#details-div').html("");
$('#details-div').html(details);
$('#9' + element_id).html(":")
}
}
else{
element.addClass('table-danger');
details = "You marked a slot as occupied";
$('#details-div').html("");
$('#details-div').html(details);
$('#9' + element_id).html("1:")
}
}

Expand Down
Loading

0 comments on commit 452d042

Please sign in to comment.