-
Notifications
You must be signed in to change notification settings - Fork 1
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
7 changed files
with
93 additions
and
76 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ name: Release Webxdc | |
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
- "v*.*.*" | ||
|
||
jobs: | ||
build: | ||
|
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,4 +1,5 @@ | ||
dist | ||
dist-xdc | ||
webxdc.js | ||
webxdc.d.ts | ||
webxdc.d.ts | ||
pnpm-lock.yaml |
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 |
---|---|---|
@@ -1,28 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
|
||
<script src="webxdc.js"></script> | ||
<link rel="stylesheet" href="./css/main.css"> | ||
</head> | ||
<body> | ||
<h1>Chat</h1> | ||
<form> | ||
<input id="input" type="text" autocomplete="off" placeholder="Message" autofocus /> | ||
<input class="btn" type="submit" onclick="sendMsg(); return false;" value="Send" /> | ||
</form> | ||
<p id="chat-area"></p> | ||
<p><em><small id="deviceName"></small></em></p> | ||
<script src="./js/main.js" type="module"></script> | ||
<script src="webxdc.js"></script> | ||
<link rel="stylesheet" href="./css/main.css" /> | ||
</head> | ||
<body> | ||
<h1>Chat</h1> | ||
<form> | ||
<input | ||
id="input" | ||
type="text" | ||
autocomplete="off" | ||
placeholder="Message" | ||
autofocus | ||
/> | ||
<input | ||
class="btn" | ||
type="submit" | ||
onclick="sendMsg(); return false;" | ||
value="Send" | ||
/> | ||
</form> | ||
<p id="chat-area"></p> | ||
<p> | ||
<em><small id="deviceName"></small></em> | ||
</p> | ||
<script src="./js/main.js" type="module"></script> | ||
|
||
<!-- Uncomment to include developer tools in your webxdc to debug it inside Delta Chat --> | ||
<!-- | ||
<!-- Uncomment to include developer tools in your webxdc to debug it inside Delta Chat --> | ||
<!-- | ||
<script type="module"> | ||
import init from 'eruda' | ||
init.init(); | ||
</script> | ||
--> | ||
</body> | ||
</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 |
---|---|---|
@@ -1,40 +1,45 @@ | ||
function h(tag, attributes, ...children) { | ||
const element = document.createElement(tag); | ||
if (attributes) { | ||
Object.entries(attributes).forEach(entry => { | ||
element.setAttribute(entry[0], entry[1]); | ||
}); | ||
} | ||
element.append(...children); | ||
return element; | ||
const element = document.createElement(tag); | ||
if (attributes) { | ||
Object.entries(attributes).forEach((entry) => { | ||
element.setAttribute(entry[0], entry[1]); | ||
}); | ||
} | ||
element.append(...children); | ||
return element; | ||
} | ||
|
||
window.sendMsg = () => { | ||
let msg = document.getElementById("input").value; | ||
let info = window.webxdc.selfName + ': ' + msg; | ||
document.getElementById("input").value = ''; | ||
let msg = document.getElementById("input").value; | ||
let info = window.webxdc.selfName + ": " + msg; | ||
document.getElementById("input").value = ""; | ||
|
||
// send new updates | ||
window.webxdc.sendUpdate({ | ||
payload: { | ||
name: window.webxdc.selfName, | ||
msg, | ||
}, | ||
info, | ||
}, info); | ||
} | ||
// send new updates | ||
window.webxdc.sendUpdate( | ||
{ | ||
payload: { | ||
name: window.webxdc.selfName, | ||
msg, | ||
}, | ||
info, | ||
}, | ||
info | ||
); | ||
}; | ||
|
||
window.onload = () => { | ||
// handle past and future state updates | ||
window.webxdc.setUpdateListener(function (update) { | ||
const chat = document.getElementById('chat-area'); | ||
chat.append( | ||
h("p", {class: "msg"}, | ||
h("span", {class: "nick"}, update.payload.name, ": "), | ||
update.payload.msg, | ||
) | ||
); | ||
}); | ||
// handle past and future state updates | ||
window.webxdc.setUpdateListener(function (update) { | ||
const chat = document.getElementById("chat-area"); | ||
chat.append( | ||
h( | ||
"p", | ||
{ class: "msg" }, | ||
h("span", { class: "nick" }, update.payload.name, ": "), | ||
update.payload.msg | ||
) | ||
); | ||
}); | ||
|
||
window.deviceName.innerHTML = 'You are: ' + window.webxdc.selfName; | ||
window.deviceName.innerHTML = "You are: " + window.webxdc.selfName; | ||
}; |
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,6 +1,5 @@ | ||
import { expect, test } from "vitest"; | ||
|
||
|
||
test("Example Test", () => { | ||
expect(1+1).toBe(2); | ||
expect(1 + 1).toBe(2); | ||
}); |
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