-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathyeswiki-base-no-defer.js
39 lines (38 loc) · 1.15 KB
/
yeswiki-base-no-defer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function _t(message, replacements = {}) {
let translation = typeof wiki !== 'undefined'
&& wiki.lang !== undefined
? (wiki.lang[message] ?? null) : null
if (!translation) {
translation = message
if (typeof wiki !== 'undefined' && wiki.isDebugEnabled) {
console.warn(`Translation was not found in wiki.lang for "${message}", (wiki.locale = ${wiki.locale})`)
}
}
for (const key in replacements) {
while (translation.includes(`{${key}}`)) {
translation = translation.replace(`{${key}}`, replacements[key])
}
}
return translation
}
var wiki = {
...((typeof wiki !== 'undefined') ? wiki : null),
...{
url(url, params = {}) {
let result = wiki.baseUrl + url
result = result.replace('??', '?')
stringParams = []
for (const key in params) {
stringParams.push(`${key}=${encodeURIComponent(params[key])}`)
}
if (stringParams.length) {
result += result.includes('?') ? '&' : '?'
result += stringParams.join('&')
}
return result
},
cssVar(varName) {
return getComputedStyle(document.documentElement).getPropertyValue(varName)
}
}
}