Skip to content

Better search and ticket numbers #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
47 changes: 46 additions & 1 deletion tdx-enhanced.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name tdx-enhanced
// @namespace ecn
// @version 2025-02-05-01
// @version 2025-04-21-01
// @description enhanced tdx coloring & formatting. follows system color scheme.
// @author Purdue STEM IT - it@purdue.edu
// @match https://service.purdue.edu/TDNext/*
Expand Down Expand Up @@ -79,6 +79,40 @@

/* BEGIN FUNCTIONS */

function left_append_ticket_number() {
try {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const ticketID = urlParams.get('TicketID') || "";
let title = document.querySelector("title");
title.innerText = ticketID + ' ' + title.innerText;
} catch (error) {
console.warn(error);
}
}

function betterSearch() {
var searchText = document.querySelector('#txtItemIDLookup').value.trim();
var isInteger = /^\d*$/.test(searchText);
if (isInteger && searchText.length > 0) {
window.open('/TDNext/Apps/Search/LookupItem?searchText=' + encodeURIComponent(searchText), '_blank');
} else if (false === false){
TeamDynamix.osjs.openApp('appSearch', 'Search', '/TDNext/Apps/Shared/Global/Search?searchText=' + encodeURIComponent(searchText));
$('#txtItemIDLookup').val('')
}
}

function search() {
var searchText = $('#txtItemIDLookup').val().trim();
var isInteger = /^\d*$/.test(searchText);
if (isInteger && searchText.length > 0) {
openWin('/TDNext/Apps/Search/LookupItem?searchText=' + encodeURIComponent($('#txtItemIDLookup').val()), 992, 700, '_blank');
} else if (false === false){
TeamDynamix.osjs.openApp('appSearch', 'Search', '/TDNext/Apps/Shared/Global/Search?searchText=' + encodeURIComponent(searchText));
$('#txtItemIDLookup').val('')
}
}

function updateHeading(mutation,numItems,totalItems) {
let headings = mutation.querySelectorAll(".panel-title")

Expand Down Expand Up @@ -266,6 +300,7 @@
if (header) {
let ticketTitle = header.childNodes[0].textContent
document.title = ticketTitle
left_append_ticket_number()
} else {
return
}
Expand Down Expand Up @@ -817,6 +852,16 @@
injectOtherStyles(frame)
});
}

let searchButton = document.getElementById("btnSearch");
if (searchButton) {
let behavior = settings('get','linkBehavior')
if (behavior==="tabs") {
searchButton.onclick = betterSearch;
} else {
searchButton.onclick = search;
}
}
});
});

Expand Down