Просмотр исходного кода

make the output red if it's an error

Lucas Stadler лет назад: 11
Родитель
Сommit
1a6afc17f6
1 измененных файлов с 6 добавлено и 3 удалено
  1. 6 3
      go/linguaevalia.go

+ 6 - 3
go/linguaevalia.go

103
    #code {
103
    #code {
104
      border: none;
104
      border: none;
105
    }
105
    }
106
107
    .error { color: red; }
106
    </style>
108
    </style>
107
  </head>
109
  </head>
108
110
126
      codeEl.onkeydown = function(ev) {
128
      codeEl.onkeydown = function(ev) {
127
        if (ev.ctrlKey && ev.keyCode == 13) {
129
        if (ev.ctrlKey && ev.keyCode == 13) {
128
          resultEl.textContent = "";
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
        xhr.open("POST", "/run");
140
        xhr.open("POST", "/run");
138
        xhr.onreadystatechange = function(ev) {
141
        xhr.onreadystatechange = function(ev) {
139
          if (xhr.readyState == XMLHttpRequest.DONE) {
142
          if (xhr.readyState == XMLHttpRequest.DONE) {
140
            cb(xhr.response);
143
            cb(xhr);
141
          }
144
          }
142
        };
145
        };
143
        xhr.send(code);
146
        xhr.send(code);