Skip to content

Commit

Permalink
adding current file name to the UI and changing download file to have…
Browse files Browse the repository at this point in the history
… the correct name
  • Loading branch information
coltonmercurio committed Apr 1, 2016
1 parent 1c4751e commit b98a1e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/components/editor/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
<label class="control-label sr-only" for="editor-font-size">font size (in pixels)</label>
<input data-bind="value: prefs.fontSize" id="editor-font-size" type="number" class="form-control input-sm">
</div>
<div class="col-md-2"></div>
<div class="col-md-2">
<button id="current-code-btn" type="button" class="btn btn-default btn-sm center-block">
<span class="glyphicon glyphicon-file"></span> <span class="file-name" data-bind="text: currentFileName">untitled</span>
</button>
</div>
<div class="col-md-2">
<button id="autoindent-code-btn" type="button" class="btn btn-default btn-sm center-block">
<span class="glyphicon glyphicon-indent-left"></span> Indent code
Expand Down
6 changes: 4 additions & 2 deletions src/components/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Editor {
prefs.fontSize = params.fontSize;
this.prefs = prefs;

this.currentFileName = SysGlobalObservables.currentFileName;

this.availableThemes = ko.observableArray(['monokai', 'terminal', 'tomorrow', 'xcode']);

this.annotations = params.annotations;
Expand All @@ -43,8 +45,8 @@ class Editor {

$('#download-file-btn').click(() => {
var text = this.getText();
var blob = new Blob([text], {type: 'text/plain;charset=utf-8'});
saveAs(blob, 'program.c');
var blob = new Blob([text]);
saveAs(blob, SysGlobalObservables.currentFileName());
});

$('#autoindent-code-btn').click(() => {
Expand Down

0 comments on commit b98a1e4

Please sign in to comment.