JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
7c134527b6dc87a85a6bb9cb5888cbd2e5c86444
[ckeditor.git] / _samples / sample.js
1 /*\r
2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license\r
4 */\r
5 \r
6 // This file is not required by CKEditor and may be safely ignored.\r
7 // It is just a helper file that displays a red message about browser compatibility\r
8 // at the top of the samples (if incompatible browser is detected).\r
9 \r
10 // Firebug has been presented some bugs with console. It must be "initialized"\r
11 // before the page load to work.\r
12 // FIXME: Remove the following in the future, if Firebug gets fixed.\r
13 if ( typeof console != 'undefined' )\r
14         console.log();\r
15 \r
16 \r
17 if ( window.CKEDITOR )\r
18 {\r
19         (function()\r
20         {\r
21                 var showCompatibilityMsg = function()\r
22                 {\r
23                         var env = CKEDITOR.env;\r
24 \r
25                         var html = '<p><strong>Your browser is not compatible with CKEditor.</strong>';\r
26 \r
27                         var browsers =\r
28                         {\r
29                                 gecko : 'Firefox 2.0',\r
30                                 ie : 'Internet Explorer 6.0',\r
31                                 opera : 'Opera 9.5',\r
32                                 webkit : 'Safari 3.0'\r
33                         };\r
34 \r
35                         var alsoBrowsers = '';\r
36 \r
37                         for ( var key in env )\r
38                         {\r
39                                 if ( browsers[ key ] )\r
40                                 {\r
41                                         if ( env[key] )\r
42                                                 html += ' CKEditor is compatible with ' + browsers[ key ] + ' or higher.';\r
43                                         else\r
44                                                 alsoBrowsers += browsers[ key ] + '+, ';\r
45                                 }\r
46                         }\r
47 \r
48                         alsoBrowsers = alsoBrowsers.replace( /\+,([^,]+), $/, '+ and $1' );\r
49 \r
50                         html += ' It is also compatible with ' + alsoBrowsers + '.';\r
51 \r
52                         html += '</p><p>With non compatible browsers, you should still be able to see and edit the contents (HTML) in a plain text field.</p>';\r
53 \r
54                         document.getElementById( 'alerts' ).innerHTML = html;\r
55                 };\r
56 \r
57                 var onload = function()\r
58                 {\r
59                         // Show a friendly compatibility message as soon as the page is loaded,\r
60                         // for those browsers that are not compatible with CKEditor.\r
61                         if ( !CKEDITOR.env.isCompatible )\r
62                                 showCompatibilityMsg();\r
63                 };\r
64 \r
65                 // Register the onload listener.\r
66                 if ( window.addEventListener )\r
67                         window.addEventListener( 'load', onload, false );\r
68                 else if ( window.attachEvent )\r
69                         window.attachEvent( 'onload', onload );\r
70         })();\r
71 }\r