Clean up JS files code a bit
This commit is contained in:
parent
26c98689f2
commit
27db688203
@ -463,11 +463,10 @@ function initSearch(rawSearchIndex) {
|
|||||||
* @param {ParserState} parserState
|
* @param {ParserState} parserState
|
||||||
*/
|
*/
|
||||||
function parseInput(query, parserState) {
|
function parseInput(query, parserState) {
|
||||||
let c, before;
|
|
||||||
let foundStopChar = true;
|
let foundStopChar = true;
|
||||||
|
|
||||||
while (parserState.pos < parserState.length) {
|
while (parserState.pos < parserState.length) {
|
||||||
c = parserState.userQuery[parserState.pos];
|
const c = parserState.userQuery[parserState.pos];
|
||||||
if (isStopCharacter(c)) {
|
if (isStopCharacter(c)) {
|
||||||
foundStopChar = true;
|
foundStopChar = true;
|
||||||
if (isSeparatorCharacter(c)) {
|
if (isSeparatorCharacter(c)) {
|
||||||
@ -506,7 +505,7 @@ function initSearch(rawSearchIndex) {
|
|||||||
}
|
}
|
||||||
throw new Error(`Expected \`,\`, \` \`, \`:\` or \`->\`, found \`${c}\``);
|
throw new Error(`Expected \`,\`, \` \`, \`:\` or \`->\`, found \`${c}\``);
|
||||||
}
|
}
|
||||||
before = query.elems.length;
|
const before = query.elems.length;
|
||||||
getNextElem(query, parserState, query.elems, false);
|
getNextElem(query, parserState, query.elems, false);
|
||||||
if (query.elems.length === before) {
|
if (query.elems.length === before) {
|
||||||
// Nothing was added, weird... Let's increase the position to not remain stuck.
|
// Nothing was added, weird... Let's increase the position to not remain stuck.
|
||||||
@ -515,7 +514,6 @@ function initSearch(rawSearchIndex) {
|
|||||||
foundStopChar = false;
|
foundStopChar = false;
|
||||||
}
|
}
|
||||||
while (parserState.pos < parserState.length) {
|
while (parserState.pos < parserState.length) {
|
||||||
c = parserState.userQuery[parserState.pos];
|
|
||||||
if (isReturnArrow(parserState)) {
|
if (isReturnArrow(parserState)) {
|
||||||
parserState.pos += 2;
|
parserState.pos += 2;
|
||||||
// Get returned elements.
|
// Get returned elements.
|
||||||
@ -1940,7 +1938,6 @@ function initSearch(rawSearchIndex) {
|
|||||||
*/
|
*/
|
||||||
const searchWords = [];
|
const searchWords = [];
|
||||||
const charA = "A".charCodeAt(0);
|
const charA = "A".charCodeAt(0);
|
||||||
let i, word;
|
|
||||||
let currentIndex = 0;
|
let currentIndex = 0;
|
||||||
let id = 0;
|
let id = 0;
|
||||||
|
|
||||||
@ -2035,7 +2032,7 @@ function initSearch(rawSearchIndex) {
|
|||||||
// convert `rawPaths` entries into object form
|
// convert `rawPaths` entries into object form
|
||||||
// generate normalizedPaths for function search mode
|
// generate normalizedPaths for function search mode
|
||||||
let len = paths.length;
|
let len = paths.length;
|
||||||
for (i = 0; i < len; ++i) {
|
for (let i = 0; i < len; ++i) {
|
||||||
lowercasePaths.push({ty: paths[i][0], name: paths[i][1].toLowerCase()});
|
lowercasePaths.push({ty: paths[i][0], name: paths[i][1].toLowerCase()});
|
||||||
paths[i] = {ty: paths[i][0], name: paths[i][1]};
|
paths[i] = {ty: paths[i][0], name: paths[i][1]};
|
||||||
}
|
}
|
||||||
@ -2049,16 +2046,14 @@ function initSearch(rawSearchIndex) {
|
|||||||
// faster analysis operations
|
// faster analysis operations
|
||||||
len = itemTypes.length;
|
len = itemTypes.length;
|
||||||
let lastPath = "";
|
let lastPath = "";
|
||||||
for (i = 0; i < len; ++i) {
|
for (let i = 0; i < len; ++i) {
|
||||||
|
let word = "";
|
||||||
// This object should have exactly the same set of fields as the "crateRow"
|
// This object should have exactly the same set of fields as the "crateRow"
|
||||||
// object defined above.
|
// object defined above.
|
||||||
if (typeof itemNames[i] === "string") {
|
if (typeof itemNames[i] === "string") {
|
||||||
word = itemNames[i].toLowerCase();
|
word = itemNames[i].toLowerCase();
|
||||||
searchWords.push(word);
|
|
||||||
} else {
|
|
||||||
word = "";
|
|
||||||
searchWords.push("");
|
|
||||||
}
|
}
|
||||||
|
searchWords.push(word);
|
||||||
const row = {
|
const row = {
|
||||||
crate: crate,
|
crate: crate,
|
||||||
ty: itemTypes.charCodeAt(i) - charA,
|
ty: itemTypes.charCodeAt(i) - charA,
|
||||||
|
@ -117,8 +117,7 @@ function createSourceSidebar() {
|
|||||||
sidebar.appendChild(title);
|
sidebar.appendChild(title);
|
||||||
Object.keys(sourcesIndex).forEach(key => {
|
Object.keys(sourcesIndex).forEach(key => {
|
||||||
sourcesIndex[key][NAME_OFFSET] = key;
|
sourcesIndex[key][NAME_OFFSET] = key;
|
||||||
hasFoundFile = createDirEntry(sourcesIndex[key], sidebar, "",
|
hasFoundFile = createDirEntry(sourcesIndex[key], sidebar, "", hasFoundFile);
|
||||||
hasFoundFile);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
container.appendChild(sidebar);
|
container.appendChild(sidebar);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user