MediaWiki:Gadget-CurrencyConverter.js: различия между версиями
Hloth (обсуждение | вклад) Нет описания правки |
Hloth (обсуждение | вклад) demovio.lol -> demovio.love |
||
| (не показаны 4 промежуточные версии этого же участника) | |||
| Строка 1: | Строка 1: | ||
var _a; | /* CSS: https://wiki.demovio.lovel/MediaWiki:Gadget-CurrencyConverter.css */ | ||
var _a, _b, _c; | |||
const DEV = false; | const DEV = false; | ||
var is_array = Array.isArray; | var is_array = Array.isArray; | ||
| Строка 475: | Строка 477: | ||
), | ), | ||
wv: 0, | wv: 0, | ||
parent: parent_derived ? | parent: parent_derived != null ? parent_derived : active_effect | ||
}; | }; | ||
return signal; | return signal; | ||
| Строка 538: | Строка 540: | ||
} | } | ||
function create_effect(type, fn, sync, push2 = true) { | function create_effect(type, fn, sync, push2 = true) { | ||
var _a2; | |||
var parent = active_effect; | var parent = active_effect; | ||
var effect2 = { | var effect2 = { | ||
| Строка 576: | Строка 579: | ||
active_reaction | active_reaction | ||
); | ); | ||
(derived2.effects ? | ((_a2 = derived2.effects) != null ? _a2 : derived2.effects = []).push(effect2); | ||
} | } | ||
} | } | ||
| Строка 773: | Строка 776: | ||
} | } | ||
function check_dirtiness(reaction) { | function check_dirtiness(reaction) { | ||
var _a2; | var _a2, _b2; | ||
var flags = reaction.f; | var flags = reaction.f; | ||
if ((flags & DIRTY) !== 0) { | if ((flags & DIRTY) !== 0) { | ||
| Строка 796: | Строка 799: | ||
dependency = dependencies[i]; | dependency = dependencies[i]; | ||
if (is_disconnected || !((_a2 = dependency == null ? void 0 : dependency.reactions) == null ? void 0 : _a2.includes(derived2))) { | if (is_disconnected || !((_a2 = dependency == null ? void 0 : dependency.reactions) == null ? void 0 : _a2.includes(derived2))) { | ||
(dependency.reactions ? | ((_b2 = dependency.reactions) != null ? _b2 : dependency.reactions = []).push(derived2); | ||
} | } | ||
} | } | ||
| Строка 835: | Строка 838: | ||
current.fn(error); | current.fn(error); | ||
return; | return; | ||
} catch { | } catch (e) { | ||
current.f ^= BOUNDARY_EFFECT; | current.f ^= BOUNDARY_EFFECT; | ||
} | } | ||
| Строка 891: | Строка 894: | ||
} | } | ||
function update_reaction(reaction) { | function update_reaction(reaction) { | ||
var _a2; | var _a2, _b2; | ||
var previous_deps = new_deps; | var previous_deps = new_deps; | ||
var previous_skipped_deps = skipped_deps; | var previous_skipped_deps = skipped_deps; | ||
| Строка 930: | Строка 933: | ||
if (!skip_reaction) { | if (!skip_reaction) { | ||
for (i = skipped_deps; i < deps.length; i++) { | for (i = skipped_deps; i < deps.length; i++) { | ||
((_a2 = deps[i]).reactions ? | ((_b2 = (_a2 = deps[i]).reactions) != null ? _b2 : _a2.reactions = []).push(reaction); | ||
} | } | ||
} | } | ||
| Строка 1407: | Строка 1410: | ||
} | } | ||
function set_text(text, value) { | function set_text(text, value) { | ||
var _a2; | |||
var str = value == null ? "" : typeof value === "object" ? value + "" : value; | var str = value == null ? "" : typeof value === "object" ? value + "" : value; | ||
if (str !== (text.__t ? | if (str !== ((_a2 = text.__t) != null ? _a2 : text.__t = text.nodeValue)) { | ||
text.__t = str; | text.__t = str; | ||
text.nodeValue = str + ""; | text.nodeValue = str + ""; | ||
| Строка 1440: | Строка 1444: | ||
var component = void 0; | var component = void 0; | ||
var unmount = component_root(() => { | var unmount = component_root(() => { | ||
var anchor_node = anchor ? | var anchor_node = anchor != null ? anchor : target.appendChild(create_text()); | ||
branch(() => { | branch(() => { | ||
if (context) { | if (context) { | ||
| Строка 1500: | Строка 1504: | ||
return clsx$1(value); | return clsx$1(value); | ||
} else { | } else { | ||
return value ? | return value != null ? value : ""; | ||
} | } | ||
} | } | ||
| Строка 1568: | Строка 1572: | ||
} | } | ||
function get_attributes(element) { | function get_attributes(element) { | ||
var _a2; | |||
return ( | return ( | ||
/** @type {Record<string | symbol, unknown>} **/ | /** @type {Record<string | symbol, unknown>} **/ | ||
// @ts-expect-error | // @ts-expect-error | ||
element.__attributes ? | (_a2 = element.__attributes) != null ? _a2 : element.__attributes = { | ||
[IS_CUSTOM_ELEMENT]: element.nodeName.includes("-"), | [IS_CUSTOM_ELEMENT]: element.nodeName.includes("-"), | ||
[IS_HTML]: element.namespaceURI === NAMESPACE_HTML | [IS_HTML]: element.namespaceURI === NAMESPACE_HTML | ||
} | } | ||
); | ); | ||
} | } | ||
| Строка 1605: | Строка 1610: | ||
var start = input.selectionStart; | var start = input.selectionStart; | ||
var end = input.selectionEnd; | var end = input.selectionEnd; | ||
input.value = value ? | input.value = value != null ? value : ""; | ||
if (end !== null) { | if (end !== null) { | ||
input.selectionStart = start; | input.selectionStart = start; | ||
| Строка 1630: | Строка 1635: | ||
} | } | ||
if (value !== input.value) { | if (value !== input.value) { | ||
input.value = value ? | input.value = value != null ? value : ""; | ||
} | } | ||
}); | }); | ||
| Строка 1643: | Строка 1648: | ||
const PUBLIC_VERSION = "5"; | const PUBLIC_VERSION = "5"; | ||
if (typeof window !== "undefined") { | if (typeof window !== "undefined") { | ||
((_a = window.__svelte ? | ((_c = (_b = (_a = window.__svelte) != null ? _a : window.__svelte = {}).v) != null ? _c : _b.v = /* @__PURE__ */ new Set()).add(PUBLIC_VERSION); | ||
} | } | ||
enable_legacy_mode_flag(); | enable_legacy_mode_flag(); | ||
| Строка 1680: | Строка 1685: | ||
}; | }; | ||
const diamondIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAIVBMVEUAAAD////V//ah++hK7dks4NggxbUaqqcckZoRcnoUXlN/hNeyAAAAAXRSTlMAQObYZgAAAF1JREFUeNpjwApmzoTQnIJCE8CMiS5GWWABEWNltwVghpCQC4gx0dHFuKwKxHByNm4DM8SMTdpBjEku5eVpXUAGl3taWtkCECM8La0YxGBY4WKcBTaZa9WqBUg2AwByXRcdUQ3W3QAAAABJRU5ErkJggg=="; | const diamondIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAIVBMVEUAAAD////V//ah++hK7dks4NggxbUaqqcckZoRcnoUXlN/hNeyAAAAAXRSTlMAQObYZgAAAF1JREFUeNpjwApmzoTQnIJCE8CMiS5GWWABEWNltwVghpCQC4gx0dHFuKwKxHByNm4DM8SMTdpBjEku5eVpXUAGl3taWtkCECM8La0YxGBY4WKcBTaZa9WqBUg2AwByXRcdUQ3W3QAAAABJRU5ErkJggg=="; | ||
var root_1$1 = /* @__PURE__ */ template(`<div class="coin svelte- | var root_1$1 = /* @__PURE__ */ template(`<div class="coin svelte-1rrj40a"><input> <img class="icon icon32px svelte-1rrj40a"></div>`); | ||
var root$ | var root$3 = /* @__PURE__ */ template(`<div class="convert svelte-1rrj40a"><div class="coins svelte-1rrj40a"><!> <!> <!> <!> <!> <!></div> <div class="result svelte-1rrj40a"><span>=</span> <strong> </strong> <div class="diamonds svelte-1rrj40a"> <img alt="Алмазы" class="icon icon24px svelte-1rrj40a"> )</div></div></div>`); | ||
function CurrencyToDiamonds($$anchor, $$props) { | function CurrencyToDiamonds($$anchor, $$props) { | ||
push($$props, true); | push($$props, true); | ||
| Строка 1699: | Строка 1704: | ||
const sum = /* @__PURE__ */ derived(() => get(numericValues).spur * spurNominal + get(numericValues).bevel * bevelNominal + get(numericValues).sprocket * sprocketNominal + get(numericValues).cog * cogNominal + get(numericValues).crown * crownNominal + get(numericValues).sun * sunNominal); | const sum = /* @__PURE__ */ derived(() => get(numericValues).spur * spurNominal + get(numericValues).bevel * bevelNominal + get(numericValues).sprocket * sprocketNominal + get(numericValues).cog * cogNominal + get(numericValues).crown * crownNominal + get(numericValues).sun * sunNominal); | ||
const diamonds = /* @__PURE__ */ derived(() => Math.round(get(sum) / oneDiamondCost)); | const diamonds = /* @__PURE__ */ derived(() => Math.round(get(sum) / oneDiamondCost)); | ||
var div = root$ | var div = root$3(); | ||
var div_1 = child(div); | var div_1 = child(div); | ||
{ | { | ||
| Строка 1710: | Строка 1715: | ||
($0) => { | ($0) => { | ||
set_attribute(div_2, "title", coins[name()].name); | set_attribute(div_2, "title", coins[name()].name); | ||
set_class(input, 1, $0, "svelte- | set_class(input, 1, $0, "svelte-1rrj40a"); | ||
set_attribute(img, "src", "data:image/png;base64," + coins[name()].icon); | set_attribute(img, "src", "data:image/png;base64," + coins[name()].icon); | ||
set_attribute(img, "alt", coins[name()].name); | set_attribute(img, "alt", coins[name()].name); | ||
| Строка 1742: | Строка 1747: | ||
set_attribute(img_1, "src", diamondIcon); | set_attribute(img_1, "src", diamondIcon); | ||
template_effect(() => { | template_effect(() => { | ||
var _a2; | |||
set_text(text, get(sum)); | set_text(text, get(sum)); | ||
set_text(text_1, `(~ ${get(diamonds) ? | set_text(text_1, `(~ ${(_a2 = get(diamonds)) != null ? _a2 : ""} `); | ||
}); | }); | ||
append($$anchor, div); | append($$anchor, div); | ||
pop(); | pop(); | ||
} | } | ||
var root_1 = /* @__PURE__ */ template(`<div class="coin svelte- | var root_1 = /* @__PURE__ */ template(`<div class="coin svelte-1u7m319"><span> </span> <img class="icon icon32px svelte-1u7m319"></div>`); | ||
var root$ | var root$2 = /* @__PURE__ */ template(`<div class="convert svelte-1u7m319"><div class="input svelte-1u7m319"><div class="diamonds svelte-1u7m319"><input type="text"> <img alt="Алмазы" class="icon icon24px svelte-1u7m319"></div> <span> </span></div> <div class="result"><span>=</span></div> <div class="coins svelte-1u7m319"><!> <!> <!> <!> <!> <!></div></div>`); | ||
function DiamondsToCurrency($$anchor, $$props) { | function DiamondsToCurrency($$anchor, $$props) { | ||
push($$props, true); | push($$props, true); | ||
| Строка 1774: | Строка 1780: | ||
return coins2; | return coins2; | ||
}); | }); | ||
var div = root$ | var div = root$2(); | ||
var div_1 = child(div); | var div_1 = child(div); | ||
var div_2 = child(div_1); | var div_2 = child(div_1); | ||
| Строка 1800: | Строка 1806: | ||
{ bold: get(coinsValues)[name()] > 0 } | { bold: get(coinsValues)[name()] > 0 } | ||
]), | ]), | ||
"svelte- | "svelte-1u7m319" | ||
); | ); | ||
set_text(text_1, get(coinsValues)[name()]); | set_text(text_1, get(coinsValues)[name()]); | ||
| Строка 1823: | Строка 1829: | ||
template_effect( | template_effect( | ||
($0) => { | ($0) => { | ||
classes = set_class(input, 1, "svelte- | var _a2; | ||
set_text(text, `(${get(sum) ? | classes = set_class(input, 1, "svelte-1u7m319", null, classes, $0); | ||
set_text(text, `(${(_a2 = get(sum)) != null ? _a2 : ""})`); | |||
}, | }, | ||
[ | [ | ||
| Строка 1836: | Строка 1843: | ||
pop(); | pop(); | ||
} | } | ||
var root = /* @__PURE__ */ template(`<!> <!>`, 1); | var root$1 = /* @__PURE__ */ template(`<!> <!>`, 1); | ||
function App($$anchor) { | function App($$anchor) { | ||
var fragment = root(); | var fragment = root$1(); | ||
var node = first_child(fragment); | var node = first_child(fragment); | ||
CurrencyToDiamonds(node, {}); | CurrencyToDiamonds(node, {}); | ||
| Строка 1844: | Строка 1851: | ||
DiamondsToCurrency(node_1, {}); | DiamondsToCurrency(node_1, {}); | ||
append($$anchor, fragment); | append($$anchor, fragment); | ||
} | |||
const root = document.getElementById("currency-converter-root"); | |||
if (root) { | |||
root.innerHTML = ""; | |||
} | } | ||
mount(App, { | mount(App, { | ||
target: | target: root | ||
}); | }); | ||