PageSourceSearch

https://www.mineshop.ch/bundles/mineshopportalleiste/werkzeuge/varianten.js?v=20260924b

js mineshop.ch collected 2026-10-08 07:57:39 UTC 3,218 bytes, 45 lines download raw bytes

1/* MineShop varianten.js v3 (Rahmen weicher abgestimmt, Wunsch Noli)
2   v1 (26.08.2026, Noli)
3   Kuerzt die Options-Texte der VariantMatcher-Dropdowns: gemeinsamen Wort-Anfang
4   und Wort-Schluss aller Optionen entfernen ("Apple iPhone 17 Pro Max 256 GB Silver"
5   -> "256 GB"). Bliebe nur eine nackte Zahl uebrig, wird das erste entfernte
6   Schlusswort als Einheit zurueckgeholt ("2 kg"). Beginnen alle Kurztexte mit einer
7   Zahl, werden die Optionen aufsteigend sortiert (256 vor 512 vor 1000 vor 2000).
8   Rein kosmetisch im Browser - Serverdaten bleiben unberuehrt. */
9(function(){
10  "use strict";
11  /* v2: Auswahlrahmen deutlich sichtbar - dunkelgrau, beim Zeigen/Fokus MineShop-Orange */
12  var s=document.createElement("style");
13  s.id="ms-varianten-stil";
14  s.textContent=".product-detail-configurator select.form-select, select.form-select[onchange*='window.location']{border:1.5px solid #8a939b !important; border-radius:8px; font-weight:500; cursor:pointer;} .product-detail-configurator select.form-select:hover, .product-detail-configurator select.form-select:focus, select.form-select[onchange*='window.location']:hover, select.form-select[onchange*='window.location']:focus{border-color:#f8821f !important; box-shadow:0 0 0 2px rgba(248,130,31,.12);}";
15  if(!document.getElementById("ms-varianten-stil")) document.head.appendChild(s);
16  function kuerzen(sel){
17    if (sel.dataset.msVarianten) return;
18    var opts = Array.prototype.slice.call(sel.options);
19    if (opts.length < 2) return;
20    var worte = opts.map(function(o){ return o.text.trim().split(/\s+/); });
21    var minL = Math.min.apply(null, worte.map(function(w){ return w.length; }));
22    var vorn = 0;
23    while (vorn < minL - 1 && worte.every(function(w){ return w[vorn] === worte[0][vorn]; })) vorn++;
24    var hinten = 0, einheit = "";
25    while (hinten < minL - vorn - 1 && worte.every(function(w){ return w[w.length-1-hinten] === worte[0][worte[0].length-1-hinten]; })) hinten++;
26    if (hinten > 0) einheit = worte[0][worte[0].length - hinten];
27    var kurz = worte.map(function(w){ return w.slice(vorn, w.length - hinten).join(" "); });
28    if (kurz.some(function(k){ return !k; })) return; /* lieber nichts tun als leere Eintraege */
29    kurz = kurz.map(function(k){ return /^[0-9]+([.,'][0-9]+)?$/.test(k) && einheit ? k + " " + einheit : k; });
30    var nummern = kurz.map(function(k){ var m = k.match(/^([0-9]+(?:[.,][0-9]+)?)/); return m ? parseFloat(m[1].replace(",", ".")) : null; });
31    opts.forEach(function(o, i){ o.text = kurz[i]; });
32    if (nummern.every(function(n){ return n !== null; })){
33      var reihen = opts.map(function(o, i){ return { o: o, n: nummern[i] }; })
34        .sort(function(a, b){ return a.n - b.n; });
35      reihen.forEach(function(r){ sel.appendChild(r.o); });
36    }
37    sel.dataset.msVarianten = "1";
38  }
39  function lauf(){
40    document.querySelectorAll(".product-detail-configurator select.form-select, select.form-select[onchange*='window.location']")
41      .forEach(kuerzen);
42  }
43  if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", lauf); else lauf();
44  new MutationObserver(lauf).observe(document.documentElement, { childList: true, subtree: true });
45})();

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.