mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-29 13:27:56 +02:00
Adding the ability to launch a search from with a URL
You can now pass a parameter to the dashboard which will immediately pop the search box and start searching for the results. This should be what #1345 and #1577 wants, or at least a basic version of it.
This commit is contained in:
@@ -28,9 +28,19 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
bindUIButtons();
|
bindUIButtons();
|
||||||
loadJackettSettings();
|
loadJackettSettings();
|
||||||
|
openSearchIfNecessary();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function openSearchIfNecessary() {
|
||||||
|
var parser = document.createElement('a');
|
||||||
|
parser.href = window.location.href;
|
||||||
|
|
||||||
|
if (parser.hash.startsWith("#search")) {
|
||||||
|
var query = parser.hash.split('=')[1];
|
||||||
|
showSearch(null, query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function insertWordWrap(str) {
|
function insertWordWrap(str) {
|
||||||
// insert optional word wrap after punctuation to avoid overflows on long scene titles
|
// insert optional word wrap after punctuation to avoid overflows on long scene titles
|
||||||
return str.replace(/([\.\-_\/\\])/g, "$1\u200B");
|
return str.replace(/([\.\-_\/\\])/g, "$1\u200B");
|
||||||
@@ -678,7 +688,7 @@ function updateReleasesRow(row)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSearch(selectedIndexer) {
|
function showSearch(selectedIndexer, query) {
|
||||||
$('#select-indexer-modal').remove();
|
$('#select-indexer-modal').remove();
|
||||||
var releaseTemplate = Handlebars.compile($("#jackett-search").html());
|
var releaseTemplate = Handlebars.compile($("#jackett-search").html());
|
||||||
var releaseDialog = $(releaseTemplate({
|
var releaseDialog = $(releaseTemplate({
|
||||||
@@ -719,15 +729,16 @@ function showSearch(selectedIndexer) {
|
|||||||
setCategories(trackerId, this.items);
|
setCategories(trackerId, this.items);
|
||||||
}, { items: configuredIndexers }));
|
}, { items: configuredIndexers }));
|
||||||
|
|
||||||
document.getElementById("searchquery")
|
var queryField = document.getElementById("searchquery");
|
||||||
.addEventListener("keyup", function (event) {
|
queryField.addEventListener("keyup", function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (event.keyCode == 13) {
|
if (event.keyCode == 13) {
|
||||||
document.getElementById("jackett-search-perform").click();
|
document.getElementById("jackett-search-perform").click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#jackett-search-perform').click(function () {
|
var searchButton = $('#jackett-search-perform');
|
||||||
|
searchButton.click(function () {
|
||||||
if ($('#jackett-search-perform span').hasClass("spinner")) {
|
if ($('#jackett-search-perform span').hasClass("spinner")) {
|
||||||
// We are searchin already
|
// We are searchin already
|
||||||
return;
|
return;
|
||||||
@@ -767,6 +778,11 @@ function showSearch(selectedIndexer) {
|
|||||||
updateSearchResultTable($('#searchResults'), []);
|
updateSearchResultTable($('#searchResults'), []);
|
||||||
clearSearchResultTable($('#searchResults'));
|
clearSearchResultTable($('#searchResults'));
|
||||||
releaseDialog.modal("show");
|
releaseDialog.modal("show");
|
||||||
|
|
||||||
|
if (query !== undefined) {
|
||||||
|
queryField.value = decodeURIComponent(query);
|
||||||
|
searchButton.click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearSearchResultTable(element) {
|
function clearSearchResultTable(element) {
|
||||||
|
Reference in New Issue
Block a user