Jump to content

iwato

Members
  • Content count

    1,048
  • Joined

  • Last visited

Community Reputation

11 Good

1 Follower

About iwato

  • Rank
    Dedicated Member

Contact Methods

  • AIM
    moogoonghwa
  • Website URL
    http://www.grammarcaptive.com
  • Yahoo
    iddor
  • Skype
    kiusau

Profile Information

  • Gender
    Male
  • Location
    Seattle, Washington USA 98104

Previous Fields

  • Languages
    HTML, CSS, Javascript, PHP, MySQL and Spoken Language

Recent Profile Visitors

14,266 profile views
  1. Matomo: async, defer, and insertBefore()

    JSG: But, you have set aside the very thing that I was trying to understand -- the jQuery ready( ) function. If I have understood this function correctly, it allows the Javascript contained within the function to be read as the rest of the page is being downloaded, but does not permit what is read to be executed until the rest of the page has been completed. My question, then: does the jQuery ready() function also insure that the Javascript thus read and loaded execute in the order that it is entered into the ready function? Roddy
  2. var a = a || [ ];

    Revisiting the Matomo insert <!-- Matomo --> <script type="text/javascript"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//{$PIWIK_URL}/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', {$IDSITE}]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> If what you said is true, then the following statement would be true would it not? STATEMENT: Were the same script to be entered twice on the same page, then the contents of the first completed _paq array would be passed onto the _paq array of the second entry and everything would be counted twice.
  3. Matomo: async, defer, and insertBefore()

    Whether it is true or not, I have understood well what you explained. Under the assumption that what you have stated is true, could it not then be said that the jQuery ready( ) function behaves as if each line of script contained within the function were assigned its own script tag and defer attribute? Roddy
  4. Array cloning

    Ingolme: I do not understand your reply. In the second example. If I change a, so too will b change, because the value of a.slice(0) is determined by the value of a. in the first example. can I not assign a new value to b without affecting the value of a? Roddy
  5. var a = a || [ ];

    BACKGROUND: Earlier I posted a script from Matomo that serves as a counter for page hits and various other bits of information gleaned from a user's behavior on a webpage that bears the script. Although I now understand what the code does, I would like to understand its purpose. In particular, I would like to understand the probable reason for assigning to a variable another variable with the same name. The full code is given as: <!-- Matomo --> <script type="text/javascript"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//{$PIWIK_URL}/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', {$IDSITE}]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> The code of interest is var _paq = _paq || []; I find this piece of code problematic for three reasons: It assumes that this variable could already exist, but I have no idea where it could come from. It it does already exist what happens to the pre-existent with the same name. How does it know which value to choose? Is there a latent selection mechanism that tells the assignment operator to choose the second value when the first is undefined? Please advise. Roddy
  6. Matomo: async, defer, and insertBefore()

    OK. I have read through the MDN reference that you provided regarding the async and defer attributes. Comparing this reference against your statement and my own reflection it appears that Javascript and HTML are treated separately by a browser. This said, if no special action is taken Javascript will always be executed in the moment that it is read along with the other HTML tags in the document. Further, if I have understood correctly, there are three ways to introduce Javascript into a webpage: one, it is executed in the order that it is read along with other HTML tags; two, although read in the order in which it appears amont other HTML tags it need not need be executed at the time it is read; and three, although read in the order in which it appears among other HTML tags, it is not executed until all of the HTML tags have been loaded, and when read, it is read in the order in which it was introduced among the other HTML tags. In other words, 1) Javascript is synchronous when it is executed in the order that it appears along with the other HTML tags. 2) Javascript is asynchronous when the browser is not compelled to execute in the order that it appears among the other HTML tags 3) When the defer attribute is indicated and is assigned the value true, the corresponding script is treated as if it were contained in a jQuery ready() method and not executed until all other HTML tags have been read. QUESTION: Is the above a proper understanding of the relationship between HTML, Javascript, and browser behavior? Roddy
  7. Please find below the Javascript insertion <script> tag that Matomo uses to track user behavior on a webpage. <!-- Matomo --> <script type="text/javascript"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//{$PIWIK_URL}/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', {$IDSITE}]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> I would like to clarify the meaning of the final line of the above function -- namely, g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); QUESTION ONE: Can the script attributes async and defer work indepedently of each another? What is the purpose of each and does their role change when they are imlpemented together? QUESTION TWO: Given the statement s=d.getElementsByTagName('script')[0]; does the statement s.parentNode.insertBefore(g,s); read: "Find the parent node of s and prepend g before s where s is the first node of all script nodes within the document including the node containing this function"?
  8. Understanding Matomo

    Although by no means fully recovered from a recent machine failure, I am back on the road in a much weakened condition. Please consider the following piece of code and correct me where my interpretation of the code is in error. <!-- Matomo --> <script type="text/javascript"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//{$PIWIK_URL}/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', {$IDSITE}]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> My interpretation of same var _paq = _paq || []; _paq is an array that is initialized as empty or some preassigned value. _paq.push(['trackPageView']); Add a new element to _paq whose key-value pair is 'trackPageView' : undefined var u="//{$PIWIK_URL}/"; Create a variable called called u and assign to it the following string "// + some.domain.name + /". _paq.push(['setTrackerUrl', u+'piwik.php']); Add a new element to _paq whose key-value pair is 'setTrackerUrl' and u + piwik.php, respectively. var d=document, g=d.createElement('script'),s=d.getElementsByTagName('script')[0]; Create three variables named d, g and s whose values are d: the DOM document g: the name of a newly created element called 'script' s: an empty index array called 'script' g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); The resulting script tag should appear as follows: <script text='javascript' async='true' defer='true' src= 'u + piwik.js'></script> function()(); Run the function upon loading the document in which it is contained. Roddy
  9. Error 500 - Probable Causes

    The absence of error messages appears to have been created by improper coding errors of the like that creates a blank screen in PHP when you miss a comma, semi-colon, or quotation mark. The past two weeks have been a very painful learning experience for me, as it came just as I am approaching the peak of my first phase of site development. I have staked out a very mountainous range to climb, and it hurt to be so close and unable to reach my first peak on schedule. I unwisely allowed my hope to overshadow my past experience of disappointment, and was brutally frustrated as a result. In any case, a long trek around the first peak has allowed me to regain my strength and upward orientation, and I am back into climbing mode. Thank you, everyone for your effort. I apologize for putting you through my frustration. Hopefully I have learned well from my errors. Roddy
  10. Thank you, Dsonesuk, for your advice regarding a proper approach to take in remedying my problem of digital toilet paper. For the moment, however, I have solved the problem by rethinking how the paper functions in a smartphone environment where most people are likely to view Grammar Captive, anyway. The cost of implementation simply does not match the benefit of outcome at this early stage of development. I must move on toward production, and performance measurement must take priority over site appearance at this time. Roddy
  11. Class Variable Declaration

    Unfortunately, the following did not work. $sql = "SELECT letter_no, letter_title, letter_abstract FROM sevengates_letter WHERE letter_no = ?"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $next_letter_no); $mysqli_stmt->execute(); $result = $mysqli_stmt->get_result(); $return = $result->fetch_all(MYSQLI_ASSOC); I have set it aside, however, for future consideration. I simple have no more time, if I am to meet my spring deadline for the commencement of podcast production. I have only two major tasks left -- both of which I suspect will be far smaller than they appear daunting. Thanks to you and others I now feel confident that I will be able to avoid many of the pitfalls into which I have fallen along the way. Have a great week! Roddy
  12. Class Variable Declaration

    JSG: I have never used the fetch_all( ) method in this context -- only the fetch_assoc( ) method --, and it does not work in the context provided. Roddy
  13. Class Variable Declaration

    JSG: For someone who is always asking for code, you are very reluctant to provide it. A simple example in the context of the class provided would be extremely helpful. Roddy
  14. Class Variable Declaration

    JSG: Please select one of any of the provided class functions that contain "ordinary variables" and show me how you would declare them in the context of the class provided. davej: Why would you make the private and not public?
  15. No access to CSS

    Submit a CSS stylesheet with your work and insure that it is specific to the HTML elements of your document. Roddy
×