2 /*global $, tizen, App, app */
4 (function () { // strict mode wrapper
10 * @param {NFCControl} nfc
12 App.NFCCard = function nfc_NFCCard(nfc) {
16 App.NFCCard.prototype = {
18 readMessageErr: function nfc_card_readMessageErr(e) {
19 console.error('Read error! ' + e.message, e);
20 this.nfc.timeExpired('Read error! ' + e.message);
24 * Read contents from a tag
27 sucTagReadAttach: function nfc_card_sucTagReadAttach(tag) {
29 if (!tag.isSupportedNDEF) {
30 throw {message: "This tag doesn't support NDEF"};
33 this.nfc.readMessage.bind(this.nfc),
34 this.readMessageErr.bind(this)
37 this.readMessageErr(e);
44 setTagDetectRead: function nfc_card_setTagDetectRead() {
46 this.nfc.nfcAdapter.setTagListener({
47 onattach: this.sucTagReadAttach.bind(this),
48 ondetach: this.nfc.sucDetach.bind(this.nfc)
51 this.readMessageErr(error);
55 sucSend: function nfc_card_sucSend() {
56 this.nfc.timeExpired('Send success!');
59 errSend: function nfc_card_errSend(e) {
60 console.warn('errSend', e);
61 this.nfc.timeExpired('Write error! ' + e.message);
64 sucTagWriteAttach: function nfc_card_sucTagWriteAttach(tag) {
65 var newMessage = null,
69 fullContact = this.nfc.prepareForNFC(localStorage);
70 newMessage = this.nfc.phoneNumber2NDEF(fullContact);
71 if (!tag.isSupportedNDEF) {
72 throw {message: "This tag doesn't support NDEF"};
76 this.sucSend.bind(this),
77 this.errSend.bind(this)
84 setTagDetectWrite: function nfc_card_setTagDetectWrite() {
86 onattach: this.sucTagWriteAttach.bind(this),
87 ondetach: this.nfc.sucDetach.bind(this.nfc)
91 this.nfc.nfcAdapter.setTagListener(suc);