Changeset View
Changeset View
Standalone View
Standalone View
swh/web/assets/src/bundles/browse/origin-search.js
/** | /** | ||||
* Copyright (C) 2018-2019 The Software Heritage developers | * Copyright (C) 2018-2019 The Software Heritage developers | ||||
ardumont: update headers to 2018-2020 now | |||||
* See the AUTHORS file at the top-level directory of this distribution | * See the AUTHORS file at the top-level directory of this distribution | ||||
* License: GNU Affero General Public License version 3, or any later version | * License: GNU Affero General Public License version 3, or any later version | ||||
* See top-level LICENSE file for more information | * See top-level LICENSE file for more information | ||||
*/ | */ | ||||
import {handleFetchError} from 'utils/functions'; | import { handleFetchError } from 'utils/functions'; | ||||
anlambertUnsubmitted Done Inline Actionsplease remove the leading and trailing space anlambert: please remove the leading and trailing space | |||||
const limit = 100; | const limit = 100; | ||||
let linksPrev = []; | let linksPrev = []; | ||||
let linkNext = null; | let linkNext = null; | ||||
let linkCurrent = null; | let linkCurrent = null; | ||||
let inSearch = false; | let inSearch = false; | ||||
function parseLinkHeader(s) { | function parseLinkHeader(s) { | ||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | $('#swh-search-origins').submit(event => { | ||||
queryParameters += '&with_visit'; | queryParameters += '&with_visit'; | ||||
} | } | ||||
if (withContent) { | if (withContent) { | ||||
queryParameters += '&with_content'; | queryParameters += '&with_content'; | ||||
} | } | ||||
if (searchMetadata) { | if (searchMetadata) { | ||||
queryParameters += '&search_metadata'; | queryParameters += '&search_metadata'; | ||||
} | } | ||||
let searchQueryTextSplitted = searchQueryText.split(':'); | |||||
if (searchQueryTextSplitted.length === 4 && searchQueryTextSplitted[0].toLowerCase() !== 'swh') { | |||||
$('#swh-origin-search-results').hide(); | |||||
$('.swh-search-pagination').hide(); | |||||
$('#swh-no-result').text('This is not a valid PID'); | |||||
$('#swh-no-result').show(); | |||||
} else { | |||||
// Update the url, triggering page reload and effective search | // Update the url, triggering page reload and effective search | ||||
window.location.search = queryParameters; | window.location.search = queryParameters; | ||||
} | |||||
}); | }); | ||||
$('#origins-next-results-button').click(event => { | $('#origins-next-results-button').click(event => { | ||||
if ($('#origins-next-results-button').hasClass('disabled') || inSearch) { | if ($('#origins-next-results-button').hasClass('disabled') || inSearch) { | ||||
return; | return; | ||||
} | } | ||||
inSearch = true; | inSearch = true; | ||||
linksPrev.push(linkCurrent); | linksPrev.push(linkCurrent); | ||||
Show All 27 Lines |
update headers to 2018-2020 now