Advertisement
plirof2

b2tgr v002 -230104a - Translate JS version

Jan 5th, 2023
1,174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5.  <!-- <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js" referrerpolicy="origin">
  6.  
  7.  
  8.   </script>
  9.  
  10. Changes:
  11. -230104a - Translate JS version
  12. -220214 - Edit-Area test002
  13. -201019 - hidesubmit option
  14.   <script src="js/tinymce/tinymce.min.js" referrerpolicy="origin">
  15.  
  16.   </script>
  17.  
  18. -->
  19. <script language="javascript" type="text/javascript" src="edit_area/edit_area_full.js"></script>
  20.  
  21.   <script>
  22. editAreaLoader.init({
  23.     id : "text_entered"     // textarea id
  24.     ,syntax: "basicsinclair"            // syntax to be uses for highgliting
  25.     ,start_highlight: true // to display with highlight mode on start-up
  26.     ,allow_resize:"both"
  27.     ,toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap,syntax_selection, |, help"
  28.     ,min_height:500
  29.     ,min_width:800
  30.     ,font_size: 18
  31.  
  32. });
  33.  
  34.  
  35.     function myFunction (){
  36.         console.log(".....myFunction (){ START ");
  37.         /*
  38.         var txt = document.getElementById('text_entered');
  39.         txt.value = greekstring_to_slug(txt.value);
  40.         //alert("Hello onsubmit myfunction");
  41.         */
  42.         //document.getElementById('theForm').submit();
  43.         var x = document.getElementsByName('theForm');
  44.         editAreaLoader.setValue(greekstring_to_slug(editAreaLoader.getValue('text_entered')));
  45.         x[0].submit(); // Form submission
  46.         console.log(".....myFunction (){ END");
  47.     }
  48.    
  49.  
  50. // Translate GREEK JS
  51. function greekcommands_to_slug(str) {
  52.  console.log('greekcommands_to_slug');
  53.  console.log(str);
  54. //https://gist.github.com/kostasx/7516158
  55.  
  56.  
  57.  //+++ MAYBE ADD a from--to for ΤΥΠΩΣΕ=>PRINT, ΔΩΣΕ->INPUT , ΧΑΡΤΙ-PAPER
  58.  
  59.  //str  = str.replace(/^\s+|\s+$/g, '') // TRIM WHITESPACE AT BOTH ENDS.
  60.  //         .toLowerCase();            // CONVERT TO LOWERCASE
  61.  
  62.  // BASIC COMMAND replace
  63.  const from = [ 'ΤΥΠΩΣΕ','ΧΑΡΤΙ','ΜΕΛΑΝΙ','ΦΛΑΣ','ΠΕΡΙΘΩΡΙΟ','ΓΙΑ','ΕΠΟΜΕΝΟ','ΠΗΓΑΙΝΕ','ΠΑΝΕΕΛΑ','ΕΠΙΣΤΡΟΦΗ','ΠΑΤΑΤΑ' ];
  64.  const to   = [ 'PRINT','PAPER','INK','FLASH','BORDER','FOR','NEXT','GOTO','GOSUB','RETURN','PRINT' ];
  65.  
  66.  for ( var i = 0; i < from.length; i++ ) {
  67.      console.log(from[i].toLowerCase());
  68.     while( str.indexOf( from[i].toLowerCase()) !== -1 ){
  69.         console.log(from[i]);
  70.         str = str.replace( from[i].toLowerCase(), to[i] );    // CONVERT GREEK CHARACTERS TO LATIN LETTERS
  71.  
  72.     }
  73.  
  74.  }
  75.  console.log('------greekcommands_to_slug');
  76.  console.log(str);
  77. return str;
  78. }//END of   function greekcommands_to_slug(str) {
  79.    
  80.    
  81. // Translate GREEK JS
  82. function greekstring_to_slug(str) {
  83.  
  84. //https://gist.github.com/kostasx/7516158
  85.  
  86.  
  87.  //first convert KEYWORDS
  88.  str=greekcommands_to_slug(str);
  89.  
  90.  //+++ MAYBE ADD a from--to for ΤΥΠΩΣΕ=>PRINT, ΔΩΣΕ->INPUT , ΧΑΡΤΙ-PAPER
  91.  
  92.  str  = str.replace(/^\s+|\s+$/g, '') // TRIM WHITESPACE AT BOTH ENDS.
  93.           .toLowerCase();            // CONVERT TO LOWERCASE
  94.  
  95.  
  96.  
  97.  console.log('greekstring_to_slug AFT greekcommands_to_slug');
  98.  console.log(str);
  99.  
  100.  
  101.  // maybe remove "ου", "ΟΥ", ... "??"...
  102.  const from = [  "ου", "ΟΥ", "Ού", "ού", "αυ", "ΑΥ", "Αύ", "αύ", "ευ", "ΕΥ", "Εύ", "εύ", "α", "Α", "ά", "Ά", "β", "Β", "γ", "Γ", "δ", "Δ", "ε", "Ε", "έ", "Έ", "ζ", "Ζ", "η", "Η", "ή", "Ή", "θ", "Θ", "ι", "Ι", "ί", "Ί", "ϊ", "ΐ", "Ϊ", "κ", "Κ", "λ", "Λ", "μ", "Μ", "ν", "Ν", "ξ", "Ξ", "ο", "Ο", "ό", "Ό", "π", "Π", "ρ", "Ρ", "σ", "Σ", "ς", "τ", "Τ", "υ", "Υ", "ύ", "Ύ", "ϋ", "ΰ", "Ϋ", "φ", "Φ", "χ", "Χ", "ψ", "Ψ", "ω", "Ω", "ώ", "Ώ" ];
  103.  const to   = [ "ou", "ou", "ou", "ou", "au", "au", "au", "au", "eu", "eu", "eu", "eu", "a", "a", "a", "a", "b", "b", "g", "g", "d", "d", "e", "e", "e", "e", "z", "z", "i", "i", "i", "i", "th", "th", "i", "i", "i", "i", "i", "i", "i", "k", "k", "l", "l", "m", "m", "n", "n", "ks", "ks", "o", "o", "o", "o", "p", "p", "r", "r", "s", "s", "s", "t", "t", "y", "y", "y", "y", "y", "y", "y", "f", "f", "x", "x", "ps", "ps", "o", "o", "o", "o" ];
  104.  
  105.  for ( var i = 0; i < from.length; i++ ) {
  106.  
  107.     while( str.indexOf( from[i]) !== -1 ){
  108.          
  109.         str = str.replace( from[i], to[i] );    // CONVERT GREEK CHARACTERS TO LATIN LETTERS
  110.  
  111.     }
  112.  
  113.  }
  114. return str;
  115. }//END of   function greekstring_to_slug(str) {
  116.  
  117.  
  118.    
  119.  
  120. /*
  121. window.onload = function() {
  122. //alert("Hello onload");
  123.  //editAreaLoader.getValue('text_entered');
  124.   document.getElementById('theForm').onsubmit = function() {
  125.     var txt = document.getElementById('text_entered');
  126.     txt.value = greekstring_to_slug(txt.value);
  127.     console.log("......document.getElementById('theForm').onsubmit");
  128.     //alert("Hello onsubmit 1");
  129.   };
  130. };
  131. */
  132.  
  133. </script>
  134.  
  135.  
  136. </head>
  137. <body>
  138. <!--    <form action="handle-submit.php" name="theForm" target="emulator_output" id="theForm" method="post" onsubmit="editAreaLoader.getValue('text_entered')">
  139. -->
  140.     <form action="handle-submit.php" name="theForm" target="emulator_output" id="theForm" method="post" onsubmit="myFunction();" >
  141. <textarea name="text_entered" id="text_entered" wrap="hard" >
  142. 10 PRINT "HELLO ΠΑΤΑΤΑ ΤΥΠΩΣΕ" 
  143. 20 INPUT "AA= ";a$
  144.  
  145. </textarea>
  146.         <!--<div id="div-submit" >----------------------------div-submit -->
  147.         <label for="name">ΟΝΟΜΑ ΣΧΟΛΕΙΟΥ (School):</label> <!--SchoolName -->
  148.         <input type="text" id="schoolname" name="schoolname" size=15>
  149.         <br>
  150.         <br> ΤΑΞΗ (Class):
  151.         <select name="taksi" id="taksi"> <!--Elementary Class -->
  152.             <option value="Α">Α</option>
  153.             <option value="Β">Β</option>
  154.             <option value="Γ">Γ</option>
  155.             <option value="Δ">Δ</option>
  156.             <option value="Ε">Ε</option>
  157.             <option value="ΣΤ">ΣΤ</option>
  158.         </select> ΤΜΗΜΑ (sub-class):
  159.         <select name="tmima" id="tmima"><!--Elementary SubClass -->
  160.             <option value="1">1</option>
  161.             <option value="2">2</option>
  162.         </select>
  163.         <BR>
  164.         <label for="name">ΟΝΟΜΑ(ΤΑ)/Names:</label><!--Student names -->
  165.         <input type="text" id="name" name="name" size=60>
  166.         <br>
  167.  
  168.         <br>
  169.         <input type="submit" value="ΥΠΟΒΟΛΗ">
  170.         <!--</div>------------------------------------------div-submit -->
  171.     </form>
  172.   <hr>
  173.  
  174. <!-- FUNCTIONS #################### -->
  175. <!--<script src="tinymce_lesson_js_footer.js" type="text/javascript"></script> -->
  176.  <script>/*
  177. window.onload = function() {
  178. alert("Hello onload END");
  179.  //editAreaLoader.getValue('text_entered');
  180.   document.getElementById('theForm').onsubmit = function() {
  181.     var txt = document.getElementById('text_entered');
  182.     txt.value = greekstring_to_slug(txt.value);
  183.     //alert("Hello onsubmit 1end");
  184.   };
  185. };
  186. */
  187.  
  188. </script>
  189.  
  190.  
  191.  
  192. </body>
  193. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement