Search Results

Search found 23794 results on 952 pages for 'serverside javascript'.

Page 14/952 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Javascript Rookie Question: Define Variables Inline

    - by Dylan Kinnett
    I'm proficient with HTML and CSS but I'm still pretty shaky when it comes to Javascript. That said, I've been able to build a site using the Internet Archive Book Reader, which relies on reader.js Here's a copy of one of my versions of reader.js https://gist.github.com/dylan-k/ed4efed2384e221d46cc It's a good site, but I find I have to repeat things a lot. Basically, I have one copy of reader.js for every page/book featured on the site. It seems there must be a better way. I re-use the script, making copies, just so that I can change lines 28, 80, 83, 84. Is there a way I could include just one copy of reader.js and then use a <script> tag to define these 4 lines for the individual pages?

    Read the article

  • Strange javascript error when using Kongregates API

    - by Phil
    In the hopes of finding a fellow unity3d developer also aiming for the Kongregate contest.. I've implemented the Kongregate API and can see that the game receives a call with my username and presents it ingame. I'm using Application.ExternalCall("kongregate.stats.submit",type,amount); where type is a string "Best Score" and amount is an int (1000 or something). This is the error I'm getting: You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround. callASFunction:function(a,b){if(FABrid...tion, can be used as a workaround."); I'm wondering, has anyone else had this error or am I somehow doing something stupid? Thanks!

    Read the article

  • Unity 3D coding language, C# or JavaScript [on hold]

    - by hemantchhabra
    Hello to the gaming community. I am a budding game designer, learning to code for the first time in my life. I did learned c++ in school, 8 years back, so I sort of understand the logic when people are doing coding and I can suggest them the right route also, but to an extent I can't code. I am beginning to learn coding for Unity 3D. Which one do you suggest is more versatile and easier to work on for future, because I am a game designer not a coder, I would do coding until I don't have anyone else to code for me. It should be easy and fast to learn, functional and universal to apply, and innovative at the same time. C# or JavaScript ? Thank you for your time Ps- if you could suggest me steps to learn and tutorials to look for, that would be just awesome.

    Read the article

  • Good resources for JavaScript 2D game programming?

    - by DJCouchyCouch
    As an exercise, I've decided to look into JavaScript for game programming. While it's far from being the best language for that, I do like the idea that it's cross-platform and it's always available as a web page. So I thought I'd see what I could do with it. Specifically, I'd like to make a 2D tile-based game of some kind. Where can I find resources to do that? I'm sure this question's come up before, but I can't find any reference to it.

    Read the article

  • Play audio in javascript with a good performance

    - by João
    I'm developing a browser game where the player can shoot. Everytime he shoots it play a sound. Currently i'm using this code to play sounds in JavaScript: var audio = document.createElement("audio"); audio.src = "my_sound.mp3"; audio.play(); I'm worried about performance here. Will 10 simultaneous sounds impact my game performance too much? Will all audio objects stay in memory even after they are played?

    Read the article

  • Recommended Reading for Polishing JavaScript coding style?

    - by wml653
    I've been coding in JavaScript for a while now and am fairly familiar with some of the more advanced coding features of the language (closures, self-executing functions, etc). So my question is, what advanced books/blogs/or anything else would be recommended to help tighten up my coding style? For example, recently I was coding something similar to: var x = ['a', 'b', 'c']; var exists = false; for(var i = 0; i < x.length; i++){ exists = x[i] === 'b' ? true : exists; } But found that the following condensed code would work better: var y = {'a':'', 'b':'', 'c':''}; var exists = 'b' in y; Both store the same value in 'exists', but the second is less common, but much cleaner. Any suggestions for where I should go to learn more tricks like this?

    Read the article

  • Referencing external javascript vs. hosting my own copy

    - by Mr. Jefferson
    Say I have a web app that uses jQuery. Is it better practice to host the necessary javascript files on my own servers along with my website files, or to reference them on jQuery's CDN (example: http://code.jquery.com/jquery-1.7.1.min.js)? I can see pros for both sides: If it's on my servers, that's one less external dependency; if jQuery went down or changed their hosting structure or something like that, then my app breaks. But I feel like that won't happen often; there must be lots of small-time sites doing this, and the jQuery team will want to avoid breaking them. If it's on my servers, that's one less external reference that someone could call a security issue If it's referenced externally, then I don't have to worry about the bandwidth to serve the files (though I know it's not that much). If it's referenced externally and I'm deploying this web site to lots of servers that need to have their own copies of all the files, then it's one less file I have to remember to copy/update.

    Read the article

  • Is this safe? <a href=http://javascript:...>

    - by KajMagnus
    I wonder if href and src attributes on <a> and <img> tags are always safe w.r.t. XSS attacks, if they start with http:// or https://. For example, is it possible to append javascript: ... to the href and src attribute in some manner, to execute code? Disregarding whether or not the destination page is e.g. a pishing site, or the <img src=...> triggers a terribly troublesome HTTP GET request. Background: I'm processing text with markdown, and then I sanitize the resulting HTML (using Google Caja's JsHtmlSanitizer). Some sample code in Google Caja assumes all hrefs and srcs that start with http:// or https:// are safe -- I wonder if it's safe to use that sample code. Kind regards, Kaj-Magnus

    Read the article

  • Adapting Javascript game for mobile

    - by Cardin
    I'm currently developing a Javascript web game for desktop users. It is a sort of tower-defense game that relies on mouse input only, developed on canvas using EaselJS. In the future, or perhaps simultaneously, I would like to adapt the game for mobile devices. I can see at least 3 potential areas in shifting from desktop to mobile: 1. resolution size and UI rearrangement, 2. converting mouse events to touch events, 3. distribution as native app wrapper or mobile Web. What would be the best strategy to facilitate this desktop to mobile conversion? For example, should I try to code the game for both platforms, or port the game UI over to mobile by branching the code base. Should I just publish on the mobile Web or wrap the game in a native app framework? And if I were to code for both platforms using the same codebase, should I register both click and touch events, or remap click events to touch using dispatchEvent?

    Read the article

  • Implement Fast Inverse Square Root in Javascript?

    - by BBz
    The Fast Inverse Square Root from Quake III seems to use a floating-point trick. As I understand, floating-point representation can have some different implementations. So is it possible to implement the Fast Inverse Square Root in Javascript? Would it return the same result? float Q_rsqrt(float number) { long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = * ( long * ) &y; i = 0x5f3759df - ( i >> 1 ); y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); return y; }

    Read the article

  • Build graph of dependencies (calls) in javascript [on hold]

    - by Maximus
    I'm new to a project and I see that everything is so interwoven that small changes here makes stuff break there. I'd like to refactor it and separate into modules. For that I'm going to need a tool that can build a graph of dependencies (calls) to visualize the connections. There are many tools like that for languages like C#, but I've found little information about the available tools for JavaScript. Has anyone done something like this? What tools have you used?

    Read the article

  • JavaScript: scroll position (Webkit engine) [migrated]

    - by Julien
    I'm currently trying to use JavaScript to find out how far down the page the user has scrolled; for Firefox 8.0, the keyword is pageYOffset. To say things mechanically: The page has a certain height. In Firefox, the useful object is document.documentElement.scrollHeight. The browser's visible area also has a certain height. In Firefox, the object is window.innerHeight; in IE8, document.documentElement.clientHeight. I need to know where the user is in the page vertically; in other words, how many pixels down the page the user has scrolled. Does Webkit have a DOM object that refers to the current scroll position? Thank you.

    Read the article

  • Experience embedding javascript

    - by deft_code
    I'm looking into scripting languages to embed in my game. I've always assumed Lua was the best choice, but I've read some recent news about embedding V8 as was considering using it instead. My question is two fold: Does anyone with experience embedding v8 (or another javascript engine) recommend it? How does it compare with embedding Lua? I like that v8 has a c++ embedding API. However Lua API has had lots of time to be refined (newer isn't always better and all that). Note: At this point I'm not too concerned with which is better language or which library has better performance. I'm only asking about ease of embedding.

    Read the article

  • Comparisons of Javascript 'data grids'?

    - by Joe
    I've found plenty of questions between here and StackExchange of people asking for the 'best' data grid / data table, or one that has a particular feature, and plenty of lists out there (of various ages) listing the various data grid implementations ... but is anyone aware of any matrix of what features the various solutions implement? (eg, allow shift-click to select multiple; support checkboxes for selection; can update a regular table in-place; allow editing of cells; support websql or indexeddb for local caching; which browsers they support; infinite scroll; etc.) There's a generic 'javascript framework' comparison on wikipedia, which would be the sort of thing I'm looking for, but it doesn't go into detail on data grids. (which makes sense, as so many are extensions, not core features of those frameworks, and in the case of jQuery, there's lots of 'em.)

    Read the article

  • Has Dart something useful that javascript doesn't have?

    - by marko
    http://www.dartlang.org/ I've checked out the site very briefly, and got curious. Is there any advantages of using Dart? Is it just a replacement for javascript? It looks like simpler java. Writing quite a lot of C# at work, the language feels very much like what I'm used to, so learning the syntax looks like a breeze to learn. Has anybody any opinions or experiences with the language? (Compared to coffeescript (= I'm not doing ruby syntax) the syntax looks more familiar to me).

    Read the article

  • in javascript whay use " var that = this "

    - by tarek11011
    hi i am new with javascript What is the benefit of using this line var that = this An example function Person( firstname, lastname, age ) { this.firstname = firstname; this.lastname = lastname; this.age = age; getfullname = function() { return firstname + “ “ + lastname; }; var that = this; this.sayHi = function() { document.write( “Hi my name is “ + getfullname() + “ and I am “ + that.age + “years old.”); }; } thanks

    Read the article

  • in javascript why use " var that = this "

    - by tarek11011
    hi i am new with javascript What is the benefit of using this line var that = this An example function Person( firstname, lastname, age ) { this.firstname = firstname; this.lastname = lastname; this.age = age; getfullname = function() { return firstname + “ “ + lastname; }; var that = this; this.sayHi = function() { document.write( “Hi my name is “ + getfullname() + “ and I am “ + that.age + “years old.”); }; } thanks

    Read the article

  • Licensing a JavaScript library

    - by Kendall Frey
    I am developing a free, open-source (duh) JavaScript library, and wondering how to license it. I was considering the GNU GPL, but I heard that I must distribute the license with the software, and I'm not sure anymore. I would like the library to be available much like jQuery: In a free, downloadable script, preferably in either original or minified form. Am I mistaken about the GNU GPL license terms? jQuery is dual licensed under GNU GPL or MIT licenses. How does the GPL apply to single script files like that? Can I license my library with nothing more than a few sentences in the script file? Is there another license that better suits my needs? What would be nice is a license that allows you to put the URL in the source, for people to read if they want. I don't know that many do, unless I am mistaken. I am generally looking to release the library as free software like the GPL specifies, but don't want to have to force licensees to download the full license unless they wish to read it.

    Read the article

  • Will Google treat this JavaScript code as a bad practice?

    - by Mathew Foscarini
    I have a website that provides a custom UX experience implemented via JavaScript. When JavaScript is disabled in the browser the website falls back to CSS for the layout. To make this possible I've added a noJS class to the <body> and quickly remove it via JavaScript. <body class="noJS layout-wide"> <script type="text/javascript">var b=document.getElementById("body");b.className=b.className.replace("noJS","");</script> This caused a problem when the page loads and JavaScript is enabled. The body immediately has it's noJS class removed, and this causes the layout to appear messed up until the JavaScript code for layout is executed (at bottom of the page). To solve this I hide each article via JavaScript by adding a CSS class fix which is display:none as each article is loaded. <article id="q-3217">....</article> <script type="text/javascript">var b=document.getElementById("q-3217");b.className=b.className+" fix";</script> After the page is ready I show all the articles in the correct layout. I've read many times in Google's documentation not to hide content. So I'm worried that the Google will penalize my website for doing this.

    Read the article

  • javascript fixed timestep gameloop with requestanimation frame

    - by coffeecup
    hello i just started to read through several articles, including http://gafferongames.com/game-physics/fix-your-timestep/ ...://gamedev.stackexchange.com/questions/1589/fixed-time-step-vs-variable-time-step/ ...//dewitters.koonsolo.com/gameloop.html ...://nokarma.org/2011/02/02/javascript-game-development-the-game-loop/index.html my understanding of this is that i need the currentTime and the timeStep size and integrate all states to the next state the time which is left is then passed into the render function to do interpolation i tried to implement glenn fiedlers "the final touch", whats troubling me is that each FrameTime is about 15 (ms) and the update loop runs at about 1500 fps which seems a little bit off? heres my code this.t = 0 this.dt = 0.01 this.currTime = new Date().getTime() this.accumulator = 0.0 this.animate() animate: function(){ var newTime = new Date().getTime() , frameTime = newTime - this.currTime , alpha if ( frameTime > 0.25 ) frameTime = 0.25 this.currTime = newTime this.accumulator += frameTime while (this.accumulator >= this.dt ) { this.prev_state = this.curr_state this.update(this.t,this.dt) this.t += this.dt this.accumulator -= this.dt } alpha = this.accumulator / this.dt this.render( this.t, this.dt, alpha) requestAnimationFrame( this.animate ) } also i would like to know, are there differences between glenn fiedlers implementation and the last solution presented here ? gameloop1 gameloop2 [ sorry couldnt post more than 2 links.. ] edit : i looked into it again and adjusted the values this.currTime = new Date().getTime() this.accumulator = 0 this.p_t = 0 this.p_step = 1000/100 this.animate() animate: function(){ var newTime = new Date().getTime() , frameTime = newTime - this.currTime , alpha if(frameTime > 25) frameTime = 25 this.currTime = newTime this.accumulator += frameTime while(this.accumulator >= this.p_step){ // prevstate = currState this.update() this.p_t+=this.p_step this.accumulator -= this.p_step } alpha = this.accumulator / this.p_step this.render(alpha) requestAnimationFrame( this.animate ) now i can set the physics update rate, render runs at 60 fps and physics update at 100 fps, maybe someone could confirm this because its the first time i'm playing around with game development :-)

    Read the article

  • Designing javascript chart library

    - by coolscitist
    I started coding a chart library on top of d3js: My chart library. I read Javascript API reusability and Towards reusable charts. However, I am NOT really following the suggestions because I am not really convinced about them. This is how my library can be used to create a bubble chart: var chart = new XYBubbleChart(); chart.data = [{"xValue":200,"yValue":300},{"xValue":400,"yValue":200},{"xValue":100,"yValue":310}]; //set data chart.dataKey.x = "xValue"; chart.dataKey.y = "yValue"; chart.elementId = "#chart"; chart.createChart(); Here are my questions: It does not use chaining. Is it a big issue? Every property and function is exposed publicly. (Example: width, height are exposed in Chart.js). OOP is all about abstraction and hiding, but I don't really see the point right now. I think exposing everything gives flexibility to change property and functionality inside subclasses and objects without writing a lot of code. What could be pitfalls of such exposure? I have implemented functions like: zooming, "showing info boxes when data point is clicked" as "abilities". (example: XYZoomingAbility.js). Basically, such "abilities" accept "chart" object, play around with public variables of "chart" to add functionality. What this allows me to do is to add an ability by writing: activateZoomAbility(chartObject); My goal is to separate "visualization" from "interactivity". I want "interactivity" like: zooming to be plugged into the chart rather than built inside the chart. Like, I don't want my bubble chart to know anything about "zooming". However, I do want zoomable bubble chart. What is the best way to do this? How to test and what to test? I have written mixed tests: jasmine and actual html files so that I can test manually on browser.

    Read the article

  • Semi Fixed-timestep ported to javascript

    - by abernier
    In Gaffer's "Fix Your Timestep!" article, the author explains how to free your physics' loop from the paint one. Here is the final code, written in C: double t = 0.0; const double dt = 0.01; double currentTime = hires_time_in_seconds(); double accumulator = 0.0; State previous; State current; while ( !quit ) { double newTime = time(); double frameTime = newTime - currentTime; if ( frameTime > 0.25 ) frameTime = 0.25; // note: max frame time to avoid spiral of death currentTime = newTime; accumulator += frameTime; while ( accumulator >= dt ) { previousState = currentState; integrate( currentState, t, dt ); t += dt; accumulator -= dt; } const double alpha = accumulator / dt; State state = currentState*alpha + previousState * ( 1.0 - alpha ); render( state ); } I'm trying to implement this in JavaScript but I'm quite confused about the second while loop... Here is what I have for now (simplified): ... (function animLoop(){ ... while (accumulator >= dt) { // While? In a requestAnimation loop? Maybe if? ... } ... // render requestAnimationFrame(animLoop); // stand for the 1st while loop [OK] }()) As you can see, I'm not sure about the while loop inside the requestAnimation one... I thought replacing it with a if but I'm not sure it will be equivalent... Maybe some can help me.

    Read the article

  • Lightweight, dynamic, fully JavaScript web UI library recommendations

    - by Matt Greer
    I am looking for recommendations for a lightweight, dynamic, fully JavaScript UI library for websites. Doesn't have to be amazing visually, the end result is for simple demos I create. What I want can be summed up as "Ext-like, but not GPL'ed, and a much smaller footprint". I want to be able to construct UIs dynamically and fully through code. My need for this is currently driven by this particle designer. Depending on what query parameters you give it, the UI components change, example 1, example2. Currently this is written in Ext, but Ext's license and footprint are turn offs for me. I like UKI a lot, but it's not very good for dynamically building UIs since everything is absolutely positioned. Extending Uki to support that is something I am considering. Ideally the library would let me make UIs with a pattern along the lines of: var container = new SomeUI.Container(); container.add(new SomeUI.Label('Color Components')); container.add(new SomeUI.NumberField('R')); container.add(new SomeUI.NumberField('G')); container.add(new SomeUI.NumberField('B')); container.add(new SomeUI.CheckBox('Enable Alpha')); container.renderTo(someDiv);

    Read the article

  • Isometric Movement in Javascript In the DOM

    - by deep
    I am creating a game using Javascript. I am not using the HTML5 Canvas Element. The game requires both side view controlles, and Isometric controls, hence the movementMode variable. I have got the specific angles, but I am stuck on an aspect of this. https://chillibyte.makes.org/thimble/movement function draw() { if (keyPressed) { if (whichKey == keys.left) { move(-1,0) } if (whichKey == keys.right) { move(1,0) } if (whichKey == keys.up) { move(0,-1) } if (whichKey == keys.down) { move(0,1) } } } This gives normal up, down , left, and right. i want to refactor this so that i can plugin two variables into the move() function, which will give the movement wanted. Now for the trig. /| / | / | y / | /a___| x Take This Right angled Triangle. given that x is 1, y must be equal to tan(a) That Seems right. However, when I do Math.tan(45), i get a number similar to 1.601. Why? To Sum up this question. I have a function, and i need a function which will converts an angle to a value, which will tell me the number of pixels that i need to go up by, if i only go across 1. Is it Math.tan that i want? or is it something else?

    Read the article

  • Duplication of code (backend and javascript - knockout)

    - by Michal B.
    We have a new developer in our team. He seems a smart guy (he just came in so I cannot really judge). He started with implementing some small enhancements in the project (MVC3 web application using javascript - jquery and knockout). Let's say we have two values: A - quite complex calculation C - constant B = A + C On the screen there is value B and user can change it (normal texbox). When B changes, A changes as well because C is constant. So there is linear dependency between A and B. Now, all the calculations are done in the backend, but we need to recalculate A as user changes B (in js, I would use knockout). I thought about storing old A and B and when B changes by 10 then we know that new A will be old A + 10. He says this is dirty, because it's duplication of code (we make use of the fact that they are dependent and according to him that should be only in one place in our app). I understand it's not ideal, but making AJAX request after every key press seems a bit too much. It's a really small thing and I would not post if we haven't had long discussion about it. How do you deal with such problems? Also I can imagine that using knockout implies lots of calculations on the client side, which very often leads to duplication of the same calculations from the backend. Does anyone have links to some articles/thoughts on this topic?

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >