diff --git a/SAP1EMU.WebApp/Views/Home/Assembler.cshtml b/SAP1EMU.WebApp/Views/Home/Assembler.cshtml index e17e070e..38f24d92 100644 --- a/SAP1EMU.WebApp/Views/Home/Assembler.cshtml +++ b/SAP1EMU.WebApp/Views/Home/Assembler.cshtml @@ -4,8 +4,12 @@ + + + -@* Need to get jQuery lib into the project staticly, no web ref *@ @{ ViewData["Title"] = "Assembler"; } @@ -17,8 +21,6 @@

Assembly


- @* An AJAX Form is prob the answer here *@ - @*https://stackoverflow.com/questions/1720020/mvc-jquery-submit-form-without-page-refresh-from-javascript-function*@
@Html.TextArea("CodeList", null, new { rows = "20", cols = "80", @class = "codebox", id = "asm_code" }) @**@ @@ -48,67 +50,4 @@
@*This blank div is req to trick the row::after or else the margins get screwed up*@ - - -@**@ - diff --git a/SAP1EMU.WebApp/wwwroot/js/Views/AssemblerView.js b/SAP1EMU.WebApp/wwwroot/js/Views/AssemblerView.js new file mode 100644 index 00000000..b40ff008 --- /dev/null +++ b/SAP1EMU.WebApp/wwwroot/js/Views/AssemblerView.js @@ -0,0 +1,50 @@ +var asm_editor; +var bin_editor; + +window.onload = function () { + asm_editor = CodeMirror.fromTextArea(document.getElementById("asm_code"), { + lineNumbers: true, + matchBrackets: true, + mode: { name: "gas_sap1", architecture: "x86" }, + }); + + bin_editor = CodeMirror.fromTextArea(document.getElementById("bin_code"), { + lineNumbers: true, + matchBrackets: true, + mode: { name: "gas_sap1", architecture: "x86" }, + readOnly: true, + }); +} + + +function AssembleCode(btnClicked) { + var asm_code = asm_editor.getValue().split('\n'); + var asm_json = JSON.stringify(asm_code); + console.log(asm_code); + console.log(asm_json); + + $.ajax({ + url: "../api/Assembler", + type: "POST", + contentType: 'application/json; charset=UTF-8', + data: asm_json, + success: function (data) { + + console.log(data.toString()); + console.log(data.toString().replace(/,/g, '\n')); + $('#assembler-out').html('
'); + + + + bin_editor.setValue(data.toString().replace(/,/g, '\n')); + return data; + }, + error: function (request, status, error) { + bin_editor.setValue(""); + $('#assembler-out').html(request.responseText); + } + }); + + return false;// if it's a link to prevent post + +} \ No newline at end of file diff --git a/SAP1EMU.sln b/SAP1EMU.sln index 76de999b..dc0331fb 100644 --- a/SAP1EMU.sln +++ b/SAP1EMU.sln @@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SAP1EMU.Lib.Test", "SAP1EMU EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SAP1EMU.Engine", "SAP1EMU.Engine\SAP1EMU.Engine.csproj", "{B1680C97-D8B2-480C-852D-FB82686D5CF5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SAP1EMU.GUI-Windows", "SAP1EMU.GUI-Windows\SAP1EMU.GUI-Windows.csproj", "{0C6629AF-D88C-41A7-BEE2-7B091B18CA77}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SAP1EMU.Assembler-CLI", "SAP1EMU.Assembler-CLI\SAP1EMU.Assembler-CLI.csproj", "{99A4A7B4-B3B7-47D7-AF77-7DEACFEBDA5D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SAP1EMU.Engine-CLI", "SAP1EMU.Engine-CLI\SAP1EMU.Engine-CLI.csproj", "{3DB615A3-ADC4-4EF8-96D2-BF64668C2BB9}" @@ -21,7 +19,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SAP1EMU.Assembler", "SAP1EM EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F62A82B5-7BC1-430B-8E3B-A76E27724A49}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SAP1EMU.WebApp", "SAP1EMU.WebApp\SAP1EMU.WebApp.csproj", "{28B1CC5D-C440-43E3-A812-17B0C29FB41C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SAP1EMU.WebApp", "SAP1EMU.WebApp\SAP1EMU.WebApp.csproj", "{28B1CC5D-C440-43E3-A812-17B0C29FB41C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -41,10 +39,6 @@ Global {B1680C97-D8B2-480C-852D-FB82686D5CF5}.Debug|Any CPU.Build.0 = Debug|Any CPU {B1680C97-D8B2-480C-852D-FB82686D5CF5}.Release|Any CPU.ActiveCfg = Release|Any CPU {B1680C97-D8B2-480C-852D-FB82686D5CF5}.Release|Any CPU.Build.0 = Release|Any CPU - {0C6629AF-D88C-41A7-BEE2-7B091B18CA77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0C6629AF-D88C-41A7-BEE2-7B091B18CA77}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0C6629AF-D88C-41A7-BEE2-7B091B18CA77}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0C6629AF-D88C-41A7-BEE2-7B091B18CA77}.Release|Any CPU.Build.0 = Release|Any CPU {99A4A7B4-B3B7-47D7-AF77-7DEACFEBDA5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {99A4A7B4-B3B7-47D7-AF77-7DEACFEBDA5D}.Debug|Any CPU.Build.0 = Debug|Any CPU {99A4A7B4-B3B7-47D7-AF77-7DEACFEBDA5D}.Release|Any CPU.ActiveCfg = Release|Any CPU