X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=js%2Fautocomplete.js;h=601544eaa2b596fd2d2852e0bcedebb63d011428;hb=0d76796f30af76ca290dea5accc894a59b40d7b1;hp=dfe0bb3209e2df75f9230950f24938ff3f76cc9f;hpb=bbd5878734e658cbc514cacc20e231e843015d04;p=friendica.git diff --git a/js/autocomplete.js b/js/autocomplete.js index dfe0bb3209..601544eaa2 100644 --- a/js/autocomplete.js +++ b/js/autocomplete.js @@ -41,7 +41,7 @@ function contact_search(term, callback, backend_url, type, mode) { postdata['conversation'] = conv_id[0]; if(mode !== null) - postdata['mode'] = mode; + postdata['smode'] = mode; $.ajax({ @@ -84,7 +84,12 @@ function editor_replace(item) { // $2 ensures that prefix (@,@!) is preserved var id = item.id; - // 16 chars of hash should be enough. Full hash could be used if it can be done in a visually appealing way. + + // don't add the id if it is empty (the id empty eg. if there are unknow contacts in thread) + if(id.length < 1) + return '$1$2' + item.nick.replace(' ', '') + ' '; + + // 16 chars of hash should be enough. Full hash could be used if it can be done in a visually appealing way. // 16 chars is also the minimum length in the backend (otherwise it's interpreted as a local id). if(id.length > 16) id = item.id.substring(0,16); @@ -99,6 +104,13 @@ function basic_replace(item) { return '$1'+item.name+' '; } +function webbie_replace(item) { + if(typeof item.replace !== 'undefined') + return '$1'+item.replace; + + return '$1'+item.nick+' '; +} + function trim_replace(item) { if(typeof item.replace !== 'undefined') return '$1'+item.replace; @@ -158,6 +170,9 @@ function listNewLineAutocomplete(id) { setCaretPosition(text, caretPos + 5); return true; } + else { + return false; + } } function string2bb(element) { @@ -208,7 +223,7 @@ function string2bb(element) { match: /(^@)([^\n]{2,})$/, index: 2, search: function(term, callback) { contact_search(term, callback, backend_url, 'x', 'contact'); }, - replace: basic_replace, + replace: webbie_replace, template: contact_format, }; @@ -217,7 +232,7 @@ function string2bb(element) { match: /(^!)([^\n]{2,})$/, index: 2, search: function(term, callback) { contact_search(term, callback, backend_url, 'x', 'community'); }, - replace: basic_replace, + replace: webbie_replace, template: contact_format, }; this.attr('autocomplete', 'off'); @@ -281,7 +296,7 @@ function string2bb(element) { $.fn.bbco_autocomplete = function(type) { if(type=='bbcode') { - var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'quote', 'code', 'spoiler', 'map', 'nobb', 'list', 'ul', 'ol', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size']; + var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'quote', 'code', 'spoiler', 'map', 'img', 'url', 'audio', 'video', 'embed', 'youtube', 'vimeo', 'list', 'ul', 'ol', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'nobb', 'noparse', 'pre', 'abstract']; var open_elements = ['*', 'hr']; var elements = open_close_elements.concat(open_elements); @@ -320,11 +335,12 @@ function string2bb(element) { a.on('textComplete:select', function(e, value, strategy) { value; }); a.keypress(function(e){ - e.stopImmediatePropagation(); if (e.keyCode == 13) { var x = listNewLineAutocomplete(this.id); - if(x) + if(x) { + e.stopImmediatePropagation(); e.preventDefault(); + } } }); };