Skip to main content

Home/ javascript/ Group items tagged how to

Rss Feed Group items tagged

yc c

HTML & JavaScript Encoder/Decoder - 1 views

  •  
    Encoding/Decoding Escape/Unescape These scripts are intended to explain how to "hide" HTML and/or javascript from other people who view your page's source code. It is not foolproof, but it does make it more difficult to read and understand the source code. Due to the nature of how these scripts work, the explanation may seem complicated and drawn out, but be patient and it should make sense once you gain a little experience with them. You don't really have to know the ins-and-outs of these scripts, but it does help you understand how and why they work. So, take a seat and I'll do my best to make this seem as un-complicated as possible.
Javier Neira

Why REST ? | /var/log/mind - 0 views

  • ‘ls’ or ‘List Directory’
  • ‘cd’or ‘Change Directory’
  • ‘put’ or ‘Upload’
  • ...26 more annotations...
  • you soon realise that every file and directory is uniquely addressable by its fully qualified path (either absolute or relative) and you can refer to each file and directory by its path. You are also aware that a valid path will uniquely resolve to only one directory or file.
  • the server allows you to retrieve the list of subdirectories and files within your current directory. It always shows you the current state of that directory.
  • following elements
  • A shared understanding of where the files will be uploaded, how they will be uniquely named, their specific file extensions (optionally) and the specific format of the file eg.
  • daemon process on the central office computer (the FTP server) which regularly scans the directory, parses each file as it comes it, does the relevant processing on it, and generates the appropriate result files and places them in the appropriate directories using the shared understanding of the directory structure and the file naming convention to communicate back the results of the processing.
  • RPC allowed you to invoke remote procedures by supporting an ability to pass messages which included the message name and the values for all the parameters necessary to be supplied to the message. Unlike FTP which was meant to do data transfer across a network, RPC was geared to do things remotely.
  • FTP required understanding of very few basic verbs (ls, cd, get, put). Thus the training required to understand FTP semantics was far less than that for RPC. This was partially due to the fact that RPC had a programmatic interface.
  • Moreover each time, new procedures were added or parameters added, these required programmatic changes
  • HTTP protoco
  • Unlike FTP and email, this required the authors to understand a new language, but used a simple markup syntax to keep the learning curve to the minimum
  • get/view/download/save a document
  • Along with RPC, these were essentially different technical manifestations of Service Oriented Architecture (SOA) principles.
  • Many services were usually expected to “do something” though quite often some services would simply return the requested data. Usually but not necessarily the services were identified by using ‘verbs’.
  • allow us to use the web to ‘do something’
  • Resource and media types as the basic units
  • Unique resource identifiers
  • Each resource has often one default manually readable representation
  • Each resource representation optionally includes contextually relevant hyperlinks to other resources
  • REST encourages a uniform interface
  • GET, PUT, POST and DELETE
  • Default Rendering
  • a default HTML rendering capability
  • Aspects such as non maintenance of conversational state, greatly increase the scalability of REST applications even if they do incur a minor cost in efficiency (which can be due to repeated redundant communication of data elements, or additional processing requirements due to preclusion of conversation state).
  • is much easier to understand from a data perspective than an invoice processor API.
  • However the simpler, cleaner and minimalistic abstractions often are far more important than feature richness. A point I would want to make in favour of REST even as I admit that conventional SOA technologies are far more feature rich than REST.
  • REST encourages you to view and model your architecture as a set of resources rather than services.
Hostforlife Hosting

How to Use JavaScript to Create Simple Animation - - 1 views

  •  
    In this example, you are going to learn how to create simple animation of an object using JavaScript. The object we're referring to here is any image.
Javier Neira

