Skip to content

Commit 4f54939

Browse files
author
SReject
committed
Added onload, HTTP request errors now flagged
On load now checks for minimum client version The HTTP request errors are now flagged with "HTTP: " prefix Removed debug tracking from tests; it will now always get enabled
1 parent c4f0d2d commit 4f54939

3 files changed

Lines changed: 26 additions & 11 deletions

File tree

src/JSON For mIRC.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,17 @@
222222
try {
223223
this._state = 'done';
224224
if (this._type === 'http') {
225-
var request = new ActiveXObject(JSONWrapper.HTTP);
226-
request.open(this._http.method, this._http.url, false);
227-
this._http.headers.forEach(function (header) {
228-
request.setRequestHeader(header[0], header[1]);
229-
});
230-
request.send(this._http.data);
225+
try {
226+
var request = new ActiveXObject(JSONWrapper.HTTP);
227+
request.open(this._http.method, this._http.url, false);
228+
this._http.headers.forEach(function (header) {
229+
request.setRequestHeader(header[0], header[1]);
230+
});
231+
request.send(this._http.data);
232+
} catch (e) {
233+
e.message = "HTTP: " + e.message;
234+
throw e;
235+
}
231236
this._http.response = request;
232237
if (!this._parse) {
233238
return this;

src/JSON For mIRC.mrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ alias JSONUrlGet {
1414
}
1515
#SReject/JSONForMirc/CompatMode end
1616

17+
;; On load, check to make sure mIRC/AdiIRC is of an applicable version
18+
on *:LOAD:{
19+
if ($~adiircexe) {
20+
if ($version < 2.6) {
21+
echo -a [JSON For mIRC] AdiIRC v2.6 or later is required
22+
}
23+
}
24+
elseif ($version < 7.44) {
25+
echo -a [JSON For mIRC] mIRC v7.44 or later is required
26+
.unload -rs $qt($script)
27+
}
28+
}
29+
1730

1831
;; Cleanup debugging when the debug window closes
1932
on *:CLOSE:@SReject/JSONForMirc/Log:{

test/JSON for mIRC - Tests.mrc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
;; /JSONTest
44
alias JSONTest {
5-
var %x = 1, %fail, %debug = $JSONDebug
5+
var %x = 1, %fail
66
JSONShutDown
7-
if (%debug) {
8-
JSONDebug on
9-
window -n @SReject/JSONForMirc/log
10-
}
7+
JSONDebug on
118
while ($isalias(jfm_test $+ %x)) {
129
tokenize 32 $jfm_test [ $+ [ %x ] ]
1310
if (!$1) {

0 commit comments

Comments
 (0)