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
7 changes: 3 additions & 4 deletions MarmoUI-Chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"manifest_version": 2,
"manifest_version": 3,

"name": "MarmoUI",
"description": "Marmoset Improved! Better UI and functionality",
Expand All @@ -14,13 +14,12 @@
{
"matches": ["https://*.uwaterloo.ca/*"],
"include_globs": ["https://marmoset*"],
"js": ["scripts/script.js"]
"js": ["scripts/jquery.js", "scripts/script.js"]
}
],

"background": {
"persistent": false,
"scripts": ["scripts/notifications.js"]
"service_worker": "scripts/notifications.js"
},
"permissions": ["notifications"]
}
4 changes: 4 additions & 0 deletions MarmoUI-Chrome/scripts/jquery.js

Large diffs are not rendered by default.

49 changes: 32 additions & 17 deletions MarmoUI-Chrome/scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ var global_css = "body,h1,h2,h3{font-family:'Droid Sans',helvetica,arial,sans-se
function loadMarmoUI(run)
{
//Utility functions
/*
function getProtocol()
{
return "https:" == document.location.protocol ? "https" : "http";
}
*/

function appendToHead(element)
{
Expand Down Expand Up @@ -76,6 +78,7 @@ function loadMarmoUI(run)
}*/

//Load jQuery from Google CDN
/*
function loadJQuery(run)
{
//Don't load twice
Expand All @@ -100,10 +103,12 @@ function loadMarmoUI(run)
}, false);
appendToHead(script);
}
*/

//loadFonts(); - We'll use our embedded fonts for better speeds
loadCSS();
loadJQuery(run);
//loadJQuery(run); - jQuery is loaded by the manifest
run();
}

function runMarmoUI()
Expand Down Expand Up @@ -534,14 +539,18 @@ function runMarmoUI()
//Load the updater - This will only show if the updater loads and is of a different version
/*
$("head").append("<link href='" + update_location + "' type='text/css' rel='stylesheet'/>");
$("body").prepend("<div style='display:none;' class='notifier-update'>" +
"<a class='notifier-text' href='" + update_download + "' target='_blank'>Update available: <span class='notifier-text-inner'></span></a>" +
"<a class='notifier-close' href='#' onclick='$(\".notifier-update\").fadeOut().queue(function(){$(this).remove();}); return false;'>x</a></div>");
$("body").prepend($("<div style='display:none;' class='notifier-update'>").append(
"<a class='notifier-text' href='" + update_download + "' target='_blank'>Update available: <span class='notifier-text-inner'></span></a>",
$("<a class='notifier-close' href='#'>x</a>").on("click", function(e) {
e.preventDefault();
$(".notifier-update").fadeOut().queue(function(){$(this).remove();});
})
));
$("body").addClass(current_version);
*/

//Google analytics helps for statistics
$("body").append("<script type='text/javascript'>var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-38018139-1']); _gaq.push(['_trackPageview']);(function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();</script>");
//$("body").append("<script type='text/javascript'>var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-38018139-1']); _gaq.push(['_trackPageview']);(function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();</script>");
}

function applyChangesProblemsList()
Expand Down Expand Up @@ -720,16 +729,16 @@ function runMarmoUI()
//Reset popup html
var popup = $(".submission-popup").html("");
//Add Close, Project, Submissions and Deadline
popup.append("<a id='submission-close' href='#' onclick='$(\"#submission-box\").hide();return false;'>Close</a>");
popup.append($("<a id='submission-close' href='#'>Close</a>").on("click", function(e) { e.preventDefault(); $("#submission-box").hide(); }));
popup.append("<h2>Project: " + row.find("td:eq(0)").html() + " (" + row.find("td:eq(6)").html() + ")</h2>");
popup.append("<p>Submissions: <a href='" + row.find("td:eq(1) a").attr("href") + "'>view</a></p>");
popup.append("<p>Due: " + row.find("td:eq(5)").html() + "</p>");
//Add the submission form
popup.append("<form target='sumbission-loader' enctype='multipart/form-data' action='/action/SubmitProjectViaWeb' method='POST'>" +
"<input type='hidden' name='projectPK' value='" + projectPK + "'>" +
"<input type='hidden' name='submitClientTool' value='web'>" +
"<input type='file' name='file' size='20'></form>" +
"<div class='submit-button'><p><a onclick='$(\"form\").submit();'>Submit</a></p></div>");
"<input type='file' name='file' size='20'></form>");
popup.append($("<div class='submit-button'><p><a>Submit</a></p></div>").find("a").on("click", function() { $("form").submit(); }).end());

