Skip to content

Instantly share code, notes, and snippets.

@lodi-g
Created January 7, 2018 16:48
Show Gist options
  • Save lodi-g/6df6e0ac08cf2d489364e30c24baec5f to your computer and use it in GitHub Desktop.
Save lodi-g/6df6e0ac08cf2d489364e30c24baec5f to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Show grades
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Show grades. Reload page if the button does not appear.
// @author You
// @match https://intra.epitech.eu/module/*/note/
// @grant none
// @run-at document-start
// ==/UserScript==
let options;
function getGrades(e) {
let grid_note = $('#grid-note');
var columns = {
login: {
label: t('Login'),
width: 250,
data: function() {
return {
login: this.login
};
},
resume: 'count',
mandatory: true
},
group_master: {
label: t('Role'),
width: 80,
display: false,
data: function() {
return {
login: this.login
};
}
},
member_status: {
label: t('Status du groupe'),
width: 80,
display: false
},
note: {
label: t('Note'),
width: 80,
render: 'float',
className: 'note',
resume: 'average'
},
status: {
label: t('Status'),
width: 80,
display: false
},
group_title: {
label: t('Group title'),
width: 150,
display: false,
type: 'text'
},
members: {
label: t('Group members'),
width: 200,
display: false
},
indiv_comment: {
label: t('Commentaire indiv.'),
width: 600,
display: false,
type: 'text'
},
indiv_star: {
label: t('Évaluation indiv.'),
width: 600,
display: false,
render: 'aze'
},
comment: {
label: t('Comment'),
width: 600,
display: false,
type: 'text'
}
};
e.preventDefault();
grid_note.datagrid({
className: 'notes',
emptyText: t('No notes'),
rowClassName: 'item ui-selectee',
detachhead: true,
storeKey: 'activite.notes',
contextmenu: function(e, rows) {
if (!rows.length) return;
if (!checkRights()) return;
launchApp('module.activite.note.contextmenu', {
target: e,
items: rows,
pathname: pathname,
remove: function(logins) {
grid_note.find('tr.item').filter(function() {
return $.inArray(this.obj, rows) != -1;
}).remove();
jQuery.infoNotice({
text: t('Suppression de:pluriel note:pluriel2 effectuée', {
pluriel: (logins.length > 1 ? 's' : ''),
pluriel2: (logins.length > 1 ? 's' : '')
})
});
button_apply.removeClass('disabled');
},
update: function(note, comment) {
for (var i = 0; i < rows.length; i++) {
rows[i].note = note;
if (comment) rows[i].comment = comment;
var item = jQuery.extend(rows[i], rows[i], {
className: "updated good"
});
grid_note.updateElement(item);
button_apply.removeClass('disabled');
}
grid_note.trigger("selected");
}
});
return false;
},
columns: columns,
items: window.options.items
});
}
function main() {
$('.item.buttons').append('<a class="button grades" href="#"><span><span class="icon"></span><span class="label">Grades</span></span></a>');
$('.item.buttons .grades').on('click', getGrades);
}
let launchAppUpdated = false;
setInterval(function() {
if (document.readyState === 'loading' && !launchAppUpdated) {
launchAppUpdated = true;
let oldLaunchApp = launchApp;
console.log('old', oldLaunchApp);
launchApp = function(path, options) {
if (path === 'module.activite.note') {
console.log('options', options.items);
window.options = options;
console.log('grades', options);
}
oldLaunchApp(path, options);
};
}
}, 10);
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment