Skip to content

Commit 277dc67

Browse files
committed
printCode function added
Prints current tab, though code flows off the page horizontally, needs tweak to something.
1 parent 0e48b8d commit 277dc67

3 files changed

Lines changed: 35 additions & 20 deletions

File tree

index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
<li><a nohref onclick="ICEcoder.uploadFilesSelect(top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1])">Upload...</a></li>
173173
<li><a nohref onclick="ICEcoder.zipIt(top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1])">Zip</a></li>
174174
<li><a nohref onclick="ICEcoder.propertiesScreen(top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1])">Properties...</a></li>
175+
<li><a nohref onClick="ICEcoder.printCode()">Print...</a></li>
175176
<li><a nohref onClick="ICEcoder.fullScreenSwitcher()">Fullscreen toggle</a></li>
176177
<li><a nohref onClick="ICEcoder.logout()">Logout</a></li>
177178
</ul>

lib/ice-coder.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,20 @@ var ICEcoder = {
20012001
.replace(/'/g, "&#039;");
20022002
},
20032003

2004+
// Print code of current tab
2005+
printCode: function() {
2006+
var cM, printIFrame;
2007+
2008+
cM = top.ICEcoder.getcMInstance();
2009+
printIFrame = top.ICEcoder.filesFrame.contentWindow.frames['fileControl'];
2010+
// Print page content injected into iFrame, escaped with pre and xssClean
2011+
printIFrame.window.document.body.innerHTML = '<!DOCTYPE html><head><title>ICEcoder code output</title></head><body><pre>'+top.ICEcoder.xssClean(cM.getValue())+'</pre></body></html>';
2012+
printIFrame.focus();
2013+
printIFrame.print();
2014+
// Focus back on code
2015+
cM.focus();
2016+
},
2017+
20042018
// ==============
20052019
// TABS
20062020
// ==============

0 commit comments

Comments
 (0)