Skip to content

Commit 85b95a2

Browse files
authored
Merge pull request #3945 from w00000dy/Webpage-shortcuts
Add Webpage shortcuts and Fix resizing bug
2 parents 4df936a + 736a8b1 commit 85b95a2

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

wled00/data/index.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ function onLoad()
272272

273273
selectSlot(0);
274274
updateTablinks(0);
275+
handleLocationHash();
275276
cpick.on("input:end", () => {setColor(1);});
276277
cpick.on("color:change", () => {updatePSliders()});
277278
pmtLS = localStorage.getItem('wledPmt');
@@ -304,7 +305,6 @@ function updateTablinks(tabI)
304305
{
305306
var tablinks = gEBCN("tablinks");
306307
for (var i of tablinks) i.classList.remove('active');
307-
if (pcMode) return;
308308
tablinks[tabI].classList.add('active');
309309
}
310310

@@ -315,6 +315,21 @@ function openTab(tabI, force = false)
315315
_C.classList.toggle('smooth', false);
316316
_C.style.setProperty('--i', iSlide);
317317
updateTablinks(tabI);
318+
switch (tabI) {
319+
case 0: window.location.hash = "Colors"; break;
320+
case 1: window.location.hash = "Effects"; break;
321+
case 2: window.location.hash = "Segments"; break;
322+
case 3: window.location.hash = "Presets"; break;
323+
}
324+
}
325+
326+
function handleLocationHash() {
327+
switch (window.location.hash) {
328+
case "#Colors": openTab(0); break;
329+
case "#Effects": openTab(1); break;
330+
case "#Segments": openTab(2); break;
331+
case "#Presets": openTab(3); break;
332+
}
318333
}
319334

320335
var timeout;
@@ -3051,8 +3066,7 @@ function togglePcMode(fromB = false)
30513066
pcMode = (wW >= 1024) && pcModeA;
30523067
if (cpick) cpick.resize(pcMode && wW>1023 && wW<1250 ? 230 : 260); // for tablet in landscape
30533068
if (!fromB && ((wW < 1024 && lastw < 1024) || (wW >= 1024 && lastw >= 1024))) return; // no change in size and called from size()
3054-
openTab(0, true);
3055-
updateTablinks(0);
3069+
if (pcMode) openTab(0, true);
30563070
gId('buttonPcm').className = (pcMode) ? "active":"";
30573071
gId('bot').style.height = (pcMode && !cfg.comp.pcmbot) ? "0":"auto";
30583072
sCol('--bh', gId('bot').clientHeight + "px");
@@ -3214,6 +3228,7 @@ size();
32143228
_C.style.setProperty('--n', N);
32153229

32163230
window.addEventListener('resize', size, true);
3231+
window.addEventListener('hashchange', handleLocationHash);
32173232

32183233
_C.addEventListener('mousedown', lock, false);
32193234
_C.addEventListener('touchstart', lock, false);

0 commit comments

Comments
 (0)