{"id":12156,"date":"2015-02-23T05:10:12","date_gmt":"2015-02-22T18:10:12","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=12156"},"modified":"2015-02-23T05:10:12","modified_gmt":"2015-02-22T18:10:12","slug":"wordpress-blog-download-mode-toggler-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wordpress-blog-download-mode-toggler-primer-tutorial\/","title":{"rendered":"WordPress Blog Download Mode Toggler Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/wordpress\/toggle_download_mode-0of.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Wordpress Blog Download Mode Toggler Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/wordpress\/toggle_download_mode-0of.jpg\" title=\"Wordpress Blog Download Mode Toggler Primer Tutorial\" id='wbdm' onmouseover=\" this.src=this.src.replace('-0', '-x1').replace('-1', '-x2').replace('-2', '-x3').replace('-3', '-x4').replace('-4', '-x5').replace('-5', '-x6').replace('-6', '-x7').replace('-7', '-x8').replace('-8', '-x9').replace('-9', '-x0').replace('-x','-');   \"    \/><\/a><p class=\"wp-caption-text\">Wordpress Blog Download Mode Toggler Primer Tutorial<\/p><\/div>\n<p>On this WordPress Blog we&#8217;ve had a policy with downloading of code that it is more or less up to the user to read the code, take their own copy, and use that (clipboard) buffer however they feel like it.   However it may be that you want to skip some of these steps and download it to your hard disk straight away, and so, we, today, offer that as an alternative, and if chosen, that mode of use stays for all visits (using that same Web Browser) for the computer you are using, until you reset the &#8220;toggler&#8221; to the other <i>download mode<\/i> of use.<\/p>\n<p>So what facilitates this change in functionality?   Well, it is to do with a Javascript DOM conditional setting for an HTML <a target=_blank title='HTML a tag information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_a.asp'><i>a<\/i><\/a> link&#8217;s <i>download<\/i> parameter (new to HTML5).<\/p>\n<p>You might ask whether all <i>a<\/i> tags are affected, and the answer is &#8230; no.   It is only those with <i>GETME<\/i> in their <i>href<\/i> parameter, and only the ones of those that don&#8217;t mention <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5435' title='Linux diff Primer Tutorial'><i>diff.php<\/i><\/a>, which is that code comparison piece of PHP we use here at this blog.<\/p>\n<p>And where might you add such functionality?   Well, we wanted it <i>above the <a target=_blank title='Above the fold information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Above_the_fold'>&#8220;fold&#8221;<\/a><\/i> somewhere, and we figured it affected lots of postings, so why not put it as a suboption or <a target=_blank title='WordPress Blog Submenu Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=11802'>submenu<\/a> of the <i>All Posts<\/i> menu.<\/p>\n<p>We make it effectively a single link to work, but give you the chance to refuse to do it with a Javascript <a target=_blank href='http:\/\/www.w3schools.com\/jsref\/met_win_prompt.asp' title='Javascript prompt window information from w3schools'><i>prompt<\/i><\/a> window, where we explain the implications in a little more detail than is applicable for a suboption submenu wording.<\/p>\n<p>So you can see the <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/wordpress\/toggle_download_mode-0of.jpg\" title='Add Page'><i>Add Page<\/i><\/a> that that menu suboption required, and the piece of independent PHP programming source code required to make all this possible is <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/wordpress\/toggle_download.php_GETME\" title='toggle_download.php'>toggle_download.php<\/a> &#8230; gasp, you just read over an applicable link for this functionality &#8230; if you click\/touch it you&#8217;ll see what <i>download mode<\/i> you have.  Click\/touch another such link on this webpage, and it should behave in a similar fashion.   Go to another webpage on the blog and it should behave in a similar fashion &#8230; until you use the new submenu suboption to toggle it.<\/p>\n<p>If you want to see how good old header.php changed it is in two parts below (with <b>bold<\/b> bits of change) &#8230; up near the top (before anything significant happens in the code), then around <i>courseCookies<\/i> (as per usual) versus, if you don&#8217;t have <i>course<\/i> functionality you can go <i>&lt;body onload=&#8221; download_mode();  &#8220;&gt;<\/i> &#8230;<\/p>\n<p><code><br \/>\n<b><br \/>\n$isnow = \"from\";<br \/>\nfunction my_t_d_server_remote_addr() {<br \/>\n    $rma = $_SERVER['REMOTE_ADDR'];<br \/>\n    $ua = strtolower($_SERVER['HTTP_USER_AGENT']);<br \/>\n    \/\/ you can add different browsers with the same way ..<br \/>\n    if(preg_match('\/(chromium)[ \/]([w.]+)\/', $ua))<br \/>\n            $rma = '000000'.$rma;<br \/>\n    elseif(preg_match('\/(chrome)[ \/]([w.]+)\/', $ua))<br \/>\n            $rma = '00000'.$rma;<br \/>\n    elseif(preg_match('\/(safari)[ \/]([w.]+)\/', $ua))<br \/>\n            $rma = '0000'.$rma;<br \/>\n    elseif(preg_match('\/(opera)[ \/]([w.]+)\/', $ua))<br \/>\n            $rma = '000'.$rma;<br \/>\n    elseif(preg_match('\/(msie)[ \/]([w.]+)\/', $ua))<br \/>\n            $rma = '00'.$rma;<br \/>\n    elseif(preg_match('\/(mozilla)[ \/]([w.]+)\/', $ua))<br \/>\n            $rma = '0'.$rma;<br \/>\n    return $rma;<br \/>\n}<br \/>\nif (file_exists(\"t_d_\" . my_t_d_server_remote_addr() . \"huh\")) {<br \/>\n  $isnow = \"to\";<br \/>\n}<br \/>\n<\/b><br \/>\n<\/code><\/p>\n<p>&#8230;<\/p>\n<p><code><br \/>\n<b><br \/>\nfunction changeasfordownload() {<br \/>\n  var idmjk=0, newaspare='', big='----------------------GETME', stuffs;<br \/>\n  var admjk = document.getElementsByTagName('a');<br \/>\n  for (idmjk=0; idmjk&lt;admjk.length; idmjk++) {<br \/>\n    if (admjk[idmjk].href.indexOf('GETME') != -1 && admjk[idmjk].href.indexOf('diff.php') == -1) {<br \/>\n      newaspare = admjk[idmjk].href.replace('_-GETME', '').replace('__GETME', '').replace('_GETME', '').replace(big, '');<br \/>\n      while (big.indexOf('-') != -1) {<br \/>\n        big = big.replace('-', '');<br \/>\n        newaspare = newaspare.replace(big, '');<br \/>\n      }<br \/>\n      big = '----------------------GETME';<br \/>\n      stuffs = newaspare.split('\/');<br \/>\n      admjk[idmjk].download = stuffs[stuffs.length - 1];<br \/>\n      admjk[idmjk].title = \"(Really download) \" + admjk[idmjk].title +  ' ... welcome to the long hover functionality that shows allows for a Download Mode for the blog that can be toggled';<br \/>\n      admjk[idmjk].onmouseover = \" getDownloadMode(); \";<br \/>\n      admjk[idmjk].onmouseout = \" yehBut(); \";<br \/>\n      admjk[idmjk].ontouchstart = \" getDownloadMode(); \";<br \/>\n      admjk[idmjk].ontouchend = \" yehBut(); \";<br \/>\n   }<br \/>\n  }<br \/>\n}<br \/>\nfunction download_mode() {<br \/>\n  var dmjk=0;<br \/>\n&lt;?php<br \/>\nif ($isnow == \"to\") {<br \/>\n echo \"n\" . ' var oxli=document.getElementsByClassName(\"page-item-12153\");  if (oxli[0] != null) { var ns=oxli[0].innerHTML.replace(' . \"'Toggle Download Mode fr' + 'om GE' + 'TME', 'Toggle Download Mode t' + 'o GE' + 'TME'\" . ').replace(' . \"'Toggle Download Mode fr' + 'om GE' + 'TME', 'Toggle Download Mode t' + 'o GE' + 'TME'\" . ');  oxli[0].innerHTML=ns;  } ' . \"n\";<br \/>\n echo \"n\" . ' var coxli=document.getElementsByClassName(\"entry-title\");  if (coxli[0] != null) { coxli[0].innerHTML=coxli[0].innerHTML.replace(' . \"'Toggle Download Mode fr' + 'om GE' + 'TME', 'Toggle Download Mode t' + 'o GE' + 'TME'\" . ').replace(' . \"'Toggle Download Mode fr' + 'om GE' + 'TME', 'Toggle Download Mode t' + 'o GE' + 'TME'\" . ');  } ' . \"n\";<br \/>\n echo \"n\" . ' changeasfordownload(); ' . \"n\";<br \/>\n}<br \/>\n?&gt;<br \/>\n}<br \/>\n<\/b><br \/>\nfunction courseCookies() {<br \/>\n<b><br \/>\n  download_mode();  \/\/ Check on Download mode<br \/>\n<\/b><br \/>\n  checkpt(); \/\/ category and tag \"oldest\"<br \/>\n  rptwo();  \/\/ Recent Post images<br \/>\n<\/code><\/p>\n<p>Our contextual help Javascript source code (all in the one place) can be downloaded by <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/wajax.js------------GETME' title='wajax.js'>wajax.js<\/a> which changed as per <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/wordpress\/wajax.js------------GETME' title='wajax.js'>wajax.js<\/a> for these modifications today.<\/p>\n<p>Hope you enjoy today&#8217;s tutorial.<\/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='#d12156' onclick='var dv=document.getElementById(\"d12156\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=wordpress\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d12156' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>On this WordPress Blog we&#8217;ve had a policy with downloading of code that it is more or less up to the user to read the code, take their own copy, and use that (clipboard) buffer however they feel like it. &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/wordpress-blog-download-mode-toggler-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,37],"tags":[51,151,354,360,488,576,578,587,652,770,932,997,1214,1319,1350,1356,1407,1418,1456],"class_list":["post-12156","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-above-the-fold","tag-blog","tag-dom","tag-download","tag-getme","tag-html","tag-html5","tag-iframe","tag-javascript","tag-menu","tag-php","tag-programming","tag-submenu","tag-tutorial","tag-user-experience","tag-ux","tag-web-design","tag-webpage","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/12156"}],"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=12156"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/12156\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=12156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=12156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=12156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}