wizard.js
wizard.js
Within wizard/wizard.js, the function onOk()
in version 1 features the following if statement:
- Version 1
- Version 2
async #onOk() {
if (this.mPadMode == WizCtl.#PadMode.PadSigning) {
if (this.#hasPenData()) {
await this.#generateSignature();
this.#onCancel();
let signObject;
for (var i=this.objects.length-1; i>-1; i--) {
if (this.objects[i].type == WizCtl.ObjectType.ObjectSignature) {
signObject = this.objects[i];
}
}
if (signObject && signObject.onSignatureCaptured) {
return signObject.onSignatureCaptured(this.mSigObj);
}
async #onOk() {
if (this.mPadMode == WizCtl.#PadMode.PadSigning) {
if (this.#hasPenData()) {
const promise = this.#generateSignature();
promise.then(value => {
if (value) {
this.#onCancel();
let signObject;
for (var i=this.objects.length-1; i>-1; i--) {
if (this.objects[i].type == WizCtl.ObjectType.ObjectSignature) {
signObject = this.objects[i];
}
}
if (signObject && signObject.onSignatureCaptured) {
return signObject.onSignatureCaptured(this.mSigObj);
}
} else {
alert("Error");
}
});
promise.catch(error => {
alert(error);
});
The function #generateSignature
also requires the following adjustments:
On line 2648:
- Version 1
- Version 2
var point = {
'x': this.mPenData[index].x,
'y': this.mPenData[index].y,
'p': this.mPenData[index].pressure,
't': this.mPenData[index].timeCount,
'azimuth': 0, // STU has no azimuth
'altitude': 0, // STU has no altitude
'twist': 0, // STU has no twist
'is_down': this.mPenData[index].sw,
'stroke_id': currentStrokeID
};
currentStroke.push_back(point);
}
//Create capture area character
var device = {
'device_max_X': this.mCapability.tabletMaxX,
'device_max_Y': this.mCapability.tabletMaxY,
'device_max_P': this.mCapability.tabletMaxPressure,
'device_pixels_per_m_x': 100000,
'device_pixels_per_m_y': 100000,
'device_origin_X': 0,
'device_origin_Y': 1,
'has_tilt': false,
'has_twist': false
}
var point = {
'x': this.mPenData[index].x,
'y': this.mPenData[index].y,
'p': this.mPenData[index].pressure,
't': this.mPenData[index].timeCount,
'azimuth': 0, // STU has not azimuth
'altitude': 0, // STU has not altitude
'twist': 0, // STU has no twist
'is_down': this.mPenData[index].sw,
'stroke_id': currentStrokeID
};
currentStroke.push_back(point);
}
//Create capture area character
var device = {
'device_max_X': this.mCapability.tabletMaxX,
'device_max_Y': this.mCapability.tabletMaxY,
'device_max_P': this.mCapability.tabletMaxPressure,
'device_pixels_per_m_x': 100000,
'device_pixels_per_m_y': 100000,
'device_origin_X': 0,
'device_origin_Y': 1,
'device_unit_pixels': false
}
Line 2688:
- Version 1
- Version 2
var digitizerInfo = "STU;'"+this.mInformation.modelName+"';"+this.mInformation.firmwareMajorVersion+"."+((parseInt(this.mInformation.firmwareMinorVersion) >> 4) & 0x0f)+"."+(parseInt(this.mInformation.firmwareMinorVersion) & 0x0f)+";"+uid2;
var nicInfo = "";
var timeResolution = 1000;
var who = this.who;
var why = this.why;
var where = "";
//in this demo we use https://github.com/keithws/browser-report library for getting
//information about the os.
const webBrowserData = browserReportSync();
const osInfo = webBrowserData.os.name + " " + webBrowserData.os.version;
const nicInfo = "";
const digitizerInfo = "STU;'"+this.mInformation.modelName+"';"+this.mInformation.firmwareMajorVersion+"."+((parseInt(this.mInformation.firmwareMinorVersion) >> 4) & 0x0f)+"."+(parseInt(this.mInformation.firmwareMinorVersion) & 0x0f)+";"+uid2;
const timeResolution = 1000;
const who = this.who;
const why = this.why;
const where = "";
Finally, line 2712:
- Version 1
- Version 2
await this.mSigObj.generateSignature(this.who?this.who:"", this.why?this.why:"", where, integrityKey, documentHash, strokeVector, device, digitizerInfo, nicInfo, timeResolution);
if (deleteHash) {
documentHash.delete();
}
strokeVector.delete();
currentStroke.delete();
const myPromise = new Promise((resolve, reject) => {
try {
const promise = this.mSigObj.generateSignature(this.who?this.who:"", this.why?this.why:"", where, integrityKey, documentHash, strokeVector, device, osInfo, digitizerInfo, nicInfo, timeResolution);
promise.then(value => {
if (deleteHash) {
documentHash.delete();
}
strokeVector.delete();
currentStroke.delete();
resolve(value);
});
promise.catch(error => {
if (deleteHash) {
documentHash.delete();
}
strokeVector.delete();
currentStroke.delete();
reject(error);
});
} catch (exception) {
if (deleteHash) {
documentHash.delete();
}
strokeVector.delete();
currentStroke.delete();
reject(exception);
}
});
return myPromise;