sample03.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <!--
  3. * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  4. * Copyright (C) 2003-2009 Frederico Caldeira Knabben
  5. *
  6. * == BEGIN LICENSE ==
  7. *
  8. * Licensed under the terms of any of the following licenses at your
  9. * choice:
  10. *
  11. * - GNU General Public License Version 2 or later (the "GPL")
  12. * http://www.gnu.org/licenses/gpl.html
  13. *
  14. * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  15. * http://www.gnu.org/licenses/lgpl.html
  16. *
  17. * - Mozilla Public License Version 1.1 or later (the "MPL")
  18. * http://www.mozilla.org/MPL/MPL-1.1.html
  19. *
  20. * == END LICENSE ==
  21. *
  22. * Sample page.
  23. -->
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <head>
  26. <title>FCKeditor - Sample</title>
  27. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  28. <meta name="robots" content="noindex, nofollow" />
  29. <link href="../sample.css" rel="stylesheet" type="text/css" />
  30. <script type="text/javascript" src="../../fckeditor.js"></script>
  31. <script type="text/javascript">
  32. var bIsLoaded = false ;
  33. function FCKeditor_OnComplete( editorInstance )
  34. {
  35. if ( bIsLoaded )
  36. return ;
  37. var oCombo = document.getElementById( 'cmbLanguages' ) ;
  38. // Remove all options. (#1399)
  39. oCombo.innerHTML = '' ;
  40. var aLanguages = new Array() ;
  41. for ( code in editorInstance.Language.AvailableLanguages )
  42. aLanguages.push( { Code : code, Name : editorInstance.Language.AvailableLanguages[code] } ) ;
  43. aLanguages.sort( SortLanguage ) ;
  44. for ( var i = 0 ; i < aLanguages.length ; i++ )
  45. AddComboOption( oCombo, aLanguages[i].Name + ' (' + aLanguages[i].Code + ')', aLanguages[i].Code ) ;
  46. oCombo.value = editorInstance.Language.ActiveLanguage.Code ;
  47. document.getElementById('eNumLangs').innerHTML = '(' + aLanguages.length + ' languages available!)' ;
  48. bIsLoaded = true ;
  49. }
  50. function SortLanguage( langA, langB )
  51. {
  52. return ( langA.Name < langB.Name ? -1 : langA.Name > langB.Name ? 1 : 0 ) ;
  53. }
  54. function AddComboOption(combo, optionText, optionValue)
  55. {
  56. var oOption = document.createElement("OPTION") ;
  57. combo.options.add(oOption) ;
  58. oOption.innerHTML = optionText ;
  59. oOption.value = optionValue ;
  60. return oOption ;
  61. }
  62. function ChangeLanguage( languageCode )
  63. {
  64. document.location.href = document.location.href.replace( /\?.*$/, '' ) + "?" + languageCode ;
  65. }
  66. </script>
  67. </head>
  68. <body>
  69. <h1>
  70. FCKeditor - JavaScript - Sample 3</h1>
  71. <div>
  72. This sample shows the editor in all its available languages.
  73. </div>
  74. <hr />
  75. <table cellpadding="0" cellspacing="0" border="0">
  76. <tr>
  77. <td>
  78. Select a language:&nbsp;
  79. </td>
  80. <td>
  81. <select id="cmbLanguages" onchange="ChangeLanguage(this.value);">
  82. <option>&nbsp;</option>
  83. </select>
  84. </td>
  85. <td>
  86. &nbsp;<span id="eNumLangs"></span>
  87. </td>
  88. </tr>
  89. </table>
  90. <br />
  91. <form action="../php/sampleposteddata.php" method="post" target="_blank">
  92. <script type="text/javascript">
  93. <!--
  94. // Automatically calculates the editor base path based on the _samples directory.
  95. // This is usefull only for these samples. A real application should use something like this:
  96. // oFCKeditor.BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value.
  97. var sBasePath = document.location.href.substring(0,document.location.href.lastIndexOf('_samples')) ;
  98. var sLang ;
  99. if ( document.location.search.length > 1 )
  100. sLang = document.location.search.substr(1) ;
  101. var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
  102. oFCKeditor.BasePath = sBasePath ;
  103. if ( sLang == null )
  104. {
  105. oFCKeditor.Config["AutoDetectLanguage"] = true ;
  106. oFCKeditor.Config["DefaultLanguage"] = "en" ;
  107. }
  108. else
  109. {
  110. oFCKeditor.Config["AutoDetectLanguage"] = false ;
  111. oFCKeditor.Config["DefaultLanguage"] = sLang ;
  112. }
  113. oFCKeditor.Value = '<p>This is some <strong>sample text<\/strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor<\/a>.<\/p>' ;
  114. oFCKeditor.Create() ;
  115. //-->
  116. </script>
  117. <br />
  118. <input type="submit" value="Submit" />
  119. </form>
  120. </body>
  121. </html>