Comparing version 2.1.2 to 2.1.3
@@ -74,2 +74,3 @@ var crypto = require('crypto'); | ||
this.signaturePartTwo = ''; | ||
this.startDelay = 0; | ||
this.applicationKey = applicationKey; | ||
@@ -243,3 +244,3 @@ this.applicationSecret = applicationSecret; | ||
if (oncomplete != null) { | ||
var error = _getError(res, data); | ||
var error = _getError(self, res, data); | ||
var obj = _convert(data, type); | ||
@@ -260,3 +261,3 @@ if (error != null) { | ||
function _getError(res, data){ | ||
function _getError(self, res, data){ | ||
if (res.statusCode == 403) { | ||
@@ -331,2 +332,8 @@ var error = new Error(); | ||
if (context['delay'] == '') { | ||
this.startDelay = 0; | ||
} else { | ||
this.startDelay = context['delay'] | ||
} | ||
this.requestParams = { | ||
@@ -384,2 +391,4 @@ 'key':this.applicationKey, | ||
this.startDelay = 0; | ||
this.requestParams = { | ||
@@ -428,17 +437,23 @@ 'key': this.applicationKey, | ||
if (context['delay'] == '') { | ||
this.startDelay = 0; | ||
} else { | ||
this.startDelay = context['delay'] | ||
} | ||
this.requestParams = { | ||
'key':this.applicationKey, | ||
'url':url, | ||
'width':context['width'], | ||
'height':context['height'], | ||
'format':context['format'], | ||
'bwidth':context['browserWidth'], | ||
'bheight':context['browserHeight'], | ||
'customid':context['customid'], | ||
'delay':context['delay'], | ||
'target':context['targetElement'], | ||
'customwatermarkid':context['customWaterMarkId'], | ||
'requestmobileversion':parseInt(context['requestAs']), | ||
'country':context['country'], | ||
'quality':parseInt(context['quality']) | ||
'key': this.applicationKey, | ||
'url': url, | ||
'width': context['width'], | ||
'height': context['height'], | ||
'format': context['format'], | ||
'bwidth': context['browserWidth'], | ||
'bheight': context['browserHeight'], | ||
'customid': context['customid'], | ||
'delay': context['delay'], | ||
'target': context['targetElement'], | ||
'customwatermarkid': context['customWaterMarkId'], | ||
'requestmobileversion': parseInt(context['requestAs']), | ||
'country': context['country'], | ||
'quality': parseInt(context['quality']) | ||
}; | ||
@@ -449,3 +464,3 @@ | ||
this.signaturePartTwo = '|' + context['format'] + '|' + context['height'] + '|' + context['width'] + '|' + context['browserHeight'] + '|' + context['browserWidth'] | ||
+ '|' + context['customId'] + '|' + context['delay'] + '|' + context['targetElement'] + '|' + context['customWaterMarkId'] + '|' + _toInt(context['requestAs']) | ||
+ '|' + context['customId'] + '|' + context['delay'] + '|' + context['targetElement'] + '|' + context['customWaterMarkId'] + '|' + _toInt(context['requestAs']) | ||
+ '|' + context['country'] + '|' + context['quality']; | ||
@@ -503,55 +518,57 @@ }; | ||
var intervalId = setInterval(function () { | ||
self.get_status(id, function (err, status) { | ||
if (err != null) { | ||
clearInterval(intervalId); | ||
if (oncompleteEvent != null) { | ||
oncompleteEvent(err, null); | ||
setTimeout(function () { | ||
var intervalId = setInterval(function () { | ||
self.get_status(id, function (err, status) { | ||
if (err != null) { | ||
clearInterval(intervalId); | ||
if (oncompleteEvent != null) { | ||
oncompleteEvent(err, null); | ||
} | ||
return; | ||
} | ||
return; | ||
} | ||
if (!status.cached && !status.processing) { | ||
clearInterval(intervalId); | ||
if (!status.cached && !status.processing) { | ||
clearInterval(intervalId); | ||
if (oncompleteEvent != null) { | ||
var error = new Error(); | ||
error.message = 'The screenshot did not complete with the error: ' + status.message; | ||
error.code = this.ERROR_CODES.RENDERING_ERROR; | ||
if (oncompleteEvent != null) { | ||
var error = new Error(); | ||
error.message = 'The screenshot did not complete with the error: ' + status.message; | ||
error.code = self.ERROR_CODES.RENDERING_ERROR; | ||
oncompleteEvent(error, null); | ||
oncompleteEvent(error, null); | ||
} | ||
} | ||
} | ||
else if (status.cached) { | ||
clearInterval(intervalId); | ||
else if (status.cached) { | ||
clearInterval(intervalId); | ||
self.get_result(id, function (err, result) { | ||
if (result == null || result == '') { | ||
if (oncompleteEvent != null) { | ||
var error = new Error(); | ||
error.message = 'The screenshot could not be found on GrabzIt.'; | ||
error.code = this.ERROR_CODES.RENDERING_MISSING_SCREENSHOT; | ||
self.get_result(id, function (err, result) { | ||
if (result == null || result == '') { | ||
if (oncompleteEvent != null) { | ||
var error = new Error(); | ||
error.message = 'The screenshot could not be found on GrabzIt.'; | ||
error.code = self.ERROR_CODES.RENDERING_MISSING_SCREENSHOT; | ||
oncompleteEvent(error, null); | ||
oncompleteEvent(error, null); | ||
return; | ||
return; | ||
} | ||
} | ||
} | ||
if (saveToFile == '') { | ||
if (oncompleteEvent != null) { | ||
oncompleteEvent(null, result) | ||
if (saveToFile == '') { | ||
if (oncompleteEvent != null) { | ||
oncompleteEvent(null, result) | ||
} | ||
} | ||
} | ||
file.writeFile(saveToFile, result, 'binary', function(err) { | ||
if (oncompleteEvent != null) { | ||
oncompleteEvent(err, null) | ||
} | ||
file.writeFile(saveToFile, result, 'binary', function (err) { | ||
if (oncompleteEvent != null) { | ||
oncompleteEvent(err, null) | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
}); | ||
}, 3000); | ||
} | ||
}); | ||
}, 3000); | ||
}, (3000 + self.startDelay)); | ||
}); | ||
@@ -708,3 +725,3 @@ }; | ||
if (oncomplete != null) { | ||
var error = _getError(res, data); | ||
var error = _getError(self, res, data); | ||
var obj = _convert(data, 'result'); | ||
@@ -711,0 +728,0 @@ if (error != null) { |
{ | ||
"name": "grabzit", | ||
"description": "Automatically create screenshots of website for free, with GrabzIt. Screenshots can be output in a variety of formats including: JPEG, PNG, TIFF, BMP, PDF, CSV and XLSX.", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"main": "./lib/grabzit", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28922
676
74