Posted 27 января, 201410 yr comment_53014 Нужна помощь в следующем: хочу сделать на форуме подсчет символов в сообщению, т.е. в форме ответа, создания темы, быстрый ответ и прочее добавить скрипт подсчета символов в своем сообщению ( Я пишу сообщение и снизу к примеру пишет, сколько символов я написал ). Гуглил этот запрос, нашло только старые сообщения, не уверен в их работоспособности. Вот такой вот скрипт я нашел: <script type='text/javascript'> function counter(el) { var wrapper = document.createElement('DIV'); wrapper.innerHTML = el.value; var len = (wrapper.textContent || wrapper.innerText).length; document.getElementById('count').innerHTML = len; document.getElementById('kb').innerHTML = (len/1024).toFixed(2); } </script> Там еще подсчет веса, но это не так важно. Так вот, рабочий ли этот javascript, и как его применять? Вот мой ips_editor: <!-- RTE ON: $rte_mode --> {parse js_module="editor"} {parse addtohead="{$this->settings['css_base_url']}style_css/{$this->registry->output->skin['_csscacheid']}/ipb_editor.css" type="importcss"} <!--top--> <input type='hidden' name='{$editor_id}_wysiwyg_used' id='{$editor_id}_wysiwyg_used' value='0' /> <input type='hidden' name='editor_ids[]' value='{$editor_id}' /> <if test="$show_sidebar = IPSCookie::get('emoticon_sidebar')"></if> <div class='ips_editor <if test="$show_sidebar == '1' && $this->settings['_remove_emoticons'] == 0">with_sidebar</if>' id='editor_{$editor_id}'> <if test="$this->settings['_remove_emoticons'] == 0"> <div class='sidebar row1 altrow' id='{$editor_id}_sidebar' <if test="IPSCookie::get('emoticon_sidebar') != '1'">style='display: none'</if>> <h4><img src='{$this->settings['img_url']}/close_popup.png' alt='' id='{$editor_id}_close_sidebar' /><span>{$this->lang->words['emoticons_template_title']}</span></h4> <div id='{$editor_id}_emoticon_holder' class='emoticon_holder'></div> <div class='show_all_emoticons' id='{$editor_id}_showall_bar'> <input type='button' value='{$this->lang->words['show_all_emotes']}' id='{$editor_id}_showall_emoticons' class='input_submit emoticons' /> </div> </div> </if> <div id='{$editor_id}_controls' class='controls'> <ul id='{$editor_id}_toolbar_1' class='toolbar' style='display: none'> <li class='left'> <span id='{$editor_id}_cmd_removeformat' class='rte_control rte_button' title='{$this->lang->words['js_tt_noformat']}'><img src='{$this->settings['img_url']}/rte_icons/remove_formatting.png' alt='{$this->lang->words['js_tt_noformat']}' /></span> </li> <!--<li class='left'> <span id='{$editor_id}_cmd_togglesource' class='rte_control rte_button' title='{$this->lang->words['js_tt_htmlsource']}'><img src='{$this->settings['img_url']}/rte_icons/toggle_source.png' alt='{$this->lang->words['js_tt_htmlsource']}' /></span> </li>--> <li class='left'> <span id='{$editor_id}_cmd_otherstyles' class='rte_control rte_menu rte_special' title='{$this->lang->words['box_other_desc']}' style='display: none'>{$this->lang->words['box_other']}</span> </li> <li class='left'> <span id='{$editor_id}_cmd_fontname' class='rte_control rte_menu rte_font' title='{$this->lang->words['box_font_desc']}'>{$this->lang->words['box_font']}</span> </li> <li class='left'> <span id='{$editor_id}_cmd_fontsize' class='rte_control rte_menu rte_fontsize' title='{$this->lang->words['box_size_desc']}'>{$this->lang->words['box_size']}</span> </li> <li class='left'> <span id='{$editor_id}_cmd_forecolor' class='rte_control rte_palette' title='{$this->lang->words['js_tt_font_col']}'><img src='{$this->settings['img_url']}/rte_icons/font_color.png' alt='{$this->lang->words['js_tt_font_col']}' /></span> </li> <!--<li class='left'> <span id='{$editor_id}_cmd_backcolor' class='rte_control rte_palette' title='{$this->lang->words['js_tt_back_col']}'><img src='{$this->settings['img_url']}/rte_icons/background_color.png' alt='{$this->lang->words['js_tt_back_col']}' /></span> </li>--> <li class='right'> <span id='{$editor_id}_cmd_spellcheck' class='rte_control rte_button' title='{$this->lang->words['js_tt_spellcheck']}'><img src='{$this->settings['img_url']}/rte_icons/spellcheck.png' alt='{$this->lang->words['js_tt_spellcheck']}' /></span> </li> <li class='right'> <span id='{$editor_id}_cmd_r_small' class='rte_control rte_button' title='{$this->lang->words['js_tt_resizesmall']}'><img src='{$this->settings['img_url']}/rte_icons/resize_small.png' alt='{$this->lang->words['js_tt_resizesmall']}' /></span> </li> <li class='right'> <span id='{$editor_id}_cmd_r_big' class='rte_control rte_button' title='{$this->lang->words['js_tt_resizebig']}'><img src='{$this->settings['img_url']}/rte_icons/resize_big.png' alt='{$this->lang->words['js_tt_resizebig']}' /></span> </li> <li class='right sep'> <span id='{$editor_id}_cmd_help' class='rte_control rte_button' title='{$this->lang->words['js_tt_help']}'><a href='{parse url="app=forums&module=extras&section=legends&do=bbcode" base="public"}' title='{$this->lang->words['js_tt_help']}'><img src='{$this->settings['img_url']}/rte_icons/help.png' alt='{$this->lang->words['js_tt_help']}' /></a></span> </li> <li class='right sep'> <span id='{$editor_id}_cmd_undo' class='rte_control rte_button' title='{$this->lang->words['js_tt_undo']}'><img src='{$this->settings['img_url']}/rte_icons/undo.png' alt='{$this->lang->words['js_tt_undo']}' /></span> </li> <li class='right'> <span id='{$editor_id}_cmd_redo' class='rte_control rte_button' title='{$this->lang->words['js_tt_redo']}'><img src='{$this->settings['img_url']}/rte_icons/redo.png' alt='{$this->lang->words['js_tt_redo']}' /></span> </li> </ul> <ul id='{$editor_id}_toolbar_2' class='toolbar' style='display: none'> <li> <span id='{$editor_id}_cmd_bold' class='rte_control rte_button' title='{$this->lang->words['js_tt_bold']}'><img src='{$this->settings['img_url']}/rte_icons/bold.png' alt='{$this->lang->words['js_tt_bold']}' /></span> </li> <li> <span id='{$editor_id}_cmd_italic' class='rte_control rte_button' title='{$this->lang->words['js_tt_italic']}'><img src='{$this->settings['img_url']}/rte_icons/italic.png' alt='{$this->lang->words['js_tt_italic']}' /></span> </li> <li> <span id='{$editor_id}_cmd_underline' class='rte_control rte_button' title='{$this->lang->words['js_tt_underline']}'><img src='{$this->settings['img_url']}/rte_icons/underline.png' alt='{$this->lang->words['js_tt_underline']}' /></span> </li> <li class='sep'> <span id='{$editor_id}_cmd_strikethrough' class='rte_control rte_button' title='{$this->lang->words['js_tt_strike']}'><img src='{$this->settings['img_url']}/rte_icons/strike.png' alt='{$this->lang->words['js_tt_strike']}' /></span> </li> <li> <span id='{$editor_id}_cmd_subscript' class='rte_control rte_button' title='{$this->lang->words['js_tt_sub']}'><img src='{$this->settings['img_url']}/rte_icons/subscript.png' alt='{$this->lang->words['js_tt_sub']}' /></span> </li> <li class='sep'> <span id='{$editor_id}_cmd_superscript' class='rte_control rte_button' title='{$this->lang->words['js_tt_sup']}'><img src='{$this->settings['img_url']}/rte_icons/superscript.png' alt='{$this->lang->words['js_tt_sup']}' /></span> </li> <li> <span id='{$editor_id}_cmd_insertunorderedlist' class='rte_control rte_button' title='{$this->lang->words['js_tt_list']}'><img src='{$this->settings['img_url']}/rte_icons/unordered_list.png' alt='{$this->lang->words['js_tt_list']}' /></span> </li> <li class='sep'> <span id='{$editor_id}_cmd_insertorderedlist' class='rte_control rte_button' title='{$this->lang->words['js_tt_list']}'><img src='{$this->settings['img_url']}/rte_icons/ordered_list.png' alt='{$this->lang->words['js_tt_list']}' /></span> </li> <if test="removeemoticons:|:$this->settings['_remove_emoticons'] == 0"> <li> <span id='{$editor_id}_cmd_emoticons' class='rte_control rte_button' title='{$this->lang->words['js_tt_emoticons']}'><img src='{$this->settings['img_url']}/rte_icons/emoticons.png' alt='{$this->lang->words['js_tt_emoticons']}' /></span> </li> </if> <li> <span id='{$editor_id}_cmd_link' class='rte_control rte_palette' title='{$this->lang->words['js_tt_link']}'><img src='{$this->settings['img_url']}/rte_icons/link.png' alt='{$this->lang->words['js_tt_link']}' /></span> </li> <li> <span id='{$editor_id}_cmd_image' class='rte_control rte_palette' title='{$this->lang->words['js_tt_image']}'><img src='{$this->settings['img_url']}/rte_icons/picture.png' alt='{$this->lang->words['js_tt_image']}' /></span> </li> <li> <span id='{$editor_id}_cmd_email' class='rte_control rte_palette' title='{$this->lang->words['js_tt_email']}'><img src='{$this->settings['img_url']}/rte_icons/email.png' alt='{$this->lang->words['js_tt_email']}' /></span> </li> <li> <span id='{$editor_id}_cmd_ipb_quote' class='rte_control rte_button' title='{$this->lang->words['js_tt_quote']}'><img src='{$this->settings['img_url']}/rte_icons/quote.png' alt='{$this->lang->words['js_tt_quote']}' /></span> </li> <li> <span id='{$editor_id}_cmd_ipb_code' class='rte_control rte_button' title='{$this->lang->words['js_tt_code']}'><img src='{$this->settings['img_url']}/rte_icons/code.png' alt='{$this->lang->words['js_tt_code']}' /></span> </li> <li> <span id='{$editor_id}_cmd_media' class='rte_control rte_palette' title='{$this->lang->words['js_tt_media']}'><img src='{$this->settings['img_url']}/rte_icons/media.png' alt='{$this->lang->words['js_tt_media']}' /></span> </li> <li class='right'> <span id='{$editor_id}_cmd_justifyright' class='rte_control rte_button' title='{$this->lang->words['js_tt_right']}'><img src='{$this->settings['img_url']}/rte_icons/align_right.png' alt='{$this->lang->words['js_tt_right']}' /></span> </li> <li class='right'> <span id='{$editor_id}_cmd_justifycenter' class='rte_control rte_button' title='{$this->lang->words['js_tt_center']}'><img src='{$this->settings['img_url']}/rte_icons/align_center.png' alt='{$this->lang->words['js_tt_center']}' /></span> </li> <li class='right'> <span id='{$editor_id}_cmd_justifyleft' class='rte_control rte_button' title='{$this->lang->words['js_tt_left']}'><img src='{$this->settings['img_url']}/rte_icons/align_left.png' alt='{$this->lang->words['js_tt_left']}' /></span> </li> <li class='right sep'> <span id='{$editor_id}_cmd_indent' class='rte_control rte_button' title='{$this->lang->words['js_tt_indent']}'><img src='{$this->settings['img_url']}/rte_icons/indent.png' alt='{$this->lang->words['js_tt_indent']}' /></span> </li> <li class='right'> <span id='{$editor_id}_cmd_outdent' class='rte_control rte_button' title='{$this->lang->words['js_tt_outdent']}'><img src='{$this->settings['img_url']}/rte_icons/outdent.png' alt='{$this->lang->words['js_tt_outdent']}' /></span> </li> </ul> </div> <div id='{$editor_id}_wrap' class='editor'> <textarea name="{$form_field}" class="input_rte" id="{$editor_id}_textarea" rows="10" cols="60" tabindex="0">{$initial_content}</textarea> </div> </div> <!-- Toolpanes --> <script type="text/javascript"> //<![CDATA[ $('{$editor_id}_toolbar_1').show(); $('{$editor_id}_toolbar_2').show(); // Rikki: Had to remove <form>... </form> because Opera would see </form> and not pass the topic icons / hidden fields properly. Tried "</" + "form>" but when it is parsed, it had the same affect ipb.editor_values.get('templates')['link'] = new Template("<label for='#{id}_url'>{$this->lang->words['js_template_url']}</label><input type='text' class='input_text' id='#{id}_url' value='__' tabindex='10' /><label for='#{id}_urltext'>{$this->lang->words['js_template_link']}</label><input type='text' class='input_text _select' id='#{id}_urltext' value='{$this->lang->words['js_template_default']}' tabindex='11' /><input type='submit' class='input_submit' value='{$this->lang->words['js_template_insert_link']}' tabindex='12' />"); ipb.editor_values.get('templates')['image'] = new Template("<label for='#{id}_img'>{$this->lang->words['js_template_imageurl']}</label><input type='text' class='input_text' id='#{id}_img' value='__' tabindex='10' /><input type='submit' class='input_submit' value='{$this->lang->words['js_template_insert_img']}' tabindex='11' />"); ipb.editor_values.get('templates')['email'] = new Template("<label for='#{id}_email'>{$this->lang->words['js_template_email_url']}</label><input type='text' class='input_text' id='#{id}_email' tabindex='10' /><label for='#{id}_emailtext'>{$this->lang->words['js_template_link']}</label><input type='text' class='input_text _select' id='#{id}_emailtext' value='{$this->lang->words['js_template_email_me']}' tabindex='11' /><input type='submit' class='input_submit' value='{$this->lang->words['js_template_insert_email']}' tabindex='12' />"); ipb.editor_values.get('templates')['media'] = new Template("<label for='#{id}_media'>{$this->lang->words['js_template_media_url']}</label><input type='text' class='input_text' id='#{id}_media' value='__' tabindex='10' /><input type='submit' class='input_submit' value='{$this->lang->words['js_template_insert_media']}' tabindex='11' />"); ipb.editor_values.get('templates')['generic'] = new Template("<div class='rte_title'>#{title}</div><strong>{$this->lang->words['js_template_example']}</strong><pre>#{example}</pre><label for='#{id}_option' class='optional'>#{option_text}</label><input type='text' class='input_text optional' id='#{id}_option' tabindex='10' /><label for='#{id}_text' class='tagcontent'>#{value_text}</label><textarea class='input_text _select tagcontent' id='#{id}_text' tabindex='11' rows='4' cols='30' style='width: 98%' /></textarea><input type='submit' class='input_submit' value='{$this->lang->words['js_template_add']}' tabindex='12' />"); ipb.editor_values.get('templates')['toolbar'] = new Template("<ul id='#{id}_toolbar_#{toolbarid}' class='toolbar' style='display: none'>#{content}</ul>"); ipb.editor_values.get('templates')['button'] = new Template("<li><span id='#{id}_cmd_custom_#{cmd}' class='rte_control rte_button specialitem' title='#{title}'><img src='{$this->settings['img_url']}/rte_icons/#{img}' alt='' /></span></li>"); ipb.editor_values.get('templates')['menu_item'] = new Template("<li id='#{id}_cmd_custom_#{cmd}' class='specialitem clickable'>#{title}</li>"); ipb.editor_values.get('templates')['togglesource'] = new Template("<fieldset id='#{id}_ts_controls' class='submit' style='text-align: left'><input type='button' class='input_submit' value='{$this->lang->words['js_template_update']}' id='#{id}_ts_update' /> <a href='#' id='#{id}_ts_cancel' class='cancel'>{$this->lang->words['js_template_cancel_source']}</a></fieldset>"); ipb.editor_values.get('templates')['emoticons_showall'] = new Template("<input class='input_submit emoticons' type='button' id='#{id}_all_emoticons' value='{$this->lang->words['show_all_emoticons']}' />"); ipb.editor_values.get('templates')['emoticon_wrapper'] = new Template("<h4><span>{$this->lang->words['emoticons_template_title']}</span></h4><div id='#{id}_emoticon_holder' class='emoticon_holder'></div>"); // Add smilies into the mix ipb.editor_values.set( 'show_emoticon_link', <if test="$allow_sidebar">true<else />false</if> ); ipb.editor_values.set( 'emoticons', $H({ $smilies }) ); ipb.editor_values.set( 'bbcodes', $H({IPSLib::fetchBbcodeAsJson()}) ); ipb.vars['emoticon_url'] = "{$this->settings['emoticons_url']}"; ipb.editors[ '{$editor_id}' ] = new ipb.editor( '{$editor_id}', USE_RTE ); //]]> Насколько я помню, javascript нужно добавлять в конец, но как его применять, что бы подсчет символов отображался ( желательно там, где происходит восстановление сохранения ( Надписи в стиле "Последнее автосохранение: 13:05:53" ), можно с другой стороны, но не стоит зацикливаться на месту расположения, главное, что бы он работал ). Как бы я не колдовал над этим ips_editor, никаких изменений не происходило. Я даже удалял textarea, текст все равно вводился Edited 27 января, 201410 yr by sereshka23 Link to comment https://ipbmafia.ru/topic/6894-podschet-simvolov-v-soobsheniyu/ Share on other sites Больше вариантов
27 января, 201410 yr comment_53016 кеш обновлять надо ) Link to comment https://ipbmafia.ru/topic/6894-podschet-simvolov-v-soobsheniyu/?&do=findComment&comment=53016 Share on other sites Больше вариантов
27 января, 201410 yr comment_53017 sereshka23, Вот есть готовый web-mastera.com/demo/script-3 (не реклама) Могу внедрить в IPB, не бесплатно разумеется Link to comment https://ipbmafia.ru/topic/6894-podschet-simvolov-v-soobsheniyu/?&do=findComment&comment=53017 Share on other sites Больше вариантов
27 января, 201410 yr comment_53019 Точно не уверен, но кажется я видел хук. Link to comment https://ipbmafia.ru/topic/6894-podschet-simvolov-v-soobsheniyu/?&do=findComment&comment=53019 Share on other sites Больше вариантов
27 января, 201410 yr Author comment_53090 Искал, неодного хука не нашел. Кеш обновлял, все равно в форме отправки сообщения, как в быстрой, так и в расширенной, не было ВООБЩЕ никаких изменений. Не смотря на все удаления, которые я там делал, вставки, вообще 0 реакции -_-. sereshka23, Вот есть готовый web-mastera.com/demo/script-3 (не реклама) Могу внедрить в IPB, не бесплатно разумеется Я слишком жадный Link to comment https://ipbmafia.ru/topic/6894-podschet-simvolov-v-soobsheniyu/?&do=findComment&comment=53090 Share on other sites Больше вариантов
27 января, 201410 yr comment_53097 sereshka23, моё дело предложить, делайте сами Link to comment https://ipbmafia.ru/topic/6894-podschet-simvolov-v-soobsheniyu/?&do=findComment&comment=53097 Share on other sites Больше вариантов
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.