|
|
|
| Есть такой JS
function pst3(sel, kto, msid, tag1, tag2)
{
var messageField = document.theForm.message;
var selStart = messageField.selectionStart;
var selEnd = messageField.selectionEnd;
var MsgVal = messageField.value;
var text = new String();
var step = new Number();
if(!sel && !tag1){
alert('Для вставки цитаты необходимо выделить нужное мышью.');
}
else{
if(kto){sel=kto+' пишет: \n'+'[quote]
'+sel+'[/quote]
';
}
messageField.focus();
if(document.selection){
document.theForm.document.selection.createRange().text
=
tag1+sel+document.theForm.document.selection.createRange().text+tag2;
}
else
{
if(selStart || messageField.selectionStart == '0'){
step = tag1.length + sel.length + tag2.length;
text = MsgVal.substring(0, selStart) + tag1 + sel;
text += MsgVal.substring(selStart, selEnd) + tag2;
text += MsgVal.substring(selEnd, MsgVal.length);
messageField.value = text;
messageField.selectionStart = selStart + selEnd + step;
messageField.selectionEnd = selEnd + step;
}}
if(msid){theForm.msgid.value = msid;}}}
function pst5()
{var URL = prompt("Введите адрес картинки. ВНИМАНИЕ: допустимые символы: буквы, цифры, точка, тильда, подчеркивание, косая черта, дефис","");
if (!URL || URL.indexOf('http://') == -1 || URL.indexOf(' ') != -1) {
alert('Ошиблись при вводе адреса!'); return;}
pst3(URL,'','','[img]','[/img]');}
function pst6()
{var URL = prompt("Введите ссылку с http или ftp","");
if (!URL || (URL.indexOf('http://') == -1 && URL.indexOf('ftp://') == -1) || URL.indexOf(' ') != -1) {alert('Ошиблись при вводе ссылки!');
return;}
var OP = prompt("Введите описание ссылки","");
if (!OP) {OP='click here';}pst3('','','','[url=+URL,]'+OP+'[/url]');}
|
Меня интересует функция pst6. Она выводит попап с формой ввода. В нее вводится ссылка и ее название. | |
|
|
|
|
|
|
|
для: xenon
(21.10.2006 в 11:18)
| | Хочу прикрутить ее вот сюда :
<?php
if (!isset($bbcode_form))
$bbcode_form = 'post';
if (!isset($bbcode_field))
$bbcode_field = 'req_message';
?>
<script type="text/javascript">
<!--
function insert_text(open, close)
msgfield = (document.all) ? document.
all.req_message : document.forms['<?php
echo $bbcode_form ?>']['<?php echo
$bbcode_field ?>'];
// IE support
if (document.selection && document.
selection.createRange)
{
msgfield.focus();
sel = document.selection.
createRange();
sel.text = open + sel.text + close;
msgfield.focus();
}
// Moz support
else if (msgfield.selectionStart ||
msgfield.selectionStart == '0')
{
var startPos = msgfield.selectionStart;
var endPos = msgfield.selectionEnd;
msgfield.value = msgfield.
value.substring(0, startPos) + open +
msgfield.value.substring(startPos, endPos)
+ close + msgfield.value.substring(endPos,
msgfield.value.length);
msgfield.selectionStart =
msgfield.selectionEnd = endPos + open.
length + close.length;
msgfield.focus();
}
// Fallback support for other browsers
else
{
msgfield.value += open + close;
msgfield.focus();
}
return;
}
-->
</script>
<div tyle="padding-top: 4px">
<input type="button" value=" B " name="B"
onclick="insert_text('[_b]','_[/b]')" />
<input type="button" value=" I " name="I"
onclick="insert_text('[_i]','[_/i]')" />
<input type="button" value=" U " name="U"
onclick="insert_text('[_u]','[_/u]')" />
<input type="button" value="http://"
name="Url" onclick="insert_text('[_url]',
'[_/url]')" />
<input type="button" value="Img" name="Img"
onclick="insert_text('[img]','[/img]')" />
<input type="button" value="Code"
name="Code" onclick="insert_text('[_code]',
'[_/code]')" />
<input type="button" value="Quote"
name="Quote" onclick="insert_text('[quote]
','[/quote]')" />
<select name='fcolor'
onmouseover="hstat('color')"
class='codebuttons'
onchange="insert_text('[color='+(this.
options[this.selectedIndex].value)+']','[/color]');this.selectedIndex=0;" >
<option value='0'>Цвет</option>
<option value='blue' style='color:blue' >Синий</option>
<option value='red' style='color:red' >Красный</option>
<option value='purple' style='color:purple' >Пурпур</option>
<option value='orange' style='color:orange' >Оранжевый</option>
<option value='yellow' style='color:yellow' >Жёлтый</option>
<option value='gray' style='color:gray' >Серый</option>
<option value='green' style='color:green' >Зелёный</option>
</select>
</div>
<div tyle="padding-top: 4px">
<?php
// Display the smiley set
require_once PUN_ROOT.'include/parser.php';
$smiley_dups = array();
$num_smilies = count($smiley_text);
for ($i = 0; $i < $num_smilies; ++$i)
{
// Is there a smiley at the current index?
if (!isset($smiley_text[$i]))
continue;
if (!in_array($smiley_img[$i], $smiley_dups))
echo "\t\t\t\t\t\t\t".'<a href="javascript:insert_text(\''.
$smiley_text[$i].'\', \'\');"><img src="img/smilies/'.$smiley_img[$i].
'" width="15" height="15" alt="'.
$smiley_text[$i].'" /></a>'."\n";
$smiley_dups[] = $smiley_img[$i];
}
?>
</div>
|
| |
|
|
|
|
|
|
|
для: xenon
(21.10.2006 в 11:23)
| | Вставлял первый JS в код и заменил функцию insert_text на pst6
<input type="button" value="http://" name="Url" onclick="insert_text('[_url]','[_/url]')" />
|
<input type="button" value="http://" name="Url" onclick="pst6()" />
|
В результате при нажатии на кнопку Url появляется попап, данные вводятся, но в форму они не заносятся.
Я с JS практически не знаком, делал все чисто логически. Может у кого будет время посмотреть, возможно ли вообще вставить функцию pst6 в вышеприведенный код? | |
|
|
|