<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Reminders in Session - RJM Programming - December, 2020 ... thanks to https://stackoverflow.com/questions/32326721/pass-parameter-to-settimeout-callback-function/32326935</title>
<script type='text/javascript'>
var myfuncs=[];
var amsg = location.search.split('msg=')[1] ? decodeURIComponent(location.search.split('msg=')[1].split('&')[0]) : '';
var woises=[];
var options=[];
var documenttitle=document.title;
var dd1, dd2;
var thesedates=[];
var thesewords=[];
var theseseconds=[];
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
var hastobe='', hastobedec='';
var timeaway=0, origtimeaway=0;
var midprefix='';
var myfunc = function(x){xx=x;preprewois()};
var x = "test";
var xx="";
var firstgo=true;
var wois=null;
var nextson=1;
if (amsg == '') {
window.onbeforeunload = function() {
if (wois) {
if (!wois.closed) {
wois.close();
}
}
return false;
};
wois=window.open(document.URL.split('#')[0].split('?')[0] + '?msg=' + encodeURIComponent(' '),'_blank','top=250,left=800,width=500,height=500');
//wois.document.title='Only Minimize Me (or lose Dynamic Timer)';
//setTimeout(myfunc,100,x);
}
if (!String.fromCodePoint) { // thanks to http://xahlee.info/js/js_unicode_code_point.html
// ES6 Unicode Shims 0.1 , © 2012 Steven Levithan , MIT License
String.fromCodePoint = function fromCodePoint () {
var chars = [], point, offset, units, i;
for (i = 0; i < arguments.length; ++i) {
point = arguments[i];
offset = point - 0x10000;
units = point > 0xFFFF ? [0xD800 + (offset >> 10), 0xDC00 + (offset & 0x3FF)] : [point];
chars.push(String.fromCharCode.apply(null, units));
}
return chars.join("");
}
}
function soit(sois) {
var remsare=[], wrems=[];
if (sois.value != '') {
if (sois.value.trim() == '') {
var retso='', retson=1, thisso=' ', preretso='', postretso='', lastgood=1;
if (window.localStorage) {
while (thisso != '') {
thisso='';
if (localStorage.getItem('reminderso' + retson)) {
thisso=decodeURIComponent(localStorage.getItem('reminderso' + retson).replace(/^null$/g,'').replace(/^undefined$/g,'')).replace(/\+/g,' ');
}
if (thisso != '') {
retso+=thisso;
preretso='<option value="">Standing Order</option>';
postretso='<option value=" ">Delete Most Recent Standing Order</option>';
lastgood=retson;
}
retson++;
}
retson--;
alert(lastgood);
if (lastgood == 1) {
localStorage.removeItem('reminderso' + lastgood);
document.getElementById('sorems').innerHTML='';
document.getElementById('sorems').style.display='none';
} else if (lastgood > 1) {
localStorage.removeItem('reminderso' + lastgood);
var optsare=document.getElementById('sorems').innerHTML.split('<option value=');
document.getElementById('sorems').innerHTML=document.getElementById('sorems').innerHTML.replace('<option value=' + optsare[eval(-1 + optsare.length)].split('</option>')[0] + '</option>', '');
}
}
} else {
remsare=sois.value.split(';;');
for (var ire=0; ire<remsare.length; ire++) {
document.getElementById('ih').value=remsare[ire].substring(0,2);
document.getElementById('im').value=remsare[ire].substring(2).substring(0,2);
document.getElementById('is').value=remsare[ire].substring(4).substring(0,2);
wrems=remsare[ire].split(';');
document.getElementById('rwording').value=remsare[ire].substring(eval(8 + wrems[1].length));
document.getElementById('go').click();
}
}
sois.value='';
}
}
function putso() {
var innards='', innardsd='';
if (window.localStorage) {
if (options.length > 0) {
options.sort();
for (var iu=0; iu<options.length; iu++) {
innards+=innardsd + options[iu];
innardsd=';;';
}
localStorage.setItem('reminderso' + nextson, encodeURIComponent('<option value="' + innards.replace(/\"/g,'\"') + '">' + (new Date()) + '</option>'));
}
}
}
function getso() {
var retso='', retson=1, thisso=' ', preretso='', postretso='';
if (window.localStorage) {
while (thisso != '') {
thisso='';
if (localStorage.getItem('reminderso' + retson)) {
thisso=decodeURIComponent(localStorage.getItem('reminderso' + retson).replace(/^null$/g,'').replace(/^undefined$/g,'')).replace(/\+/g,' ');
}
if (thisso != '') {
retso+=thisso;
preretso='<option value="">Standing Order</option>';
postretso='<option value=" ">Delete Most Recent Standing Order</option>';
}
retson++;
nextson++;
}
}
return preretso + retso + postretso;
}
function preprewois() {
prewois(xx);
}
function prewois(inv) {
var spare='';
var pprefix='<p>';
var pmiddle='';
var psuffix='</p>';
if ((inv.trim() + ' ').substring(0,1) == '<') {
if (firstgo) {
pprefix='';
} else {
pprefix='<br>';
}
psuffix='';
} else if ((inv.trim() + ' ').indexOf('<') != -1) {
pprefix='<div>';
pmiddle='</div><br><div>';
psuffix='</div>';
}
if (wois && 1 == 2) {
wois.close();
wois=null;
wois=window.open(document.URL.split('#')[0].split('?')[0] + '?msg=' + encodeURIComponent(inv),'_blank','top=250,left=800,width=500,height=500');
wois.focus();
wois.document.write(pprefix + crbr(inv) + pmiddle + ' ... ' + (new Date()) + psuffix);
//setTimeout(alater,2000);
} else if (wois) {
midprefix=String.fromCodePoint(128718) + ' ';
if (document.title.indexOf(' (up to ') == -1) {
document.title=String.fromCodePoint(128718) + ' ' + maybe(document.getElementById('rwording').value,false) + ' ... ' + documenttitle;
timeaway=0;
origtimeaway=timeaway;
document.getElementById('nums').innerHTML='';
} else if (document.title.indexOf(midprefix) != 0) {
spare=document.title;
document.title=String.fromCodePoint(128718) + ' ' + spare;
}
document.getElementById('myh3').innerHTML=document.getElementById('myh3').innerHTML.split(' ... ')[0] + ' ... <span title="Last reminder" id=sglow class=glow>' + maybe(document.getElementById('rwording').value,true) + '</span>';
try {
wois.focus();
} catch(jhjh) {
}
wois.document.write(pprefix + crbr(inv) + pmiddle + ' ... ' + (new Date()) + psuffix);
}
if (1 == 5) {
if (wois) {
wois.focus();
wois.document.write(pprefix + crbr(inv) + pmiddle + ' ... ' + (new Date()) + psuffix);
wois.focus();
} else {
setTimeout(alater,2000);
}
}
firstgo=false;
}
function alater() {
//wois.document.write(xx);
//wois.focus();
if (xx != '') {
wois.document.title=xx;
}
}
function crbr(inst) {
var sval=inst + ' ... ' + (new Date());
document.getElementById('selrems').innerHTML+='<option value="' + sval + '">' + sval + '</option>';
document.getElementById('selrems').style.display='inline-block';
document.getElementById('selrems').value=sval;
document.getElementById('myh3').title=inst;
if (document.getElementById('sglow')) {
//document.getElementById('sglow').innerHTML=inst;
if (document.title.indexOf(' ... ') > document.title.indexOf(' ')) {
document.title=document.title.replace(document.title.substring(eval(eval('' + document.title.indexOf(' ')) + 1)).split(' ... ')[0], inst);
}
}
while (inst.indexOf(String.fromCharCode(10)) != -1) {
inst=inst.replace(String.fromCharCode(10), '<br>');
}
if (document.getElementById('sglow')) {
document.getElementById('sglow').innerHTML=inst;
}
return inst;
}
function createReminder(what, when) {
var other='', whenvalue='', latestdate=new Date();
if (('' + when.id).indexOf('number') == -1 && hastobedec != '') {
if (what != '') {
document.title=midprefix + 'Waiting ' + hastobedec + ' (up to ' + hastobedec + ' remaining) seconds from ' + (new Date()) + ' ... ' + documenttitle;
when=document.getElementById('rnumber');
other=hastobedec;
timeaway=eval('' + other);
origtimeaway=timeaway;
dd1=new Date();
document.getElementById('nums').innerHTML='';
document.getElementById('myh3').innerHTML=document.getElementById('myh3').innerHTML.split(' ... ')[0];
}
} else if (('' + whenvalue).indexOf('-') == -1) {
whenvalue=when.value;
document.title=midprefix + 'Waiting ' + whenvalue + ' (up to ' + whenvalue + ' remaining) seconds from ' + (new Date()) + ' ... ' + documenttitle;
timeaway=eval('' + whenvalue);
origtimeaway=timeaway;
dd1=new Date();
document.getElementById('nums').innerHTML='';
document.getElementById('myh3').innerHTML=document.getElementById('myh3').innerHTML.split(' ... ')[0];
}
if (('' + when.id).indexOf('number') != -1 && what != '') {
myfuncs.push(myfunc);
thesewords.push(what);
latestdate.setTime(latestdate.getTime() + eval(eval('' + timeaway) * 1000))
thesedates.push(latestdate);
if (other != '') {
theseseconds.push(-1);
document.getElementById('iorems').style.display='inline-block';
options.push(("0" + latestdate.getHours()).slice(-2) + ("0" + eval(0 + latestdate.getMinutes())).slice(-2) + ("0" + latestdate.getSeconds()).slice(-2) + ";-1;" + what);
setTimeout(myfuncs[eval(-1 + myfuncs.length)], eval(1000 * eval('' + other)), what);
} else if (('' + whenvalue).indexOf('-') == -1) {
theseseconds.push(eval('' + whenvalue));
document.getElementById('iorems').style.display='inline-block';
options.push(("0" + latestdate.getHours()).slice(-2) + ("0" + eval(0 + latestdate.getMinutes())).slice(-2) + ("0" + latestdate.getSeconds()).slice(-2) + eval('' + whenvalue) + ";" + what);
setTimeout(myfuncs[eval(-1 + myfuncs.length)], eval(1000 * eval('' + whenvalue)), what);
}
}
hastobe='';
hastobedec='';
}
function amc() {
if (amsg != '') {
if ((amsg.trim() + ' ').substring(0,1) == '<') {
document.body.innerHTML=amsg.trim();
} else if ((amsg.trim() + ' ').indexOf('<') != -1) {
document.body.innerHTML='<div>' + crbr(amsg) + '</div>';
} else {
document.body.innerHTML='<p>' + crbr(amsg) + '</p>';
}
} else {
document.getElementById('mydiv').style.display='block';
}
}
function preonl(setit) {
d = new Date();
h = d.getHours();
m = d.getMinutes();
s = d.getSeconds();
if (setit) {
onl();
}
}
function onl() {
document.getElementById('ih').value=('0' + h).slice(-2);
document.getElementById('im').value=('0' + m).slice(-2);
document.getElementById('is').value=('0' + s).slice(-2);
if (amsg == '') {
document.getElementById('sorems').innerHTML=getso();
}
if (document.getElementById('sorems').innerHTML != '') {
document.getElementById('sorems').style.display='inline-block';
}
}
function precheckfor() {
preonl(0);
var ii=eval(eval(('' + h).slice(-2)) * 3600);
ii+=eval(eval(('' + m).slice(-2)) * 60);
ii+=eval(eval(('' + s).slice(-2)) * 1);
document.getElementById('isecs').value='' + eval(eval('' + hastobedec) - eval('' + ii));
setTimeout(resetit, 1000);
checkfor();
}
function checkfor() {
preonl(0);
if ((('0' + h).slice(-2) + ('0' + m).slice(-2) + ('0' + s).slice(-2)) >= hastobe) {
eval('setTimeout(function() { ' + document.getElementById('jsis').value + ' }, 1)');
preonl(1);
} else {
setTimeout(checkfor, 1000);
}
}
function resetit() {
if (eval('' + document.getElementById('isecs').value) >= 0) {
document.getElementById('isecs').value='' + eval(-1 + eval('' + document.getElementById('isecs').value));
setTimeout(resetit, 1000);
}
}
function go(ob) {
//if (eval('' + document.getElementById('isecs').value) > -1) {
// eval('setTimeout(function() { ' + document.getElementById('jsis').value + String.fromCharCode(10) + ' document.getElementById("isecs").value="-1"; preonl(1); }, ' + eval(eval('' + document.getElementById('isecs').value) * 1000) + ')');
// setTimeout(resetit, 1000);
//} else {
var xd = new Date();
var xh = xd.getHours();
var xm = xd.getMinutes();
var xs = xd.getSeconds();
hastobe=document.getElementById('ih').value + document.getElementById('im').value + document.getElementById('is').value;
hastobedec=eval(eval(eval('' + document.getElementById('ih').value) * 3600) - eval(eval('' + xh) * 3600));
hastobedec+=eval(eval(eval('' + document.getElementById('im').value) * 60) - eval(eval('' + xm) * 60));
hastobedec+=eval(eval('' + document.getElementById('is').value) - eval('' + xs));
if (eval('' + hastobedec) > 0) {
if (wois) { wois.focus(); }
createReminder(document.getElementById('rwording').value, ob);
//precheckfor(); // setTimeout(checkfor, 1000);
} else {
hastobe='';
hastobedec='';
alert('Sorry, we only look forward into today.');
}
//}
}
function diff_seconds(dt2, dt1) { // thanks to https://www.w3resource.com/javascript-exercises/javascript-date-exercise-44.php
var diff =(dt2.getTime() - dt1.getTime()) / 1000;
return Math.abs(Math.round(diff));
}
function dotimeawaytwo() {
setTimeout(dotimeawaytwo, 1000);
dd2=new Date();
if (eval('' + timeaway) > 0) {
var taw='(up to ' + timeaway + ' ';
if (document.title.indexOf(' (up to ') != -1) {
taw='(up to ' + document.title.split(' (up to ')[1].split(' ')[0] + ' ';
}
var absi=eval(-1 + origtimeaway - diff_seconds(dd2,dd1));
document.title=document.title.replace(taw + 'remaining) ', '(up to ' + absi + ' remaining) ');
document.getElementById('nums').innerHTML=' up to ' + absi;
}
}
function maybe(inid, tenout) {
var preinid='';
if (document.getElementById('myh3').title != '') {
inid=document.getElementById('myh3').title;
}
if (tenout && inid.indexOf(String.fromCharCode(10)) != -1) {
preinid='<br><br>';
while (inid.indexOf(String.fromCharCode(10)) != -1) {
inid=inid.replace(String.fromCharCode(10), '<br>');
}
}
return preinid + inid;
}
function dotimeaway() {
if (eval('' + timeaway) > 0) {
timeaway--;
document.getElementById('nums').innerHTML=' up to ' + timeaway;
if (eval('' + timeaway) == 0) {
document.getElementById('myh3').innerHTML=document.getElementById('myh3').innerHTML.split(' ... ')[0] + ' ... <span title="Last reminder" id=sglow class=glow>' + maybe(document.getElementById('rwording').value,true) + '</span>';
midprefix=String.fromCodePoint(128718) + ' ';
if (document.title.indexOf(' (up to ') == -1) {
document.title=String.fromCodePoint(128718) + ' ' + maybe(document.getElementById('rwording').value,false) + ' ... ' + documenttitle;
timeaway=0;
origtimeaway=timeaway;
document.getElementById('nums').innerHTML='';
} else if (document.title.indexOf(midprefix) != 0) {
spare=document.title;
document.title=String.fromCodePoint(128718) + ' ' + spare;
timeaway=0;
origtimeaway=timeaway;
document.getElementById('nums').innerHTML='';
}
document.getElementById('myh3').title='';
document.getElementById('nums').innerHTML='';
d = new Date();
h = d.getHours();
m = d.getMinutes();
s = d.getSeconds();
onl();
}
}
}
if (amsg == '') { setTimeout(amc, 3000); }
if (amsg == '') { setInterval(dotimeaway, 1000); setTimeout(dotimeawaytwo, 900); }
</script>
<style>
td { vertical-align: top; }
textarea { background-color: #f0f0f0; }
select { background-color: pink; }
input[type=number] { background-color: #e0e0e0; }
.glow {
-webkit-animation: glow 1s ease-in-out infinite alternate;
-moz-animation: glow 1s ease-in-out infinite alternate;
animation: glow 1s ease-in-out infinite alternate;
}
/* Thanks to https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_glowing_text */
@-webkit-keyframes glow {
from {
box-shadow: 0 0 3px #fff, 0 0 5px #fff, 0 0 37px #e60073, 0 0 9px #e60073, 0 0 11px #e60073, 0 0 13px #e60073, 0 0 15px #e60073;
}
to {
box-shadow: 0 0 24px #fff, 0 0 6px #ff4da6, 0 0 8px #ff4da6, 0 0 10px #ff4da6, 0 0 12px #ff4da6, 0 0 14px #ff4da6, 0 0 16px #ff4da6;
}
}
</style>
</head>
<body onload='onl();'>
<div id=mydiv style='display:none;'>
<h1><select onchange=soit(this); style='margin-left:12px;margin-right:10px;display:none;' id=sorems></select><input onclick=putso(); id=iorems style='margin-left:12px;margin-right:10px;display:none;' type=button value='Make a Standing Order the '></input>Reminders <select style='display:none;' id=selrems></select> in Session</h1>
<h3 title='' id=myh3>RJM Programming - December, 2020 ... Please only Minimize Popup</h3>
<h4>Thanks to <a target=_blank title='https://stackoverflow.com/questions/32326721/pass-parameter-to-settimeout-callback-function/32326935' href='https://stackoverflow.com/questions/32326721/pass-parameter-to-settimeout-callback-function/32326935'>https://stackoverflow.com/questions/32326721/pass-parameter-to-settimeout-callback-function/32326935</a></h4>
<table border=20 cellspacing=20 cellpadding=20>
<tr><th>Reminder Wording ... at ...</th><th>Reminder Time ... or ...</th><th>Reminder Time Away in<span id=nums></span> Seconds</th></tr>
<tr><td><textarea rows=6 placeholder='Reminder wording ... at ...' id='rwording' value='' style='width:98%;'></textarea></td><td>
At/after this time: <select title="Hours" style="inline-block;" id="ih"><option value="00">00</option><option value="01">01</option><option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>:<select title="Minutes" style="inline-block;" id="im"><option value="00">00</option><option value="01">01</option><option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option></select>:<select title="Seconds" style="inline-block;" id="is"><option value="00">00</option><option value="01">01</option><option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option></select><br><br><br><input id=go style="background-color:yellow;" onclick="go(this);" type="button" value="Go"></td>
</td><td><input onblur=" if (this.value.length > 0) { if (wois) { wois.focus(); } createReminder(document.getElementById('rwording').value,this); this.value='-1'; }" placeholder'Seconds Away' type=number id='rnumber' value='-1' style='width:98%;'></input>
</td></tr>
</table>
<input type=text style='position:absolute;top:-2000px;left:-2000px;' value=''></input>
</div>
</body>
</html>