<html>
<head>
<title>Animated GIF Slide Extraction Display - RJM Programming - May, 2024</title>
<script type='text/javascript'>
var defgif='./linkedin_learning_stata_15.gif';
if (document.URL.indexOf('rjmprogramming.com.au') != -1) {
defgif='./making_of_red_wriggler_concatenation_of_still_images_to_video.gif';
}
var gifurl=(location.search + location.hash).split('url=')[1] ? decodeURIComponent((location.search + location.hash).split('url=')[1].split('&')[0]) : defgif;
var gifloc=(location.search + location.hash).split('slide=')[1] ? decodeURIComponent((location.search + location.hash).split('slide=')[1].split('&')[0]) : '1';
var canextract=0;
var ingif='', goi=null, ih=0, iw=0, goisrc='', jjxhr=null, jjform=null, ij=0, doit=false;
var origgifloc='', pbefore='';


function ob(tv) {
if (tv.trim() != '') { prefetch(tv); }
}

function prefetch(whatgifmaybe) { // thanks to https://stackoverflow.com/questions/69564118/how-to-get-duration-of-gif-image-in-javascript#:~:text=Mainly%20use%20parseGIF()%20%2C%20then,duration%20of%20a%20GIF%20image.
if (whatgifmaybe.trim() != '' || (whatgifmaybe.toLowerCase().trim().split('#')[0] + '?').indexOf('.gif?') != -1 || whatgifmaybe.indexOf('data:image/') == 0) {
ingif=whatgifmaybe;
fetch(whatgifmaybe.replace('http;','https:'))
.then(res => res.arrayBuffer())
.then(ab => isGifAnimated(new Uint8Array(ab)))
.then(console.log);
}
}

function oneslidedu() {
//document.title='' + jjxhr.readyState + '/' + jjxhr.status;
if (jjxhr.readyState == 4) {
if (jjxhr.status == 200) {
setTimeout(function(){
if (jjxhr.responseText) {
if (jjxhr.responseText != '') {
goisrc=jjxhr.responseText;
}
}
}, 6000);
}
}
}

/** @param {Uint8Array} uint8 */
function isGifAnimated(uint8) { // thanks to https://stackoverflow.com/questions/69564118/how-to-get-duration-of-gif-image-in-javascript#:~:text=Mainly%20use%20parseGIF()%20%2C%20then,duration%20of%20a%20GIF%20image.
if (origgifloc == '') { origgifloc=gifloc; }
pbefore='';
//ij=0;
let duration = 0;
for (let i = 0, len = uint8.length; i < len; i++) {
if (uint8[i] == 0x21
&& uint8[i + 1] == 0xF9
&& uint8[i + 2] == 0x04
&& uint8[i + 7] == 0x00)
{
const delay = (uint8[i + 5] << 8) | (uint8[i + 4] & 0xFF);
duration += delay < 2 ? 10 : delay;

if (doit || gifloc.indexOf('%') != -1 || 1 == 1) {
ij++;
doit=true;
gifloc=origgifloc;
pbefore='' + ('gifloc=' + gifloc + ' and duration=' + eval(duration / 100) + ' and ij=' + ij + ' ');
if (origgifloc.indexOf('%') != -1) { gifloc='' + Math.round(eval(eval(gifloc.replace('%','')) * eval('' + ij) / 100.0)); }
//document.title='' + pbefore + ' ... ' + gifloc;
}
}
}
if (eval(duration / 100) <= 0.11) {
return 0;
}
//if (gifloc.indexOf('%') != -1) {
// alert('' + eval(duration / 100) + ' vs ' + delay);
// gifloc=gifloc.replace('%','');
//}
if (1 == 5 && canextract > 0) {
alert('' + eval(duration / 100));
} else {

document.getElementById('mygimage').title=('' + document.getElementById('mygimage').title).replace(' of 0', ' of ' + ij);

var newimg=new Image();
newimg.onload = function(){
ih=newimg.height;
iw=newimg.width;
document.getElementById('dimg').style.width='' + eval(1 * newimg.width) + 'px';
document.getElementById('dimg').style.height='' + eval(1 * newimg.height) + 'px';
document.getElementById('dimg').style.background='linear-gradient(rgba(255,255,255,0.9),rgba(255,255,255,0.9)),url(' + gifurl + ')';
//document.getElementById('dimg').style.backgroundPosition='' + iw + 'px ' + ih + 'px';
document.getElementById('dimg').style.backgroundPosition='0px 0px';
document.getElementById('dimg').style.backgroundSize='' + newimg.width + 'px ' + newimg.height + 'px';
document.getElementById('dimg').style.backgroundRepeat='no-repeat';
document.getElementById('dimg').src='#';
document.getElementById('dimg').src=gifurl;
document.getElementById('mygimage').style.opacity='0.1';
};

newimg.src=gifurl;
goi=document.getElementById('mygimage');
goisrc=gifurl;
document.getElementById('mygimage').src=gifurl;
//newimg.src=gifurl;
setTimeout(function(){
jjform = new FormData();
jjxhr = new XMLHttpRequest();
document.getElementById('agname').value=gifurl;
document.getElementById('mygimage').title='Finding slide ' + eval(1 + eval(eval(-1 + eval('' + gifloc.replace('%',''))) % ij)) + ' of ' + ij + ' ... please wait ...';
document.getElementById('slidenumber').value='' + eval(1 + eval(eval(-1 + eval('' + gifloc.replace('%',''))) % ij));
jjform.append('agname', gifurl);
jjform.append('slidenumber', '' + eval(1 + eval( eval(-1 + eval('' + gifloc.replace('%',''))) % ij)));
jjform.append('random', document.getElementById('random').value);
jjxhr.onreadystatechange = oneslidedu;
//jjxhr.responseType = "Document";
jjxhr.open('post', './agtoslides.php', true);
if (1 == 1) {
if (eval('' + document.getElementById('agname').value.length) < 400) {
//document.getElementById('dimg').style.opacity='0.1';
document.body.style.cursor='progress';
document.getElementById('myif').src='./agtoslides.php?agname=' + encodeURIComponent(document.getElementById('agname').value) + '&slidenumber=' + encodeURIComponent(document.getElementById('slidenumber').value) + '&random=' + encodeURIComponent(document.getElementById('random').value);
} else {
//document.getElementById('dimg').style.opacity='0.1';
document.body.style.cursor='progress';
//alert(document.getElementById('myform').outerHTML);
document.getElementById('mysub').click();
}
} else {
jjxhr.send(jjform);
}
}, 5000);
}
return duration / 100; // if 0.1 is not an animated GIF
}

