Poniżej masz kompletną, zaktualizowaną wersję pliku HTML.
Jedyne zmiany względem poprzedniej odsłony to:
padding‐top i padding‐bottom ustawione na 75 vh (3/4 ekranu),
korekta wzoru stopPoint, aby zatrzymanie przewijania było spójne z nowym punktem startowym (0.75 * wysokość okna).
Gotowy plik możesz po prostu nadpisać poprzedni.
html Copy code
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prosty Prompter</title>
<style>
body{font-family:Arial,Helvetica,sans-serif;margin:0;padding:0;background:#f4f4f4}
/* ---------- PANEL KONFIGURACYJNY ---------- */
#config-panel{max-width:800px;margin:20px auto;padding:20px;background:#fff;box-shadow:0 0 10px rgba(0,0,0,.1)}
textarea{width:100%;height:200px;margin-bottom:15px;padding:10px;box-sizing:border-box}
.control-group{margin-bottom:15px}
label{display:block;margin-bottom:5px;font-weight:bold}
input[type=range],input[type=color],input[type=file]{width:100%}
button{padding:10px 20px;font-size:16px;cursor:pointer;border:none;border-radius:4px;background:#4caf50;color:#fff}
button:hover{background:#45a049}
/* ---------- EKRAN PROMPTERA ---------- */
#prompter-screen{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:#000;overflow:hidden;cursor:pointer}
/* --- KLUCZOWA ZMIANA: padding 75vh --- */
#prompter-text{
color:#fff;
padding:75vh 10% 75vh; /* górny i dolny padding = 3/4 ekranu */
text-align:left;
line-height:1.5;
transform:translateY(0);
will-change:transform
}
/* ---------- NAKŁADKA KONTROLNA ---------- */
#controls-overlay{
position:fixed;bottom:10px;left:50%;transform:translateX(-50%);
background:rgba(255,255,255,.8);padding:10px;border-radius:5px;
display:none;z-index:10;white-space:nowrap
}
.speed-control{margin:0 10px;display:inline-block}
#current-speed{min-width:70px;text-align:center;font-family:monospace;font-weight:bold}
</style>
</head>
<body>
<!-- ======================================== -->
<!-- PANEL KONFIGURACYJNY -->
<!-- ======================================== -->
<div id="config-panel">
<h1>Ustawienia Promptera</h1>
<div class="control-group">
<label for="text-input">Wklej tekst lub załaduj plik .txt:</label>
<input type="file" id="file-input" accept=".txt" style="margin-bottom:10px">
<textarea id="text-input" placeholder="Wklej tutaj swój tekst..."></textarea>
</div>
<div class="control-group">
<label for="font-size">Wielkość czcionki: <span id="font-size-value">60</span> px</label>
<input type="range" id="font-size" min="20" max="150" value="60">
</div>
<div class="control-group">
<label for="speed">Szybkość przewijania: <span id="speed-value">0.1875</span></label>
<input type="range" id="speed" min="0.0125" max="1.25" value="0.1875" step="0.0125">
</div>
<div class="control-group">
<label for="font-color">Kolor czcionki:</label>
<input type="color" id="font-color" value="#FFFFFF">
</div>
<button onclick="startPrompter()">Startuj Prompter</button>
</div>
<!-- ======================================== -->
<!-- EKRAN PROMPTERA -->
<!-- ======================================== -->
<div id="prompter-screen">
<div id="prompter-text"></div>
</div>
<!-- ======================================== -->
<!-- OVERLAY Z PRZYCISKAMI PODCZAS PRACY -->
<!-- ======================================== -->
<div id="controls-overlay">
<button onclick="togglePause()">Pauza/Wznów (Spacja)</button>
<button onclick="exitPrompter()">Wyjdź (Esc)</button>
<span class="speed-control">
Szybkość:
<button onclick="decreaseSpeed()">-</button>
<span id="current-speed">0.1875</span>
<button onclick="increaseSpeed()">+</button>
</span>
</div>
<script>
/* ========= ELEMENTY DOM ========= */
const configPanel=document.getElementById('config-panel');
const prompterScreen=document.getElementById('prompter-screen');
const prompterText=document.getElementById('prompter-text');
const controlsOverlay=document.getElementById('controls-overlay');
const textInput=document.getElementById('text-input');
const fontSizeInput=document.getElementById('font-size');
const speedInput=document.getElementById('speed');
const fontColorInput=document.getElementById('font-color');
const fileInput=document.getElementById('file-input');
const speedVal=document.getElementById('speed-value');
const currentSpeedDisplay=document.getElementById('current-speed');
/* ========= ZMIENNE STANU ========= */
let animationFrameId=null;
let isPaused=false;
let currentScrollY=0;
let speed=0.1875;
const speedStep=0.0125;
const minSpeed=0.0125;
const maxSpeed=1.25;
let accumulatedDelta=0;
/* ========= POMOCNICZE ========= */
fontSizeInput.oninput=()=>{document.getElementById('font-size-value').innerText=fontSizeInput.value};
speedInput.oninput=()=>{
speed=parseFloat(speedInput.value);
speedVal.innerText=speed.toFixed(4);
currentSpeedDisplay.innerText=speed.toFixed(4);
};
function updateSpeedDisplay(){currentSpeedDisplay.innerText=speed.toFixed(4);speedVal.innerText=speed.toFixed(4)}
function increaseSpeed(){speed=Math.min(maxSpeed,speed+speedStep);updateSpeedDisplay()}
function decreaseSpeed(){speed=Math.max(minSpeed,speed-speedStep);updateSpeedDisplay()}
fileInput.addEventListener('change',e=>{
const file=e.target.files[0];
if(file?.type==="text/plain"){
const reader=new FileReader();
reader.onload=ev=>{textInput.value=ev.target.result};
reader.readAsText(file);
}else if(file){alert("Proszę wybrać plik tekstowy (.txt)");}
});
/* ========= GŁÓWNA PĘTLA SCROLL ========= */
function scrollPrompter(){
if(isPaused){animationFrameId=requestAnimationFrame(scrollPrompter);return;}
accumulatedDelta+=speed;
if(Math.abs(accumulatedDelta)>=0.01){
const move=Math.floor(accumulatedDelta);
currentScrollY-=move;
accumulatedDelta-=move;
prompterText.style.transform=`translateY(${currentScrollY}px)`;
}
/* ---- KLUCZOWA ZMIANA: stopPoint dla 75 vh ---- */
const stopPoint=(window.innerHeight*0.75)-prompterText.offsetHeight;
if(currentScrollY<stopPoint){stopScrolling();}
else{animationFrameId=requestAnimationFrame(scrollPrompter);}
}
function startScrolling(){
if(!animationFrameId){
accumulatedDelta=0;
animationFrameId=requestAnimationFrame(scrollPrompter);
}
}
function stopScrolling(){
if(animationFrameId){cancelAnimationFrame(animationFrameId);animationFrameId=null;}
}
/* ========= URUCHOMIENIE ========= */
function startPrompter(){
const html=textInput.value.replace(/\n/g,'<br>');
if(!html.trim()){alert("Proszę wkleić tekst lub załadować plik.");return;}
prompterText.style.fontSize=`${fontSizeInput.value}px`;
prompterText.style.color=fontColorInput.value;
speed=parseFloat(speedInput.value);updateSpeedDisplay();
prompterText.innerHTML=html;
configPanel.style.display='none';
prompterScreen.style.display='block';
controlsOverlay.style.display='block';
currentScrollY=0;
prompterText.style.transform='translateY(0px)';
isPaused=false;
startScrolling();
}
/* ========= KLAWISZE & PRZYCISKI ========= */
function togglePause(){isPaused=!isPaused}
function exitPrompter(){stopScrolling();configPanel.style.display='block';prompterScreen.style.display='none';controlsOverlay.style.display='none'}
document.addEventListener('keydown',e=>{
if(prompterScreen.style.display==='block'){
if(e.code==='Space'){e.preventDefault();togglePause();}
else if(e.code==='Escape'){exitPrompter();}
else if(e.code==='ArrowUp'){e.shiftKey?speed=Math.min(maxSpeed,speed+speedStep/2):increaseSpeed();e.preventDefault();updateSpeedDisplay();}
else if(e.code==='ArrowDown'){e.shiftKey?speed=Math.max(minSpeed,speed-speedStep/2):decreaseSpeed();e.preventDefault();updateSpeedDisplay();}
}
});
</script>
</body>
</html>
Po uruchomieniu zobaczysz, że pierwszy wiersz tekstu pojawia się dokładnie na wysokości 3/4 ekranu, a całość przewija się w górę z zachowaniem dotychczasowych ustawień prędkości, pauzy, kolorów itp. Daj znać, jeśli potrzebujesz kolejnych zmian!