for example title of this article is "The JavaScript Building Blocks: Data Types, Literals, and Variables"
http://www.informit.com/articles/article.aspx?p=169501
What is the means of terms "Building Blocks" in JavaScript? Is it related to box on web-page, CSS box model?
The term "Building Blocks" is just a metaphor for the basic, essential elements needed to create something. It has no meaning specific to javascript.
The article is using it as a means of saying that it is dealing with the most elemental parts of javascript that you'll need to know.
No, it means the basic parts of the language.
It is an English term that means the basic parts of a larger whole (comes from building - where they are made from bricks/blocks).
See the Chambers dictionary, in particular 3 (highlighted):
building block noun 1 a hollow or solid block, larger than a brick, made of concrete or other material. 2 a child's toy, usually a cube made of wood. 3 any of the separate parts out of which something is built.
It's a colloquial/informal way of saying the most basic elements of the language that are needed for most tasks that you might want to do.
Related
Hello,
I'm relatively new to the programming world and I was wondering how I would go about creating the following for a website I'm designing. I will use a random example as to not give my application away, but the process should be the same. I apologize ahead of time for the unrealistic values:
Say a civil engineer wants to come onto my website and figure out the mechanical stress at certain points on the Eiffel tower, lets say on the corner of the first/second observation deck (see Image). To make this more general, they want to vary values such as the height and base width of the tower to see how that affects the mechanical stress at those points.
Now, I can make the algorithm for calculating those stress values. My question is, how would a programmer go about creating this dynamic figure, such that the 'stress values' are shown on the image at distinct locations, and they change based off of the values of the user inputs + algorithm? My thoughts are the following:
Use HTML/CSS to place the images and design the webpage
Use JavaScript to take inputs, run the algorithm and calculate outputs. This would also make the dynamic changes on the image.
I have zero experience with JavaScript (I'm okay with HTML/CSS as I have built my own website before). I guess I'm hoping to be pointed in the right direction before I go off and start learning the wrong language for this application.
Bonus Challenge
While they're doing this, it would be nice to see a visual representation of the Eiffel tower change when the height and base area are changed. ie if you make the base way wider and the height much shorter, the bending in the midsection is going to be much more apparent. Obviously, this means I wouldn't be using a picture, but actually a vector-image model of the Eiffel tower that would change based off of the inputs. So what language and what libraries would one use to go about making this sort of things?
Thank you to anyone that can provide some insight on my issue. I really appreciate it!
Mike
Hello to integrate dynamic graph in a webpage there are two ways;
First you need to make your own graph library. For that you need to know SVG well to make a good looking graph.
Second, you can use any existing library. There are lot of open source libraries are there some of them are free to use also. To integrate graph using those libraries is not much difficult.
Some examples of graph generating library morris chart, c3.js etc. Google search 'll give you more detail idea.
As you said you have no idea about javascript so it will be a bit difficult at first for integrating graph. But 'll definitely much more easy to make your own graph library.
I have just started a school assignment where they want me to detect and recognize objects in a webcam stream, in an webgl application. It will be added to an already existing javascript plugin. It is important that this will be done in real time since the objects will change stuff in the application.
Example, if a user wears a yellow shirt with a specific icon on it will change the layout of the application.
I have researched this a few days now and found some intresting articles.
This seems like an intresting approach:
http://research.ijcaonline.org/volume83/number3/pxc3892575.pdf
And ofcourse the SURF algorithm seems to be a legimate approach:
http://www.vision.ee.ethz.ch/~surf/eccv06.pdf
So my question is "what algortihms might be best to implement?".
And also if possible, which might be easiest to implement? I have quite limited time and this is only one of the objectives for this project.
I appreciate all the help and answers I can get.
edit. Surf is not acceptable because of patents.
Please refer to the HAAR cascade or SURF based classifiers featured in this answer (replace "face" with "any object").
However, you would probably need to train your own classifiers which is not possible within a limited timeframe.
Alternatively, simplify your application and go with simple color tracking.
I'm reading "Javascript, The Good Parts" by Douglas Crockford, and having a difficulty understanding the use of all the railroad diagrams. He also doesn't elaborate much on this. He just says the following (on pg. 21):
The rules for interpreting these diagrams are simple:
You start on the left edge and follow the tracks to the right edge.
As you go, you will encounter literals in ovals, and rules or descriptions in rectangles.
Any sequence that can be made by following the tracks is legal.
Any sequence that cannot be made by following the tracks is not legal.
Railroad diagrams with one bar at each end allow whitespace to be inserted between any pair of tokens. Railroad diagrams with two bars at each end do not.
I am aware that this book is considered to be fundamental read for anyone who's really serious about Javascript, and I would very much like to understand the concepts he's addressing. But something just isn't clicking about the whole railroad diagram thing.
Could anyone explain his use of the railroad diagrams? Examples would be great.
This IBM page probably has the simplest explanation.
The Wikipedia page offers more info in how to construct them.
Railroad diagrams (Syntax diagrams, http://en.wikipedia.org/wiki/Syntax_diagram) are a graphical way to explain a grammar. If all you want to do is understand a railroad diagram, understand that you start at the left, and follow the line (track). And when you encounter a symbol/name, you go follow that track, until it is done, and then come back where you left off.
Also, reading about BNF and EBNF (Extended? Backus-Naur Formalism, http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form) which is a formal way of describing a language grammar, using a set of productions, or rewrite rules. BNF/EBNF work the same as railroad diagrams, but using symbolic notation, the ::= production symbol, and a more formal/mathematical way to document a grammar.
I am also reading this book. It takes me a long time, but finally understand Railroad Diagrams.
First, as #ChuckCottrill mentioned, you should have a basic acknowledge about Syntax Diagrams and BNF/EBNF. But after reading that, it still confused me until I compare three graphs of different situation:
zero or more, zero or one, one or more
To understand their differences (as the following picture shows), the point is
"You start on the left edge and follow the tracks to the right edge."
So imagine you are the train, you just turn right, cannot turn left.
the above picture created by http://bottlecaps.de/rr/
In the "Edit Grammar" tab, input the following grammar:
zeroormore ::= element*
zeroorone ::= element?
oneormore ::= element+
I'm trying to learn how to program a (virtual) Trading Card Game game (similar to Magic the Gathering) in Javascript. I've read a little about MVC architecture and controllers, but it's all over my head (I don't have any formal CS education) and I'm wondering if anyone has any good links or tips about how I might learn more about code architecture at a beginner's level.
Would each "card" be represented as an object, and all the logic of the cards' rules be wrapped inside one large game engine function, or many small functions that are connected to each other?
Here's an example question:
Imagine there's a card which says, "When this card comes into play, draw a card." How should I architect the game to prepare for this situation, and how is it triggered (most efficiently)? Does the card trigger the game engine, or does the game engine parse each card that's played?
Here's another example:
Imagine there's a card which says, "All your cards cost 1 less to play." and it stays in play permanently. How does the game understand that it needs to alter its rules in this case? Is this a function which listens for card to be played and interrupts the cost? As each turn resolves, where is this rule stored? Are there variables which store the base rules of the game (global card cost modifier: 0; your card cost modifier: 0) and other variables which store those new rules which cards introduce (your card cost modifier: -1), or are these variables dynamically created by the game engine as cards alter the rules (your elf cost modifier: -2)? And how do the rules know to change when a card has been destroyed, thus removing the card's rule modification?
Is what I need a primer on listeners and events? (I don't really know anything about them, but I've seen references to them from time to time.) Could you point me in the direction of a good resource?
To be clear, I'm not trying to make a long-winded request for folks to manually Google for me; I'm blindly fumbling in the dark and asking if someone would point me to the right words or phrases to search. Thank you!
There is a very nice blog about recreating a similar card game: Hearthstone from Blizzard. Allthough it is written in C# and uses Unity as a view layer, you get a pretty good understanding of how one goes about creating a suitable architecture for such a game. A fair warning though, recreating Magic the Gathering in Javascript can prove incredibly complicated and mess with your head a lot (I have first hand experience).
Blog: http://theliquidfire.com/2017/08/21/make-a-ccg-intro/
You need to go a level deeper here and think about the "game" itself. The game you're describing will actually be built around a "state machine" which is a core CS concept you should dive into and understand before you start building.
The rules of your game are going to be a state machine and the events (cards) triggered (by being played) during your game can modify those rules. You'll want some kind of interpreter to "read" the card and to modify either the rules or the game state. And then you'll need something to iterate the game through turns and phases, reading the state and taking appropriate action.
You'll also want to learn about stacks. If your game lets players interrupt each other you'll need a way to keep track of which event should happen first because events will want to be able to affect, block, redirect other events. A stack will help you keep track of that ordering.
I have been working on a project that dynamically creates a javascript file using ASP.NET which is called from another site.
This jquery javascript file appends a div and fills it with a rather large HTML segment and in order to do that I need to turn the segment into a string like so:
$(document).ready(function(){
var html = "Giving this magazine such a lofty epithet may seem a bit presumptuous, but for a non scientifically trained outsider this magazine offers a fresh and challenging look at the fast paced world of science that doesn't shy away from humor and the use of terms and ideas that may require its readers to go online and define a term. And in some cases it may inspire the reader to pick up a book on science by such greats as Hawking and Greene in order to better grasp some of the concepts dealing with time, space and atoms. This magazine isn't dumbed down. It includes well placed and efficient illustrations to help explain some of the more abstract points. It is not designed in the way popular magazinea are, in so much as they only touch upon a topic in the simplest manner and then move on before the audience is lost. Yet this magazine keeps the attention of the reader by combining explanatory notes that help people with no background knowledge have some grasp of the topic and by using humor and well written articles to clearly make their points. <br />For a magazine with a serious and well researched list of topics having small cartoons the likes of the New Yorker shows how comfortable this magazine is with itself. From the moment I picked up this magazine for the first time I felt like every word I read mattered and was worth my time to read. (Not true of many other magazines) American Scientist may not have the audience of Discover or National Geographic, nor is it as accessible as said titles, but for those with a true interest in science willing to challenge themselves and commit to real learning this magazine may be a perfect fit. At $4.95 it is certainly worth it to pick a copy on the news stand and try it out."
$("#divname").append(html);
});
As you can see the segment will be pretty large and I have no way of knowing how big as it is generated dynamically from my database depending on the reviewID which is defined by the user in their request.
The html to be inserted into the div is a list of reviews and is generated using asp.net MVC by a repeater which loops through a list. (if that helps give you an idea of what I am doing).
Is there any way to turn this large segment into one string which can be inserted into the append script?
Thank You
Cross domain jquery json
http://docs.jquery.com/Release:jQuery_1.2/Ajax#Cross-Domain_getJSON_.28using_JSONP.29
Some ideas:
You can replace new lines with spaces and create a huge line. There shouldn't be a problem with it.
Use string concatenation. Split the string and lines and do:
var html = line1 +
line2 +
...
linen;
Make an Ajax call to fill the div:
$("#divname").load(service_url);
You need to create a service that will return the string.
In my opinion the 3rd option is better than the other ones.
Correct me if i'm wrong but i think everything between the starting and ending quotation marks would be considered part of that string no matter how many lines it has. Unless your string has got any quotation marks in itself, in which case it'll be better to do the equivalent of php's addslashes() function in ASP on your string, which should add a \ before all the " marks in the string.
Another idea can be to use Json to encode/decode the string.
i don't see what's wrong with just generating one big-ass long single-line string and appending it just like you are doing. period. done. Fancier isn't going to gain you anything.
Hide it else where on the page and populate the div with it when you need it?