Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
becki:linux:javascript [2010-06-16 10:10] becki |
becki:linux:javascript [2011-03-21 17:04] (aktuell) becki |
||
|---|---|---|---|
| Zeile 2: | Zeile 2: | ||
| ===== Links == | ===== Links == | ||
| - | [[http://de.selfhtml.org/javascript/objekte/|Selfhtml]] - [[https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide|JavaScript 1.5 Guide]] - [[https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference|JavaScript 1.5 Reference]] - [[https://developer.mozilla.org/en/Gecko_DOM_Reference|Gecko DOM Reference]] - [[http://msdn.microsoft.com/en-us/library/ms533050%28VS.85%29.aspx|M$ HTML and DHTML Reference]] - [[Dojo]] | + | [[http://de.selfhtml.org/javascript/objekte/|Selfhtml]] - [[https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide|JavaScript 1.5 Guide]] - [[https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference|JavaScript 1.5 Reference]] - [[https://developer.mozilla.org/en/Gecko_DOM_Reference|Gecko DOM Reference]] - [[http://msdn.microsoft.com/en-us/library/ms533050%28VS.85%29.aspx|M$ HTML and DHTML Reference]] - [[Dojo]] - [[html5]] - [[jrunscript]] |
| ===== Variables == | ===== Variables == | ||
| Zeile 128: | Zeile 128: | ||
| </code> | </code> | ||
| - | Seems to cause overhead, see http://phrogz.net/JS/Classes/OOPinJS.html | + | * Seems to cause overhead, see [[http://phrogz.net/JS/Classes/OOPinJS.html|OOP in JS, Part 1 : Public/Private Variables and Methods]] |
| + | * This is callad a privileged method (which has access to private methods, see below) | ||
| === External method definition and link to object inside of the constructor == | === External method definition and link to object inside of the constructor == | ||
| Zeile 159: | Zeile 160: | ||
| Seems to be the **best** solution :-) | Seems to be the **best** solution :-) | ||
| - | ==== Access Types ==== | + | ==== Public Access == |
| <code javascript> | <code javascript> | ||
| Zeile 194: | Zeile 195: | ||
| </code> | </code> | ||
| - | Private methods seem to be only possible as inline constructor functions, but those seem to cause overhead. | + | ==== Public Access == |
| + | |||
| + | Private methods are possible as inline constructor functions: | ||
| + | |||
| + | <code javascript> | ||
| + | function MyClass() { // The constructor | ||
| + | var privateVariable= 10; // A private instance variable | ||
| + | var privMeth1= function {...} // A private method | ||
| + | fuction privMeth2 {...} // private method (shortcut) | ||
| + | var that= this; // To make this available for priv methods | ||
| + | } | ||
| + | </code> | ||
| + | |||
| + | Notes: | ||
| + | * Private methods possibly cause overhead, compared to the prototype way of public methods | ||
| + | * ''this'' seems only to be accessible in private methods by the ''that'' workaround variable above | ||
| + | * Public methods defined with the (recommended) ''prototype''-way doesn't seem to have access to private mehtods. You need privileged methods (see above) for that. | ||
| + | |||
| + | Sources & more information: | ||
| + | * [[http://javascript.crockford.com/private.html|Private Members in JavaScript]] | ||
| + | * [[http://phrogz.net/JS/Classes/OOPinJS.html|OOP in JS, Part 1 : Public/Private Variables and Methods]] | ||
| ==== Inheritance == | ==== Inheritance == | ||
| Zeile 204: | Zeile 225: | ||
| * [[http://dojotoolkit.org/book/dojo-book-0-4/part-3-dojo-programming-model/global-dojo-objects|Using objects to simulate a namespace]] | * [[http://dojotoolkit.org/book/dojo-book-0-4/part-3-dojo-programming-model/global-dojo-objects|Using objects to simulate a namespace]] | ||
| - | ===== Events ===== | + | ===== Constants == |
| + | |||
| + | ''const'' is mentioned in the [[https://developer.mozilla.org/en/JavaScript/Guide/Values%2c_Variables%2c_and_Literals#Constants|Mozilla guide]] but dosen't work with Rhino version :?: and probabaly neither with IE | ||
| + | |||
| + | ===== Events == | ||
| + | |||
| + | For event handling see: [[https://developer.mozilla.org/en/DOM/element#Event_Handlers|Mozilla]] & [[http://de.selfhtml.org/javascript/sprache/eventhandler.htm|Selfhtml]] | ||
| + | |||
| + | See also Dojo [[dojo#events]] | ||
| ==== Get the Source of the Event ==== | ==== Get the Source of the Event ==== | ||
| <code javascript> | <code javascript> | ||
| Zeile 225: | Zeile 255: | ||
| </code> | </code> | ||
| Event handler for value input fields | Event handler for value input fields | ||
| - | For event handling see: [[http://developer.mozilla.org/en/docs/DOM:element#Event_Handlers|Mozilla]] & [[http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onchange.asp|Micro$oft]] | ||
| ===== Closures == | ===== Closures == | ||
| Zeile 345: | Zeile 374: | ||
| ===== Ajax == | ===== Ajax == | ||
| + | ==== Links == | ||
| - | * [[http://www-128.ibm.com/developerworks/web/library/wa-ajaxintro1.html|Basic principles]] from [[http://www.ibm.com/developerworks/views/web/libraryview.jsp?search_by=Mastering+Ajax|Mastering Ajax series]] at IBM developerWorks | + | [[http://www-128.ibm.com/developerworks/web/library/wa-ajaxintro1.html|Basic principles]] from [[http://www.ibm.com/developerworks/views/web/libraryview.jsp?search_by=Mastering+Ajax|Mastering Ajax series]] at IBM developerWorks - [[http://www.twilightuniverse.com/projects/sack/|Simple AJAX Code-Kit]] - [[http://www.jibbering.com/2002/4/httprequest.html|Raw cross browser code]] |
| - | * [[http://www.jibbering.com/2002/4/httprequest.html|Raw cross browser code]] | + | |
| - | * [[http://www.twilightuniverse.com/projects/sack/|Simple AJAX Code-Kit]] | + | |
| ==== Sending JSON to Server == | ==== Sending JSON to Server == | ||
| Zeile 354: | Zeile 382: | ||
| To convert any javscript value to a JSON string, use json2.js at [[http://www.json.org/js.html|json.org]] | To convert any javscript value to a JSON string, use json2.js at [[http://www.json.org/js.html|json.org]] | ||
| - | FIXME look in http://www.ibm.com/developerworks/views/web/libraryview.jsp?search_by=Mastering+Ajax | + | ==== Todo / Pending == |
| + | |||
| + | * Check [[ibm>web/library/wa-aj-ajaxcomm/|Various client-server communication mechanisms in an Ajax-based web application]] | ||
| + | * Comet allows a web server to push data to a browser. [[wp>Comet_(programming)|Wikpedia article]] Introduction: [[http://www.developer.com/java/ent/article.php/3756841|Pushing Data to the Browser with Comet]] Manual: [[http://www.webreference.com/programming/javascript/rg28/|Comet Programming: Using Ajax to Simulate Server Push]] | ||
| ===== Cookies == | ===== Cookies == | ||
| Zeile 364: | Zeile 395: | ||
| See [[dojo]] | See [[dojo]] | ||
| - | ===== Further Reading == | + | ===== Using Javascript from the Command Line == |
| + | |||
| + | See [[jrunscript]] | ||
| - | * [[ibm>library/x-svgclientside/|Create client-side diagrammatic interaction in Web applications with SVG]]: Include and animate external SVG images, with example code! | ||
| - | * [[ibm>web/library/wa-html5webapp/|Build Web applications with HTML 5]] | ||
| - | * [[ibm>web/tutorials/wa-html5/|Create modern Web sites using HTML5 and CSS3]] | ||