I am using this package:
cordova:com.phonegap.plugins.barcodescanner
and you scan using this function:
Template.barcode_scanner.events({
'click button': function () {
cordova.plugins.barcodeScanner.scan(
function (result) {
if(!result.cancelled)
{
alert("Barcode type is: " + result.format);
alert("Decoded text is: " + result.text);
}
else
{
alert("You have cancelled scan");
}
},
function (error) {
alert("Scanning failed: " + error);
}
);
}
});
I am wondering how I can customize the scanning screen. I need to add a few buttons to the scanning screen. Anyone know how?
I fixed it by using the package:
cordova:cordova-plugin-qrscanner
Docs:
https://www.npmjs.com/package/cordova-plugin-qrscanner
It is fully customizable, but only reads QR codes.
Related
I am using Ostrio/files also known as meteor-files (from VeliovGroup or keenethics) on the server-side to insert a file to db.images, db.fs.files and db.fs.chunks. My code only manages to insert a record only in db.images and nothing on fs.files and fs.chunks. My code is as follows:
Images.write(this.bodyParams.file, {
fileName: 'SignUpTermsAndConditions_' + this.bodyParams.name,
fielId: 'abc123myId', //optional
type: 'application/vnd.oasis.opendocument.text',
meta: {owner: this.userId,createdAt: new Date()}
}, function (error, fileRef) {
if (error) {
throw error;
} else {
console.log(fileRef.name + ' is successfully saved to FS. _id: ' + fileRef._id);
}
});
I am able to insert a file from the client into db.images, db.fs.files and db.fs.chunks using the following code:
Images.insert({
file: file, // where var file = e.currentTarget.files[0];
fileName: fileName + e.currentTarget.files[0].name,
onStart: function () {
},
onUploaded: function (error, fileObj) {
if (error) {
alert('Error during upload: ' + error);
} else {
}
},
streams: 'dynamic',
chunkSize: 'dynamic'
});
The server code as per the first snippet above is one that is not working correctly or as expected.Please help.
For info: how I setup my gridFS is as per
this link. My Images.write as per my second code snippet above is as per the code in
this link. In short I am following the documentation but my server Images.write is not working as expected.Please help!
I found the answer to my question. I set the fourth parameter to true i.e proceedAfterUpload=true and records are inserted in db.fs.files and db.fs.chunks. This is as per the write method documentation, it is slightly vague though. Here is the amended code:
Images.write(this.bodyParams.file, {
fileName: 'SignUpTermsAndConditions_' + this.bodyParams.name,
fielId: 'abc123myId', //optional
type: 'application/vnd.oasis.opendocument.text',
meta: {owner: this.userId,createdAt: new Date()}
}, function (error, fileRef) {
if (error) {
throw error;
} else {
console.log(fileRef.name + ' is successfully saved to FS. _id: ' + fileRef._id);
}
},proceedAfterUpload=true);
That's it.
PS: Make sure this.bodyParams.file is a buffer so that the inserted file is not corrupt - thanks to #dr.dimitru for advising me on inserting a buffer.
I'm trying to scrape products with color and size variations.
Every variation is a form and to get the next variation I'm clicking on radio button and it is doing a form submit action on each click.
I have tried to click it using
1. “casper.getElementsInfo(element)[0].click();”
2. “document.querySelectorAll(element)[2].click();”
3. “casper.thenClick('element');”
4. “casper.evaluate(function(){document.querySelectorAll(element)[2].click();});”
After every click I'm doing a casper wait for 8 seconds !
So here is my problem Casperjs is getting error after clicking the next color/size
var casper = require('casper').create({
viewportSize: {
width: 1920,
height: 1080
},
pageSettings: {
loadImages: false,
loadPlugins: false
}
});
casper.then(function () {
self.thenOpen("https://scubapro.johnsonoutdoors.com/fins/fins/seawing-nova-fin-full-foot", function () {
casper.then(function () {
var varitoinCount = document.querySelectorAll('div#edit-attributes-field-swatch-taxonomy > div input').length;
var i = 0;
casper.repeat(varitoinCount + 1, function () {
try {
document.querySelectorAll('div#edit-attributes-field-swatch-taxonomy > div input')[i].click();
casper.log('we got to anhoter variatoin ...' + i);
} catch (error) {
console.log(error);
}
i++;
});
});
});
});
try {
casper.run();
} catch (e) {
consol.log("Error..... " + e);
}
(TypeError: undefined is not a constructor )
And btw when I'm doing the same thing in a console it works fine
You have to understand that accessing DOM is not possible in Casper environment. You should switch to browser environment to execute your DOM selectors by using Casper's evaluate method. Basically it used to get some information from within browser or to manually do some actions with javascript. To understand it you have a whole section dedicated for that in official documentation.
That being said, I amended your code to properly click on different color variation inputs.
var casper = require('casper').create({
viewportSize: {
width: 1920,
height: 1080
},
pageSettings: {
loadImages: false,
loadPlugins: false
}
});
casper
.start()
.thenOpen("https://scubapro.johnsonoutdoors.com/fins/fins/seawing-nova-fin-full-foot", function () {
var varitoinCount = this.evaluate(function() {
return document.querySelectorAll('div#edit-attributes-field-swatch-taxonomy > div input').length;
});
var i = 0;
this.repeat(varitoinCount + 1, function() {
this.evaluate(function(iterator) {
document.querySelectorAll('div#edit-attributes-field-swatch-taxonomy > div input')[i].click();
}, i);
i++;
})
});
try {
casper.run();
} catch (e) {
console.log("Error..... " + e);
}
However it still doesn't change the color since website(for some reason) needs to take 2 clicks to change the color and I suggest that you throw in some waitFor functions to be sure that color has changed.
I implemented a React native Toolbar its showing me all actions which i have given but after press on that any action it gives me error. Its entering in the function that onActionSelected But after that my Logout() , Move() any function is not working.
where i am going wrong plz help
code:
<ToolbarAndroid
title="Shopcon"
style={styles.toolbar}
actions={toolbarActions}
onActionSelected={this.onActionSelected}
/>
const toolbarActions = [
{title: 'Logout', show: 'never'},
{title: 'Got to Login', show: 'never'},
];
onActionSelected(position) {
if (position === 0) {
console.log("I am in 0");
this.Logout();
}
if (position === 1) {
console.log("I am in 1");
this.Move();
}
}
async Logout() {
console.log("fun1");
const { navigate } = this.props.navigation;
try {
await AsyncStorage.removeItem(STORAGE_KEY);
Alert.alert("Logout Success! Token:" + DEMO_TOKEN)
} catch (error) {
console.log('AsyncStorage error: ' + error.message);
}
navigate("Login");
}
Move(){
console.log("fun2")
const { navigate } = this.props.navigation;
navigate("Login");
}
both are entering in onActionSelected(position) function but not entering in those other functions.
where i am going wrong please help.
I get the following error with this code in the update function below and I don't understand why.
err: [RangeError: Maximum call stack size exceeded]
Does it have something to do with using Meteor.setTimeout()?
if (Meteor.isServer) {
Meteor.clearTimeout(league.nextPickTimeoutId);
var pickTimeoutId = Meteor.setTimeout(function () {
Meteor.call('pickPlayer', leagueId, findTopScoringPlayer(leagueId, nextTeam._id)._id);
}, 30*1000);
Leagues.update(leagueId, {
$set: {
nextPickTill: new Date().getTime() + (league.secondsPerPick * 1000),
nextPickTimeoutId: pickTimeoutId
}
}, function (err) {
if (err) console.log('err:', err);
});
}
The problem was that:
Meteor.setTimeout() returns a handle that can be used by Meteor.clearTimeout. Source
The Meteor.clearTimeout() function confused me that I thought took an id as an argument.
i have been using colorbox lightbox(slideshow) but the problem is whenever i click on the image i get "settings is undefined". which setting is it talking about. i am confused. i tried to change the settings but i can't find what to change. the settings it showed was
if (settings.slideshow && $related[1]) {
start = function () {
$slideshow
.text(settings.slideshowStop)
.unbind(click)
.bind(event_complete, function () {
if (index < $related.length - 1 || settings.loop) {
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
}
})
.bind(event_load, function () {
clearTimeout(timeOut);
})
.one(click + ' ' + event_cleanup, stop);
$box.removeClass(className + "off").addClass(className + "on");
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
};
stop = function () {
clearTimeout(timeOut);
$slideshow
.text(settings.slideshowStart)
.unbind([event_complete, event_load, event_cleanup, click].join(' '))
.one(click, function () {
publicMethod.next();
start();
});
$box.removeClass(className + "on").addClass(className + "off");
};
if (settings.slideshowAuto) {
start();
} else {
stop();
}
} else {
$box.removeClass(className + "off " + className + "on");
}
}
what do i have to change here. thanks for any suggestion or help.
You don't change anything there. You are likely getting that error because you are doing someone on your end that is removing the settings data. Show what you are doing, not snippets of code from the plugin.