📜 ⬆️ ⬇️

widget do it yourself

Hey.

Probably, many of you used standard javascript-widgets written by both unknown developers, and strong professionals, and gurus. There are great collections of widgets that come as plugins for well-known frameworks (like jQuery , Prototype JS , YUI ), and whole frameworks that focus on creating widgets like Ext JS or qooXdoo .

But what if you don’t want to use a large enough framework to create a simple dialog box, or want to figure out how to create such widgets, or even develop your own framework?
')
This will be discussed in today's post - how to make the simplest dialog box and alert using pure javascript, without using any frameworks.

Disclaimer : should warn that the code presented below is only an example of implementation, it is intended only to show the way, but this is not the final result. Of course, you can use the resulting widget in your project, but be aware - you can do much better, in general, there is a space for self-expression and screwing up. In addition, I tried to describe every step that would be useful for a beginner, but without a doubt, would annoy a professional. However, if you are a professional, then this article is unlikely to help you.

First of all, we will need a small collection of methods that facilitate our work - first of all, hanging and removing event handlers on DOM elements, the rest are completely optional, and are simply helpers that reduce the amount of code and increase its clarity:

// "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  1. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  2. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  3. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  4. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  5. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  6. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  7. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  8. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  9. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  10. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  11. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  12. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  13. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  14. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  15. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  16. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  17. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  18. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  19. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  20. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  21. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  22. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  23. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  24. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  25. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  26. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  27. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  28. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  29. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  30. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  31. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  32. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  33. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  34. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  35. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  36. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  37. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  38. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  39. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  40. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  41. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  42. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  43. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  44. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  45. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  46. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  47. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  48. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  49. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  50. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  51. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  52. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  53. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  54. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  55. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  56. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  57. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  58. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  59. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  60. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  61. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  62. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  63. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
  64. // "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .
// "DEMO". // ? // : // 1. , , , // ( ), , ( ) , // . - , , ? // 2. , ( javascript' - window) // , , , // , , . // , , , . // , // . if ( typeof DEMO == "undefined" || !DEMO) { var DEMO = {}; } // Lang - , . // , - , , // , . // // , , Lang DEMO, , // , , , // , (, ), // , - // DEMO.Lang , , . DEMO.Lang = typeof DEMO.Lang != 'undefined' && DEMO.Lang ? DEMO.Lang : { isUndefined : function (o) { return typeof o === 'undefined' ; }, isString : function (o) { return typeof o === 'string' ; } }; // DOM - , DOM. - // , get . DEMO.DOM = typeof DEMO.DOM != 'undefined' && DEMO.DOM ? DEMO.DOM : { get : function (el) { return (el && el.nodeType) ? el : document .getElementById(el); }, addListener : function (el, type, fn) { // el dom-, , dom- id, if (DEMO.Lang.isString(el)) { el = this .get(el); } // // feature-testing. // , : www.unix.com.ua/orelly/webprog/jscript/ch20_01.htm // : fastcoder.org/articles/?aid=17 if (el.addEventListener) { el.addEventListener(type, fn, false ); } else if (el.attachEvent) { el.attachEvent( 'on' + type, fn); } else { el[ 'on' + type] = fn; } }, removeListener : function (el, type, fn) { if (DEMO.Lang.isString(el)) { el = this .get(el); } if (el.removeEventListener){ el.removeEventListener(type, fn, false ); } else if (el.detachEvent) { el.detachEvent( 'on' + type, fn); } else { el[ 'on' + type] = function () { return true ; }; } } }; * This source code was highlighted with Source Code Highlighter .


In order not to inflate the listing, I did not include two more functions in it - purge and setInnerHTML, you can find their description and principle of operation by the link. You can also find them in the source code of the example.

