Войти
Меню :
js (301)
bbcode (4)



Blog (1953)
other (410)
php (390)
js (301)
html (153)
php book (148)
css (147)
пк (124)
html tags (63)
js tag (56)
windows (48)
js method (44)
jquery (43)
php array (39)
Показать еще :
ruweb.net (37)
text (37)
js date (33)
form html (30)
online (29)
link (26)
fonts (24)
js events (22)
dosite (22)
php file (21)
atom (20)
foto (20)
input (19)
database (19)
svg (18)
lingvo (18)
forum (18)
hosting (17)
php date (17)
mysql (17)
php img (16)
фото (16)
info (15)
android (15)
img (15)
php time (15)
color (15)
js url (14)
js time (14)
jsphp (14)
xiaomi (14)
notepad (14)
board (14)
yandex (13)
select (13)
знак (13)
htaccess (13)
table (13)
osclass (13)
$ server (12)
php path (12)
download (12)
vs code (11)
icon (11)
dw block (11)
html book (11)
keyboard (11)
css img (10)
paint (10)
mouse (10)
ось (10)
form (10)
js delete (10)
ftp (9)
hover (8)
iframe (8)
php url (7)
cookie (7)
comment (7)
list (6)
hey tag (6)
php get (6)
search (6)
js vars (6)
нок (6)
click (6)
canvas (6)
console (5)
js id (5)
value (5)
mb (5)
tag a (5)
js math (5)
heading (5)
year (5)
reg.ru (5)
web (5)
ok (5)
xml (5)
js file (5)
week (4)
day (4)
ssl (4)
adminka (4)
js img (4)
youtube (4)
php var (4)
ucoz (4)
scandir (4)
bbcode (4)
pages (4)
month (4)
vk (4)
2022 (4)
submit (4)
task (4)
js form (4)
word (4)
base64 (4)
symbols (4)
js hash (4)
news (4)
js book (4)
numbers (4)
games (4)
folder (4)
https (3)
file (3)
куб (3)
units (3)
captcha (3)
line (3)
php day (3)
js post (3)
рся (3)
aimp (3)
404 (3)
padding (3)
video (3)
domen (3)
akaso (2)
qr code (2)
tag hr (2)
kfc (2)
counter (2)
seo (2)
prompt (2)
src (2)
height (2)
sitemap (2)
details (2)
typeof (2)
blob (2)
google (2)
arrows (2)
atom 11 (1)
atom 10 (1)
atom 7 (1)
atom 9 (1)
atom 8 (1)
php 5 (1)
atom 6 (1)
php 17 (1)
atom 15 (1)
atom 14 (1)
atom 13 (1)
atom 16 (1)
atom 17 (1)
atom 12 (1)
php 27 (1)
php 30 (1)
php 26 (1)
php 25 (1)
php 23 (1)
php 24 (1)
php 28 (1)
php 38 (1)
php 41 (1)
php 4 (1)
php 22 (1)
cursor (1)
php 19 (1)
php 20 (1)
php 8 (1)
php 9 (1)
php 10 (1)
php 32 (1)
js no4 (1)
php 7 (1)
#html (1)
chart (1)
atom 3 (1)
atom 4 (1)
atom 2 (1)
atom 1 (1)
header (1)
php 40 (1)
php 3 (1)
php 33 (1)
replace (1)
php 31 (1)
php 34 (1)
php 18 (1)
atom 5 (1)
date (1)
aimp 2 (1)
aimp 1 (1)
aimp 3 (1)
php 44 (1)
php 45 (1)
php 13 (1)
php (1)
php 2 (1)
js 10 (1)
js 9 (1)
jino (1)
php 37 (1)
js 8 (1)
js 4 (1)
js 5 (1)
js 6 (1)
js 1 (1)
js 7 (1)
php 1 (1)
php 43 (1)
ftp 5 (1)
php 15 (1)
php 36 (1)
webp (1)
php 42 (1)
ftp 4 (1)
ftp 3 (1)
ftp 2 (1)
php 6 (1)
php 35 (1)
php 11 (1)
speed (1)
atom 20 (1)
php 16 (1)
ftp 1 (1)
scroll (1)
opera (1)
php 14 (1)
atom 18 (1)
archive (1)
atom 19 (1)
php 29 (1)
php 39 (1)
rutube (1)
php 12 (1)
втб (1)
php 21 (1)
нод (1)
font (1)
js 2 (1)
name (1)
smile (1)
js 3 (1)

