Explorar el Código

make the output red if it's an error

Lucas Stadler %!s(int64=11) %!d(string=hace) años
padre
commit
1a6afc17f6
Se han modificado 1 ficheros con 6 adiciones y 3 borrados
  1. 6 3
      go/linguaevalia.go

+ 6 - 3
go/linguaevalia.go

@ -103,6 +103,8 @@ const homePageTemplateStr = `
103 103
    #code {
104 104
      border: none;
105 105
    }
106
107
    .error { color: red; }
106 108
    </style>
107 109
  </head>
108 110
@ -126,8 +128,9 @@ func main() {
126 128
      codeEl.onkeydown = function(ev) {
127 129
        if (ev.ctrlKey && ev.keyCode == 13) {
128 130
          resultEl.textContent = "";
129
          sendCode(codeEl.value, function(result) {
130
            resultEl.textContent = result;
131
          sendCode(codeEl.value, function(xhr) {
132
            resultEl.className = xhr.status == 200 ? "success" : "error";
133
            resultEl.textContent = xhr.response;
131 134
          });
132 135
        }
133 136
      }
@ -137,7 +140,7 @@ func main() {
137 140
        xhr.open("POST", "/run");
138 141
        xhr.onreadystatechange = function(ev) {
139 142
          if (xhr.readyState == XMLHttpRequest.DONE) {
140
            cb(xhr.response);
143
            cb(xhr);
141 144
          }
142 145
        };
143 146
        xhr.send(code);