{"id":28897,"date":"2017-09-03T03:01:09","date_gmt":"2017-09-02T17:01:09","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=28897"},"modified":"2017-09-02T16:03:04","modified_gmt":"2017-09-02T06:03:04","slug":"binding-javascript-settimeout-arguments-php-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/binding-javascript-settimeout-arguments-php-tutorial\/","title":{"rendered":"Binding Javascript setTimeout Arguments PHP Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.php\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Binding Javascript setTimeout Arguments PHP Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.png\" title=\"Binding Javascript setTimeout Arguments PHP Tutorial\"   \/><\/a><p class=\"wp-caption-text\">Binding Javascript setTimeout Arguments PHP Tutorial<\/p><\/div>\n<p>Yesterday, with <a title='Binding Javascript setTimeout Arguments Trace Tutorial' href='#bjsatt'>Binding Javascript setTimeout Arguments Trace Tutorial<\/a> we started out &#8220;guinea pig&#8221; fashion, fashioning &#8220;trace&#8221; thoughts regarding <i>client<\/i> Javascript code <i>tracing<\/i>.  So what is &#8220;PHP&#8221; doing in the blog posting title today, it being synonymous with <i>server<\/i> code?  Well, as is so often the case, the way serverside code is like a supervisory coding layer on top of any client side Javascript you have, this is particularly beneficial for you &#8220;not to blow your mind&#8221; with respect to proceeding in any generic way with these thoughts for more than our little HTML we wrote to illustrate &#8220;Binding Javascript setTimeout Arguments&#8221; thoughts, starting two days ago with <a title='Binding Javascript setTimeout Arguments Primer Tutorial' href='#bjsapt'>Binding Javascript setTimeout Arguments Primer Tutorial<\/a> as shown way below.<\/p>\n<p>The aspects of dynamic &#8220;tracing&#8221; of a web application that PHP can help with, so far with our design thoughts (which are still a &#8220;fluid&#8221; list), are &#8230;<\/p>\n<ul>\n<li>accept a $_GET[&#8216;trace&#8217;] argument pointing at the web application<\/li>\n<li>settle on <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.js_GETME\" title=\"argument_to_setTimeout.js\">argument_to_setTimeout.js<\/a> as the generic Javascript to ensure is called via an HTML <i>script<\/i> tag pointing at it, added after any internal Javascript code<\/li>\n<li>ensure an HTML div element id=<i>myta<\/i> exists at the end of the <i>body<\/i> element, ready to hold the web application tracing &#8220;report&#8221;<\/li>\n<li>insert into the Javascript code, purloining the thoughts of yesterday&#8217;s blog posting &#8230;\n<ol>\n<li>at lines of code involving <a target=_blank title='Javascript setTimeout method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_settimeout.asp'><i>setTimeout<\/i><\/a> (Batman&#8217;s, and the partner in <font size=1>whatevvvvvvvver<\/font>, Robin&#8217;s) <a target=_blank title='Javascript setInterval method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_setinterval.asp'><i>setInterval<\/i><\/a> timers<\/li>\n<li>at the top of an &#8220;if&#8221; or &#8220;while&#8221; or &#8220;for&#8221; or other looping structure, and one (or more) lines of code into the &#8220;if&#8221; (or &#8220;else if&#8221; etcetera) blocks<\/li>\n<\/ol>\n<p> &#8230; before relevant lines of Javascript code (this thought process and logic is also very &#8220;fluid&#8221;)\n<\/li>\n<li>all above has, in the meantime, been stored in an PHP (<i>$htmlis<\/i>) variable <font size=1> &#8230; see how PHP can help &#8230; <\/font> that is then <i>echo<\/i>ed out as the web application client code used for your execution &#8230; hopefully showing some tracing of the execution &#8220;highlights&#8221;<\/li>\n<\/ul>\n<p>That &#8220;first draft&#8221; PHP (serverside code) supervisor <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.php_GETME\" title=\"argument_to_setTimeout.php\">argument_to_setTimeout.php<\/a> has this <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.php\" title=\"Click picture\">live run<\/a> link, which, bereft of a $_GET[&#8216;trace&#8217;] argument, will execute yesterday&#8217;s <a target=_blank title='argument_to_setTimeout.htm' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.html-GETME'>argument_to_setTimeout.htm<\/a>&#8216;s <a target=_blank title='argument_to_setTimeout.htm' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.html' title='Live run from yesterday'>live run<\/a> link.<\/p>\n<hr>\n<p id='bjsatt'>Previous relevant <a target=_blank title='Binding Javascript setTimeout Arguments Trace Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/binding-javascript-settimeout-arguments-trace-tutorial\/'>Binding Javascript setTimeout Arguments Trace 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\/argument_to_setTimeout.htm\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Binding Javascript setTimeout Arguments Trace Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.gif\" title=\"Binding Javascript setTimeout Arguments Trace Tutorial\"   \/><\/a><p class=\"wp-caption-text\">Binding Javascript setTimeout Arguments Trace Tutorial<\/p><\/div>\n<p>In movies just about everything looks possible with code, and yes, there will be programmers out there that can make a lot of it feasible.  Those debugging, or tracing (or perhaps &#8220;profiling&#8221;) types of scenes would be amusing to a lot of programmers, not so much the type that spurt a lot lot of command line output, but ones that worm their way into the code and <i>trace<\/i> what is being executed.  That is what a debugger is good for, and that debugging software sits on top of what code is being debugged, or traced, if you like.  For some reason, the simplicity of yesterday&#8217;s code, made us think of writing a rudimentary &#8220;tracer&#8221; for it &#8230; and by &#8220;it&#8221; we mean &#8220;it&#8221; <font size=1>not It nor iT nor IT nor I.T. &#8230;<\/font> because, as of &#8220;so far&#8221;, we haven&#8217;t thought of foolproof thoughts to make it generic, yet.  But have not given up thinking on this.<\/p>\n<p>So what we get to today, is to add in a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.js_GETME\" title=\"argument_to_setTimeout.js\">argument_to_setTimeout.js<\/a> helper external Javascript, but it makes us wince at how un-generic it is.  Dumb, you might say, in that all the parent HTML internal Javascript functionality is virtually &#8220;overridden&#8221;.  Nevertheless, as we like to stress here, &#8220;guinea pig&#8221; methodologies are not a thing you should be sheepish about.  From &#8220;guinea pigs&#8221; &#8220;guinea fowl&#8221; are born <font size=1> &#8230; you heard it here first, folks<\/font>!<\/p>\n<p>But, even with the <strike title='No, we cannot hide behind some clever database get and set functionality deriving thoughts'>CRUD<\/strike>crudity of the methodology, it does reiterate Javascript&#8217;s &#8220;overloading&#8221; capabilities, in that our identically names external Javascript functions do &#8220;override&#8221; or (&#8220;overload&#8221;) the internal ones, just with a <i>script<\/i> tag places after the internal Javascript (not even with <i>defer<\/i> nor <i>async<\/i> properties set), and this is news of sorts, to some of us <fot size=1> &#8230; need reminding here, on this, quite a lot<\/font>.<\/p>\n<p>Now, writing this, we can tell you that the Javascript <a target=_blank title='Javascript setTimeout method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_settimeout.asp'><i>setTimeout<\/i><\/a> may be needed to see any <i>tracing<\/i> at all, because, of course, a computer can process lots of lines of code faster than the eye can detect a <i>tracing<\/i> mechanism <font size=1> &#8230; even for Coke subliminal advertisements in your &#8220;movie&#8221;<\/font>.  And so, thinking generically here, the standout places to intervene for &#8220;profiling interest&#8221; (Mission Impossible style) are &#8230;<\/p>\n<ul>\n<li>at lines of code involving <a target=_blank title='Javascript setTimeout method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_settimeout.asp'><i>setTimeout<\/i><\/a> (Batman&#8217;s, and the partner in <font size=1>whatevvvvvvvver<\/font>, Robin&#8217;s) <a target=_blank title='Javascript setInterval method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_setinterval.asp'><i>setInterval<\/i><\/a> timers<\/li>\n<li>at the top of an &#8220;if&#8221; or &#8220;while&#8221; or &#8220;for&#8221; or other looping structure, and one (or more) lines of code into the &#8220;if&#8221; (or &#8220;else if&#8221; etcetera) blocks<\/li>\n<\/ul>\n<p> &#8230; the (coding) statement highlightings stretched out in time, over that setTimeout or setInterval delay (of the code) anyway.<\/p>\n<p>The other aspect to the external Javascript&#8217;s functionality is to follow the advice that would come from reading <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>, and harness the &#8220;talents&#8221; of the HTML <i>div<\/i> element regarding highlighting, converting the original HTML&#8217;s <i>textarea<\/i> &#8220;talent&#8221; for a great way to show a lot of HTML code in a readonly way.<\/p>\n<p>Today, exploring this idea, we&#8217;ve got this very simple counter going, with a trace on, on with a small HTML and Javascript web application, devoid of global variables, and using a <a target=_blank title='Javascript setTimeout method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_settimeout.asp'><i>setTimeout<\/i><\/a> scenario that passes in arguments to the function, using [functionName].<a target=_blank title='Javascript bind method information' href='http:\/\/stackoverflow.com\/questions\/2236747\/use-of-the-javascript-bind-method'>bind()<\/a> methodologies.  It is called <a target=_blank title='argument_to_setTimeout.htm' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.html-GETME'>argument_to_setTimeout.htm<\/a> (and changed in <a target=_blank title='argument_to_setTimeout.htm' href='http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.html-GETME'>this way<\/a>) that you could peruse, or try out via this <a target=_blank title='Click picture' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.htm'>live run<\/a> link, or look below &#8230;<\/p>\n<p><iframe style='width:100%;height:1200px;' src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.htm'><\/iframe><\/p>\n<hr>\n<p id='bjsapt'>Previous relevant <a target=_blank title='Binding Javascript setTimeout Arguments Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/binding-javascript-settimeout-arguments-primer-tutorial\/'>Binding Javascript setTimeout Arguments 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\/argument_to_setTimeout.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Binding Javascript setTimeout Arguments Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.jpg\" title=\"Binding Javascript setTimeout Arguments Primer Tutorial\"   \/><\/a><p class=\"wp-caption-text\">Binding Javascript setTimeout Arguments Primer Tutorial<\/p><\/div>\n<p>At this blog, with Javascript work, we like using <a target=_blank title='Javascript scope of variables discussion at w3schools' href='https:\/\/www.w3schools.com\/js\/js_scope.asp'><i>global<\/i><\/a> variables, in particular the global variables defined at or near the top of (Javascript) scripting, and existant from then on.  However, the use of global variables is not popular in many coding schools I guess because it is less user friendly as far as understanding the code goes, (we guess again) because the initialization of the global variable is likely to occur out of the view of the coding work you are involved in (perhaps) 90% of the time, for any coding of any length, that is (and using your usual text editor screen).<\/p>\n<p>So, what about some discipline regarding reducing (Javascript) global variable usage, and still doing some of those favourite things you like to do, that if you are anything like me, might include (the wonderful, the stupendous, the endlessly <a target=_blank title='Schweppervescence' href='https:\/\/www.youtube.com\/watch?v=Gn52eThyTwQ'>refreshing<\/a> <font size=1>&#8230; sheep grazier&#8217;s alert &#8230; repeated joke &#8230; repeated bubbles <\/font><font size=2>&#8230; see you on the foul line<\/font>) &#8230;<\/p>\n<p><code><br \/>\n<a target=_blank title='Javascript setTimeout method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_settimeout.asp'><i>setTimeout<\/i><\/a><br \/>\n<\/code><\/p>\n<p> &#8230; timer functionality (that&#8217;s Batman, and Robin is <a target=_blank title='Javascript setInterval method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_setinterval.asp'><i>setInterval<\/i><\/a>)?<\/p>\n<p>Well, we did some research on this, and came upon this great advice <a target=_blank title='Useful webpage, thanks' href='http:\/\/stackoverflow.com\/questions\/1190642\/how-can-i-pass-a-parameter-to-a-settimeout-callback'>webpage<\/a>, thanks, that got me onto using (the Javascript method) &#8230;<\/p>\n<p><code><br \/>\n[functionName].<a target=_blank title='Javascript bind method information' href='http:\/\/stackoverflow.com\/questions\/2236747\/use-of-the-javascript-bind-method'>bind()<\/a><br \/>\n<\/code><\/p>\n<p>Today, exploring this idea, we&#8217;ve got this very simple counter going on with a small HTML and Javascript web application, devoid of global variables, and using a <a target=_blank title='Javascript setTimeout method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_settimeout.asp'><i>setTimeout<\/i><\/a> scenario that passes in arguments to the function, using [functionName].<a target=_blank title='Javascript bind method information' href='http:\/\/stackoverflow.com\/questions\/2236747\/use-of-the-javascript-bind-method'>bind()<\/a> methodologies.  It is called <a target=_blank title='argument_to_setTimeout.html' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.html_GETME'>argument_to_setTimeout.html<\/a> that you could peruse, or try out via this <a target=_blank title='Click picture' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/argument_to_setTimeout.html'>live run<\/a> link.<\/p>\n<p>We&#8217;re hoping this might be a piece in a jigsaw of coding issues that helps you out.<\/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='#d28820' onclick='var dv=document.getElementById(\"d28820\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/settimeout\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d28820' 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='#d28862' onclick='var dv=document.getElementById(\"d28862\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/trace\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d28862' 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='#d28897' onclick='var dv=document.getElementById(\"d28897\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/php\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d28897' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday, with Binding Javascript setTimeout Arguments Trace Tutorial we started out &#8220;guinea pig&#8221; fashion, fashioning &#8220;trace&#8221; thoughts regarding client Javascript code tracing. So what is &#8220;PHP&#8221; doing in the blog posting title today, it being synonymous with server code? Well, &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/binding-javascript-settimeout-arguments-php-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":[89,91,183,626,630,725,734,815,932,1020,1021,1032,1200,1265,1319,1369],"class_list":["post-28897","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-app","tag-apple","tag-camera","tag-ios","tag-ipad","tag-mac-os-x","tag-macbook-pro","tag-movie","tag-php","tag-quicktime","tag-quicktime-player","tag-recording","tag-stop-press","tag-textwrangler","tag-tutorial","tag-video"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/28897"}],"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=28897"}],"version-history":[{"count":2,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/28897\/revisions"}],"predecessor-version":[{"id":28964,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/28897\/revisions\/28964"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=28897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=28897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=28897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}