{"id":25719,"date":"2016-10-16T03:01:54","date_gmt":"2016-10-15T17:01:54","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=25719"},"modified":"2016-10-16T19:47:28","modified_gmt":"2016-10-16T09:47:28","slug":"html-style-mapping-tool-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-style-mapping-tool-primer-tutorial\/","title":{"rendered":"HTML Style Mapping Tool Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/emojislideshow.htm\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"HTML Style Mapping Tool Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/meld_styles.jpg\" title=\"HTML Style Mapping Tool Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">HTML Style Mapping Tool Primer Tutorial<\/p><\/div>\n<p>We&#8217;re having a first go at a new web application tool idea today, an external Javascript tool that when applied to a webpage, <a onclick=\" document.getElementById('qpcomzm').style.display='inline'; document.getElementById('scomzm').style.display='inline';  \" style=\" text-decoration:underline; cursor: pointer; \"><font color=blue;>or not<\/font><\/a>, between &lt;head&gt; and &lt;\/head&gt; via &#8230;<\/p>\n<p><code><br \/>\n&lt;<span id='qpcomzm' style='display:none;color:blue;'>!--<\/span>script type='text\/javascript' src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/meld_styles.js'&gt;&lt;\/script<span id='scomzm' style='display:none;color:blue;'>--<\/span>&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; allows you to dynamically map some aspects of an HTML element&#8217;s style onto others.<\/p>\n<p>So far, with our prototype &#8220;tool&#8221; we only allow elements to have styling mapped from, be those with a non-blank <i>innerHTML<\/i> property, but we&#8217;ll see over time if this opens up &#8230; am not sure.<\/p>\n<p>Maybe you remember the Javascript function &#8220;copyTextareaStyling&#8221; featuring in the <a title='HTML Textarea and Div Talents Primer Tutorial' href='#htadtpt'>HTML Textarea and Div Talents Primer Tutorial<\/a> as shown below?  Well, that formed the heart and soul of the new &#8220;tool&#8221; today that has this external Javascript programming source you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/meld_styles.js_GETME\" title='meld_styles.js'>meld_style.js<\/a> and which you can try out because we have <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/emojislideshow.htm\">here<\/a> a Random Emoji Slideshow to enable you to try this &#8220;tool&#8221;.<\/p>\n<hr>\n<p id='htadtpt'>Previous relevant <a target=_blank title='HTML Textarea and Div Talents Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/html-textarea-and-div-talents-primer-tutorial\/'>HTML Textarea and Div Talents Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.html\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"HTML Textarea and Div Talents Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.jpg\" title=\"HTML Textarea and Div Talents Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">HTML Textarea and Div Talents Primer Tutorial<\/p><\/div>\n<p>We faced a dilemma today with the name of our web application, and ended up with <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.html-GETME\" title='textarea_talent.html'>textarea_talent.html<\/a> (along with its business logic external Javascript <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.js_GETME\" title='textarea_talent.js'>textarea_talent.js<\/a>), but as the project went along we were torn towards a name of <i>div_talent.html<\/i> and <i>div_talent.js<\/i> as we shall explain below.<\/p>\n<p>We understand the great role the HTML <a target=_blank title='HTML textarea tag information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_textarea.asp'>textarea<\/a> element has in <a target=_blank title='Content Management System information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Content_management_system'>CMS<\/a> (Content Management Systems) work, and we illustrate this below with (a) WordPress (blog as an example) &#8230;<\/p>\n<p><img src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.jpeg'><\/img><\/p>\n<p>It&#8217;s crucial for getting HTML or non-caretted Text (that is internally turned into HTML behind the scenes) &#8230; via those <a target=_blank title='Excel Online Spreadsheet Monthly Planner Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/excel-online-spreadsheet-monthly-planner-primer-tutorial\/'>wonderful<\/a> <a target=_blank title='Tab navigation button or panel information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Tab_(GUI)'>tabs<\/a> &#8230; 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&#8217;ve no doubt this content is embedded in an HTML <a target=_blank title='HTML div tag information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_div.asp'>div<\/a> element, the other &#8220;talent&#8221; here.<\/p>\n<p>But their strengths and weaknesses go like this, at least to us, in the limited HTML text view of things &#8230;<\/p>\n<table border=100>\n<tr>\n<th>Text Functionality Issue<\/th>\n<th>HTML Element Type<\/th>\n<th>Strength<\/th>\n<th>Weakness (where a &#8220;Yes&#8221; is like &#8230; &#8220;Oh No!&#8221;)<\/th<\/tr>\n<tr>\n<td rowspan=2>Display Monocolour Text<\/td>\n<td>Textarea<\/th>\n<td>Yes<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Div<\/th>\n<td>Yes<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td rowspan=2>Display Editable Text<\/td>\n<td>Textarea<\/th>\n<td>Yes<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Div<\/th>\n<td><\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<tr>\n<td rowspan=2>Display Multicolour Text<\/td>\n<td>Textarea<\/th>\n<td><\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Div<\/th>\n<td>Yes<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<\/table>\n<p>Our web application today is like an inhouse version of (a web browser) View Page Source type of arrangement, but allowing, optionally, for the highlighting of words.  The &#8220;highlighting of words&#8221; functionality needed the HTML div element to come into the equation, otherwise the &#8220;talents&#8221; of an HTML textarea element would have sufficed, and are normally preferred, for those editing reasons.  By the way, an HTML textarea element given a <a target=_blank title='HTML textarea element readonly property' href='http:\/\/www.w3schools.com\/tags\/att_textarea_readonly.asp'><i>readonly<\/i><\/a> property stops the user changing an HTML textarea element&#8217;s contents, should that be what you require.<\/p>\n<p>Another issue came into play as a &#8220;subtheme&#8221; of today&#8217;s tutorial.  Are you aware that some HTML elements, such as &#8230;<\/p>\n<blockquote><p>\nTextarea elements do not, by default, inherit CSS styling settings of the webpage Body element\n<\/p><\/blockquote>\n<p> &#8230; which means, without Javascript DOM programmatic intervention the text shown in an HTML textarea element will differ greatly in its appearance to that of an HTML div element.  This annoyed us enough to warrant some research and development on this topic and found that the idea to have both HTML div and textarea elements to be mapped to the inherited look of the HTML body element, that you might attempt to do via CSS like &#8230;<\/p>\n<p><code><br \/>\n&lt;style&gt;<br \/>\ntextarea, div {<br \/>\n font-family: inherit;<br \/>\n font-size: inherit;<br \/>\n}<br \/>\n&lt;\/style&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; was not nearly so effective a thing to do, as to put in the hard yards to &#8220;purloin&#8221; the styling characteristics of one HTML element type and &#8220;slap&#8221; those characteristics, via Javascript DOM, onto the other HTML element type of interest, via code (snippet) like used today (with its &#8220;thank you&#8221; implied link), as per &#8230;<\/p>\n<p><code><br \/>\nfunction copyTextareaStyling() {<br \/>\n    var output = document.getElementById(\"tarea\"), divelem = document.getElementById(\"tareadiv\");<br \/>\n    if (divelem) { \/\/ thanks to ideas off <a target=_blank title='Useful link, thanks' href='http:\/\/stackoverflow.com\/questions\/12266320\/copy-div-content-to-textarea-or-text-with-the-same-font-family-style'>http:\/\/stackoverflow.com\/questions\/12266320\/copy-div-content-to-textarea-or-text-with-the-same-font-family-style<\/a><br \/>\n      divelem.style.fontFamily = window.getComputedStyle(output,null).fontFamily || output.style.fontFamily || output.currentStyle.getCurrentProperty('font-family');<br \/>\n      divelem.style.fontSize = window.getComputedStyle(output,null).fontSize || output.style.fontSize || output.currentStyle.getCurrentProperty('font-size');<br \/>\n      divelem.style.border = window.getComputedStyle(output,null).border || output.style.border || output.currentStyle.getCurrentProperty('border');<br \/>\n      divelem.style.padding = window.getComputedStyle(output,null).padding || output.style.padding || output.currentStyle.getCurrentProperty('padding');<br \/>\n      divelem.style.margin = window.getComputedStyle(output,null).margin || output.style.margin || output.currentStyle.getCurrentProperty('margin');<br \/>\n      divelem.style.overflow = window.getComputedStyle(output,null).overflow || output.style.overflow || output.currentStyle.getCurrentProperty('overflow');<br \/>\n    }<br \/>\n}<br \/>\n<\/code><\/p>\n<p> &#8230; via the wonders of the Javascript <a target=_blank title='window.getComputedStyle information' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/getComputedStyle'>window.getComputedStyle()<\/a> method that we have mentioned before a few times at this <a target=_blank title='Search for window.getComputedStyle blog postings here' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/?s=window.getComputedStyle&#038;stype=Search'>blog<\/a>.<\/p>\n<p>Maybe you are a regular at this blog, and recognize the look of today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.html\" title='Click picture'>live run<\/a> web application?  Yes, a lot of the ideas emanating from <a target=_blank title='Legend for and from HTML Map Element Web Server Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/legend-for-and-from-html-map-element-web-server-tutorial\/'>Legend for and from HTML Map Element Web Server Tutorial<\/a> thread of blog postings went into the <a target=_blank title='Information about purloinment' href='http:\/\/www.yourdictionary.com\/purloinment'>&#8220;purloinment&#8221;<\/a> &#8230; <font size=1>nga, nga .. nga nga &#8230; ngaaa &#8230; it is a word<\/font> &#8230; exercise done on <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/legend_via_map.html------GETME\" title='legend_via_map.htm'>legend_via_map.htm<\/a>&#8216;s code <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.html-GETME\" title='textarea_talent.html'>in this way<\/a> mostly to do with the virtuous decision to hive off specific business logic to the external Javascript <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/textarea_talent.js_GETME\" title='textarea_talent.js'>textarea_talent.js<\/a>.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d25195' onclick='var dv=document.getElementById(\"d25195\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/textarea\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d25195' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d25719' onclick='var dv=document.getElementById(\"d25719\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/css\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d25719' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re having a first go at a new web application tool idea today, an external Javascript tool that when applied to a webpage, or not, between &lt;head&gt; and &lt;\/head&gt; via &#8230; &lt;!&#8211;script type=&#8217;text\/javascript&#8217; src=&#8217;http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/meld_styles.js&#8217;&gt;&lt;\/script&#8211;&gt; &#8230; allows you to dynamically map &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-style-mapping-tool-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,1,37],"tags":[281,409,576,652,716,997,1254,2005,1319],"class_list":["post-25719","post","type-post","status-publish","format-standard","hentry","category-elearning","category-uncategorised","category-tutorials","tag-css","tag-external-javascript","tag-html","tag-javascript","tag-log","tag-programming","tag-text","tag-tool","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/25719"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=25719"}],"version-history":[{"count":4,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/25719\/revisions"}],"predecessor-version":[{"id":25723,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/25719\/revisions\/25723"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=25719"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=25719"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=25719"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}