These forums have officially been deprecated. Please post all new issues on the IDZ forums.

scanner camera barcode QR code

scanner camera barcode QR code

Postby stubuck » Thu May 30, 2013 10:35 am

I am working on a small project for a school assignment and I need some help. I would like to use the smart phone to scan books into a database, however I'm very new to programming and app development. Can anyone provide some help on how to use the scanner jsAPI (http://html5dev-software.intel.com/docu ... index.html)?

I have a very simple screen... one form that contains the following... one text input field (label - scan book), one submit button, one reset button and one "scan book" button (that's as far a I've been able to get because I'm not very proficient with my programming skills -yet).

I don't know how to 'tell' the scan book button to open the camera, grab the barcode and place the information in the text field so that I can either look for the book in the database OR (if not found) add the book to the database.

Thank you for any help you can offer.

Stu Buck
stubuck
 
Posts: 17
Joined: Thu May 23, 2013 11:47 am

Re: scanner camera barcode QR code

Postby IntelJohn » Fri May 31, 2013 7:26 am

Code: Select all
  <button id="btnBeep" ontouchstart="scan();">Beep</button>

function scan()
{
AppMobi.device.scanBarcode();
}

document.addEventListener("appMobi.device.barcode.scan",function(evt){
        AppMobi.notification.beep(1);
        if (evt.success == true) {
                //successful scan
                console.log(evt.codedata);

                if (evt.codedata == "http://www.sampleurl.com/fake.html")
                {
                        //in the XDK
                }
                else
                {
                        alert(evt.codedata);  // alerts what was scanned
                        document.getElementById('inputFiled').innerHTML=evt.codedata;  // this will put what was scanned into an input field you have created named 'inputField'
                }
        }else {
                //failed scan
                console.log("failed scan");
        }
},false);



You will need to figure out how to look in the db or add it your self :)
IntelJohn
 
Posts: 4255
Joined: Mon Apr 19, 2010 9:00 am

Re: scanner camera barcode QR code

Postby stubuck » Sun Jun 02, 2013 1:42 pm

IntelJohn... Thank you so much :D !!!
I cannot begin to express how much your expertise has helped and is very much appreciated!

Best Regards,
Stu Buck
stubuck
 
Posts: 17
Joined: Thu May 23, 2013 11:47 am

Re: scanner camera barcode QR code

Postby skirix » Thu Oct 03, 2013 4:05 am

Hi,
I am using the same code snippet, but the event "appMobi.device.barcode.scan" is never fired...
skirix
 
Posts: 55
Joined: Fri Sep 06, 2013 3:12 am

Re: scanner camera barcode QR code

Postby scgrant327 » Thu Oct 10, 2013 3:31 pm

document.getElementById('inputFiled')

Should be:

document.getElementById('inputField')
scgrant327
 
Posts: 606
Joined: Fri Oct 28, 2011 10:36 am

Re: scanner camera barcode QR code

Postby skirix » Mon Oct 14, 2013 3:31 am

Code: Select all
 /*******************Barcode Scan Test******************/
       
       $('#btnLogin').click(function scan()
        {
            alert('scan begin');
             AppMobi.device.scanBarcode();
             alert('scan ending');
        }
        );
         document.addEventListener("appMobi.device.barcode.scan",barcodeScanned,false);
       

/*******************Barcode Scan Test******************/




    };
    document.addEventListener("appMobi.device.ready",onDeviceReady,false);
   
     var barcodeScanned=function (evt){
        alert('scan listener');
        if (evt.success == true) {
                //successful scan
                alert('scan success');

                if (evt.codedata == "http://www.sampleurl.com/fake.html")
                {
                        //in the XDK
                        alert('scan success');
                }
                else
                {
                    alert('scan success2');
                        alert(evt.codedata);  // alerts what was scanned
                        //document.getElementById('inputFiled').innerHTML=evt.codedata;  // this will put what was scanned into an input field you have created named 'inputField'
                }
            }
        else {
                //failed scan
                alert('scan failed');
                console.log("failed scan");
        }
        };
     
  </script>


'barcodeScanned' Is called only when the scan fails
skirix
 
Posts: 55
Joined: Fri Sep 06, 2013 3:12 am

Re: scanner camera barcode QR code

Postby skirix » Fri Nov 08, 2013 5:28 am

Resolved...

I had Carriage Return on my QR Code.
skirix
 
Posts: 55
Joined: Fri Sep 06, 2013 3:12 am

Re: scanner camera barcode QR code

Postby IntelJohn » Fri Nov 08, 2013 10:01 am

I recently (yesterday) discovered the same thing. I filed a bug and it will be handled as time allows.
IntelJohn
 
Posts: 4255
Joined: Mon Apr 19, 2010 9:00 am

Re: scanner camera barcode QR code

Postby cindy313 » Mon Nov 25, 2013 2:20 am

stubuck wrote:I am working on a small project for a school assignment and I need some help. I would like to use the smart phone to scan books into a database, however I'm very new to programming and app development. Can anyone provide some help on how to use the scanner jsAPI (http://html5dev-software.intel.com/docu ... index.html)?

I have a very simple screen... one form that contains the following... one text input field (label - scan book), one submit button, one reset button and one "scan book" button (that's as far a I've been able to get because I'm not very proficient with my programming skills -yet).

I don't know how to 'tell' the scan book button to open the camera, grab the barcode and place the information in the text field so that I can either look for the book in the database OR (if not found) add the book to the database.

Thank you for any help you can offer.

Stu Buck

er. which barcode scanner you used?
cindy313
 
Posts: 14
Joined: Tue Aug 13, 2013 1:20 am

Re: scanner camera barcode QR code

Postby stubuck » Mon Nov 25, 2013 12:42 pm

Cindy313

I'm not using a barcode scanner. I'm attempting to use my phone (both android os and apple os) to read and return value using the camera on the device. I know there are bluetooth attached scanners available for both android and apple, however, I'd rather use the mobile device capability to read scan code and/or QR code and return the data to my app.

I've had some 'luck' with my programming... but as I mentioned, I'm very new to the mobile programming world and even though the Intel XDK seems to be a great environment, I'm still on a steep learning curve with all the framework and programming.

Thanks for your question. Now may I ask you a question? What is your interest / capability?

Stu Buck
stubuck
 
Posts: 17
Joined: Thu May 23, 2013 11:47 am

Next

Return to Help getting started with Intel

Who is online

Users browsing this forum: No registered users and 2 guests