ScriptClip
Displays a small line of text on the page with a button to transfer it to the clipboard.
Parameters
script - The text to display
fileName - Alternative to script. The file to display as a clip
[{/OpenForum/Extensions/ScriptClip script="ls -la /open-forum/content"}]
[{/OpenForum/Extensions/ScriptClip fileName="renderer.sjs"}]
ls -la /open-forum/content
/* * Author: * Description: */ try{ var script = extension.getAttribute("script"); var fileName = extension.getAttribute("fileName"); var scriptPageName = extension.getAttribute("scriptPageName"); if( fileName!=null ) { if( scriptPageName==null ) scriptPageName = pageName; if(file.attachmentExists( scriptPageName, fileName )) { script = file.getAttachment( scriptPageName, fileName ); } else { script = ""; } } script = ""+script; var id = extension.getAttribute("id"); var ofId = ""; if(id==null) { id = ""+js.generateMD5(script).substring(0,8); } else { id = "" + id; ofId = "of-id='" + id + "'"; } var rows = script.split("\n").length+1; script = script.replace(/</g,"<").replace(/>/g,">"); var html = "<div class='row'><div class='columns large-10'><textarea style='border: none; background-color: black; color: lightgreen; font-family: monospace;' " + ofId + " id='" + id + "' rows='"+rows+"' >"+script+"</textarea></div>"+ "<div class='columns large-2'>"+ "<a href='#' title='Copy to clipboard' onClick='"+ "OpenForum.copyElement(\""+id+"\"); return false;"+ "'><img src='/OpenForum/Images/icons/png/page_copy.png' /></a>"+ "</div></div><script>document.getElementById('" + id + "').setAttribute('readonly', 'readonly');</script>"; return html; } catch(e) { return ""+e; }
Source
/OpenForum/Extensions/ScriptClip/renderer.sjs
/* * Author: * Description: */ try{ var script = extension.getAttribute("script"); var fileName = extension.getAttribute("fileName"); var scriptPageName = extension.getAttribute("scriptPageName"); if( fileName!=null ) { if( scriptPageName==null ) scriptPageName = pageName; if(file.attachmentExists( scriptPageName, fileName )) { script = file.getAttachment( scriptPageName, fileName ); } else { script = ""; } } script = ""+script; var id = extension.getAttribute("id"); var ofId = ""; if(id==null) { id = ""+js.generateMD5(script).substring(0,8); } else { id = "" + id; ofId = "of-id='" + id + "'"; } var rows = script.split("\n").length+1; script = script.replace(//g,">"); var html = "
"+script+"
"+ "
"+ "
"+ "
"; return html; } catch(e) { return ""+e; }