minigame 5 jumper 1.4
This commit is contained in:
@@ -2630,6 +2630,50 @@
|
||||
});
|
||||
}
|
||||
|
||||
function updateSpaceShooterShipPreview(slot) {
|
||||
var img = el('space-shooter-ship-prev-' + slot);
|
||||
var inp = el('space-shooter-ship-url-' + slot);
|
||||
if (!img) return;
|
||||
var v = inp && inp.value ? String(inp.value).trim() : '';
|
||||
if (!v) {
|
||||
img.removeAttribute('src');
|
||||
img.alt = '';
|
||||
return;
|
||||
}
|
||||
if (!/^https?:\/\//i.test(v) && v.charAt(0) !== '/') v = '/' + v.replace(/^\/+/, '');
|
||||
img.alt = 'Ship slot ' + slot;
|
||||
img.src = v;
|
||||
}
|
||||
|
||||
function bindSpaceShooterShipUrlInputs() {
|
||||
for (var s = 1; s <= 6; s++) {
|
||||
(function (slot) {
|
||||
var inp = el('space-shooter-ship-url-' + slot);
|
||||
var btn = el('btn-space-shooter-ship-clear-' + slot);
|
||||
if (inp) {
|
||||
inp.addEventListener('change', function () { updateSpaceShooterShipPreview(slot); });
|
||||
inp.addEventListener('blur', function () { updateSpaceShooterShipPreview(slot); });
|
||||
}
|
||||
if (btn) {
|
||||
btn.addEventListener('click', function () {
|
||||
var i = el('space-shooter-ship-url-' + slot);
|
||||
if (i) i.value = '';
|
||||
updateSpaceShooterShipPreview(slot);
|
||||
});
|
||||
}
|
||||
})(s);
|
||||
}
|
||||
}
|
||||
|
||||
function readSpaceShooterShipImageUrlsFromForm() {
|
||||
var urls = [];
|
||||
for (var i = 1; i <= 6; i++) {
|
||||
var inp = el('space-shooter-ship-url-' + i);
|
||||
urls.push(inp && inp.value ? String(inp.value).trim() : '');
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
function loadSpaceShooterTimingPanel() {
|
||||
gameTimingFetch('GET')
|
||||
.then(function (data) {
|
||||
@@ -2638,6 +2682,13 @@
|
||||
var ss = Number(data.spaceShooterMissionTimeSec);
|
||||
inpT.value = String(Number.isFinite(ss) && ss > 0 ? Math.floor(ss) : 0);
|
||||
}
|
||||
var urls = data.spaceShooterShipImageUrls;
|
||||
if (!Array.isArray(urls)) urls = [];
|
||||
for (var k = 1; k <= 6; k++) {
|
||||
var inpU = el('space-shooter-ship-url-' + k);
|
||||
if (inpU) inpU.value = urls[k - 1] != null ? String(urls[k - 1]) : '';
|
||||
updateSpaceShooterShipPreview(k);
|
||||
}
|
||||
setMsg('space-shooter-timing-msg', '', '');
|
||||
})
|
||||
.catch(function (e) {
|
||||
@@ -2649,9 +2700,11 @@
|
||||
var limSs = el('space-shooter-mission-sec') ? parseInt(String(el('space-shooter-mission-sec').value), 10) : 0;
|
||||
if (Number.isNaN(limSs) || limSs < 0) limSs = 0;
|
||||
limSs = limSs <= 0 ? 0 : Math.max(10, Math.min(7200, limSs));
|
||||
var shipUrls = readSpaceShooterShipImageUrlsFromForm();
|
||||
gameTimingFetch('GET')
|
||||
.then(function (data) {
|
||||
data.spaceShooterMissionTimeSec = limSs;
|
||||
data.spaceShooterShipImageUrls = shipUrls;
|
||||
return gameTimingFetch('PUT', data);
|
||||
})
|
||||
.then(function () {
|
||||
@@ -2887,6 +2940,7 @@
|
||||
if (btnSpaceShooterSave) {
|
||||
btnSpaceShooterSave.addEventListener('click', saveSpaceShooterTimingPanel);
|
||||
}
|
||||
bindSpaceShooterShipUrlInputs();
|
||||
var btnStackGameSave = el('btn-stack-game-save');
|
||||
if (btnStackGameSave) {
|
||||
btnStackGameSave.addEventListener('click', saveStackGamePanel);
|
||||
|
||||
Reference in New Issue
Block a user