File manager - Edit - /home/c14075/dragmet-ural.ru/www/bitrix/components/bitrix/wiki.edit/templates/.default/script.min.js
Back
var BXWikiEditor=function(t){this.element=t.element||null;this.elementId=t.elementId;this.wikiTextHtmlInit=t.wikiTextHtmlInit;this.editUrl=t.editUrl;this.htmlEditorId=t.editorId;this.htmlEditor=null;this.charset=t.charset;this.maxImageWidth=t.maxImageWidth;this.myAgent=navigator.userAgent.toLowerCase();this.myVersion=parseInt(navigator.appVersion);this.wikitags=[];this.arWikiImg={};this.arWikiCodeStorage=[];this.rng=null;this.sel=null;this.selLength=null;this.selStart=null;this.selEnd=null;this.oPrevRange=null;this.currentMode="text";this.is_ie=this.myAgent.indexOf("msie")!=-1&&this.myAgent.indexOf("opera")==-1;this.is_nav=this.myAgent.indexOf("mozilla")!=-1&&this.myAgent.indexOf("spoofer")==-1&&this.myAgent.indexOf("compatible")==-1&&this.myAgent.indexOf("opera")==-1&&this.myAgent.indexOf("webtv")==-1&&this.myAgent.indexOf("hotjava")==-1;this.is_opera=this.myAgent.indexOf("opera")!=-1;this.is_win=this.myAgent.indexOf("win")!=-1||this.myAgent.indexOf("16bit")!=-1;this.is_mac=this.myAgent.indexOf("mac")!=-1;if(!window.phpVars)window.phpVars={}};BXWikiEditor.prototype.init=function(){if(!this.element){this.element=document.getElementById(this.elementId)}var t=this.getHtmlEditor(this.htmlEditorId);if(t){this.htmlEditor=t}if(this.element){this.bindEventHandlers();if(this.wikiTextHtmlInit)setTimeout(function(){this.showEditField("html","N")}.bind(this),100);else this.showEditField("text","N")}};BXWikiEditor.prototype.getHtmlEditor=function(t){if(window["JCLightHTMLEditor"]&&window["JCLightHTMLEditor"].items[t])return window["JCLightHTMLEditor"].items[t];else return null};BXWikiEditor.prototype.bindEventHandlers=function(){BX.addCustomEvent(window,"LHE_OnInit",function(t){if(t.id===this.htmlEditorId){this.htmlEditor=t}}.bind(this));var t={"wiki-wcode-bold":this.wiki_bold.bind(this),"wiki-wcode-italic":this.wiki_italic.bind(this),"wiki-wcode-wheader":this.wiki_header.bind(this),"wiki-wcode-category":this.ShowCategoryInsert.bind(this),"wiki-wcode-url":this.ShowInsertLink.bind(this,false),"wiki-wcode-signature":this.wiki_signature.bind(this),"wiki-wcode-line":this.wiki_line.bind(this),"wiki-wcode-ignore":this.wiki_nowiki.bind(this),"wiki-wcode-external-url":this.ShowInsertLink.bind(this,true),"wiki-wcode-img":this.ShowImageInsert.bind(this),"wiki-wcode-img-upload":this.ShowImageUpload.bind(this),"wiki-wcode-code":this.WikiInsertCode.bind(this)};for(var e in t){var i=this.element.querySelector("a."+e);if(i&&t.hasOwnProperty(e)){i.addEventListener("click",t[e])}}var s=this.element.querySelector("#wki-text-text");if(s)s.addEventListener("click",this.showEditField.bind(this,"text","Y"));var n=this.element.querySelector("#wki-text-html");if(n)n.addEventListener("click",this.showEditField.bind(this,"html","Y"));var r=this.element.querySelector("#MESSAGE");if(r)r.addEventListener("keydown",this.check_ctrl_enter)};BXWikiEditor.prototype.wiki_bold=function(){this.simpletag("'''")};BXWikiEditor.prototype.wiki_italic=function(){this.simpletag("''")};BXWikiEditor.prototype.wiki_header=function(){this.simpletag("==")};BXWikiEditor.prototype.wiki_line=function(){this.doInsert("----","",false)};BXWikiEditor.prototype.wiki_signature=function(){if(this.htmlEditor&&this.currentMode==="html"){this.htmlEditor.InsertHTML("--~~~~")}else{this.doInsert("--~~~~","",false)}};BXWikiEditor.prototype.wiki_nowiki=function(){this.simpletag("<NOWIKI>")};BXWikiEditor.prototype.simpletag=function(t){if(this.doInsert(t,this.checkTag(t),true)){this.wikitags.push(t);this.cstat()}};BXWikiEditor.prototype.showDialog=function(t,e){var i=new BX.CDialog(t);i.ClearButtons();i.SetButtons(e);i.adjustSizeEx();BX.addCustomEvent(i,"onWindowUnRegister",function(){if(i.DIV&&i.DIV.parentNode)i.DIV.parentNode.removeChild(i.DIV)});i.Show()};BXWikiEditor.prototype.ShowImageUpload=function(){var t=this;var e={title:BX.message("WIKI_IMAGE_UPLOAD"),content:this.getTemplate("template-image-upload"),height:150,width:400,min_height:150,min_width:400};var i=[{title:BX.message("WIKI_SAVE"),id:"wk_upload",action:function(){this.disableUntilError();BX.ajax.submitAjax(document.forms["load_form"],{url:this.editUrl,method:"POST",dataType:"json",onsuccess:function(e){if(e.hasOwnProperty("ERROR_MESSAGE")){BX.WindowManager.Get().ShowError(e["ERROR_MESSAGE"]);return}if(!e.hasOwnProperty("IMAGE")){return}var i={id:parseInt(e["IMAGE"]["ID"]),name:e["IMAGE"]["ORIGINAL_NAME"],html:e["IMAGE"]["FILE_SHOW"]};var s=document.getElementById("wiki-post-image");var n=document.createElement("div");n.classList.add("wiki-post-image-item");n.innerHTML=t.render(t.getTemplate("template-image-item"),i);s.appendChild(n);t.arWikiImg[i.id]=i.name;t.doInsert("[File:"+i.name+"]","",false,i.id);BX.closeWait();BX.WindowManager.Get().Close()},onerror:function(){BX.closeWait()}})}},BX.CDialog.btnCancel];this.getSelectedText();this.showDialog(e,i)};BXWikiEditor.prototype.ShowImageInsert=function(){var t=this;this.getSelectedText();var e={title:BX.message("WIKI_INSERT_IMAGE"),content:this.getTemplate("template-insert-image"),height:150,width:400,min_height:150,min_width:400};var i=[{title:BX.message("WIKI_BUTTON_INSERT"),id:"wk_insert",action:function(){t.wiki_tag_image(BX("image_url").value);this.parentWindow.Close()}},BX.CDialog.btnCancel];this.showDialog(e,i)};BXWikiEditor.prototype.ShowCategoryInsert=function(){var t=this;this.getSelectedText();var e={title:BX.message("WIKI_INSERT_CATEGORY"),content:this.getTemplate("template-insert-category"),height:120,width:400,min_height:120,min_width:400};var i=new BX.CDialog(e);var s=[{title:BX.message("WIKI_BUTTON_INSERT"),id:"wk_insert",action:function(){t.wiki_tag_category(BX("category_name").value);this.parentWindow.Close()}},BX.CDialog.btnCancel];this.showDialog(e,s)};BXWikiEditor.prototype.ShowInsertLink=function(t){var e=this;var i=t?this.getTemplate("template-insert-external-link"):this.getTemplate("template-insert-internal-link");var s=this.getSelectedText();var n={linkName:s?s:""};var r=this.render(i,n);var o={title:t?BX.message("WIKI_INSERT_EXTERANL_HYPERLINK"):BX.message("WIKI_INSERT_HYPERLINK"),content:r,height:120,width:400,min_height:120,min_width:400};var l=[{title:BX.message("WIKI_BUTTON_INSERT"),id:"wk_insert",action:function(){if(t)e.wiki_tag_url_external(BX("bx_url_type").value,BX("link_url").value,BX("link_name").value);else e.wiki_tag_url(BX("link_url").value,BX("link_name").value);this.parentWindow.Close()}},BX.CDialog.btnCancel];this.showDialog(o,l)};BXWikiEditor.prototype.WikiInsertCode=function(){var t=this.getSelectedText();if(!t)t=" ";if(this.doInsert("{{{"+t+"}}}","",false,null,true)){this.wikitags.push("{{{");this.cstat()}};BXWikiEditor.prototype.wiki_tag_url=function(t,e){var i;if(e&&!t)t=e;i="[["+t+(e&&e!=""?"|"+e:"")+"]]";if(this.htmlEditor&&this.currentMode==="html"){this.htmlEditor.SelectRange(this.oPrevRange);this.htmlEditor.InsertHTML(i)}else{this.doInsert(i,"",false,null,true)}};BXWikiEditor.prototype.wiki_tag_url_external=function(t,e,i){var s="";if(!e)return;if(this.htmlEditor&&this.currentMode==="html"){s='<a href="'+t+e+'" >'+i+"</a>";this.htmlEditor.SelectRange(this.oPrevRange);this.htmlEditor.InsertHTML(s)}else{s="["+t+e+(i&&i!=""?" "+i:"")+"]";this.doInsert(s,"",false,null,true)}};BXWikiEditor.prototype.wiki_tag_image=function(t){if(t){if(this.htmlEditor&&this.currentMode==="html"){var e="<img "+'id="'+this.htmlEditor.SetBxTag(false,{tag:"wiki_img",params:{id:t,file_name:t}})+'" '+'src="'+t+'">';this.htmlEditor.SelectRange(this.oPrevRange);this.htmlEditor.InsertHTML(e)}else{this.doInsert("["+BX.message("FILE_NAME")+":"+t+"]","",false,null,true)}}};BXWikiEditor.prototype.wiki_tag_category=function(t){if(t){if(this.htmlEditor&&this.currentMode==="html"){var e="[["+BX.message("CATEGORY_NAME")+":"+t+"]]<br />";this.htmlEditor.SelectRange(this.oPrevRange);this.htmlEditor.InsertHTML(e)}else{this.doInsert("[["+BX.message("CATEGORY_NAME")+":"+t+"]]\n","",false,null,true)}}};BXWikiEditor.prototype.closeall=function(){while(this.wikitags.length>0){var t=this.wikitags.pop();document.getElementById("MESSAGE").value+=this.checkTag(t)}this.wikitags=[];this.cstat()};BXWikiEditor.prototype.cstat=function(){document.getElementById("MESSAGE").focus()};BXWikiEditor.prototype.getSelectedText=function(){var t=false;if(this.htmlEditor&&this.currentMode==="html"){this.oPrevRange=this.htmlEditor.GetSelectionRange();if(this.oPrevRange.startContainer&&this.oPrevRange.endContainer){if(this.oPrevRange.startContainer==this.oPrevRange.endContainer&&(this.oPrevRange.endContainer.nodeType==3||this.oPrevRange.endContainer.nodeType==1))t=this.oPrevRange.startContainer.textContent.substring(this.oPrevRange.startOffset,this.oPrevRange.endOffset)||""}else{if(this.oPrevRange.text==this.oPrevRange.htmlText)t=this.oPrevRange.text||"";else if(this.oPrevRange.htmlText)t=this.oPrevRange.htmlText}if(!t){if(this.is_ie)t=this.oPrevRange.text||"";else t=this.oPrevRange||""}}else{var e=document.getElementById("MESSAGE");var i=e.scrollTop;if(this.is_ie){e.focus();this.sel=document.selection;this.rng=this.sel.createRange();var s=this.rng.duplicate();s.moveToElementText(e);s.setEndPoint("EndToEnd",this.rng);this.selStart=s.text.length-this.rng.text.length;this.selEnd=this.selStart+this.rng.text.length;this.rng.collapse();if((this.sel.type=="Text"||this.sel.type=="None")&&this.rng.text.length>0)t=this.rng.text}else{this.selLength=e.textLength;this.selStart=e.selectionStart;this.selEnd=e.selectionEnd;if(e.selectionEnd>e.selectionStart)t=e.value.substring(e.selectionStart,e.selectionEnd)}}return t};BXWikiEditor.prototype.mozillaWr=function(t,e,i,s){if(!this.selLength){this.selLength=t.textLength}if(!this.selStart)this.selStart=t.selectionStart;if(!this.selEnd)this.selEnd=t.selectionEnd;if(this.selEnd==1||this.selEnd==2)this.selEnd=this.selLength;var n=t.value.substring(0,this.selStart);var r=t.value.substring(this.selStart,this.selEnd);var o=t.value.substring(this.selEnd,this.selLength);if(s===true)t.value=n+e+i+o;else t.value=n+e+r+i+o;t.selectionEnd=0;t.selectionStart=this.selEnd+e.length+i.length;t.setSelectionRange(this.selStart,this.selEnd);this.selLength=null;this.selStart=null;this.selEnd=null};BXWikiEditor.prototype.checkTag=function(t){var e="";var i="";if(t.substr(0,1)=="["||t.substr(0,1)=="<"){i=t.substr(0,1)+"/";t=t.substring(1,t.length);e=t.substr(t.length,1)}return i+t+e};BXWikiEditor.prototype.doInsert=function(t,e,i,s,n){if(s>0&&this.htmlEditor&&this.currentMode==="html"){var r=document.getElementById(s);var o=r.src;var l=null;var a=null;var h="";if(!r.naturalWidth){var d=new Image;d.src=o;l=d.width;a=d.height}else{l=r.naturalWidth;a=r.naturalHeight}if(l>this.maxImageWidth)h+="width: "+this.maxImageWidth;var c=this.arWikiImg[s];var m='<img id="'+this.htmlEditor.SetBxTag(false,{tag:"wiki_img",params:{id:s,file_name:c}})+'"'+'src="'+o+'" style="'+h+'">';this.htmlEditor.InsertHTML(m);return true}var g=false;var u=document.getElementById("MESSAGE");var E=u.scrollTop;if(i)g=true;if(this.is_ie){u.focus();if(!this.sel)this.sel=document.selection;if(!this.rng)this.rng=this.sel.createRange();this.rng.collapse();if((this.sel.type=="Text"||this.sel.type=="None")&&this.rng!=null){if(e!=""&&this.rng.text.length>0){t+=this.rng.text+e;g=false}else if(e!=""){t+=this.rng.text+" "+e;g=false}this.rng.text=t;var p=u.createTextRange();p.move("character",this.selStart);p.select()}this.rng=null;this.sel=null}else{if(this.is_nav&&document.getElementById){if(e!=""&&u.selectionEnd>u.selectionStart){this.mozillaWr(u,t,e,n);g=false}else if(e!=""){this.mozillaWr(u,t+" ",e,false)}else this.mozillaWr(u,t,"",n)}else u.value+=t}u.scrollTop=E;u.focus();return g};BXWikiEditor.prototype.check_ctrl_enter=function(t){if((t.keyCode==13||t.keyCode==10)&&t.ctrlKey){document.REPLIER.submit()}};BXWikiEditor.prototype.saveWikiCodes=function(t){this.arWikiCodeStorage=[];var e="";var i=this;e=t.replace(/({{{[\s\S]*?}}}|\[CODE\][\s\S]*?\[\/CODE\])/gim,function(t,e,s){var n=i.arWikiCodeStorage.push(t)-1;return"##CODE"+n+"##"});return e};BXWikiEditor.prototype.restoreWikiCodes=function(t){var e=this;return t.replace(/##CODE(\d+)##/gim,function(t,i,s,n){return e.arWikiCodeStorage[i]?e.arWikiCodeStorage[i]:""})};BXWikiEditor.prototype.convTextForText=function(t){t=this.saveWikiCodes(t);t=t.replace(/<br(\s*\/)?>\s*(\r*\n)?/gim,"\n");t=this.restoreWikiCodes(t);t=t.replace(/\[CODE\]/gim,"{{{");t=t.replace(/\[\/CODE\]/gim,"}}}");return t};BXWikiEditor.prototype.convTextForVisual=function(t){t=this.saveWikiCodes(t);t=t.replace(/(<\s*\/?(h\d|li|ul|ol|p|table|tbody|td|tr|hr|div|span)\s*>)\s*(\r*\n)/gim,"$1##NN##");t=t.replace(/(<\s*(ul)\s*>)\s*(\r*\n)/gim,"$1##NN##");t=t.replace(/\r*\n/gim,"<br />\n");t=t.replace(/##NN##/gim,"\n");t=this.restoreWikiCodes(t);t=t.replace(/{{{/gim,"[CODE]");t=t.replace(/}}}/gim,"[/CODE]");return t};BXWikiEditor.prototype.htmlspecchWikiCodes=function(t){return t.replace(/({{{(\s|.)*}}}|\[CODE\](\s|.)*\[\/CODE\])/gim,function(t,e,i,s,n,r){return BX.util.htmlspecialchars(t)})};BXWikiEditor.prototype.htmlspecchWikiCodesBack=function(t){return t.replace(/({{{(\s|.)*}}}|\[CODE\](\s|.)*\[\/CODE\])/gim,function(t,e,i,s,n,r){return BX.util.htmlspecialcharsback(t)})};BXWikiEditor.prototype.insertSanitized=function(t,e){var i=this;e.SetEditorContent("");var s=document.getElementById("edit-post-html");var n=BX.showWait(s);var r=this.saveWikiCodes(t);var o={act:"sanitize",sessid:BX.bitrix_sessid(),text:r};BX.ajax({url:"/bitrix/components/bitrix/wiki/component.ajax.php",method:"POST",data:o,onsuccess:function(t){t=i.restoreWikiCodes(t);t=i.convTextForVisual(t);e.SetEditorContent(t);BX.closeWait(s,n)}})};BXWikiEditor.prototype.setEditorContentAfterLoad=function(t){var e=document.getElementById("MESSAGE").value;this.insertSanitized(e,t)};BXWikiEditor.prototype.showEditField=function(t,e){var i=document.getElementById("edit-post-html");var s=document.getElementById("edit-post-text");if(t=="html"){s.style.display="none";if(i)i.style.display="block";if(e=="Y"){if(this.htmlEditor){var n=document.getElementById("MESSAGE").value;this.insertSanitized(n,this.htmlEditor)}}this.currentMode="html"}else{if(i)i.style.display="none";s.style.display="block";if(e=="Y"){if(this.htmlEditor){this.htmlEditor.SaveContent();var r=this.htmlEditor.GetContent();r=this.convTextForText(r);r=r.replace(/(<\s*\/*\s*)(code)(\s*>)/gi,"$1nowiki$3");document.getElementById("MESSAGE").value=r}}this.currentMode="text"}return false};BXWikiEditor.prototype.wikiPostToFeedTogle=function(){var t=document.getElementById("post_to_feed");if(!t)return false;if(t.value=="Y")t.value="N";else t.value="Y";this.wikiSetCheckboxPTF(t.value);return true};BXWikiEditor.prototype.wikiSetCheckboxPTF=function(t){var e=document.getElementById("cb_post_to_feed");if(!e)return false;e.checked=t=="Y";return true};BXWikiEditor.prototype.replaceLinkByInput=function(t,e){if(!t.parentNode)return false;var i=BX(e);if(!i)return false;BX.addClass(t.parentNode,"wiki-post-div-hide");setTimeout(function(){BX.addClass(t.parentNode,"wiki-post-div-nonedisplay")},300);setTimeout(function(){BX.removeClass(i,"wiki-post-div-nonedisplay");i.parentNode.style.height="3em";BX.removeClass(i,"wiki-post-div-hide")},295);return false};BXWikiEditor.prototype.getTemplate=function(t){var e=document.getElementById(t);var i="";if(e){i=e.innerHTML}return i};BXWikiEditor.prototype.render=function(t,e){var i;if(typeof t!=="string")return t;if(typeof e!=="object")return t;i=t.replace(/#(\w+?)#/g,function(t,i,s){if(e.hasOwnProperty(i))return e[i];else return t});return i}; //# sourceMappingURL=script.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.38 |
proxy
|
phpinfo
|
Settings