Commit 3145ac5c authored by Peter Walter's avatar Peter Walter
Browse files

version 1.8

parent 5faa4108
......@@ -4,13 +4,13 @@
// @description Add some shortcut links to RT
// @match https://rt.ebi.ac.uk/*
// @include https://rt.ebi.ac.uk/extserv/*
// @version 1.7
// @version 1.8
// @updateURL http://www.ebi.ac.uk/~pwalter/rthelper/rthelper.user.js
// @run-at document-end
// ==/UserScript==
var info = {};
info['version'] = '1.7';
info['version'] = '1.8';
/*jshint scripturl:true, strict:false, jquery:true */
......@@ -128,7 +128,7 @@ function getElementText(selector, type) {
/**
* Get id of current user
* @return String
* @return String, eg "19200"
*/
function getUserId() {
if (document.location.pathname === '/extserv/Ticket/Display.html' && getValue('userId', '') === '') {
......@@ -139,27 +139,31 @@ function getUserId() {
/**
* Get id for current ticket
* @return String
* @return String, eg "17774"
*/
function getTicketId() {
return getElementText('div.ticket-info-basics tr.id td.value').split('\n',1)[0];
}
/**
* Get first name of current user
* Get name of current user
* @param Bool full - true to return fullname, default false to return firstname
* @return String
* @return String, eg "Peter" or "Peter Walter"
*/
function getName(full) {
if (document.location.pathname === '/extserv/Ticket/Display.html' && getValue('name', '') === '') {
setValue('name', getElementText('select#NewReminder-Owner option[selected=selected]'));
var name=getElementText('select#NewReminder-Owner option[selected=selected]');
if (name.indexOf('(') !== -1) {
name=/\((.*)\)/gi.exec(name)[1];
}
setValue('name', name);
}
return full ? getValue('name', '') : getValue('name', '').split(' ',1)[0];
}
/**
* Get queue for current ticket
* @return String
* @return String, eg "Web Development"
*/
function getQueue() {
return getElementText('div.ticket-info-basics tr.queue td.value').split('\n')[0];
......@@ -167,10 +171,14 @@ function getQueue() {
/**
* Get owner for current ticket
* @return String
* @return String, eg
*/
function getOwner() {
return getElementText('div.ticket-info-people tr td.value').split('\n')[0];
var owner=getElementText('div.ticket-info-people tr td.value', 'text').split('\n')[0];
if (owner.indexOf('(') !== -1) {
owner=/\((.*)\)/gi.exec(owner)[1];
}
return owner;
}
/**
......@@ -183,7 +191,7 @@ function getCustomField(id) {
/**
* Get status for current ticket
* @return String
* @return String, eg "Open", "Resolved"
*/
function getStatus() {
return getElementText('div.ticket-info-basics tr.status td.value').split('\n',1)[0];
......@@ -609,7 +617,7 @@ function init() {
var hides = document.querySelectorAll('.hide-first-line');
for (var i=0; i<hides.length; i++) {
hides[i].innerHTML = hides[i].innerHTML.replace(/^.*\s*<br>\s*<a/, '<a');
// hides[i].innerHTML = hides[i].innerHTML.replace(/^.*\s*<br>\s*<a/, '<a');
}
})();
......@@ -924,7 +932,12 @@ function init() {
var owners = {}, statuses = {}, queues = {};
for (var ownerOption in ownerOptions) {
if (ownerOptions[ownerOption].value && ownerOptions[ownerOption].text) {
owners[ownerOptions[ownerOption].text] = ownerOptions[ownerOption].value;
if (ownerOptions[ownerOption].text.indexOf('(') !== -1 && ownerOptions[ownerOption].text.indexOf(')') !== -1) {
owners[/\((.*)\)/gi.exec(ownerOptions[ownerOption].text)[1]] = ownerOptions[ownerOption].value;
}
else {
owners[ownerOptions[ownerOption].text] = ownerOptions[ownerOption].value;
}
}
}
for (var statusOption in statusOptions) {
......
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