// prompt.js
// RJM Programming
// March, 2016
// Override prompt window function along with input type=button method of asking regarding DotDotDot web applications
var preinput = " ";
var ourone = " ";
var ourtwo = " ";
var ourthree = " ";
var ourccnt = 0;
var within=false;
var topq='', topd='';
var wino = null;
var co = '';
function oldsleep(n) { // thanks to http://stackoverflow.com/questions/951021/what-do-i-do-if-i-want-a-javascript-version-of-sleep
var request = new XMLHttpRequest();
request.open('GET', '/prompt.php?n=' + n, false); // `false` makes the request synchronous
request.send(null);
}
function sleep(seconds) { // thanks to http://phpjs.org/functions/time_sleep_until/
var milliseconds=eval(1000 * seconds);
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
function preprompt() {
//document.title=document.getElementById('promptiframe').src;
preinput=document.getElementById('promptinput').value;
if (preinput == " ") setTimeout(preprompt, 1000);
}
function xpreprompt() {
//document.title=document.getElementById('promptiframe').src;
preinput=document.getElementById('promptinput').value;
setTimeout(xpreprompt, 1000);
}
function tryagain() {
}
function nextprompt(q,d) {
var retval=' ';
topq=q;
topd=d;
ourprompt(q,d);
if (preinput == " ") {
if (preinput == " ") {
document.getElementById('promptinput').focus();
}
while (within && retval == ' ') {
retval=ourprompt(q,d);
}
}
return retval;
}
function fixparent(tvis) {
preinput = tvis;
}
function jprompt(q,d) {
var retscr=" function fixparent(tvis) { } ";
retscr+=" $(document).ready(function() { ";
retscr+=' $("#myeg").dialog({ ';
retscr+=" modal: true, ";
retscr+=" resizable: false, ";
retscr+=" overlay: { ";
retscr+=" opacity: 0.4, ";
retscr+=' background: "black" ';
retscr+=" }, ";
retscr+=" buttons: { ";
retscr+=' "Cancel": function() { ';
retscr+=' $(this).dialog("close"); ';
retscr+=" }, ";
retscr+=' "OK": function() { ';
retscr+=' $(this).dialog("close"); ';
retscr+=" } ";
retscr+=" } ";
retscr+=" }); ";
retscr+=" }); ";
retscr+="";
if (wino) wino.close();
//alert("
" + '' + "" + "
" + retscr + "");
//wino = window.open("","wino","fullscreen=no, toolbar=no, menubar=no,status=no,location=no,width=635,height=630,resizable=1");
//var doc = wino.document;
//doc.write("" + retscr + '' + "Modal Dialog
" + "
" + "");
//doc.write("hello
");
//retscr+="
";
//alert(retscr);
return "";
}
function cthen() {
document.getElementById('promptiframe').src=co;
//prompt(topq,topd);
}
function zthen() {
prompt(topq,topd);
}
function prompt(q,d) {
var sof; //=document.getElementById('promptiframe').src;
var sofs; //=sof.split('?');
var bealert = -2, bef='', aft='';
var pmyeg=document.getElementById('myeg');
var pdivs=document.getElementsByTagName('h1');
var pdiv=document.getElementById('promptdiv');
var piframe=document.getElementById('promptiframe');
var hint=document.getElementById('hint');
var pinput; //=document.getElementById('promptinput');
var pinputval=" "; //pinput.value;
var ct=-1;
topp2: do {
if (!within) {
topq=q;
topd=d;
if (hint != null) {
if (hint.title) bef = hint.title;
if (hint.alt) aft = hint.alt;
}
if (pmyeg != null || document.getElementById('abutton')) {
document.getElementById('myeg').title=q;
$('#myeg').dialog('option', 'title', q);
document.getElementById('myin').value=d;
within=true;
setTimeout(xpreprompt, 1000);
document.getElementById('abutton').click();
if (bef != '') {
//alert(630);
eval("bealert=" + bef + "('" + q + "','" + d + "')");
//alert(bealert);
} else {
bealert = q.indexOf('Enter third of your ');
}
} else if (pdiv == null) {
if (pdivs.length == 0) {
pdivs=document.getElementsByTagName('div');
}
if (pdivs.length == 0) {
document.body.innerHTML+='' + jprompt(q,d) + '
';
//alert("pdivs[0].innerHTML");
} else {
pdivs[0].innerHTML+='' + jprompt(q,d) + '' + "
";
//alert(pdivs[0].innerHTML);
}
sof=document.getElementById('promptiframe').src;
sofs=sof.split('?');
//alert(sofs[0].replace("/zz.", "/prompt.") + '?q=' + encodeURIComponent(q) + '&d=' + encodeURIComponent(d));
//document.getElementById('promptiframe').src=sofs[0].replace("/zz.", "/prompt.") + '?q=' + encodeURIComponent(q) + '&d=' + encodeURIComponent(d);
co=sofs[0].replace("/zz.", "/prompt.") + '?q=' + encodeURIComponent(q) + '&d=' + encodeURIComponent(d);
setTimeout(preprompt, 1000);
within=true;
document.getElementById('promptiframe').src=co; //setTimeout(cthen,100);
if (bef != '') {
//alert(630);
eval("bealert=" + bef + "('" + q + "','" + d + "')");
//alert(bealert);
} else {
bealert = q.indexOf('Enter third of your ');
}
//break topp;
} else if (piframe == null) {
pdiv.innerHTML=jprompt(q,d) + '';
sof=document.getElementById('promptiframe').src;
sofs=sof.split('?');
document.getElementById('promptiframe').src=sofs[0].replace("/zz.", "/prompt.") + '?q=' + encodeURIComponent(q) + '&d=' + encodeURIComponent(d);
co=sofs[0].replace("/zz.", "/prompt.") + '?q=' + encodeURIComponent(q) + '&d=' + encodeURIComponent(d);
setTimeout(preprompt, 1000);
within=true;
document.getElementById('promptiframe').src=co; //setTimeout(cthen,100);
if (bef != '') {
//alert(630);
eval("bealert=" + bef + "('" + q + "','" + d + "')");
//alert(bealert);
} else {
bealert = q.indexOf('Enter third of your ');
}
//break topp;
} else {
document.getElementById('promptdiv').style.display='block';
sof=document.getElementById('promptiframe').src;
sofs=sof.split('?');
//alert(sofs[0] + '?q=' + encodeURIComponent(q) + '&d=' + encodeURIComponent(d));
//document.getElementById('promptiframe').src=sofs[0].replace("/zz.", "/prompt.") + '?q=' + encodeURIComponent(q) + '&d=' + encodeURIComponent(d);
co=sofs[0].replace("/zz.", "/prompt.") + '?q=' + encodeURIComponent(q) + '&d=' + encodeURIComponent(d);
if (sof[0].indexOf('?q=') == -1) {
setTimeout(preprompt, 1000);
}
within=true;
document.getElementById('promptiframe').src=co; //setTimeout(cthen,100);
if (bef != '') {
//alert(630);
eval("bealert=" + bef + "('" + q + "','" + d + "')");
//alert(bealert);
} else {
bealert = q.indexOf('Enter third of your ');
}
//break topp;
}
//setTimeout(cthen,100);
//return ' ';
// Place for business logic regarding scrutiny of prompt question and/or default
//alert(bef);
//if (bef != '') {
//alert(630);
//eval("bealert=" + bef + "('" + q + "','" + d + "')");
//alert(bealert);
//} else {
//bealert = q.indexOf('Enter third of your ');
//}
}
// End of place for business logic regarding scrutiny of prompt question and/or default
pinput=document.getElementById('promptinput');
pinputval=pinput.value;
//document.title=document.getElementById('promptiframe').src;
//alert(document.getElementById('promptiframe').src);
//window.open(document.getElementById('promptiframe').src,'_blank'); //,'top=50,left=50,width=50,height=50');
ct++;
//while (pinputval == " ") {
if (pinputval == " ") {
within=true;
preinput=pinput.value;
pinputval = preinput;
//oldsleep(5);
//ct+=9;
//document.title+="";
if (pinputval == " ") {
sleep(10);
//alert(87);
//setTimeout(zthen, 1000);
//alert(61 + ' ' + ct);
if (ct == 0) {
continue topp2;
} else {
ct=-1;
break topp2;
}
} else {
within=false;
}
}
//alert(63);
document.getElementById('promptinput').value=' ';
// Place for business logic regarding scrutiny of prompt answer
if (preinput != " ") {
if (aft != '') {
//alert(aft + "('" + ourone + "','" + ourtwo + "','" + ourthree + "')");
eval(aft + "('" + ourone + "','" + ourtwo + "','" + ourthree + "')");
} else {
if (eval(bealert) > -1) {
ourthree=pinputval;
if (document.getElementById('modesel').value != '') {
var was=document.getElementById('altview').innerHTML;
var inps=document.getElementsByTagName('input');
ourccnt=inps.length;
document.getElementById('altview').innerHTML="" + was + "";
ourccnt++;
ourccnt++;
}
} else if (ourone == ' ') {
ourone=pinputval;
//alert(')' + ourone + ')');
} else {
ourtwo=pinputval;
}
}
}
// End of place for business logic regarding scrutiny of prompt answer
if (preinput == " ") break topp2;
//alert(670 + preinput + "xx");
} while (preinput == ' ')
if (preinput != " ") {
within=false;
pinputval = preinput;
preinput = " ";
return pinputval; //pinputval;
} else if (preinput == '') {
within=false;
preinput = " ";
}
return '';
}