Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
floki1250 committed Oct 6, 2024
1 parent 9d3b045 commit 57ed898
Show file tree
Hide file tree
Showing 37 changed files with 6,854 additions and 6,254 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
.nitro
.cache
dist
mobile/www
mobile/platforms
# Node dependencies
node_modules
Expand Down
150 changes: 49 additions & 101 deletions components/NfcTest.vue
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>
16 changes: 16 additions & 0 deletions mobile/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"devDependencies": {
"cordova-android": "^13.0.0",
"cordova-browser": "^7.0.0",
"cordova-plugin-vibration": "^3.1.1",
"phonegap-nfc": "^1.2.0"
},
"cordova": {
Expand All @@ -23,7 +24,8 @@
"android"
],
"plugins": {
"phonegap-nfc": {}
"phonegap-nfc": {},
"cordova-plugin-vibration": {}
}
}
}
13 changes: 13 additions & 0 deletions mobile/www/200.html
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>
13 changes: 13 additions & 0 deletions mobile/www/404.html
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>
Binary file added mobile/www/MagicPing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions mobile/www/Receive/index.html
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>
13 changes: 13 additions & 0 deletions mobile/www/Send/index.html
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>
Binary file added mobile/www/android-chrome-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile/www/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions mobile/www/browserconfig.xml
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>
Binary file added mobile/www/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile/www/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile/www/favicon.ico
Binary file not shown.
Binary file added mobile/www/hello.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions mobile/www/index.html
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>
Binary file added mobile/www/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 57ed898

Please sign in to comment.