Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/gpa/activateGPA.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ add_checkboxes = function(){
}

show_total_gpa = function(){

if (document.location.href !== "https://aims.iith.ac.in/aims/courseReg/myCrsHistoryPage") {
return null;
}

var courses = [];
$('#gpa_button').val('Calculating');
$('#gpa_bar').remove();
Expand Down
6 changes: 5 additions & 1 deletion src/popup/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@
</head>
<body>
<div class="heading"><p>aims helper<p></div>
<p class="status" style="display: none">You are not on the AIMS Page. </p> <!-- Replace with JS checker later. -->
<p class="status" id="error-message" style="display: none;">You are probably not on the appropriate AIMS page. Goto <a
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "probably". Add "please" before Goto.

href="https://aims.iith.ac.in/aims/courseReg/studentRegForm/44">Course Registration</a> for timetable and <a
href="https://aims.iith.ac.in/aims/courseReg/myCrsHistoryPage">View my courses</a> for GPA.
If you think this is a mistake, please reach us at <a href="mailto:lambda@iith.ac.in"> lambda@iith.ac.in</a>
</p>
<div class="gpa-container">
<span class="gpa-text"> GPA </span><span class="gpa-text">=</span> <span class="gpa-text gpa-value"></span>
</div>
Expand Down
38 changes: 32 additions & 6 deletions src/popup/popup.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@

var whichButton = 0 ; // 0 : no button has been clicked

// Show the error message div
function showError() {
document.getElementById("error-message").style.display = "block";
document.getElementsByClassName("button-container")[0].style.display = "none";
document.getElementById("loading-image").style.display = "none";
}


chrome.runtime.onMessage.addListener((request, sender) => {
if (request.action == "activateTimetable" && request.status == true)
{
onWindowLoad();
}
if (request.action == "activateTimetable" && request.status == true) {
onWindowLoad();
}
else {
showError();
}
});
chrome.runtime.onMessage.addListener(function(request, sender) {
if (request.action == "getSource") {
Expand Down Expand Up @@ -38,19 +49,29 @@ function onWindowLoad() {
function showLoading() {
document.getElementById("loading-image").style.display = "block";
document.getElementsByClassName("button-container")[0].style.display="none";
document.getElementById("error-message").style.display = "none"; // adding to avoid any risks!
}

function removeLoading() {
document.getElementById("loading-image").style.display = "none";
document.getElementsByClassName("button-container")[0].style.display = "block";
document.getElementById("error-message").style.display = "none"; // adding to avoid any risks!
}

function injectTimetable() {
showLoading();
chrome.tabs.executeScript(null, {
file: "/src/timetable/activateTimetable.js"
}, function() {
if (chrome.runtime.lastError) console.log(chrome.runtime.lastError.message);
}, function () {
if (chrome.runtime.lastError) {
switch (chrome.runtime.lastError.message) {
case "Cannot access a chrome:// URL":
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find error code in the chrome.runtime.lastError. Let me know if there is a better way to do this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine. However, I don't see the need for both an if and a switch here. Maybe you can do some refactoring?

showError();
break;
default:
console.log(chrome.runtime.lastError.message);
}
}
});
}

Expand All @@ -68,6 +89,11 @@ function injectGPA() {
}
chrome.runtime.onMessage.addListener(function(request, sender){
if(request.action == "parsedGPA"){

if (!request.data) {
return showError();
}

removeLoading();
var gpa_value = request.data.gpa;
document.getElementsByClassName("gpa-container")[0].style.display = "flex";
Expand Down
5 changes: 5 additions & 0 deletions src/timetable/activateTimetable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
function activate() {

if (!(document.location.href === "https://aims.iith.ac.in/aims/courseReg/studentRegForm/44")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This URL may very well change, so use a constant variable here.

return false
}

var timeTabIcons = document.getElementsByClassName("time_tab_icon");
for (var i = 0 ; i < timeTabIcons.length ; i++)
{
Expand Down