mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 00:36:47 +02:00
Convert indentation spaces to tabs.
This commit is contained in:
parent
2a0cb31f38
commit
b1e8019e2a
1 changed files with 37 additions and 37 deletions
|
@ -25,7 +25,7 @@ const formatting = {
|
||||||
// Gets the current time and adds it to a given packet
|
// Gets the current time and adds it to a given packet
|
||||||
const timeArray = formatting.helpers._timestampArray(packet.timestamp);
|
const timeArray = formatting.helpers._timestampArray(packet.timestamp);
|
||||||
packet.timeString = timeArray[0];
|
packet.timeString = timeArray[0];
|
||||||
packet.dateString = timeArray[1];
|
packet.dateString = timeArray[1];
|
||||||
return packet;
|
return packet;
|
||||||
},
|
},
|
||||||
trimPacketToSave: function(packet) {
|
trimPacketToSave: function(packet) {
|
||||||
|
@ -40,31 +40,31 @@ const formatting = {
|
||||||
},
|
},
|
||||||
parseMessage: async function(message, enableEmbedding) {
|
parseMessage: async function(message, enableEmbedding) {
|
||||||
const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
|
const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
|
||||||
const overteLocationRegex = /hifi:\/\/[a-zA-Z0-9_-]+\/[-+]?\d*\.?\d+,[+-]?\d*\.?\d+,[+-]?\d*\.?\d+\/[-+]?\d*\.?\d+,[+-]?\d*\.?\d+,[+-]?\d*\.?\d+,[+-]?\d*\.?\d+/;
|
const overteLocationRegex = /hifi:\/\/[a-zA-Z0-9_-]+\/[-+]?\d*\.?\d+,[+-]?\d*\.?\d+,[+-]?\d*\.?\d+\/[-+]?\d*\.?\d+,[+-]?\d*\.?\d+,[+-]?\d*\.?\d+,[+-]?\d*\.?\d+/;
|
||||||
|
|
||||||
let runningMessage = message; // The remaining message that will be parsed
|
let runningMessage = message; // The remaining message that will be parsed
|
||||||
let messageArray = []; // An array of messages that are split up by the formatting functions
|
let messageArray = []; // An array of messages that are split up by the formatting functions
|
||||||
|
|
||||||
const regexPatterns = [
|
const regexPatterns = [
|
||||||
{ type: "url", regex: urlRegex },
|
{ type: "url", regex: urlRegex },
|
||||||
{ type: "overteLocation", regex: overteLocationRegex }
|
{ type: "overteLocation", regex: overteLocationRegex }
|
||||||
]
|
]
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
let firstMatch = _findFirstMatch();
|
let firstMatch = _findFirstMatch();
|
||||||
|
|
||||||
if (firstMatch == null) {
|
if (firstMatch == null) {
|
||||||
// If there is no more text to parse, break out of the loop and return the message array.
|
// If there is no more text to parse, break out of the loop and return the message array.
|
||||||
// Format any remaining text as a basic 'text' type.
|
// Format any remaining text as a basic 'text' type.
|
||||||
if (runningMessage.trim() != "") messageArray.push({type: 'text', value: runningMessage});
|
if (runningMessage.trim() != "") messageArray.push({type: 'text', value: runningMessage});
|
||||||
|
|
||||||
// Append a final 'fill width' to the message text.
|
// Append a final 'fill width' to the message text.
|
||||||
messageArray.push({type: 'messageEnd'});
|
messageArray.push({type: 'messageEnd'});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_formatMessage(firstMatch);
|
_formatMessage(firstMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Embed images in the message array.
|
// Embed images in the message array.
|
||||||
if (enableEmbedding) {
|
if (enableEmbedding) {
|
||||||
|
@ -90,35 +90,35 @@ const formatting = {
|
||||||
return messageArray;
|
return messageArray;
|
||||||
|
|
||||||
function _formatMessage(firstMatch){
|
function _formatMessage(firstMatch){
|
||||||
let indexOfFirstMatch = firstMatch[0];
|
let indexOfFirstMatch = firstMatch[0];
|
||||||
let regex = regexPatterns[firstMatch[1]].regex;
|
let regex = regexPatterns[firstMatch[1]].regex;
|
||||||
|
|
||||||
let foundMatch = runningMessage.match(regex)[0];
|
let foundMatch = runningMessage.match(regex)[0];
|
||||||
|
|
||||||
if (runningMessage.substring(0, indexOfFirstMatch) != "") messageArray.push({type: 'text', value: runningMessage.substring(0, indexOfFirstMatch)});
|
if (runningMessage.substring(0, indexOfFirstMatch) != "") messageArray.push({type: 'text', value: runningMessage.substring(0, indexOfFirstMatch)});
|
||||||
messageArray.push({type: regexPatterns[firstMatch[1]].type, value: runningMessage.substring(indexOfFirstMatch, indexOfFirstMatch + foundMatch.length)});
|
messageArray.push({type: regexPatterns[firstMatch[1]].type, value: runningMessage.substring(indexOfFirstMatch, indexOfFirstMatch + foundMatch.length)});
|
||||||
|
|
||||||
runningMessage = runningMessage.substring(indexOfFirstMatch + foundMatch.length); // Remove the part of the message we have worked with
|
runningMessage = runningMessage.substring(indexOfFirstMatch + foundMatch.length); // Remove the part of the message we have worked with
|
||||||
}
|
}
|
||||||
|
|
||||||
function _findFirstMatch(){
|
function _findFirstMatch(){
|
||||||
let indexOfFirstMatch = Infinity;
|
let indexOfFirstMatch = Infinity;
|
||||||
let indexOfRegexPattern = Infinity;
|
let indexOfRegexPattern = Infinity;
|
||||||
|
|
||||||
for (let i = 0; regexPatterns.length > i; i++){
|
for (let i = 0; regexPatterns.length > i; i++){
|
||||||
let indexOfMatch = runningMessage.search(regexPatterns[i].regex);
|
let indexOfMatch = runningMessage.search(regexPatterns[i].regex);
|
||||||
|
|
||||||
if (indexOfMatch == -1) continue; // No match found
|
if (indexOfMatch == -1) continue; // No match found
|
||||||
|
|
||||||
if (indexOfMatch < indexOfFirstMatch) {
|
if (indexOfMatch < indexOfFirstMatch) {
|
||||||
indexOfFirstMatch = indexOfMatch;
|
indexOfFirstMatch = indexOfMatch;
|
||||||
indexOfRegexPattern = i;
|
indexOfRegexPattern = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexOfFirstMatch !== Infinity) return [indexOfFirstMatch, indexOfRegexPattern]; // If there was a found match
|
if (indexOfFirstMatch !== Infinity) return [indexOfFirstMatch, indexOfRegexPattern]; // If there was a found match
|
||||||
return null; // No found match
|
return null; // No found match
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
helpers: {
|
helpers: {
|
||||||
|
|
Loading…
Reference in a new issue