Do you believe in …
The power of the Guinea Pig
? Or is it the case that …
… is not proof enough that Guinea Pigs can form part of the solution, to the point where we found it the case that though, personally, we know of manys a “scratch Guinea Pig on the golf course” where they are all too shy to film themselves on YouTube … or perhaps too modest … and so we cannot present the achingly beautiful follow through of some of these creatures for you today, alas?! Still …
follow
throughalong ain’t bad
Which brings us to today’s work, following up on yesterday’s One Image Website Onpaste Uploading Device Copying Tutorial, feeling daunted by the difficulty of the idea of individualized editing sessions to try to encapsulate what we’ve learnt over the last three days regarding “One Image Website” more dynamic (via Copy buffer) photograph uploading functionality, and applying the thinking to the three categories of affected source codes here …
- index.php … we learnt in doing this, may not exist, in which case we create one … as the software means of uploading to create a new used image member of the “One Image Website” project involved
- index.html or index.htm … first responders … which need that new Asynchronous and Ajax code and the means by which either …
- graphical image Copy into buffer via some Edit->Select All, Edit->Copy (eg. within an Image Editor desktop application) (combination) option Edit->Pasted into a new HTML span contenteditable=true onpaste and onblur savvy events “uploading” helper … or …
- right click at first webpage (of one of these “One Image Website” projects) to get to a prompt window that can accept a data URI the likes of which Google Image Search (say, of “clipart”)->right click->Copy Image Address could glean for you as a representation of an image
… can be catered for as uploading conduits
- subsequent webpages interested in the image list … as well as not changing …
- the rest of any HTML and/or PHP are unaffected by any uploading thinking
… of the “wish we could be the Guinea Pig” gang among our other “One Image Website” project crew …
… we decided, instead, to write some “internal use only” PHP to avoid too many hiccups bringing the non Guinea Pigs along.
We started …
- one_image_website_generic_changes.php this way
- then to second draft
- then to third draft
- then to fourth draft
- then to fifth draft
- then to sixth draft
- then to seventh draft (and final one_image_website_generic_changes.php draft for now)
… following today’s animated GIF presentation build up where we get the bygone “One Image Website” project up and running.
Previous relevant One Image Website Onpaste Uploading Device Copying Tutorial is shown below.
Further to yesterday’s One Image Website Onpaste Uploading Hashtagging Tutorial you may be wondering about our original gambit statement wondering if regarding …
take a new relevant photograph (on an iPhone, for instance) … and then easily …
… upload? Aren’t we worried about the iPhone device end of …
- getting the image off the Camera app …
- and then referencing in the Photos app …
- via a long hover and choosing the Copy option
… will just fall upon deaf ears as far as our MacBook Air web browser use of the “One Image Website” webpage goes?
Well, read this “if an iPhone is connected to a MacBook Air can the copy buffer of the iPhone be transferred to the copy buffer of the MacBook Air?” ask …
Yes, if an iPhone is connected to a MacBook Air—or even just nearby—the copy buffer (clipboard) of the iPhone can be transferred to the copy buffer of the MacBook Air. Apple calls this feature Universal Clipboard.
It allows you to copy text, images, photos, and videos on your iPhone and instantly paste them onto your Mac (or vice versa).
Cute, huh?! If on the same network, and close, the iPhone and MacBook Air do not even need an Apple White Lead connection, necessarily, though we noticed it sped up the process!
Given the “smarts” at this end, today, we turned to …
var myxhr=null, formis=null, iclen=0, icsuffix='', extnew='.png', yehbutisob=true;
var ipuvalid=true, ipis='', lhend='', lhdata='', fourthousand=(document.URL.indexOf('diris=') != -1 ? 10000 : 4000), gencount=0, upcount=(document.URL.indexOf('data=%') != -1 ? eval('' + decodeURIComponent(document.URL.split('data=')[1].split('&')[0].split('#')[0]).split(',').length) : 0);
var fetchcmd="./index.php?diris=images&prefixis=DSC_0&startsuffix=279&endsuffix=364", within=false;
// Thanks to https://www.google.com/search?q=javascript+convert+png+to+jpg&rlz=1C5OZZY_en&oq=javascript+convert+png+to+jpg&gs_lcrp=EgZjaHJvbWUyCggAEEUYFhgeGDkyCAgBEAAYFhgeMggIAhAAGBYYHjINCAMQABiGAxiABBiKBTIHCAQQABjvBdIBCTEyNzIxajBqN6gCALACAA&sourceid=chrome&ie=UTF-8
const convertPngToJpg = (pngDataUrl) => {
const img = new Image();
img.onload = () => {
const canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
const ctx = canvas.getContext('2d');
// Optional: Fill white background (JPEGs don't support transparency)
ctx.fillStyle = "#FFFFFF";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(img, 0, 0);
// Get JPG as Data URL (quality 0.9)
const jpgDataUrl = canvas.toDataURL("image/jpeg", 0.1);
extnew='.jpg';
icsuffix=(' 0' + jpgDataUrl.length);
formis.append('newdurl', jpgDataUrl);
myxhr.open('POST', './index.php'); //, true);
myxhr.onreadystatechange=mstateChanged;
myxhr.send(formis);
console.log(jpgDataUrl);
};
img.src = pngDataUrl;
};
… as a solution to massive image png copy buffers coming off the camera being fed into an HTML5 canvas and out as a reduced size jpeg image to allow PHP $_POST methodologies used for the uploading process not be overwhelmed, as per the adjusted Ajax code …
function mstateChanged() {
var ioff=1, thisoff=1;
var vsoff=0, getridof='YouLlneverFinDtHis';
//document.title=document.title.substring(0,1) + ' readyState=' + myxhr.readyState + ' and status=' + myxhr.status + ' ' + iclen;
if (myxhr.readyState == 4) {
if (myxhr.status == 200) {
//alert(iclen);
setTimeout(function(){
if (document.URL.indexOf('#') != -1 && lhdata == '' && document.URL.indexOf('data=%') != -1) {
lhdata=(('' + location.search + decodeURIComponent(('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'').replace(/^\#/g,''))).split('data=')[1] ? decodeURIComponent(('' + location.search + decodeURIComponent(('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'').replace(/^\#/g,'')))).split('data=')[eval(-1 + decodeURIComponent(('' + location.search + decodeURIComponent(('' + location.hash).replace(/^undefined/g,'').replace(/^null/g,'').replace(/^\#/g,'')))).split('data=').length)].split('&')[0].split('#')[0] : '');
var coms=lhdata.split(',');
vsoff=eval('' + fetchcmd.split('endsuffix=')[1].split('&')[0].split('#')[0]);
getridof=fetchcmd.split('diris=')[1].split('&')[0].split('#')[0] + '/' + fetchcmd.split('prefixis=')[1].split('&')[0].split('#')[0];
for (var iuyt=0; iuyt<coms.length; iuyt++) {
//alert(coms[iuyt] + ' ... ' + getridof + ' ... ' + coms[iuyt].replace('[','').replace(']','').replace('"','').replace('"','').replace(getridof,''));
thisoff=eval(eval(coms[iuyt].replace('[','').replace(']','').replace('"','').replace('"','').replace(getridof,'').split('.')[0]) - vsoff + 1);
if (thisoff > ioff) { ioff=thisoff; }
}
}
if (document.URL.indexOf('#') == -1) {
if (lhdata == '' && fetchcmd.indexOf('endsuffix=') != -1) {
lhdata='["' + fetchcmd.split('diris=')[1].split('&')[0].split('#')[0] + '/' + fetchcmd.split('prefixis=')[1].split('&')[0].split('#')[0] + eval(1 + eval('' + fetchcmd.split('endsuffix=')[1].split('&')[0].split('#')[0])) + extnew + '"]';
lhend='#' + encodeURIComponent(eval(1 + number_of_image) + '.' + fetchcmd.split('endsuffix=')[1].split('&')[0].split('#')[0]) + '&diris=' + fetchcmd.split('diris=')[1] + '&data=' + encodeURIComponent(lhdata);
if (document.URL.indexOf(lhend.substring(1)) == -1) {
if (6 == 6) {
location.href=(document.URL.indexOf('?') != -1 ? document.URL.split('#')[0] + '&endbit=' + reduced(lhend).substring(1) + lhend : document.URL.split('#')[0] + '?endbit=' + reduced(lhend).substring(1) + lhend);
} else {
location.hash=lhend;
}
}
}
} else if (lhdata.indexOf('[') != -1) {
lhdata=lhdata.replace('[', '["' + fetchcmd.split('diris=')[1].split('&')[0].split('#')[0] + '/' + fetchcmd.split('prefixis=')[1].split('&')[0].split('#')[0] + eval(ioff + eval('' + fetchcmd.split('endsuffix=')[1].split('&')[0].split('#')[0])) + extnew + '",');
lhend='#' + encodeURIComponent(eval(1 + number_of_image) + '.' + fetchcmd.split('endsuffix=')[1].split('&')[0].split('#')[0]) + '&diris=' + fetchcmd.split('diris=')[1] + '&data=' + encodeURIComponent(lhdata);
if (document.URL.indexOf(lhend.substring(1)) == -1) {
if (6 == 6) {
location.href=(document.URL.indexOf('?') != -1 ? document.URL.split('&')[0].replace('data=','daWASta=').replace('?diris=','?dirWASis=').replace('?endbit=','?endWASbit=') + '&endbit=' + reduced(lhend).substring(1) + lhend : document.URL.split('#')[0].replace('data=','daWASta=') + '?endbit=' + reduced(lhend).substring(1) + lhend);
} else {
location.hash=lhend;
}
}
}
within=false;
}, 26000);
}
}
}
function uplitc(icontis) {
if (icontis.indexOf('data:image/') == 0) {
//document.title='A';
myxhr = new XMLHttpRequest();
formis = new FormData();
formis.append('diris', fetchcmd.split('diris=')[1].split('&')[0].split('#')[0]);
formis.append('prefixis', fetchcmd.split('prefixis=')[1].split('&')[0].split('#')[0]);
formis.append('startsuffix', fetchcmd.split('startsuffix=')[1].split('&')[0].split('#')[0]);
formis.append('endsuffix', fetchcmd.split('endsuffix=')[1].split('&')[0].split('#')[0]);
iclen=eval('' + icontis.length);
extnew='.' + icontis.split('data:image/')[1].split(',')[0].split(';')[0].replace('jpeg','jpg');
if (iclen > 9000000) {
convertPngToJpg(icontis);
} else {
formis.append('newdurl', icontis);
myxhr.open('POST', './index.php'); //, true);
myxhr.send(formis);
}
}
}
function uplit(divo, isonblurnotonpaste) {
var icontis='';
if (isonblurnotonpaste != 0) {
yehbutisob=true;
}
if (divo.innerHTML.indexOf('data:image/') == 0) {
icontis=divo.innerHTML;
divo.innerHTML='';
divo.title=icontis;
//document.title='B';
myxhr = new XMLHttpRequest();
formis = new FormData();
formis.append('diris', fetchcmd.split('diris=')[1].split('&')[0].split('#')[0]);
formis.append('prefixis', fetchcmd.split('prefixis=')[1].split('&')[0].split('#')[0]);
formis.append('startsuffix', fetchcmd.split('startsuffix=')[1].split('&')[0].split('#')[0]);
formis.append('endsuffix', fetchcmd.split('endsuffix=')[1].split('&')[0].split('#')[0]);
iclen=eval('' + icontis.length);
extnew='.' + icontis.split('data:image/')[1].split(',')[0].split(';')[0].replace('jpeg','jpg');
if (iclen > 9000000) {
convertPngToJpg(icontis);
} else {
formis.append('newdurl', icontis);
myxhr.open('POST', './index.php'); //, true);
myxhr.onreadystatechange=mstateChanged;
myxhr.send(formis);
}
//alert(78);
//setTimeout(function(){ within=false; }, 6000);
} else if (divo.innerHTML.indexOf('"data:image/') != -1) {
icontis='data:image/' + divo.innerHTML.split('data:image/')[1].split('"')[0];
divo.innerHTML='';
divo.title=icontis;
//document.title='C';
myxhr = new XMLHttpRequest();
formis = new FormData();
formis.append('diris', fetchcmd.split('diris=')[1].split('&')[0].split('#')[0]);
formis.append('prefixis', fetchcmd.split('prefixis=')[1].split('&')[0].split('#')[0]);
formis.append('startsuffix', fetchcmd.split('startsuffix=')[1].split('&')[0].split('#')[0]);
formis.append('endsuffix', fetchcmd.split('endsuffix=')[1].split('&')[0].split('#')[0]);
iclen=eval('' + icontis.length);
extnew='.' + icontis.split('data:image/')[1].split(',')[0].split(';')[0].replace('jpeg','jpg');
if (iclen > 9000000) {
convertPngToJpg(icontis);
} else {
formis.append('newdurl', icontis);
myxhr.open('POST', './index.php'); //, true);
myxhr.onreadystatechange=mstateChanged;
myxhr.send(formis);
}
//alert(278);
//setTimeout(function(){ within=false; }, 6000);
} else if (eval('' + divo.innerHTML.length) < 30 && isonblurnotonpaste == 0) {
yehbutisob=false;
setTimeout(function(){
if (!yehbutisob) {
document.getElementById('offscreen').focus();
yehbutisob=true;
}
}, 8000);
} else {
setTimeout(function(){ within=false; }, 56000);
}
}
… helped out by changed onrightclick.js external Javascript.
Previous relevant One Image Website Onpaste Uploading Hashtagging Tutorial is shown below.
You guessed it! Yesterday’s One Image Website Onpaste Uploading Tutorial‘s work was working just within the realms of those “first webpages” occurring within the “One Image Website” project paradigm, but that we needed to pass onto subsequent webpages this “new image uploaded” list as ….
- hashtagged data … but also …
- argumented data (ie. ? and & arguments) for those “first webpages” occurring within the “One Image Website” project paradigm …
… the reason being that document.referrer cannot be used to glean hashtagged data. Luckily in this project that second requirement above, which asks for a true document reload, is not the end of the woooorrrrllllddd, as we know it, and means we can get help from the external Javascript we use in these projects, as per …
- yesterday’s changed onrightclick.js as a precursor to …
- today’s changed onrightclick.js external Javascript …
… featuring a new Javascript function the subsequent webpages can call just after any …
image_list = new Array();
… that being …
initthearr(image_list);
… as per …
var prefx='';
function reduced(documentreferrer) {
if (('' + documentreferrer).indexOf('data=') != -1) {
if (('' + documentreferrer).indexOf('diris=') != -1) {
if (prefx == '' && ('' + documentreferrer).indexOf('prefixis=') != -1) {
prefx=decodeURIComponent(('' + documentreferrer).split('diris=')[1].split('&')[0].split('#')[0]) + '/' + decodeURIComponent(('' + documentreferrer).split('prefixis=')[1].split('&')[0].split('#')[0]);
}
}
}
if (prefx != '') {
if (documentreferrer.indexOf(encodeURIComponent(prefx)) != -1) {
while (documentreferrer.indexOf(encodeURIComponent(prefx)) != -1) {
documentreferrer=documentreferrer.replace(encodeURIComponent(prefx),'');
}
}
}
return documentreferrer;
}
function initthearr(inarr) {
var fort=false, jsonstr='', datas=[], inm=0;
if (('' + location.hash).indexOf('data=') != -1) {
if (('' + location.hash).indexOf('diris=') != -1) {
if (prefx == '' && ('' + location.hash).indexOf('prefixis=') != -1) {
prefx=decodeURIComponent(('' + location.hash).split('diris=')[1].split('&')[0].split('#')[0]) + '/' + decodeURIComponent(('' + location.hash).split('prefixis=')[1].split('&')[0].split('#')[0]);
}
}
jsonstr=decodeURIComponent(('' + location.hash).split('data=')[1].split('&')[0].split('#')[0]);
datas=jsonstr.split(',');
for (inm=0; inm<datas.length; inm++) {
inarr[image_index++] = new imageItem(prefx + datas[inm].replace((prefx == '' ? 'yOuLlneverfindThIs' : prefx),'').replace('[','').replace(']','').replace('"','').replace('"',''));
console.log('ADDed ' + datas[inm].replace((prefx == '' ? 'yOuLlneverfindThIs' : prefx),'').replace('[','').replace(']','').replace('"','').replace('"',''));
fort=true;
}
} else if (('' + document.referrer).indexOf('data=') != -1) {
if (('' + document.referrer).indexOf('diris=') != -1) {
if (prefx == '' && ('' + document.referrer).indexOf('prefixis=') != -1) {
prefx=decodeURIComponent(('' + document.referrer).split('diris=')[1].split('&')[0].split('#')[0]) + '/' + decodeURIComponent(('' + document.referrer).split('prefixis=')[1].split('&')[0].split('#')[0]);
}
}
jsonstr=decodeURIComponent(('' + document.referrer).split('data=')[1].split('&')[0].split('#')[0]);
//alert(jsonstr);
datas=jsonstr.split(',');
for (inm=0; inm<datas.length; inm++) {
inarr[image_index++] = new imageItem(prefx + datas[inm].replace((prefx == '' ? 'yOuLlneverfindThIs' : prefx),'').replace('[','').replace(']','').replace('"','').replace('"',''));
console.log('AddEd ' + prefx + datas[inm].replace((prefx == '' ? 'yOuLlneverfindThIs' : prefx),'').replace('[','').replace(']','').replace('"','').replace('"',''));
fort=true;
}
}
return fort;
}
… in order to avoid any Asynchronous concerns in these subsequent webpages. The ordering of external Javascript loading …
<script type=text/javascript src='/onrightclick.js?rand=86475'></script>
… is sensitive here, and for the most part, is moved to above the “inline Javascript” loading within the head webpage element, to help make all this idea function, all the way back from changes to inline Javascript parts to the initialization code of (our Guinea Pig) “first webpage” occurring within the “One Image Website” project paradigm …
var image_index = 0;
var number_of_image = 0;
var myxhr=null, formis=null;
var ipuvalid=true, ipis='', lhend='', lhdata='';
var fetchcmd="./index.php?diris=images&prefixis=DSC_0&startsuffix=279&endsuffix=364";
// Thanks to https://stackoverflow.com/questions/74997800/how-to-code-a-synchronous-wrapper-for-jquery-ajax-functions
(async () => {
const resip = await fetch("./index.php?getmeip=" + Math.floor(Math.random() * 198978675), {/* options here */});
const dataip = await resip.json();
for (var inmip=0; inmip<dataip.length; inmip++) {
if (inmip == eval(-1 + dataip.length)) {
ipis='' + dataip[inmip];
if (inmip != 0) {
ipuvalid=false;
setTimeout(nag, 200);
}
}
}
})();
image_list = new Array();
//if (initthearr(image_list)) {
// lhend=lhend;
//
//} else
if (1 == 1) {
// Thanks to https://stackoverflow.com/questions/74997800/how-to-code-a-synchronous-wrapper-for-jquery-ajax-functions
(async () => {
const res = await fetch(fetchcmd, {/* options here */});
const data = await res.json();
for (var inm=0; inm<data.length; inm++) {
lhend='# ';
if (lhdata == '') {
lhdata='["' + data[inm] + '"]';
} else {
lhdata=lhdata.replace(']', ',"' + data[inm] + '"]');
}
image_list[image_index++] = new imageItem(data[inm]);
console.log('Added ' + data[inm]);
}
console.log(data);
console.log("Some code after that uses data");
setTimeout(function(){
if (lhend == '# ') {
//lhend='#' + encodeURIComponent(number_of_image + '.364') + '&fetch=' + encodeURIComponent(fetchcmd) + '&data=' + encodeURIComponent(lhdata);
lhend='#' + encodeURIComponent(number_of_image + '.364') + '&diris=' + fetchcmd.split('diris=')[1] + '&data=' + encodeURIComponent(lhdata);
if (document.URL.indexOf(lhend.substring(1)) == -1) {
if (6 == 6) {
location.href=(document.URL.indexOf('?') != -1 ? document.URL.split('#')[0] + '&endbit=' + reduced(lhend).substring(1) + lhend : document.URL.split('#')[0] + '?endbit=' + reduced(lhend).substring(1) + lhend);
} else {
location.hash=lhend;
}
}
console.warn(image_list[0]);
//lhend=' ';
}
}, 2000);
})();
}
setTimeout(function(){
image_list[image_index++] = new imageItem('images/DSC_0279.jpg');
image_list[image_index++] = new imageItem('images/DSC_0280.jpg');
image_list[image_index++] = new imageItem('images/DSC_0281.jpg');
image_list[image_index++] = new imageItem('images/DSC_0282.jpg');
image_list[image_index++] = new imageItem('images/DSC_0283.jpg');
image_list[image_index++] = new imageItem('images/DSC_0284.jpg');
image_list[image_index++] = new imageItem('images/DSC_0285.jpg');
image_list[image_index++] = new imageItem('images/DSC_0286.jpg');
image_list[image_index++] = new imageItem('images/DSC_0287.jpg');
image_list[image_index++] = new imageItem('images/DSC_0288.jpg');
image_list[image_index++] = new imageItem('images/DSC_0289.jpg');
image_list[image_index++] = new imageItem('images/DSC_0290.jpg');
image_list[image_index++] = new imageItem('images/DSC_0291.jpg');
image_list[image_index++] = new imageItem('images/DSC_0292.jpg');
image_list[image_index++] = new imageItem('images/DSC_0293.jpg');
image_list[image_index++] = new imageItem('images/DSC_0294.jpg');
image_list[image_index++] = new imageItem('images/DSC_0295.jpg');
image_list[image_index++] = new imageItem('images/DSC_0296.jpg');
image_list[image_index++] = new imageItem('images/DSC_0297.jpg');
image_list[image_index++] = new imageItem('images/DSC_0298.jpg');
image_list[image_index++] = new imageItem('images/DSC_0299.jpg');
image_list[image_index++] = new imageItem('images/DSC_0300.jpg');
image_list[image_index++] = new imageItem('images/DSC_0301.jpg');
image_list[image_index++] = new imageItem('images/DSC_0302.jpg');
image_list[image_index++] = new imageItem('images/DSC_0303.jpg');
image_list[image_index++] = new imageItem('images/DSC_0304.jpg');
image_list[image_index++] = new imageItem('images/DSC_0305.jpg');
image_list[image_index++] = new imageItem('images/DSC_0306.jpg');
image_list[image_index++] = new imageItem('images/DSC_0307.jpg');
image_list[image_index++] = new imageItem('images/DSC_0308.jpg');
image_list[image_index++] = new imageItem('images/DSC_0309.jpg');
image_list[image_index++] = new imageItem('images/DSC_0310.jpg');
image_list[image_index++] = new imageItem('images/DSC_0311.jpg');
image_list[image_index++] = new imageItem('images/DSC_0312.jpg');
image_list[image_index++] = new imageItem('images/DSC_0313.jpg');
image_list[image_index++] = new imageItem('images/DSC_0314.jpg');
image_list[image_index++] = new imageItem('images/DSC_0315.jpg');
image_list[image_index++] = new imageItem('images/DSC_0316.jpg');
image_list[image_index++] = new imageItem('images/DSC_0317.jpg');
image_list[image_index++] = new imageItem('images/DSC_0318.jpg');
image_list[image_index++] = new imageItem('images/DSC_0319.jpg');
image_list[image_index++] = new imageItem('images/DSC_0320.jpg');
image_list[image_index++] = new imageItem('images/DSC_0321.jpg');
image_list[image_index++] = new imageItem('images/DSC_0322.jpg');
image_list[image_index++] = new imageItem('images/DSC_0323.jpg');
image_list[image_index++] = new imageItem('images/DSC_0324.jpg');
image_list[image_index++] = new imageItem('images/DSC_0325.jpg');
image_list[image_index++] = new imageItem('images/DSC_0326.jpg');
image_list[image_index++] = new imageItem('images/DSC_0327.jpg');
image_list[image_index++] = new imageItem('images/DSC_0328.jpg');
image_list[image_index++] = new imageItem('images/DSC_0329.jpg');
image_list[image_index++] = new imageItem('images/DSC_0330.jpg');
image_list[image_index++] = new imageItem('images/DSC_0331.jpg');
image_list[image_index++] = new imageItem('images/DSC_0332.jpg');
image_list[image_index++] = new imageItem('images/DSC_0333.jpg');
image_list[image_index++] = new imageItem('images/DSC_0334.jpg');
image_list[image_index++] = new imageItem('images/DSC_0335.jpg');
image_list[image_index++] = new imageItem('images/DSC_0336.jpg');
image_list[image_index++] = new imageItem('images/DSC_0337.jpg');
image_list[image_index++] = new imageItem('images/DSC_0338.jpg');
image_list[image_index++] = new imageItem('images/DSC_0339.jpg');
image_list[image_index++] = new imageItem('images/DSC_0340.jpg');
image_list[image_index++] = new imageItem('images/DSC_0341.jpg');
image_list[image_index++] = new imageItem('images/DSC_0342.jpg');
image_list[image_index++] = new imageItem('images/DSC_0343.jpg');
image_list[image_index++] = new imageItem('images/DSC_0344.jpg');
image_list[image_index++] = new imageItem('images/DSC_0345.jpg');
image_list[image_index++] = new imageItem('images/DSC_0346.jpg');
image_list[image_index++] = new imageItem('images/DSC_0347.jpg');
image_list[image_index++] = new imageItem('images/DSC_0348.jpg');
image_list[image_index++] = new imageItem('images/DSC_0349.jpg');
image_list[image_index++] = new imageItem('images/DSC_0350.jpg');
image_list[image_index++] = new imageItem('images/DSC_0351.jpg');
image_list[image_index++] = new imageItem('images/DSC_0352.jpg');
image_list[image_index++] = new imageItem('images/DSC_0353.jpg');
image_list[image_index++] = new imageItem('images/DSC_0354.jpg');
image_list[image_index++] = new imageItem('images/DSC_0355.jpg');
image_list[image_index++] = new imageItem('images/DSC_0356.jpg');
image_list[image_index++] = new imageItem('images/DSC_0357.jpg');
image_list[image_index++] = new imageItem('images/DSC_0358.jpg');
image_list[image_index++] = new imageItem('images/DSC_0359.jpg');
image_list[image_index++] = new imageItem('images/DSC_0360.jpg');
image_list[image_index++] = new imageItem('images/DSC_0361.jpg');
image_list[image_index++] = new imageItem('images/DSC_0362.jpg');
image_list[image_index++] = new imageItem('images/DSC_0363.jpg');
image_list[image_index++] = new imageItem('images/DSC_0364.jpg');
//alert('yay ' + lhend);
number_of_image = image_list.length;
if ((lhend + ' ').substring(0,1) == '#') {
setTimeout(function(){
number_of_image = image_list.length;
}, 2000);
}
if (lhend == '#') { lhend='#' + encodeURIComponent(number_of_image + '.364') + '&fetch=' + encodeURIComponent(fetchcmd) + '&data=' + encodeURIComponent(lhdata); alert(lhend); location.hash=lhend; lhend=''; }
}, 1000);
To most, it is still “undercover” trying out our “still at the Guinea Pig upload functionality thinking stage” Street Art “One Image Website” project.
Previous relevant One Image Website Onpaste Uploading Tutorial is shown below.
The onpaste event referencing work of the recent Using Document Writeln Onpaste Tutorial set us to thinking about the unwieldy nature of our “One Image Website” series of photographic projects ability to, on the fly, these days …
- take a new relevant photograph (on an iPhone, for instance) … and then easily …
- get some functionality on the “One Image Websites” (our Guinea Pig, here, being our Street Art project) to accept either …
- graphical image Copy into buffer via some Edit->Select All, Edit->Copy (eg. within an Image Editor desktop application) (combination) option Edit->Pasted into a new HTML span contenteditable=true onpaste and onblur savvy events “uploading” helper … or …
- right click at first webpage (of one of these “One Image Website” projects) to get to a prompt window that can accept a data URI the likes of which Google Image Search (say, of “clipart”)->right click->Copy Image Address could glean for you as a representation of an image
Where’s the security and moderation here? Any upload operation needs to worry about that, huh?! Well, we limit it via IP address at this stage, in our Guinea Pig start to proceedings, and will monitor over time.
Let’s start, codewise with the pretty well self contained PHP block of code that is new for this work …
<?php
$oklist=['0::1', '1.156.90.221'];
function server_remote_addr() {
global $ris;
$rma = $_SERVER['REMOTE_ADDR'];
if ($rma != "") {
$qris = $rma;
} else if ($rma == "") {
$rma = $qris;
}
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
// you can add different browsers with the same way ..
if(preg_match('/(chromium)[ \/]([\w.]+)/', $ua))
$rma = '000000'.$rma;
elseif(preg_match('/(chrome)[ \/]([\w.]+)/', $ua))
$rma = '00000'.$rma;
elseif(preg_match('/(safari)[ \/]([\w.]+)/', $ua))
$rma = '0000'.$rma;
elseif(preg_match('/(opera)[ \/]([\w.]+)/', $ua))
$rma = '000'.$rma;
elseif(preg_match('/(msie)[ \/]([\w.]+)/', $ua))
$rma = '00'.$rma;
elseif(preg_match('/(mozilla)[ \/]([\w.]+)/', $ua))
$rma = '0'.$rma;
//echo "<p>".$ua.$rma."</p>";
return $rma;
}
if (isset($_GET['getmeip'])) {
$okipwise=false;
$visip=server_remote_addr();
for ($inb=0; $inb<sizeof($oklist); $inb++) {
if (strpos($visip . '!', $oklist[$inb] . '!') !== false) {
$okipwise=true;
}
}
if ($okipwise) {
echo '["' . server_remote_addr() . '"]';
} else {
echo '["","' . server_remote_addr() . '"]';
}
exit;
} else if (isset($_GET['diris']) && isset($_GET['prefixis']) && isset($_GET['startsuffix']) && isset($_GET['endsuffix'])) {
$arrbit='';
if ($_GET['prefixis'] != '' && $_GET['diris'] != '' && $_GET['startsuffix'] != '' && $_GET['endsuffix'] != '') {
foreach(glob(str_replace('+',' ',urldecode($_GET['diris'])) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['prefixis'])) . '*.*g*') as $filename) {
if (strpos($filename, str_replace('+',' ',urldecode($_GET['diris'])) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['prefixis']))) !== false) {
$restfnamebit=explode('.', explode(str_replace('+',' ',urldecode($_GET['diris'])) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['prefixis'])), $filename)[1])[0];
if ($restfnamebit < str_replace('+',' ',urldecode($_GET['startsuffix'])) || $restfnamebit > str_replace('+',' ',urldecode($_GET['endsuffix']))) {
if ($arrbit == '') {
$arrbit='["' . $filename . '"]';
} else {
$arrbit=str_replace(']', ',"' . $filename . '"]', $arrbit);
}
}
}
}
if ($arrbit == '') {
echo "[]";
} else {
echo $arrbit;
}
exit;
}
echo "[]";
exit;
} else if (isset($_POST['newdurl']) && isset($_POST['diris']) && isset($_POST['prefixis']) && isset($_POST['startsuffix']) && isset($_POST['endsuffix'])) {
if (strpos(str_replace(' ','+',urldecode($_POST['newdurl'])), 'data:image/') !== false && $_POST['prefixis'] != '' && $_POST['diris'] != '' && $_POST['startsuffix'] != '' && $_POST['endsuffix'] != '') {
$okipwise=false;
$visip=server_remote_addr();
for ($inb=0; $inb<sizeof($oklist); $inb++) {
if (strpos($visip . '!', $oklist[$inb] . '!') !== false) {
$okipwise=true;
}
}
if ($okipwise) {
$proposedext='.' . str_replace('jpeg','jpg',explode(';',explode(',',explode('data:image/', str_replace(' ','+',urldecode($_POST['newdurl'])))[1])[0])[0]);
if (strpos($proposedext, 'g') !== false) {
$fidea=str_replace('+',' ',urldecode($_POST['endsuffix']));
$isthere=true;
$fnameproposed='';
while ($isthere) {
$isthere=false;
foreach(glob(str_replace('+',' ',urldecode($_POST['diris'])) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['prefixis'])) . $fidea . '.*g*') as $filename) {
$isthere=true;
}
if (!$isthere) {
$fnameproposed=str_replace('+',' ',urldecode($_POST['diris'])) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['prefixis'])) . $fidea . $proposedext;
} else {
$fidea++;
}
}
if ($fnameproposed != '') {
file_put_contents($fnameproposed, base64_decode(explode(";base64,", str_replace(' ','+',urldecode($_POST['newdurl'])))[1]));
}
}
}
}
exit;
}
?>
… and then there is some new “fetch” and Ajax rich HTML and Javascript as per …
| New Global Variables and Asynchronous section Javascript … |
|---|
|
| New Javascript functions … |
|
| New HTML span element … |
|
… that is “undercover” to most trying out our Street Art “One Image Website” project.
Previous relevant Using Document Writeln Onpaste Tutorial is shown below.
Regarding yesterday’s Using Document Writeln Primer Tutorial you might wonder …
Why involve either/both textarea and div (contenteditable=true) elements as “containers” of content?
Well, with yesterday’s starting onblur (just) event gambit, it’s a very pertinent question, but, today, we introduce onpaste event work, and involving this event with the div element can have it distinguishing itself, able to accept graphical (eg. image) content. For example, the user can have their cursor placed into the div element and have been in an image editor having Edit->Select Alled and Edit->Copyed graphical content, then that can be Edit->Pasted into the div as graphical content.
As you might imagine, this opens a Pandora’s Box of possibilities regarding image sizing, but we apply inline CSS styling …
style='object-fit:contain;width:100%;height:100%;'
… to the img data URIed element within the div element that happens when graphical content is pasted into it, so that the graphical data is unlikely to spill too far outside the div bounds, assuming only one image is pasted, that is.
So feel free to try a changed using_writeln.html first draft Using (Document) Writeln web application for you to try yourself.
Previous relevant Using Document Writeln Primer Tutorial is shown below.
The other day we stumbled on some advice leading us to use …
document.writeln([html-content]);
… rather than our usual “go to” …
document.write([html-content]);
And so we wrote a “proof of concept” using_writeln.html first draft Using (Document) Writeln web application for you to try yourself.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.