Perfection kills » Understanding delete - 3 views

  • All because it’s not possible to delete variables in Javascript. At least not when declared in such way.
  • It’s almost as if Firebug follows some other rules of deletion. It is Firebug that has led Stoyan astray! So what is really going on here?
  • we need to understand how delete operator works in Javascript: what exactly can and cannot be deleted and why.
  • ...35 more annotations...
  • var o = { x: 1 }; delete o.x; // true o.x; // undefined
  • var x = 1; delete x; // false x; // 1
  • function x(){} delete x; // false typeof x; // "function"
  • Note that delete only returns false when a property can not be deleted.
  • variable instantiation and property attributes
  • Global code, Function code and Eval code.
  • When a source text is treated as a Program, it is executed in a global scope, and is considered a Global code.
  • Anything that’s executed directly within a function is, quite obviously, considered a Function code. In browsers, content of event attributes (e.g. <p onclick="...">) is usually parsed and treated as a Function code.
  • text that’s supplied to a built-in eval function is parsed as Eval code. We will soon see why this type is special.
  • And now that we know the difference between property assignment and variable declaration — latter one sets DontDelete, whereas former one doesn’t — it should be clear why undeclared assignment creates a deletable property:
  • As you can see, execution contexts can logically form a stack. First there might be Global code with its own execution context; that code might call a function, with its own execution context; that function could call another function, and so on and so forth. Even if function is calling itself recursively, a new execition context is being entered with every invocation.
  • Every execution context has a so-called Variable Object associated with it. Similarly to execution context, Variable object is an abstract entity, a mechanism to describe variable instantiation. Now, the interesing part is that variables and functions declared in a source text are actually added as properties of this Variable object.
  • When control enters execution context for Global code, a Global object is used as a Variable object. This is precisely why variables or functions declared globally become properties of a Global object:
  • The behavior is actually very similar: they become properties of Variable object. The only difference is that when in Function code, a Variable object is not a Global object, but a so-called Activation object. Activation object is created every time execution context for Function code is entered.
  • and a special Arguments object (under arguments name). Note that Activation object is an internal mechanism and is never really accessible by program code.
  • within Eval code are created as properties of calling context’s Variable object. Eval code simply uses Variable object of the execution context that it’s being called within:
  • Execution context When ECMAScript code executes, it always happens within certain execution context.
  • When declared variables and functions become properties of a Variable object — either Activation object (for Function code), or Global object (for Global code), these properties are created with DontDelete attribute. However, any explicit (or implicit) property assignment creates property without DontDelete attribute. And this is essentialy why we can delete some properties, but not others:
  • Special arguments variable (or, as we know now, a property of Activation object) has DontDelete. length property of any function instance has DontDelete as well:
  • As you might remember, undeclared assignment creates a property on a global object.
  • Now that it’s clear what happens with variables (they become properties), the only remaining concept to understand is property attributes. Every property can have zero or more attributes from the following set — ReadOnly, DontEnum, DontDelete and Internal. These attributes serve as sort of flags — an attribute can either exist on a property or not. For the purposes of today’s discussion, we are only interested in DontDelete.
  • Variables declared within Eval code are actually created as properties without DontDelete:
  • This interesting eval behavior, coupled with another aspect of ECMAScript can technically allow us to delete non-deletable properties. The thing about function declarations is that they can overwrite same-named variables in the same execution context:
  • Note how function declaration takes precedence and overwrites same-named variable (or, in other words, same property of Variable object). This is because function declarations are instantiated after variable declarations, and are allowed to overwrite them
  • If we declare function via eval, that function should also replace that property’s attributes with its own. And since variables declared from within eval create properties without DontDelete, instantiating this new function should essentially remove existing DontDelete attribute from the property in question, making that property deletable (and of course changing its value to reference newly created function).
  • Unfortunately, this kind of spoofing doesn’t work in any implementation I tried. I might be missing something here, or this behavior might simply be too obscure for implementors to pay attention to
  • this.x = 1; delete x; // TypeError: Object doesn't support this action
  • var x = 1; delete this.x; // TypeError: Cannot delete 'this.x'
  • It’s as if variable declarations in Global code do not create properties on Global object in IE.
  • Not only is there an error, but created property appears to have DontDelete set on it, which of course it shouldn’t have:
  • “The global variable object is implemented as a JScript object, and the global object is implemented by the host.
  • Note how this and window seem to reference same object (if we can believe === operator), but Variable object (the one on which function is declared) is different from whatever this references.
  • delete doesn’t differentiate between variables and properties (in fact, for delete, those are all References) and really only cares about DontDelete attribute (and property existence).
  • The moral of the story is to never trust host objects.
  • Few restrictions are being introduced. SyntaxError is now thrown when expression in delete operator is a direct reference to a variable, function argument or function identifier. In addition, if property has internal [[Configurable]] == false, a TypeError is thrown:
