Olen yrittänyt jo pitkään vääntää php chattiin bold, italic ja underline toimintoa... Sellaista, joka ei boldaisi koko tekstiä kun haluaa boldata yhden sanan.
Yritin kopioida toisesta chatista läppäisesti juttuja niin että se sallisi nuo edellä mainitut html koodit mutta tietenkään se ei ihan niinkään toiminut.
Chatin html sallimishommeli on eri tiedostossa kuin tekstikenttä, joka lähettää tekstin koodeineen chatin ruudulle ja ne molemmat tiedostot (joista koodinsallimisjutussa vaan se tekstiin liittyvä osa) on tässä liitteenä.
Minulle on oikeastaan ihan sama millaisella ratkaisukiekuralla ja kaakuralla tämä onnistuisi, haluan vaan ja ainoastaan että chatti vihdoin ja viimein toimii. Muuten se on varsin hyvä.
Tässä on chattiviestin lähetyssivu chat_room.tpl
<PCPIN:TPL name="main"> <!-- TOP BANNER AREA --> <iframe id="chatroom_top_banner" name="chatroom_top_banner" src="dummy.html" scrolling="No" frameborder="0"></iframe> <!-- BOTTOM BANNER AREA --> <iframe id="chatroom_bottom_banner" name="chatroom_bottom_banner" src="dummy.html" scrolling="No" frameborder="0"></iframe> <!-- USERLIST AREA --> <div id="chatroom_userlist"> <div id="chatroom_userlist_contents"> {LNG_CHAT_ROOM} "<span id="chatroom_userlist_room_name"></span>" <br /> <PCPIN:TPL name="room_selection" type="simplecondition" requiredvars="DISPLAY"> <table border="0" cellspacing="0" cellpadding="2"> <tr valign="middle"> <td align="left"> <select id="chatroom_userlist_room_selection"></select> </td> <td style="padding:0px; vertical-align:middle; text-align:left;"> <button style="width:23px;background-image:url(./pic/arrow_left_11x9.gif);background-repeat:no-repeat;background-position:center center;" onclick="switchChatRoom($('chatroom_userlist_room_selection').value, $('chatroom_userlist_room_selection').options[$('chatroom_userlist_room_selection').selectedIndex].password_protect)" alt="{LNG_ENTER_THIS_CHAT_ROOM}" title="{LNG_ENTER_THIS_CHAT_ROOM}"> </button> </td> </tr> </table> </PCPIN:TPL> <div id="chatroom_userlist_list"> <table cellspacing="0" cellpadding="0" border="0"> <tbody id="userlist_table_body"><!-- USERLIST GOES HERE --></tbody> </table> </div> </div> </div> <!-- CONTROLS AREA --> <div id="chatroom_controls"> <div id="chatroom_controls_contents"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td align="left" colspan="2"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td><button type="button" id="msg_bold_btn" style="width:23px;font-weight:900;" title="{LNG_BOLD}" onclick="invertCssProperty('main_input_textarea', 'font-weight', '700/500', true, this.id, '{LNG_BOLD_SHORT}*/{LNG_BOLD_SHORT}')" onfocus="blur()">{LNG_BOLD_SHORT}</button></td> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="1" height="1" /></td> <td><button type="button" id="msg_italic_btn" style="width:23px;font-style:italic;" title="{LNG_ITALIC}" onclick="invertCssProperty('main_input_textarea', 'font-style', 'italic/normal', true, this.id, '{LNG_ITALIC_SHORT}*/{LNG_ITALIC_SHORT}')" onfocus="blur()">{LNG_ITALIC_SHORT}</button></td> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="1" height="1" /></td> <td><button type="button" id="msg_underlined_btn" style="width:23px;text-decoration:underline;" title="{LNG_UNDERLINED}" onclick="invertCssProperty('main_input_textarea', 'text-decoration', 'underline/none', true, this.id, '{LNG_UNDERLINED_SHORT}*/{LNG_UNDERLINED_SHORT}')" onfocus="blur()">{LNG_UNDERLINED_SHORT}</button></td> <PCPIN:TPL name="fonts" type="simplecondition" requiredvars="FONTS"> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td> <span id="available_fonts_list" style="display:none">{FONTS}</span> <select id="message_font_select" title="{LNG_FONT_FAMILY}"></select> </td> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="1" height="1" /></td> <td id="message_fontsize_select_col" style="display:none"> <span id="available_font_sizes_list" style="display:none">{FONT_SIZES}</span> <select id="message_fontsize_select" title="{LNG_FONT_SIZE}"></select> </td> </PCPIN:TPL> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td><button id="message_colors_btn" type="button" style="width:32px;background-image:none;" onclick="openColorBox('main_input_textarea', 'color', this, 'outgoingMessageColor', false, 'background-color')" title="{LNG_MESSAGE_COLOR}" onfocus="blur()"></button></td> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td><button type="button" id="invert_timestamp_btn" style="width:23px;background-repeat:no-repeat;background-position:center center;" onclick="invertTimeStampView()" onfocus="blur()"></button></td> <PCPIN:TPL name="invert_sounds_btn" type="simplecondition" requiredvars="DISPLAY"> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td><button id="invert_sounds_btn" type="button" style="width:23px;background-image:url(./pic/sounds_active_15x15.gif);background-repeat:no-repeat;background-position:center center;" onclick="toggleSounds()" title="{LNG_SOUNDS}" onfocus="blur()"></button></td> </PCPIN:TPL> <PCPIN:TPL name="msg_attachment_btn" type="simplecondition" requiredvars="DISPLAY"> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td><button id="msg_attachment_btn" type="button" style="width:23px;background-image:url(./pic/attachment_15x15.gif);background-repeat:no-repeat;background-position:center center;" onclick="addMsgAttachment()" title="{LNG_ATTACH_FILE}" onfocus="blur()"></button></td> </PCPIN:TPL> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td><button id="smilies_btn" type="button" style="width:23px;background-image:url(./pic/smilie_15x15.gif);background-repeat:no-repeat;background-position:center center;" onclick="openSmilieBox('main_input_textarea', null, this, false)" title="{LNG_SMILIES}" onfocus="blur()"></button></td> <td width="100%"><img src="./pic/clearpixel_1x1.gif" width="1" height="1" alt="" /></td> <td><button style="width:23px;background-image:url(./pic/members_15x15.gif);background-repeat:no-repeat;background-position:center center;" onclick="openMemberlistWindow()" title="{LNG_MEMBERLIST}" onfocus="blur()"></button></td> <PCPIN:TPL name="your_profile_button" type="simplecondition" requiredvars="DISPLAY"> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td><button id="your_profile_button" style="width:23px;background-image:url({FORMLINK}?b_x=15&b_y=15&b_id={AVATAR_BID}&s_id={S_ID});background-repeat:no-repeat;background-position:center center;" onclick="openEditProfileWindow(currentUserId, 'own_profile')" title="{LNG_YOUR_PROFILE}" onfocus="blur()"></button></td> </PCPIN:TPL> <PCPIN:TPL name="admin_btn" type="simplecondition" requiredvars="DISPLAY"> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td><button style="width:23px;background-image:url(./pic/admin_18x18.gif);background-repeat:no-repeat;background-position:center center;" onclick="openAdminWindow()" title="{LNG_ADMINISTRATION_AREA}" onfocus="blur()"></button></td> </PCPIN:TPL> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td><button id="online_status_pulldown" style="width:23px;background-repeat:no-repeat;background-position:center center;" onclick="openOnlineStatusBox(this)" onfocus="blur()"></button></td> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td><button type="button" style="width:23px;background-image:url(./pic/help_18x18.gif);background-repeat:no-repeat;background-position:center center;" onclick="showHelpBox(this)" title="{LNG_HELP}" onfocus="blur()"></button></td> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td><button type="button" style="width:23px;background-image:url(./pic/close_red_18x18.gif);background-repeat:no-repeat;background-position:center center;" onclick="openExitBox(this)" title="{LNG_LEAVE_THIS_ROOM}" onfocus="blur()"></button></td> <td style="width:1px"><img src="./pic/clearpixel_1x1.gif" alt="" width="5" height="1" /></td> <td><button type="button" id="scroll_ctl_btn" style="width:11px;background-image:url(./pic/scroll_active_5x18.gif);background-repeat:no-repeat;background-position:center center;" onclick="setAutoScroll()" title="" onfocus="blur()"></button></td> </tr> </table> </td> </tr> <tr> <td width="1%" style="vertical-align:middle;padding-top:2px;"> <div id="attached_files" style="height:18px;overflow:auto;padding:0px;display:none;"></div> <textarea id="main_input_textarea" cols="1" rows="1" title="{LNG_TYPE_MESSAGE_HERE}" style="margin:0px" autocomplete="off"></textarea> </td> <td width="100%" style="vertical-align:bottom;text-align:left;padding-left:5px;padding-top:2px;padding-bottom:3px;"> <button id="mainSendMessageButton" type="button" style="width:50px; height:50px;" title="{LNG_SEND}" onfocus="blur()" onclick="postChatMessage($('main_input_textarea'))">{LNG_SEND}</button> </td> </tr> </table> </div> </div> <!-- MESSAGES AREA --> <div id="chatroom_messages" style="background-image:url({ROOM_BACKGROUND_IMAGE_URL})"> <div id="chatroom_messages_contents" style="position:absolute;top:0px;left:0px;"></div> </div> <!-- ONLINE STATUS SELECTION BOX --> <div id="online_status_selection_box" style="display:none"> <table border="0" cellspacing="0" cellpadding="2" width="1px" class="context_menu_table"> <tr> <td align="left" class="context_menu_table_header" colspan="3" nowrap="nowrap">{LNG_ONLINE_STATUS}</td> </tr> <tr title="{LNG_ONLINE_STATUS}: {LNG_ONLINE_STATUS_1}" class="context_menu_table_row" onmouseover="setCssClass(this, '.context_menu_table_hrow')" onmouseout="setCssClass(this, '.context_menu_table_row')" onclick="closeOnlineStatusBox(1, '{LNG_ONLINE_STATUS_1}')"> <td width="1%"><img id="online_status_1_pointer" src="./pic/clearpixel_1x1.gif" alt="" /></td> <td width="1%"><img src="./pic/online_status_1_10x10.gif" alt="" /></td> <td nowrap="nowrap"> {LNG_ONLINE_STATUS_1} </td> </tr> <tr title="{LNG_ONLINE_STATUS}: {LNG_ONLINE_STATUS_2}" class="context_menu_table_row" onmouseover="setCssClass(this, '.context_menu_table_hrow')" onmouseout="setCssClass(this, '.context_menu_table_row')" onclick="closeOnlineStatusBox(2, '{LNG_ONLINE_STATUS_2}')"> <td width="1%"><img id="online_status_2_pointer" src="./pic/clearpixel_1x1.gif" alt="" title="" /></td> <td width="1%"><img src="./pic/online_status_2_10x10.gif" alt="" /></td> <td nowrap="nowrap"> {LNG_ONLINE_STATUS_2} </td> </tr> <tr title="{LNG_ONLINE_STATUS}: {LNG_ONLINE_STATUS_3}" class="context_menu_table_row" onmouseover="setCssClass(this, '.context_menu_table_hrow')" onmouseout="setCssClass(this, '.context_menu_table_row')" onclick="closeOnlineStatusBox(3, '{LNG_ONLINE_STATUS_3}')"> <td width="1%"><img id="online_status_3_pointer" src="./pic/clearpixel_1x1.gif" alt="" title="" /></td> <td width="1%"><img src="./pic/online_status_3_10x10.gif" alt="" /></td> <td nowrap="nowrap"> {LNG_ONLINE_STATUS_3} </td> </tr> </table> </div> <!-- EXIT OPTIONS SELECTION BOX --> <div id="exit_selection_box" style="display:none"> <table border="0" cellspacing="0" cellpadding="2" width="1px" class="context_menu_table"> <tr> <td align="left" class="context_menu_table_header" colspan="3" nowrap="nowrap">{LNG_LEAVE_THIS_ROOM}</td> </tr> <PCPIN:TPL name="leave_room_link" type="simplecondition" requiredvars="DISPLAY"> <tr title="{LNG_LEAVE_THIS_ROOM}" class="context_menu_table_row" onmouseover="setCssClass(this, '.context_menu_table_hrow')" onmouseout="setCssClass(this, '.context_menu_table_row')" onclick="closeExitBox(-1)"> <td nowrap="nowrap" colspan="3" align="center"> {LNG_LEAVE_THIS_ROOM} </td> </tr> </PCPIN:TPL> <tr title="{LNG_LOG_OUT_OF_CHAT}" class="context_menu_table_row" onmouseover="setCssClass(this, '.context_menu_table_hrow')" onmouseout="setCssClass(this, '.context_menu_table_row')" onclick="closeExitBox(-2)"> <td nowrap="nowrap" colspan="3" align="center"> {LNG_LOG_OUT_OF_CHAT} </td> </tr> </table> </div> <!-- HELP BOX --> <div id="help_box" style="display:none"> <table border="0" cellspacing="0" cellpadding="2" width="1px" class="context_menu_table"> <tr> <td align="left" class="context_menu_table_header" colspan="3" nowrap="nowrap">{LNG_HELP}</td> </tr> <tr title="{LNG_CHAT_COMMANDS}" class="context_menu_table_row" onmouseover="setCssClass(this, '.context_menu_table_hrow')" onmouseout="setCssClass(this, '.context_menu_table_row')" onclick="closeHelpBox(1)"> <td width="1%"><img src="./pic/commands_20x14.png" alt="" /></td> <td nowrap="nowrap"> {LNG_CHAT_COMMANDS} </td> </tr> <tr title="{LNG_CALL_MODERATOR}" class="context_menu_table_row" onmouseover="setCssClass(this, '.context_menu_table_hrow')" onmouseout="setCssClass(this, '.context_menu_table_row')" onclick="closeHelpBox(2)"> <td width="1%"><img src="./pic/sos_20x14.png" alt="" /></td> <td nowrap="nowrap"> {LNG_CALL_MODERATOR} </td> </tr> <tr class="context_menu_table_row"> <td colspan="2" class="context_menu_table_separator_row"></td> </tr> <tr title="{LNG_ABOUT}" class="context_menu_table_row" onmouseover="setCssClass(this, '.context_menu_table_hrow')" onmouseout="setCssClass(this, '.context_menu_table_row')" onclick="closeHelpBox(0)"> <td colspan="2" nowrap="nowrap"> {LNG_ABOUT}... </td> </tr> </table> </div> <!-- HELP MESSAGES --> <div id="cmd_help_records" style="display:none"> <PCPIN:TPL name="cmd_help_records" type="simplecondition" requiredvars="CMD"> <span id="help_record_cmd_{CMD}">{TEXT}</span> </PCPIN:TPL> </div> <!-- COMMAND EXECUTION ERROR MESSAGES --> <div id="cmd_err_records" style="display:none"> <PCPIN:TPL name="cmd_err_records" type="simplecondition" requiredvars="CMD"> <span id="error_record_cmd_{CMD}">{TEXT}</span> </PCPIN:TPL> </div> <!-- POPUP BANNER AREA --> <div id="banner_popup" style="display:none"> <img src="./pic/close_18x18.gif" alt="{LNG_CLOSE_WINDOW}" title="{LNG_CLOSE_WINDOW}" style="cursor:pointer" onclick="hidePopupBanner()" /> <br /> <iframe id="banner_popup_frame" name="banner_popup_frame" src="dummy.html" scrolling="No" frameborder="0"></iframe> </div> <!-- COMMUNICATION INDICATOR --> <div id="CommunicationIndicator" style="position:absolute;display:none;"><img src="./pic/progress_16x16.gif" alt="" style="border:0px" id="CommunicationIndicatorImg" /></div> </PCPIN:TPL>
Tässä alhaalla taas puolestaan on saman sivun tarkemmat koodivänkäykset
ja juttu jonne haluan minun html juttuja sallittavaksi, chat_room.js
/** * Convert message body into HTML string * @param string body Message body * @return string */ function parseMessage(body) { var parsed=''; var msg_parts=null; var found=false; var pos=0; var tmp=''; var converted_parts=new Array(); if (typeof(body)=='string' && body!='') { msg_parts=body.split(' '); // B I U koodit // Convert URLs for (var i=0; i<msg_parts.length; i++) { if (msg_parts[i]!=' ') { tmp=msg_parts[i].toLowerCase(); if (tmp.indexOf(':')>0) { tmp=tmp.split(':', 2); if (tmp.length==2 && tmp[1]!='') { switch (tmp[0]) { // URI://... case 'acap' : case 'cap' : case 'crid' : case 'dict' : case 'dns' : case 'ed2k' : case 'file' : case 'ftp' : case 'gopher' : case 'http' : case 'https' : case 'irc' : case 'ircs' : case 'lastfm' : case 'mms' : case 'nntp' : case 'rsync' : case 'sftp' : case 'smb' : case 'snmp' : case 'ssh' : case 'telnet' : if (tmp[1].length>2 && 0==tmp[1].indexOf('//')) { // OK msg_parts[i]='<a target="_blank" href="'+formlink+'?external_url='+urlencode(msg_parts[i])+'" title="'+msg_parts[i]+'">'+htmlspecialchars(msg_parts[i])+'</a>'; converted_parts[i]=1; } break; // URI://... case 'aaa' : case 'aaas' : case 'about' : case 'aim' : case 'callto' : case 'cid' : case 'data' : case 'dav' : case 'fax' : case 'feed' : case 'go' : case 'imap' : case 'imaps' : case 'ldap' : case 'mailto' : case 'mailto' : case 'mid' : case 'msnim' : case 'news' : case 'nfs' : case 'pop' : case 'pop3' : case 'pops' : case 'pop3s' : case 'pres' : case 'sip' : case 'sips' : case 'skype' : case 'tel' : case 'urn' : case 'wais' : case 'xmpp' : case 'ymsgr' : if (tmp[1].length>1) { // OK msg_parts[i]='<a target="_blank" href="'+formlink+'?external_url='+urlencode(msg_parts[i])+'" title="'+htmlspecialchars(msg_parts[i])+'">'+htmlspecialchars(msg_parts[i])+'</a>'; converted_parts[i]=1; } break; } } } if (typeof(converted_parts[i])=='undefined' && 0==msg_parts[i].indexOf('www.') && msg_parts[i].length>=9) { // HTTP link begins with "www." msg_parts[i]='<a target="_blank" href="'+formlink+'?external_url='+urlencode('http://'+msg_parts[i])+'" title="'+htmlspecialchars(msg_parts[i])+'">'+htmlspecialchars(msg_parts[i])+'</a>'; converted_parts[i]=1; } } } // Convert smilies for (var i=0; i<msg_parts.length; i++) { if (typeof(converted_parts[i])=='undefined') { found=false; if (msg_parts[i]!='') { for (var code in SmilieList.SmilieList) { if (msg_parts[i]==code) { msg_parts[i]='<img src="'+SmilieList.SmilieList[code].source+'" alt="'+code+'" title="'+code+'" />'; found=true; break; } } if (found==false) { msg_parts[i]=htmlspecialchars(msg_parts[i]); } } } body=msg_parts.join(' '); } parsed=body; } return parsed; } /** * Display a message * @param string author Message author * @param string message Message body * @param string css_properties Message CSS properties * @param boolean show_date If TRUE (default), then date will be displayed before message * @param int timestamp Message post time (UNIX timestamp) * @param object tgt_window Window handler to display message in. Default: main chat window. * @param int author_id Optional. ID of message author * @param boolean do_focus Optional. If TRUE, then window will get focus after displaying the message * @param array attachments Optional. Message attachments * @param int privacy Privacy level * @param string target_user_id Optional. ID of message target user */ function displayMessage(author, message, css_properties, show_date, timestamp, tgt_window, author_id, do_focus, attachments, privacy, target_user_id) { if (typeof(tgt_window)=='undefined') { tgt_window=window; } var tgt_doc=tgt_window.document; var author_span=null; var date_span=null; var msg_span=null; var sp=null; var pair=null; var css_attr_name=''; var css_attr_value=''; var css_array=null; var now=new Date(); if (typeof(message)=='string' && message!='' || attachments && attachments.length>0) { if ((typeof(show_date)!='boolean' || show_date) && typeof(timestamp)=='number' && timestamp>0) { // Message timestamp date_span=tgt_doc.createElement('SPAN'); date_span.id='date_span_'+(++timestampSpansIndex); timestampSpans.push(date_span.id); // Keep array small (100 ids max) if (timestampSpans.length>100) { timestampSpans.splice(0, timestampSpans.length-100); } date_span.innerHTML='['+htmlspecialchars(date(dateFormat, timestamp))+'] '; if (defaultMessageColor!='') { date_span.style.color='#'+defaultMessageColor; } $('chatroom_messages_contents', tgt_doc).appendChild(date_span); if (displayTimeStamp) { date_span.style.display=''; } else { date_span.style.display='none'; } } if (typeof(author)=='string' && author!='') { author_span=tgt_doc.createElement('SPAN'); if (typeof(author_id)=='number') { author_span.innerHTML= '<a href=":" onclick="showUserOptionsBox('+author_id+', this.title); return false;" oncontextmenu="showUserOptionsBox('+author_id+'); return false;" title="'+coloredToPlain(author, true)+'">' +coloredToHTML(author) +'</a>'; } else { author_span.innerHTML='<b>'+coloredToHTML(author)+'</b>'; } if (typeof(privacy)=='number' && typeof(target_user_id)=='number' && target_user_id>0 && UserList.getRecord(target_user_id)) { if (privacy==1) { // "Whispered to" message author_span.innerHTML+=' '+getLng('whispered_message').split('[USER]').join('<a href=":" onclick="showUserOptionsBox('+target_user_id+', this.title); return false;" oncontextmenu="showUserOptionsBox('+target_user_id+'); return false;" title="'+coloredToPlain(UserList.getRecord(target_user_id).Nickname, true)+'">' +coloredToHTML(UserList.getRecord(target_user_id).Nickname) +'</a>' ); } else { // "Sayd to" message author_span.innerHTML+=' '+getLng('said_message').split('[USER]').join('<a href=":" onclick="showUserOptionsBox('+target_user_id+', this.title); return false;" oncontextmenu="showUserOptionsBox('+target_user_id+'); return false;" title="'+coloredToPlain(UserList.getRecord(target_user_id).Nickname, true)+'">' +coloredToHTML(UserList.getRecord(target_user_id).Nickname) +'</a>' ); } } if (defaultMessageColor!='') { author_span.style.color='#'+defaultMessageColor; } $('chatroom_messages_contents', tgt_doc).appendChild(author_span); sp=tgt_doc.createElement('SPAN'); if (defaultMessageColor!='') { sp.style.color='#'+defaultMessageColor; } sp.innerHTML=' : '; $('chatroom_messages_contents', tgt_doc).appendChild(sp); } msg_span=tgt_doc.createElement('SPAN'); if (defaultMessageColor!='') { msg_span.style.color='#'+defaultMessageColor; } // Parse CSS attributes if (typeof(css_properties)=='string' && css_properties!='') { pair=null; css_attr_name=''; css_attr_value=''; css_array=css_properties.split(';'); msg_span.style.setCssProperty=function(name, value) { eval('this.'+name+'=\''+value+'\''); }; for (var i=0; i<css_array.length; i++) { css_array[i]=trimString(css_array[i]); if (css_array[i]!='' && -1!=css_array[i].indexOf(':')) { pair=css_array[i].split(':'); if (pair.length==2) { pair[0]=trimString(pair[0]); pair[1]=trimString(pair[1]); if (pair[0]!='' && pair[1]!='') { css_attr_name=cssToJs(pair[0]); if (css_attr_name!='') { msg_span.style.setCssProperty(css_attr_name, pair[1]); // Apply fontSize for all spans if (css_attr_name=='fontSize') { author_span.style.fontSize=pair[1]; if (typeof(sp)!='undefined' && sp) { sp.style.fontSize=pair[1]; } if (date_span && typeof(date_span.style)=='object' && date_span.style) { date_span.style.fontSize=pair[1]; } } } } } } } msg_span.style.setCssProperty=null; } // Display attachments for (var i in attachments) { message+=' ' +'<a href="'+formlink+'?s_id='+htmlspecialchars(s_id)+'&b_id='+urlencode(attachments[i]['binaryfile_id'])+'&filename='+urlencode(attachments[i]['filename'])+'" target="_blank" title="'+htmlspecialchars(getLng('attachment')+': '+attachments[i]['filename'])+'">' +'<img src="./pic/attachment_10x10.png" title="'+htmlspecialchars(getLng('attachment'))+'" alt="'+htmlspecialchars(getLng('attachment'))+'" />' +htmlspecialchars(attachments[i]['filename']) +'</a>'; } msg_span.innerHTML=nl2br(message)+'<br />'; $('chatroom_messages_contents', tgt_doc).appendChild(msg_span); if (tgt_window.AutoScroll) { try { $('chatroom_messages', tgt_doc).scrollTop=$('chatroom_messages', tgt_doc).scrollHeight; } catch (e) { msg_span.scrollIntoView(false); } } if (typeof(do_focus)=='boolean' && do_focus==true) { tgt_window.focus(); } } } /** * Post a message * @param object inputElement Message input element * @param string type Message type * @param string offline Offline flag * @param string target_user_id ID of message target user * @param string target_room_id ID of message target room * @param string privacy Privacy level * @param boolean no_focus If TRUE, then message input element will not become a focus. Default: FALSE */ function postChatMessage(inputElement, type, offline, target_user_id, target_room_id, privacy, no_focus) { // Check flood protection if (MessageDelay>0 && unixTimeStamp()-lastPostedMessageTime<MessageDelay) { return false; } lastPostedMessageTime=unixTimeStamp(); if (typeof(inputElement)=='object' && inputElement && typeof(inputElement.value)=='string') { var msg_body=trimString(inputElement.value); var tmp=null; if (inputElement.addMsgHistorie) { inputElement.addMsgHistorie(); } inputElement.value=''; var msg_src=parseCommands(msg_body); var ctl_msg_args=null; msg_src_txt=msg_src[0]; if (typeof(msg_src[1])!='undefined' && msg_src[1]!=null) { type=msg_src[1]; } if (typeof(msg_src[2])!='undefined' && msg_src[2]!=null) { target_room_id=msg_src[2]; } if (typeof(msg_src[3])!='undefined' && msg_src[3]!=null) { target_user_id=msg_src[3]; } if (typeof(msg_src[4])!='undefined' && msg_src[4]!=null) { privacy=msg_src[4]; } if (msg_src_txt!='' || MsgAttachments && MsgAttachments.length>0) { if (typeof(type)=='undefined' || type==null) type=3001; if (typeof(offline)=='undefined' || offline==null) offline='n'; if (typeof(target_user_id)=='undefined' || target_user_id==null) target_user_id=0; if (typeof(target_room_id)=='undefined' || target_room_id==null) target_room_id=currentRoomID; if (typeof(privacy)=='undefined' || privacy==null) privacy=0; // Get CSS properties var css_properties=new Array(); var css_property=''; if (type==3001 && inputElement.style) { // ... color css_property=inputElement.style.color.toLowerCase(); if (css_property.substring(0, 4)=='rgb(') { css_property=css_property.substring(4); css_property=css_property.substring(0, css_property.length-1); tmp=css_property.split(','); if (tmp.length==3) { css_property='#'+decHex(trimString(tmp[0]), 2)+decHex(trimString(tmp[1]), 2)+decHex(trimString(tmp[2]), 2); } else { css_property=''; } } if (css_property=='' || css_property.length!=6 && css_property.length!=7) { css_property='#'+outgoingMessageColor; } else if (css_property.length==6) { css_property='#'+css_property; } css_properties['color']=css_property; // ... font-weight css_property=inputElement.style.fontWeight; if (css_property!='') { css_properties['font-weight']=css_property; } // ... font-style css_property=inputElement.style.fontStyle; if (css_property!='') { css_properties['font-style']=css_property; } // ... text-decoration css_property=inputElement.style.textDecoration; if (css_property!='') { css_properties['text-decoration']=css_property; } // ... font-family css_property=inputElement.style.fontFamily; if (css_property!='') { css_properties['font-family']=css_property; } // ... font-size css_property=inputElement.style.fontSize; if (css_property!='') { css_properties['font-size']=css_property; } } MessageQueue.addRecordOut(type, offline, unixTimeStamp(), target_user_id, target_room_id, privacy, msg_src_txt.substring(0, messageLengthMax), css_properties); // Send message to server startUpdater(true); } if (typeof(no_focus)!='boolean' || no_focus==true) { inputElement.focus(); } } }
Mod. korjasi kooditagit!
Hei, suosittelen tutustumaan johonkin WYSIWYG - editoriin, esim TinyMce:
Koodisi on kohtuuttoman pitkä ja sekava, ja kysymyksestä en ihan ymmärrä, onko jokin tietty kohta ongelmana vai tulitko vain toivomaan, että joku jaksaisi ottaa selvää tuosta sotkusta ja tekisi koko homman puolestasi.
Aihe on jo aika vanha, joten et voi enää vastata siihen.