PageRenderTime 49ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/movil/js/general06.js

https://bitbucket.org/jonarano/joneame
JavaScript | 677 lines | 517 code | 90 blank | 70 comment | 130 complexity | b61047cc63c9455a9cb09db1d12b02d0 MD5 | raw file
Possible License(s): AGPL-1.0
  1. /*******************
  2. VOTES FUNCTIONS
  3. BASIC FUNCTIONS
  4. ************************************/
  5. function jonea(user, id, htmlid, md5) {
  6. var url = base_url + "backend/jonea.php";
  7. var content = "id=" + id + "&user=" + user + "&md5=" + md5;
  8. url = url + "?" + content;
  9. disable_vote_link(id, "espera...", '#adcee9');
  10. $.getJSON(url,
  11. function(data) {
  12. parseLinkAnswer(htmlid, data);
  13. }
  14. );
  15. }
  16. function joneo_aleatorio(user, id, htmlid, md5) {
  17. var url = base_url + "backend/aleatorio.php";
  18. var content = "id=" + id + "&user=" + user + "&md5=" + md5;
  19. url = url + "?" + content;
  20. disable_vote_link(id, "lloneandoo!", '#adcee9');
  21. $.getJSON(url,
  22. function(data) {
  23. parseLinkAnswer(htmlid, data);
  24. parsealeatorioLinkAnswer(htmlid,data); // cambia contadores de votos aleatorios
  25. }
  26. );
  27. }
  28. function karga_mezuak(userid, md5) {
  29. var url = base_url + "backend/mezuak.php";
  30. var content = "id=" + userid + "&md5=" +md5;
  31. url = url + "?" + content;
  32. $.getJSON(url,
  33. function(data) {
  34. ErantzunaProzesatu(userid, data);
  35. }
  36. );
  37. setTimeout('karga_mezuak("'+userid+'", "'+md5+'")', 40000);
  38. }
  39. function idatzi_mezuak(zer) {
  40. $('#mezuak').html('<span>'+zer+'</span>');
  41. }
  42. function ErantzunaProzesatu (id, link) {
  43. if (link.error || id != link.id) {
  44. idatzi_mezuak(".. error al actualizar los datos ..");
  45. alert("Error: "+link.error);
  46. return false;
  47. }
  48. idatzi_mezuak(link.mezuberri);
  49. return false;
  50. }
  51. /************************
  52. * Leer los mensajes
  53. ************************/
  54. function irakurri_mezua(mezuid, userid, md5, mota, eg) {
  55. var url = base_url + "backend/mezuak_ikusi.php";
  56. var content = "id=" + userid + "&md5=" +md5 + "&mid=" +mezuid+"&mota=" +mota+"&eg=" +eg;
  57. url = url + "?" + content;
  58. $.ajax({
  59. url: url,
  60. dataType: "html",
  61. success: function(html) {
  62. idatzi_mezuguztia(html, mezuid);
  63. }
  64. });
  65. }
  66. function ezabatu_mezua(mezuid, userid, md5, mota) {
  67. var url = base_url + "backend/ezabatu_mezua.php";
  68. var content = "id=" + userid + "&md5=" +md5 + "&mid=" +mezuid+"&mota=" +mota;
  69. url = url + "?" + content;
  70. // Ocultamos
  71. document.getElementById('mezuak'+mezuid).style.display = 'none';
  72. $.ajax({
  73. url: url,
  74. dataType: "html",
  75. success: function(html) {
  76. $('#mezuak'+mezuid).html('no data');
  77. }
  78. });
  79. }
  80. function clk(f, id) {
  81. f.href=base_url + 'backend/go.php?id=' + id;
  82. return true;
  83. }
  84. function idatzi_mezuguztia(zer, id) {
  85. $('#mezuak'+id).html(zer);
  86. }
  87. function ProzesatuMezua(id, link, mezuid)
  88. {
  89. if (link.error || id != link.id) {
  90. idatzi_mezuguztia(".. error al actualizar los datos ..", mezuid);
  91. alert("Error: "+link.error);
  92. return false;
  93. }
  94. idatzi_mezuguztia(link.mezuberri, mezuid);
  95. return false;
  96. }
  97. function votar_comentario(user, id, value) {
  98. var url = base_url + "backend/comentario_voto.php";
  99. var content = "id=" + id + "&user=" + user + "&value=" + value;
  100. var myid = 'comment-'+id;
  101. url = url + "?" + content;
  102. $.getJSON(url,
  103. function(data) {
  104. if (data.error) {
  105. alert("Error: "+data.error);
  106. return false;
  107. } else {
  108. $('#vc-'+id).html(data.votes+"");
  109. $('#vk-'+id).html(data.karma+"");
  110. if (data.image.length > 0) {
  111. $('#c-votes-'+id).html('<img style="background: url(\'/img/iconos/sprite.png\') '+data.image+' no-repeat;" src="/img/estructura/pixel.gif" width="12" height="8"/>');
  112. }
  113. }
  114. }
  115. );
  116. }
  117. function poll_comment_vote(user, id, value) {
  118. var url = base_url + "backend/poll_comment_vote.php";
  119. var content = "id=" + id + "&user=" + user + "&value=" + value;
  120. var myid = 'comment-'+id;
  121. url = url + "?" + content;
  122. $.getJSON(url,
  123. function(data) {
  124. if (data.error) {
  125. alert("Error: "+data.error);
  126. return false;
  127. } else {
  128. $('#vc-'+id).html(data.votes+"");
  129. $('#vk-'+id).html(data.karma+"");
  130. if (data.image.length > 0) {
  131. $('#c-votes-'+id).html('<img style="background: url(\'/img/iconos/sprite.png\') '+data.image+' no-repeat;" src="/img/estructura/pixel.gif" width="12" height="8"/>');
  132. }
  133. }
  134. }
  135. );
  136. }
  137. function votar_corto(user, id, value) {
  138. var url = base_url + "backend/corto_voto.php";
  139. var content = "id=" + id + "&user=" + user + "&value=" + value;
  140. var myid = 'comment-'+id;
  141. url = url + "?" + content;
  142. $.getJSON(url,
  143. function(data) {
  144. if (data.error) {
  145. alert("Error: "+data.error);
  146. return false;
  147. } else {
  148. $('#vc-'+id).html(data.votes+"");
  149. $('#vk-'+id).html(data.karma+"");
  150. if (data.image.length > 0) {
  151. $('#c-votes-'+id).html('<img style="background: url(\'/img/iconos/sprite.png\') '+data.image+' no-repeat;" src="/img/estructura/pixel.gif" width="12" height="8"/>');
  152. }
  153. }
  154. }
  155. );
  156. }
  157. function votar_notita(user, id, value) {
  158. var url = base_url + "backend/notita_voto.php";
  159. var content = "id=" + id + "&user=" + user + "&value=" + value;
  160. var myid = 'comment-'+id;
  161. url = url + "?" + content;
  162. $.getJSON(url,
  163. function(data) {
  164. if (data.error) {
  165. alert("Error: "+data.error);
  166. return false;
  167. } else {
  168. $('#vc-'+id).html(data.votes+"");
  169. $('#vk-'+id).html(data.karma+"");
  170. if (data.image.length > 0) {
  171. $('#c-votes-'+id).html('<img style="background: url(\'/img/iconos/sprite.png\') '+data.image+' no-repeat;" src="/img/estructura/pixel.gif" width="12" height="8"/>');
  172. }
  173. }
  174. }
  175. );
  176. }
  177. function disable_vote_link(id, mess, background) {
  178. $('#a-va-' + id).html('<span>'+mess+'</span>');
  179. $('#a-va-' + id).css('background', background);
  180. }
  181. function parseLinkAnswer (id, link) {
  182. $('#problem-' + id).hide();
  183. if (link.error || id != link.id) {
  184. disable_vote_link(id, "vaya :-(", '#adcee9');
  185. alert("Error: "+link.error);
  186. return false;
  187. }
  188. votes = parseInt(link.votes)+parseInt(link.anonymous);
  189. if ($('#a-votes-' + link.id).html() != votes) {
  190. $('#a-votes-' + link.id).hide();
  191. $('#a-votes-' + link.id).html(votes+"");
  192. $('#a-votes-' + link.id).fadeIn('slow');
  193. }
  194. $('#a-neg-' + link.id).html(link.negatives+"");
  195. $('#a-usu-' + link.id).html(link.votes+"");
  196. $('#a-ano-' + link.id).html(link.anonymous+"");
  197. $('#a-karma-' + link.id).html(link.karma+"");
  198. if (link.value > 0) {
  199. if (link.aleatorio_valor == "no") {
  200. disable_vote_link(link.id, "&#161;biibaaa!", '#FFFFFF');
  201. } else {
  202. disable_vote_link(link.id, "valió " + link.aleatorio_valor, '#FFFFFF');
  203. }
  204. } else if (link.value < 0) {
  205. disable_vote_link(link.id, ":-(", '#FFFFFF');
  206. }
  207. return false;
  208. }
  209. function parsealeatorioLinkAnswer(id, link) {
  210. if (link.error || id != link.id) {
  211. disable_vote_link(id, "vaya :-(", '#adcee9');
  212. alert("Error: "+link.error);
  213. return false;
  214. }
  215. if (link.aleatorios_positivos == 0) color = '#aaa';
  216. else color = '';
  217. $('#a-ale_pos-' + link.id).html(link.aleatorios_positivos+"");
  218. document.getElementById('a-ale_pos-'+link.id).style.color = color;
  219. $('#a-ale_neg-' + link.id).html(link.aleatorios_negativos+"");
  220. if (link.aleatorios_negativos == 0) color = '';
  221. else color = 'red';
  222. document.getElementById('a-ale_neg-'+link.id).style.color = color;
  223. return false;
  224. }
  225. function securePasswordCheck(field) {
  226. /*La función comprueba si la clave contiene al menos
  227. *ocho caracteres e incluye mayúsculas, minúsculas y números.
  228. *
  229. * Function checks if the password provided contains at least
  230. * eight chars, including upper, lower and numbers.
  231. *
  232. * jotape - jplopez.net */
  233. if (field.value.length > 5 && field.value.match("^(?=.{6,})(?=(.*[a-z].*))(?=(.*[A-Z0-9].*)).*$", "g")) {
  234. if (field.value.match("^(?=.{8,})(?=(.*[a-z].*))(?=(.*[A-Z].*))(?=(.*[0-9].*)).*$", "g")) {
  235. field.className = "verde";
  236. } else {
  237. field.className = "amarillo";
  238. }
  239. } else {
  240. field.className = "rojo";
  241. }
  242. return false;
  243. }
  244. function checkEqualFields(field, against) {
  245. if(field.value == against.value) {
  246. field.className = "verde"
  247. } else {
  248. field.className = "rojo"
  249. }
  250. return false;
  251. }
  252. function enablebutton (button, button2, target) {
  253. var string = target.value;
  254. if (button2 != null) {
  255. button2.disabled = false;
  256. }
  257. if (string.length > 0) {
  258. button.disabled = false;
  259. } else {
  260. button.disabled = true;
  261. }
  262. }
  263. function checkfield (type, form, field) {
  264. var url = base_url + 'backend/checkfield.php?type='+type+'&name=' + encodeURIComponent(field.value);
  265. $.get(url,
  266. function(html) {
  267. if (html == 'OK') {
  268. $('#'+type+'checkitvalue').html('<br/><span style="color:black">"' + encodeURI(field.value) + '": ' + html + '</span>');
  269. form.submit.disabled = '';
  270. } else {
  271. $('#'+type+'checkitvalue').html('<br/><span style="color:red">"' + encodeURI(field.value) + '": ' + html + '</span>');
  272. form.submit.disabled = 'disabled';
  273. }
  274. }
  275. );
  276. return false;
  277. }
  278. function check_checkfield(fieldname, mess) {
  279. field = document.getElementById(fieldname);
  280. if (field && !field.checked) {
  281. alert(mess);
  282. // box is not checked
  283. return false;
  284. }
  285. }
  286. function report_problem(frm, user, id, md5 /*id, code*/) {
  287. if (frm.ratings.value == 0)
  288. return;
  289. if (! confirm("¿Estás seguro de querer votar '" + frm.ratings.options[frm.ratings.selectedIndex].text +"'?") ) {
  290. frm.ratings.selectedIndex=0;
  291. return false;
  292. }
  293. var content = "id=" + id + "&user=" + user + "&md5=" + md5 + '&value=' +frm.ratings.value;
  294. var url=base_url + "backend/negativo.php?" + content;
  295. $.getJSON(url,
  296. function(data) {
  297. parseLinkAnswer(id, data);
  298. }
  299. );
  300. return false;
  301. }
  302. // Get voters by Beldar <beldar.cat at gmail dot com>
  303. // Generalized for other uses (gallir at gmail dot com)
  304. function obtener(program,type,container,page,id) {
  305. var url = base_url + 'backend/'+program+'?id='+id+'&p='+page+'&type='+type;
  306. $('#'+container).load(url);
  307. }
  308. function modal_from_ajax(url, title) {
  309. if (typeof(title) == "undefined") title = '&nbsp';
  310. // !!!WARNING: this may (and will) break if you don't install jonéame at /
  311. // because pixel.gif won't be found, so X button won't appear.
  312. // change the path or just replace the image with a X if you
  313. // install jonéame with another base url! --neiKo
  314. $.modal('<div class="header" id="modalHeader" style="z-index: 10;display: block;" ><div id="modalTitle">'+title+'</div><a href="#" title="Cerrar" class="modalCloseX modalClose"><img src="/img/estructura/pixel.gif" width="16" height="16"/></a></div><div style="z-index: 10;display: block;" class="content" id="modalContent">Loading...</div>', {overlay: "50"});
  315. $.get(url, function(data){
  316. // create a modal dialog with the data
  317. $('#modalContent').html(data);
  318. });
  319. }
  320. // See http://www.shiningstar.net/articles/articles/javascript/dynamictextareacounter.asp?ID=AW
  321. function textCounter(field,cntfield,maxlimit) {
  322. if (field.value.length > maxlimit)
  323. // if too long...trim it!
  324. field.value = field.value.substring(0, maxlimit);
  325. // otherwise, update 'characters left' counter
  326. else
  327. cntfield.value = maxlimit - field.value.length;
  328. }
  329. /**************************************
  330. Tooltips functions
  331. ***************************************/
  332. /**
  333. Stronglky modified, onky works with DOM2 compatible browsers.
  334. Ricardo Galli
  335. From http://ljouanneau.com/softs/javascript/tooltip.php
  336. */
  337. // create the tooltip object
  338. function tooltip(){}
  339. // setup properties of tooltip object
  340. tooltip.id="tooltip";
  341. tooltip.main=null;
  342. tooltip.offsetx = 10;
  343. tooltip.offsety = 10;
  344. tooltip.shoffsetx = 8;
  345. tooltip.shoffsety = 8;
  346. tooltip.x = 0;
  347. tooltip.y = 0;
  348. tooltip.tooltipShadow=null;
  349. tooltip.tooltipText=null;
  350. tooltip.title_saved='';
  351. tooltip.saveonmouseover=null;
  352. tooltip.timeout = null;
  353. tooltip.active = false;
  354. tooltip.cache = new JSOC();
  355. tooltip.ie = (document.all)? true:false; // check if ie
  356. if(tooltip.ie) tooltip.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0);
  357. else tooltip.ie5 = false;
  358. tooltip.dom2 = ((document.getElementById) && !(tooltip.ie5))? true:false; // check the W3C DOM level2 compliance. ie4, ie5, ns4 are not dom level2 compliance !! grrrr >:-(
  359. /**
  360. * Open ToolTip. The title attribute of the htmlelement is the text of the tooltip
  361. * Call this method on the mouseover event on your htmlelement
  362. * ex : <div id="myHtmlElement" onmouseover="tooltip.show(this)"...></div>
  363. */
  364. tooltip.show = function (event, text) {
  365. // we save text of title attribute to avoid the showing of tooltip generated by browser
  366. if (this.dom2 == false ) return false;
  367. if (this.tooltipShadow == null) {
  368. this.tooltipShadow = document.createElement("div");
  369. this.tooltipShadow.setAttribute("id", "tooltip-shadow");
  370. document.body.appendChild(tooltip.tooltipShadow);
  371. this.tooltipText = document.createElement("div");
  372. this.tooltipText.setAttribute("id", "tooltip-text");
  373. document.body.appendChild(this.tooltipText);
  374. }
  375. this.saveonmouseover=document.onmousemove;
  376. document.onmousemove = this.mouseMove;
  377. this.mouseMove(event); // This already moves the div to the right position
  378. this.setText(text);
  379. this.tooltipText.style.visibility ="visible";
  380. this.tooltipShadow.style.visibility ="visible";
  381. this.active = true;
  382. return false;
  383. }
  384. tooltip.setText = function (text) {
  385. tooltip.tooltipShadow.style.width = 0+"px";
  386. tooltip.tooltipShadow.style.height = 0+"px";
  387. this.tooltipText.innerHTML=text;
  388. setTimeout('tooltip.setShadow()', 1);
  389. return false;
  390. }
  391. tooltip.setShadow = function () {
  392. tooltip.tooltipShadow.style.width = tooltip.tooltipText.clientWidth+"px";
  393. tooltip.tooltipShadow.style.height = tooltip.tooltipText.clientHeight+"px";
  394. }
  395. /**
  396. * hide tooltip
  397. * call this method on the mouseout event of the html element
  398. * ex : <div id="myHtmlElement" ... onmouseout="tooltip.hide(this)"></div>
  399. */
  400. tooltip.hide = function (event) {
  401. if (this.dom2 == false) return false;
  402. document.onmousemove=this.saveonmouseover;
  403. this.saveonmouseover=null;
  404. if (this.tooltipShadow != null ) {
  405. this.tooltipText.style.visibility = "hidden";
  406. this.tooltipShadow.style.visibility = "hidden";
  407. this.tooltipText.innerHTML='';
  408. }
  409. this.active = false;
  410. }
  411. // Moves the tooltip element
  412. tooltip.mouseMove = function (e) {
  413. // we don't use "this", but tooltip because this method is assign to an event of document
  414. // and so is dreferenced
  415. if (tooltip.ie) {
  416. tooltip.x = event.clientX;
  417. tooltip.y = event.clientY;
  418. } else {
  419. tooltip.x = e.pageX;
  420. tooltip.y = e.pageY;
  421. }
  422. tooltip.moveTo( tooltip.x +tooltip.offsetx , tooltip.y + tooltip.offsety);
  423. }
  424. // Move the tooltip element
  425. tooltip.moveTo = function (xL,yL) {
  426. if (this.ie) {
  427. xL += document.documentElement.scrollLeft;
  428. yL += document.documentElement.scrollTop;
  429. }
  430. if (this.tooltipText.clientWidth > 0 && document.documentElement.clientWidth > 0 && xL > document.documentElement.clientWidth * 0.55) {
  431. xL = xL - this.tooltipText.clientWidth - 2*this.offsetx;
  432. }
  433. this.tooltipText.style.left = xL +"px";
  434. this.tooltipText.style.top = yL +"px";
  435. xLS = xL + this.shoffsetx;
  436. yLS = yL + this.shoffsety;
  437. this.tooltipShadow.style.left = xLS +"px";
  438. this.tooltipShadow.style.top = yLS +"px";
  439. }
  440. // Show the content of a given comment
  441. tooltip.c_show = function (event, type, element, link) {
  442. // we save text of title attribute to avoid the showing of tooltip generated by browser
  443. if (this.dom2 == false ) return false;
  444. if (element == 0 && link > 0) { // It's a #0 from a comment
  445. this.ajax_delayed(event,'get_link.php',link);
  446. return;
  447. }
  448. if (type == 'id') {
  449. this.ajax_delayed(event,'get_comment_tooltip.php',element+"&link="+link);
  450. return;
  451. } else if (type == 'order') {
  452. this.ajax_delayed(event,'get_comment_tooltip.php',element+"&link="+link);
  453. return;
  454. } else {
  455. text = element;
  456. }
  457. return this.show(event, text);
  458. }
  459. // Show the content of a given comment
  460. tooltip.poll_c_show = function (event, type, element, link) {
  461. // we save text of title attribute to avoid the showing of tooltip generated by browser
  462. if (this.dom2 == false ) return false;
  463. if (element == 0 && link > 0) { // It's a #0 from a comment
  464. this.ajax_delayed(event,'get_encuesta.php',link);
  465. return;
  466. }
  467. if (type == 'id') {
  468. this.ajax_delayed(event,'get_opinion_tooltip.php',element+"&link="+link);
  469. return;
  470. } else if (type == 'order') {
  471. this.ajax_delayed(event,'get_opinion_tooltip.php',element+"&link="+link);
  472. return;
  473. } else {
  474. text = element;
  475. }
  476. return this.show(event, text);
  477. }
  478. tooltip.clear = function (event) {
  479. if (this.timeout != null) {
  480. clearTimeout(this.timeout);
  481. this.timeout = null;
  482. }
  483. this.hide(event);
  484. }
  485. tooltip.ajax_delayed = function (event, script, id, maxcache) {
  486. maxcache = maxcache || 600000; // 10 minutes in cache
  487. if (this.active) return false;
  488. if ((object = this.cache.get(script+id)) != undefined) {
  489. tooltip.show(event, object[script+id]);
  490. } else {
  491. this.show(event, 'cargando...'); // Translate this to your language: it's "loading..." ;-)
  492. this.timeout = setTimeout("tooltip.ajax_request('"+script+"', '"+id+"', "+maxcache+")", 100);
  493. }
  494. }
  495. tooltip.ajax_request = function(script, id, maxcache) {
  496. var url = base_url + 'backend/'+script+'?id='+id;
  497. tooltip.timeout = null;
  498. $.ajax({
  499. url: url,
  500. dataType: "html",
  501. success: function(html) {
  502. tooltip.cache.set(script+id, html, {'ttl':maxcache});
  503. tooltip.setText(html);
  504. }
  505. });
  506. }
  507. /************************
  508. Simple format functions
  509. **********************************/
  510. /*
  511. Code from http://www.gamedev.net/community/forums/topic.asp?topic_id=400585
  512. strongly improved by Juan Pedro López for http://meneame.net
  513. 2006/10/01, jotape @ http://jplopez.net
  514. */
  515. function applyTag(id, tag) {
  516. obj = document.getElementById(id);
  517. if (obj) wrapText(obj, tag, tag);
  518. }
  519. function wrapText(obj, tag) {
  520. if(typeof obj.selectionStart == 'number') {
  521. // Mozilla, Opera and any other true browser
  522. var start = obj.selectionStart;
  523. var end = obj.selectionEnd;
  524. if (start == end || end < start) return false;
  525. obj.value = obj.value.substring(0, start) + replaceText(obj.value.substring(start, end), tag) + obj.value.substring(end, obj.value.length);
  526. } else if(document.selection) {
  527. // Damn Explorer
  528. // Checking we are processing textarea value
  529. obj.focus();
  530. var range = document.selection.createRange();
  531. if(range.parentElement() != obj) return false;
  532. if (range.text == "") return false;
  533. if(typeof range.text == 'string')
  534. document.selection.createRange().text = replaceText(range.text, tag);
  535. } else
  536. obj.value += text;
  537. }
  538. function replaceText(text, tag) {
  539. text = text.replace(/(^|\s)[\*_]([^\s]+)[\*_]/gm, '$1$2')
  540. text = text.replace(/([^\s]+)/gm, tag+"$1"+tag)
  541. return text;
  542. }
  543. // This function report the ajax request to stats trackers
  544. // Only known how to do it with urchin/Google Analytics
  545. // See http://www.google.com/support/analytics/bin/answer.py?answer=33985&topic=7292
  546. function reportAjaxStats(page) {
  547. return; // Slow down
  548. if (window.urchinTracker) {
  549. urchinTracker(page+'.ajax');
  550. }
  551. }
  552. function bindTogglePlusMinus(img_id, link_id, container_id) {
  553. $(document).ready(function (){
  554. $('#'+link_id).bind('click',
  555. function() {
  556. if ($('#'+img_id).attr("src") == plus){
  557. $('#'+img_id).attr("src", minus);
  558. }else{
  559. $('#'+img_id).attr("src", plus);
  560. }
  561. $('#'+container_id).slideToggle("fast");
  562. return false;
  563. }
  564. );
  565. });
  566. }
  567. // puto wrapper feo
  568. function abrirEditar(a,b,c,d,e) {
  569. get_ajax(a,b,c,d,e);
  570. document.getElementById("ajaxcontainer").style.height = 'auto';
  571. return;
  572. }
  573. function get_ajax(program,type,container,page,id) {
  574. var url = base_url + 'ajax/'+program+'?id='+id+'&p='+page+'&type='+type;
  575. $('#'+container).load(url);
  576. }
  577. function comment_reply(id) {
  578. ref = '#' + id + ' ';
  579. textarea = $('#comment');
  580. if (textarea.length == 0 ) return;
  581. var re = new RegExp(ref);
  582. var oldtext = textarea.val();
  583. if (oldtext.match(re)) return;
  584. if (oldtext.length > 0 && oldtext.charAt(oldtext.length-1) != "\n") oldtext = oldtext + "\n";
  585. textarea.val(oldtext + ref);
  586. textarea.get(0).focus();
  587. }