We have been thinking with our latest project called โDo It Yourself HTML Editorโ that it bore huge similarities to the Legend via HTML Map Element ideas we started with the blog post series ending with Legend for and from HTML Map Element Web Server Tutorial. Other interfacings to this project have happened as well, but today, there is a subset of functionality of interest that we want to integrate into our โDo It Yourself HTML Editorโ, that subset being โฆ
- an HTML input element where the user can fill in a URL of interest whose HTML contents can be imported into the HTML textarea element of our โDo It Yourself HTML Editorโ โฆ and โฆ
- an HTML file browsing mechanism you can read a lot about at that last blog posting link whereby a user can browse for an HTML file of interest whose HTML contents can be imported into the HTML textarea element, like above
โฆ adding two more methods of HTML data input into the โfunctionality equationโ. You may notice from reading the blog post thread of postings ending at that link above, we discuss a lot of cross-domain issues and interprocess messaging (via Javascript postMessage) that was involved with that project, and we may revisit one day. Those issues are largely behind the interest we have in interfacing to the โLegend via HTML Map Elementโ project, but there are a few issues that come into play when considering this (software) integration, and in many you may consider yourself โฆ
- How can we set up the interfacing? โฆ we decide on โparentโ HTML supervises โchildโ (Legend via Map) HTML iframe design
- How do we make the โchildโ look part of the โparentโ process? โฆ with the HTML iframe we encase it in the โparentโ with an HTML div element (as per) โฆ
<div style='height:60px;overflow:auto;-webkit-overflow-scrolling:touch;'<>iframe src='./legend_via_map.htm' style='width:100%;height:60px;' scrolling='no' frameborder=0></Iframe></div>
โฆ that uses a style height parameter such that just those two HTML input โrowsโ of functionality show, by controlling the scrolling issues and overflow:hidden and/or overflow:auto โฆ thanks to this useful link for help with that - In the โchildโ how can it tell it is being supervised as distinct from when it is not? โฆ youโll see lots of โฆ
If (parent.document.getElementById('htmlcontent')) {
// do code particular to be supervised by the "Do It Yourself HTML Editor"
} - In the โchildโ how can it make changes in the โparentโ, or flag for this in the โparentโ? โฆ similar to above we can go (something like) โฆ
parent.document.getElementById('htmlcontent').value = ourHTMLcontentVar;
That leaves us with the โparentโ HTML and Javascript could be called do_away_with_the_boring_bitshtml with this live
run link, changed from yesterday, in thisway, still supervising a PHP โchildโ helper you could call do_away_with_the_boring_bits
php (changed a little in thisway), but now also supervising a โLegend via Mapโ HTML iframe โchildโ helper you could call legend_via_map
htm (changed a little in thisway), and which, itself can be supervising that other PHP helper in a โgrandchildโ arrangement to the โparentโ whereby it makes changes via code like โฆ
top.document.getElementById('htmlcontent').value = ourHTMLcontentVar;
Previous relevant Do It Yourself HTML Textarea Editor Post Tutorial is shown below.
Weโre introducing a โduck paddling fast underwaterโ but โwho says you have to be the duckโ aspect to our โDo It Yourself HTML Editorโ today, adding onto the (blog posting) thread we left off yesterday with Do It Yourself HTML Textarea Editor CSS Pseudo Element Tutorial as shown below. The duck is paddling fast because โฆ you guessed it โฆ itโs a โdualโ purpose duck, and itโs a PHP duck, with roles, helping out the HTML, of โฆ
- processing long bits of HTML contained in the Textarea by having the HTML โPOSTโ this large amount of data to the PHP for processing โฆ via โฆ
- method=POST
- action=./do_away_with_the_boring_bits.php
โฆ and that can come into play because of a new HTML form element validation onsubmit event added whereby the Textarea characteristics determine the approach to use to process that data
- a feature not really advertised, but catering for PHP code input from the user
With that last role, we do not execute the PHP at our rjmprogramming.com.au website, but rather, give you some advice regarding that great local Apache/PHP/MySQL web server product called MAMP (now that we have it pretty steady on both Mac and Windows here) and direct the user to a link to //localhost:8888/doityourself.php which will be workable should the user follow through on the PHP (contained in PHP variable $andintoitgoes of code snippet below) we download to the user โฆ
$file = 'doityourself.php';
file_put_contents($file, urldecode($andintoitgoes));
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
unlink($file);
exit;
โฆ that they could copy from their โDownloadsโ folder to MAMPโs htdocs (Document Root ( is equivalent to //localhost:8888/ )) folder. We got great help from โฆ
- here regarding the PHP download advice hooking up to the PHP readfile command
- here regarding an error message we got with a very large amount of HTML POSTed to the PHP, in the context of using the Google Chrome web browser and getting the error โฆ
The XSS Auditor refused to execute a script in //localhost:8888/weather/do_away_with_the_boring_bits.php because its source code was found within the request. The auditor was enabled as the server sent neither an 'X-XSS-Protection' nor 'Content-Security-Policy' header.
โฆ so, thanks.
The former role dovetails with another change to add to the โdualโ roles โฆ wouldnโt you know it? โฆ regarding the use of Cookies in that โฆ
- in the HTML โparentโ we now have a mechanism whereby the user can flag that they do not want to use Cookies for a session of work by changing the default HTML bits that now go โฆ
To not use cookies put space between no and cookies in nocookies.
- our PHP โchildโ, that is automatically called into play as a long HTML entry is detected by the HTML โparentโ, currently does not access nor create any Cookie data
And one last additional change, to add to the changes additional to the โdualโ changes โฆ perhaps this is โdualโ dueal? โฆ is that โฆ
- we now allow for HTML <body> code that is not <body> โฆ eg. <body onload=โdothisonloading();โ> โฆ but please do not expect any Javascript defined here to be executed, but it will allow it through for you to see the โlookโ, at least, of such HTML
Now the โparentโ HTML and Javascript could be called do_away_with_the_boring_bitshtml, changed from yesterday, in thisway, now supervises a PHP โchildโ helper you could call do_away_with_the_boring_bits
php that assists with long HTML data that is POSTed and with some Cookie related (usage) flexibility.
As ever, we hope you get the context of all this by trying our liverun link.
Previous relevant Do It Yourself HTML Textarea Editor CSS Pseudo Element Tutorial is shown below.
Thereโs nothing like restrictive conditions to help you concentrate and not be lazy about what is, and in this case, what isnโt, available to you to make some programming code happen. We havenโt further delved into why, with our โrecent daysโ โDo It Yourself HTML Editorโ project, the Javascript within the head section doesnโt work, yet the CSS within the head section does. It could be a thing to do with timing, or security, at the web browser โฆ whatevvvvverrrrrrrr. Anyway, the point is, this hones curiosity back onto CSS for us, and this is rare compared to our far greater interest in Javascript and โthe DOMโ โฆ am sure, related to if I divulged Iโd have to โฆ?
But the other day I arrived at a webpage, which Iโve lost now โฆ sorrrrrryyyy โฆ looking up the question โCan an HTML element be affected remotely to another just using CSS?โ. And this website reminded me of the CSS pseudo element โadjacent toโ (โ+โ syntax) we discussed (particularly in the Stop Press) at WordPress Blog Complex Selectors Tutorial. This was a very important thing to remember, but it was not really what I was getting at with the question. I was after something just in CSS (with no Javascript DOM) that could change the characteristics of a โcompletely removedโ HTML element caused by the user actions on a completely separate element. That โ+โ CSS syntax is for elements that follow each other, but then โฆ doh! โฆ the penny dropped โฆ that HTML element that follows can use (half of our usual CSS โoverlay suspectsโ) โฆ
- position:absolute;
- top:0;
- left:0;
โฆ in our case, for the last two โฆ to position that adjacent element anywhere you like relative to the other as a position on the resultant webpage, different to their โdeliberate adjacencyโ โฆ
<a class='dyk' href='#mypheading' style='cursor:pointer;text-decoration:underline;'>The rain in Spain,
Falls mainly,
On the plain</a>
<p id='mypheading'>Did you like our pithy thought?</p>
โฆ you, the programmer, arrange, for these elements. Then, CSS โฆ
<style>
.dyk:link + * { background-color:red; }
.dyk:link + *::after { content: ' Yes?'; }
.dyk:hover + * { background-color:yellow; }
.dyk:hover + *::after { content: ' Purrrrrhaps?'; }
.dyk:active + * { background-color:lightgreen; }
.dyk:active + *::after { content:' Wow, thanks for visiting.'; }
#mypheading { position:absolute; top:0; left:0; }
</style>
โฆ takes on a webpage (functionality) look of Javascript DOM.
But, thereโs more. Do you remember our CSS (wonder at the) CSS pseudos :after (and, implicitly, the ::after that we finally work out, today, how to โworkโ โฆ ie. itโs the way to combine two pseudos onto the one definitional โthoughtโ) content and :before (and ::before) content we first talked about CSS Before and After Content Primer Tutorial? Combine this with thoughts above, and youโve got CSS doing very Javascript DOMโy things (to HTML elements far removed, perhaps, from where the webpage user is interacting).
Given that it is awkward to work lots of Javascript DOM scripting in our โDo It Yourself HTML Editorโ (at least for now) this is very interesting to us, so we have a dual purpose modus operandi โฆ
- write our proof
of concept HTML and CSS code you could call pithy
html โฆ and to also โฆ
- copy/paste that HTML and CSS into our โDo It Yourself HTML Editorโ as per โฆ please be warned, that this may blow your Cookie size limits, as it is close to being too big for us โฆ but get ready, if so, to clear Browsing History for the Last Hour at your web browser, if so โฆ this link โฆ we last talked about at yesterdayโs Do It Yourself HTML Textarea Editor Shortcut Key Tutorial as shown below, and the HTML and Javascript could be called do_away_with_the_boring_bits
html and changed, trivially, just to do with the โtoo smallโ blue bit height, from yesterday, in thisway
โฆ and โdualโ being 2 probably means we have to show you a third HTML iframe view of it below (and say adios), separately, because there is no way on this Earth that Iโm changing โdualโ to being anything else โฆ
Previous relevant Do It Yourself HTML Textarea Editor Shortcut Key Tutorial is shown below.
If you are using a laptop and following our thread of โDo It Yourself HTML Editorโ blog postings, you may benefit from todayโs progress on our web application, that you can also see being played out at Do It Yourself HTML Textarea Editor Shortcut Key Tutorial. We allow for the linking of yesterdayโs Cursor Positioned HTML dropdown, introduced with Do It Yourself HTML Textarea Editor Cursor Tutorial as shown below, to a keyboard shortcut in the order โฆ
- Ctrl key (or Mac equivalent) (separated please) to the key letter starting that HTML element you are selecting via a dropdown eg. <p></p> could have a shortcut key Ctrl_P โฆ or if already used โฆ
- Alt key (or Mac equivalent) (separated please) to the key letter starting that HTML element you are selecting via a dropdown eg. <span></span> could have a shortcut key Alt_S
A strong advantage using these (Cookieโable) shortcuts is that you might be able to swing it to have the cursor stay where you want it in the HTML textarea element more often.
We would like to thank this wonderful webpage for some direction with this work, which was more involved than we thought it would be, and maybe too long in code changes to encapsulate here. In which case, it would be better to examine the HTML and Javascript could be called do_away_with_the_boring_bitshtml and changed from yesterday for shortcut key functionality in thisway, mainly regarding the organization of document onkeyup (keyboard) event logic. And, as per usual, here is a live
run link for you to try this yourself, we hope?!
Previous relevant Do It Yourself HTML Textarea Editor Cursor Tutorial is shown below.
If you do lots of text editing perhaps you take the โcursorโ for granted. But just as the stylus on a vinyl record makes the music in relation to its position, the equivalent of our text editing โcursorโ is that it defines where to place the next typed character. Itโs been around, as a concept, and survived, more to the point, for a long time now, as it has been around regarding much database SQL query design too. But today, for us, we are giving it some attention, because we want to โฆ
- read off the HTML textarea โeditorโ elementโs data its cursor position โฆ and also โฆ
- set the cursor position of the HTML textarea โeditorโ element after modifying its contents
That ability means that we now have the ability to offer the user of this HTML textarea โeditorโ the chance to use โhelperโ (like shortcut) HTML (select element) โdropdownโ options to optionally speed up the creation of the HTML code. We realise this โflies in the faceโ of a basic belief we have that it is good to hand code your HTML to learn it better, but the real fact is that the quicker your success, the more youโll want to try out other HTML ideas, and that makes these ideas worthwhile. These HTML drop downs are structured to mandatorily have the โฆ
- HTML element type โฆ as for <p></p> โฆ mandatory โฆ and optional, for properties like โฆ
- id
- class
- title
- style
- src
- href
- value
โฆ as well as several other property combinations, presented in combination with the HTML type whether that is apt, or not. Now, we may fix this perhaps, but we also see that it can serve a purpose to teach the HTML with trial and error thoughts as well. We see โtrial and errorโ as an incredibly important idea here. Hand coding HTML by trial and error, sometimes, particularly in combination with a web browser Web Inspector product, are a potent mix to finding out how the client side of web applications work. Pretty obviously, looking at books and search engine information, as a conduit to websites like W3schools helps a lot too.
Speaking of useful websites, weโd like to thank this really useful link is helping us with our code for getting the cursor position and setting the cursor position, respectively via โฆ
function wherearewe(ota) { // thanks to //stackoverflow.com/questions/2897155/get-cursor-position-in-characters-within-a-text-input-field
// Initialize
var ipos = 0;
if (document.selection) { // IE Support
// Set focus on the element
ota.focus();
// To get cursor position, get empty selection range
var oselis = document.selection.createRange();
// Move selection start to 0 position
oselis.moveStart('character', -ota.value.length);
// The caret position is selection length
ipos = oselis.text.length;
} else if (ota.selectionStart || ota.selectionStart == '0') { // Firefox support
ipos = ota.selectionStart;
}
// Return results
//alert(ipos);
return ipos;
}
โฆ and โฆ
function setwherearewe(ota, wota) { // thanks to //stackoverflow.com/questions/2897155/get-cursor-position-in-characters-within-a-text-input-field
if (ota.setSelectionRange) {
ota.setSelectionRange(wota, wota);
} else if (ota.createTextRange) {
var range = ota.createTextRange();
range.collapse(true);
range.moveEnd('character', wota);
range.moveStart('character', wota);
range.select();
}
// Return cursor position
ota.focus();
//document.title=ota.value.length + ' vs ' + wota;
return wota;
}
Todayโs HTML and Javascript code you could call do_away_with_the_boring_bitshtml changed in thisway regarding textarea cursor functionality and can be seen in live action here, as it can for WordPress 4.1.1โs Do It Yourself HTML Textarea Editor Cursor Tutorial.
Previous relevant Do It Yourself HTML Primer Tutorial is shown below.
It is because of yesterdayโs generic HTTP Cookie thoughts we had when we presented Job Search Grid Game Cookie Tutorial, as shown below, that makes us feel okay using โDo It Yourselfโ in the blog posting title โDo It Yourself HTML Primer Tutorialโ. Without the use of cookies what we do today is probably not worth the bother because we โฆ
- want to get you programming in HTML and Javascript and CSS, if you are curious, and have never done it before, and want to taste that incredible feeling programmers get when they โsee something workingโ โฆ so โฆ
- we get you to draft up some HTML and Javascript and CSS in an HTML textarea element โฆ and weโll talk more about the limitations here later on โฆ
- click or tap the โTry your HTML and Javascript and CSS Aboveโ button โฆ then โฆ
- see the results of your work to the right in a light blue area โฆ and โฆ
- notice up the top middle a new (and/or updated) HTML (select element) dropdown with some datetime flagged previous โHTML Editโ sessions you can recall โฆ thatโs HTTP Cookie functionality at work
The thing is about hand coded HTML, and we think you learn more by hand coding your HTML, at least in the early days, you are going to need a few goes at things to get things going, and yet, like most programmers, youโll be curious to know โdoes it work yet?โ (sound familiar to โare we there yet?โ to you?), so remember those โworthwhile coming back toโ datetime stamps, is our advice โฆ gratuitous, as always?!
Now about those restrictions to use. Alas, within the web page โheadโ section โฆ between <head> and </head> โฆ the โฆ
- good news is that all the CSS styling โฆ between <style> and </style> โฆ seems to be fine, but, alas, the โฆ
- bad news is that the Javascript scripting โฆ between <script type=โtext/javascriptโ> and </script> โฆ does not work, as of this first draft โฆ not with code between <script type=โtext/javascriptโ> and </script> between <body> and </body> โฆ but event logic defined within <body> and </body> such as onclick= works (but no โbody onload pleaseโ, nor โbody anything elseโ either โฆ just plain straight โbodyโ please)
Be that as it may, you can still see a lot happening with this arrangement, and be like us, perhaps, still in wonder at that feeling of โlook at that, it works!โ.
So, thatโs the go, and you can try it out via this liverun link and/or peruse the code behind this (just HTML and CSS and Javascript) โDo It Yourself HTML Editorโ you could call do_away_with_the_boring_bits
html yourself.
Previous relevant Job Search Grid Game Cookie Tutorial is shown below.
Yesterday we got to a point with a web project we were working on called the โJob Search Grid Gameโ (and thanks here to Science Puzzles for Young Einsteins by Helene Hovanec ISBN 0-8069-3542-1 for the inspiration) and we ended up with a game that could use Content Management System ideas whereby the user could control the content of the game. Guess you might categorize this functionality as โpersonalizationโ.
That โpersonalizationโ only lasted as long as that web browser session lasted, and there was no recourse to recall any of that user โpersonalizedโ game data settings again, but today weโve started, by using this project as the โguinea pigโ project to start down the road of seeing whether the use of HTTP cookies might assist to extend functionality for โฆ
- only users who tailor their game via that โManagementโ link down the bottom of the game โฆ and who โฆ
- use this new
live run link (rather than the old
live run link) โฆ because there are checks to see that โฆ
- functionality occurs if the calling HTML has code such as <div id=dcookies_okay><input type=hidden id=cookies_okay value=โ></input></div>
Weโve tried thoughts that are quite โgenericโ by nature here, but we have to better monitor web browser cookie usage limits, as we go further down the road, but we โฆ
- in a web browser address bar URL such as //www.rjmprogramming.com.au/HTMLCSS/job_search_grid_game.htm that bold part is combined with a reworked date and timestamp to be the โnameโ of the cookie โฆ and only if โฆ
- the web browser address bar URL must contain a โ&โ to attract any attention as a candidate for the creation of a new cookie โฆ which, if never encountered before โฆ
- placed on a dropdown โcookieโ list of game configurations that indicate the date and timestamp for reference purposes โฆ and, as for all web browser scenarios โฆ
- cookie logic only works while the user has not cleared the Browser History at their web browser
โฆ and that HTML (select element) dropdown is placed, in โoverlayโ style โฆ
- position:absolute; top:0px ; left: 300px;
- opacity: 0.7;
- zIndex: 56;
- method=GET
- action=./job_search_grid_game.html
โฆ the Javascript logic for which has been placed into some external Javascript you could call cookie_getjs that we are going to place at //www.rjmprogramming.com.au/ (document root) for maximal access purposes, and which is called by the job_search_grid_game
htm via โฆ
<script type='text/javascript' src='../../../../cookie_get.js'></script>
โฆ which is like saying any webpage out from document root to four subfolder hierarchy could all access this external Javascript with the same codeline between <head> and </head> as above, and that external Javascript uses a setTimeout function call to separate its logic from any clashes with document.body onload event logic, or any jQuery document ready logic.
Now the HTML and Javascript could be called job_search_grid_gamehtm and changed from yesterday for HTTP Cookie functionality in thisway.
We hope you get something out of these โearly daysโ HTTP Cookie thoughts, that we may apply to some of our game web applications.
Previous relevant Job Search Grid Game Tutorial is shown below.
We are always on the lookout for a good quiz or game. But what if that idea is โsort ofโ โฆ both? Well, we just had to give the dog a bone! But we digress.
This is where we have to thank Science Puzzles for Young Einsteins by Helene Hovanec ISBN 0-8069-3542-1 profusely. This book is full of wonderful brain games that combine puzzle feels with game feel and quiz feel. We normally like to shape a game based on another we stumble across, and add our own content, but, alas, the content here for todayโs game is so good, it makes my brain hurt thinking of another set to make it work. And that is where we โvalue addโ. Not with the โdefault contentโ of the game, but to value add to the experience we CMS it. So what does โCMS itโ mean? Well, โCMSโ stands for โContent Management Systemโ, and we use the principles of CMS to encapsulate all the variable aspects we can think of about this game โฆ within reason and present that in an HTML form โฆ
โฆ our usual โsuspectsโ for such goings on. So should the information not be too long, this should allow the user to set their own content for the game โฆ all you young and old Einsteins out there.
However, if you find todayโs game interesting and/or stimulating, rest assured Helene Hovanec has filled a book full of puzzles and quizzes and challenges like this, and so we would recommend you get out there and buy Science Puzzles for Young Einsteins by Helene Hovanec ISBN 0-8069-3542-1.
Within the HTML and Javascript job_search_grid_gamehtml code you will find lots of calls to Javascriptโs eval method to get a CMS job done, but not involve a serverside language โฆ does not compute โฆ whatttevvvvvvvver.
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.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
3 Responses to Do It Yourself HTML Editor Integration Tutorial