Skip to content

Commit

Permalink
More OCR feature improvement.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylianst committed Jul 26, 2020
1 parent 060f012 commit ed99687
Show file tree
Hide file tree
Showing 8 changed files with 279 additions and 77 deletions.
1 change: 1 addition & 0 deletions amt-0.2.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ function AmtStackCreateService(wsmanStack) {
obj.AMT_EnvironmentDetectionSettingData_SetSystemDefensePolicy = function (Policy, callback_func) { obj.Exec('AMT_EnvironmentDetectionSettingData', 'SetSystemDefensePolicy', { 'Policy': Policy }, callback_func); }
obj.AMT_EnvironmentDetectionSettingData_EnableVpnRouting = function (Enable, callback_func) { obj.Exec('AMT_EnvironmentDetectionSettingData', 'EnableVpnRouting', { 'Enable': Enable }, callback_func); }
obj.AMT_EthernetPortSettings_SetLinkPreference = function (LinkPreference, Timeout, callback_func) { obj.Exec('AMT_EthernetPortSettings', 'SetLinkPreference', { 'LinkPreference': LinkPreference, 'Timeout': Timeout }, callback_func); }
obj.AMT_GeneralSettings_AMTAuthenticate = function (Nonce, callback_func) { obj.Exec('AMT_GeneralSettings', 'AMTAuthenticate', { 'MC_Nonce': Nonce }, callback_func); }
obj.AMT_HeuristicPacketFilterStatistics_ResetSelectedStats = function (SelectedStatistics, callback_func) { obj.Exec('AMT_HeuristicPacketFilterStatistics', 'ResetSelectedStats', { 'SelectedStatistics': SelectedStatistics }, callback_func); }
obj.AMT_KerberosSettingData_GetCredentialCacheState = function (callback_func) { obj.Exec('AMT_KerberosSettingData', 'GetCredentialCacheState', {}, callback_func); }
obj.AMT_KerberosSettingData_SetCredentialCacheState = function (Enable, callback_func) { obj.Exec('AMT_KerberosSettingData', 'SetCredentialCacheState', { 'Enable': Enable }, callback_func); }
Expand Down
21 changes: 16 additions & 5 deletions amt-wsman-0.2.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ var WsmanStackCreateService = function (host, port, user, pass, tls, extra) {
obj.PerformAjax = function (postdata, callback, tag, pri, namespaces) {
if (namespaces == null) namespaces = '';
obj.comm.PerformAjax('<?xml version=\"1.0\" encoding=\"utf-8\"?><Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns=\"http://www.w3.org/2003/05/soap-envelope\" ' + namespaces + '><Header><a:Action>' + postdata, function (data, status, tag) {
if (status != 200) { callback(obj, null, { Header: { HttpError: status } }, status, tag); return; }
var wsresponse = obj.ParseWsman(data);
if (!wsresponse || wsresponse == null) { callback(obj, null, { Header: { HttpError: status } }, 601, tag); } else { callback(obj, wsresponse.Header['ResourceURI'], wsresponse, 200, tag); }
if ((data != null) && (!wsresponse || wsresponse == null)) {
callback(obj, null, { Header: { HttpError: status } }, 601, tag);
} else {
if (status != 200) {
if (wsresponse == null) { wsresponse = { Header: {} }; }
wsresponse.Header.HttpError = status;
try { wsresponse.Header.WsmanError = wsresponse.Body['Reason']['Text']['Value']; } catch (ex) { }
}
callback(obj, wsresponse.Header['ResourceURI'], wsresponse, status, tag);
}
}, tag, pri);
}

Expand Down Expand Up @@ -100,6 +108,7 @@ var WsmanStackCreateService = function (host, port, user, pass, tls, extra) {

// Private method
obj.ParseWsman = function (xml) {
if (xml == null) return null;
try {
if (!xml.childNodes) xml = _turnToXml(xml);
var r = { Header: {} }, header = xml.getElementsByTagName('Header')[0], t;
Expand All @@ -116,11 +125,13 @@ var WsmanStackCreateService = function (host, port, user, pass, tls, extra) {
t = body.childNodes[0].localName;
if (t.indexOf('_OUTPUT') == t.length - 7) { t = t.substring(0, t.length - 7); }
r.Header['Method'] = t;
r.Body = _ParseWsmanRec(body.childNodes[0]);
try {
r.Body = _ParseWsmanRec(body.childNodes[0]);
} catch (ex) { console.log('_ParseWsmanRec failed', body, ex); return null; }
}
return r;
} catch (e) {
console.log('Unable to parse XML: ' + xml);
} catch (ex) {
console.log('Unable to parse XML: ' + xml + ', ' + ex);
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions amt-wsman-ajax-0.2.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ var CreateWsmanComm = function (url) {
if (obj.FailAllError == 999) return;
// console.log('RECV: ' + data); // DEBUG
if (obj.FailAllError != 0) { callArgs[1](null, obj.FailAllError, callArgs[2]); return; }
if (request.status != 200) { callArgs[1](null, request.status, callArgs[2]); obj.PerformNextAjax(); return; }
callArgs[1](data, 200, callArgs[2]);
//if (request.status != 200) { callArgs[1](data, request.status, callArgs[2]); obj.PerformNextAjax(); return; }
callArgs[1](data, request.status, callArgs[2]);
obj.PerformNextAjax();
}

Expand Down
4 changes: 2 additions & 2 deletions amt-wsman-node-0.2.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ var CreateWsmanComm = function (host, port, user, pass, tls, tlsoptions) {
obj.gotNextMessages = function (data, status, request, callArgs) {
if (obj.FailAllError == 999) return;
if (obj.FailAllError != 0) { try { callArgs[1](null, obj.FailAllError, callArgs[2]); } catch (ex) { console.error(ex); } return; }
if (request.status != 200) { try { callArgs[1](null, request.status, callArgs[2]); } catch (ex) { console.error(ex); } return; }
try { callArgs[1](data, 200, callArgs[2]); } catch (ex) { console.error(ex); }
//if (request.status != 200) { try { callArgs[1](data, request.status, callArgs[2]); } catch (ex) { console.error(ex); } return; }
try { callArgs[1](data, request.status, callArgs[2]); } catch (ex) { console.error(ex); }
}

// Private method
Expand Down
4 changes: 2 additions & 2 deletions amt-wsman-ws-0.2.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ var CreateWsmanComm = function (host, port, user, pass, tls) {
obj.gotNextMessages = function (data, status, request, callArgs) {
if (obj.FailAllError == 999) return;
if (obj.FailAllError != 0) { callArgs[1](null, obj.FailAllError, callArgs[2]); return; }
if (request.status != 200) { callArgs[1](null, request.status, callArgs[2]); return; }
callArgs[1](data, 200, callArgs[2]);
//if (request.status != 200) { callArgs[1](null, request.status, callArgs[2]); return; }
callArgs[1](data, request.status, callArgs[2]);
}

// Private method
Expand Down
8 changes: 7 additions & 1 deletion common-0.0.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ function random(max) { return Math.floor(Math.random() * max); }
function trademarks(x) { return x.replace(/\(R\)/g, '&reg;').replace(/\(TM\)/g, '&trade;'); }

// Format
function format(format) { var args = Array.prototype.slice.call(arguments, 1); return format.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match; }); };
function format(format) { var args = Array.prototype.slice.call(arguments, 1); return format.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match; }); };

// Returns a UEFI boot parameter in binary
function makeUefiBootParam(type, data, len) {
if (typeof data == 'number') { if (len == 1) { data = String.fromCharCode(data & 0xFF); } if (len == 2) { data = ShortToStrX(data); } if (len == 4) { data = IntToStrX(data); } }
return ShortToStrX(0x8086) + ShortToStrX(type) + IntToStrX(data.length) + data;
}
Loading

0 comments on commit ed99687

Please sign in to comment.