Javier Neira

How To Make Firebug's JavaScript Debugger Break Inside Dynamic JavaScript Using The 'de... - 0 views

  • The Problem With Dynamic JavaScript However, what if the JavaScript file where you need to set breakpoints is not static but instead dynamic (generated on the fly). If you set a breakpoint in this case and reload the page, the breakpoint will most likely disappear, especially if the JavaScript url is generated uniquely every time. The Solution If you have access to the source, the solution comes in the form of the debugger; keyword. Just add it to your dynamic JavaScript generator or into any JavaScript file you have access to exactly where you want Firebug to break, and voila – it does.
  • More so, this method also works in Google Chrome and IE (if you have Microsoft Script Debugger)
  •  
    The Problem With Dynamic JavaScript However, what if the JavaScript file where you need to set breakpoints is not static but instead dynamic (generated on the fly). If you set a breakpoint in this case and reload the page, the breakpoint will most likely disappear, especially if the JavaScript url is generated uniquely every time. The Solution If you have access to the source, the solution comes in the form of the debugger; keyword. Just add it to your dynamic JavaScript generator or into any JavaScript file you have access to exactly where you want Firebug to break, and voila - it does.
lambdatestteam

End to End Testing - 0 views

  •  
    End to end testing is a very common testing methodology where the objective is to test how an application works by checking the flow from start to end. Not only the application flow under dev environment is tested, but the tester also has to check how it behaves once integrated with the external interface.
Javier Neira

JavaScript setTimeout Function - JavaScript Timing Events - 0 views

  •  
    JavaScript setTimeout Function - JavaScript Timing Events November 16, 2007 by Blogging Developer JavaScript features a couple of methods that lets you run a piece of JavaScript code (javascript function) at some point in the future. These methods are: * setTimeout() * setInterval() In this tutorial, I'll explain how setTimetout() method works, and give a real world example. You may find the details of setInterval() method in JavaScript setInterval Function - JavaScript Timing Events setTimeout() window.setTimeout() method allows you to specify a piece of JavaScript code (expression) will be run after specified number of miliseconds from when the setTimeout() method is called. Syntax var t = setTimeout ( expression, timeout ); The setTimeout() method returns a numeric timeout ID which can be used to refer the timeout to use with clearTimeout method. The first parameter (expression) of setTimeout() is a string containing a javascript statement. The statement could be a call to a JavaScript function like "delayedAlert();" or a statement like "alert('This alert is delayed.');". The second parameter (timeout), indicates the number of miliseconds to pass before executing the expression. Example An alert box will be shown 5 seconds later when you clicked the button. clearTimeout() Sometimes it's useful to be able to cancel a timer before it goes off. The clearTimeout() method lets us do exactly that. Its syntax is: clearTimeout ( timeoutId ); where timeoutId is the ID of the timeout as returned from the setTimeout() method call.
Julian Knight

Chris Adams: Cleaning up the web with jQuery and a little help from Google - 2 views

  •  
    How to use JQuery (or other libraries) in a bookmarklet! With an example of making textarea's resizeable. Chris Adams provides a template for creating your own bookmarklet and explains some of the reasons you might want to use this technique for development and testing. He also points out some gotcha's to be careful of.
  •  
    How to use JQuery (or other libraries) in a bookmarklet! With an example of making textarea's resizeable. Chris Adams provides a template for creating your own bookmarklet and explains some of the reasons you might want to use this technique for development and testing. He also points out some gotcha's to be careful of.
Javier Neira

