-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
6,854 additions
and
6,254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
.nitro | ||
.cache | ||
dist | ||
mobile/www | ||
mobile/platforms | ||
# Node dependencies | ||
node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,65 @@ | ||
<template> | ||
<div> | ||
<h1>NFC Text Sharing</h1> | ||
|
||
<div> | ||
<label for="mimeType">MIME Type:</label> | ||
<input type="text" v-model="mimeType" placeholder="text/plain"> | ||
</div> | ||
|
||
<div> | ||
<label for="payload">Payload:</label> | ||
<input type="text" v-model="payload" placeholder="Enter text to share"> | ||
</div> | ||
|
||
<button @click="shareMessage">Share via NFC</button> | ||
<button @click="loadSampleData">Load Sample Data</button> | ||
|
||
<div v-if="status" id="status">{{ status }}</div> | ||
<div class="grid grid-cols-2 gap-4"> | ||
<UButton @click="shareMessage" icon="i-solar-share-bold-duotone" variant="soft">Share Message</UButton> | ||
<UButton @click="openSettings" icon="i-solar-settings-bold-duotone" variant="soft">Settings</UButton> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
// Import necessary libraries for NFC, if available in Cordova environment | ||
import { ref, onMounted } from 'vue' | ||
// State variables | ||
const mimeType = ref('text/plain') | ||
const payload = ref('Hello from PhoneGap') | ||
const status = ref('') | ||
let sampleDataIndex = 0 | ||
import { onMounted } from 'vue' | ||
// Sample NFC data | ||
const sampleData = [ | ||
{ mimeType: 'text/pg', payload: 'Hello PhoneGap' }, | ||
{ mimeType: 'game/rockpaperscissors', payload: 'Rock' }, | ||
{ | ||
mimeType: 'text/x-vCard', | ||
payload: 'BEGIN:VCARD\nVERSION:2.1\nN:Coleman;Don;;;\nFN:Don Coleman\nORG:Chariot Solutions;\nTEL:215-358-1780\nEMAIL:dcoleman@chariotsolutions.com\nEND:VCARD' | ||
} | ||
] | ||
// Lifecycle hook to wait until device is ready | ||
// Wait until the device is ready | ||
onMounted(() => { | ||
document.addEventListener('deviceready', () => { | ||
console.log('Device is ready!') | ||
}) | ||
}) | ||
// Function to share message via NFC | ||
const shareMessage = () => { | ||
if (!window.nfc || !window.ndef) { | ||
alert("NFC or NDEF plugin not found!") | ||
return | ||
} | ||
const record = window.ndef.mimeMediaRecord(mimeType.value, window.nfc.stringToBytes(payload.value)) | ||
// Share NFC record | ||
window.nfc.share( | ||
[record], | ||
() => { | ||
navigator.notification.vibrate(100) // Vibrate on success | ||
setStatus("Message sent successfully!") | ||
}, | ||
(error) => { | ||
alert("Failed to share: " + error) | ||
setStatus("Error while sharing message") | ||
} | ||
) | ||
document.addEventListener("deviceready", onDeviceReady, false); | ||
}); | ||
// Function to handle device ready event | ||
function onDeviceReady () { | ||
// Enable NFC | ||
nfc.enabled( | ||
() => alert('NFC enabled'), | ||
error => alert(error) | ||
); | ||
// Add NFC tag reading listener | ||
nfc.addNdefListener(onNfcMessageRead, | ||
() => console.log("Listening for NFC messages"), | ||
error => console.log("Error adding NFC listener: " + error) | ||
); | ||
// Vibrate the device to indicate readiness | ||
navigator.vibrate(1000); | ||
} | ||
// Function to load sample data into inputs | ||
const loadSampleData = () => { | ||
const sample = sampleData[sampleDataIndex] | ||
mimeType.value = sample.mimeType | ||
payload.value = sample.payload | ||
// Function to read NFC message | ||
function onNfcMessageRead (nfcEvent) { | ||
var tag = nfcEvent.tag; | ||
var ndefMessage = tag.ndefMessage; | ||
sampleDataIndex++ | ||
if (sampleDataIndex >= sampleData.length) { | ||
sampleDataIndex = 0 | ||
if (ndefMessage) { | ||
// Iterate through the NDEF records | ||
var payload = nfc.bytesToString(ndefMessage[0].payload); | ||
console.log("Read NFC message:", payload); | ||
alert("NFC message: " + payload); | ||
} | ||
} | ||
// Function to set status message | ||
const setStatus = (message) => { | ||
status.value = message | ||
setTimeout(() => { status.value = '' }, 3000) | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
h1 { | ||
font-size: 1.5rem; | ||
margin-bottom: 1rem; | ||
} | ||
input { | ||
display: block; | ||
margin: 0.5rem 0; | ||
padding: 0.5rem; | ||
width: 100%; | ||
max-width: 300px; | ||
} | ||
button { | ||
margin: 0.5rem; | ||
padding: 0.5rem 1rem; | ||
font-size: 1rem; | ||
cursor: pointer; | ||
// Function to share a message via NFC | ||
const shareMessage = () => { | ||
var message = [ | ||
ndef.textRecord("Hello, world"), | ||
ndef.uriRecord("http://github.com/chariotsolutions/phonegap-nfc") | ||
]; | ||
nfc.write( | ||
message, | ||
() => console.log('Wrote data to NFC tag'), | ||
error => console.log("Write failed: " + error) | ||
); | ||
} | ||
#status { | ||
margin-top: 1rem; | ||
color: green; | ||
// Function to open NFC settings | ||
const openSettings = () => { | ||
nfc.showSettings(); | ||
} | ||
</style> | ||
</script> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>MagicPing V2.0</title> | ||
<link rel="stylesheet" href="/web/entry.BHRJPv_P.css"> | ||
<link rel="modulepreload" as="script" crossorigin href="/web/Cu8u9gU9.js"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/64UPlvN9.js"> | ||
<link rel="prefetch" as="style" crossorigin href="/web/error-404.D0jWoSZV.css"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/BxEeDPFq.js"> | ||
<link rel="prefetch" as="style" crossorigin href="/web/error-500.BFDZwCYg.css"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/7g-l3pP1.js"> | ||
<script id="unhead:payload" type="application/json">{"title":"MagicPing V2.0"}</script> | ||
<script type="module" src="/web/Cu8u9gU9.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1728217969310,false]</script> | ||
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/",buildId:"42f5c61e-a1e1-4130-bed6-f2406a671622",buildAssetsDir:"/web/",cdnURL:""}}</script></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>MagicPing V2.0</title> | ||
<link rel="stylesheet" href="/web/entry.BHRJPv_P.css"> | ||
<link rel="modulepreload" as="script" crossorigin href="/web/Cu8u9gU9.js"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/64UPlvN9.js"> | ||
<link rel="prefetch" as="style" crossorigin href="/web/error-404.D0jWoSZV.css"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/BxEeDPFq.js"> | ||
<link rel="prefetch" as="style" crossorigin href="/web/error-500.BFDZwCYg.css"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/7g-l3pP1.js"> | ||
<script id="unhead:payload" type="application/json">{"title":"MagicPing V2.0"}</script> | ||
<script type="module" src="/web/Cu8u9gU9.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1728217969311,false]</script> | ||
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/",buildId:"42f5c61e-a1e1-4130-bed6-f2406a671622",buildAssetsDir:"/web/",cdnURL:""}}</script></body></html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>MagicPing V2.0</title> | ||
<link rel="stylesheet" href="/web/entry.BHRJPv_P.css"> | ||
<link rel="modulepreload" as="script" crossorigin href="/web/Cu8u9gU9.js"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/64UPlvN9.js"> | ||
<link rel="prefetch" as="style" crossorigin href="/web/error-404.D0jWoSZV.css"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/BxEeDPFq.js"> | ||
<link rel="prefetch" as="style" crossorigin href="/web/error-500.BFDZwCYg.css"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/7g-l3pP1.js"> | ||
<script id="unhead:payload" type="application/json">{"title":"MagicPing V2.0"}</script> | ||
<script type="module" src="/web/Cu8u9gU9.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1728217969310,false]</script> | ||
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/",buildId:"42f5c61e-a1e1-4130-bed6-f2406a671622",buildAssetsDir:"/web/",cdnURL:""}}</script></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>MagicPing V2.0</title> | ||
<link rel="stylesheet" href="/web/entry.BHRJPv_P.css"> | ||
<link rel="modulepreload" as="script" crossorigin href="/web/Cu8u9gU9.js"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/64UPlvN9.js"> | ||
<link rel="prefetch" as="style" crossorigin href="/web/error-404.D0jWoSZV.css"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/BxEeDPFq.js"> | ||
<link rel="prefetch" as="style" crossorigin href="/web/error-500.BFDZwCYg.css"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/7g-l3pP1.js"> | ||
<script id="unhead:payload" type="application/json">{"title":"MagicPing V2.0"}</script> | ||
<script type="module" src="/web/Cu8u9gU9.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1728217969310,false]</script> | ||
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/",buildId:"42f5c61e-a1e1-4130-bed6-f2406a671622",buildAssetsDir:"/web/",cdnURL:""}}</script></body></html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<browserconfig> | ||
<msapplication> | ||
<tile> | ||
<square150x150logo src="/public/mstile-150x150.png"/> | ||
<TileColor>#00ffca</TileColor> | ||
</tile> | ||
</msapplication> | ||
</browserconfig> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>MagicPing V2.0</title> | ||
<link rel="stylesheet" href="/web/entry.BHRJPv_P.css"> | ||
<link rel="modulepreload" as="script" crossorigin href="/web/Cu8u9gU9.js"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/64UPlvN9.js"> | ||
<link rel="prefetch" as="style" crossorigin href="/web/error-404.D0jWoSZV.css"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/BxEeDPFq.js"> | ||
<link rel="prefetch" as="style" crossorigin href="/web/error-500.BFDZwCYg.css"> | ||
<link rel="prefetch" as="script" crossorigin href="/web/7g-l3pP1.js"> | ||
<script id="unhead:payload" type="application/json">{"title":"MagicPing V2.0"}</script> | ||
<script type="module" src="/web/Cu8u9gU9.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1728217969311,false]</script> | ||
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/",buildId:"42f5c61e-a1e1-4130-bed6-f2406a671622",buildAssetsDir:"/web/",cdnURL:""}}</script></body></html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.