// web_share_api_test.js
// RJM Programming
// July, 2022
// Thanks to https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share
// Help out web_share_api_test.html perhaps
var czhr=null;
var czform=null;
var wsadate=new Date();
var lfd=String.fromCharCode(10);
var bighuh=('' + parent.document.URL + '&' + document.URL + '&' + top.document.head.innerHTML + top.document.body.innerHTML);
//console.log(('' + parent.document.URL + '&' + document.URL + '&' + top.document.head.innerHTML + top.document.body.innerHTML));
var prebit=(bighuh.indexOf('&word' + 'ing=') != -1 ? decodeURIComponent(bighuh.split('&word' + 'ing=')[1].split('&')[0].split('"')[0].split("'")[0]) : 'Timekeeping screenshots'); // + lessssi + ' or media or documents');
var postbit=(bighuh.indexOf('&word' + 'ing=') != -1 ? '' : ' perhaps?! '); // + lessssi + ' or media or documents');
var tmks='';
var canvc=' ', lastcanvc=' ';
var accl='image/*,video/*,audio/*,application/*,text/*';
var postlt='left:60%;top:calc(100% - 50px);';
var cci='Url';
var shareData = {
title: 'IT Blog',
text: 'RJM Programming Blog',
url: 'https://www.rjmprogramming.com.au/ITblog/'
};
if ((document.head.innerHTML + document.body.innerHTML).indexOf('web_share_api_test.js?pop' + 'ulate=') != -1 && (!document.getElementById('files') || !document.getElementById('output') || !document.getElementById('shareurl') || !document.getElementById('share'))) {
if (navigator.canShare) {
shareData = {
title: 'Quarter Hour Timer',
text: 'Quarter Hour Timer via MAMP local web server',
url: 'https://www.rjmprogramming.com.au/HTMLCSS/quarter_hour_timer.html#Quarter Hour Timer via MAMP local web server#Quarter Hour Timer'
};
document.body.innerHTML+="
";
setTimeout(eventuallyshow, 20000);
}
} else if ((document.head.innerHTML + document.body.innerHTML).indexOf('web_share_api_test.js?canv' + 'asshare=') != -1 && (!document.getElementById('files') || !document.getElementById('output') || !document.getElementById('shareurl') || !document.getElementById('share'))) {
if (navigator.canShare) {
canvc=tctowebp();
cci='Canvas Content Image URL';
setInterval(tctowebp, 20000);
tmks='Canvas contents.';
shareData = {
title: 'Canvas Content Share',
text: 'Canvas Content Share',
url: document.URL.substring(0,9) + document.URL.substring(9).split('/')[0] + '/canvas.webp'
};
if (document.URL.indexOf('/localhost') != -1) {
accl='.webp';
}
if (document.getElementById('dcm')) {
//alert(document.URL.toUpperCase());
document.getElementById('dcm').innerHTML+="
";
} else if (document.URL.indexOf('/signature_signature.htm') != -1) {
if (window.parent && document.URL.indexOf('/user_of_signature_signature.htm') == -1) {
if (parent.document.URL.indexOf('/user_of_signature_signature.htm') != -1 && 1 == 1) {
postlt+='left:-1300px;top:-1200px;display:none;';
}
}
//alert(document.URL.toLowerCase() + ' ... ' + postlt);
document.body.innerHTML+="
";
if (postlt.indexOf('display:none') != -1) { setTimeout(eventuallyshow, 20000); }
} else if (document.URL.indexOf('/user_of_signature_signature.htm') != -1) {
document.body.innerHTML+="
";
if (postlt.indexOf('display:none') != -1) { setTimeout(eventuallyshow, 20000); }
}
}
}
function cstateChanged() {
if (czhr.readyState == 4) {
if (czhr.status == 200) {
if (1 == 2) { alert('Did it'); }
if (document.getElementById('shareurl')) {
document.getElementById('shareurl').style.backgroundColor='yellow';
}
}
}
}
function tctowebp() {
var ourcanvc='';
var canvs=[];
if (window.top) {
canvs=top.document.getElementsByTagName('canvas');
}
if (eval('' + canvs.length) == 0 && window.parent) {
canvs=parent.document.getElementsByTagName('canvas');
}
if (eval('' + canvs.length) == 0) {
canvs=document.getElementsByTagName('canvas');
}
if (eval('' + canvs.length) == 0 && window.parent) {
canvs=parent.document.getElementsByTagName('canvas');
if (eval('' + canvs.length) == 0 && window.top) {
canvs=top.document.getElementsByTagName('canvas');
}
}
if (eval('' + canvs.length) > 0) {
ourcanvc=canvs[0].toDataURL('image/webp');
if (lastcanvc != ' ') {
if (lastcanvc != ourcanvc) {
lastcanvc=ourcanvc;
canvc=ourcanvc;
czhr = new XMLHttpRequest();
czform = new FormData();
czform.append('webpit', canvc);
czhr.onreadystatechange=cstateChanged;
czhr.open('post', './signature_signature.php', true);
czhr.send(czform);
} else {
if (document.getElementById('shareurl')) {
document.getElementById('shareurl').style.backgroundColor='#f9f9f9';
}
}
}
lastcanvc=ourcanvc;
}
return ourcanvc;
}
function getwsadate(dd, mm, yyyy, hh, mi) {
wsadate=new Date(yyyy, eval(-1 + eval('' + mm)), dd, hh, mi, 0, 0);
var outdstr=wsadate.toDateString() + ' ' + wsadate.toTimeString();
outdstr=outdstr.replace('Sun ', 'Sunday ').replace('Mon ', 'Monday ').replace('Tue ', 'Tuesday ').replace('Wed ', 'Wednesday ').replace('Thu ', 'Thursday ').replace('Fri ', 'Friday ').replace('Sat ', 'Saturday ');
outdstr=outdstr.replace(':00 ', ' ').replace(' Jan ', ' January ').replace(' Feb ', ' February ').replace(' Mar ', ' March ').replace(' Apr ', ' April ').replace(' Jun ', ' June ').replace(' Jul ', ' July ').replace(' Aug ', ' August ').replace(' Sep ', ' September ').replace(' Oct ', ' October ').replace(' Nov ', ' November ').replace(' Dec ', ' December ');
//console.log('tatd_' + yyyy + mm + dd + '_' + hh + mi);
if (document.getElementById('tatd_' + yyyy + mm + dd + '_' + hh + mi)) {
//console.log('yes tatd_' + yyyy + mm + dd + '_' + hh + mi);
if (document.getElementById('tatd_' + yyyy + mm + dd + '_' + hh + mi).value.trim() != '') {
outdstr+=' ' + String.fromCharCode(10) + '"' + document.getElementById('tatd_' + yyyy + mm + dd + '_' + hh + mi).value + '"';
} else if (document.getElementById('tatd_' + yyyy + mm + dd + '_' + hh + mi).innerHTML.trim() != '') {
outdstr+=' ' + String.fromCharCode(10) + '"' + document.getElementById('tatd_' + yyyy + mm + dd + '_' + hh + mi).innerHTML + '"';
}
}
lfd='';
return outdstr + String.fromCharCode(10);
}
function eventuallyshow() {
document.getElementById('mydivshare').style.display='block';
}
async function atclick() {
const files = document.getElementById('files').files;
var moressi='', ifl=0, lessssi='';
if (files.length === 0) {
shareurl();
document.getElementById('output').textContent = 'No files selected.';
return;
} else {
for (ifl=0; ifl {
const files = input.files;
var moressi='', ifl=0, lessssi='';
if (files.length === 0) {
shareurl();
output.textContent = 'No files selected.';
return;
} else {
for (ifl=0; ifl 1) {
shareData.text=decodeURIComponent(hs[1]);
shareData.title=decodeURIComponent(hs[1]);
}
if (hs.length > 2) {
shareData.title=decodeURIComponent(hs[2]);
}
}
try {
await navigator.share(shareData);
document.getElementById('output').textContent = shareData.text + ' shared successfully';
} catch(err) {
document.getElementById('output').textContent = 'Error: ' + err;
}
}
setTimeout(atthestart, 1000);