Resolve eslint errs/warnings in search-results.js
This commit is contained in:
parent
c9e894f670
commit
16d32c40f5
|
@ -1,3 +1,4 @@
|
||||||
|
/* global handleEvent */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,27 +164,27 @@ const SearchResults = (() => {
|
||||||
|
|
||||||
const entry = template.searchResult.cloneNode(true);
|
const entry = template.searchResult.cloneNode(true);
|
||||||
Object.assign(entry, {
|
Object.assign(entry, {
|
||||||
id: ENTRY_ID_PREFIX_RAW + userstyleSearchResult.id,
|
|
||||||
styleId: userstyleSearchResult.id
|
styleId: userstyleSearchResult.id
|
||||||
});
|
});
|
||||||
$('#searchResults-list').appendChild(entry);
|
$('#searchResults-list').appendChild(entry);
|
||||||
|
|
||||||
|
const searchResultName = userstyleSearchResult.name;
|
||||||
const title = $('.searchResult-title', entry);
|
const title = $('.searchResult-title', entry);
|
||||||
Object.assign(title, {
|
Object.assign(title, {
|
||||||
textContent: userstyleSearchResult.name,
|
textContent: searchResultName,
|
||||||
title: userstyleSearchResult.name,
|
title: searchResultName,
|
||||||
href: 'https://userstyles.org' + userstyleSearchResult.url,
|
href: 'https://userstyles.org' + userstyleSearchResult.url,
|
||||||
onclick: handleEvent.openURLandHide
|
onclick: handleEvent.openURLandHide
|
||||||
});
|
});
|
||||||
|
|
||||||
const screenshot = $('.searchResult-screenshot', entry);
|
const screenshot = $('.searchResult-screenshot', entry);
|
||||||
let ss_url = userstyleSearchResult.screenshot_url;
|
let screenshotUrl = userstyleSearchResult.screenshot_url;
|
||||||
if (RegExp(/^[0-9]*_after.(jpe?g|png|gif)$/i).test(ss_url)) {
|
if (RegExp(/^[0-9]*_after.(jpe?g|png|gif)$/i).test(screenshotUrl)) {
|
||||||
ss_url = 'https://userstyles.org/style_screenshot_thumbnails/' + ss_url;
|
screenshotUrl = 'https://userstyles.org/style_screenshot_thumbnails/' + screenshotUrl;
|
||||||
}
|
}
|
||||||
Object.assign(screenshot, {
|
Object.assign(screenshot, {
|
||||||
src: ss_url,
|
src: screenshotUrl,
|
||||||
title: userstyleSearchResult.name
|
title: searchResultName
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Expand/collapse description
|
// TODO: Expand/collapse description
|
||||||
|
@ -205,13 +206,12 @@ const SearchResults = (() => {
|
||||||
// TODO: Rating
|
// TODO: Rating
|
||||||
|
|
||||||
const installButton = $('.searchResult-install', entry);
|
const installButton = $('.searchResult-install', entry);
|
||||||
const name = userstyleSearchResult.name;
|
|
||||||
Object.assign(installButton, {
|
Object.assign(installButton, {
|
||||||
onclick: install
|
onclick: install
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Installs the current userstyleSearchResult into stylus. */
|
/** Installs the current userstyleSearchResult into stylus. */
|
||||||
function install(event) {
|
function install() {
|
||||||
UserStylesAPI.fetch('/api/v1/styles/' + userstyleSearchResult.id)
|
UserStylesAPI.fetch('/api/v1/styles/' + userstyleSearchResult.id)
|
||||||
.then(styleObject => {
|
.then(styleObject => {
|
||||||
console.log('TODO: Install style ID', userstyleSearchResult.id);
|
console.log('TODO: Install style ID', userstyleSearchResult.id);
|
||||||
|
@ -233,7 +233,7 @@ const SearchResults = (() => {
|
||||||
notify: true
|
notify: true
|
||||||
});
|
});
|
||||||
saveStyleSafe(styleObject);
|
saveStyleSafe(styleObject);
|
||||||
alert('TODO: Install style ID #' + userstyleSearchResult.id + ' name "' + userstyleSearchResult.name + '"');
|
alert('TODO: Install style ID #' + userstyleSearchResult.id + ' name "' + searchResultName + '"');
|
||||||
})
|
})
|
||||||
.catch(reason => {
|
.catch(reason => {
|
||||||
console.log('Error during installation:', reason);
|
console.log('Error during installation:', reason);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user