if (gifurl.trim() != '') {
if (gifurl.indexOf('//') == -1) {
canextract=2;
} else if (document.URL.indexOf('//' + gifurl.split('//')[1].split('/')[0] + '/') != -1) {
canextract=2;
} else if (gifurl.indexOf('data:image/') == 0) {
canextract=1;
}
}

function checkit(iois) {
if (iois.src.indexOf('agtoslides.php') != -1) {
var aconto = (iois.contentWindow || iois.contentDocument);
if (aconto != null) {
if (aconto.document) { aconto = aconto.document; }
if (aconto.body != null) {
if (aconto.body.innerHTML.indexOf(' src="') != -1) {
goisrc=aconto.body.innerHTML.split(' src="')[1].split('"')[0];
} else if (aconto.body.innerHTML.indexOf('<') == 0) {
goisrc=aconto.body.innerHTML.split(aconto.body.innerHTML.split('>')[0] + '>')[1].split('</')[0];
} else {
goisrc=aconto.body.innerHTML;
}
//alert(goisrc);
document.getElementById('mygimage').style.opacity='1.0';
document.getElementById('mygimage').src=goisrc;
document.getElementById('dimg').style.background='url(' + goisrc + ')';
document.body.style.cursor='pointer';
document.getElementById('mygimage').title='Found slide ' + eval(1 + eval(eval(-1 + eval('' + gifloc.replace('%',''))) % ij)) + ' of ' + ij + '. Click to also show the original animated GIF.';
}
}
}
}

function askaway() {
var wans='', postwans='', fromone='youllneverfindthis', toone='youllneverfindthis', huhs='';
if (window.parent) {
if (window.self !== window.parent && document.URL.indexOf('noask=') == -1) {
wans=prompt('Please, optionally, enter an animated GIF URL of interest and optionally append hashtag (ie. #) separated slide number of interest (can be a percentage)', gifurl);
if (wans == null) { wans=''; }
if (wans.trim() != '' && wans != gifurl) {
var wansh=wans.split('#');
if (eval('' + wansh.length) > 1) { fromone='slide='; toone='slidnoe='; postwans='&slide=' + encodeURIComponent(wansh[1]); wans=wansh[0]; }
if (wans.trim() == '') { huhs='junk'; }
if (top.location.href.indexOf('?') == -1) {
if (top.location.href.indexOf('/extract_ag_slide_huh_of.htm') != -1) {
top.location.href+='?url' + huhs + '=' + encodeURIComponent(wans) + postwans + '&noask=y';
} else {
location.href+='?url' + huhs + '=' + encodeURIComponent(wans) + postwans + '&noask=y';
}
} else {
if (top.location.href.indexOf('/extract_ag_slide_huh_of.htm') != -1) {
top.location.href=top.document.URL.replace(fromone,toone).replace('?', '?url' + huhs + '=' + encodeURIComponent(wans) + postwans + '&noask=y&');
} else {
location.href=document.URL.replace(fromone,toone).replace('?', '?url' + huhs + '=' + encodeURIComponent(wans) + postwans + '&noask=y&');
}
}
}
} else if (gifurl == defgif && document.URL.indexOf('noask=') == -1) {
document.getElementById('myiftwo').src=document.URL + '#ask=';
}
} else if (gifurl == defgif && document.URL.indexOf('noask=') == -1) {
document.getElementById('myiftwo').src=document.URL + '#ask=';
}
}

