Do It Yourself HTML Textarea Editor Shortcut Key Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

Do It Yourself HTML Textarea Editor Shortcut Key Tutorial

Do It Yourself HTML Textarea Editor Shortcut Key Tutorial

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. We allow for the linking of yesterdayโ€™s Cursor Positioned HTML dropdown helpers, 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 you could call do_away_with_the_boring_bitsโšซhtml and which 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.

Do It Yourself HTML Textarea Editor Cursor Tutorial

Do It Yourself HTML Textarea Editor Cursor Tutorial

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.

Below are the two main functions new to the logic to get a cursor position โ€ฆ



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 then to set a cursor position โ€ฆ



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;

}

โ€ฆ you can see with the HTML and Javascript you could call do_away_with_the_boring_bits.html and which changed from yesterday for textarea cursor functionality in thisway. Please feel free to try it out yourself at a liveโœ‚run link.


Previous relevant Do It Yourself HTML Primer Tutorial is shown below.

Do It Yourself HTML Primer Tutorial

Do It Yourself HTML Primer Tutorial

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 โ€ฆ
    1. see the results of your work to the right in a light blue area โ€ฆ and โ€ฆ
    2. 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 liveโœ‚run 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.

Job Search Grid Game Cookie Tutorial

Job Search Grid Game Cookie Tutorial

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;
  • โ€ฆ the Javascript logic for which has been placed into some external Javascript you could call cookie_getโšซjs 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_gameโšซhtm 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.

    Job Search Grid Game Tutorial

    Job Search Grid Game Tutorial

    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 โ€ฆ

    • method=GET
    • action=./job_search_grid_game.html

    โ€ฆ 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_gameโšซhtml 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.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *