We add some โaccountabilityโ to where we stopped off at yesterday with Textarea Pointing Canvas Tutorial today. We define โaccountabilityโ in this context, and with our rules, short of bothering with โฆ
- a fully blown database solution โฆ too much โฆ
- HTTP Cookies โฆ too little โฆ
- HTML5 Web Storage localStorage โฆ just right
Porridge is served! How to make this decision? To us, it goes by โpermanence factorโ (database really good) and โdata size requirementsโ (and today we store the whole innerHTML of the HTML form that encompasses all our โtextarea posseโ and this is far too much for HTTP Cookies โฆ so HTML5 localStorage is our decision).
There are these aspects to doing this โฆ
- in the menu section of the webpage have one select element id=ssaveas (dropdown) (with an initial option element labelled โFill in Save As or chooseโ) and one input type=text element
- at document.body onload event look through localStorage โฆ as per the Javascript โฆ
if (window.localStorage) {
for (var iq in window.localStorage) {
val = localStorage.getItem(iq);
if (val) {
if (iq.substring(0,3) == 'tp_') {
document.getElementById('ssaveas').innerHTML+='<option value="' + iq.substring(3) + '">Recall "' + iq.substring(3) + '"</option>';
}
}
}
}
โฆ to further populate, as necessary, the dropdown, that has โฆ - onchange event for select element dropdown reads localStorage โฆ as per Javascript (for variable newo being that webpage snapshotโs name) โฆ as entered by user โฆ
if (localStorage) {
if (localStorage.getItem('tp_' + newo)) {
var bih=decodeURIComponent(localStorage.getItem('tp_' + newo));
document.getElementById('myform').innerHTML=bih;
}
} - at onblur event of the input type=text element โฆ Javascript (for variable newo being that webpage snapshotโs name and variable hcont is the HTML code for a โNew Windowโ scenario) as per โฆ
if (newo != '') {
if (localStorage) {
if (localStorage.getItem('tp_' + newo)) {
localStorage.removeItem('tp_' + newo);
}
var bbit='m' + hcont.split('<f' + 'orm')[1].split('>')[0] + '>';
localStorage.setItem('tp_' + newo, encodeURIComponent(hcont.split('<fo' + 'r')[1].replace(bbit,'').split('</f' + 'orm>')[0]));
document.getElementById('ssaveas').innerHTML+='<option value="' + newo + '">Recall "' + newo + '"</option>';
}
}
Todayโs liverunโs textarea_pointing
htm HTML and Javascript (DOM) and CSS codechanges were all clientside, like yesterdayโs work.
Accountability food for thought, we hope?!
Previous relevant Textarea Pointing Canvas Tutorial is shown below.
With our blog posting thread last left off with yesterdayโs Textarea Pointing PDF Tutorial, I know weโve been holding out on involving โฆ
โฆ not for โnga, nga, nga nga, ngaโ reasons, but because we want to show that the starting out with โtextarea character dataโ sets is a useful layer of information that can sit on top and easily pass onto these (last two above in particular) functionalities above in optional reporting modes of use, but still keep that โtextual contextโ in place as well. Win, win, weโd say.
However, on non-mobile web browsers in particular, youโve got to appreciate how the modern browsers interface to canvas elements and image data (which can be derived from that canvas element by the oft mentioned [canvasElement].toDataURL() method) with a myriad of right click (Windows or two finger gesture on Mac OS X) options, our favourites of which are โฆ
- image โ Open Image in New Tab (or Window)
- image โ Save Image to Desktop
- image โ Save Image Asโฆ
- image โ Copy Image
- image โ Share Mail (to client email (ie. your own email address is โFromโ email address) as image attachment)
- image โ Share Message
- canvas โ Save Page as Web Archive
- canvas โ Print Pageโฆ Open PDF in PDF Reader
- canvas โ Print Pageโฆ Save As PDF
- canvas โ Print Pageโฆ Save As PostScript
- canvas โ Print Pageโฆ Mail PDF (to client email (ie. your own email address is โFromโ email address) with a PDF attachment)
โฆ so much so that we just want all this clientside (no PHP serverside โanythingโ today) to wash over you with your mind โswimmingโ with possibilities, perhaps?!
Take a look at todayโs liverunโs textarea_pointing
htm HTML and Javascript (DOM) and CSS code changed thisway as all that needed to change to involve canvas and image data and data URIs in our Textarea Pointing project.
If there is no serverside โanythingโ going on, what is the โglueโ that holds all this clientside interfacing together? These days, more and more, it is the use of data URI portable data that can be used in, just with todayโs work โฆ
- HTML img element src attribute
- HTML img element style attribute background URL(data URI)
This is all great, but thatโs it, unless you want to run that image data back through an intelligent scanning process to try to regain the โcharacter dataโ? Some scanners do this, but do you really think you are going to continue getting a good result that way forever? We say, hang on to data in rawer forms and resolutions until the very last minute, and only go to these very well programmed for โgraphicalโ forms (of final reporting) for your final reporting, or if you know that only that โblobbyโ โgraphicalโ form is all thatโs required anyway. If so, think about using HTML canvas from the start. Itโs data capture capabilities, as we at this blog have been at pains to point out for a long time now, are also excellent.
Another Paul Kelly song seems apt!
Previous relevant Textarea Pointing PDF Tutorial is shown below.
Yesterdayโs Textarea Pointing Email Tutorial was a start to our โsharingโ functionality โpushโ with our new Textarea Pointing project. That work involved โฆ
- (new window) with menu
- (new window) without menu
- email with HTML attachment โฆ and today we add to that โฆ
- email with PDF attachment โฆ as well as โฆ
- PDF download to client device
- PDF display via default client PDF viewer
โฆ that required, again, Linux diff PDF Tutorial liverunโs prediffphp PHP code integration inthis changed way. This time, though, rather than $outputpdf->Cell($x, $y, $line_of_text); being the best Fpdf means of displaying of the PDF text, we found โฆ
$outputpdf->Text($x, $y, $line_of_text);
โฆ to be more applicable to programming like for the way vinyl records work with their stylus, in other words, at a given โฆ
- HTML textarea element (x,y) position โฆ we gather โฆ
- HTML textarea element font information stored in the alt attribute โฆ to place text โฆ
- to be able to โฆ
$outputpdf->SetFont($fontFamily, $fontStyle, $fontSize);
$outputpdf->SetTextColor($fontColR, $fontColG, $fontColB);
$outputpdf->Text($x, $y, $line_of_text);
โฆ as the โwork of the codeโ needed to transition from our โuser capture with character dataโ (in the โtextareaโs) to a graphical system (or โwidgetโ, you might like to think of this as). It just so happens that the first (graphical) โwidgetโ design of interest is the creation of PDF, as it is a good conduit between โcharacter dataโ and a โgraphical lookโ. A โwidgetโ feeling thing being what it is though, expect more integrations to come, as time goes on!
Todayโs liverunโs textarea_pointing
htm code changed thisway.
Previous relevant Textarea Pointing Email Tutorial is shown below.
Yesterdayโs Textarea Pointing Primer Tutorial was a little too localised in its application in our books. Not if a web application is not of generic use, but this one could be of generic use, in our pamphlettes books.
Our favourite โsharingโ idea is email, by far, as today, as far as that goes, we are going to offer email โservicesโ via a โclient pre-emptive iframeโ determination of whether where you have placed todayโs liverunโs textarea_pointing
htm code (changed thisway) has, relative to it, an existant ../PHP/Geographicals/prediff.php PHP code source (that we left to go on our Textarea Pointing project) of Linux diff PDF Tutorial (live
runโs prediffphp PHP codeโs lastchanges were used to cater for the Textarea Pointing HTML email attachment requirement).
We like to use a โclient pre-emptive iframeโ technique initial check for whether the HTML finds prediff.php because the email functionality is optional after all. If prediff.php is not found, then the Email button is never shown, simple as that. But the other two displays of the HTML in new popup windows โฆ
- with menu
- without menu โฆ as well as โฆ
- email with HTML attachment
โฆ complete the scope of the new โSharingโ functionalities today, and this year, on this!
So โฆ Happy New Year!
Previous relevant Textarea Pointing Primer Tutorial is shown below.
Completely new idea today, so hoping this does not put some of you โepisodicโ users off. Weโll get back to incomplete recent โthreadsโ at a later date. This is because we had pause for thought, due to yesterdayโs PDF textual data positioning work, regarding one of our favourite HTML fundamental element types of interest (that we are always comparing) โฆ
To quote HTML Textarea and Div Talents Primer Tutorial (as it was addressing the textarea HTML element) โฆ
Itโs crucial for getting HTML or non-caretted Text (that is internally turned into HTML behind the scenes) โฆ via those wonderful tabs โฆ off the user and onto the MySql database, and then out to the client user as part of a webpage. Out at that webpage, though, weโve no doubt this content is embedded in an HTML div element, the other โtalentโ here.
But their strengths and weaknesses go like this, at least to us, in the limited HTML text view of things โฆ
Text Functionality Issue HTML Element Type Strength Weakness (where a โYesโ is like โฆ โOh No!โ) Display Monocolour Text Textarea Yes Div Yes Display Editable Text Textarea Yes Div Yes Display Multicolour Text Textarea Yes Div Yes
Nothing there above gives much encouragement about the HTML textareaโs โpositioningโ talents. But what if we were to create a โposseโ, or perhaps a โphalanxโ, of โtextareaโs to bank up with โbits and piecesโ of the positioning โissueโ (under the auspices of an HTML form element, for later accountability)?
What do we mean by โissueโ here? Well, something like a letter, as with the end product of a scanning process involving a hardcopy letter, is that much more useful if what we end up with is the โcharactersโ that go to make up that letter (or report, or essay), not some graphic (or totally visual) encapsulation of it, which can be what happens when you involve as your HTML โcaptureโ element the โcanvasโ element. No, we want that โposseโ of โtextareaโs be that โcharacterโ source, which later, we can present as an overall graphic at a later date, for sharing purposes for instance, and maintain the โletterโ (or report or essay) data continuously as the user edits.
How to do? We click/touch with a base โtextareaโ and that is enough to arrange for an โoverlayโ โtextareaโ (via CSS position:absolute and z-index properties, some background-color:transparent styling, along with div id=dscript (innerHTML) appended dynamic CSS styling making use of CSS calcโing <style> .mboard2 { width: calc(85% โ 56px); } </style> type syntax (where the 56px would have been derived via the onclick event logic, the 85% is to allow for a 15% width menu at the right, and the 2 in mboard2 refers to the second textarea in question)) to follow (ironically an HTML div element is by far the best โcontainerโ in a (Javascript DOM controlled) linked list fashion for this, rather than appending to the HTML form elementโs innerHTML (which seems to wipe out previous textarea values)), like a linked list of โtextareaโs. Along the way we allow for font information to be collected and kept as well (for now, via the textareaโs alt attribute), to add to the chances for variety with our overall โletterโ (or report or essay) reporting end product.
Which leaves us to talk about the โtextarea pointingโ liverunโs underlying HTML and Javascript and CSS textarea_pointing
html code for your perusal.
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.