function woit() {
var wo=window.open('', '_blank', 'top=50,left=50,width=' + iw + ',height=' + ih);
wo.document.write('<html><body><img src="' + gifurl + '"></img></body></html>');
}

function setgurl(gurl) {
ij=0;
gifurl=gurl;
document.getElementById('agname').value=gifurl; //'';
document.getElementById('mygimage').src=gifurl;
document.getElementById('random').value='' + Math.floor(Math.random() * 198786753);
gifloc=prompt('Please, optionally, enter a slide number of interest (can be a percentage) ', '' + gifloc);
if (gifloc == null) { gifloc='1'; } else if (gifloc == '0') { gifloc='1'; } else if (gifloc.indexOf('-') != -1) { gifloc='1'; }
document.getElementById('slidenumber').value='' + gifloc;
doit=false;
origgifloc='';
ob(gifurl);
document.getElementById('mygimage').title='Finding slide ' + gifloc + ' of ' + ij + ' ... please wait ...';
document.getElementById('myifthree').style.display='none';
window.scrollTo(0,0);
if (1 == 5) {
setTimeout(function(){
var wans='', postwans='', fromone='youllneverfindthis', toone='youllneverfindthis', huhs='';
wans=prompt('Please, optionally, enter a hashtag (ie. #) separated slide number of interest (can be a percentage)', '#1');
if (wans == null) { wans=''; }
if (wans.trim() != '' && wans != gifurl) {
var wansh=wans.split('#');
if (eval('' + wansh.length) > 1) { origgifloc=''; gifloc=wansh[1]; fromone='slide='; toone='slidnoe='; postwans='&slide=' + encodeURIComponent(wansh[1]); wans=wansh[0]; }
if (wans.trim() == '') { huhs='junk'; }
if (top.location.href.indexOf('?') == -1) {
if (top.location.href.indexOf('/extract_ag_slide_huh_of.htm') != -1) {
top.location.href+='?rand=' + Math.floor(Math.random() * 19878675) + '#url' + huhs + '=' + encodeURIComponent(wans) + postwans + '&noask=y';
} else {
location.href+='?rand=' + Math.floor(Math.random() * 19878675) + '#url' + huhs + '=' + encodeURIComponent(wans) + postwans + '&noask=y';
}
} else {
if (top.location.href.indexOf('/extract_ag_slide_huh_of.htm') != -1) {
top.location.href=top.document.URL.replace(fromone,toone).replace('?', '?rand=' + Math.floor(Math.random() * 19878675) + '#url' + huhs + '=' + encodeURIComponent(wans) + postwans + '&noask=y&');
} else {
location.href=document.URL.replace(fromone,toone).replace('?', '?rand=' + Math.floor(Math.random() * 19878675) + '#url' + huhs + '=' + encodeURIComponent(wans) + postwans + '&noask=y&');
}
}
}
}, 3000);
}
}
</script>
</head>
<body onload="document.getElementById('random').value='' + Math.floor(Math.random() * 19878675); setTimeout(askaway,8000); ob(gifurl);">
<iframe style="display:none;" onload="if (this.src.length > 0) { setTimeout(function() { this.srcdoc='<iframe src=//www.rjmprogramming.com.au/About_Us.html></iframe>'; }, 20000); }" id=dimg src=''></iframe>
<!--hr></hr-->
<img onclick=woit(); data-onload="if (this.src.length > 0) { goi.style.display='block'; setTimeout(function() { document.getElementById('dimg').style.backgroundPosition='' + 0 + 'px ' + 0 + 'px'; setInterval(function() { if (1 == 11) { window.stop(); } else { goi.src=goi.src; } },1); }, 20000); }" id=mygimage src='' style='display:BLOCK;'></img>
<form target=myif style=display:none; method=POST id=myform action='./agtoslides.php'>
<input type=hidden name=agname id=agname value=''></input>
<input type=hidden name=slidenumber id=slidenumber value='1'></input>
<input type=hidden name=random id=random value='1'></input>
<input type=submit style=display:none; id=mysub></input>
</form>
<iframe onload="checkit(this);" style=display:none; name=myif id=myif src=></iframe>
<iframe style=display:none; id=myiftwo src=></iframe>
<iframe style='display:block;width:95%;height:800px;' id=myifthree src=/PHP/read_exif_off_image_rotate.php></iframe>
</body>
</html>