Skip to content
Snippets Groups Projects
Commit 6e0b5c8f authored by TheJoeCoder's avatar TheJoeCoder
Browse files

Allow working with other pages.

parent 204effbb
Branches
No related tags found
No related merge requests found
// ==UserScript==
// @name Bromcom VLE Tools
// @namespace http://radialbog9.uk/
// @version 2024-04-23
// @version 2024-04-23_02
// @description Bromcom VLE dashboard widget
// @author Radialbog9
// @match https://vle.bromcomcloud.com/Home/Dashboard
// @match https://vle.bromcomcloud.com/*
// @downloadURL https://git.rb9.xyz/TheJoeCoder/bromcom-vle-to-ics/-/raw/main/bvletools.user.js
// @updateURL https://git.rb9.xyz/TheJoeCoder/bromcom-vle-to-ics/-/raw/main/bvletools.user.js
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
......@@ -35,6 +35,80 @@
</div>
*/
// Behaviour page script modifications
if (window.location.href.endsWith("/Behaviour")) {
// copied from https://vle.bromcomcloud.com/lib/pages/js/behaviour.js
var toCamelCase = (str) => {
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
return index == 0 ? word.toLowerCase() : word.toUpperCase();
}).replace(/\s+/g, '');
}
// copied from https://vle.bromcomcloud.com/lib/pages/js/behaviour.js
var loadBehaviourTable = () => {
$(".wait").show();
$.ajax({
url: "/Behaviour/StudentBehaviour",
type: "Post",
data: null,
contentType: false,
processData: false,
cache: false,
success: function (data) {
console.log(data);
$(".wait").hide();
var content = "";
var headerContent = "";
if (data.behaviourStudentEventHeader.length > 0) {
headerContent += "<tr>"
for (var i = 0; i < data.behaviourStudentEventHeader.length; i++) {
headerContent += "<th>" + data.behaviourStudentEventHeader[i].displayName.replace(/([A-Z])/g, ' $1').trim() + "</th>"
}
headerContent += "</tr>"
}
if (data.studentEvents.length > 0) {
for (var i = 0; i < data.studentEvents.length; i++) {
content += "<tr>"
for (var j = 0; j < data.behaviourStudentEventHeader.length; j++) {
content += '<td>' +
data.studentEvents[i][toCamelCase(data.behaviourStudentEventHeader[j].fieldName = data.behaviourStudentEventHeader[j].fieldName == "" ? data.behaviourStudentEventHeader[j].displayName : data.behaviourStudentEventHeader[j].fieldName)] + '</td>';
}
content += "</tr>"
}
}
$('#Behaviour thead').empty();
$('#Behaviour tbody').empty();
$('#Behaviour thead').html(headerContent);
$('#Behaviour tbody').html(content);
$.fn.dataTable.moment('DD/MM/YYYY HH:mm');
$('#Behaviour').DataTable({
"bPaginate": false,
columnDefs: [{
target: [0],
type: 'datetime-moment'
}],
"order": [[0,'desc']],
"fnDrawCallback": function () {
$('th').each(function () {
if (($(this).hasClass('sorting')) || ($(this).hasClass('sorting_desc'))) {
$(this).attr({ title: 'Sort Ascending' });
} else {
$(this).attr({ title: 'Sort Descending' });
}
});
}
});
},
error: function (msg) {
$(".wait").hide();
}
});
}
}
(function() {
'use strict';
function formatDate(date) {
......@@ -63,11 +137,14 @@
function timetableToClipboardProcess(data) {
var data_str = JSON.stringify(data);
console.log(data_str);
console.log("[RB9] " + data_str);
navigator.clipboard.writeText(data_str);
alert("Copied to Clipboard.\n Number of lessons " + data["table"].length);
}
if (window.location.href.endsWith("/Home/Dashboard")) {
console.log("[RB9] Page is Dashboard, injecting widget!");
$("#widgetsDahsboard .grid-stack")
.append("\n<div class=\"grid-stack-item ui-draggable ui-resizable ui-resizable-autohide ui-resizable-disabled\" id=\"gs_RB9Buttons\" data-color=\"danger\" data-gs-id=\"gs_RB9Buttons\" data-gs-x=\"8\" data-gs-y=\"2\" data-gs-width=\"4\" data-gs-height=\"2\" data-gs-no-resize=\"yes\">\n <div class=\"panel panel-danger shadow grid-stack-item-content ui-draggable-handle\">\n <div class=\"panel-heading\">\n <table>\n <tbody>\n <tr class=\"tableheader\">\n <td><i style=\"font-size:35px; padding-right:5px; padding-left:5px\" class=\"fa fa fa-wrench \"><\/i><\/td>\n <td>\n <h3 class=\"panel-title\">Toolkit<\/h3><h5 class=\"panelSubTitle\">Utilities Toolkit<\/h5>\n <\/td>\n <\/tr>\n <tr><\/tr>\n <\/tbody>\n <\/table>\n <\/div>\n <div id=\"content_RB9Buttons\" style=\"display:block; width: 100%;padding:0px;\" class=\"ifNoDataInWidget\">\n<\/div>\n <\/div><div class=\"ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se\" style=\"z-index: 90; display: none;\"><\/div>\n <\/div>");
......@@ -108,4 +185,5 @@
timetableToClipboardProcess(data);
});
});
}
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment