Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions controllers/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ exports.set = function(data, callback) {
program.id = data.id;
program.password = data.password;
program.fork = data.fork;
program.toolchain = data.toolchain;
program.save(function(err) {
if(callback) callback(err, program);
});
Expand Down
5 changes: 3 additions & 2 deletions models/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ var mongoose = require('mongoose'),
Schema = mongoose.Schema;

var programSchema = new Schema({
'id': {'type': String, 'unique': true, 'index:': true},
'id': {'type': String, 'unique': true, 'index:': true},
'title': {'type': String, 'default': 'Untitled'},
'author': {'type': String, 'default': 'Anonymous'},
'description': {'type': String, 'default': ''},
'date': {'type': Date, 'default': Date.now},
'code': {'type': String},
'views': {'type': Number, 'default': 0},
'password': {'type': String, 'default': ''},
'fork': {'type': String, 'default': ''}
'fork': {'type': String, 'default': ''},
'toolchain': {'type': String, 'default': '0x10code'}
});

module.exports = mongoose.model('Program', programSchema);
20 changes: 14 additions & 6 deletions public/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ $(function() {
}
}
});
editor.setAssemblerOption = function(v) {
assembler = v;
}
$('.CodeMirror').addClass('inset');

$('#savePanel').on('show', function(){ $(this).show(); });
Expand Down Expand Up @@ -103,11 +106,11 @@ $(function() {
switch(assembler) {
case "0x10code":
console.log("Assembling with 0x10code");
assembler = new DCPU16.Assembler(cpu);
var assembler_inst = new DCPU16.Assembler(cpu);
try {
assembler.compile(code);
addressMap = assembler.addressMap;
instructionMap = assembler.instructionMap;
assembler_inst.compile(code);
addressMap = assembler_inst.addressMap;
instructionMap = assembler_inst.instructionMap;
notRun = true;
initial_mem = cpu.mem.slice();
return true;
Expand All @@ -116,7 +119,7 @@ $(function() {
$('#error span').text(e.message);

try {
errorLine = editor.setLineClass(assembler.instructionMap[assembler.instruction - 1] - 1, null, 'errorLine');
errorLine = editor.setLineClass(assembler_inst.instructionMap[assembler_inst.instruction - 1] - 1, null, 'errorLine');
} catch(e) {}

$('#error').show();
Expand Down Expand Up @@ -145,6 +148,10 @@ $(function() {
});
return true;
break;
default:
alert("The '" + assembler + "' assembler specified with this post isn't valid! Changing to 0x10code...");
assembler = "0x10code";
break;
}
} else {
for(i = 0; i < initial_mem.length; i++) {
Expand Down Expand Up @@ -304,6 +311,7 @@ $(function() {
title: $('#saveTitle').val(),
author: $('#saveAuthor').val(),
description: $('#saveDescription').val(),
toolchain: assembler,
password: $('#savePassword').val(),
code: window.editor.getValue(),
id: $('#saveId').val()
Expand All @@ -325,7 +333,7 @@ $(function() {
});

$('#dcputoolchain').click(function() {
$("#assembler-btn").html("DCPU toolchain");
$("#assembler-btn").html("DCPU-16 Toolchain");
assembler = "dcputoolchain";
editor_updated = true;
});
Expand Down
9 changes: 8 additions & 1 deletion views/edit.jade
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ append top
button#info.btn.btn-info(data-toggle="button")
i.icon-chevron-down.icon-white
span Post Options
button.btn.btn-info(data-toggle="dropdown")
i.icon-list.icon-white
span#assembler-btn 0x10code
ul.dropdown-menu.pull-right(role="menu")
li
a#0x10code(tabindex=-1, href="#") 0x10code
a#dcputoolchain(tabindex=-1, href="#") DCPU-16 Toolchain
button#save.btn.btn-info
i.icon-share.icon-white
span Post
Expand All @@ -33,4 +40,4 @@ prepend left
- if(typeof id !== 'undefined')
input#saveId(type="hidden", value="#{id}")
- if(current === 'fork')
input#saveFork(type="hidden", value="#{fork}")
input#saveFork(type="hidden", value="#{fork}")
3 changes: 2 additions & 1 deletion views/noedit.jade
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ append scripts
script(type="text/javascript").
$(function() {
window.editor.setOption('readOnly', true);
});
window.editor.setAssemblerOption("#{toolchain}");
});
8 changes: 0 additions & 8 deletions views/program.jade
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ append right
button#stop.btn.btn-action
i.icon-stop
span Stop
div.btn-group
button.btn.btn-info(data-toggle="dropdown")
i.icon-list.icon-white
span#assembler-btn 0x10code
ul.dropdown-menu.pull-right(role="menu")
li
a#0x10code(tabindex=-1, href="#") 0x10code
a#dcputoolchain(tabindex=-1, href="#") DCPU toolchain
div.btn-group
button#debug.btn.btn-danger(data-toggle="button")
i#debugIcon.icon-chevron-down.icon-white
Expand Down