// country_quiz.js // Help out backgrounds of country_flag/currency/capital_quiz.php suite // RJM Programming // November, 2016 var oneoftwo=0, xinxy=[], yinxy=[], opis='1.0', ovnum=1, defzoom=2, canvcont='', zzaconto=null; var zpos3=-999, zpos4=-999; var trjm=null; var zaconto=null; var xsprefix=''; var xuprefix="//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=Countries&onclick=y&width=298&height=194&country=Country&popularity=Intensity&guess=&data="; function xselchangeit(osel) { uprefix+=sprefix + '%20[~' + encodeURIComponent(osel.options[osel.selectedIndex].text) + '~,66]%20'; sprefix=','; iframeit(); } function xsetup(ins) { uprefix+=sprefix + '%20[~' + encodeURIComponent(ins.replace(/_/g,' ')) + '~,66]%20'; sprefix=','; iframeit(); } function xiframeit() { document.getElementById('dgeochart').innerHTML=''; } function xcheckforpost(insg, oiframe, owhere) { var outs=insg, fbits=''; if (oiframe == null) { fbits='
'; } else { if (oiframe.name != '') { fbits=''; } else { fbits=''; } } if (insg.length > 950) { var outarr=insg.split('#')[0].split('?'); if (outarr.length > 1) { var outarrtwo=outarr[1].split('&'), oath; for (var im=0; im
you needed for your answer was ' + document.getElementById(countryids[choice]).title;
} else {
suffix=' The country
represented by
you needed for your answer was ' + document.getElementById(countryids[choice]).title;
}
if (document.getElementById('ssuffix')) {
document.gteElementById('ssuffix').innerHTML=suffix; suffix='';
}
document.getElementById('score').innerHTML='Score: ' + score + ' Goes: ' + goes + suffix;
document.getElementById('country').value='';
choose();
if (suffix != '' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
//document.body.style.zoom='1';
//window.scrollTo(0,0);
if (document.getElementById('container')) {
document.getElementById('country').scrollIntoView();
if (document.getElementById('ssuffix')) {
document.getElementById('container').innerHTML=(document.getElementById('score').innerHTML + ' ').replace('The country ', '
The country ').replace('has the capital city ', 'has the capital city
');
} else {
document.getElementById('container').innerHTML=(document.getElementById('score').innerHTML + ' ').replace('The country ', '
The country ').replace('has the capital city ', 'has the capital city
');
}
if (document.getElementById('thleft')) {
document.getElementById('thleft').scrollIntoView();
} else {
document.getElementById('container').scrollIntoView();
}
setTimeout(nocontainer, 20000);
} else {
document.getElementById('myh1').scrollIntoView();
}
}
}
function capitalcheck(inv) {
if (inv.value != '') {
var suffix='';
goes++;
if (ourcomp(inv.value,document.getElementById('country').value)) {
score++;
} else if (document.getElementById(countryids[choice]).outerHTML.indexOf('
represented by ' + document.getElementById(countryids[choice]).innerHTML + '
has the capital city ' + document.getElementById(countryids[choice]).title;
} else {
suffix=' The country ' + document.getElementById(countryids[choice]).id.replace(/_/g,' ') + '
represented by
has the capital city ' + document.getElementById(countryids[choice]).title;
}
var wass=suffix;
if (document.getElementById('ssuffix')) {
document.gteElementById('ssuffix').innerHTML=suffix;
suffix='';
}
document.getElementById('score').innerHTML='Score: ' + score + ' Goes: ' + goes + suffix;
choose();
if (wass != '' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
//document.body.style.zoom='1';
//window.scrollTo(0,0);
if (document.getElementById('container')) {
document.getElementById('country').scrollIntoView();
if (document.getElementById('ssuffix')) {
document.getElementById('container').innerHTML=(document.getElementById('score').innerHTML + ' ').replace('The country ', '
The country ').replace('has the capital city ', 'has the capital city
');
} else {
document.getElementById('container').innerHTML=(document.getElementById('score').innerHTML + ' ').replace('The country ', '
The country ').replace('has the capital city ', 'has the capital city
');
}
if (document.getElementById('thleft')) {
document.getElementById('thleft').scrollIntoView();
} else {
document.getElementById('container').scrollIntoView();
}
setTimeout(nocontainer, 20000);
} else {
document.getElementById('myh1').scrollIntoView();
}
}
}
}
function nocontainer() {
document.getElementById('container').innerHTML='';
}
function currencycheck(inv) {
if (inv.value != '') {
var suffix='';
goes++;
if (ourcomp(inv.value,document.getElementById('country').value)) {
score++;
} else if (document.getElementById(countryids[choice]).outerHTML.indexOf('
represented by ' + document.getElementById(countryids[choice]).innerHTML + '
has the currency ' + document.getElementById(countryids[choice]).title;
} else {
suffix=' The country ' + document.getElementById(countryids[choice]).id.replace(/_/g,' ') + ' (' + countrycodes[choice] + ')
represented by
has the currency ' + document.getElementById(countryids[choice]).title;
}
if (document.getElementById('ssuffix')) {
document.gteElementById('ssuffix').innerHTML=suffix; suffix='';
}
document.getElementById('score').innerHTML='Score: ' + score + ' Goes: ' + goes + suffix; choose();
if (suffix != '' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
//document.body.style.zoom='1';
//window.scrollTo(0,0);
if (document.getElementById('container')) {
document.getElementById('country').scrollIntoView();
if (document.getElementById('ssuffix')) {
document.getElementById('container').innerHTML=(document.getElementById('score').innerHTML + ' ').replace('The country ', '
The country ').replace('has the currency ', 'has the currency
');
} else {
document.getElementById('container').innerHTML=(document.getElementById('score').innerHTML + ' ').replace('The country ', '
The country ').replace('has the currency ', 'has the currency
');
}
if (document.getElementById('thleft')) {
document.getElementById('thleft').scrollIntoView();
} else {
document.getElementById('container').scrollIntoView();
}
setTimeout(nocontainer, 20000);
} else {
document.getElementById('myh1').scrollIntoView();
}
}
}
}
function ifon() {
if (trjm != null) {
document.getElementById('iback').style.display='block';
} else {
document.getElementById('iback').style.display='none';
}
}
function youralert(ev) { //},yblurb1,yblurb2,yblurb3,yblurb4,yblurb5) {
if (ev.touches) {
if (ev.touches[0].pageX) {
zpos3 = ev.touches[0].pageX;
zpos4 = ev.touches[0].pageY;
} else {
zpos3 = ev.touches[0].clientX;
zpos4 = ev.touches[0].clientY;
}
} else if (ev.clientX || ev.clientY) {
zpos3 = ev.clientX;
zpos4 = ev.clientY;
} else {
zpos3 = ev.pageX;
zpos4 = ev.pageY;
}
//alert('x=' + zpos3 + ' and y=' + zpos4);
//if (zpos3 >= 0) {
//zaconto.ouralert(yblurb1,yblurb2,yblurb3,yblurb4,yblurb5);
//}
//zaconto.ouralert(yblurb1,yblurb2,yblurb3,yblurb4,yblurb5);
if (oneoftwo == 0) { return true; } else if (Math.abs(oneoftwo) == 1) { xinxy.push(zpos3); yinxy.push(zpos4); if (oneoftwo < 0) { oneoftwo--; } else { oneoftwo++; } if (1 == 5) { alert('first of two ' + 'x=' + zpos3 + ' and y=' + zpos4); } return false; } else if (Math.abs(oneoftwo) == 2) { xinxy.push(zpos3); yinxy.push(zpos4); if (1 == 5) { alert('second of two ' + 'x=' + zpos3 + ' and y=' + zpos4); } overlayit(0); return false; }
return true;
}
function setdefzoom(towhat) {
defzoom=eval('' + towhat);
}
function dotwor() {
if (oneoftwo == 1) {
defzoom++;
} else {
defzoom=2;
}
oneoftwo=1;
}
function dotwoc() {
if (oneoftwo == -1) {
defzoom++;
} else {
defzoom=2;
}
oneoftwo=-1;
}
function alternatevisibility() {
var igh=1;
while (zaconto.getElementById('iciov' + igh)) {
if (igh == 1 && zaconto.getElementById('iciov' + igh).outerHTML.indexOf('visibility:') == -1) {
nextv='hidden';
} else if (igh == 1 && zaconto.getElementById('iciov' + igh).outerHTML.split('visibility:')[1].split(';')[0].split('>')[0].toLowerCase().indexOf('visible') != -1) {
nextv='hidden';
} else if (igh == 1) {
nextv='visible';
}
zaconto.getElementById('iciov' + igh).style.visibility='' + nextv;
igh++;
}
}
function overlayit(ootis) {
var prerest='', zb='', wascc='';
if (ootis == 0) {
if (eval('' + xinxy.length) == 2) {
if (ovnum == 1) { // thanks to https://stackoverflow.com/questions/69491728/how-to-zoom-an-image-on-mouse-hover-using-css
prerest=' .zoom-img { width: ' + zaconto.getElementById('myimg').width + 'px; height: ' + zaconto.getElementById('myimg').height + 'px; overflow: hidden; } .zoom-img:hover { transform: scale(2.0); } ';
}
if (defzoom != 2) {
zb=' #iciov' + ovnum + ':hover { transform: scale(' + defzoom + '.0); } ';
}
if (oneoftwo < 0) { // circle
wascc=canvcont;
//zzaconto.onl();
if (canvcont == '') { canvcont=zaconto.getElementById('mycanvas').toDataURL('image/jpeg',0.1); }
canvcont='/HTMLCSS/HYP_50M_SR_W.jpg';
zaconto.getElementById('myimg').style.opacity='1.0';
//alert(zaconto.getElementById('myimg').outerHTML.replace('myimg','iciov' + ovnum).replace('myimg','iciov' + ovnum).replace('56;','1899;background-color:transparent;').replace(/\\\"\\ on/g, '\" data-on').replace(' ' + prerest + zb + ' #iciov' + ovnum + ' { -webkit-filter: brightness(150%); filter: brightness(150%); transform-origin: ' + xinxy[0] + 'px ' + yinxy[0] + 'px; clip-path: circle(' + Math.sqrt(eval(xinxy[0] - xinxy[1]) * eval(xinxy[0] - xinxy[1]) + eval(yinxy[0] - yinxy[1]) * eval(yinxy[0] - yinxy[1])) + 'px at ' + xinxy[0] + 'px ' + yinxy[0] + 'px); } ');
zaconto.getElementById('dvstyle').innerHTML+='';
} else { // rectangle
wascc=canvcont;
//zzaconto.onl();
if (canvcont == '') { canvcont=zaconto.getElementById('mycanvas').toDataURL('image/jpeg',0.1); }
canvcont='/HTMLCSS/HYP_50M_SR_W.jpg';
zaconto.getElementById('myimg').style.opacity='1.0';
zaconto.getElementById('imgmore').innerHTML+=zaconto.getElementById('myimg').outerHTML.replace('myimg','iciov' + ovnum).replace('myimg','iciov' + ovnum).replace('56;','1899;').replace(/\\\"\\ on/g, '\" data-on').replace(' ' + prerest + zb + ' #iciov' + ovnum + ' { -webkit-filter: brightness(150%); filter: brightness(150%); transform-origin: ' + eval(eval(xinxy[0] + xinxy[1]) / 2) + 'px ' + eval(eval(yinxy[0] + yinxy[1]) / 2) + 'px; clip-path: polygon(' + Math.min(eval(xinxy[0]),eval(xinxy[1])) + 'px ' + Math.min(eval(yinxy[0]),eval(yinxy[1])) + 'px,' + Math.min(eval(xinxy[0]),eval(xinxy[1])) + 'px ' + Math.max(eval(yinxy[0]),eval(yinxy[1])) + 'px,' + Math.max(eval(xinxy[0]),eval(xinxy[1])) + 'px ' + Math.max(eval(yinxy[0]),eval(yinxy[1])) + 'px,' + Math.max(eval(xinxy[0]),eval(xinxy[1])) + 'px ' + Math.min(eval(yinxy[0]),eval(yinxy[1])) + 'px,' + Math.min(eval(xinxy[0]),eval(xinxy[1])) + 'px ' + Math.min(eval(yinxy[0]),eval(yinxy[1])) + 'px' + '); } ';
}
if (ovnum == 1) { setInterval(alternatevisibility, 15000); }
ovnum++;
}
oneoftwo=ootis;
defzoom=2;
xinxy=[];
yinxy=[];
}
}
function putcc(inccis) {
canvcont=inccis;
}
function ctyifcheck(ziois) {
var kkfound=false, iars=0, iiars=0;
zaconto = (ziois.contentWindow || ziois.contentDocument);
zzaconto=zaconto;
if (zaconto != null) {
try {
if (zaconto.document) { zaconto = zaconto.document; }
if (zaconto.body.innerHTML.indexOf('>') != -1 && ziois.src.indexOf('highlight=') != -1) {
//canvcont=zaconto.getElementById('mycanvas').toDataURL('image/jpeg',0.1);
document.getElementById('iback').style.width='110%';
document.getElementById('iback').style.height='900px';
document.getElementById('iback').style.marginLeft='-20px';
document.getElementById('iback').frameborder='0';
var arstart=zaconto.getElementsByTagName('area');
var ars=zaconto.getElementsByTagName('div');
for (iiars=0; iiars
";
if (ziois.src.indexOf('zoom=4&') != -1 && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
zaconto.body.style.zoom='4';
//alert(1);
// var mvp = zaconto.getElementById('myviewport');
//alert(11);
// mvp.setAttribute('content','initial-scale=' + eval(1 * 4));
//alert(111);
}
}
} catch(hgjgs) { }
}
return true;
}
function check(inv) {
var ourcis="";
if (inv.value != "") {
if (document.URL.indexOf('_flag_') != -1) {
if (document.getElementById('fav_opt').value == 'wi') {
ourcis="//www.rjmprogramming.com.au/PHP/fgc/?tzexact=" + encodeURIComponent(document.getElementById(countryids[choice]).title.replace(/\ /g,'_')) + "&tznickname=" + encodeURIComponent(document.getElementById(countryids[choice]).title.replace(/\ /g,'_'));
} else if (document.getElementById('fav_opt').value == 'gj') {
ourcis="//www.rjmprogramming.com.au/HTMLCSS/countries.html?zoom=4&highlight=" + encodeURIComponent(countryccs[choice]);
} else if (document.getElementById('fav_opt').value == 'tz') {
ourcis="//www.rjmprogramming.com.au/PHP/tz_places.php?iso=" + encodeURIComponent(countryccs[choice]);
} else if (document.getElementById('fav_opt').value == 'ic') {
ourcis="//www.rjmprogramming.com.au/PHP/GeoChart/image_chart.php?ccode=" + encodeURIComponent(countryccs[choice]);
} else {
ourcis="//www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=" + encodeURIComponent(" flag of " + document.getElementById(countryids[choice]).title);
}
flagcheck(inv);
} else if (document.URL.indexOf('_capital_') != -1) {
if (document.getElementById('fav_opt').value == 'wi') {
ourcis="//www.rjmprogramming.com.au/PHP/fgc/?tzexact=" + encodeURIComponent(document.getElementById(countryids[choice]).id.replace(/\ /g,'_')) + "&tznickname=" + encodeURIComponent(document.getElementById(countryids[choice]).id.replace(/\ /g,'_'));
} else if (document.getElementById('fav_opt').value == 'gj') {
ourcis="//www.rjmprogramming.com.au/HTMLCSS/countries.html?zoom=4&highlight=" + encodeURIComponent(countryccs[choice]);
} else if (document.getElementById('fav_opt').value == 'tz') {
ourcis="//www.rjmprogramming.com.au/PHP/tz_places.php?iso=" + encodeURIComponent(countryccs[choice]);
} else if (document.getElementById('fav_opt').value == 'ic') {
ourcis="//www.rjmprogramming.com.au/PHP/GeoChart/image_chart.php?ccode=" + encodeURIComponent(countryccs[choice]);
} else {
ourcis="//www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=" + encodeURIComponent(" capital of " + document.getElementById(countryids[choice]).id.replace(/_/g,' '));
}
capitalcheck(inv);
} else if (document.URL.indexOf('_currency_') != -1) {
if (document.getElementById('fav_opt').value == 'wi') {
ourcis="//www.rjmprogramming.com.au/PHP/fgc/?tzexact=" + encodeURIComponent(document.getElementById(countryids[choice]).id.replace(/\ /g,'_')) + "&tznickname=" + encodeURIComponent(document.getElementById(countryids[choice]).id.replace(/\ /g,'_'));
} else if (document.getElementById('fav_opt').value == 'gj') {
ourcis="//www.rjmprogramming.com.au/HTMLCSS/countries.html?zoom=4&highlight=" + encodeURIComponent(countryccs[choice]);
} else if (document.getElementById('fav_opt').value == 'tz') {
ourcis="//www.rjmprogramming.com.au/PHP/tz_places.php?iso=" + encodeURIComponent(countryccs[choice]);
} else if (document.getElementById('fav_opt').value == 'ic') {
ourcis="//www.rjmprogramming.com.au/PHP/GeoChart/image_chart.php?ccode=" + encodeURIComponent(countryccs[choice]);
} else {
ourcis="//www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=" + encodeURIComponent(" currency of " + document.getElementById(countryids[choice]).id.replace(/_/g,' '));
}
currencycheck(inv);
}
if (trjm != null) {
document.getElementById('iback').src=ourcis;
document.getElementById('iback').style.display='block';
}
}
}
function xpreandquizthen() {
if (document.getElementById('mydpost') == null && document.getElementById('dgeochart') == null) {
document.body.innerHTML+="";
if (document.getElementById('country').value != '') {
selchangeit(document.getElementById('country'));
}
}
if (document.getElementById('mydpost') == null) {
document.body.innerHTML+='';
if (document.getElementById('country').value != '') {
selchangeit(document.getElementById('country'));
}
}
if (document.getElementById('dgeochart') == null) {
document.body.innerHTML+="";
if (document.getElementById('country').value != '') {
selchangeit(document.getElementById('country'));
}
}
}
function ronclk(cv) {
var wasv=document.getElementById('fav_opt').value;
if (1 == 2) {
if (wasv == 'yv' && cv != 'yv') {
document.getElementById('fav_opt').value='wi';
} else if (wasv == 'gj' && cv != 'gj') {
document.getElementById('fav_opt').value='gj';
} else if (wasv == 'ic' && cv != 'ic') {
document.getElementById('fav_opt').value='ic';
} else if (wasv == 'tz' && cv != 'tz') {
document.getElementById('fav_opt').value='tz';
} else if (wasv == 'wi' && cv != 'wi') {
document.getElementById('fav_opt').value='yv';
}
}
if (cv.trim() != '' && cv.trim() != wasv) {
document.getElementById('fav_opt').value=cv;
}
}
function andquizthen() {
// xpreandquizthen();
if (trjm == null) {
trjm=document.getElementsByTagName('h3')[0];
if (trjm != null) {
//trjm.innerHTML+='
Optional ';
trjm.innerHTML+='
Optional
';
trjm.style.fontSize='10px';
document.body.innerHTML+="";
choose();
}
}
}
//setTimeout(xpreandquizthen, 2200);
setTimeout(andquizthen, 3000);