1
function initAttachDialog(){tinyMCEPopup.resizeToInnerSize();}
2
function getAttachInfo(){var scripturl=FoswikiTiny.getFoswikiVar("SCRIPTURL");var suffix=FoswikiTiny.getFoswikiVar("SCRIPTSUFFIX");if(suffix==null)suffix='';var url=scripturl+"/rest"+suffix+"/WysiwygPlugin/attachments";var request=(tinyMCE.isIE)?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();request.open("POST",url,true);request.setRequestHeader("Content-type","application/x-www-form-urlencoded");var path=FoswikiTiny.getFoswikiVar("WEB")+'.'
3
+FoswikiTiny.getFoswikiVar("TOPIC");var params="nocache="+encodeURIComponent((new Date()).getTime())
4
+"&topic="+encodeURIComponent(path);request.setRequestHeader("Content-length",params.length);request.onreadystatechange=function(){attachmentListCallback(request);};request.send(params);var el=document.getElementById('upload_form');el.action=scripturl+"/rest"+suffix+
5
"/WysiwygPlugin/upload";el=document.getElementById('upload_form_topic');el.value=path;}
6
function attachmentListCallback(request){if(request.readyState==4){if(request.status==200){var atts=request.responseText;if(atts!=null){atts=eval(atts);var select=document.getElementById("attachments_select");for(var i=0;i<atts.length;i++){select.options[i]=new Option(atts[i].name,atts[i].name);}}}else{alert("There was a problem retrieving the attachments list: "
7
+request.statusText);}}}
8
function insertLink(){var inst=tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id'));var select=document.getElementById("attachments_select");var filename=select.value;var url=FoswikiTiny.getFoswikiVar("ATTACHURL")+'/'+filename;var tmp=filename.lastIndexOf(".");if(tmp>=0)
9
tmp=filename.substring(tmp+1,filename.length).toLowerCase();var html;if(tmp=="jpg"||tmp=="gif"||tmp=="jpeg"||tmp=="png"||tmp=="bmp"){html="<img src='"+url+"' alt='"+filename+"'>";}else{html="<a href='"+url+"'>"+filename+"</a>";}
10
tinyMCEPopup.execCommand('mceBeginUndoLevel');tinyMCE.execCommand('mceInsertContent',false,html);tinyMCE.triggerNodeChange();tinyMCEPopup.execCommand('mceEndUndoLevel');tinyMCEPopup.close();}
b'\\ No newline at end of file'