Obsah fóra
PravidláRegistrovaťPrihlásenie




Odpovedať na tému [ Príspevkov: 7 ] 
AutorSpráva
Offline

Užívateľ
Užívateľ
BBcode nejde

Registrovaný: 09.09.07
Prihlásený: 07.11.16
Príspevky: 3114
Témy: 233
Bydlisko: Nové Zámky
Príspevok NapísalOffline : 24.03.2008 15:19

Zdravim, do js sa rozumiem asi ako moja mama do hackingu :)

preliezol som phpbb kody zhora z dola,ale nejak neviem stale rozchodit to, ze ked oznacim v textareii text a tuknem na tlacitko, tak mi ho vlozi napr medzi text

ide len o to, ma nekdo nejaky primitivny script, kde by sa dalo taketo nastavit?? dalej spracovanie uz ok, php zvladam, ale toto nie...

ja som nasiel toto:

Kód:
<script language="JavaScript" type="text/javascript">
<!--
// bbCode control by
// subBlue design
// www.subBlue.com

// Startup variables
var imageTag = false;
var theSelection = false;

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);

// Helpline messages
b_help = "Bold text: [b]text[/b] (alt+b)";
i_help = "Italic text: [i]text[/i] (alt+i)";
u_help = "Underline text: [u]text[/u] (alt+u)";
q_help = "Quote text: [quote]text[/quote] (alt+q)";
c_help = "Code display: [code]code[/code]  alt+c)";
l_help = "List: [list]text[/list] (alt+l)";
o_help = "Ordered list: [list=]text[/list] (alt+o)";
p_help = "Image: [img]http://imageurl[/img] (alt+p)";
w_help = "URL: [url]http://url[/url] or [url=http://url]Text[/url] (alt+w)";
a_help = "Close all open bbCode tags";
s_help = "Font color: [color=red]text[/color]  Tip: you can also use color=#FF0000";
f_help = "Font size: [size=x-small]small text[/size]";

// Define the bbCode tags
bbcode = new Array();
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]');
imageTag = false;

// Shows the help messages in the helpline window
function helpline(help) {
   document.post.helpbox.value = eval(help + "_help");
}


// Replacement for arrayname.length property
function getarraysize(thearray) {
   for (i = 0; i < thearray.length; i++) {
      if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
         return i;
      }
   return thearray.length;
}

// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value) {
   thearray[ getarraysize(thearray) ] = value;
}

// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
   thearraysize = getarraysize(thearray);
   retval = thearray[thearraysize - 1];
   delete thearray[thearraysize - 1];
   return retval;
}


function checkForm() {
  formErrors = false;
  document.post.message.value = '';
   if (document.post.input.value.length < 2) {
      formErrors = 'Musíte zadať text príspevku!';
   }
   if (formErrors) {
      alert(formErrors);
      return false;
   } else {
     if (document.post.quick_quote.checked) {
        document.post.message.value = document.post.last_msg.value + '\r\n';
     }
     document.post.message.value += document.post.input.value;
     return true;
   }
}

function bbstyle(bbnumber) {
   var txtarea = document.post.input;

   txtarea.focus();
   donotinsert = false;
   theSelection = false;
   bblast = 0;

   if (bbnumber == -1) { // Close all open tags & default button names
      while (bbcode[0]) {
         butnumber = arraypop(bbcode) - 1;
         txtarea.value += bbtags[butnumber + 1];
         buttext = eval('document.post.addbbcode' + butnumber + '.value');
         eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
      }
      imageTag = false; // All tags are closed including image tags :D
      txtarea.focus();
      return;
   }

   if ((clientVer >= 4) && is_ie && is_win)
   {
      theSelection = document.selection.createRange().text; // Get text selection
      if (theSelection) {
         // Add tags around selection
         document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
         txtarea.focus();
         theSelection = '';
         return;
      }
   }
   else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
   {
      mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
      return;
   }

   // Find last occurance of an open tag the same as the one just clicked
   for (i = 0; i < bbcode.length; i++) {
      if (bbcode[i] == bbnumber+1) {
         bblast = i;
         donotinsert = true;
      }
   }

   if (donotinsert) {      // Close all open tags up to the one just clicked & default button names
      while (bbcode[bblast]) {
            butnumber = arraypop(bbcode) - 1;
            txtarea.value += bbtags[butnumber + 1];
            buttext = eval('document.post.addbbcode' + butnumber + '.value');
            eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
            imageTag = false;
         }
         txtarea.focus();
         return;
   } else { // Open tags

      if (imageTag && (bbnumber != 14)) {      // Close image tag before adding another
         txtarea.value += bbtags[15];
         lastValue = arraypop(bbcode) - 1;   // Remove the close image tag from the list
         document.post.addbbcode14.value = "Img";   // Return button back to normal state
         imageTag = false;
      }

      // Open tag
      txtarea.value += bbtags[bbnumber];
      if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
      arraypush(bbcode,bbnumber+1);
      eval('document.post.addbbcode'+bbnumber+'.value += "*"');
      txtarea.focus();
      return;
   }
   storeCaret(txtarea);
}

// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
   var selLength = txtarea.textLength;
   var selStart = txtarea.selectionStart;
   var selEnd = txtarea.selectionEnd;
   if (selEnd == 1 || selEnd == 2)
      selEnd = selLength;

   var s1 = (txtarea.value).substring(0,selStart);
   var s2 = (txtarea.value).substring(selStart, selEnd)
   var s3 = (txtarea.value).substring(selEnd, selLength);
   txtarea.value = s1 + open + s2 + close + s3;
   return;
}

// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
   if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

//-->
</script>

ale je to zbytocne zlozite a mam taky dojem, ze je tam kopa veci navyse :)
(je to z phpbb fora vytiahnute :) )


Offline

Užívateľ
Užívateľ
BBcode nejde

Registrovaný: 25.07.07
Prihlásený: 27.11.14
Príspevky: 217
Témy: 38
Bydlisko: Kálnica city
Príspevok NapísalOffline : 24.03.2008 15:23

neviem ci myslim na to na co ty, skus sa pozret na blueboard shoutboard ako maju vyriesene pridavanie smajlov.. ale ty asi budes potrebovat pridavanie slov z oboch stran


Offline

Užívateľ
Užívateľ
BBcode nejde

Registrovaný: 09.09.07
Prihlásený: 07.11.16
Príspevky: 3114
Témy: 233
Bydlisko: Nové Zámky
Príspevok Napísal autor témyOffline : 24.03.2008 15:30

no ved to, ze, dam neco do bloku, a stlacim tlacitko a prida okolo toho....

je to vlastne aku tu na fore :)
pozri si zdrojak, ked pises tu spravu, neco z toho nekdo JS zdatny vyhuta mozno :)
ale pre mna je to len kopa pismeniek :D







_________________
"It took a lot of work, but this latest Linux patch enables support for machines with 4096 CPUs, up from the old limit of 1024." "Do you have support for smooth full-screen flash video yet?" "No, but who uses that?"
- ak dlho neodpisujem do témy, zabudol som na ňu, takže ma upozornite SS, ak chcete moju odpoveď
Offline

Užívateľ
Užívateľ
Obrázok užívateľa

Registrovaný: 21.02.07
Prihlásený: 21.02.10
Príspevky: 3984
Témy: 96
Príspevok NapísalOffline : 24.03.2008 18:25

myslím že toto:
Kód:
function bbstyle(bbnumber) {
   var txtarea = document.post.message;
   txtarea.focus();
   donotinsert = false;
   theSelection = false;
   bblast = 0;
   if (bbnumber == -1) {
      while (bbcode[0]) {
         butnumber = arraypop(bbcode) - 1;
         txtarea.value += bbtags[butnumber + 1];
         buttext = eval('document.post.addbbcode' + butnumber + '.value');
         eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
      }
      imageTag = false;
      txtarea.focus();
      return;
   }
   if ((clientVer >= 4) && is_ie && is_win)
   {
      theSelection = document.selection.createRange().text;
      if (theSelection) {
         document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
         txtarea.focus();
         theSelection = '';
         return;
      }
   }
   else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
   {
      mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
      return;
   }
   for (i = 0; i < bbcode.length; i++) {
      if (bbcode[i] == bbnumber+1) {
         bblast = i;
         donotinsert = true;
      }
   }
   if (donotinsert) {
      while (bbcode[bblast]) {
            butnumber = arraypop(bbcode) - 1;
            txtarea.value += bbtags[butnumber + 1];
            buttext = eval('document.post.addbbcode' + butnumber + '.value');
            eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
            imageTag = false;
         }
         txtarea.focus();
         return;
   } else {
      if (imageTag && (bbnumber != 14)) {
         txtarea.value += bbtags[15];
         lastValue = arraypop(bbcode) - 1;
         document.post.addbbcode14.value = "Img";
         imageTag = false;
      }
      txtarea.value += bbtags[bbnumber];
      if ((bbnumber == 14) && (imageTag == false)) imageTag = 1;
      arraypush(bbcode,bbnumber+1);
      eval('document.post.addbbcode'+bbnumber+'.value += "*"');
      txtarea.focus();
      return;
   }
   storeCaret(txtarea);
}

ale vyznám sa do JS ako tvoja mama do hackingu ... :D


Offline

Užívateľ
Užívateľ
BBcode nejde

Registrovaný: 09.09.07
Prihlásený: 07.11.16
Príspevky: 3114
Témy: 233
Bydlisko: Nové Zámky
Príspevok Napísal autor témyOffline : 24.03.2008 22:57

noo, to je pekne, ale nejak tam neviidm, kde to tam vlastne vklada :D







