Skip to content

Commit ad5a8ba

Browse files
committed
Публикация исправлений
1 parent 9896ade commit ad5a8ba

1 file changed

Lines changed: 32 additions & 8 deletions

File tree

jsTimer.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function addTimer_Mil(milliSeconds)
197197
var text = te.value;
198198
te.value = '';
199199

200-
var id = getNewId(timersObject.timers);
200+
var id = getNewId();
201201
addTimer(id, milliSeconds, text);
202202

203203
hideAlert();
@@ -439,11 +439,35 @@ function addTimer24()
439439
var ID = 1;
440440
function getNewId(timers)
441441
{
442-
var id = ID;
443-
for (var cur of timers)
442+
var id;
443+
if (!timers)
444444
{
445-
if (cur.id >= id)
446-
id = cur.id + 1;
445+
var ids = [];
446+
ids.push
447+
(
448+
{id: ID}
449+
);
450+
451+
ids.push
452+
(
453+
{id: getNewId(timersObject.saved)}
454+
);
455+
456+
ids.push
457+
(
458+
{ id: getNewId(timersObject.timers)}
459+
);
460+
461+
id = getNewId(ids)
462+
}
463+
else
464+
{
465+
id = ID;
466+
for (var cur of timers)
467+
{
468+
if (cur.id >= id)
469+
id = cur.id + 1;
470+
}
447471
}
448472

449473
ID = id + 1;
@@ -1030,7 +1054,7 @@ function onClickToSavedTimer(Element, timer, addImmediately, timerType)
10301054

10311055
if (addImmediately || mouseEvent.shiftKey)
10321056
{
1033-
var id = getNewId(timersObject.timers);
1057+
var id = getNewId();
10341058
addTimer(id, 1000*(timer.h*3600 + timer.m*60 + timer.s), val);
10351059

10361060
// Контекстное меню не должно появится (здесь - от клика на таймер)
@@ -1151,7 +1175,7 @@ function MergeTimers(text)
11511175
}
11521176

11531177
if (!found)
1154-
addTimer(getNewId(timersObject.timers), cur.end, cur.text, true, true);
1178+
addTimer(getNewId(), cur.end, cur.text, true, true);
11551179
}
11561180
catch (e)
11571181
{
@@ -1369,7 +1393,7 @@ function addSavedTimer(id, h, m, s, timerName, savedInterval, toDelete, isContro
13691393
h: h,
13701394
m: m,
13711395
s: s,
1372-
id: id || getNewId(timersObject.saved),
1396+
id: id || getNewId(),
13731397

13741398
totalSeconds: seconds,
13751399
name: timerName,

0 commit comments

Comments
 (0)