Jump to content

Search the Community

Showing results for tags 'object'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 22 results

  1. jsonLikeObj.getFoo.value( ); BACKGROUND: Consider the following object var jsonLikeObj = Object.create( {}, {getFoo: { value: function() { return this.foo = 1; }, enumerable: false } } ); DISCUSSION: Now I could more easily understand the following that does not work, than what does work. What Does Not Work jsonLikeObj.getFoo.value(); What Does Work jsonLikeObj.getFoo(); QUESTION: What is going on? Roddy
  2. 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
  3. BACKGROUND: I recently installed chart.js using npm but had much trouble in do doing and would like now to verify that it is working properly. Accordingly, I ran the following two pieces of code followed by console.log(typeof myChart) in my browser's console. var Chart = require('chart.js'); var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, {}); and var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, {}); only to discover that the results were the same -- namely, object QUESTION: Is this telling me that the require statement is unnecessary, or is it telling me that no matter how you use the new expression it will always produce an object? OBSERVATION: Indeed, when I enter the chart.js sample code, the <canvas> item does not fill with the intended chart. Please advise. Roddy
  4. ACKNOWLEDGMENT and RESULTS: Let me begin by announcing my success in having merged Matomo and wordcount2.js into a dynamically loading word cloud that reflects visitor use of Grammar Captive's local search engines. It is a little slow in loading, but unfortunately everything related to Matomo is slow at this point -- this, despite my recent server upgrade that has sped everything up. If you would like to see the result, simply click on the menu option Word Cloud under Visitor Profile in the navigation bar on the Grammar Captive mainpage. And, now back to Javascript. Thank you everyone for your effort. BACKGROUND: In an effort to distinguish between visitor desire and Grammar Captive's ability to meet this desire, I am seeking to create another word cloud that measures only visitor behavior. The aforementioned word cloud reflects a matching of visitor desire with Grammar Captives ability to match it. It is not a true reflection of visitor desire. In order to achieve this latter I must count not the number of hits that visitors receive when they make a search, rather I must count the number of searches for a particular item. In order to do this I found a function on Stack Overflow that will likely be of help, if only I could understand it. The FUNCTION: function checkDuplicateInObject(propertyName, inputArray) { var seenDuplicate = false, testObject = {}; inputArray.map(function(item) { var itemPropertyName = item[propertyName]; if (itemPropertyName in testObject) { testObject[itemPropertyName].duplicate = true; item.duplicate = true; seenDuplicate = true; } else { testObject[itemPropertyName] = item; delete item.duplicate; } }); return seenDuplicate; } MY QUANDARY: The condition of the above function's if-statement appears to be self-defeating. Still, the function works, for I have tested it with my own data. Specifically, the variable testObject appears to contain an undefined object. It would appear then that the condition of the if-statement would always return false. As this is definitely not the case, I am at a loss as to how to interpret the condition. QUESTION: How is it that testObject can be empty and the condition still return true? Roddy
  5. Hi all, I'm trying to wrap my head around the idea of the window object and the document object relationship. I've read some really good explanations in stackoverflow and others. I have a pretty good grasp of it so I tried an experiment. If the window object opens in the browser, and then the document object opens in the window, then if I change the document, will the window object remain the same. I tried make 2 simple html's - in the first I set a variable like window.myVar = "myValue";. I was able to change the value with a button so it was working fine, and then I used an <a> href to change to a different document. I tried to reference the window.myVar but it came back 'undefined'. If you change documents in a window, does the document always come with a new window, or am I doing something wrong here? Like I said, I've read a lot about the window and document object, but I couldn't see that this was addressed. Thank You for any response....
  6. Cu.import("resource://gre/modules/NewTabUtils.jsm"); var { links: gLinks, allPages: gAllPages, linkChecker: gLinkChecker, pinnedLinks: gPinnedLinks, blockedLinks: gBlockedLinks, gridPrefs: gGridPrefs } = NewTabUtils; and the scipt of NewTabUtils.jsm is /** * Singleton that provides the public API of this JSM. */ this.NewTabUtils = { a_Property_is_here: false, Some_Method_A: function Some_Method_A() { } Some_Method_B: function Some_Method_A() { } And_so_on: function And_so_on() { } links: Links, allPages: AllPages, linkChecker: LinkChecker, pinnedLinks: PinnedLinks, blockedLinks: BlockedLinks, gridPrefs: GridPrefs, placesProvider: PlacesProvider, activityStreamLinks: ActivityStreamLinks, activityStreamProvider: ActivityStreamProvider }; What does the part "var{properties}=NewTabUtils;" mean? I understand if that's "NewTabUtils={properties};" And another minor question is about the second script, in the Class-like JS methods, properties are asigned at bottom of the script, also bottom of the file. I guess that's because it is easy to read, but not sure the reason. Would somebody know these questions? thanks.
  7. <?php /* * DB Class * This class is used for database related (connect, insert, update, and delete) operations * @author CodexWorld.com * @url http://www.codexworld.com * @license http://www.codexworld.com/license */ class DB{ private $dbHost = "..."; private $dbUsername = "..."; private $dbPassword = "..."; private $dbName = "..."; public function __construct(){ if(!$this->db){ // Connect to the database $conn = new mysqli($this->dbHost, $this->dbUsername, $this->dbPassword, $this->dbName); if($conn->connect_error){ die("Failed to connect with MySQL: " . $conn->connect_error); }else{ $this->db = $conn; } } } /* * Returns rows from the database based on the conditions * @param string name of the table * @param array select, where, order_by, limit and return_type conditions */ public function getRows($table,$conditions = array()){ $sql = 'SELECT '; $sql .= array_key_exists("select",$conditions)?$conditions['select']:'*'; $sql .= ' FROM '.$table; if(array_key_exists("where",$conditions)){ $sql .= ' WHERE '; $i = 0; foreach($conditions['where'] as $key => $value){ $pre = ($i > 0)?' AND ':''; $sql .= $pre.$key." = '".$value."'"; $i++; } } if(array_key_exists("order_by",$conditions)){ $sql .= ' ORDER BY '.$conditions['order_by']; } if(array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['start'].','.$conditions['limit']; }elseif(!array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['limit']; } $result = $this->db->query($sql); if(array_key_exists("return_type",$conditions) && $conditions['return_type'] != 'all'){ switch($conditions['return_type']){ case 'count': $data = $result->num_rows; break; case 'single': $data = $result->fetch_assoc(); break; default: $data = ''; } }else{ if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ $data[] = $row; } } } return !empty($data)?$data:false; } } $test = new DB(); if ($test instanceof DB) { echo 'Instantiated'; } else { echo 'Uninstantiated. Include failed.'; } $conditions = []; $tbl_name = 'rss2_podcast_item'; $test->getRows($tbl_name, $conditions); function getRows($mysqli_obj, $table,$conditions = array()){ $sql = 'SELECT '; $sql .= array_key_exists("select",$conditions)?$conditions['select']:'*'; $sql .= ' FROM '.$table; if(array_key_exists("where",$conditions)){ $sql .= ' WHERE '; $i = 0; foreach($conditions['where'] as $key => $value){ $pre = ($i > 0)?' AND ':''; $sql .= $pre.$key." = '".$value."'"; $i++; } } if(array_key_exists("order_by",$conditions)){ $sql .= ' ORDER BY '.$conditions['order_by']; } if(array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['start'].','.$conditions['limit']; }elseif(!array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['limit']; } $result = $mysqli_obj->query($sql); if(array_key_exists("return_type",$conditions) && $conditions['return_type'] != 'all'){ switch($conditions['return_type']){ case 'count': $data = $result->num_rows; break; case 'single': $data = $result->fetch_assoc(); break; default: $data = ''; } }else{ if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ $data[] = $row; } } } return !empty($data)?$data:false; } ?> <?php $tbl_name = 'rss2_podcast_item'; $conditions = []; print_r(getRows($mysqli_obj,$tbl_name,$conditions)); ?> Please find above two sets of code and a quoted error message from the first set. The first set of code is a portion of a PHP class called DB. The second set of code is extracted from the first and modified in order to test the integrity of the function. At the bottom of each block of code is included the code necessary to call the getRows() method/function. Whereas the method of the class fails, the extracted function does not. In both cases the same database and table are accessed with success. I am suspicious of the way in which the class is constructed. I have tried several modifications, but none of them appear to work. Roddy
  8. Having NULL type as an object to be a bug in js, is there any harm to code this could result in, and what precautions should we take to avoid such harm?
  9. Hi, I am learning javaScript and jQuery. In this code, I saw that if I keep the script in the head section it doesn't work.But if I keep the script in the body section it works. Can you please tell me why this happens? Thank you in advance. <!DOCTYPE html> <html> <body> <h3>Your Screen:</h3> <div id="demo"></div> <script> var txt = ""; txt += "<p>Total width/height: " + screen.width + "*" + screen.height + "</p>"; txt += "<p>Available width/height: " + screen.availWidth + "*" + screen.availHeight + "</p>"; txt += "<p>Color depth: " + screen.colorDepth + "</p>"; txt += "<p>Color resolution: " + screen.pixelDepth + "</p>"; document.getElementById("demo").innerHTML = txt; </script> </body> </html>
  10. What is the use of 'window' object? I really didn't understood anything about the window object.
  11. I am attempting to create a drop down menu and I liked the style of the top home menu seen here http://www.lego.com/en-us/products (right near the lego symbol) but I am not sure how to create a similar one would some one gI've me guidance on how I can do this I just started html coding so I am a noon with little knowledge of html right now.
  12. Hello, I'm currently learning JavaScript and I plan to work a lot with arrays. I store all arrays in external files and use JSON to access them. Now I wanted to read the names of all arrays that are nested in one main array to create a navigation list but I don't know how to do that. This is an example of a JSON file I use: {"MainArray":[ {"SubArray1":[{ ... }] }, {"SubArray2":[{ ... }] }, {"SubArray3":[{ ... }] } ]} How do I get the names of all SubArrays? I tried this // arr is a JSON-parsed string function myFunction(arr) { var out = ""; var i; for(i = 0; i < arr.MainArray.length; i++) { out += arr.MainArray[i].toString() + '<br>'; } document.getElementById("aso").innerHTML = out; } but it only creates a list of "[object Object]" items. Should I create another JSON file where all array names are listed instead?
  13. Hi all, Im pretty much a noob to javascript. I try to get how the statements work together. if you have a javascript command like this: document.all.myFile.innerText Then document is an object and so is all myFIle is a variable but what is innerText ? Is that a property or a method? Are there any obligations in writing these commands? like this: object.subobject.property.method? Or are you free to use these through each other?
  14. I used AJAX to retrieve concatenated data from a XML document. Now I need to store that data into a Javascript array. How do I do this? My Javascript Code: var SVG_Data var Retrieved_Data var Coordinate_Pair var Element_List var Counter function Setup() { SVG_Data = new XMLHttpRequest(); SVG_Data.open("GET","http://localhost:8080/exist/rest/db/apps/HTML_Student/Database_Retrieval.xq", true); SVG_Data.onreadystatechange = function () { if (SVG_Data.readyState = 4) { Retrieved_Data = SVG_Data.responseText; document.getElementById("Information").value = Retrieved_Data; Coordinate_Pair = new Array(); Coordinate_Pair.push.apply(Retrieved_Data); Element_List = new Array("Top_Ladder_Line","Middle_Ladder_Line", "Bottom_Ladder_Line"); for (Counter = 0; Counter < 3; Counter++) { document.getElementById("Information").value = Coordinate_Pair[Counter]; document.getElementById(Element_List[Counter]).setAttribute("points", Coordinate_Pair[Counter]);} } } SVG_Data.send(); } The concatenated data I received from the eXist database: "60,30 60,80 150,80 150,30", "60,130 60,80 150,80 150,130", "60,180 60,130 150,130 150,180"
  15. Alright, so I am making a program that when a button that says "yo" for example, will display a prompt when click. If the answer to the prompt is a verb, then the "yo" form of that verb is displayed. So far I have a button, that when clicked has a prompt. When I enter a word in the button I can't make it display the "yo" form of the verb. Please help: Here is my javascript: function verb(verb, yo) { this.verb = verb; this.yo = yo;}//*All verbsvar estar = new verb("estar", "estoy");//*All arraysvar verbs = [estar];//*Verb translation present_yofunction presentYo(){ var verb = verbs; var answer = prompt("Enter a verb: ").toLowerCase(); if (answer == verb){ document.getElementById("translation").innerHTML = "verbs.yo"; } else{ document.getElementById("translation").innerHTML = "I do not know the translation."; } } When I enter a word, all that shows up is "I do not know the translation." Please help. Thanks.
  16. I want to know bereif knowledge about the session storage object in HTML5.
  17. Hi all, I am a beginner in HTML5. I need to play a video using my custom mediaplayer which is residing on the client-side. Mediaplayer is written CPP and Qt. Is there any way I can invoke the mediaplayer from the html 5 page? If object or embed tag is to be used, how do I specify the external application on client-side? How to control the function in javascript? (Video tag support is not provided on my target machine)Please help...
  18. I’m working my way through Javascript Step by Step (Steve Suehring, Microsoft Press) and I’m having difficulty understanding the way the words ‘object’ and ‘property’ are used in the book. In this post I will put verbatim extracts from the book in blue. Things start off simply enough: You can create an object in Javascript in two ways: * Using the new keyword, as shown here: var star = now Object; * Using curly braces, as shown here: var star = {}; The author explains there is no concept of classes in Javascript, but shows how to create objects using pseudo-class constructors: var star = {}; function Star(constell,type,specclass,magnitude) { this.constellation = constell; this.type = type; this.spectralClass = specclass; this.mag = magnitude;} star["Polaris"] = new Star("Ursa Minor","Double/Cepheid","F7",2.0);star["Mizar"] = new Star("Ursa Major","Spectroscopic Binary","A1 V",2.3);star["Aldebaran"] = new Star("Taurus","Irregular Variable","K5 III",0.85);star["Rigel"] = new Star("Orion","Supergiant with Companion","B8 Ia",0.12);star["Castor"] = new Star("Gemini","Multiple/Spectroscopic","A1 V",1.58);star["Albireo"] = new Star("Cygnus","Double","K3 II",3.1);star["Acrux"] = new Star("Crux","Double","B1 IV",0.8);star["Gemma"] = new Star("Corona Borealis","Eclipsing Binary","A0 V",2.23);star["Procyon"] = new Star("Canis Minor","Double","F5 IV",0.38);star["Sirius"] = new Star("Canis Major","Double","A1 V",-1.46);star["Rigil Kentaurus"] = new Star("Centaurus","Double","G2 V",-0.01);star["Deneb"] = new Star("Cygnus","Supergiant","A2 Ia",1.25);star["Vega"] = new Star("Lyra","White Dwarf","A0 V",0.03);star["Altair"] = new Star("Aquila","White Dwarf","A7 V",0.77); The heading he puts on this section is Assembling a star object using a pseudo-class. Note he uses the singular. He doesn’t say ‘Assembling star objects’. The next section is headed Displaying Object Properties and has the following code and explanation: With a for…in loop, you can loop through each of the properties in an object: DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Properties</title> <script type="text/javascript"> var star = {}; function Star(constell,type,specclass,magnitude) { this.constellation = constell; this.type = type; this.spectralClass = specclass; this.mag = magnitude; } star["Polaris"] = new Star("Ursa Minor","Double/Cepheid","F7",2.0); star["Mizar"] = new Star("Ursa Major","Spectroscopic Binary","A1 V",2.3); star["Aldebaran"] = new Star("Taurus","Irregular Variable","K5 III",0.85); star["Rigel"] = new Star("Orion","Supergiant with Companion","B8 Ia",0.12); star["Castor"] = new Star("Gemini","Multiple/Spectroscopic","A1 V",1.58); star["Albireo"] = new Star("Cygnus","Double","K3 II",3.1); star["Acrux"] = new Star("Crux","Double","B1 IV",0.8); star["Gemma"] = new Star("Corona Borealis","Eclipsing Binary","A0 V",2.23); star["Procyon"] = new Star("Canis Minor","Double","F5 IV",0.38); star["Sirius"] = new Star("Canis Major","Double","A1 V",-1.46); star["Rigil Kentaurus"] = new Star("Centaurus","Double","G2 V",-0.01); star["Deneb"] = new Star("Cygnus","Supergiant","A2 Ia",1.25); star["Vega"] = new Star("Lyra","White Dwarf","A0 V",0.03); star["Altair"] = new Star("Aquila","White Dwarf","A7 V",0.77); </script></head><body><script type="text/javascript" > for (var propt in star) { alert(propt); } </script></body></html> View this page in a web browser. You are presented with an alert() dialogue box for each of the stars in the star object, for a total of 14. Here’s an example of the type of dialog box you see: (displays alert box with 'Polaris', followed by 13 more alerts, Mizar through to Altair) This step-by-step builds on the earlier example of using pseudo-classes to define properties of objects. In this case, a star object was created with the following code: var star = {}; That object was then given several properties of individual star names by using a call to create a new Star [sic] object (using the pseudo-class): star["Polaris"] = new Star("Ursa Minor","Double/Cepheid","F7",2.0); Each property of the original star object, in this case the name of each star, was then enumerated within the <body> of the code using a for…in loop: for (var propt in star) { alert(propt); } You might be wondering how to get the actual properties of the stars, such as the constellations, magnitudes, types and spectral class. Chapter 14 shows you how to enumerate through each of these. The bits in bold are what trouble me. Here are my questions: 1. When the block of code above is run, how many objects are created in total? 1, 14 or 15? 2. Would it be right or wrong to call the result a collection of objects (in the sense of a Visual Basic collection)? 3. Is the word preceding my [sic] mark a typo for star, seeing that Star is the name of a function, not an object? 4. When the author refers to the named properties of star (constell, type, specclass, magnitude) as it’s ‘actual properties’ (his last para), is he implying that the star name (e.g. Polaris) is not a true property? Hope someone can clear this up so I can get on to the next chapter!
  19. Hi I am new to web coding and working on a website that incorporate swf. I wrote the code as follows: <object type="application/x-shockwave-flash"codebase="http://www.citizensoldiersupport.org/media/home-gallery.swf"width="574"'>http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0"data="http://www.citizensoldiersupport.org/media/home-gallery.swf"width="574" height="359"><param name="movie"value="http://www.citizensoldiersupport.org/media/home-gallery.swf" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="scale" value="noscale" /><param name="salign" value="lt" /><param name="wmode" value="transparent" /></object> however, the swf is not displaying (just white space in the area where is it supposed to be) Can anyone shed some light on what I'm doing wrong? Also just a side note, I've found many people suggesting the javascript method. But I'm not sure how to upload the objectswf.js into the server I'm working on, is there an .js already available online for use?
  20. I am trying to create my own Image( ); Object. This is how the build in Image function works: var img = new Image(); // Create new img element img.src = 'myImage.png'; // Set source path ctx.drawImage(img,0,0) is going to draw the image loaded from the img.src property. But I don't understand why.. Why am I not required to type: ctx.drawImage(img.src,0,0) ?? In fact, that breaks the script. Saying Type Error Please help me out here, I want to create my own "new Image()" with custom properties and methods..
  21. Hi all,Forgive me if this is the worng place for this.I have a webserver running a stream of audio files in a folder on my server on port 8080I can access the streaming audio using a media player like vlc. The server has http, and php.What I want to do is have a visual player object, where if you visited my site you could listen into my stream by clicking on the embeded media player. I Tried the examples, from http://www.w3schools...html_sounds.aspbut I dont know how to use the code to specify the ip and port where I am streaming from. <embed height="100" width="100" src="130.111.192.142:8080" /><object height="100" width="100" data="130.111.192.142:8080"></object> Things like that, just dont work. What am i doing wrong? How can I embed a way to play the audio I am already streaming on my server?
  22. if (object.focused = true) {// do something} Is there a way to check if an element is focused in JavaScript?
×
×
  • Create New...