Stránka: 1 z 1
| [ Príspevkov: 7 ] | |
Autor | Správa |
---|
Registrovaný: 09.09.07 Prihlásený: 07.11.16 Príspevky: 3114 Témy: 233 | 233 Bydlisko: Nové Zámky |
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 )
|
|
Registrovaný: 25.07.07 Prihlásený: 27.11.14 Príspevky: 217 Témy: 38 | 38 Bydlisko: Kálnica city |
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
|
|
Registrovaný: 09.09.07 Prihlásený: 07.11.16 Príspevky: 3114 Témy: 233 | 233 Bydlisko: Nové Zámky |
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
_________________ "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ď |
|
Registrovaný: 21.02.07 Prihlásený: 21.02.10 Príspevky: 3984 Témy: 96 | 96 |
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 ...
|
|
Registrovaný: 09.09.07 Prihlásený: 07.11.16 Príspevky: 3114 Témy: 233 | 233 Bydlisko: Nové Zámky |
noo, to je pekne, ale nejak tam neviidm, kde to tam vlastne vklada
_________________ "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ď |
|
Registrovaný: 21.02.07 Prihlásený: 21.02.10 Príspevky: 3984 Témy: 96 | 96 |
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; }
|
|
Registrovaný: 09.09.07 Prihlásený: 07.11.16 Príspevky: 3114 Témy: 233 | 233 Bydlisko: Nové Zámky |
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ď |
|
Stránka: 1 z 1
| [ Príspevkov: 7 ] | |
Podobné témy | Témy | Odpovede | Zobrazenia | Posledný príspevok |
---|
| v Redakčné systémy | 5 | 981 | 28.08.2009 16:50 nicram | | v PHP, ASP | 2 | 583 | 05.11.2008 18:18 Unlink | | v PHP, ASP | 2 | 695 | 02.12.2007 9:51 pepek92 | | v Redakčné systémy | 9 | 906 | 23.10.2006 13:48 PCMark | | v PHP, ASP | 2 | 397 | 24.02.2010 18:20 B.A.X.O | | v PHP, ASP | 4 | 449 | 17.10.2011 15:17 Lkopo | | v PHP, ASP | 13 | 724 | 18.01.2009 15:30 Tominator | | v Redakčné systémy | 2 | 949 | 03.07.2008 12:36 Blackshadow | | v PHP, ASP | 4 | 523 | 28.01.2008 9:16 stenley | | v JavaScript, VBScript, Ajax | 7 | 691 | 20.01.2008 15:49 qacer | | v PHP, ASP | 8 | 534 | 05.07.2009 18:48 Tominator | | v PHP, ASP | 4 | 720 | 30.11.2009 20:46 pilná lama glama | | v Redakčné systémy | 0 | 772 | 14.10.2006 15:11 JanoF | | v Redakčné systémy | 0 | 619 | 14.10.2006 14:51 JanoF | | v PHP, ASP | 0 | 380 | 27.09.2010 19:43 DeiForm | | v Redakčné systémy | 0 | 519 | 18.09.2007 22:55 palop |
|