code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
buildQualifier = (scope, anchor, parser, filter, transformer) => ({
scope,
name: this.i18n.t(`scope.${scope}`),
anchor,
is_meta: false,
need_read_file: true,
cost: 3,
preprocess: this.MIXIN.PREPROCESS.noop,
validate: this.MI... | The matching process consists of the following steps: (Steps 1-4 are executed once; steps 5-6 are executed repeatedly)
1. Parse: Parses the input to generate an Abstract Syntax Tree (AST)
2. Preprocess: Convert certain specific, predefined, and special meaning vocabulary (e.g. converting 'today' in 'mtime=toda... | buildQualifier | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
parse(input, optimize = false) {
input = input.replace(/\r?\n/g, " ")
input = this.config.CASE_SENSITIVE ? input : input.toLowerCase()
const ast = this.parser.parse(input)
this.postParse(ast)
return optimize ? this.optimize(ast) : ast
} | The matching process consists of the following steps: (Steps 1-4 are executed once; steps 5-6 are executed repeatedly)
1. Parse: Parses the input to generate an Abstract Syntax Tree (AST)
2. Preprocess: Convert certain specific, predefined, and special meaning vocabulary (e.g. converting 'today' in 'mtime=toda... | parse | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
postParse(ast) {
const { REGEXP } = this.parser.TYPE
this.parser.walk(ast, node => {
const qualifier = this.qualifiers.get(node.scope.toLowerCase())
node.operand = qualifier.preprocess(node.scope, node.operator, node.operand, node.type)
node.validateError = qualifier.... | The matching process consists of the following steps: (Steps 1-4 are executed once; steps 5-6 are executed repeatedly)
1. Parse: Parses the input to generate an Abstract Syntax Tree (AST)
2. Preprocess: Convert certain specific, predefined, and special meaning vocabulary (e.g. converting 'today' in 'mtime=toda... | postParse | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
optimize(ast) {
if (!ast) return
const { OR, AND } = this.parser.TYPE
const setCost = node => {
if (!node) return
setCost(node.left)
setCost(node.right)
const rootCost = node.cost || 1
const leftCost = (node.left && node.left.cost) |... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | optimize | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
setCost = node => {
if (!node) return
setCost(node.left)
setCost(node.right)
const rootCost = node.cost || 1
const leftCost = (node.left && node.left.cost) || 1
const rightCost = (node.right && node.right.cost) || 1
node.cost = Math.m... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | setCost | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
setCost = node => {
if (!node) return
setCost(node.left)
setCost(node.right)
const rootCost = node.cost || 1
const leftCost = (node.left && node.left.cost) || 1
const rightCost = (node.right && node.right.cost) || 1
node.cost = Math.m... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | setCost | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
getDataNodes = (cur, root, dataNodes = []) => {
if (cur.type === root.type) {
if (cur.right) {
getDataNodes(cur.right, root, dataNodes)
}
if (cur.left) {
getDataNodes(cur.left, root, dataNodes)
}
... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | getDataNodes | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
getDataNodes = (cur, root, dataNodes = []) => {
if (cur.type === root.type) {
if (cur.right) {
getDataNodes(cur.right, root, dataNodes)
}
if (cur.left) {
getDataNodes(cur.left, root, dataNodes)
}
... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | getDataNodes | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
rebuild = node => {
if (!node) return
if (node.type === OR || node.type === AND) {
const dataNodes = getDataNodes(node, node)
if (dataNodes.length > 1) {
dataNodes.sort((a, b) => a.cost - b.cost)
let newNode = dataNodes.shi... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | rebuild | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
rebuild = node => {
if (!node) return
if (node.type === OR || node.type === AND) {
const dataNodes = getDataNodes(node, node)
if (dataNodes.length > 1) {
dataNodes.sort((a, b) => a.cost - b.cost)
let newNode = dataNodes.shi... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | rebuild | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
match(ast, source) {
return this.parser.evaluate(ast, node => this._match(node, source))
} | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | match | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_match(node, source) {
const { scope, operator, castResult, type } = node
const qualifier = this.qualifiers.get(scope)
let queryResult = qualifier.query(source)
if (!this.config.CASE_SENSITIVE) {
if (typeof queryResult === "string") {
queryResult = queryResult... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _match | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
getReadFileScope(ast) {
const scope = new Set()
const needRead = new Set([...this.qualifiers.values()].filter(q => q.need_read_file).map(q => q.scope))
this.parser.walk(ast, node => {
if (needRead.has(node.scope)) {
scope.add(node.scope)
}
})
... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | getReadFileScope | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
toMermaid(ast, translate = false, direction = "TB") {
let idx = 0
const { t, link } = this.i18n
const { KEYWORD, PHRASE, REGEXP, OR, AND, NOT } = this.parser.TYPE
const I18N = {
not: t("not"),
matchRegex: t("matchRegex"),
":": t("operator.colon"),
... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | toMermaid | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_getName = (node) => {
if (node._shortName) {
return node._shortName
}
node._shortName = "T" + ++idx
let longName
const isRegex = node.type === REGEXP
const operand = isRegex ? `/${node.operand}/` : node.operand
const n... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _getName | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_getName = (node) => {
if (node._shortName) {
return node._shortName
}
node._shortName = "T" + ++idx
let longName
const isRegex = node.type === REGEXP
const operand = isRegex ? `/${node.operand}/` : node.operand
const n... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _getName | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_link = (left, right) => {
return left.tail.flatMap(t => right.head.map(h => `${_getName(t)} --> ${_getName(h)}`))
} | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _link | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_link = (left, right) => {
return left.tail.flatMap(t => right.head.map(h => `${_getName(t)} --> ${_getName(h)}`))
} | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _link | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_eval = (node, negated) => {
let left, right
switch (node.type) {
case AND:
left = _eval(node.left, negated)
right = _eval(node.right, negated)
node.head = left.head
node.tail = right.tail
... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _eval | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_eval = (node, negated) => {
let left, right
switch (node.type) {
case AND:
left = _eval(node.left, negated)
right = _eval(node.right, negated)
node.head = left.head
node.tail = right.tail
... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _eval | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_link = (left, right) => {
return left.result.flatMap(lPath => right.result.map(rPath => [...lPath, ...rPath]))
} | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _link | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_link = (left, right) => {
return left.result.flatMap(lPath => right.result.map(rPath => [...lPath, ...rPath]))
} | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _link | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_eval = (node, negated) => {
let left, right
switch (node.type) {
case AND:
left = _eval(node.left, negated)
right = _eval(node.right, negated)
node.result = _link(left, right)
return node
... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _eval | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_eval = (node, negated) => {
let left, right
switch (node.type) {
case AND:
left = _eval(node.left, negated)
right = _eval(node.right, negated)
node.result = _link(left, right)
return node
... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _eval | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_to = async (expression, optimize, callback) => {
try {
const ast = this.parse(expression, optimize)
return callback(ast)
} catch (e) {
console.error(e)
return `Syntax Error: ${e.toString().slice(7)}`
}
} | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _to | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_to = async (expression, optimize, callback) => {
try {
const ast = this.parse(expression, optimize)
return callback(ast)
} catch (e) {
console.error(e)
return `Syntax Error: ${e.toString().slice(7)}`
}
} | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _to | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_toGraph = async ({ expression, optimize, translate, direction }) => {
return _to(expression, optimize, async ast => {
const definition = this.toMermaid(ast, translate, direction)
const svg = await this.utils.mermaid.render(definition)
return `<div style="font... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _toGraph | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
_toGraph = async ({ expression, optimize, translate, direction }) => {
return _to(expression, optimize, async ast => {
const definition = this.toMermaid(ast, translate, direction)
const svg = await this.utils.mermaid.render(definition)
return `<div style="font... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | _toGraph | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
getSchema = async ({ expression, optimize, translate, direction, presentation, grammar }) => {
const dep = { dependencies: { presentation: "graph" } }
const directionOps = Object.fromEntries(["TB", "BT", "RL", "LR"].map(e => [e, e]))
const presentOps = {
text: t("moda... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | getSchema | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
getSchema = async ({ expression, optimize, translate, direction, presentation, grammar }) => {
const dep = { dependencies: { presentation: "graph" } }
const directionOps = Object.fromEntries(["TB", "BT", "RL", "LR"].map(e => [e, e]))
const presentOps = {
text: t("moda... | Process OR/AND nodes by:
1. Gathering data child nodes into `dataNodes`
2. Sorting `dataNodes` by `cost`
3. Rebuilding the subtree based on `dataNodes` to favor low-cost operations | getSchema | javascript | obgnail/typora_plugin | plugin/search_multi/searcher.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/search_multi/searcher.js | MIT |
function setRoomMode(room) {
if(room){
SystemPrompt.select(settings.system_prompt_preset_room);
is_room = true;
$("#option_select_chat").css("display", "none");
}else{
SystemPrompt.select(settings.system_prompt_preset_chat);
is_room = false;
... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | setRoomMode | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function showCharaCloud(){
if(!charaCloud.is_init){
charaCloudInit();
}
$('#shell').css('display', 'none');
$('#chara_cloud').css('display', 'block');
$('#chara_cloud').css('opacity', 0.0);
$('#chara_cloud').transition({
opacity: 1.0,
d... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | showCharaCloud | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function hideCharaCloud(){
$('#shell').css('display', 'grid');
$('#shell').css('opacity', 0.0);
$('#shell').transition({
opacity: 1.0,
duration: 1000,
easing: "",
complete: function() { }
});
$('#chara_cloud').css('display', 'non... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | hideCharaCloud | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function checkOnlineStatus(){
if(online_status == 'no_connection'){
$("#online_status_indicator").removeClass('online_status_indicator_online');
$("#online_status_indicator2").removeClass('online_status_indicator_online');
$("#online_status_indicator3").removeClass('online_st... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | checkOnlineStatus | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function getLastVersion(){
jQuery.ajax({
type: 'POST', //
url: '/getlastversion', //
data: JSON.stringify({
'': ''
}),
beforeSend: function(){
},
cache: false,
timeout: req... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | getLastVersion | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function setPygFmtg(){
if(online_status != 'no_connection'){
online_status = online_status.replace(pyg_fmtg_str_ind, '');
switch (pyg_fmtg){
case 1:
is_pyg = true;
online_status+=pyg_fmtg_str_ind;
break;
... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | setPygFmtg | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function getStatus(){
if(is_get_status){
jQuery.ajax({
type: 'POST', //
url: '/getstatus', //
data: JSON.stringify({
api_server: api_server
}),
beforeSend: function(){
... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | getStatus | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function resultCheckStatus(){
is_api_button_press = false;
checkOnlineStatus();
$("#api_loading").css("display", 'none');
if(is_mobile_user){$("#api_button").css('display', 'block');}
else{$("#api_button").css('display', 'inline-block');}
} | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | resultCheckStatus | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function getStatusWebui(){
if(is_get_status_webui){
jQuery.ajax({
type: 'POST', //
url: '/getstatus_webui', //
data: JSON.stringify({
api_server_webui: api_server_webui
}),
beforeS... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | getStatusWebui | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function resultCheckStatusWebui(){
is_api_button_press_webui = false;
checkOnlineStatus();
$("#api_loading_webui").css("display", 'none');
if(is_mobile_user){$("#api_button_webui").css('display', 'block');}
else{$("#api_button_webui").css('display', 'inline-block');}
} | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | resultCheckStatusWebui | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function getStatusHorde(){
if(is_get_status){
var data = {'type':'text'};
jQuery.ajax({
type: 'POST', //
url: '/getstatus_horde', //
data: JSON.stringify(data),
beforeSend: function(){
//$('#create_... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | getStatusHorde | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function resultCheckStatusHorde(){
is_api_button_press = false;
checkOnlineStatus();
$("#api_loading_horde").css("display", 'none');
$("#api_button_horde").css("display", 'inline-block');
} | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | resultCheckStatusHorde | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function getBackgrounds() {
const response = await fetch("/getbackgrounds", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-CSRF-Token": token
},
... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | getBackgrounds | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function isColab() {
is_checked_colab = true;
const response = await fetch("/iscolab", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-CSRF-Token": token
},
body: JSON.stringify(... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | isColab | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function setBackground(bg) {
jQuery.ajax({
type: 'POST', //
url: '/setbackground', //
data: JSON.stringify({
bg: bg
}),
beforeSend: function(){
//$('#create_button').attr('value','Creating...'... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | setBackground | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function delBackground(bg) {
const response = await fetch("/delbackground", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-CSRF-Token": token
},
body: JSON.stringify({
... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | delBackground | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function printMessages(){
if(Tavern.mode === 'chat'){
let missing_chars = [];
chat.forEach(function(item, i, arr) {
// if(is_room && !imageExists(getMessageAvatar(item)) && missing_chars.indexOf(item.name) === -1)
// missing_chars.push(item.name);
... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | printMessages | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function clearChat(){
count_view_mes = 0;
Story.showHide();
$('#chat').html('');
$('#story_textarea').val('');
} | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | clearChat | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function messageFormating(mes, ch_name){
//if(Characters.selectedID != undefined) mes = mes.replaceAll("<", "<").replaceAll(">", ">");
//for Chloe
if(Characters.selectedID === undefined){
mes = mes.replace(/\*\*(.+?)\*\*/g, '<b>$1</b>').replace(/\*(.+?)\*/g, '<i>$1</i>').replac... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | messageFormating | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function getMessageAvatar(mes) {
var avatarImg = "User Avatars/"+user_avatar;
if(!mes.is_user){
if(Characters.selectedID === undefined) {
avatarImg = "img/chloe.png";
} else {
//mes.chid = mes.chid || parseInt(Characters.selectedID);
... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | getMessageAvatar | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function addOneMessage(mes, type='normal') {
var messageText = mes['mes'];
var characterName = name1;
var messageImageRecognition = '';
generatedPromtCache = '';
var avatarImg = getMessageAvatar(mes);
if(!mes.is_user){
if(!is_room)
mes.chid = C... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | addOneMessage | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function typeWriter(target, text, speed, i) {
if (i < text.length) {
//target.append(text.charAt(i));
target.html(target.html() + text.charAt(i));
i++;
setTimeout(() => typeWriter(target, text, speed, i), speed);
}
} | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | typeWriter | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function newMesPattern(name){ //Patern which denotes a new message
name = name+':';
return name;
} | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | newMesPattern | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function Generate(type) {
let this_gap_holder = gap_holder;
let originalName2 = name2;
// console.log((type === 'swipe' || (type === 'regenerate' && !chat[chat.length-1]['is_user'])) && is_room);
// if((type === 'swipe' || (type === 'regenerate' && !chat[chat.length-1]['is_user']))... | Function to change the context/mode from/to "room" or "character", given parameter value.
This function does not affect the character/room list, which should be handled separately.
Will update the is_room variable.
@param {*} room Switch to "room" mode if true | Generate | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function setPromtString(){
mesSendString = '';
mesExmString = '';
for(let j = 0; j < count_exm_add; j++){
mesExmString+=mesExamplesArray[j];
}
for(let j = 0; j < mesSend.length; j++){
... | Base replace***
if(mesExamples !== undefined){
if(mesExamples.length > 0){
if(is_pyg){
mesExamples = mesExamples.replace(/{{user}}:\s/gi, 'You: ');
mesExamples = mesExamples.replace(/<USER>:\s/gi, 'You: ');
... | setPromtString | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function checkPromtSize(){
setPromtString();
let thisPromtContextSize = await Tokenizer.encode(storyString+mesExmString+mesSendString+anchorTop+anchorBottom+charPersonality+generatedPromtCache)+this_gap_holder+imageRecognitionBudgetTokens;
if(thisPromtCo... | Base replace***
if(mesExamples !== undefined){
if(mesExamples.length > 0){
if(is_pyg){
mesExamples = mesExamples.replace(/{{user}}:\s/gi, 'You: ');
mesExamples = mesExamples.replace(/<USER>:\s/gi, 'You: ');
... | checkPromtSize | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function removeMessage() {
const deletedMsg = mesSend.shift();
if (deletedMsg['image_for_recognition'] !== undefined) {
imageRecognitionBudgetTokens -= 85;
}
if(deletedMsg['jailbreak_prompt'] !== undefined){
... | Base replace***
if(mesExamples !== undefined){
if(mesExamples.length > 0){
if(is_pyg){
mesExamples = mesExamples.replace(/{{user}}:\s/gi, 'You: ');
mesExamples = mesExamples.replace(/<USER>:\s/gi, 'You: ');
... | removeMessage | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function generateCallback(data){
tokens_already_generated += this_amount_gen;
if(data.error != true){
var getMessage = '';
if(main_api == 'kobold'){
getMessage = data.results[0].text;
}
if(main_api == 'webui'){
getMessage = ... | Base replace***
if(mesExamples !== undefined){
if(mesExamples.length > 0){
if(is_pyg){
mesExamples = mesExamples.replace(/{{user}}:\s/gi, 'You: ');
mesExamples = mesExamples.replace(/<USER>:\s/gi, 'You: ');
... | generateCallback | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function getImageTypeFromBase64(base64String) {
const firstChar = base64String.charAt(0);
switch (firstChar) {
case '/':
return 'image/jpeg';
case 'i':
return 'image/png';
case 'R':
return 'image/gif';
case '... | Base replace***
if(mesExamples !== undefined){
if(mesExamples.length > 0){
if(is_pyg){
mesExamples = mesExamples.replace(/{{user}}:\s/gi, 'You: ');
mesExamples = mesExamples.replace(/<USER>:\s/gi, 'You: ');
... | getImageTypeFromBase64 | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function getBase64Image(imageFile) {
return new Promise(function (resolve, reject) {
const reader = new FileReader();
reader.onload = function () {
resolve(reader.result.replace(/^data:image\/[a-z]+;base64,/, ''));
};
reader.onerror = reject;
... | Base replace***
if(mesExamples !== undefined){
if(mesExamples.length > 0){
if(is_pyg){
mesExamples = mesExamples.replace(/{{user}}:\s/gi, 'You: ');
mesExamples = mesExamples.replace(/<USER>:\s/gi, 'You: ');
... | getBase64Image | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function aiImagePickerInit(){
$('#ai_image_picker').css("display", 'none');
if (isModelHaveImageRecognition()) {
$('#ai_image_picker').css("display", 'block');
}
} | Base replace***
if(mesExamples !== undefined){
if(mesExamples.length > 0){
if(is_pyg){
mesExamples = mesExamples.replace(/{{user}}:\s/gi, 'You: ');
mesExamples = mesExamples.replace(/<USER>:\s/gi, 'You: ');
... | aiImagePickerInit | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function isModelHaveImageRecognition(){
if((main_api === 'openai' && model_openai === 'gpt-4-vision-preview'))
return true;
if(main_api === 'proxy' && (model_proxy === 'gpt-4-vision-preview' || model_proxy.includes('claude-3')))
return true;
if(main_api === 'claude' && m... | Base replace***
if(mesExamples !== undefined){
if(mesExamples.length > 0){
if(is_pyg){
mesExamples = mesExamples.replace(/{{user}}:\s/gi, 'You: ');
mesExamples = mesExamples.replace(/<USER>:\s/gi, 'You: ');
... | isModelHaveImageRecognition | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function getIDsByFilenames(ch_filenames) {
let ids = [];
ch_filenames.forEach(function(filename) {
ids.push(Characters.getIDbyFilename(filename));
});
return ids;
} | Base replace***
if(mesExamples !== undefined){
if(mesExamples.length > 0){
if(is_pyg){
mesExamples = mesExamples.replace(/{{user}}:\s/gi, 'You: ');
mesExamples = mesExamples.replace(/<USER>:\s/gi, 'You: ');
... | getIDsByFilenames | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function assignIDsByFilenames() {
chat.forEach(function(mes, i) {
chat[i].chid = Characters.getIDbyFilename(mes.character_file);
});
} | Base replace***
if(mesExamples !== undefined){
if(mesExamples.length > 0){
if(is_pyg){
mesExamples = mesExamples.replace(/{{user}}:\s/gi, 'You: ');
mesExamples = mesExamples.replace(/<USER>:\s/gi, 'You: ');
... | assignIDsByFilenames | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function getChatRoom(filename) {
//console.log(characters[Characters.selectedID].chat);
jQuery.ajax({
type: 'POST',
url: '/getchatroom',
data: JSON.stringify({
room_filename: filename
}),
beforeSend: function(){
... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | getChatRoom | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function saveChatRoom() {
chat.forEach(function(item, i) {
if(item['is_user']){
var str = item['mes'].replace(name1+':', default_user_name+':');
chat[i]['mes'] = str;
chat[i]['name'] = default_user_name;
}else if(i !== chat.length-1){... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | saveChatRoom | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function saveChat() {
chat.forEach(function(item, i) {
if(item['is_user']){
var str = item['mes'].replace(name1+':', default_user_name+':');
chat[i]['mes'] = str;
chat[i]['name'] = default_user_name;
}else if(i !== chat.length-1){
... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | saveChat | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function getChat() {
//console.log(characters[Characters.selectedID].chat);
jQuery.ajax({
type: 'POST',
url: '/getchat',
data: JSON.stringify({
ch_name: Characters.id[Characters.selectedID].name,
file_name: Characters.id[Cha... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | getChat | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function getChatResult(){
name2 = Characters.id[Characters.selectedID].name;
if(chat.length > 1){
chat.forEach(function(item, i) {
if(item['is_user']){
var str = item['mes'].replace(default_user_name+': ', name1+': ');
chat[i]['mes'] = ... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | getChatResult | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function loadRoomCharacterSelection() {
$("#room_character_select_items").empty();
$("#room_character_selected_items").empty();
let characterFilenameList = [];
Characters.id.forEach(function(character, i) {
// if(!characterNameList.includes(character.name))
// ... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | loadRoomCharacterSelection | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function loadRoomSelectedCharacters() {
$("#room_character_select_items").empty();
$("#room_character_selected_items").empty();
Rooms.selectedCharacters.forEach(function(characterId, i) {
// $("#room_character_selected_items")
// .append('<div class="avatar" tit... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | loadRoomSelectedCharacters | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function select_rm_create(){
// menu buttons
menu_type = 'create';
$( "#rm_charaters_block" ).css("display", "none");
$( "#rm_api_block" ).css("display", "none");
$( "#rm_ch_create_block" ).css("display", "block");
$('#rm_ch_create_block').css('opacity',0.0);
$('#... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | select_rm_create | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function select_room_create(){
// menu buttons
menu_type = 'create_room';
$( "#rm_charaters_block" ).css("display", "none");
$( "#rm_api_block" ).css("display", "none");
$( "#rm_ch_create_block" ).css("display", "block");
$('#rm_ch_create_block').css('opacity',0.0);
... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | select_room_create | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function select_rm_characters(){
menu_type = 'characters';
$( "#rm_charaters_block" ).css("display", "block");
$('#rm_charaters_block').css('opacity',0.0);
$('#rm_charaters_block').transition({
opacity: 1.0,
duration: animation_rm_duration,
... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | select_rm_characters | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function select_selected_character(chid){ //character select
// is_room = false;
select_rm_create();
menu_type = 'character_edit';
$( "#delete_button_div" ).css("display", "block");
$( "#rm_button_selected_ch" ).children("h2").removeClass('deselected_button_style');
$( "#... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | select_selected_character | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function callPopup(text = '', type){
popup_type = type;
$("#dialogue_popup_cancel").css("display", "inline-block");
switch(popup_type){
case 'logout':
$("#dialogue_popup_ok").css("background-color", "#191b31CC");
$("#dialogue_popup_ok").text("Yes");
... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | callPopup | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function read_bg_load(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#bg_load_preview')
.attr('src', e.target.result)
.width(103)
.height(83);
... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | read_bg_load | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function showSwipeButtons(){
if(swipes){
if(!chat[chat.length-1]['is_user'] && count_view_mes > 1){
$("#chat").children().filter('[mesid="'+(count_view_mes-1)+'"]').children('.swipe_right').css('display', 'block');
if(chat[chat.length-1]['swipe_id'] !== undefined){
... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | showSwipeButtons | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function hideSwipeButtons(){
$("#chat").children().filter('[mesid="'+(count_view_mes-1)+'"]').children('.swipe_right').css('display', 'none');
$("#chat").children().filter('[mesid="'+(count_view_mes-1)+'"]').children('.swipe_left').css('display', 'none');
} | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | hideSwipeButtons | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function changeMainAPI(){
$('#kobold_api').css("display", "none");
$('#novel_api').css("display", "none");
$('#openai_api').css("display","none");
$('#horde_api').css("display", "none");
$('#webui_api').css("display", "none");
$('#claude_api').css("display", "none");
... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | changeMainAPI | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
async function getUserAvatars(){
const response = await fetch("/getuseravatars", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-CSRF-Token": token
},
... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | getUserAvatars | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function customProxyModelUpdate(){
let this_text = '';
if(main_api === 'openai'){
this_text = 'Custom OpenAI model';
}
if(main_api === 'proxy'){
this_text = 'Custom proxy model';
}
if(custom_proxy_model.length > 0){
this_text += " <font color=#4... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | customProxyModelUpdate | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function updateHordeStats() {
jQuery.ajax({
type: "GET",
url: "/gethordeinfo",
cache: false,
contentType: "application/json",
success: function(data) {
if(data.hordeData && data.hordeData.finished) {
Tavern.hordeChec... | Note that the clearChat() function (and chat.length = 0 assignment) is already called in this function, calling it before calling this function is redundant | updateHordeStats | javascript | TavernAI/TavernAI | public/script.js | https://github.com/TavernAI/TavernAI/blob/master/public/script.js | MIT |
function triggerLoadOrError(e) {
triggerEvent(e.type, $(this).off(load_error, triggerLoadOrError));
} | Trigger onload/onerror handler
@param {Event} e | triggerLoadOrError | javascript | TavernAI/TavernAI | public/scripts/jquery.lazyloadxt.min.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/jquery.lazyloadxt.min.js | MIT |
function timeoutLazyElements() {
if (waitingMode > 1) {
waitingMode = 1;
checkLazyElements();
setTimeout(timeoutLazyElements, options.throttle);
} else {
waitingMode = 0;
}
} | Run check of lazy elements after timeout | timeoutLazyElements | javascript | TavernAI/TavernAI | public/scripts/jquery.lazyloadxt.min.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/jquery.lazyloadxt.min.js | MIT |
function getDefaultWhiteList() {
return {
a: ["target", "href", "title"],
abbr: ["title"],
address: [],
area: ["shape", "coords", "href", "alt"],
article: [],
aside: [],
audio: [
"autoplay",
"controls",
"crossorigin",
"loop",
"muted",
"preload",
"s... | default settings
@author Zongmin Lei<leizongmin@gmail.com> | getDefaultWhiteList | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function onTag(tag, html, options) {
// do nothing
} | default onTag function
@param {String} tag
@param {String} html
@param {Object} options
@return {String} | onTag | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function onIgnoreTag(tag, html, options) {
// do nothing
} | default onIgnoreTag function
@param {String} tag
@param {String} html
@param {Object} options
@return {String} | onIgnoreTag | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function onTagAttr(tag, name, value) {
// do nothing
} | default onTagAttr function
@param {String} tag
@param {String} name
@param {String} value
@return {String} | onTagAttr | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function onIgnoreTagAttr(tag, name, value) {
// do nothing
} | default onIgnoreTagAttr function
@param {String} tag
@param {String} name
@param {String} value
@return {String} | onIgnoreTagAttr | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function escapeHtml(html) {
return html.replace(REGEXP_LT, "<").replace(REGEXP_GT, ">");
} | default escapeHtml function
@param {String} html | escapeHtml | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function safeAttrValue(tag, name, value, cssFilter) {
// unescape attribute value firstly
value = friendlyAttrValue(value);
if (name === "href" || name === "src") {
// filter `href` and `src` attribute
// only allow the value that starts with `http://` | `https://` | `mailto:` | `/` | `#`
value = _.t... | default safeAttrValue function
@param {String} tag
@param {String} name
@param {String} value
@param {Object} cssFilter
@return {String} | safeAttrValue | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function escapeQuote(str) {
return str.replace(REGEXP_QUOTE, """);
} | escape double quote
@param {String} str
@return {String} str | escapeQuote | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function unescapeQuote(str) {
return str.replace(REGEXP_QUOTE_2, '"');
} | unescape double quote
@param {String} str
@return {String} str | unescapeQuote | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function escapeHtmlEntities(str) {
return str.replace(REGEXP_ATTR_VALUE_1, function replaceUnicode(str, code) {
return code[0] === "x" || code[0] === "X"
? String.fromCharCode(parseInt(code.substr(1), 16))
: String.fromCharCode(parseInt(code, 10));
});
} | escape html entities
@param {String} str
@return {String} | escapeHtmlEntities | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function escapeDangerHtml5Entities(str) {
return str
.replace(REGEXP_ATTR_VALUE_COLON, ":")
.replace(REGEXP_ATTR_VALUE_NEWLINE, " ");
} | escape html5 new danger entities
@param {String} str
@return {String} | escapeDangerHtml5Entities | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function clearNonPrintableCharacter(str) {
var str2 = "";
for (var i = 0, len = str.length; i < len; i++) {
str2 += str.charCodeAt(i) < 32 ? " " : str.charAt(i);
}
return _.trim(str2);
} | clear nonprintable characters
@param {String} str
@return {String} | clearNonPrintableCharacter | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function friendlyAttrValue(str) {
str = unescapeQuote(str);
str = escapeHtmlEntities(str);
str = escapeDangerHtml5Entities(str);
str = clearNonPrintableCharacter(str);
return str;
} | get friendly attribute value
@param {String} str
@return {String} | friendlyAttrValue | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function escapeAttrValue(str) {
str = escapeQuote(str);
str = escapeHtml(str);
return str;
} | unescape attribute value
@param {String} str
@return {String} | escapeAttrValue | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function onIgnoreTagStripAll() {
return "";
} | `onIgnoreTag` function for removing all the tags that are not in whitelist | onIgnoreTagStripAll | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.