Am using phonegap-plugin-barcodescanner in a phonegap app to scan QR codes.
When firing the scanner using:
function scan() {
cordova.plugins.barcodeScanner.scan(
function (result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
function (error) {
alert("Scanning failed: " + error);
}
);
}
The camera doesn't start - I just get a prompt saying:
"Enter barcode value (empty value will fire handler)"
Any ideas welcome TQ
The prompt says "Enter barcode value (empty value will fire handler)" maybe because you run platform browser. I' ve got the same "problem" when i run my project with "cordova run browser", and "browser" is a platform installed.
Related
Previously the code worked correctly. Why an internal error has occurred?
Is this a problem with the JavaScript API for Office?
https://learn.microsoft.com/en-us/outlook/add-ins/add-and-remove-attachments-to-an-item-in-a-compose-form
The link and title are correct. I checked it out.
var options = {
asyncContext: null
};
Office.context.mailbox.item.addFileAttachmentAsync(link, title, options, function (asyncResult) {
console.log("asyncResult: " + JSON.stringify(asyncResult));
if (asyncResult.status === "succeeded") {
$docName.prepend("<i class='ms-Icon ms-Icon--checkbox ms-font-m ms-fontColor-green'>");
$fileProcess.resolve();
} else {
console.log("Office.context.mailbox.item.addFileAttachmentAsync() [" + asyncResult.status + "] error: "//
+ JSON.stringify(asyncResult.error) + " value: " + JSON.stringify(asyncResult.value));
$fileProcess.reject();
$attachedDoc.addClass("ms-bgColor-error");
$docName.prepend("<i class='ms-Icon ms-Icon--alert ms-font-m ms-fontColor-error'></i>");
$docName.after("<div class='ms-ListItem-tertiaryText addedError'>" + asyncResult.error.message + "</div>");
}
});
I got an asyncResult:
asyncResult: {"value":null,"status":"failed","error":{"name":"Internal Error","message":"An internal error has occurred."}}
The problem was with a self-signed certificate.
I have an monitor.js file that I turned into an executable using nexe.
I want the monitor to have the ability to uninstall itself, which means delete it's own .exe file and his containing directory.
I tried : (monitorPath = monitor.exe file path, installPath = monitor.exe folder)
childProcess.exec("TIMEOUT 3 && del " + monitorPath + " && rmdir " + installPath);
setTimeout(function() {
process.exit(0);
}, 2000);
EDIT: It should run on windows, so those are all windows commands
Solved using the start command
var installPath = path.join(exePath, "..");
var monitorPath = path.join(installPath, "qqmonitor.exe");
var delCommand = 'start cmd /c "cd .. && TIMEOUT 1 && del "' + monitorPath + '" && rmdir "' + installPath + '" && exit"';
log("Uninstalling with command : '" + delCommand + "'");
childProcess.exec(delCommand, null);
setTimeout(function () {
process.exit(0);
}, 500);
My Popup.js is passing a value to my local php file for processing then the results are displayed on popup.html as shown below:
$.get("get_charities.php", {scope: "ALL", m_val: formatted_val},function(charity_arr){
$('#convertor_content .result').remove();
console.log(charity_arr);
for(var i in charity_arr){
$('#convertor_content').append( "Enough to "+ charity_arr[i].pre_text+" <a href='" + charity_arr[i].url + "' target='_blank'>" + Math.round(charity_arr[i].impact_value) + " " + charity_arr[i].post_text + "</a>" + "<br>" + "<hr>" );
}
});
Since I am using a local php file, how do I test if my popup.html is working correctly?
I am firing an event using ontouchstart. It is working on other Android browsers like Firefox and Chrome (desktop too), but it is not functioning on the default Android browser.
Here is my code:
gauge.node.ontouchstart = function (e) {
e.preventDefault();
$.get("/varigate/zone/" + zoneId, function(zone) {
$.get("/varigate/crop/" + zone['cropId'] + "/name", function(cropName) {
var capitalized = cropName.charAt(0).toUpperCase() + cropName.slice(1);
deletePaddock();
history.pushState(null, "Irrigation of Field " + paddockId, "irrigation/id=" + paddockId);
switchToPage('gauge', irrigationPlan, paddockId, capitalized, zone['label'], currentFarm);
});
});
};
I can't seem to get PhantomJS through a test successfully. I tried to integrate it into my project, but after that failed I tried to just run the basic Angular Docs samples and I'm getting the same issue. My steps so far:
npm install -g phantomjs
phantomjs --webdriver=9515 // ... GhostDriver - Main - running on port 9515
protractor protractorConf.js
This is the same file from the example with only browserName, and seleniumAddress port changed:
// An example configuration file.
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:9515',
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'phantomjs'
},
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['onProtractorRunner.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
}
};
I get the following error message:
UnknownError: Error Message => 'Detected a page unload event; asynchronous script execution does not work across page loads.'
I found this issue on github, which seemed to be related. I thought I had made enough sense of their brower-setup.md to include it in one of my beforeEach functions. Then I found here ptor is just wrapping the driver anyway. Wow, I know I'm a noob here in protractor/selenium land, but the signal to noise ratio is intensively dissuasive. I'd really like to get the performance benefits of using PhantomJS, but the prospect of losing several more hours on this is hurting my head. I'm on Windows 7 Enterprise 64-bit, in case that matters. Thanks!
Acutally this fix was solving the same issue for me:
https://github.com/pschwartau/protractor/commit/1eeff8b1b2e3e8f3b7c8152264411f26d4665a07
As originally described here: https://github.com/angular/protractor/issues/85#issuecomment-26846255 by renanmartins
Inside protractor/lib/protractor.js Replace
this.driver.get('about:blank');
this.driver.executeScript(
'window.name = "' + DEFER_LABEL + '" + window.name;' +
'window.location.href = "' + destination + '"');
with
var driver = this.driver;
this.getCapabilities().then(function (capabilities) {
if (capabilities.caps_.browserName === 'phantomjs') {
driver.executeScript('window.name = "' + DEFER_LABEL + '" + window.name;');
driver.get(destination);
} else {
driver.get('about:blank');
driver.executeScript(
'window.name = "' + DEFER_LABEL + '" + window.name;' +
'window.location.href = "' + destination + '"');
}
// Make sure the page is an Angular page.
driver.executeAsyncScript(clientSideScripts.testForAngular, 10).
then(function(hasAngular) {
if (!hasAngular) {
throw new Error('Angular could not be found on the page ' +
destination);
}
});
});