Commit 5b812426 authored by Peter Walter's avatar Peter Walter
Browse files

version 1.9

parent 3145ac5c
......@@ -2,15 +2,23 @@
// @name RT Helpers
// @namespace https://rt.ebi.ac.uk/
// @description Add some shortcut links to RT
// @match https://rt.ebi.ac.uk/*
// @match https://*.ebi.ac.uk/*
// @include https://rt.ebi.ac.uk/extserv/*
// @version 1.8
// @updateURL http://www.ebi.ac.uk/~pwalter/rthelper/rthelper.user.js
// @include https://helpdesk.ebi.ac.uk/*
// @grant GM_xmlhttpRequest
// @version 1.9a
// @updateURL http://www.ebi.ac.uk/~pwalter/rthelper/rthelper-dev.user.js
// @run-at document-end
// ==/UserScript==
var info = {};
info['version'] = '1.8';
info['version'] = '1.9a';
if (document.location.pathname.indexOf('extserv') !== -1) {
info['root'] = '/extserv';
} else {
info['root'] = '';
}
/*jshint scripturl:true, strict:false, jquery:true */
......@@ -131,7 +139,7 @@ function getElementText(selector, type) {
* @return String, eg "19200"
*/
function getUserId() {
if (document.location.pathname === '/extserv/Ticket/Display.html' && getValue('userId', '') === '') {
if (document.location.pathname === info['root'] + '/Ticket/Display.html' && getValue('userId', '') === '') {
setValue('userId', document.querySelector('select#NewReminder-Owner').value);
}
return getValue('userId', '');
......@@ -151,7 +159,7 @@ function getTicketId() {
* @return String, eg "Peter" or "Peter Walter"
*/
function getName(full) {
if (document.location.pathname === '/extserv/Ticket/Display.html' && getValue('name', '') === '') {
if (document.location.pathname === info['root'] + '/Ticket/Display.html' && getValue('name', '') === '') {
var name=getElementText('select#NewReminder-Owner option[selected=selected]');
if (name.indexOf('(') !== -1) {
name=/\((.*)\)/gi.exec(name)[1];
......@@ -442,7 +450,7 @@ function init() {
// apply login and password to login box
(function autoLogin() {
if (!document.querySelector('form#login') || document.querySelector('ul.action-results li') || document.referrer.indexOf('/extserv/NoAuth/Logout.html') !== -1) {
if (!document.querySelector('form#login') || document.querySelector('ul.action-results li') || document.referrer.indexOf(info['root'] + '/NoAuth/Logout.html') !== -1) {
return;
};
......@@ -461,15 +469,15 @@ function init() {
return;
}
if (getValue('showOwners', '') === '' || getValue('showQueues', '') === '' || getValue('showStatuses', '') === '') {
if (document.location.pathname !== '/extserv/rthelper') {
document.location.href = '/extserv/rthelper';
if (document.location.pathname !== info['root'] + '/rthelper') {
document.location.href = info['root'] + '/rthelper';
}
}
})();
// add some links to queue
(function queueSwitch() {
if (document.location.pathname !== '/extserv/Ticket/Display.html') {
if (document.location.pathname !== info['root'] + '/Ticket/Display.html') {
return;
}
......@@ -501,7 +509,7 @@ function init() {
// add some links to status
(function statusSwitch() {
if (document.location.pathname !== '/extserv/Ticket/Display.html') {
if (document.location.pathname !== info['root'] + '/Ticket/Display.html') {
return;
}
......@@ -533,7 +541,7 @@ function init() {
// add some links to owner
(function ownerSwitch() {
if (document.location.pathname !== '/extserv/Ticket/Display.html') {
if (document.location.pathname !== info['root'] + '/Ticket/Display.html') {
return;
}
......@@ -565,7 +573,7 @@ function init() {
// add some links to project
(function customFieldSwitch() {
if (document.location.pathname !== '/extserv/Ticket/Display.html') {
if (document.location.pathname !== info['root'] + '/Ticket/Display.html') {
return;
}
......@@ -623,7 +631,7 @@ function init() {
// add quick link to add cc
(function addCcLink() {
if (document.location.pathname !== '/extserv/Ticket/Display.html') {
if (document.location.pathname !== info['root'] + '/Ticket/Display.html') {
return;
}
......@@ -653,7 +661,7 @@ function init() {
})();
(function addCcInput() {
if (document.location.pathname !== '/extserv/Ticket/Display.html') {
if (document.location.pathname !== info['root'] + '/Ticket/Display.html') {
return;
}
......@@ -708,7 +716,7 @@ function init() {
// add quick link to reply
(function quickreplyLink() {
if (document.location.pathname !== '/extserv/Ticket/Display.html') {
if (document.location.pathname !== info['root'] + '/Ticket/Display.html') {
return;
}
......@@ -760,7 +768,7 @@ function init() {
// add quick link to SPAM
(function spamLink() {
if (document.location.pathname !== '/extserv/Ticket/Display.html') {
if (document.location.pathname !== info['root'] + '/Ticket/Display.html') {
return;
}
......@@ -840,7 +848,7 @@ function init() {
}
// get fresh set of quicksearches every time we visit homepage
if (document.location.pathname === '/extserv/' && document.querySelector('table.myrt')) {
if (document.location.pathname === info['root'] + '/' && document.querySelector('table.myrt')) {
var links = document.querySelectorAll('.titlebox .left a');
var quickSearch = '';
......@@ -899,7 +907,7 @@ function init() {
})();
(function adminPage() {
if (document.location.pathname !== '/extserv/rthelper') {
if (document.location.pathname !== info['root'] + '/rthelper') {
return;
}
......@@ -959,7 +967,7 @@ function init() {
// create option form
var form = document.createElement('form');
form.action = '/extserv/rthelper';
form.action = info['root'] + '/rthelper';
form.method = 'put';
document.getElementById('body').appendChild(form);
// store the form results
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment