[Ликбез]

Форма входа
Логин:
Пароль:

Меню сайта


Скрипты и коды для юкоз - Форум аццкого кодера » Если вы пришли за помощью, то Вам сюда... » Скрипт для ЛС в аякс, как сделать для отправки пользователю?

Скрипт для ЛС в аякс, как сделать для отправки пользователю?
[16] likbezz [10.03.2012, 20:24]
Igor,
Quote (Igor)
Не понял smile
Quote (likbezz)
Кавычки (одинарные)
Это "(" или "{" или "<"?

? ... А что из этого можно с уверенностю назвать «кавычками» Ты что, издеваешься? )))
JavaScript. Вставка cпециальных cимволов в строку
Кавычка - «"» - двойная, «'» - одинарная.
...

Quote (Igor)
Кот смайлов -

Чей кот? )))
Смотри сколько тут кавычек:
Quote
<a onclick="emoticon('>(','message');return false;" rel="nofollow" href="javascript://">

- Замучаешься экранировать )
По этому и написал:
Quote (likbezz)
то бишь не очень удобно. Я это про смайлы.

- Можно сказать - совсем не удобно...
...

Quote (Igor)
Ниче не работает - при клике на ссылку аякс не открывается.

- Логично.
[17] Igor [10.03.2012, 20:52]
Quote (likbezz)
? ... А что из этого можно с уверенностю назвать «кавычками» Ты что, издеваешься? )))

Ну да smile Не понял какие.
Quote (likbezz)
Чей кот? )))

biggrin
Quote (likbezz)
<a onclick="emoticon('>(','message');return false;" rel="nofollow" href="javascript://">

Отэкранируй пожалуйста, а то я не совсем понял смысл.
Спасибо.[/code]

Добавлено (10.03.2012, 20:33)
---------------------------------------------

Quote (Igor)
<a onclick="emoticon('>(','message');return false;" rel="nofollow" href="javascript://">

Правильно будет так -
Code
<a onclick="emoticon(\'>('\,\'message\');return false;" rel="nofollow" href="javascript://">
?

Добавлено (10.03.2012, 20:49)
---------------------------------------------
Все, сделал, спасибо.

Добавлено (10.03.2012, 20:52)
---------------------------------------------
Только ниче не пашет,надо же эти смайлы еще и с текстовой формой привязать.
Вот что у меня получилось -

Code

var ucodes = {
  ls: function (pmuser) {
   new _uWnd('pmsend','Отправка сообщения', 502, 250, {
    alert: 1,
    modal: 1,
    resize: 1,
    nomove: 1,
    fadespeed: 500,
    maxh: 425,
    align: 0,
                         header: 1,
                         popup: 1,
    oncontent: function () {if(pmuser) $('#PMtoUser').attr('value',pmuser);}
   },
          '<a href="javascript://" onclick="ajaxPm.start();">Мои сообщения</a><br /><br /><div class="brucpmtopl"><div class="optblockpmtop" id="bodypmsend"><input id="PMtoUser" type="hidden" value=""><div style="margin: 0px 0px 10px 0px;">Тема: <input id="subject" style="width:98%" type="text"></div><div>Текст сообщения:<textarea onkeypress="ucodesru.ctrpost(event);" id="ucodesmessagepm" style="width:98%"></textarea></div><input type="button" value="Отправить сообщение" id="ucodespostmessagepm" onclick="ucodes.send();">   <span id="st"></span></div></div><tbody><tr><td class="sml1" align="center"><a onclick="emoticon(\'>(\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="angry" src="http://s44.ucoz.net/sm/1/angry.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\':D\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="biggrin" src="http://s44.ucoz.net/sm/1/biggrin.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\'B)\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="cool" src="http://s44.ucoz.net/sm/1/cool.gif" style="margin:0;padding:0;border:0;" alt=""></a></td></tr><tr><td class="sml1" align="center"><a onclick="emoticon(\': \'(\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="cry" src="http://s44.ucoz.net/sm/1/cry.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\'<_<\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="dry" src="http://s44.ucoz.net/sm/1/dry.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\'^_^\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="happy" src="http://s44.ucoz.net/sm/1/happy.gif" style="margin:0;padding:0;border:0;" alt=""></a></td></tr><tr><td class="sml1" align="center"><a onclick="emoticon(\':(\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="sad" src="http://s44.ucoz.net/sm/1/sad.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\':)\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="smile" src="http://s44.ucoz.net/sm/1/smile.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\':o\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="surprised" src="http://s44.ucoz.net/sm/1/surprised.gif" style="margin:0;padding:0;border:0;" alt=""></a></td></tr><tr><td class="sml1" align="center"><a onclick="emoticon(\':p\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="tongue" src="http://s44.ucoz.net/sm/1/tongue.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\'%)\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="wacko" src="http://s44.ucoz.net/sm/1/wacko.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\';)\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="wink" src="http://s44.ucoz.net/sm/1/wink.gif" style="margin:0;padding:0;border:0;" alt=""></a></td></tr><tr id="asmltrsS2pW" style="display: none;"><td id="allSmiles" nowrap="" align="center" colspan="3"><a onclick="new _uWnd(\'Sml\',\' \',-250,-350,{autosize:0,closeonesc:1,resize:0},{url:\'/index/35-1-0\'});return false;" rel="nofollow" href="javascript://">Все смайлы</a></td></tr></tbody>');
  },
  send: function () {
   $("#ucodespostmessagepm").attr({disabled: 1, value: "Отправить сообщение"});
   $("#st").html('Идет отправка...');
   s = $('#PMtoUser').val();
   subject = $('#subject').val();
   message = $('#ucodesmessagepm').val();
   $.get("/index/14-0-0-1", function (pm) {
    ssid = $("input[name='ssid']", pm).val();
    if ($("#secuImg", pm).size() > 0) {
     imgsec = $("#secuImg", pm).clone();
     seckey = $("input[name='seckey']", pm).val();
     new _uWnd('cap', 'Код с картинки', 300, 80, {
      autosize: 0,
      modal: 1,
      oncontent: function () {
       $("#capImgSpan").html(imgsec);
       $("#capcode").focus();
      }
     },
     '<span id="capImgSpan"></span> <input type="text" id="capcode" onkeyup="ucodes.sendsec()" maxlength="5">');
    } else {
    $.post("/index", {
     s: s,
     subject: subject,
     message: message,
                         ssid: ssid,
     a: 18
     },
     function (re) {
     var rTxt = $($(re).text()).text();
     if(rTxt.indexOf("успешно") > -1) {
     setTimeout('_uWnd.close("pmsend")', 500);
     _uWnd.alert(rTxt, 'Внимание', {
      w: 225,
      h: 75
     });
     } else {
     _uWnd.alert(rTxt, 'Внимание', {
      w: 225,
      h: 75
     });
     }
     });
    }
    $("#ucodespostmessagepm").attr({disabled: 0, value: "Отправить сообщение"});
    $("#st").empty();
    $("#ucodesmessagepm").empty();
   });
  },
  sendsec: function () {
   var code = $("#capcode").val();
   if (code.length == 5) {
    $.post("/index", {
     s: s,
     subject: subject,
     message: message,
     code: code,
                        ssid: ssid,
     seckey: seckey,
     a: 18
    },
    function (re) {
     var rTxt = $($(re).text()).text();
     if(rTxt.indexOf("успешно") > -1) {
     setTimeout('_uWnd.close("pmsend")', 500);
     _uWnd.close('cap');
     _uWnd.alert('Сообщение отправлено', 'Успех…', {
      w: 225,
      h: 75
     });
     } else {
      if(rTxt.indexOf("код б") > -1) {
      $('#secuImg').click();
      } else {
      _uWnd.close('cap');
      _uWnd.alert(rTxt, 'Внимание', {
       w: 225,
       h: 75
      });
      }
     }
    });
    $("#ucodespostmessagepm").attr({disabled: 0, value: "Отправить сообщение"});
    $("#st").empty();
    $("#ucodesmessagepm").empty();
   }
  },
  ctrpost: function (e) {
   e = e || window.event;
   if (e.keyCode == 10 || e.ctrlKey && e.keyCode == 13) ucodesru.postPmanswer();
  }
};

Как сделать чтоб при нажатии они появлялись в форме (она в скрипте) -
Code
Текст сообщения:<textarea onkeypress="ucodesru.ctrpost(event);" id="ucodesmessagepm" style="width:98%"></textarea></div><input type="button" value="Отправить сообщение" id="ucodespostmessagepm" onclick="ucodes.send();">   <span id="st"></span></div>

Помоги плз cry . Спасибо.
[18] likbezz [10.03.2012, 20:54]
Igor,
Quote (Igor)
Правильно будет так -

Вот-вот - и так все, лучше через блокнот - выстрой заменой.
...
[19] Igor [10.03.2012, 20:56]
likbezz, а что насчет этого:
Только ниче не пашет,надо же эти смайлы еще и с текстовой формой привязать.
Вот что у меня получилось -
Code

var ucodes = {
   ls: function (pmuser) {
    new _uWnd('pmsend','Отправка сообщения', 502, 250, {
     alert: 1,
     modal: 1,
     resize: 1,
     nomove: 1,
     fadespeed: 500,
     maxh: 425,
     align: 0,
                          header: 1,
                          popup: 1,
     oncontent: function () {if(pmuser) $('#PMtoUser').attr('value',pmuser);}
    },
           '<a href="javascript://" onclick="ajaxPm.start();">Мои сообщения</a><br /><br /><div class="brucpmtopl"><div class="optblockpmtop" id="bodypmsend"><input id="PMtoUser" type="hidden" value=""><div style="margin: 0px 0px 10px 0px;">Тема: <input id="subject" style="width:98%" type="text"></div><div>Текст сообщения:<textarea onkeypress="ucodesru.ctrpost(event);" id="ucodesmessagepm" style="width:98%"></textarea></div><input type="button" value="Отправить сообщение" id="ucodespostmessagepm" onclick="ucodes.send();">   <span id="st"></span></div></div><tbody><tr><td class="sml1" align="center"><a onclick="emoticon(\'>(\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="angry" src="http://s44.ucoz.net/sm/1/angry.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\':D\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="biggrin" src="http://s44.ucoz.net/sm/1/biggrin.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\'B)\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="cool" src="http://s44.ucoz.net/sm/1/cool.gif" style="margin:0;padding:0;border:0;" alt=""></a></td></tr><tr><td class="sml1" align="center"><a onclick="emoticon(\': \'(\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="cry" src="http://s44.ucoz.net/sm/1/cry.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\'<_<\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="dry" src="http://s44.ucoz.net/sm/1/dry.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\'^_^\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="happy" src="http://s44.ucoz.net/sm/1/happy.gif" style="margin:0;padding:0;border:0;" alt=""></a></td></tr><tr><td class="sml1" align="center"><a onclick="emoticon(\':(\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="sad" src="http://s44.ucoz.net/sm/1/sad.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\':)\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="smile" src="http://s44.ucoz.net/sm/1/smile.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\':o\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="surprised" src="http://s44.ucoz.net/sm/1/surprised.gif" style="margin:0;padding:0;border:0;" alt=""></a></td></tr><tr><td class="sml1" align="center"><a onclick="emoticon(\':p\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="tongue" src="http://s44.ucoz.net/sm/1/tongue.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\'%)\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="wacko" src="http://s44.ucoz.net/sm/1/wacko.gif" style="margin:0;padding:0;border:0;" alt=""></a></td><td class="sml1" align="center"><a onclick="emoticon(\';)\',\'message\');return false;" rel="nofollow" href="javascript://"><img title="wink" src="http://s44.ucoz.net/sm/1/wink.gif" style="margin:0;padding:0;border:0;" alt=""></a></td></tr><tr id="asmltrsS2pW" style="display: none;"><td id="allSmiles" nowrap="" align="center" colspan="3"><a onclick="new _uWnd(\'Sml\',\' \',-250,-350,{autosize:0,closeonesc:1,resize:0},{url:\'/index/35-1-0\'});return false;" rel="nofollow" href="javascript://">Все смайлы</a></td></tr></tbody>');
   },
   send: function () {
    $("#ucodespostmessagepm").attr({disabled: 1, value: "Отправить сообщение"});
    $("#st").html('Идет отправка...');
    s = $('#PMtoUser').val();
    subject = $('#subject').val();
    message = $('#ucodesmessagepm').val();
    $.get("/index/14-0-0-1", function (pm) {
     ssid = $("input[name='ssid']", pm).val();
     if ($("#secuImg", pm).size() > 0) {
      imgsec = $("#secuImg", pm).clone();
      seckey = $("input[name='seckey']", pm).val();
      new _uWnd('cap', 'Код с картинки', 300, 80, {
       autosize: 0,
       modal: 1,
       oncontent: function () {
        $("#capImgSpan").html(imgsec);
        $("#capcode").focus();
       }
      },
      '<span id="capImgSpan"></span> <input type="text" id="capcode" onkeyup="ucodes.sendsec()" maxlength="5">');
     } else {
     $.post("/index", {
      s: s,
      subject: subject,
      message: message,
                          ssid: ssid,
      a: 18
      },
      function (re) {
      var rTxt = $($(re).text()).text();
      if(rTxt.indexOf("успешно") > -1) {
      setTimeout('_uWnd.close("pmsend")', 500);
      _uWnd.alert(rTxt, 'Внимание', {
       w: 225,
       h: 75
      });
      } else {
      _uWnd.alert(rTxt, 'Внимание', {
       w: 225,
       h: 75
      });
      }
      });
     }
     $("#ucodespostmessagepm").attr({disabled: 0, value: "Отправить сообщение"});
     $("#st").empty();
     $("#ucodesmessagepm").empty();
    });
   },
   sendsec: function () {
    var code = $("#capcode").val();
    if (code.length == 5) {
     $.post("/index", {
      s: s,
      subject: subject,
      message: message,
      code: code,
                         ssid: ssid,
      seckey: seckey,
      a: 18
     },
     function (re) {
      var rTxt = $($(re).text()).text();
      if(rTxt.indexOf("успешно") > -1) {
      setTimeout('_uWnd.close("pmsend")', 500);
      _uWnd.close('cap');
      _uWnd.alert('Сообщение отправлено', 'Успех…', {
       w: 225,
       h: 75
      });
      } else {
       if(rTxt.indexOf("код б") > -1) {
       $('#secuImg').click();
       } else {
       _uWnd.close('cap');
       _uWnd.alert(rTxt, 'Внимание', {
        w: 225,
        h: 75
       });
       }
      }
     });
     $("#ucodespostmessagepm").attr({disabled: 0, value: "Отправить сообщение"});
     $("#st").empty();
     $("#ucodesmessagepm").empty();
    }
   },
   ctrpost: function (e) {
    e = e || window.event;
    if (e.keyCode == 10 || e.ctrlKey && e.keyCode == 13) ucodesru.postPmanswer();
   }
};

Как сделать чтоб при нажатии они появлялись в форме (она в скрипте) -
Code
Текст сообщения:<textarea onkeypress="ucodesru.ctrpost(event);" id="ucodesmessagepm" style="width:98%"></textarea></div><input type="button" value="Отправить сообщение" id="ucodespostmessagepm" onclick="ucodes.send();">   <span id="st"></span></div>

Помоги плз cry . Спасибо.
[20] likbezz [10.03.2012, 21:01]
Quote (Igor)
Как сделать чтоб при нажатии они появлялись в форме (она в скрипте) -
Code

Quote
<a onclick="emoticon('>(','ucodesmessagepm');return false;" rel="nofollow" href="javascript://">

...
[21] Igor [10.03.2012, 21:17]
likbezz, оъххх..спасибо огромнейшие!

Добавлено (10.03.2012, 21:17)
---------------------------------------------
likbezz, Только нихера не пашет!!!.. cranky crazy evil facepalm facepalm killed
Я сделал только один смайл,но он не ставитсо.

[22] likbezz [10.03.2012, 22:24]
Igor,
Quote (Igor)
Я сделал только один смайл,но он не ставитсо.

))) Не может быть)
Посмотри какой ID у поля. Пропиши такой же. Должен вставляться. ...
А, подожди, а сама функция emoticon есть?
Code
function emoticon(a,b){if(a!=''){var d=document,c=(b)?d.getElementById(b):d.getElementById('message');a=' '+a+' ';if(d.selection){c.focus();var e=c.value;var f=d.selection.createRange();if(f.text==''){f.text=a}else if(e.indexOf(f.text)!=-1){f.text=a+f.text}else{c.value=e+a}}else{c.value=c.value+a}}}

Что кажет консоль ошибок?
...
[23] Igor [10.03.2012, 22:32]
likbezz, Сори, все заработало, недоглядел одну фигню. спасибо большое.

Добавлено (10.03.2012, 22:32)
---------------------------------------------
likbezz,

Quote (likbezz)
А, подожди, а сама функция emoticon есть?

в этом и была ошибка. biggrin
[24] likbezz [10.03.2012, 22:33]
Igor,
Quote (Igor)
в этом и была ошибка

))) Ну вот, теперь ты знаешь как это делается )


Полная версия сайта