Well, now let's move on to what it was all about - to create a dialog box directly.

  1. if ( typeof DEMO == "undefined" ||! DEMO) {
  2. var DEMO = {};
  3. }
  4. // Pay attention - the object is built on the so-called "modular" pattern proposed by YAHOO!
  5. // read more: ajaxian.com/archives/a-javascript-module-pattern
  6. DEMO.Dialog = typeof DEMO.Dialog! = ' Undefined ' && DEMO.Dialog? DEMO.Dialog: function () {
  7. // "private" properties
  8. // create a dialog container and remember it.
  9. var dialog = document .createElement ( 'div' );
  10. dialog.className = 'dialog' ;
  11. document .body.appendChild (dialog);
  12. // Main function. The input can come as a string (in this case, it becomes the text of the window)
  13. // same way with properties:
  14. // body {String} - window text
  15. // buttons {Array} is an array of buttons, with each button being an object of the form:
  16. // id: {String} - button id
  17. // text: {String} - button text
  18. // callback: {Function | Object} is either a function (in this case it will be hung by clicking on the button), or an object of the form:
  19. // fn: {Function} directly function
  20. // type: {String} type of the event to which the function will be attached.
  21. var render = function (o) {
  22. var html, i, length = ( typeof o.buttons === 'undefined' )? 0: o.buttons.length,
  23. button;
  24. // dialog box text
  25. if ( typeof o === 'string' ) {
  26. html = '<p>' + o + '</ p>' ;
  27. } else {
  28. html = '<p>' + ((o.body)? o.body: o) + '</ p>' ;
  29. }
  30. for (i = 0; i <length; i ++) {
  31. button = o.buttons [i];
  32. html + = '<a href="#" id="' + button.id +'">' + button.text + '</a>' ;
  33. }
  34. // we don’t need to worry about memory leaks, Douglas Crockford worried about us
  35. DEMO.DOM.setInnerHTML (dialog, html);
  36. activateListeners (o.buttons);
  37. };
  38. // hang event handlers on the buttons. If there are no buttons, we do nothing.
  39. var activateListeners = function (buttons) {
  40. var i, length, button, isUndefined = DEMO.Lang.isUndefined;
  41. if (DEMO.Lang.isUndefined (buttons)) { return ; }
  42. length = buttons.length;
  43. for (i = 0; i <length; i ++) {
  44. button = buttons [i];
  45. if (! isUndefined (button.callback.type) &&! isUndefined (button.callback.fn)) {
  46. DEMO.DOM.addListener (button.id, button.callback.type, button.callback.fn);
  47. } else {
  48. DEMO.DOM.addListener (button.id, 'click' , button.callback);
  49. }
  50. }
  51. cached_buttons = buttons;
  52. };
  53. return {
  54. // public function
  55. // show dialog dialog
  56. show: function (o) {
  57. render (o);
  58. },
  59. // hide the dialog box
  60. hide: function () {
  61. dialog.style.display = 'none' ;
  62. }
  63. };
  64. } ();
* This source code was highlighted with Source Code Highlighter .


Now we have a DEMO.Dialog object, which has two public methods - show and hide. At the same time, the object is quite flexible and can draw both a dialog box and an alert.

If we want to display a dialog box, we will add two buttons:
  1. DEMO.Dialog.show ({
  2. body: 'Would you like some coffee?' ,
  3. buttons: [
  4. {
  5. id: 'cancel' ,
  6. text: 'Not' ,
  7. callback: function () {DEMO.Dialog.hide (); }
  8. },
  9. {
  10. id: accept ,
  11. text: 'Yes!' ,
  12. callback: function () {
  13. DEMO.Dialog.hide ();
  14. document .body.appendChild ( document .createTextNode ( 'Me too :)' ));
  15. }
  16. }
  17. ]
  18. });
* This source code was highlighted with Source Code Highlighter .


If we want to notify the user about something, then just one button "Close" is enough:

  1. DEMO.Dialog.show ({
  2. body: "Um ... um ... your coffee ran away!" ,
  3. buttons: [
  4. {
  5. id: accept ,
  6. text: 'Where? o_O ' ,
  7. callback: function () {DEMO.Dialog.hide (); }
  8. }
  9. ]
  10. });
* This source code was highlighted with Source Code Highlighter .


I think the css-code used for the example is not important.

Demonstration

Source code in the archive .

Weight javascript code after gluing:


Of course, this is just an example. In a real project, you had to add the following:


PS crosspost in my blog.

Source: https://habr.com/ru/post/45968/


All Articles