BBcode в javascript

В общем-то функция BBcode в javascript ничем не отличается, от ранее написанной страницы о BBcode в php. Единственное отличие BBcode в javascript, что данный пример не использует массивы, а в функцию на каждую замену – отдельная строка с функцией replace

Преобразование BBcode в html в javascript

Для того, чтобы преобразовать BBcode в html в javascript, копируем все, что выделено внизу... вставляем туда, где это вам требуется...

заменяем название htmlToBBCode например на BBCodeTohtml ? html на ...например backhtml

Берем каждую строку, на примере первой:

html = html.replace(/<h2(.*?)>(.*?)<\/h2>/, "\n[h2]$2[/h2]\n");

И преобразуем её в такую:

backhtml = backhtml .replace( '/\[h2\](.*?)\[\/h2\]' , '<h2>$1</h2>' );

Я бы вам предложил готовую BBcode функцию javascript, но её нет у меня!

Ну а вот живая функция html в BBcode есть, которой непосредственно пользуюсь и использовали в наших комментах

Преобразование html в BBcode в javascript

В некоторых строках, где присутствует переменная httpDomen - для смайлов - заменяем на свой путь до папки.

Некоторые строки закомментированы(//) - это сделано потому, что не все преобразования мне требуются...

var htmlToBBCode = functionhtml {

html = html.replace(/<h2(.*?)>(.*?)<\/h2>/, "\n[h2]$2[/h2]\n");

html = html.replace(/<h3(.*?)>(.*?)<\/h3>/, "\n[h3]$2[/h3]\n");

html = html.replace(/<h4(.*?)>(.*?)<\/h4>/, "\n[h4]$2[/h4]\n");

html = html.replace(/<a(.*?)href="(.*?)"(.*?)>(.*?)<\/a>/gi, "[url=$2]$4[/url]");

html = html.replace(/<span(.*?)style="color:(.*?)"(.*?)>(.*?)<\/span>/gi, '[COLOR="$2"]$4[/COLOR]');

html = html.replace(/<img(.*?)src="httpDomen\/comments+1_4\/blocks\/_smaile\/(.*?).gif"(.*?)>/gi, "[$2]");

html = html.replace(/<img(.*?)src="httpDomen\/comments+1_4\/blocks\/_smaile_girl\/(.*?).gif"(.*?)>/gi, "[$2]");

html = html.replace(/<img(.*?)src="(.*?)"(.*?)>/gi, '[img]$2[/img]');

html = html.replace(/<red>(.*?)<\/red>/gi, '[red]$1[/red]');

html = html.replace(/<s>(.*?)<\/s>/gi, '[s]$1[/s]');

html = html.replace(/<l>(.*?)<\/l>/gi, '[l]$1[/l]');

html = html.replace(/<strong>(.*?)<\/strong>/gi, '[strong]$1[/strong]');

html = html.replace(/<em>(.*?)<\/em>/gi, '[em]$1[/em]');

html = html.replace(/<u>(.*?)<\/u>/gi, '[u]$1[/u]');

html = html.replace(/<sup>(.*?)<\/sup>/gi, '[sup]$1[/sup]');

html = html.replace(/<sub>(.*?)<\/sub>/gi, '[sub]$1[/sub]');

html = html.replace(/<iframe(.*?)src="https:\/\/www.youtube.com\/embed\/(.*?)"(.*?)><\/iframe>/gi, "[YOUTUBE]$2[/YOUTUBE]");

html = html.replace(/<br(.*?)>/gi, "\n");

//- if a paragraph opens on the same line as another one closes, insert an extra blank line

//- opening tag becomes two line breaks

//- closing tags are just removed

// html += html.replace(/<\/p><p/<\/p>\n<p/gi;

// html += html.replace(/<p[^>]*>/\n\n/gi;

// html += html.replace(/<\/p>//gi;

// html = html.replace(/<textarea(.*?)>(.*?)<\/textarea>/gmi, "\[code]$2\[\/code]");

// html = html.replace(/<b>/gi, "[b]");

// html = html.replace(/<i>/gi, "[i]");

// html = html.replace(/<u>/gi, "[u]");

// html = html.replace(/<\/b>/gi, "[/b]");

// html = html.replace(/<\/i>/gi, "[/i]");

// html = html.replace(/<\/u>/gi, "[/u]");

// html = html.replace(/<em>/gi, "[b]");

// html = html.replace(/<\/em>/gi, "[/b]");

// html = html.replace(/<strong>/gi, "[b]");

// html = html.replace(/<\/strong>/gi, "[/b]");

// html = html.replace(/<cite>/gi, "[i]");

// html = html.replace(/<\/cite>/gi, "[/i]");

// html = html.replace(/<font color="(.*?)">(.*?)<\/font>/gmi, "[color=$1]$2[/color]");

// html = html.replace(/<font color=(.*?)>(.*?)<\/font>/gmi, "[color=$1]$2[/color]");

// html = html.replace(/<link(.*?)>/gi, "");

// html = html.replace(/<li(.*?)>(.*?)<\/li>/gi, "[*]$2");

// html = html.replace(/<ul(.*?)>/gi, "[list]");

// html = html.replace(/<\/ul>/gi, "[/list]");

// html = html.replace(/<div>/gi, "\n");

// html = html.replace(/<\/div>/gi, "\n");

// html = html.replace(/<td(.*?)>/gi, " ");

// html = html.replace(/<tr(.*?)>/gi, "\n");

// html = html.replace(/<img(.*?)src="(.*?)"(.*?)>/gi, "[img]$2[/img]");

// html = html.replace(/<head>(.*?)<\/head>/gmi, "");

// html = html.replace(/<object>(.*?)<\/object>/gmi, "");

// html = html.replace(/<script(.*?)>(.*?)<\/script>/gmi, "");

// html = html.replace(/<style(.*?)>(.*?)<\/style>/gmi, "");

// html = html.replace(/<title>(.*?)<\/title>/gmi, "");

// html = html.replace(/<!--(.*?)-->/gmi, "\n");

// html = html.replace(/\/\//gi, "/");

// html = html.replace(/http:\//gi, "http://");

// html = html.replace(/<(?:[^>'"]*|(['"]).*?\1)*>/gmi, "");

// html = html.replace(/\r\r/gi, "");

// html = html.replace(/\[url=\//gi, "[url=");

// html = html.replace(/(\S)\n/gi, "$1 ");

return html;

}

Не стесняемся говорить спасибо!
О комментах : 05.11.2024
Свои комменты в ожидании переделки!
Когда сделаю не знаю!
Времени нет...
Друзья! Пожалуйста держите себя в рамках приличия!
Иначе сообщение будет удалено, вас в бан - все просто!
Но если, сил нет как хочется высказать всё, что вы думаете об этом, пожалуйста - комменты от Vk - форма ниже:
Помочь проекту DwWeb.ru

Поделиться ссылкой! C друзьями или врагами!

Этим вы очень поможете проекту! Заранее огромное спасибо!

Теги:
BBcode в javascript
ruweb
См. интсрукция по ruweb. dwweb.ru есть здесь:
Все соцсети в одном месте!
defense_js Разное :Игра "пятнашки"
Угадай страну по флагу

Кальклятор
Математика онлайн

Списки шифрования
Часы

Числа словами
Названия чисел(max=10305)
Графики

Qr код онлайн

Как сделать сайт?
Md5 онлайн
Sitemap.html
Все статьи авторские, при копироавании активная ссылка обязательна DwWeb.ru! © 2015 - 2025 Контакты. Лучший хостинг : RUWEB + помощь по RUWEB Сайт работает круглосуточно 24/7.
Страница загружена за : 0.045738 секунд.