mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-13 05:31:37 +08:00
Removing dependency on script-name
This commit is contained in:
+17
-14
@@ -1,5 +1,6 @@
|
||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
||||
/* global define, vec2, importScripts */
|
||||
/* jshint undef: true, unused: true, browser:true, devel: true, evil: true */
|
||||
/* global define, vec2 */
|
||||
|
||||
|
||||
define(["code_128_reader", "ean_reader", "input_stream", "image_wrapper", "barcode_locator", "barcode_decoder", "frame_grabber", "html_utils", "config", "events", "camera_access", "image_debug"],
|
||||
function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, BarcodeDecoder, FrameGrabber, HtmlUtils, _config, Events, CameraAccess, ImageDebug) {
|
||||
@@ -278,8 +279,13 @@ function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, Ba
|
||||
}
|
||||
|
||||
|
||||
function workerInterface(scriptUrl) {
|
||||
importScripts(scriptUrl);
|
||||
function workerInterface(factory) {
|
||||
if (factory) {
|
||||
var Quagga = factory();
|
||||
if (!Quagga) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* jshint ignore:start */
|
||||
var imageWrapper;
|
||||
|
||||
@@ -313,18 +319,15 @@ function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, Ba
|
||||
|
||||
function generateWorkerBlob() {
|
||||
var blob,
|
||||
quaggaAbsoluteUrl,
|
||||
scripts = document.getElementsByTagName('script'),
|
||||
regex = new RegExp('\/' + _config.scriptName + '$');
|
||||
factorySource;
|
||||
|
||||
quaggaAbsoluteUrl = Array.prototype.slice.apply(scripts).filter(function(script) {
|
||||
return script.src && script.src.match(regex);
|
||||
}).map(function(script) {
|
||||
return script.src;
|
||||
})[0];
|
||||
/* jshint ignore:start */
|
||||
if (typeof __factorySource__ !== 'undefined') {
|
||||
factorySource = __factorySource__;
|
||||
}
|
||||
/* jshint ignore:end */
|
||||
|
||||
|
||||
blob = new Blob(['(' + workerInterface.toString() + ')("' + quaggaAbsoluteUrl + '");'],
|
||||
blob = new Blob(['(' + workerInterface.toString() + ')(' + factorySource + ');'],
|
||||
{type : 'text/javascript'});
|
||||
|
||||
return window.URL.createObjectURL(blob);
|
||||
|
||||
Reference in New Issue
Block a user