Tag Info

New answers tagged

1

Well, the client-side is still served from the application server, isn't it? So basically what you need is ability to provide some parameters to it. Obviously you'll need to substitute the server URL. Most look can be modified just by loading appropriate style sheets (CSS), which is just another replaced URL. And one more replaced URL can give you ...


0

Someone needs to build a jQuery path manager interface for an indirection and cache layer to the dom. pathMgr.register(name,selector [,isDynamic=false]); pathMgr.get(name [,refresh]); Then, String.prototype.reg([isDynamic=false]); String.prototype.get(name [,refresh]); So, // at init.... var pathMgr=new PathMgr(); 'sidebar-links #sidebar a'.reg();// ...


0

Statics belong on the Function IMO, in your case you have a private static, so ... Panes._createPane=function(pane){}


1

Here is what you've done wrong already -- you have hand-rolled an MVC while in a state of confusion, and without any MVC under your belt. Take a look at PureMVC, it is language agnostic and can be a good platform to get your feet wet with actually doing MVC. Its code is small and comprehensible, and this will allow you to tweak it to your needs as you ...


1

I suspect your question is academic, or formal, so you might not be satisfied with my solution which is a practical one. When you think about it, what you have is a LogConcernedWithFrogRibbits ultimately. The best way I have found to quickly decouple things is through an MVC (like PureMVC for example) which is the 'complex solution' or just go with a ...


-1

If I've understood your question correctly then simply yes... Of course. If you're building the mobile apps separately you can of course just connect to a backend API that you've created on a server. The server is completely independent of the app itself so it doesn't matter from where it's called. Think of any app the has a release on multiple OS's but ...


2

I recently discovered Intercom, which uses local storage to implement broadcast messaging between windows. Local storage fires an event (onstorage) when data changes, so no polling is necessary. Intercom allows all pages on a domain to communicate, regardless of how they were opened.


17

Writing code is only a part of the interview process. Actually solving the logical problem is only a part of the code writing task. Interviewers want to be sure that: You can write code. Many candidates with ten years professional experience in a language can't write any code at all, and this test is intended to reject those candidates. You think about a ...


1

You cannot use HTML and AJAX on its own to access your databases or data stored on remote/hosting server. You will need a server side scripting language PHP, ASP, PERL, CGI, etc. HTML and AJAX run on the "client side", the computer accessing the web page. The server side languages run on the "server". HTML can invoike AJAX to access a server side script ...


3

Login using AJAX, jQuery and PHP: http://stackoverflow.com/questions/14449118/php-ajax-login Personally I think PHP is barbaric. The only acceptable use is if you're using a framework like CakePHP or Laravel. My preference is Django Python or Node.js. But there is no disadvantage to which backend you use. Each language has its strengths and can perform ...


0

To 1: I know that Xamarin has a proprietary way based on their implementation of .NET. You can use one language to build the common application backend and there are wrappers for the native libraries. They share the philosophy of building the GUI with the native libraries. It is not javascript though.


0

Well, if you need to find something in your associative array, you need to iterate through each of the keys, and find equality. This means that in the worst case, you'll need to iterate through your whole collection to find the good key. Accessing an array with an index (myArray[0] for example) is instant; it doesn't require any searching, because the ...


3

Because you still need a way to search the associative array. The hash table is your search mechanism; it gives you O(1) performance for any given key search. What is your underlying search mechanism, if it's not a hash table? A Binary Search Tree? That's good for very large tables, but it's not O(1); it's O(log n). If you don't have a search ...


0

The only possible downsides to bundling all of your JS into one file that I can think of are: Some of the your files may not "play well" together. Eg if one file is missing a semicolon at the end then bundling another file onto the end might break things. This has happened to me more than once. Some files might depend on being in a particular path, and ...


0

Depending on the size of the application, it might be worthwhile to modify your app to use modules with an AMD loader, such as RequireJS. By moving your code into separate modules and letting an AMD loader manage the dependencies, your code should become more organized and prevent the issue of you having to manually load files. You can use this for files ...


1

Constants do serve a error-checking function in statically-typed languages, but they also serve a second purpose. They centralize information into one place. This is not lost when we move to JavaScript. Imagine that your example looks more like this, config.js: CompanyAPI.constants.ENROLL_URL = "/rest/enroll"; CompanyAPI.constants.FIRST_NAME = ...


