jsxc-react-hook 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +9 -0
- package/package.json +1 -1
- package/public/jsxc.bundle.js +1 -1
- package/src/Jsxc.tsx +32 -2
- package/src/Sel.tsx +2 -2
- package/src/lib/styles/jsxc.bundle.css +3 -3
package/src/Jsxc.tsx
CHANGED
@@ -2,36 +2,58 @@ import './lib/styles/jsxc.bundle.css';
|
|
2
2
|
import {useEffect} from 'react';
|
3
3
|
//import Keepalive from 'react-activation';
|
4
4
|
|
5
|
+
let userJid: string = '';
|
6
|
+
|
5
7
|
export interface JsxcProp {
|
6
8
|
boshUrl: string;
|
7
9
|
id: string;
|
8
10
|
pw: string;
|
11
|
+
contactId?: string,
|
9
12
|
marginTop?: string;
|
10
13
|
marginLeft?: string;
|
11
14
|
marginBottom?: string;
|
12
15
|
marginRight?: string;
|
13
16
|
fullscreen?: boolean;
|
14
17
|
jqueryUrl?: string;
|
18
|
+
showMenu: "yes"|"no";
|
19
|
+
}
|
20
|
+
|
21
|
+
export async function directOpenChatWindow(jid: string) {
|
22
|
+
if (!userJid) {
|
23
|
+
throw "user jid is empty, please initialize jsxc";
|
24
|
+
}
|
25
|
+
await (window as any).jsxc.getAccount(userJid).account.getConnection().getRosterService().
|
26
|
+
addContact(new (window as any).jsxc.JID(jid), '');
|
27
|
+
(window as any).jsxc.getAccount(userJid).getContact(jid).openChatWindow();
|
15
28
|
}
|
16
29
|
|
17
30
|
export function Jsxc(prop: JsxcProp) {
|
31
|
+
|
18
32
|
const rosterAppend = 'roster-append';
|
19
33
|
const windowListAppend = 'windowlist-append';
|
20
34
|
const dialogAppend = 'dialog-append';
|
21
35
|
const {
|
22
|
-
|
36
|
+
|
23
37
|
jqueryUrl = 'https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.js',
|
24
38
|
marginTop = '40px',
|
25
39
|
marginLeft = '40px',
|
26
40
|
marginBottom = '40px',
|
27
41
|
marginRight = '40px',
|
42
|
+
contactId = null,
|
43
|
+
showMenu,
|
44
|
+
fullscreen,
|
28
45
|
boshUrl,
|
29
46
|
id,
|
30
47
|
pw
|
31
48
|
} = prop;
|
32
|
-
useEffect(()=>{
|
33
49
|
|
50
|
+
userJid = id;
|
51
|
+
|
52
|
+
useEffect(()=>{
|
34
53
|
if ((window as any).jsxc) {
|
54
|
+
if (contactId) {
|
55
|
+
(window as any).jsxc.getAccount(id).getContact(contactId).openChatWindow();
|
56
|
+
}
|
35
57
|
return;
|
36
58
|
}
|
37
59
|
if (fullscreen) {
|
@@ -54,6 +76,8 @@ export function Jsxc(prop: JsxcProp) {
|
|
54
76
|
root.style.setProperty('--jsxc-margin-right', marginRight);
|
55
77
|
|
56
78
|
|
79
|
+
|
80
|
+
|
57
81
|
script.onload = ()=> { localStorage.removeItem('jsxc2:accounts'); // for fobidden show 'account has ..' error message;
|
58
82
|
let jsx = new (window as any).JSXC({
|
59
83
|
/* loadConnectionOptions: function(username: any, password: any) {
|
@@ -71,6 +95,12 @@ export function Jsxc(prop: JsxcProp) {
|
|
71
95
|
(window as any).jsxc = jsx;
|
72
96
|
jsx.start(boshUrl, id, pw);}
|
73
97
|
|
98
|
+
if (showMenu === 'yes') {
|
99
|
+
root.style.setProperty('--jsxc-show-menu', 'none');
|
100
|
+
console.log('not show jsxc menu')
|
101
|
+
}
|
102
|
+
|
103
|
+
|
74
104
|
},[]);
|
75
105
|
|
76
106
|
|
package/src/Sel.tsx
CHANGED
@@ -11,9 +11,9 @@ export default function Sel() {
|
|
11
11
|
}
|
12
12
|
}>
|
13
13
|
|
14
|
-
|
14
|
+
|
15
15
|
{sel && <Jsxc boshUrl = 'https://localhost:5443/bosh' fullscreen={true}
|
16
|
-
id= 'user1@localhost' pw='987654'
|
16
|
+
id= 'user1@localhost' pw='987654' showMenu={false}
|
17
17
|
/>}
|
18
18
|
|
19
19
|
{!sel && <div>hellow world</div> }
|