Jump to content

iwato

Members
  • Content Count

    1,506
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. Dsonesuk. It makes no difference how the viewbox width and height values are set; the result is both similar and different. Important is that the map image does not properly fill its container until the visitor as scrolled. I had tried fixing the value as you suggested earlier, but did not tell. My apologies. By the way, I have now tested it on another, non-Apple iPhone. The problem is the same. I conclude therefore that the issues lies with the Javascript. If I have understood the problem correctly. the onResize callback function of the object created by the JQVMaps vectorMap() function responds only responds to container resizing triggered by changes in the browser itself, not the viewport per se. I have concluded this for two reasons: one, the behavior is excellent in my FireFox browser on my MacBook without any scrolling; and two, when using the viewbox attribute, both the horizontal and vertical positions of a smartphone viewport require scrolling -- visitor induced, direct browser interaction. Do you agree with this assessment? Roddy
  2. Oops! Thank you for the correction. I have been away from jQuery for several months ... Ha! Ha! Ha! In any case it makes no difference. Proper alignment only takes place with an iPhone scroll. I have not tested it on Android. onResize: function() { var containerWidth = $(this).parent().width(), containerHeight = (containerWidth * (2/3)); console.log('Parent: ' + $(this).parent().attr('id')); $(this).css({ 'width': containerWidth, 'height': containerHeight }).find('svg').attr('viewbox', "0 0 " + containerWidth + " " + containerHeight); console.log('Map Size: ' + containerWidth + 'x' + containerHeight); }, Here is the link. In the navigation bar look for Visitor Profile / World Map. Roddy
  3. So, I tried this the following. onResize: function() { var containerWidth = $(this).parent().width(), containerHeight = (containerWidth * (2/3)); console.log('Parent: ' + $(this).parent().attr('id')); $(this).css({ 'width': containerWidth, 'height': containerHeight }).find('svg').css('viewbox', "0 0 " + containerWidth + " " + containerHeight); console.log('Map Size: ' + containerWidth + 'x' + containerHeight); } RESULT: It had no effect on my browser responsiveness (a good thing), but it worsened the iPhone experience (bad thing). In any case, it did not solve the problem. In the vertical iPhone position the map is now too large (before it was just right), and in the horizontal position the map is too small (just as before). Upon scrolling both images fill the container div properly. Any more suggestions? Roddy
  4. Hi, Dsonesuk! Truly I do not understand how I could incorporate what you are suggesting in the context of the problem. Surely you understand that the HTML that hosts the SVG object is pulled into an already formatted HTML page with AJAX in the form of a set of nested div tags that have their own style sheet and no document heading. Roddy
  5. The problem appears to be that the a change in the size of the viewport is not automatically registered as a change in the size of container. Once the page is scrolled the map fills the viewport and container as it should. Roddy
  6. I have never used console.log on an iPhone before and have no idea where to look for such information. Else, I would have looked long ago. Roddy
  7. Hi Dsonesuk! It appears not to make a difference. The width(), innerWidth(), and outerWidth() functions all yield the same result on the iPhone. What is unusual is both the placement and size of the map when the iPhone is placed on its side. For, rather than filling the center of the viewport, as it does when the iPhone is vertically positioned, it appears in the upper left-hand corner and retains the size that it had when the iPhone was horizontal. Roddy
  8. Thank you, Ingolme! Almost there. $('#vmap').vectorMap({ map: 'world_en', enableZoom: true, showTooltip: true, onResize: function() { var containerWidth = $(this).parent().width(), containerHeight = (containerWidth * (2/3)); $(this).css({ 'width': containerWidth, 'height': containerHeight }).find('svg').css({ 'width': containerWidth, 'height': containerHeight }); console.log('Map Size: ' + containerWidth + 'x' + containerHeight); } }); The above works well in a Firefox browser, but only partially on my iPhone. Any more suggestions? Roddy
  9. SoOK. So, I added the following onResize() function, but the error message remains the same and there is no change in the imagery. $('#vmap').vectorMap({ map: 'world_en', enableZoom: true, showTooltip: true, onResize: function() { var containerWidth = $('#wm_container').width, containerHeight = (containerWidth / 1.4); $(this).find('svg').css({ 'width': containerWidth, 'height': containerHeight }); console.log('Map Size: ' + containerWidth + 'x' + containerHeight); } }); Roddy
  10. Hello, JSG. Please read my note to Dsonesuk. In regard to the console.log() statement (see below) you would agree then, that the onResize() function provided as an option to the vectorMap() function is unnecessary to the resizing of the document. For, all it appears to do is tell the user what the result of the resize is, when, and if, it actually worked. onResize: function (element, width, height) { console.log('Map Size: ' + width + 'x' + height); } Roddy
  11. Hi, Dsonesuk. When I enter values other than 100% and auto for the height and width into the <div> tag that identifies the location of the map on the webpage, the map appears, but it is no longer responsive. It seems that I can have the map without responsive design, or responsive design without the map. This is the problem. Roddy
  12. BACKGROUND: I am introducing a new jQuery plug-in into my website, but it enters without any height -- this despite the fact that the width of the SVG object is fully responsive. You can see the problem on the Grammar Captive mainpage by clicking in the navigation bar under Visitor Profile / World Map. WEB INSPECTOR RESULTS: <div style="position: relative; overflow: hidden; background-color: rgb(165, 191, 221);" id="vmap"> <svg height="0" width="513"><g transform="scale(0) translate(Infinity, 0)"> <path class="jqvmap-region" id="jqvmap1_id" original="#f4f3f0" fill="#f4f3f0" stroke-opacity="0.25" stroke-linejoin="round" stroke-linecap="round" stroke-width="1" stroke="#818181" d="..."></path> <path class="jqvmap-region" id="jqvmap1_pg" original="#f4f3f0" fill="#f4f3f0" stroke-opacity="0.25" stroke-linejoin="round" stroke-linecap="round" stroke-width="1" stroke="#818181" d="..."></path> . . . <path class="jqvmap-region" id="jqvmap1_gr" original="#f4f3f0" fill="#f4f3f0" stroke-opacity="0.25" stroke-linejoin="round" stroke-linecap="round" stroke-width="1" stroke="#818181" d="..."></path></g> </svg> <div class="jqvmap-zoomin">+</div> <div class="jqvmap-zoomout">−</div> </div> PROPOSED STRATEGY Target the height and scale attributes of the SVG object with some jQuery. For some reason I believe that there is a more civil less intrusive way to fix the problem. Simply after several hours of experimentation I have run out of ideas. QUESTION: Can you provide a likely explanation as to why the scale attribute is registering as zero? Can you come up with a solution. SPECIAL REQUEST: If you could explain the following line of code console.log('Map Size: ' + width + 'x' + height); in https://www.grammarcaptive.com/_utilities/javascript/worldmap_filler.js it would be greatly appreciated. HINT: https://github.com/10bestdesign/jqvmap/blob/master/examples/responsive.html As always, you are the rising sun on my horizon of relentless frustration, Roddy
  13. So, why is it that the dateCounter() function only returns one name-value pair in a single object, if the initial empty object is left out? The empty object appears to induce recursion, but I do not understand why. Roddy
  14. OK. you have adequately explained the following line of code. countDates[date] = ++countDates[date] || 1; Can you now explain this line of code. (countDates, date) => {...; return countDates;},{}) The result set, by the way, appears to be an object of name-value pairs which is exactly what I was hoping for when I introduced the function into my code. Object { 2019/01/01: 2, 2019/01/03: 4, 2019/01/04: 2, 2019/01/05: 2, 2019/01/06: 1, 2019/01/07: 2, 2019/01/09: 6, 2019/01/11: 1, 2019/01/18: 3, 2019/01/20: 2, 60 more… } Roddy
  15. BACKGROUND: Recently I discovered a nifty Javascript function that counts the like values of an index array and returns as its value an object whose property-value pairs consist of a single repeated value and its corresponding frequency. Unfortunately, I am having trouble understanding how the function works. As I have adapted it to fit my own needs I have changed the variable names. Indeed, this change may be the source of my own confusion. The FUNCTION: function dateCounter(dates) { return dates.reduce( (countDates, date) => { countDates[date] = ++countDates[date] || 1; return countDates; }, {} ); } REQUEST: Please write in plain English what the so-called reducer function of the reduce( ) function is achieving with each iteration. I am baffled. Roddy
  16. If you like my suggestion, pass your cursor over the heart and select the trophy. Roddy
  17. I suppose that the conclusion to this discussion is that anything sent via an HTTP request is vulnerable and that one should protect one's MySQL database from potential threats with the use of prepared statements. This said, I am confused about their use. Is it sufficient to prepare and bind a statement only once, and then execute the prepared and bound statement with fresh data as many times as one wants? Roddy
  18. Have you tried tipue? Roddy
  19. Hi, JSG! Understood. Thank you. Access to neither the local Matomo server, nor the local Grammar Captive database is direct. The Matomo server is located in one domain and the PHP class documents and PHP data fetch, translation, and storage code document are located in another domain on the same server. The Matomo server is accessed using a cURL routine and Matomo authentication key. The translated data is stored in data tables that are accessed with two MySQLi objects constructed with two separate SQL queries using password authentication. In brief, both the Matomo API and the GC datatables are accesses with HTTP requests. Once again, the Matomo database from which the Matomo server fetches its data and the GC database to which the data is ultimately stored are located on the same server. Roddy
  20. BACKGROUND: As always I am concerned about security on the one hand, but do not wish to over-code on the other. In the following outlined procedure the data is fetched from the super secure, vast thicket of layered PHP and sent after translation THE PROCEDURE: Create two MySQL tables linked with a foreign key. Make a method call to the Matomo API and retrieve a four tiered nested array containing two tiers of visitor data. The first tier consists of an indexed array whose 100 elements each corresponds to a single visit to the Grammar Captive website. The second tier consists of an associative array, one for each of the 100 elements of the first tier. The third tier consists of an indexed array of varying length corresponding to one of the elements of each of the second tier arrays. Each element of this third tier array contains an associative array of varying length whose elements correspond to different actions and/or events associated with the respective visit. The fourth tier contains the data for each recorded action or event. Generate two classes: one for the visit data (2nd tier), and one for the action/event data (4th tier). Translate the keys of the key-value pairs of the two aforementioned tiers so that their values can be properly inserted into either of the two data tables. Insert the translated data into the two data tables via two separate objects created from the two classes. With the exception of the creation of the data tables Steps 1-5 are all performed within the context of the same PHP document. QUESTION: Do you see any security risk in the above? Roddy
  21. Hi, Funce! Thank you for your quick response. It was you who gave me the idea of creating a data table. And, now I have two: one for each visit and one for all of the actions and events associated with each visit. Hooray! Hooray! In regard to the TranslateMatomoAction class I understand now clearly about the __contructor() function. I was trying to make it do something that it was not intended to do. This said, I was unable to get the __invoke() function to work as you suggested. So, I moved the contents of the __constructor() function outside of the class and changed the variable names. My object is now fully complemented with the desired information is ready for MySQL insertion. Many thanks! Roddy
  22. BACKGROUND: Many moons ago it was suggested that I create a CRON job that would read into a MySQL table the results of a method call to a Matomo API call and thereby speed up the rendering of data for visitors to the Grammar Captive website. I have since come to learn that this technique is called data translation. The following code creates a class object that when inserted into a foreach loop is suppose to fill the properties of the object for further manipulation. Unfortunately it does perform the intended task. THE CLASS class TranslateMatomoAction { public $mysqli_obj; public $visitID; public $type; public $serverTimePretty; public $timestamp; public $url; public $generationTime; public $pageTitle; public $pageID; public $pageView_ID; public $pageID_Action; public $timeSpent; public $eventCategory; public $eventAction; public $eventName; public function __construct($property, $value) { if ($property === 'type') { $this->type = $value; } else if ($property === 'serverTimePretty') { $this->serverTimePretty = $value; } else if ($property === 'timestamp') { $this->timestamp = $value; } else if ($property === 'url') { $this->url = $value; } else if ($property === 'generationTimeMilliseconds') { $this->generationTime = $value; } else if ($property === 'pageTitle') { $this->pageTitle = $value; } else if ($property === 'pageId') { $this->pageID = $value; } else if ($property === 'idpageview') { $this->pageView_ID = $value; } else if ($property === 'pageIdAction') { $this->pageID_Action = $value; } else if ($property === 'timeSpent') { $this->timeSpent = $value; } else if ($property === 'eventCategory') { $this->eventCategory = $value; } else if ($property === 'eventAction') { $this->eventAction = $value; } else if ($property === 'eventName') { $this->eventName = $value; } } public function set_visitID($visitID) { $this->visitID = $visitID; } public function set_mysqli_obj($mysqli_obj) { $this->visitID = $visitID; } } THE INSERTED CLASS AND ASSOCIATED CODE if (is_array($value1) && ($key1 === 'actionDetails')) { foreach($value1 as $key2 => $value2) { //LEVEL 2 - This foreach statement traverses the set of indexed arrays whose elements are a key-value pair of indices and arrays. Each array is a value of the actionDetails element of a visit. if (is_array($value2)) { $matomo_action = new TranslateMatomoAction($key3,$value3); foreach($value2 as $key3 => $value3) { //LEVEL 3 - This foreach statement traverses the elements of the associative array corresponding to the value of $key2. $matomo_action($key3, $value); } } } } DILEMMA: Unfortunately, the above procedure fails to fill the values of the object's property as expected. QUESTION: Where have I gone wrong? Roddy
  23. So, in the end, the table was corrupted, and I had no back up. Alas, I reconstructed the entire table with UTF-8 encoding. The result was nothing but spectacular. I now have an in-tact Mecab parser that parses Japanese. Not only this, but the Mecab parser does not interfere with the parsing of French, English, and German., or likely any other language that using blank spaces to separate words. Arabic will be my next challenge, but I am fairly confident that it will work just like English with no additional encoding required. Roccy
  24. Thank you, JSG. I do not know a thing about C, let alone the argv and argc parameter. This said, I can well imagine. No, no, no. I am not eager to learn still another computing language! I am having enough trouble with the ones, that I have already attempted. It has never been my goal to become an online developer. It just sort of happened out of curiosity and in self-defense. Roddy p.s. Great Link!
  25. Yes, your link is the same that caused me to ask the question. I will explore a little further with the idea of looking for a command. Thank you for responding. Roddy
×
×
  • Create New...