PageSourceSearch

https://poe2lens.com/js/high_value_affixes/tablet_hv_price_store.js?v=20260926c

js poe2lens.com collected 2026-10-02 01:40:28 UTC 4,297 bytes, 135 lines download raw bytes

1/**
2 * Tablet HV price profiles via ToolSettingsStore (separate from favorites).
3 * toolKey: poe2_tablet_hv_prices
4 */
5(function (global) {
6    'use strict';
7
8    var TOOL_KEY = 'poe2_tablet_hv_prices';
9    var LOCAL_KEY = 'poe2_tablet_hv_prices_local_v1';
10
11    function emptyPayload() {
12        return { overrides: {} };
13    }
14
15    function countItems(profile) {
16        var o = (profile && profile.overrides) || {};
17        return Object.keys(o).length;
18    }
19
20    function stripMarket(profile) {
21        if (!profile) return;
22        profile.overrides = {};
23    }
24
25    function copyNonMarket(src, dest) {
26        dest.overrides = {};
27    }
28
29    function itemStableId(item) {
30        if (!item) return '';
31        var ids = [];
32        if (Array.isArray(item.affixes) && item.affixes.length) {
33            ids = item.affixes.map(function (x) {
34                return String(x);
35            });
36        } else if (Array.isArray(item.affix_labels) && item.affix_labels.length) {
37            ids = item.affix_labels.map(function (lab) {
38                return String((lab && lab.id) || '');
39            });
40        }
41        ids = ids.filter(Boolean).slice().sort();
42        return ids.join('+');
43    }
44
45    function priceKey(tabletKey, itemOrStableId) {
46        var sid =
47            typeof itemOrStableId === 'string'
48                ? itemOrStableId
49                : itemStableId(itemOrStableId);
50        return String(tabletKey || '') + '::' + sid;
51    }
52
53    function createStore() {
54        if (!global.ToolSettingsStore) return null;
55        return global.ToolSettingsStore.create({
56            toolKey: TOOL_KEY,
57            localKey: LOCAL_KEY,
58            multiProfile: true,
59            emptyPayload: emptyPayload,
60            countItems: countItems,
61            stripMarketOnDefault: stripMarket,
62            copyNonMarketFields: copyNonMarket,
63            feedbackTool: 'poe2_tablet_hv'
64        });
65    }
66
67    function getOverride(store, tabletKey, item) {
68        if (!store) return null;
69        var p = store.activeProfile();
70        var o = (p && p.overrides) || {};
71        return o[priceKey(tabletKey, item)] || null;
72    }
73
74    function round1(n) {
75        return Math.round(Number(n) * 10) / 10;
76    }
77
78    function setOverrideField(store, tabletKey, item, field, value) {
79        if (!store) return;
80        store.ensureWritableForMarket();
81        var p = store.activeProfile();
82        if (!p.overrides) p.overrides = {};
83        var k = priceKey(tabletKey, item);
84        var cur = Object.assign({}, p.overrides[k] || {});
85        if (value == null || value === '' || !isFinite(Number(value))) {
86            cur[field] = null;
87        } else {
88            cur[field] = round1(value);
89        }
90        if (cur.normal_d == null && cur.high_roll_d == null) {
91            delete p.overrides[k];
92        } else {
93            p.overrides[k] = cur;
94        }
95        store._emit();
96    }
97
98    /**
99     * Display price: override ?? observed
100     */
101    function displayNormal(store, tabletKey, item, observed) {
102        var ov = getOverride(store, tabletKey, item);
103        if (ov && ov.normal_d != null && isFinite(Number(ov.normal_d))) {
104            return round1(ov.normal_d);
105        }
106        if (observed != null && observed !== '' && isFinite(Number(observed))) {
107            return round1(observed);
108        }
109        return null;
110    }
111
112    function displayHighRoll(store, tabletKey, item, observed) {
113        var ov = getOverride(store, tabletKey, item);
114        if (ov && ov.high_roll_d != null && isFinite(Number(ov.high_roll_d))) {
115            return round1(ov.high_roll_d);
116        }
117        if (observed != null && observed !== '' && isFinite(Number(observed))) {
118            return round1(observed);
119        }
120        return null;
121    }
122
123    global.TabletHvPriceStore = {
124        TOOL_KEY: TOOL_KEY,
125        LOCAL_KEY: LOCAL_KEY,
126        createStore: createStore,
127        itemStableId: itemStableId,
128        priceKey: priceKey,
129        getOverride: getOverride,
130        setOverrideField: setOverrideField,
131        displayNormal: displayNormal,
132        displayHighRoll: displayHighRoll,
133        round1: round1
134    };
135})(window);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.