[Swift-commit] r7770 - in SwiftApps/tryswift: . css
davidk at ci.uchicago.edu
davidk at ci.uchicago.edu
Wed Apr 16 16:07:52 CDT 2014
Author: davidk
Date: 2014-04-16 16:07:51 -0500 (Wed, 16 Apr 2014)
New Revision: 7770
Modified:
SwiftApps/tryswift/css/tryswift.css
SwiftApps/tryswift/getfiles.php
SwiftApps/tryswift/index.php
SwiftApps/tryswift/tryswift.php
Log:
Various updates to tryswift - remove twitter bootstrap, layout changes
Modified: SwiftApps/tryswift/css/tryswift.css
===================================================================
--- SwiftApps/tryswift/css/tryswift.css 2014-04-16 17:51:49 UTC (rev 7769)
+++ SwiftApps/tryswift/css/tryswift.css 2014-04-16 21:07:51 UTC (rev 7770)
@@ -1,79 +1,44 @@
-#header {
- text-align: center;
+#body,html {
+ height: 100%;
}
-#infoFrame {
- width: 100%;
- background: white;
- overflow-y: scroll;
+a {
+ text-decoration: none
}
-#editor {
- width: 100%;
- height: 50%;
-}
-
#scriptNav {
- position: relative;
- left: 25%;
- right: 25%;
width: 100%;
-}
-
-#scriptDropdown {
- position: relative;
- top: 5px;
-}
-
-.b0b0 {
- background: #b0b0b0;
border: 1px solid black;
+ float: left;
+ line-height: 2em;
}
-#editorContainer {
+#editor {
+ width: 100%;
+ height: 30%;
border: 1px solid black;
- border-bottom: 0px;
}
-#executeButton {
- position: relative;
- left: 47px;
- width: 100px;
- font-size: 1.2em;
-}
-
-#resetButton {
- position: relative;
- left: 44px;
- width: 100px;
- font-size: 1.2em;
-}
-
#editorButtons {
- background: #fbf1d3;
+ width: 100%;
+ border: 1px solid black;
}
-#pre {
- background: #fff;
- margin: 0;
- padding: 0;
+#swiftOutputDiv {
+ width: 100%;
+ border: 1px solid black;
}
-#fileOutput {
- width: 100%;
- overflow-x: hidden;
- overflow-y: scroll;
- background: #fff;
+#example {
+ float: left;
}
-#swiftOutput {
- overflow-y: scroll;
- overflow-x: hidden;
- border: 1px solid black;
- background: #fff;
+#explanation {
+ float: left;
+ padding-left: 20px;
+ top:50%
}
-#.ace_editor {
- line-height: normal;
-}
-
+#outputs {
+ visibility: hidden;
+}
Modified: SwiftApps/tryswift/getfiles.php
===================================================================
--- SwiftApps/tryswift/getfiles.php 2014-04-16 17:51:49 UTC (rev 7769)
+++ SwiftApps/tryswift/getfiles.php 2014-04-16 21:07:51 UTC (rev 7770)
@@ -1,5 +1,4 @@
<?PHP
-
$dir = $_POST['dir'];
$web_directory = "/home/tryswift/tryswift";
chdir("$web_directory/$dir");
@@ -31,7 +30,8 @@
) {
$size = filesize($file);
#$type = shell_exec("file -b $file");
- print "<div class=\"span2\"><a href=\"$dir/$file\" target=\"_blank\">$file</a> [$size bytes]</div>\n";
+ # print "<div class=\"span2\"><a href=\"$dir/$file\" target=\"_blank\">$file</a> [$size bytes]</div>\n";
+ print "<option value=\"$dir/$file\">$file</option>\n";
}
}
?>
Modified: SwiftApps/tryswift/index.php
===================================================================
--- SwiftApps/tryswift/index.php 2014-04-16 17:51:49 UTC (rev 7769)
+++ SwiftApps/tryswift/index.php 2014-04-16 21:07:51 UTC (rev 7770)
@@ -2,58 +2,48 @@
<html lang="en">
<head>
<title>Try Swift</title>
- <link href="css/tryswift.css" rel="stylesheet" media="screen">
- <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
+ <link rel="stylesheet" type="text/css" href="css/tryswift.css">
</head>
<body>
- <div class="container-fluid">
+ <div id="scriptNav">
+ <div id="example">
+ Example:
+ <select id="scriptDropdown">
+ </select>
+ </div>
+ <div id="explain">
+ </div>
+ </div> <!-- scriptNav -->
+
+ <!-- Swift code editor -->
+ <div id="editor">
+ <script src="js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
+ <script>
+ var editor = ace.edit("editor");
+ editor.setFontSize('13px');
+ editor.setTheme("ace/theme/solarized_light");
+ editor.getSession().setMode("ace/mode/text");
+ editor.setShowPrintMargin(false);
+ editor.setHighlightActiveLine(false);
+ editor.setDisplayIndentGuides(false);
+ </script>
+ </div> <!-- editor -->
- <!-- Script navigation -->
- <div class="row-fluid">
- <div id="infoContainer" class="span4 b0b0">
- <div id="scriptNav">
- <select id="scriptDropdown">
- </select>
- </div> <!-- scriptNav -->
- <iframe id="infoFrame"></iframe>
- </div> <!-- infoContainer -->
-
- <!-- Code editor -->
- <div id="editorContainer" class="span8">
- <div id="editor">
- <script src="js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
- <script>
- var editor = ace.edit("editor");
- editor.setFontSize('13px');
- editor.setTheme("ace/theme/solarized_light");
- editor.getSession().setMode("ace/mode/text");
- editor.setShowPrintMargin(false);
- editor.setHighlightActiveLine(false);
- editor.setDisplayIndentGuides(false);
- </script>
- </div> <!-- editor -->
-
- <div id="editorButtons">
- <button id="executeButton">Execute</button>
- <button id="resetButton">Reset</button>
- </div> <!-- editorButtons -->
- </div> <!-- editorContainer -->
- </div> <!-- row -->
+ <!-- Execute and reset buttons -->
+ <div id="editorButtons">
+ <button id="executeButton">Execute</button>
+ <button id="resetButton">Reset</button>
+ <select id="outputs">
+ <option>File outputs</option>
+ </select>
+ </div> <!-- editorButtons -->
+
+ <!-- Textual swift output and ticker -->
+ <div id="swiftOutputDiv">
+ <pre id="swiftOutput"></pre>
+ </div> <!-- swiftOutputDiv -->
- <div class="row-fluid">
- <div class="span12">
- <pre id="swiftOutput">Swift output</pre>
- </div> <!-- span12 -->
- </div> <!-- row -->
-
- <div class="row-fluid">
- <div class="span12">
- <div id="fileOutput"> Output files</div>
- </div> <!-- span12 -->
- </div> <!-- row-fluid -->
- </div> <!-- container -->
-
<script>
var scriptCounter=0;
var scripts=[
@@ -78,29 +68,44 @@
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="js/logtail.js"></script>
<script type="text/javascript">
-
+
+ // Popup a new browser window in center of screen
+ function popupwindow(url, name, w, h) {
+ var left = (screen.width/2)-(w/2);
+ var top = (screen.height/2)-(h/2);
+ return window.open(url, name, 'width='+w+', height='+h+', top='+top+', left='+left);
+ }
+
+ // Fill editor with script selected from dropdown
function updateScript(index) {
$.get(scripts[index][0], null, function (data) {
editor.setValue(data);
editor.gotoLine(1);
}, "text");
- $('#infoFrame').attr('src', scripts[index][2]);
+ $('#explain').html("<button id=\"explainButton\" value=\"" + scripts[index][2] + "\">Explain</button>");
}
-
+
function resize() {
- $('#editor').height( $(document).height() / 2 );
- $('#infoContainer').height( $('#editorContainer').height() );
- $('#infoFrame').height( $('#infoContainer').height() - $('#scriptDropdown').height()-5 );
- $('#swiftOutput').height( $(document).height() * .20 );
- $('#fileOutput').height( $(document).height() * .19 );
- $('#fileOutput').width( $(document).width() );
+ $('#editor').height( $(document).height() * .55 );
+ $('#swiftOutputDiv').height( $(document).height() * .35 );
}
+ function hideOutputs() {
+ $('#outputs').css('visibility', 'hidden');
+ }
+
+ function showOutputs() {
+ $('#outputs').css('visibility', 'visible');
+ }
+
$(document).ready(function() {
resize();
updateScript(0);
$(window).resize(function() { resize(); });
- $('#resetButton').click(function() { updateScript(); })
+ $('#resetButton').click(function() {
+ updateScript($('#scriptDropdown').find('option:selected').index());
+ hideOutputs();
+ })
$.each(scripts, function(key, value) {
$('#scriptDropdown')
@@ -111,21 +116,33 @@
$('#scriptDropdown').change(function() {
updateScript($(this).find('option:selected').index());
+ hideOutputs();
});
+ $(document).on("change", "#outputs", function(){
+ popupwindow($('#outputs').val(), '', 800, 600);
+ // $('#swiftOutput').load($("#outputs").val());
+ });
+
+ $(document).on("click", "#explainButton", function(){
+ popupwindow($(this).attr("value"), $(this).text(), 800, 600);
+ return false;
+ });
+
$('#executeButton').click(function() {
sourceCode=editor.getSession().getValue();
if(!sourceCode) {
alert("Source text is empty!");
return false;
}
+ $('#outputs').html('<option>File outputs</option>');
$.post("tryswift.php", {source: sourceCode}).done(function(data) {
- $('#fileOutput').html("");
var urlArray = data.split("\n");
tailf(urlArray[0], "#swiftOutput");
$.post("getfiles.php", {dir: urlArray[1]}).done(function(filedata) {
- $('#fileOutput').html(filedata);
+ $('#outputs').append(filedata);
+ showOutputs();
});
});
})
Modified: SwiftApps/tryswift/tryswift.php
===================================================================
--- SwiftApps/tryswift/tryswift.php 2014-04-16 17:51:49 UTC (rev 7769)
+++ SwiftApps/tryswift/tryswift.php 2014-04-16 21:07:51 UTC (rev 7770)
@@ -27,7 +27,7 @@
}
# Run Swift
- system("echo Executing.. > $dirname/swift.out");
+ system("echo Swift run starting at $( date +%T ) > $dirname/swift.out");
system("$swift_cmd >> $dirname/swift.out 2>&1 &");
print "runs/$unique/swift.out\n";
More information about the Swift-commit
mailing list