_________________
"It took a lot of work, but this latest Linux patch enables support for machines with 4096 CPUs, up from the old limit of 1024." "Do you have support for smooth full-screen flash video yet?" "No, but who uses that?"
- ak dlho neodpisujem do témy, zabudol som na ňu, takže ma upozornite SS, ak chcete moju odpoveď
Offline

Užívateľ
Užívateľ
Obrázok užívateľa

Registrovaný: 21.02.07
Prihlásený: 21.02.10
Príspevky: 3984
Témy: 96
Príspevok NapísalOffline : 25.03.2008 8:27

by som povedal že toto je najdôležitejšie a okolo toho je len podstatný obal:
Kód:
   if (donotinsert) {
      while (bbcode[bblast]) {
            butnumber = arraypop(bbcode) - 1;
            txtarea.value += bbtags[butnumber + 1];
            buttext = eval('document.post.addbbcode' + butnumber + '.value');
            eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
            imageTag = false;
         }
         txtarea.focus();
         return;
   } else {
      if (imageTag && (bbnumber != 14)) {
         txtarea.value += bbtags[15];
         lastValue = arraypop(bbcode) - 1;
         document.post.addbbcode14.value = "Img";
         imageTag = false;
      }
      txtarea.value += bbtags[bbnumber];
      if ((bbnumber == 14) && (imageTag == false)) imageTag = 1;
      arraypush(bbcode,bbnumber+1);
      eval('document.post.addbbcode'+bbnumber+'.value += "*"');
      txtarea.focus();
      return;
   }



Offline

Užívateľ
Užívateľ
BBcode nejde

Registrovaný: 09.09.07
Prihlásený: 07.11.16
Príspevky: 3114
Témy: 233
Bydlisko: Nové Zámky
Príspevok Napísal autor témyOffline : 25.03.2008 13:23

no joo, to je len vytiahnute, a to ci to ma ten boal okolo, alebo ne, proste to nejde.... myslel som, ze je to viazane na name textarei alebo na jej class.. ale nieje..

nema to nekdo funkcne??







_________________
"It took a lot of work, but this latest Linux patch enables support for machines with 4096 CPUs, up from the old limit of 1024." "Do you have support for smooth full-screen flash video yet?" "No, but who uses that?"
- ak dlho neodpisujem do témy, zabudol som na ňu, takže ma upozornite SS, ak chcete moju odpoveď
Odpovedať na tému [ Príspevkov: 7 ] 


Podobné témy

 Témy  Odpovede  Zobrazenia  Posledný príspevok 
V tomto fóre nie sú ďalšie neprečítané témy. BBCode

v PHP, ASP

2

659

02.12.2007 9:51

pepek92 Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. bbcode

v Redakčné systémy

5

945

28.08.2009 16:50

nicram Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. bbcode

v PHP, ASP

2

548

05.11.2008 18:18

Unlink Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. BBcode Edit

v Redakčné systémy

9

858

23.10.2006 13:48

PCMark Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. wordwrap + bbcode

v PHP, ASP

2

354

24.02.2010 18:20

B.A.X.O Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. BBcode help :)

v PHP, ASP

4

397

17.10.2011 15:17

Lkopo Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Vyhladavanie v bbcode

v PHP, ASP

4

486

28.01.2008 9:16

stenley Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. 2 bbcode textarei

v JavaScript, VBScript, Ajax

7

654

20.01.2008 15:49

qacer Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. problem s bbcode

v PHP, ASP

8

496

05.07.2009 18:48

Tominator Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. free BBcode editor

v PHP, ASP

4

652

30.11.2009 20:46

pilná lama glama Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Signature BBCode Controller

v Redakčné systémy

0

724

14.10.2006 15:11

JanoF Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Signature BBCode Controller

v Redakčné systémy

0

588

14.10.2006 14:51

JanoF Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. wordwrap & bbcode

v PHP, ASP

13

679

18.01.2009 15:30

Tominator Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. TinyMCE - BBcode plugin

v Redakčné systémy

2

900

03.07.2008 12:36

Blackshadow Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. wordwrap & bbcode (url)

v PHP, ASP

0

346

27.09.2010 19:43

DeiForm Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Chyba v BBcode (image)

v Redakčné systémy

0

483

18.09.2007 22:55

palop Zobrazenie posledných príspevkov


Nemôžete zakladať nové témy v tomto fóre
Nemôžete odpovedať na témy v tomto fóre
Nemôžete upravovať svoje príspevky v tomto fóre
Nemôžete mazať svoje príspevky v tomto fóre

Skočiť na:  

Powered by phpBB Jarvis © 2005 - 2024 PCforum, webhosting by WebSupport, secured by GeoTrust, edited by JanoF
Ako väčšina webových stránok aj my používame cookies. Zotrvaním na webovej stránke súhlasíte, že ich môžeme používať.
Všeobecné podmienky, spracovanie osobných údajov a pravidlá fóra