הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   מערכת BBCODE (https://hosts.co.il/forums/showthread.php?t=32655)

-roee- 11-10-06 11:24

מערכת BBCODE
 
שלום

אני לא מתמצא במיוחד ב JS אבל אני צריך שתדגימו לי איך אני בונה מערכת BBCODE
את החלק של ה PHP וה REPLACE אני יודע לבצע.

אני רק צריך שתדגימו לי איך אני עושה נגיד שאם לוחצים על BOTTOM אז זה יוסיף
קוד:

[B]/B]
יש מבין?
אני צריך רק דוגמא אחת ומהשאר אני אדע להסתדר.. חח או שלא..

תודה בכל מקרה

Elad-A 11-10-06 11:45

שים את זה ב HEAD:

PHP קוד:


<script type="text/javascript"
function 
addtoForm(openTagcloseTagtextAreaId){ /// Add tags code to textarea 
    
var txtAr document.getElementById(""+textAreaId), oRange 
    txtAr
.focus() 
    if (
document.selection && document.selection.createRange){ 
        
oRange=document.selection.createRange(); /// Create Range object form the selected Text 
        
if (oRange.parentElement()==txtAr){ /// Check if the parent of the Range object is our textarea 
         
oRange.textopenTag+oRange.text+closeTag /// add the tags before and after the selected text 
        

    }else if(
navigator.appName=="Netscape"){ 
        var 
txtLength parseInt(txtAr.textLength// fint the length of the selected text 
        
var selStart=txtAr.selectionStart /// find the start position 
        
var selEnd=txtAr.selectionEnd /// find the end position 
        
if (selEnd==|| selEnd==1){ 
            
selEnd=txtLength 
        

        var 
sect1 = (txtAr.value).substring(0,selStart/// text before the selected text 
        
var sect2 = (txtAr.value).substring(selStart,selEnd// the selected text 
        
var sect3 = (txtAr.value).substring(selEnd,txtLength/// text after the selected text 
        
txtAr.value sect1+openTag+sect2+closeTag+sect3 /// add the tags before and after the selected text 
        
txtAr.focus() 
    }else{ 
        return (
alert("your browser is not supported by us\ only Mozilla(NS6 & higher) AND IE\n thanks"),false
    } 


</script> 

וכדי להשתמש תעשה ככה:

PHP קוד:


<form action="<?=$PHP_SELF?>" method="post"> 
<input type="button" value="מודגש" onClick="addtoForm('[b]', '[/b]', 'elad')" /><br />
<textarea rows="5" name="text" id="elad" cols="36"></textarea><br>  
<input type="submit" value="Send" name="submit" >  
</form>

אני מקווה שזה מה שהתכוונת אליו..

-roee- 11-10-06 12:24

כן בערך רק תגיד מאיפה לקחת את זה כדי שאני ישאיר זכויות באתר שלי..

Elad-A 11-10-06 12:59

אם אני לא טועה יש את זה בוובמסטר אבל שם זה לא עבד..

meshuga 11-10-06 16:28

http://raswa.sbsil.net/works/bbcode/
תרגיש חופשי לקחת את הJS.(אני עשיתי, אני לא צריך שתשים זכויות...תהנה)
בחלק של הPHP, נאתגר אותך וניתן לך לעשות לבד...זה לא מסובך...preg_replace

נריה 11-10-06 16:54

כל זה לקחת?
<script type="text/javascript"> ......עד הסוף???
ואיך אפפשר להוסיף עוד אפשרויות כמו קו תחתי וכו'? אם תוכל להסביר את השיטה שיהיה אפשר לפתח את זה עוד לעוד אפשרויות??

Ben-Malka 11-10-06 17:02

http://benmalka.com/ADMIN/textpro.php
איזה קובץ חסר כאן בכדי שיעבוד ?

meshuga 11-10-06 17:17

חברה תלמדו לקרוא, צריך ידע בPHP וביטויים רגולרים. (הפונקציה preg_replace)...
בלי זה, אי אפשר לעשות את זה.
לא, אני לא הולך פה ללמד ולהראות מה אני עשיתי..אין לי זמן לזה ולא, לא לפנות אליי בפרטי.

-roee- 12-10-06 17:47

הצלחתי "הכל" חוץ מהזה של רשימה וגודל הפונט וצבע הפונט

אולי תתן דוגמא בבקשה?

Elad-A 12-10-06 18:54

http://www.webmaster.org.il/article.asp?id=173


כל הזמנים הם GMT +2. הזמן כעת הוא 14:07.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