Local File Browsing Tool Stringency Tutorial

Local File Browsing Tool Stringency Tutorial

Local File Browsing Tool Stringency Tutorial

We tend to stand up and take notice when a “middleperson tool”, in the web application “scheme of things”, needs a change to improve a situation. Yesterday’s Open File Picker Experimental Status Tutorial “middleperson tool”, our inhouse local file browsing client_browsing.htm helper tool, is the case in point, for us, today.

With such a “tool” we tend to want it …

  • open and flexible … in the short term … but as it matures in usability you might start thinking to …
  • allow it, depending on the call, be “buttoned down” and “stringent”

… so that it only helps when the call parameters suggest it should. This is a sign of maturity with a “tool”, and if you want to string inhouse functionality together, you will rely on these well designed and modular “tools” you develop as you proceed. Please feed functionality into these “tools” rather than spreading it to “one off” web applications you are apt to forget exist over time, we’re recommending.

We’ve thought of a requirement, affecting local file browsing input functionality, that wil require …

  • exactly two (local files) selected
  • of two mimetype specifications ( ie. a mimetype where the second part is * … eg. image/* ) that must match

… else we’d like our local file browsing client_browsing.htm helper tool bail out, supplying no data information back to any parent caller web application.

This is definitely a piece of functionality we can make our “middleperson tool” be capable of taking on, so, like we say above, that “middleperson tool” should be modified to take on this new capablity, and have any calling web application start using a new GET arguments ( ie. ? and & URL ) arrangement when they need this new “stringency”.

And so we’re adding two new GET argument logics into “it’s mix” …

  1. numhastobe=[number of files to be selected] … optional … and/or …
  2. typehastobe=[list of mimetype specifications to satisfy] … optional
  3. … where …


    function readBlob(opt_startByte, opt_stopByte) {
    var hsf="", ourij=0, myform='';
    var blks=' ', variiuy=0, xssuffix='0', xnsuffix='2';
    var defto='html';
    var midw='_this_';

    isag=-1;

    files = document.getElementById('files').files;
    xx=[];
    yy=[];
    ten=500;
    ixy=0;
    awis=[];
    ahis=[];
    awx=[];
    awy=[];
    awid=[];
    reader=[];
    blob=[];
    //imgo=[];
    var ij=0;
    kij=0;
    kkij=0;
    lastiw=0;
    lastih=0;
    if (!files.length) {
    alert('Please select a file!');
    return;
    }
    iinum=files.length;
    if (window.parent && eval('' + iinum) > 0) {
    if (parent.document.getElementById('inum')) {
    parent.document.getElementById('inum').value='' + iinum;
    }
    }
    jjnum=0;
    var aneg='-';
    var vneg='-';
    var isnworry=false;
    var typeshavetobe=(location.search.split('typehastobe=')[1] ? ('' + (decodeURIComponent(location.search.split('typehastobe=')[1].split('&')[0]))) : ' ');
    var isn=(location.search.split('numhastobe=')[1] ? eval('' + (decodeURIComponent(location.search.split('numhastobe=')[1].split('&')[0]))) : 0);
    if (isn > 0) {
    isnworry=(location.search.split('numhastobe=')[1] ? (iinum != eval('' + (decodeURIComponent(location.search.split('numhastobe=')[1].split('&')[0])))) : false);
    }
    if (isnworry) {
    if (typeshavetobe.trim() != '') {
    alert('Have to select ' + isn + ' files that are ' + typeshavetobe.replace(/video/g, ' video ').replace(/pdf/g, ' pdf ').replace(/document/g, ' document ').replace(/audio/g, ' audio ').replace(/image/g, ' image ').replace(/text/g, ' text ').replace(/application/g, ' application ') + ' type files.');
    } else {
    alert('Have to select ' + isn + ' files.');
    }
    return '';
    }
    if (typeshavetobe != '') {
    wastypeshavetobe=typeshavetobe;
    for (ij=0; ij<files.length; ij++) {
    typeshavetobe=typeshavetobe.replace(('' + files[ij].type), '');
    typeshavetobe=typeshavetobe.replace(('' + files[ij].type).split('/')[0], '');
    if (files[ij].type.indexOf('/') != -1) {
    typeshavetobe=typeshavetobe.replace(('' + files[ij].type).split('/')[1], '');
    }
    }
    if (typeshavetobe.replace(/\//g,'').replace(/\*\./g,'').replace(/\,/g,'').trim() != '') {
    alert('Have to select ' + wastypeshavetobe.replace(/video/g, ' video ').replace(/audio/g, ' audio ').replace(/pdf/g, ' pdf ').replace(/document/g, ' document ').replace(/image/g, ' image ').replace(/text/g, ' text ').replace(/application/g, ' application ') + ' type files.');
    return '';
    }
    }

    for (ij=0; ij<files.length; ij++) {
    // go on and do lots more logic here that would send information back to the calling parent web application
    }
    }

    … incorporating additional bailing out possibilities in the changed client_browsing.htm “middleperson tool” you can see below using URL https://www.rjmprogramming.com.au/HTMLCSS/client_browsing.htm?numhastobe=3&typehastobe=imageaudiopdf in a scenario where it will only accept three image or audio or PDF local input files …

    Some “middleperson tools” are never meant to be standalone entities, but the job of testing changes is even easier when they are, because you can debug and step through your changes just by calling them up at the web browser address bar, to test new functionality, and that you haven’t stuffed any existant old functionality (which, after all, is even more important when the tests concern a “middleperson tool”).

    Stop Press

    Can you guess the musical connections? Happy new year!

    BtoB


    Tmol


    Glue


    IHad


    F1


    90am


    Sshh


    Faith



    Previous relevant Open File Picker Experimental Status Tutorial is shown below.

    Open File Picker Experimental Status Tutorial

    Open File Picker Experimental Status Tutorial

    The basis of yesterday’s Open File Picker of PDF Javascript Tutorial‘s functionality is showOpenFilePicker, an experimental Javascript offering.

    Which begs the question, at least for us …

    What is the alternative approach to trying a piece of experimental Javascript functionality, only to find your web browser environment does not support it?

    Well, there is the great Javascript typeof operator fitting the bill …

    The typeof operator returns the data type of a JavaScript variable.

    … we’re applying, now, in our changed file_open_picker.html Open File Picker Interfacing web application


    var sofp=('' + typeof(window.showOpenFilePicker));

    if (sofp != 'function') {
    rectx=document.getElementById('divmypdfbut').getBoundingClientRect();
    document.getElementById('divmypdfbut').style.borderLeft='1px dashed red';
    document.getElementById('divmypdfbut').style.position='absolute';
    document.getElementById('divmypdfbut').style.left='50%';
    document.getElementById('divmypdfbut').style.top='' + rectx.top + 'px';
    document.getElementById('divmypdfbut').innerHTML='<iframe onload=checkpif(this); id=ifmypdfbut frameborder=0 style="width:' + rectx.width + 'px;height:' + eval(1.5 * eval('' + rectx.height)) + 'px;" src="/php_calls_pdfimages.php?jghdjh#files"></iframe> PDF';
    document.getElementById('divmypdfbut').onmouseover=function(){ document.getElementById('divmypdfbut').style.width='700px'; document.getElementById('divmypdfbut').style.height='700px'; document.getElementById('ifmypdfbut').style.width='100%'; document.getElementById('ifmypdfbut').style.height='100%'; };
    document.getElementById('divmypdfbut').onmousedown=function(){ document.getElementById('divmypdfbut').style.width='700px'; document.getElementById('divmypdfbut').style.height='700px'; document.getElementById('ifmypdfbut').style.width='100%'; document.getElementById('ifmypdfbut').style.height='100%'; };
    document.getElementById('divmypdfbut').ontouchdown=function(){ document.getElementById('divmypdfbut').style.width='700px'; document.getElementById('divmypdfbut').style.height='700px'; document.getElementById('ifmypdfbut').style.width='100%'; document.getElementById('ifmypdfbut').style.height='100%'; };
    rectx=document.getElementById('divmybut').getBoundingClientRect();
    document.getElementById('divmybut').style.backgroundColor='yellow';
    document.getElementById('divmybut').style.position='absolute';
    document.getElementById('divmybut').style.left='0%';
    document.getElementById('divmybut').style.top='' + rectx.top + 'px';
    document.getElementById('divmybut').innerHTML='<iframe onload=checkppif(this); id=ifmybut frameborder=0 style="width:' + rectx.width + 'px;height:' + eval(1.5 * eval('' + rectx.height)) + 'px;" src="/HTMLCSS/user_of_signature_signature.html?fcol=' + Math.floor(Math.random() * 19878565) + '#dcmib"></iframe> Image';
    document.getElementById('divmybut').onmouseover=function(){ document.getElementById('divmybut').style.width='700px'; document.getElementById('divmybut').style.height='700px'; document.getElementById('ifmybut').style.width='700px'; document.getElementById('ifmybut').style.height='700px'; };
    document.getElementById('divmybut').onmousedown=function(){ document.getElementById('divmybut').style.width='700px'; document.getElementById('divmybut').style.height='700px'; document.getElementById('ifmybut').style.width='700px'; document.getElementById('ifmybut').style.height='700px'; };
    document.getElementById('divmybut').ontouchdown=function(){ document.getElementById('divmybut').style.width='700px'; document.getElementById('divmybut').style.height='700px'; document.getElementById('ifmybut').style.width='700px'; document.getElementById('ifmybut').style.height='700px'; };
    }

    … meaning web browsers not compatible get supplied web browser webpage functionality turning to our inhouse local file browsing client_browsing.htm specialist for alternative help, rather than giving up on the user, doing nothing, as you can try below.


    Previous relevant Open File Picker of PDF Javascript Tutorial is shown below.

    Open File Picker of PDF Javascript Tutorial

    Open File Picker of PDF Javascript Tutorial

    Yesterday’s Open File Picker Javascript Primer Tutorial browsed for …

    • image file … input data, and today we’d like to allow for the way to use the same showOpenFilePicker means by which to browse for local …
    • PDF file

    … input data, it being the online world’s first choice for a “hard printout” equivalent means of data expression. Online users use PDF for so many purposes, so us swivelling to allow for this input data type is likely to gel with what users have stored on their local devices, where the browsing takes place.

    Yesterday we …

    • allowed for canvas means of editing image data … and today we …
    • allow for the extraction of information from PDF data repositories

    … to output data options …

    • Video
    • Animated GIF
    • Images
    • HTML
    • XML
    • Excel
    • Word
    • Powerpoint

    … via interfacing to our inhouse modified

    <?php

    if (isset($_POST['pdfcont']) && isset($_POST['pdfname'])) {
    file_put_contents('/tmp/' . basename(str_replace('+',' ',urldecode($_POST['pdfname']))), base64_decode($_POST['pdfcont']));
    header('Location: ./php_calls_pdfimages.php?inpath=' . urlencode('/tmp/') . '&convertthis=' . urlencode('' . basename(str_replace('+',' ',urldecode($_POST['pdfname'])))));
    exit;
    } else if (isset($_GET['pdfcont']) && isset($_GET['pdfname'])) {
    file_put_contents('/tmp/' . basename(str_replace('+',' ',urldecode($_GET['pdfname']))), base64_decode($_GET['pdfcont']));
    header('Location: ./php_calls_pdfimages.php?inpath=' . urlencode('/tmp/') . '&convertthis=' . urlencode('' . basename(str_replace('+',' ',urldecode($_GET['pdfname'])))));
    exit;
    }

    ?>

    php_calls_pdfimages.php PHP interfacer to the great open source PDFimages product (you can read more about interfacing to from PDF to Images and Microsoft Office on AlmaLinux Tutorial) now installed up at RJM Programming’s AlmaLinux web server helping out the changed file_open_picker.html Open File Picker Interfacing web application you can also try, alas only successfully on non-mobile platforms (with experimental functionality), below.


    Previous relevant Open File Picker Javascript Primer Tutorial is shown below.

    Open File Picker Javascript Primer Tutorial

    Open File Picker Javascript Primer Tutorial

    There are other ways to go about local file browsing, regarding web applications using a web browser, than the HTML input type=file element way we’ve become so fond of here at RJM Programming with client_browsing.htm and we’re here, today, ready to talk about …


    Window: showOpenFilePicker() method

    … described as …

    The showOpenFilePicker() method of the Window interface shows a file picker that allows a user to select a file or multiple files and returns a handle for the file(s).

    … means of achieving this.

    Developing a …

    • browser for local image file …
    • transference of a returned “piece of data” …
    • used to create an img element object … and onto …
    • an HTML5 canvas element … via …
    • [canvasContext].drawImage([imageElementObject],0,0) … temporarily in the parent window … and later …
    • to an iframe element for an inhouse image editing via canvas web application

    … what took half the day was the replacement of with this alternative response object return as an easier means by which clientside Javascript can convert real image file data into a useful data URI which is needed to form img element content that [canvasContext].drawImage([imgElementObject],0,0) can use to get to an Image Editing scenario …


    const pickerOpts = {
    types: [
    {
    description: "Images",
    accept: {
    "image/*": [".png", ".gif", ".jpeg", ".jpg"],
    },
    },
    ],
    excludeAcceptAllOption: true,
    multiple: false,
    };

    // create a reference for our file handle
    let fileHandle;

    async function getFile() {
    // open file picker, destructure the one element returned array
    [fileHandle] = await window.showOpenFilePicker(pickerOpts);

    // run code with our fileHandle
    const file = await fileHandle.getFile();
    const content = await file.arrayBuffer(); //text();
    const contents = _arrayBufferToBase64(content);
    //alert('' + file.name + ' ... ' + (contents));
    const canvaso=document.getElementById('canvas');
    const context=canvaso.getContext('2d');


    nimg=new Image();

    nimg.onload = (event) => {
    canvaso.width=event.target.width;
    canvaso.height=event.target.height;
    context.drawImage(event.target, 0, 0);
    document.getElementById('cif').src='/HTMLCSS/user_of_signature_signature.html?rand=' + Math.floor(Math.random() * 1987867);
    document.getElementById('cif').style.display='block';
    };

    nimg.src='data:image/' + file.name.split('.')[eval(-1 + file.name.split('.').length)].split('?')[0].split('#')[0].toLowerCase().replace('jpg','jpeg') + ';base64,' + ((((contents))));
    }

    … within today’s proof of concept Show Open File Picker Image Editing web application you can also try, alas only successfully on non-mobile platforms (with experimental functionality), below …

    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.

Posted in eLearning, Event-Driven Programming, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Open File Picker Experimental Status Tutorial

Open File Picker Experimental Status Tutorial

Open File Picker Experimental Status Tutorial

The basis of yesterday’s Open File Picker of PDF Javascript Tutorial‘s functionality is showOpenFilePicker, an experimental Javascript offering.

Which begs the question, at least for us …

What is the alternative approach to trying a piece of experimental Javascript functionality, only to find your web browser environment does not support it?

Well, there is the great Javascript typeof operator fitting the bill …

The typeof operator returns the data type of a JavaScript variable.

… we’re applying, now, in our changed file_open_picker.html Open File Picker Interfacing web application


var sofp=('' + typeof(window.showOpenFilePicker));

if (sofp != 'function') {
rectx=document.getElementById('divmypdfbut').getBoundingClientRect();
document.getElementById('divmypdfbut').style.borderLeft='1px dashed red';
document.getElementById('divmypdfbut').style.position='absolute';
document.getElementById('divmypdfbut').style.left='50%';
document.getElementById('divmypdfbut').style.top='' + rectx.top + 'px';
document.getElementById('divmypdfbut').innerHTML='<iframe onload=checkpif(this); id=ifmypdfbut frameborder=0 style="width:' + rectx.width + 'px;height:' + eval(1.5 * eval('' + rectx.height)) + 'px;" src="/php_calls_pdfimages.php?jghdjh#files"></iframe> PDF';
document.getElementById('divmypdfbut').onmouseover=function(){ document.getElementById('divmypdfbut').style.width='700px'; document.getElementById('divmypdfbut').style.height='700px'; document.getElementById('ifmypdfbut').style.width='100%'; document.getElementById('ifmypdfbut').style.height='100%'; };
document.getElementById('divmypdfbut').onmousedown=function(){ document.getElementById('divmypdfbut').style.width='700px'; document.getElementById('divmypdfbut').style.height='700px'; document.getElementById('ifmypdfbut').style.width='100%'; document.getElementById('ifmypdfbut').style.height='100%'; };
document.getElementById('divmypdfbut').ontouchdown=function(){ document.getElementById('divmypdfbut').style.width='700px'; document.getElementById('divmypdfbut').style.height='700px'; document.getElementById('ifmypdfbut').style.width='100%'; document.getElementById('ifmypdfbut').style.height='100%'; };
rectx=document.getElementById('divmybut').getBoundingClientRect();
document.getElementById('divmybut').style.backgroundColor='yellow';
document.getElementById('divmybut').style.position='absolute';
document.getElementById('divmybut').style.left='0%';
document.getElementById('divmybut').style.top='' + rectx.top + 'px';
document.getElementById('divmybut').innerHTML='<iframe onload=checkppif(this); id=ifmybut frameborder=0 style="width:' + rectx.width + 'px;height:' + eval(1.5 * eval('' + rectx.height)) + 'px;" src="/HTMLCSS/user_of_signature_signature.html?fcol=' + Math.floor(Math.random() * 19878565) + '#dcmib"></iframe> Image';
document.getElementById('divmybut').onmouseover=function(){ document.getElementById('divmybut').style.width='700px'; document.getElementById('divmybut').style.height='700px'; document.getElementById('ifmybut').style.width='700px'; document.getElementById('ifmybut').style.height='700px'; };
document.getElementById('divmybut').onmousedown=function(){ document.getElementById('divmybut').style.width='700px'; document.getElementById('divmybut').style.height='700px'; document.getElementById('ifmybut').style.width='700px'; document.getElementById('ifmybut').style.height='700px'; };
document.getElementById('divmybut').ontouchdown=function(){ document.getElementById('divmybut').style.width='700px'; document.getElementById('divmybut').style.height='700px'; document.getElementById('ifmybut').style.width='700px'; document.getElementById('ifmybut').style.height='700px'; };
}

… meaning web browsers not compatible get supplied web browser webpage functionality turning to our inhouse local file browsing client_browsing.htm specialist for alternative help, rather than giving up on the user, doing nothing, as you can try below.


Previous relevant Open File Picker of PDF Javascript Tutorial is shown below.

Open File Picker of PDF Javascript Tutorial

Open File Picker of PDF Javascript Tutorial

Yesterday’s Open File Picker Javascript Primer Tutorial browsed for …

  • image file … input data, and today we’d like to allow for the way to use the same showOpenFilePicker means by which to browse for local …
  • PDF file

… input data, it being the online world’s first choice for a “hard printout” equivalent means of data expression. Online users use PDF for so many purposes, so us swivelling to allow for this input data type is likely to gel with what users have stored on their local devices, where the browsing takes place.

Yesterday we …

  • allowed for canvas means of editing image data … and today we …
  • allow for the extraction of information from PDF data repositories

… to output data options …

  • Video
  • Animated GIF
  • Images
  • HTML
  • XML
  • Excel
  • Word
  • Powerpoint

… via interfacing to our inhouse modified

<?php

if (isset($_POST['pdfcont']) && isset($_POST['pdfname'])) {
file_put_contents('/tmp/' . basename(str_replace('+',' ',urldecode($_POST['pdfname']))), base64_decode($_POST['pdfcont']));
header('Location: ./php_calls_pdfimages.php?inpath=' . urlencode('/tmp/') . '&convertthis=' . urlencode('' . basename(str_replace('+',' ',urldecode($_POST['pdfname'])))));
exit;
} else if (isset($_GET['pdfcont']) && isset($_GET['pdfname'])) {
file_put_contents('/tmp/' . basename(str_replace('+',' ',urldecode($_GET['pdfname']))), base64_decode($_GET['pdfcont']));
header('Location: ./php_calls_pdfimages.php?inpath=' . urlencode('/tmp/') . '&convertthis=' . urlencode('' . basename(str_replace('+',' ',urldecode($_GET['pdfname'])))));
exit;
}

?>

php_calls_pdfimages.php PHP interfacer to the great open source PDFimages product (you can read more about interfacing to from PDF to Images and Microsoft Office on AlmaLinux Tutorial) now installed up at RJM Programming’s AlmaLinux web server helping out the changed file_open_picker.html Open File Picker Interfacing web application you can also try, alas only successfully on non-mobile platforms (with experimental functionality), below.


Previous relevant Open File Picker Javascript Primer Tutorial is shown below.

Open File Picker Javascript Primer Tutorial

Open File Picker Javascript Primer Tutorial

There are other ways to go about local file browsing, regarding web applications using a web browser, than the HTML input type=file element way we’ve become so fond of here at RJM Programming with client_browsing.htm and we’re here, today, ready to talk about …


Window: showOpenFilePicker() method

… described as …

The showOpenFilePicker() method of the Window interface shows a file picker that allows a user to select a file or multiple files and returns a handle for the file(s).

… means of achieving this.

Developing a …

  • browser for local image file …
  • transference of a returned “piece of data” …
  • used to create an img element object … and onto …
  • an HTML5 canvas element … via …
  • [canvasContext].drawImage([imageElementObject],0,0) … temporarily in the parent window … and later …
  • to an iframe element for an inhouse image editing via canvas web application

… what took half the day was the replacement of with this alternative response object return as an easier means by which clientside Javascript can convert real image file data into a useful data URI which is needed to form img element content that [canvasContext].drawImage([imgElementObject],0,0) can use to get to an Image Editing scenario …


const pickerOpts = {
types: [
{
description: "Images",
accept: {
"image/*": [".png", ".gif", ".jpeg", ".jpg"],
},
},
],
excludeAcceptAllOption: true,
multiple: false,
};

// create a reference for our file handle
let fileHandle;

async function getFile() {
// open file picker, destructure the one element returned array
[fileHandle] = await window.showOpenFilePicker(pickerOpts);

// run code with our fileHandle
const file = await fileHandle.getFile();
const content = await file.arrayBuffer(); //text();
const contents = _arrayBufferToBase64(content);
//alert('' + file.name + ' ... ' + (contents));
const canvaso=document.getElementById('canvas');
const context=canvaso.getContext('2d');


nimg=new Image();

nimg.onload = (event) => {
canvaso.width=event.target.width;
canvaso.height=event.target.height;
context.drawImage(event.target, 0, 0);
document.getElementById('cif').src='/HTMLCSS/user_of_signature_signature.html?rand=' + Math.floor(Math.random() * 1987867);
document.getElementById('cif').style.display='block';
};

nimg.src='data:image/' + file.name.split('.')[eval(-1 + file.name.split('.').length)].split('?')[0].split('#')[0].toLowerCase().replace('jpg','jpeg') + ';base64,' + ((((contents))));
}

… within today’s proof of concept Show Open File Picker Image Editing web application you can also try, alas only successfully on non-mobile platforms (with experimental functionality), below …

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.

Posted in eLearning, Event-Driven Programming, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Open File Picker of PDF Javascript Tutorial

Open File Picker of PDF Javascript Tutorial

Open File Picker of PDF Javascript Tutorial

Yesterday’s Open File Picker Javascript Primer Tutorial browsed for …

  • image file … input data, and today we’d like to allow for the way to use the same showOpenFilePicker means by which to browse for local …
  • PDF file

… input data, it being the online world’s first choice for a “hard printout” equivalent means of data expression. Online users use PDF for so many purposes, so us swivelling to allow for this input data type is likely to gel with what users have stored on their local devices, where the browsing takes place.

Yesterday we …

  • allowed for canvas means of editing image data … and today we …
  • allow for the extraction of information from PDF data repositories

… to output data options …

  • Video
  • Animated GIF
  • Images
  • HTML
  • XML
  • Excel
  • Word
  • Powerpoint

… via interfacing to our inhouse modified

<?php

if (isset($_POST['pdfcont']) && isset($_POST['pdfname'])) {
file_put_contents('/tmp/' . basename(str_replace('+',' ',urldecode($_POST['pdfname']))), base64_decode($_POST['pdfcont']));
header('Location: ./php_calls_pdfimages.php?inpath=' . urlencode('/tmp/') . '&convertthis=' . urlencode('' . basename(str_replace('+',' ',urldecode($_POST['pdfname'])))));
exit;
} else if (isset($_GET['pdfcont']) && isset($_GET['pdfname'])) {
file_put_contents('/tmp/' . basename(str_replace('+',' ',urldecode($_GET['pdfname']))), base64_decode($_GET['pdfcont']));
header('Location: ./php_calls_pdfimages.php?inpath=' . urlencode('/tmp/') . '&convertthis=' . urlencode('' . basename(str_replace('+',' ',urldecode($_GET['pdfname'])))));
exit;
}

?>

php_calls_pdfimages.php PHP interfacer to the great open source PDFimages product (you can read more about interfacing to from PDF to Images and Microsoft Office on AlmaLinux Tutorial) now installed up at RJM Programming’s AlmaLinux web server helping out the changed file_open_picker.html Open File Picker Interfacing web application you can also try, alas only successfully on non-mobile platforms (with experimental functionality), below.


Previous relevant Open File Picker Javascript Primer Tutorial is shown below.

Open File Picker Javascript Primer Tutorial

Open File Picker Javascript Primer Tutorial

There are other ways to go about local file browsing, regarding web applications using a web browser, than the HTML input type=file element way we’ve become so fond of here at RJM Programming with client_browsing.htm and we’re here, today, ready to talk about …


Window: showOpenFilePicker() method

… described as …

The showOpenFilePicker() method of the Window interface shows a file picker that allows a user to select a file or multiple files and returns a handle for the file(s).

… means of achieving this.

Developing a …

  • browser for local image file …
  • transference of a returned “piece of data” …
  • used to create an img element object … and onto …
  • an HTML5 canvas element … via …
  • [canvasContext].drawImage([imageElementObject],0,0) … temporarily in the parent window … and later …
  • to an iframe element for an inhouse image editing via canvas web application

… what took half the day was the replacement of with this alternative response object return as an easier means by which clientside Javascript can convert real image file data into a useful data URI which is needed to form img element content that [canvasContext].drawImage([imgElementObject],0,0) can use to get to an Image Editing scenario …


const pickerOpts = {
types: [
{
description: "Images",
accept: {
"image/*": [".png", ".gif", ".jpeg", ".jpg"],
},
},
],
excludeAcceptAllOption: true,
multiple: false,
};

// create a reference for our file handle
let fileHandle;

async function getFile() {
// open file picker, destructure the one element returned array
[fileHandle] = await window.showOpenFilePicker(pickerOpts);

// run code with our fileHandle
const file = await fileHandle.getFile();
const content = await file.arrayBuffer(); //text();
const contents = _arrayBufferToBase64(content);
//alert('' + file.name + ' ... ' + (contents));
const canvaso=document.getElementById('canvas');
const context=canvaso.getContext('2d');


nimg=new Image();

nimg.onload = (event) => {
canvaso.width=event.target.width;
canvaso.height=event.target.height;
context.drawImage(event.target, 0, 0);
document.getElementById('cif').src='/HTMLCSS/user_of_signature_signature.html?rand=' + Math.floor(Math.random() * 1987867);
document.getElementById('cif').style.display='block';
};

nimg.src='data:image/' + file.name.split('.')[eval(-1 + file.name.split('.').length)].split('?')[0].split('#')[0].toLowerCase().replace('jpg','jpeg') + ';base64,' + ((((contents))));
}

… within today’s proof of concept Show Open File Picker Image Editing web application you can also try, alas only successfully on non-mobile platforms (with experimental functionality), below …

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Open File Picker Javascript Primer Tutorial

Open File Picker Javascript Primer Tutorial

Open File Picker Javascript Primer Tutorial

There are other ways to go about local file browsing, regarding web applications using a web browser, than the HTML input type=file element way we’ve become so fond of here at RJM Programming with client_browsing.htm and we’re here, today, ready to talk about …


Window: showOpenFilePicker() method

… described as …

The showOpenFilePicker() method of the Window interface shows a file picker that allows a user to select a file or multiple files and returns a handle for the file(s).

… means of achieving this.

Developing a …

  • browser for local image file …
  • transference of a returned “piece of data” …
  • used to create an img element object … and onto …
  • an HTML5 canvas element … via …
  • [canvasContext].drawImage([imageElementObject],0,0) … temporarily in the parent window … and later …
  • to an iframe element for an inhouse image editing via canvas web application

… what took half the day was the replacement of with this alternative response object return as an easier means by which clientside Javascript can convert real image file data into a useful data URI which is needed to form img element content that [canvasContext].drawImage([imgElementObject],0,0) can use to get to an Image Editing scenario …


const pickerOpts = {
types: [
{
description: "Images",
accept: {
"image/*": [".png", ".gif", ".jpeg", ".jpg"],
},
},
],
excludeAcceptAllOption: true,
multiple: false,
};

// create a reference for our file handle
let fileHandle;

async function getFile() {
// open file picker, destructure the one element returned array
[fileHandle] = await window.showOpenFilePicker(pickerOpts);

// run code with our fileHandle
const file = await fileHandle.getFile();
const content = await file.arrayBuffer(); //text();
const contents = _arrayBufferToBase64(content);
//alert('' + file.name + ' ... ' + (contents));
const canvaso=document.getElementById('canvas');
const context=canvaso.getContext('2d');


nimg=new Image();

nimg.onload = (event) => {
canvaso.width=event.target.width;
canvaso.height=event.target.height;
context.drawImage(event.target, 0, 0);
document.getElementById('cif').src='/HTMLCSS/user_of_signature_signature.html?rand=' + Math.floor(Math.random() * 1987867);
document.getElementById('cif').style.display='block';
};

nimg.src='data:image/' + file.name.split('.')[eval(-1 + file.name.split('.').length)].split('?')[0].split('#')[0].toLowerCase().replace('jpg','jpeg') + ';base64,' + ((((contents))));
}

… within today’s proof of concept Show Open File Picker Image Editing web application you can also try, alas only successfully on non-mobile platforms (with experimental functionality), below …

If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , | Leave a comment

Javascript Microtask Primer Tutorial

Javascript Microtask Primer Tutorial

Javascript Microtask Primer Tutorial

Javascript, in “clientside mode”, has many more asynchronous ideas than it used to, say, a decade ago, where it was mainly setTimeout and setInterval timer functions we turned to, in this regard. It used to be that any idea of “waiting for JS” was not on, but that does not have to be the case with the modern web browsers using “modern Javascript”. Today, for example, we’ve written a “proof of concept” web application making use of …


queueMicrotask

… with accompanying description …

A microtask is a short function which is executed after the function or program which created it exits and only if the JavaScript execution stack is empty, but before returning control to the event loop being used by the user agent to drive the script’s execution environment.

… which, as you may surmise, allows for a “jumping order of execution” paradigm with your Javascript.

The example code of the queueMicrotask informational webpage made us happy, thanks, and so we wrapped that into a “shell of user usage” by …

  • writing code in PHP … huh?! … so that …
  • we can use navigation via an HTML form method=POST … allowing for large amounts of user written Javascript code they want to dynamically execute … and …
  • as we mentioned with the recent PHP Tokeniser Primer Tutorial talking about “code as content, teamed with navigation using this code data” …
    1. we leave using Javascript window.btoa
      <?php echo ”

      function doit(tdiho) {
      document.getElementById('jcode').value=window.btoa(tdiho.innerText);
      document.getElementById('mysub').click();
      }

      “; ?>
      … hanging off an HTML td contenteditable=true onblur event logic idea … and …
    2. arrive back using PHP base64_decode
      <?php

      if (isset($_POST['jcode'])) {
      $thejcode=base64_decode($_POST['jcode']);
      }

      ?>

    … so as …

  • to better handle the transference of real “+” characters in your data (as code is apt to have)

… as you can see using today’s proof of concept queueMicrotask using web application you can also try below …

If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Apple iPad Books App Tutorial

Apple iPad Books App Tutorial

Apple iPad Books App Tutorial

The Apple iOS Books app has had a makeover since we last looked. We used to associate it with being a PDF Reader, and small time, editor. But now, it has become more about reading and listening within the realms of …

  • Books
  • Audiobooks

… where it is like shopping, to pick your contents, and some PDF functionality is there too, but not looking like the previous Books iOS app incarnations.

And so, we gave it a go, and must say, we were reading within ten minutes. Even though what we chose to read was free, you will still need an Apple account to read this way.

For us, these days, once you are reading, it is the light level that is critical, and what you might be comparing against regarding this way versus the Kindle way? Well, this depends a bit on your hardware we’re thinking, but on our iPad, it was very good, as you can see viewing today’s animated GIF tutorial presentation.

If this was interesting you may be interested in this too.

Posted in eLearning, Hardware, iOS, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , | Leave a comment

Apple iPad Gesture Settings Tutorial

Apple iPad Gesture Settings Tutorial

Apple iPad Gesture Settings Tutorial

We do a lot of screenshotting here at RJM Programming, mainly on …

  • Apple macOS MacBook Airs and Pros … where control-command-shift-3 (after we were keen on Grab) has done us nicely for years now … and …
  • Apple iOS … via Home button “and another” …

… we have a certain “muscle memory thing” going on about. But when we presented Bluetooth iPad Keyboard and Case Document Editing Tutorial and had a stand habitating our iPad around here, perhaps there was interference to that “muscle memory” arrangement … poor Apple accessory peoples! Anyway, it made us look around our iPad’s …


Settings -> General -> Gestures

… settings, and we were introduced to a whole new (what have I been missing) wooooorrrrllllddd, as visiting Apple settings areas is apt to do.

We use diagonal swipes all the time on iPhone and iPad for the Torch, but you can configure bottom diagonal swipes, either or both from the left or right, to equate to …

  1. Quick Note
  2. Screenshot

And so, that gets around our button based screenshotting via muscle memory disappearance issue to dissolve like molasses in hot water (ie. it will take a while to sink in, and will need practice).

Toggling through the apps open we’ve been handling, on …

  • iPhone … via a swipe from the bottom and swivel … and with the …
  • iPad … via a double tap of Home button … but …

… and, didn’t you just know there’d be a small flat mountain in the desert “but” here?! On our iPad …


Settings -> General -> Gestures

… place we had a …

Four & Five Finger Swipe

… “not on”, and we thought “far fetched”, but tried it toggling through the open apps, and we got a “now we’re sold” feeling trying it out!

If this was interesting you may be interested in this too.

Posted in eLearning, GUI, Hardware, iOS, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , | Leave a comment

Podcasts via macOS Primer Tutorial

Podcasts via macOS Primer Tutorial

Podcasts via macOS Primer Tutorial

As you’d expect with Apple software …

… and it’s there as the Podcast desktop app “out of the box”, so to speak.

And did you know, a WordPress.org blog with the usual RSS Feed functionality can be fed into this Podcast app’s list via you guessed it


File -> Follow a Show by URL...

? And in the case of the blog you are reading, that URL would be …


https://www.rjmprogramming.com.au/ITblog/feed

… you can see us accessing, not via a web browser address bar URL, but rather a macOS desktop app (which may send you to a default web browser webpage via it’s links) with today’s tutorial animated GIF presentation.

As easy as falling off a log, really?!

Did you know?

Separate and related to the use of the Podcast (macOS) app is that with that “feed link” above, to copy it’s wording and using that in the Podcast setup suits (macOS), but, if you’re anything like us with an iPhone or iPad around here (with iOS), and tapping that link above, you may run into the issue that no iOS mobile app is there ready to receive and process your RSS Feed properly, and that is where the iOS NetNewsWire mobile app has helped us in the past, as you can read with NewNewsWire Web Feed macOS Safari Primer Tutorial, to fix this issue. NetNewsWire is available on the Apple Store.


Previous relevant Podcasts via iPad Synching Primer Tutorial is shown below.

Podcasts via iPad Synching Primer Tutorial

Podcasts via iPad Synching Primer Tutorial

Many young people will have never known a world without device synching and so may find my wonder below quite strange.

Today’s observation is about the iPad application called Podcasts, that comes with the iOS operating system software. I do not actively “attend” to this application in any way, and yet it responds to “synch” requests of movies (or podcasts), patently, and collects unwatched movies (or podcasts) and those in a feed.

That cleverness is impressive but I still miss the ability of the older Mac OS X operating system versions (as we’re on an Apple thaing today) to create your own podcasts, which you can read about, last, here at the blog, with Podcast Publisher on Mac Primer Tutorial.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment