[ Index ]

PHP Cross Reference of Nuke-Evolution v2.0.5

title

Body

[close]

/includes/ -> bbcode.js (source)

   1  b_help = "Bold: [B]text[/B]";
   2  i_help = "Italic: [I]text[/I]";
   3  u_help = "Under Line: [U]text[/U]";
   4  quote_help = "Quote: [quote]text[/quote]";
   5  code_help = "Code: [code]code[/code]";
   6  php_help = "PHP: [php]code[/php]";
   7  img_help = "Insert Image: [img]http://image path[/img]";
   8  fc_help = "Font Color: [color=red]text[/color] You can use HTML color=#FF0000";
   9  fs_help = "Font Size: [size=9]Very Small[/size]";
  10  ft_help = "Font type: [font=Andalus]text[/font]";
  11  rtl_help = "Make message box align from Right to Left";
  12  ltr_help = "Make message box align from Left to Right";
  13  mail_help = "Insert Email: [email]Email Here[/email]";
  14  url_help="Insert Web Page: [url=Page URL]Page name[/url]";
  15  right_help="set text align to right: [align=right]text[/align]";
  16  left_help="set text align to left: [align=left]text[/align]";
  17  center_help="set text align to center: [align=center]text[/align]";
  18  justify_help="justify text: [align=justify]text[/align]";
  19  marqr_help="Marque text to Right: [marq=right]text[/marq]";
  20  marql_help="Marque text to Left: [marq=left]text[/marq]";
  21  marqu_help="Marque text to up: [marq=up]text[/marq]";
  22  marqd_help="Marque text to down: [marq=down]text[/marq]";
  23  hr_help="Insert H-Line [hr]";
  24  video_help="Insert video file: [video width=# height=#]file URL[/video]";
  25  flash_help="Insert flash file: [flash width=# height=#]flash URL[/flash]";
  26  
  27  var bbcode = new Array();
  28  var theSelection = false;
  29  
  30  function helpline(form, field, help) {
  31      document.forms[form].elements["help"+field].value = eval(help + "_help");
  32      document.forms[form].elements["help"+field].readOnly = "true";
  33  }
  34  
  35  function emoticon(form, field, text) { BBCwrite(form, field, '', ' '+text+' ', true); }
  36  function BBChr(form, field) { BBCwrite(form, field, '', "[hr]", true); }
  37  function BBCdir(form, field, dirc) { document.forms[form].elements[field].dir=(dirc); }
  38  function BBCft(form, field, box) { BBCfont(form, field, "font", box); }
  39  function BBCfs(form, field, box) { BBCfont(form, field, "size", box); }
  40  function BBCfc(form, field, box) { BBCfont(form, field, "color", box); }
  41  function BBCfont(form, field, code, box) { BBCwrite(form, field, "["+code+"="+box.value+"]", "[/"+code+"]", true); }
  42  
  43  function BBCwmi(form, field, type) {
  44      if (type == 'img') { var URL = prompt("Please enter image URL","http://"); }
  45      else { var URL = prompt("Enter the Email Address",""); }
  46      if (URL == null) { return; }
  47      if (!URL) { return alert("Error : You didn't write the Address"); }
  48      BBCwrite(form, field, '', "["+type+"]"+URL+"[/"+type+"]", true);
  49  }
  50  
  51  function BBCode(form, field, code, img) {
  52      var type = img.name;
  53      if (BBCwrite(form, field, "["+code+"="+type+"]", "[/"+code+"]")) { return; }
  54      if (bbcode[code+type+form+field] == null) {
  55          ToAdd = "["+code+"="+type+"]";
  56          re = new RegExp(type+".(\\w+)$");
  57          img.src = img.src.replace(re, type+"1.$1");
  58          bbcode[code+type+form+field] = 1;
  59      } else {
  60          ToAdd = "[/"+code+"]";
  61          re = new RegExp(type+"1.(\\w+)$");
  62          img.src = img.src.replace(re, type+".$1");
  63          bbcode[code+type+form+field] = null;
  64      }
  65      BBCwrite(form, field, '', ToAdd, true);
  66  }
  67  
  68  function BBCcode(form, field, img) {
  69      var code = img.name;
  70      if (BBCwrite(form, field, "["+code+"]", "[/"+code+"]")) { return; }
  71      if (bbcode[form+field+code] == null) {
  72          ToAdd = "["+code+"]";
  73          re = new RegExp(code+".(\\w+)$");
  74          img.src = img.src.replace(re, code+"1.$1");
  75          bbcode[form+field+code] = 1;
  76      } else {
  77          ToAdd = "[/"+code+"]";
  78          re = new RegExp(code+"1.(\\w+)$");
  79          img.src = img.src.replace(re, code+".$1");
  80          bbcode[form+field+code] = null;
  81      }
  82      BBCwrite(form, field, '', ToAdd, true);
  83  }
  84  
  85  function BBCmm(form, field, type) {
  86      var URL = prompt("Enter the "+type+" file URL", "http://");
  87      if (URL == null) { return; }
  88      if (!URL) { return alert("Error: You didn't write the "+type+" file URL"); }
  89      var WS = prompt("Enter the "+type+" width", "250");
  90      if (WS == null) { return; }
  91      if (!WS) { WS = 250; }
  92      var HS = prompt("Enter the "+type+" height", "200");
  93      if (HS == null) { return; }
  94      if (!HS) { HS = 200; }
  95      BBCwrite(form, field, '', "["+type+" width="+WS+" height="+HS+"]"+URL+"[/"+type+"]", true);
  96  }
  97  
  98  function BBCurl(form, field) {
  99      var URL = prompt("Enter the URL", "http://");
 100      if (URL == null) { return; }
 101      if (!URL) { return alert("Error: You didn't write the URL "); }
 102      if (BBCwrite(form, field, "[url="+URL+"]", "[/url]")) { return; }
 103      var TITLE = prompt("Enter the page name", "Web Page Name");
 104      if (TITLE == null) { return; }
 105      var Add = "]"+URL;
 106      if (TITLE) { Add = "="+URL+"]"+TITLE; }
 107      BBCwrite(form, field, '', "[url"+Add+"[/url]", true);
 108  }
 109  
 110  function BBCwrite(form, field, start, end, force) {
 111      var textarea = document.forms[form].elements[field];
 112      if (textarea.caretPos) {
 113        textarea.focus();
 114          // Attempt to create a text range (IE).
 115          theSelection = document.selection.createRange().text;
 116          if (force || theSelection != '') {
 117              document.selection.createRange().text = start + theSelection + end;
 118              textarea.focus();
 119              return true;
 120          }
 121      } else if (typeof(textarea.selectionStart) != "undefined") {
 122          // Mozilla text range replace.
 123          var text = new Array();
 124          text[0] = textarea.value.substr(0, textarea.selectionStart);
 125          text[1] = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd-textarea.selectionStart);
 126          text[2] = textarea.value.substr(textarea.selectionEnd);
 127          caretPos = textarea.selectionEnd+start.length+end.length;
 128          if (force || text[1] != '') {
 129              textarea.value = text[0]+start+text[1]+end+text[2];
 130              if (textarea.setSelectionRange) {
 131                  textarea.focus();
 132                  textarea.setSelectionRange(caretPos, caretPos);
 133              }
 134              return true;
 135          }
 136      } else if (force) {
 137          // Just put it on the end.
 138          textarea.value += start+end;
 139          textarea.focus(textarea.value.length-1);
 140          return true;
 141      }
 142      return false;
 143  }
 144  
 145  function storeCaret(text) {
 146      if (text.createTextRange) text.caretPos = document.selection.createRange().duplicate();
 147  }
 148  
 149  function bbstyle(bbnumber) {
 150      return true;
 151  }


Generated: Wed Jun 6 11:38:01 2007 Cross-referenced by PHPXref 0.7