0

Ignoring licensing, it is generally preferable to provide at least one version of your script that includes none of its external dependencies. Some libraries include a wide variety of wrappers and bundles (e.g., HistoryJS) to make things easier on their users. Complicated sites may or may not already include dependencies (and not necessarily the same ...


3

Just like learning another language, one shouldn't compare it to his/her mother tongue. Some Languages often have concepts that are not found in others. We simply learn to accept them. Constants in Java, C# and C++ do not exist in binary code. These constants were invented to help programmers and compilers. As this answer ...


-1

There are two important factors you did not mention. Do you want to retain copyright for future benefit to you, or is this purely community? Do you want to make money out of this, or will you compete with someone who does? The basic breakdown is this. If you make no money out of it and harm no-one then just do your best, acknowledge the work of others ...


1

How should I best handle these dependencies without violating the license? If you would packaging your dependency modules, you should only ensure to mantain the MIT requirements The MIT License is a free software license originating at the Massachusetts Institute of Technology (MIT). It is a permissive free software license, meaning that it ...


1

If you want to call server-side logic from the client, you will have to make an HTTP (or other) request -- this can not be avoided. From what I understand as I read your question, an AJAX request may be what you're looking for. See: http://www.w3schools.com/ajax/ajax_intro.asp If you're using jQuery: http://api.jquery.com/jquery.ajax/


2

Most of the answers centre on JavaScript code in the web browser. If you're interested in server-side JavaScript code (or more generally, JavaScript code in non-browser environments), then you've got a couple of other options: Node.js is currently the most popular server-side JavaScript framework and comes with an interactive console. Once you've installed ...


0

Jetbrains Webstorm is an IDE you can use as well, if that's the sort of thing you're looking into. Otherwise, there's probably an eclipse plugin. There's also Sublime Text and Atom, that, with a few plugins, can do it very well.


1

As for actual IDE's, you could use Visual Studio (express version is free). They've added better JS intellisense support in the past few releases.


0

Now that my understanding has broadened a bit, I'd like to build on Esailija's answer with a specific example: One specific concern is that a constructor can set instance-specific properties. Thus, if you use a prototype object created with new, all your child instances could share a single constructor-defined instance-specific property from the prototype. ...


3

Mainstream browsers’ dev tools have a console for executing expressions: Evaluating Expressions in Google Chrome. The Internet Explorer F12 tools console. The Firefox Console. See also Plunker. It is similar to the already mentioned jsFiddle.


13

I find http://jsfiddle.net/ to be a good test environment for trying things out (in JavaScript, HTML and CSS), if you just want to try something easily and now using your browser.


14

Any of the major browsers (IE, FireFox, Chrome, Safari, etc..) will execute and display the results of JavaScript code that you put into it. You can open the developer console in Chrome and in IE using F12 and in Firefox using Ctrl+Shift+K. Alternatively you can simply put it into a .html file.


1

By doing this, you actually are reducing both the readability and the extent to which the plugin can be minified. Let's take your example of your HTML string by getting a HTML file with some <div> tags. Running some sample code through a minifier, we get 380 bytes before gzip for the first one:174 var ...


2

You are right that Class attributes [were originally] meant for CSS, but that doesn't necessarily mean that you cannot also use them as JavaScript hooks. (But some care is required.) According to the HTML4 spec, The class attribute has several roles in HTML: * As a style sheet selector (when an author wishes to assign style information to a set of ...


0

Note: This question may be better suited to Stack Overflow rather than programmers. I would use the .dataset(MDN) to store local IDs. I would access them using element.querySelector(MDN). Example[1]: <widget id="AwesomeWidget"> <div data-ID="Sidebar"></div> <div data-ID="Toolbar"></div> </widget> and I would ...


1

You first and third assumptions are solid. You middle assumption "class attributes are meant for CSS and should not be used in JS selectors" is completely, utterly wrong. Granted, there's some structural / separation-of-concerns purity about it. But it rejects the reality and common practice of almost all dynamic JavaScript modification of HTML documents. ...


2

Combine the two ID's together, as in ID="WidgetID_RelativeID" This will guarantee uniqueness.


3

If you are trying to find a path through an array of terrain squares, or else a path through a connected set of nodes, then breadth-first or depth-first traversal work well. (One trick to limit the size of the traversal to do a breadth-first search, but start a traversal at both the start point and the end point, and stop at the first cell that both have ...


4

Dijkstra's Algorithm You could apply the algorithm that A* is based on: Dijkstra's algorithm with the assumption that travel to each neighboring node is equal. This will still give you the shortest path (or paths as your network may vary) However you might still view this as overkill (since you make no mention of shortest path, only of linear) Implement ...


5

It's hard to tell exactly what you're asking, so this answer is aimed at providing more context about monads. Some preliminaries about monads: Crockford's monad talk is a poor source for learning about monads (I hate to say this because he's so much smarter than me, and therefore probably understand monads better than I do, but IMHO it gives an inaccurate ...


0

Your question might be better placed on gamedev, but if you aren't worried about terrain and/or walls, then what you want is not a path-finding algorithm. The difference between the two points (or vectors) is the "step" required to get from point A to point B instantly. You therefore simply need to divide the difference, using some amount, to determine the ...


2

If code were perfect, there would be no need for documentation because it is simple and straightforward, hence there would be no need to optimize for anything other than performance. However, code is not perfect, and if you're like me, you'll have passed several days pulling your hair out trying to resolve a silly issue with a javascript library. I think ...


0

I’ve got it. The expression: if(undefined > 9) typecasts undefined as a number: in this case it is NaN. NaN is the only value in JavaScript which doesn’t equal anything, including itself. As a result it is neither less than nor greater than another number, so the test is always false. So, it’s not the undefined value as such, but its conversion it ...


0

Forget about the database, think in your domain and build a model, if you are working with a Object Oriented language think in objects that model your problem, for example, creation of a new voting period: def myVotingSystem = new VotingSystem() def oneStory = new Story("one") def secondStory = new Story("second") def oneDayVotingPeriod = new ...


2

It’s certainly something that’s considered in every standard, but I would say that yes, a more comprehensive standard library is a focus of ES6; comparing it to the changes in every other revision of JavaScript (which have, for the most part, added functions to existing types), you’ll notice that it’s… a lot more. No, the changes are not contingent on ...


2

It depends. Unless client-side performance is an observable concern, focus on maintainability. That means you ideally want the translation from data to markup/DOM to be consolidated. You don't want two or three different objects, especially sitting in two or three different languages, that are each responsible for producing the same DOM structure. If your ...


4

For those who are looking for the quick answer Avoiding writing anything that modifies the JS DOM is always good practice, unless you have a good handle on exactly what is or is not going into the page, your likely going to run into a lot of trouble. If you want the longer answer, keep reading Unless your code and html is encapsulated in the new web ...


4

Every time you make a code change that touches your serialization, you must add a new test case in your automated test suite that uses the new fields, or reads the old fields, etc. Over time you'll accumulate more and more coverage for your version transitions. As long as you run your test suite whenever you make changes you'll get notified when you stop ...


4

How do I automate something (possibly a test) that tells me when I need to write a migration script and when I need to change the data's version number? When your automated unit tests fail while importing old data into a newer model, that's one very clear indicator that you need to write a migration script/process.


2

This is essentially a dependency injection framework. They are very commonly used in server-side development. Spring and Guice are two frameworks used in the Java world. Grails uses a similar convention as you have defined, specifically injecting ovjects Dependency injection supports the Inversion of Control principle. This is important for modularity and ...


3

This is not just for functions - this is how JavaScript generally deals with assignments. When you use the var keyword, the variable is assigned at the current scope. When you don't use it, the variable is assigned at the global scope(the window object in browsers). That means that gSetNumber = ... is the same as window.gSetNumber = ...(assuming the code is ...


0

If your table contains small amount of data (and will always contain small amount) then of course you can filter in JavaScript. This is true, for example, if you always select from DB only one "page" of data (LIMIT 10,20). But in real application you want to LIMIT and FILTER the same time as user wants to see filtered results but only 10 of them at once. He ...


0

Treat Web services the same as any other data access: To approach client side MVC architecture, without frameworks, we treated Web services in the same manner as we did localStorage and the local IndexedDB database. All code that involves requests to remote servers or that query a database or that read/write to localStorage happen in the model layer as DAO ...



Top 50 recent answers are included