mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
[ticket/13713] Cleanup code based on eslint suggestions
PHPBB3-13713
This commit is contained in:
parent
a0d9c7fe85
commit
b420419655
1 changed files with 11 additions and 9 deletions
|
@ -84,9 +84,9 @@
|
||||||
let i;
|
let i;
|
||||||
|
|
||||||
for (i = query.length; i > 0; i--) {
|
for (i = query.length; i > 0; i--) {
|
||||||
const startStr = query.substr(0, i);
|
const startString = query.slice(0, i);
|
||||||
if (cachedNames[startStr]) {
|
if (cachedNames[startString]) {
|
||||||
return startStr;
|
return startString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@
|
||||||
*/
|
*/
|
||||||
function itemFilter(query, items) {
|
function itemFilter(query, items) {
|
||||||
let i;
|
let i;
|
||||||
let len;
|
let itemsLength;
|
||||||
const highestPriorities = { u: 1, g: 1 };
|
const highestPriorities = { u: 1, g: 1 };
|
||||||
const _unsorted = { u: {}, g: {} };
|
const _unsorted = { u: {}, g: {} };
|
||||||
const _exactMatch = [];
|
const _exactMatch = [];
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
items = getMatchedNames(query, items, 'name');
|
items = getMatchedNames(query, items, 'name');
|
||||||
|
|
||||||
// Group names by their types and calculate priorities
|
// Group names by their types and calculate priorities
|
||||||
for (i = 0, len = items.length; i < len; i++) {
|
for (i = 0, itemsLength = items.length; i < itemsLength; i++) {
|
||||||
const item = items[i];
|
const item = items[i];
|
||||||
|
|
||||||
// Check for unsupported type - in general, this should never happen
|
// Check for unsupported type - in general, this should never happen
|
||||||
|
@ -172,7 +172,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Priority is calculated as the sum of priorities from different sources
|
// Priority is calculated as the sum of priorities from different sources
|
||||||
_unsorted[item.type][item.id].priority += parseFloat(item.priority.toString());
|
_unsorted[item.type][item.id].priority += Number.parseFloat(item.priority.toString());
|
||||||
|
|
||||||
// Calculate the highest priority - we'll give it to group names
|
// Calculate the highest priority - we'll give it to group names
|
||||||
highestPriorities[item.type] = Math.max(highestPriorities[item.type], _unsorted[item.type][item.id].priority);
|
highestPriorities[item.type] = Math.max(highestPriorities[item.type], _unsorted[item.type][item.id].priority);
|
||||||
|
@ -224,7 +224,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const cachedKeyword = getCachedKeyword(query);
|
const cachedKeyword = getCachedKeyword(query);
|
||||||
const cachedNamesForQuery = (cachedKeyword !== null) ? cachedNames[cachedKeyword] : null;
|
const cachedNamesForQuery = cachedKeyword === null ? null : cachedNames[cachedKeyword];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use cached values when we can:
|
* Use cached values when we can:
|
||||||
|
@ -242,8 +242,9 @@
|
||||||
|
|
||||||
queryInProgress = query;
|
queryInProgress = query;
|
||||||
|
|
||||||
const params = { keyword: query, topic_id: mentionTopicId, _referer: location.href };
|
// eslint-disable-next-line camelcase
|
||||||
$.getJSON(mentionURL, params, data => {
|
const parameters = { keyword: query, topic_id: mentionTopicId, _referer: location.href };
|
||||||
|
$.getJSON(mentionURL, parameters, data => {
|
||||||
cachedNames[query] = data.names;
|
cachedNames[query] = data.names;
|
||||||
cachedAll[query] = data.all;
|
cachedAll[query] = data.all;
|
||||||
callback(data.names);
|
callback(data.names);
|
||||||
|
@ -282,6 +283,7 @@
|
||||||
return $mentionDataContainer.length;
|
return $mentionDataContainer.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* global Tribute */
|
||||||
this.handle = function(textarea) {
|
this.handle = function(textarea) {
|
||||||
tribute = new Tribute({
|
tribute = new Tribute({
|
||||||
trigger: '@',
|
trigger: '@',
|
||||||
|
|
Loading…
Add table
Reference in a new issue