Просмотр файла wwphpmaster1.03/www.phpedited.com/js/bb_code.php

Размер файла: 3.79Kb
<?php
////////////////////////////////////////////////////////////////////////////
//               -_- W|W PHP-master -_-                                   //
//                                                                        //
//                Copyright 2008 MyIE                                     //
//  Create and Design by -_- MyIE                                         //
//  Site (web)           -_- http://www.phpedited.com                     //
//  Site (wap)           -_- http://wap.phpedited.com                     //
//  E-mail (MyIE)        -_- [email protected]                           //
//  ICQ (MyIE)           -_- 952-11-78                                    //
//                                                                        //
//  Вы не имеете право убирать копирайт                                   //
//  оффициального сайта!                                                  //
//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 3 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, see <http://www.gnu.org/licenses/>.    //
////////////////////////////////////////////////////////////////////////////
?>
<script type="text/javascript">
<!--
function insert(aTag, eTag) {
  var input = document.forms['formular'].elements['msg'];
  input.focus();
  /* fur Internet Explorer */
  if(typeof document.selection != 'undefined') {
    /* Einfugen des Formatierungscodes */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    /* Anpassen der Cursorposition */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);      
    }
    range.select();
  }
  /* fur neuere auf Gecko basierende Browser */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Einfugen des Formatierungscodes */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    /* Anpassen der Cursorposition */
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* fur die ubrigen Browser */
  else
  {
    /* Abfrage der Einfugeposition */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfugen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Einfugen des Formatierungscodes */
    var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}
//-->
</script>