Caffeinated Simpleton » Blog Archive » An Introduction to JavaScript's "this" - 2 views

  • That’s what this is expected to be, anyway. It’s expected to be a reference to the current instance of whatever object it’s defined within.
  • It’ll give an error saying that this doesn’t have a member called condiments, even though it clearly does. What happened?!
  • This is because there is no binding of functions to instances in JavaScript.
  • ...3 more annotations...
  • The setTimeout function, however, just has a reference to that function. When it calls it, it’s not aware of myHotDog, so JavaScript sets this to window
  • function HotDog() { var my = this; // my references the current this, which is correct. my.condiments = "mustard, ketchup"; my.getCondiments = function() { return my.condiments; //my is guaranteed to be a reference to the original "this" } }
  • In constructors, this is always your instance. So we created a new variable, my, that references the HotDog instance. This allows you to always refer to the HotDog instance, no matter how the getCondiments function is called.
Hussain M Elius

Creating a "Filterable" Portfolio with jQuery - NETTUTS - 0 views

  •  
    If you have worked in your field for a while, there is a pretty good chance that you have a rather extensive portfolio. To make it a little easier to navigate, you will probably be tempted to break them into different categories. In this tutorial, I will show you how to make "filtering by category" a little more interesting with just a little bit of jQuery
marketngedwisor

How to become a Front-end developer in 2019 - 0 views

  •  
    Front End Development or Client-Side Development is the practice of coding in technologies like HTML, CSS, and Javascript in a website. The practice involves converting Data into a Graphical Interface for a user to view and interact. Growth in Front-end development is excellent and there are plenteous opportunities available, especially because companies now want their customers to have a good experience while using their Web applications. Want to get hired as a Front End Developer in 2019? Acquire skills in Front End Development, Build live Projects and Get Guaranteed Interviews with edWisor.
Justin Pierce

Managing Finances Gets Easier - 1 views

started by Justin Pierce on 27 Nov 12 no follow-up yet
Dirk Sorensby

JavaScript Object Chaining using Prototypal Inheritance - 2 views

  •  
    how to use the prototype and constructor properties to trace an object's ancestry up to the base Object. H
Julian Knight

jQuery and Google Maps Tutorial: #1 Basics: jQuery, Google Maps - 0 views

  •  
    "There are many times I want to leverage jQuery's strengths to create a custom Google Maps mashup. In this tutorial, I will walk you through how to get started using jQuery inside the Google Maps environment. I will assume nothing, and explain each piece in detail."
Hussain M Elius

How to hide, show, or toggle your div - 0 views

  •  
    Are you trying to find a way to hide and show your content? The demo below shows a simple way of toggling your content via Javascript and styling.
yc c

Soba1.1 - a live HTML editor - 2 views

  •  
    just edit the html on the left pane, and you'll see how it rendered on the right pane as you typed.\nIt should be useful when you want to develop such as CSS or JavaScript which need to be tuned litlle by little.\nNote that the html document is automatically stored into a browser's cookie(up to approx.4kb).\nSo you can continue working on the html even after you closed the browser window.
anonymous

nodeschool.io - 4 views

  •  
    Learn Node.JS with interactive lessons Install these choose-your-own-adventure style lessons and learn how to use node.js, npm and other related tools by writing code to solve realistic problems. The lessons run in your terminal and work on Windows, Mac and Linux. Select a lesson below to get started!
Javier Neira

Google Closure: How not to write JavaScript - 3 views

  • “It’s a JavaScript library written by Java developers who clearly don’t get JavaScript.”
  • Unfortunately, unlike the built-in properties supplied by Object.prototype, custom properties added to Object.prototype will show up as an object property in any for-in loop in the page.
  • custom properties added to
  • ...3 more annotations...
  • will show up as an object property in any
  • loop in the page.
  • var a = "I am a string!";   2 alert(typeof a); // Will output "string"   3 var b = new String("I am also a string!");   4 alert(typeof b); // Will output "object" 
seth kutcher

The Best Remote PC Support I Ever Had - 1 views

The Remote PC Support Now excellent remote PC support services are the best. They have skilled computer tech professionals who can fix your PC while you wait or just go back to work or just simpl...

remote PC support

started by seth kutcher on 12 Sep 11 no follow-up yet
Eunikorn Imazinator

How to Monitor If an Image Loads Completed - HTML and Javascript Tips |JAVASCRIPT CODES - 0 views

  • imgDom.onreadystatechange
    • Eunikorn Imazinator
       
      cross browser way to deal with loading of single dom elements.  Note : this does not ensure that entire subsidiary dom tree has loaded and also it does not ensure that the event will be immediately fired if dom has already loaded.  Doing the same thing through JQuery :  $("..something..").load(function() { ... });
1 - 20 of 42 Next › Last »
Showing 20 items per page