//Fix the anchor having an extra space at the end
trimInner($("h2 a"));
Expand Down Expand Up @@ -824,14 +833,14 @@ function runMarmoUI()
//Reset popup html
var popup = $(".submission-popup").html("");
//Add Close, Project, Submissions and Deadline
popup.append("<a id='submission-close' href='#' onclick='$(\"#submission-box\").hide();return false;'>Close</a>");
popup.append($("<a id='submission-close' href='#'>Close</a>").on("click", function (e) { e.preventDefault(); $("#submission-box").hide(); }));
popup.append("<p>Due: " + $("p:contains('Deadline')").html().replace("<b>Deadline:</b>", "").trim() + "</p>");
//Add the submission form
popup.append("<form target='sumbission-loader' enctype='multipart/form-data' action='/action/SubmitProjectViaWeb' method='POST'>" +
"<input type='hidden' name='projectPK' value='" + projectPK + "'>" +
"<input type='hidden' name='submitClientTool' value='web'>" +
"<input type='file' name='file' size='20'></form>" +
"<div class='submit-button'><p><a onclick='$(\"form\").submit();'>Submit</a></p></div>");
"<input type='file' name='file' size='20'></form>");
popup.append($("<div class='submit-button'><p><a>Submit</a></p></div>").find("a").on("click", function() { $("form").submit(); }).end());
//Show the popup box
$("#submission-box").show();
});
Expand Down Expand Up @@ -881,11 +890,17 @@ function runMarmoUI()
var submissionPK = releaseTestElement.find("a").attr("href").match("submissionPK=([0-9]+)")[1];
releaseTestElement.replaceWith(
// <input type='submit' value='OK'>
"<form method='POST' action='/action/RequestReleaseTest'><div class='submit-button' style='width:10em'><p>" +
$("<form method='POST' action='/action/RequestReleaseTest'><div class='submit-button' style='width:10em'><p>" +
"<input type='hidden' name='submissionPK' value='" + submissionPK + "'>" +
"<a href='" + link + "' onclick='if(confirm(\"Are you sure you want to release test this?\")){$(\"form\").submit();} return false;'>" +
"<a href='" + link + "'>" +
"Release Test" +
"</a></p><div></form>");
"</a></p><div></form>").find("a").on("click", function(e) {
e.preventDefault();

if (confirm("Are you sure you want to release test this?")) {
$("form").submit();
}
}).end());
}
//Release tokens
$("ul").eq(0).addClass("release-tokens");
Expand Down Expand Up @@ -929,7 +944,7 @@ function runMarmoUI()
//Remove Logout button
$("div.logout").remove();
//Chang submit button
$("input[type='submit']").attr("value", "Use this account").attr("onclick", "$(this).attr('value', 'as')");
$("input[type='submit']").attr("value", "Use this account").on("click", function() { $(this).attr('value', 'as') });
$("p:contains('please login as')").remove();
break;
case PAGE.COURSE_LIST.value:
Expand Down Expand Up @@ -964,7 +979,7 @@ function runMarmoUI()
break;
case PAGE.ERROR.value:
//Change navigation for a go back button
$(".nav").html("<a href='#' onclick='history.back(); return false;'>Go back</a>");
$(".nav").empty().append($("<a href='#'>Go back").on("click", function(e) { e.preventDefault(); history.back(); }));
//Remove the ugly image
$("p img").remove();
//Add something more constructive inside the title
Expand Down Expand Up @@ -998,7 +1013,7 @@ window.addEventListener("message", function(event) {
var toSend = {type: "notification",
notification: {
type: "basic",
iconUrl: chrome.extension.getURL("image/icon128.png"),
iconUrl: chrome.runtime.getURL("image/icon128.png"),
title: event.data.test + " Testing Complete",
message: (event.data.result ? "Result: " + event.data.result : "")
},
Expand Down
38 changes: 24 additions & 14 deletions marmo-ui.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,13 @@ function runMarmoUI()

//Load the updater - This will only show if the updater loads and is of a different version
$("head").append("<link href='" + update_location + "' type='text/css' rel='stylesheet'/>");
$("body").prepend("<div style='display:none;' class='notifier-update'>" +
"<a class='notifier-text' href='" + update_download + "' target='_blank'>Update available: <span class='notifier-text-inner'></span></a>" +
"<a class='notifier-close' href='#' onclick='$(\".notifier-update\").fadeOut().queue(function(){$(this).remove();}); return false;'>x</a></div>");
$("body").prepend($("<div style='display:none;' class='notifier-update'>").append(
"<a class='notifier-text' href='" + update_download + "' target='_blank'>Update available: <span class='notifier-text-inner'></span></a>",
$("<a class='notifier-close' href='#'>x</a>").on("click", function(e) {
e.preventDefault();
$(".notifier-update").fadeOut().queue(function(){$(this).remove();});
})
));
$("body").addClass(current_version);

//Google analytics helps for statistics
Expand Down Expand Up @@ -700,16 +704,16 @@ function runMarmoUI()
//Reset popup html
var popup = $(".submission-popup").html("");
//Add Close, Project, Submissions and Deadline
popup.append("<a id='submission-close' href='#' onclick='$(\"#submission-box\").hide();return false;'>Close</a>");
popup.append($("<a id='submission-close' href='#'>Close</a>").on('click', function(e) { e.preventDefault(); $("#submission-box").hide(); }));
popup.append("<h2>Project: " + row.find("td:eq(0)").html() + " (" + row.find("td:eq(6)").html() + ")</h2>");
popup.append("<p>Submissions: <a href='" + row.find("td:eq(1) a").attr("href") + "'>view</a></p>");
popup.append("<p>Due: " + row.find("td:eq(5)").html() + "</p>");
//Add the submission form
popup.append("<form target='sumbission-loader' enctype='multipart/form-data' action='/action/SubmitProjectViaWeb' method='POST'>" +
"<input type='hidden' name='projectPK' value='" + projectPK + "'>" +
"<input type='hidden' name='submitClientTool' value='web'>" +
"<input type='file' name='file' size='20'></form>" +
"<div class='submit-button'><p><a onclick='$(\"form\").submit();'>Submit</a></p></div>");
"<input type='file' name='file' size='20'></form>");
popup.append($("<div class='submit-button'><p><a>Submit</a></p></div>").find("a").on("click", function() { $("form").submit(); }).end());

//Fix the anchor having an extra space at the end
trimInner($("h2 a"));
Expand Down Expand Up @@ -801,14 +805,14 @@ function runMarmoUI()
//Reset popup html
var popup = $(".submission-popup").html("");
//Add Close, Project, Submissions and Deadline
popup.append("<a id='submission-close' href='#' onclick='$(\"#submission-box\").hide();return false;'>Close</a>");
popup.append($("<a id='submission-close' href='#'>Close</a>").on("click", function (e) { e.preventDefault(); $("#submission-box").hide(); }));
popup.append("<p>Due: " + $("p:contains('Deadline')").html().replace("<b>Deadline:</b>", "").trim() + "</p>");
//Add the submission form
popup.append("<form target='sumbission-loader' enctype='multipart/form-data' action='/action/SubmitProjectViaWeb' method='POST'>" +
"<input type='hidden' name='projectPK' value='" + projectPK + "'>" +
"<input type='hidden' name='submitClientTool' value='web'>" +
"<input type='file' name='file' size='20'></form>" +
"<div class='submit-button'><p><a onclick='$(\"form\").submit();'>Submit</a></p></div>");
"<input type='file' name='file' size='20'></form>");
popup.append($("<div class='submit-button'><p><a>Submit</a></p></div>").find("a").on('click', function() { $("form").submit(); }).end());
//Show the popup box
$("#submission-box").show();
});
Expand Down Expand Up @@ -858,11 +862,17 @@ function runMarmoUI()
var submissionPK = releaseTestElement.find("a").attr("href").match("submissionPK=([0-9]+)")[1];
releaseTestElement.replaceWith(
// <input type='submit' value='OK'>
"<form method='POST' action='/action/RequestReleaseTest'><div class='submit-button' style='width:10em'><p>" +
$("<form method='POST' action='/action/RequestReleaseTest'><div class='submit-button' style='width:10em'><p>" +
"<input type='hidden' name='submissionPK' value='" + submissionPK + "'>" +
"<a href='" + link + "' onclick='if(confirm(\"Are you sure you want to release test this?\")){$(\"form\").submit();} return false;'>" +
"<a href='" + link + "'>" +
"Release Test" +
"</a></p><div></form>");
"</a></p><div></form>").find("a").on("click", function(e) {
e.preventDefault();

if (confirm("Are you sure you want to release test this?")) {
$("form").submit();
}
}).end());
}
//Release tokens
$("ul").eq(0).addClass("release-tokens");
Expand Down Expand Up @@ -901,7 +911,7 @@ function runMarmoUI()
//Remove Logout button
$("div.logout").remove();
//Chang submit button
$("input[type='submit']").attr("value", "Use this account").attr("onclick", "$(this).attr('value', 'as')");
$("input[type='submit']").attr("value", "Use this account").on("click", function() { $(this).attr('value', 'as') });
$("p:contains('please login as')").remove();
break;
case PAGE.COURSE_LIST.value:
Expand Down Expand Up @@ -936,7 +946,7 @@ function runMarmoUI()
break;
case PAGE.ERROR.value:
//Change navigation for a go back button
$(".nav").html("<a href='#' onclick='history.back(); return false;'>Go back</a>");
$(".nav").empty().append($("<a href='#'>Go back").on("click", function(e) { e.preventDefault(); history.back(); }));
//Remove the ugly image
$("p img").remove();
//Add something more constructive inside the title
Expand Down