<?php 
/*
 * Interaction/functionJavascript.php
 * 
 * Copyright 2009, 2018 Pedro Quaresma <pedro@mat.uc.pt>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */

// Function javascript for the text area editor

?>



<script language="javascript" type="text/javascript" src="/editarea/edit_area/edit_area_compressor.php?plugins">
</script>

<script language="Javascript" type="text/javascript">
// initialisation
editAreaLoader.init({
id: "exemple_1"	// id of the textarea to transform		
      ,start_highlight: true	// if start with highlight
      ,allow_resize: "both"
      ,allow_toggle: true
      ,language: "en"
      ,syntax: "php"	
      });

editAreaLoader.init({
id: "exemple_2"	// id of the textarea to transform	
      ,start_highlight: true	
      ,font_size: "8"
      ,font_family: "verdana, monospace"
      ,allow_resize: "y"
      ,allow_toggle: false
      ,language: "fr"
      ,syntax: "css"	
      ,toolbar: "new_document, save, load, |, charmap, |, search, go_to_line, |, undo, redo, |, select_font, |, change_smooth_selection, highlight, reset_highlight, |, help"
      ,load_callback: "my_load"
      ,save_callback: "my_save"
      ,plugins: "charmap"
      ,charmap_default: "arrows"
      
      });

editAreaLoader.init({
id: "exemple_3"	// id of the textarea to transform		
      //,start_highlight: true	// if start with highlight
      //,font_size: "10"	
      ,allow_resize: "no"
      ,allow_toggle: true
      ,language: "de"
      ,syntax: "python"
      ,load_callback: "my_load"
      ,save_callback: "my_save"
      ,display: "later"
      ,replace_tab_by_spaces: 4
      ,min_height: 350
      });


// callback functions
function my_save(id, content){
  alert("Here is the content of the EditArea '"+ id +"' as received by the save callback function:\n"+content);
}

function my_load(id){
  editAreaLoader.setValue(id, "The content is loaded from the load_callback function into EditArea");
}

function test_setSelectionRange(id){
  editAreaLoader.setSelectionRange(id, 100, 150);
}

function test_getSelectionRange(id){
  var sel =editAreaLoader.getSelectionRange(id);
  alert("start: "+sel["start"]+"\nend: "+sel["end"]); 
}

function test_setSelectedText(id){
  text= "[REPLACED SELECTION]"; 
  editAreaLoader.setSelectedText(id, text);
}

function test_getSelectedText(id){
  alert(editAreaLoader.getSelectedText(id)); 
}
</script>
