{"id":46742,"date":"2019-10-14T03:01:51","date_gmt":"2019-10-13T17:01:51","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=46742"},"modified":"2019-10-14T09:29:28","modified_gmt":"2019-10-13T23:29:28","slug":"acronyms-lookup-wikipedia-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/acronyms-lookup-wikipedia-tutorial\/","title":{"rendered":"Acronyms Lookup Wikipedia Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Acronyms Lookup Wikipedia Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronymdata_better.jpg\" title=\"Acronyms Lookup Follow Up Tutorial\" \/><\/a><p class=\"wp-caption-text\">Acronyms Lookup Wikipedia Tutorial<\/p><\/div>\n<p>We&#8217;re revisiting the PHP web application of <a title='Acronyms Lookup Follow Up Tutorial' href='#alfut'>Acronyms Lookup Follow Up Tutorial<\/a> because &#8230;<\/p>\n<ul>\n<li>knowledge moves on, and we can normally think of either new ways (eg. today we add an <a target=_blank title='Events information from w3schools' href='http:\/\/www.w3schools.com\/tags\/ref_eventattributes.asp'>onkeydown<\/a> event &#8230; &#8221; onkeydown=&#8217;okd(event);&#8217; &#8221; &#8230;<br \/>\n<code><br \/>\nfunction okd(event) { \/\/ thanks to https:\/\/stackoverflow.com\/questions\/15355948\/preventing-tab-to-cycle-through-address-bar<br \/>\n  if ((event.keyCode == 9 || event.keyCode == 13 || event.keyCode == 10) && event.shiftKey == false) {<br \/>\n    getacronym(event.target.value);  \/\/ rejoin onblur event logic<br \/>\n  }<br \/>\n}<br \/>\n<\/code><br \/>\n &#8230; to the textbox to allow an Enter key function as well as a Tab key does on non-mobile platforms to set off the <a target=_blank title='Events information from w3schools' href='http:\/\/www.w3schools.com\/tags\/ref_eventattributes.asp'>onblur<\/a> event logic), which is a good logical improvement when only one textbox is involved in user interaction) or new functionality to add, when relooking at projects after some time (a practice we recommend) &#8230; and&#8230;<\/li>\n<li>the whole point of an acronym is that that shortening itself often hides complexity, which we think <b>links<\/b> to <a target=_blank title='Wikipedia, thanks' href='https:\/\/wikipedia.org'>Wikipedia<\/a> &#8230;<br \/>\n<code><br \/>\nfunction wikilinkit(inwds) {<br \/>\n  return \"&lt;a target=wikif onmouseover=\\\"window.open('\/\/en.wikipedia.org\/wiki\/\" + inwds.toLowerCase().replace(\/\\ \/g,'_') + \"','wikif');\\\" href='\/\/en.wikipedia.org\/wiki\/\" + inwds.toLowerCase().replace(\/\\ \/g,'_') + \"'&gt;\" + inwds + \"&lt;\/a&gt;\";<br \/>\n}<br \/>\n<br \/>\nfunction getacronym(vsselname) {   \/\/ textbox onblur event logic<br \/>\n\/\/code above ... see a bit of it in excerpt later ...<br \/>\n     <i>var w = window.open();<\/i><br \/>\n     w.document.open();<br \/>\n     <b>var bits=output.split('&lt;\/td&gt;&lt;td&gt;');<br \/>\n     for (var ij=(-2 + bits.length); ij&gt;1; ij--) {<br \/>\n       if ((bits[ij] + ' ').substring(0,1).toUpperCase() &gt;= 'A' && (bits[ij] + ' ').substring(0,1).toUpperCase() &lt;= 'Z') {<br \/>\n         output=output.replace('&lt;\/td&gt;&lt;td&gt;' + bits[ij] + '&lt;\/td&gt;&lt;td&gt;', '&lt;\/td&gt;&lt;td&gt;' + wikilinkit(bits[ij]) + '&lt;\/td&gt;&lt;td&gt;');<br \/>\n       }<br \/>\n     }<\/b><br \/>\n     w.document.write(output.replace('vis' + 'ible','VIS' + 'ible').replace('hid' + 'den','VIS' + 'IBLE').replace('hid' + 'den','VIS' + 'IBLE').replace('hid' + 'den','VIS' + 'IBLE').replace('hid' + 'den','VIS' + 'IBLE'));<br \/>\n     w.document.close();<br \/>\n\/\/ code below<br \/>\n}<br \/>\n<\/code><br \/>\n &#8230; can really help the user understand more, and be functionally quite useful<\/li>\n<\/ul>\n<p>How do we know?  Well, we tried it, and found in a short space of time we learnt a lot by (on non-mobile) hovering over (and on mobile, clicking) newly linked acronym meanings, and seeing information to the right, if possible or below, otherwise, in an HTML <a target=_blank title='HTML iframe element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_iframe.asp'>iframe<\/a> element containing the Wikipedia lookup of those acronym meaning words.<\/p>\n<p>It may have happened before, we cannot exactly recall, but <b>today&#8217;s changes<\/b> made real use of <a target=_blank title='window.opener information from W3Schools' href='https:\/\/www.w3schools.com\/jsref\/prop_win_opener.asp'>window.opener<\/a> &#8220;reference to parent(.window) of a window.open() child window&#8221; &#8230;<\/p>\n<p><code><br \/>\nfunction getacronym(vsselname) {  \/\/ textbox onblur event logic<br \/>\n <b>if (window.opener) {  <i>\/\/ ie. this window was opened using window.open<\/i><br \/>\n   window.opener.document.getElementById('acronym').value=vsselname;<br \/>\n   window.opener.getacronym(vsselname);<br \/>\n } else {<\/b><br \/>\n   \/\/usual parent (ie. window.opener) textbox onblur logic goes here<br \/>\n <b>}<\/b><br \/>\n}<br \/>\n<\/code><\/p>\n<p> &#8230; so that a user can enter new acronyms in any textboxes that present themselves (parent window, or otherwise), and the logic to open a new window (via window.open) is redirected back to that very first textbox&#8217;s (onblur logic, eventually), every time.<\/p>\n<p>You can check out <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronymdata.html---GETME\" title='getacronymdata.htm'>these changes<a> of <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronymdata.html---GETME\" title='getacronymdata.htm'>getacronymdata.htm<\/a>&#8216;s <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/\" title=\"Click picture\">acronym web application<\/a> to see (or try) this all for yourself.<\/p>\n<p>You can also see this play out at WordPress 4.1.1&#8217;s <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/acronyms-lookup-wikipedia-tutorial\/'>Acronyms Lookup Wikipedia Tutorial<\/a>.<\/p>\n<hr>\n<p id='alfut'>Previous relevant <a target=_blank title='Acronyms Lookup Follow Up Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/acronyms-lookup-follow-up-tutorial\/'>Acronyms Lookup Follow Up Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Acronyms Lookup Follow Up Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronym.png\" title=\"Acronyms Lookup Follow Up Tutorial\" id='ialfut' onmouseover=\" this.src=this.src.replace('.gif','.xpng').replace('.png','.xjpg').replace('.jpg','.xgif').replace('.x','.');    \" \/><\/a><p class=\"wp-caption-text\">Acronyms Lookup Follow Up Tutorial<\/p><\/div>\n<p>Wanted, today, to follow up on yesterday&#8217;s <a target=_blank title='Acronyms Lookup Primer Tutorial' href='#alpt'>Acronyms Lookup Primer Tutorial<\/a> as shown below, with some improvements, we think would be good, regarding &#8230;<\/p>\n<ul>\n<li>making its aesthetics more impactive &#8230; via <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronym.jpg\" title='getacronym.jpg'>background image<\/a> up the top, created by a combination of (Mac) Paintbrush and good ol&#8217; Gimp (you may want to refer to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=9389' title='Gimp Transparency Primer Tutorial'>Gimp Transparency Primer Tutorial<\/a> here) &#8230; the inspiration for which came from <a target=_blank href='http:\/\/abbreviations.yourdictionary.com\/articles\/common-accronyms.html' title='Common acronyms'>this link<\/a> and which set in play, for consistency&#8217;s sake, that if some of the more modern background image acronyms are used we should get a result, even if that acronym is not on the NaCTeM database, but not say they have a <i>&#8220;frequency&#8221;<\/i> nor <i>&#8220;since&#8221;<\/i> value (to differentiate them) &#8230; affecting &#8230;<\/li>\n<li>add to the functionality by allowing sorts on columns in the header fields &#8230; do you remember <a target=_blank title='jQuery Sortable Table Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=9094'>jQuery Sortable Table Primer Tutorial<\/a>? &#8230; we include this functionality &#8230; which meant that &#8230;<\/li>\n<li>all JSON parsing will now be handled by PHP (whether uppercase or lowercase), in this amended parent HTML you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronymdata.html-GETME\" title='getacronymdata.htm'>getacronymdata.htm<\/a> calling  <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronymdata.php-GETME\" title='getacronymdata.php'>getacronymdata.php<\/a> (and the differences to yesterday&#8217;s can be found at <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronymdata.html-GETME\" title='getacronymdata.htm'>getacronymdata.htm<\/a> and  <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronymdata.php-GETME\" title='getacronymdata.php'>getacronymdata.php<\/a>)\n<\/ul>\n<p>You may notice with the amended HTML that we made use of JavaScript <a target=_blank title='Window.open information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_open.asp'>&#8220;var w = window.open();&#8221;<\/a> (exactly) and JavaScript <a target=_blank title='Document.write information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_doc_write.asp'>&#8220;w.document.write([newHTMLviaPHP]);&#8221;<\/a> to have the jQuery Sortable Table logic happen at the web page&#8217;s onload event, where so much needs to go on, when you get into HTML and JavaScript usage, and where the interface of traditional JavaScript and jQuery means that you should not assume both &#8220;onload&#8221; logics will get a look in without testing this out for yourself.<\/p>\n<p>We&#8217;ve tagged this posting with <a target=_blank title='ESL' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=esl'>&#8220;ESL&#8221;<\/a> (because we leave it open to a teacher of English whether such a web application could become a resource for a good lesson about acronymns).  We think the increasing everyday use of acronyms in all walks of life maybe make it a necessary &#8220;getting by&#8221; lesson for English learners, but maybe not very early English learners.<\/p>\n<p>Hope you like the new web application that results at this <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/\" title='Click picture'>live run<\/a>.<\/p>\n<hr>\n<p id='alpt'>Previous relevant <a target=_blank title='Acronyms Lookup Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=14122'>Acronyms Lookup 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\/PHP\/JSON\/Acronym\/getacronymdata.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Acronyms Lookup Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronymdata.jpg\" title=\"Acronyms Lookup Primer Tutorial\" \/><\/a><p class=\"wp-caption-text\">Acronyms Lookup Primer Tutorial<\/p><\/div>\n<p>It&#8217;s good every now and then to see what is new in the world of data feeds on the internet, so that is how, via this <a target=_blank title='Great link for latest public feeds of interest' href='http:\/\/gearside.com\/public-json-feeds\/'>great link<\/a>, we got onto the wonderful Acronym lookup resource at <a target=_blank title='' href='http:\/\/www.nactem.ac.uk\/'>NaCTeM<\/a> (The National Centre for Text Mining) &#8230; thanks &#8230; <\/p>\n<blockquote><p>\nAcromine: Okazaki, N., Ananiadou, S. (2006) Building an abbreviation dictionary using a term recognition approach. Bioinformatics, Volume 22, Number 24, pp. 3089-3095, Oxford University Press\n<\/p><\/blockquote>\n<p>So this tutorial uses the data emanating from NaCTeM&#8217;s feed of Acronym data.  You fill in an Acronym of interest into an input text box and known results are sent back in JSON format.<\/p>\n<p>The two big PHP functions of use for JSON parsing are (normally):<\/p>\n<ul>\n<li><a target=_blank title='file_get_contents' href='http:\/\/us1.php.net\/file_get_contents'>file_get_contents<\/a><\/li>\n<li><a target=_blank title='json_decode' href='http:\/\/php.net\/manual\/en\/function.json-decode.php'>json_decode<\/a><\/li>\n<\/ul>\n<p>Another tool you should have in your armoury for jobs like this is the online JSON validator <a target=_blank title='JSON validator online' href='http:\/\/jsonlint.com\/'>here<\/a>.  A generic JSON approach to issues could be:<\/p>\n<ol>\n<li>Type the URL you were given into a web browser address bar and have a look at it<\/li>\n<li>Type the URL you were given into http:\/\/jsonlint.com\/ and have it validated<\/li>\n<li>Understand in your own mind what would be different about 1. to make it suitable<\/li>\n<li>Incorporate findings of 3. into massaging of data between file_get_contents and json_decode<\/li>\n<\/ol>\n<p>Here is a link to some downloadable HTML programming source code which you may want to rename to <a target=_blank title='getacronymdata.html' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronymdata.html_GETME\">getacronymdata.html<\/a> which calls some downloadable PHP programming source code which you may want to rename to <a target=_blank title='getacronymdata.php' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronymdata.php_GETME\">getacronymdata.php<\/a><\/p>\n<p>Here are a few things you may find interesting about the code &#8230;<\/p>\n<ul>\n<li>the HTML calls the PHP via <a target=_blank title='jQuery Ajax' href='http:\/\/api.jquery.com\/jquery.ajax\/'>jQuery Ajax<\/a> (and avoids cross-domain issues by using local PHP)<\/li>\n<li>the HTML will parse the JSON callback data if it is a totally capitalised entry (using <a target=_blank title='JSON.parse() and general JSON information from w3schools' href='http:\/\/www.w3schools.com\/json\/json_eval.asp'>JSON.parse()<\/a>), else the PHP will do the JSON parsing<\/li>\n<li>we found the raw callback data needed the outer [] stripped to be JSON parsable<\/li>\n<\/ul>\n<p>So maybe you will find something interesting with today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/Acronym\/getacronymdata.html\" title='Click picture'>live run<\/a>, and hope to see you tomorrow with improvements.<\/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='#d14122' onclick='var dv=document.getElementById(\"d14122\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=JSON\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d14122' 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='#d14143' onclick='var dv=document.getElementById(\"d14143\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=ESL\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d14143' 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='#d46742' onclick='var dv=document.getElementById(\"d46742\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/wikipedia\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d46742' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re revisiting the PHP web application of Acronyms Lookup Follow Up Tutorial because &#8230; knowledge moves on, and we can normally think of either new ways (eg. today we add an onkeydown event &#8230; &#8221; onkeydown=&#8217;okd(event);&#8217; &#8221; &#8230; function okd(event) &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/acronyms-lookup-wikipedia-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,14,37],"tags":[56,69,2907,652,663,1807,932,997,1238,1319,1431],"class_list":["post-46742","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-acronym","tag-ajax","tag-ajax-jquery","tag-javascript","tag-jquery","tag-link","tag-php","tag-programming","tag-table","tag-tutorial","tag-wikipedia"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/46742"}],"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=46742"}],"version-history":[{"count":7,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/46742\/revisions"}],"predecessor-version":[{"id":46786,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/46742\/revisions\/46786"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=46742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=46742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=46742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}