Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
58b39fb5
Commit
58b39fb5
authored
May 23, 2014
by
Thibaut Frain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added jabber chatbox gadget
parent
3bd308e0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
1 deletion
+121
-1
Gruntfile.js
Gruntfile.js
+3
-1
src/jabber_chatbox/index.html
src/jabber_chatbox/index.html
+22
-0
src/jabber_chatbox/jabber_chatbox.css
src/jabber_chatbox/jabber_chatbox.css
+28
-0
src/jabber_chatbox/jabber_chatbox.js
src/jabber_chatbox/jabber_chatbox.js
+68
-0
No files found.
Gruntfile.js
View file @
58b39fb5
...
...
@@ -102,7 +102,9 @@ module.exports = function (grunt) {
"
<%= global_config.dest %>/jabber_login/jabber_login.css
"
:
"
<%= global_config.src %>/jabber_login/jabber_login.css
"
,
"
<%= global_config.dest %>/jabber_contactlist/jabber_contactlist.css
"
:
"
<%= global_config.src %>/jabber_contactlist/jabber_contactlist.css
"
"
<%= global_config.src %>/jabber_contactlist/jabber_contactlist.css
"
,
"
<%= global_config.dest %>/jabber_chatbox/jabber_chatbox.css
"
:
"
<%= global_config.src %>/jabber_chatbox/jabber_chatbox.css
"
}
}
},
...
...
src/jabber_chatbox/index.html
0 → 100644
View file @
58b39fb5
<!doctype html>
<html>
<head>
<meta
charset=
"utf-8"
>
<title>
Chatbox
</title>
<link
rel=
"stylesheet"
href=
"jabber_chatbox.css"
>
<script
src=
"../<%= curl.jquery.relative_dest %>"
></script>
<script
src=
"../<%= curl.strophejs.relative_dest %>"
></script>
<script
src=
"../<%= copy.rsvp.relative_dest %>"
></script>
<script
src=
"../<%= copy.renderjs.relative_dest %>"
></script>
<script
src=
"jabber_chatbox.js"
></script>
</head>
<body>
<div
id=
"contact"
></div>
<div
id=
"talk"
></div>
<textarea
id=
"talk-input"
></textarea>
<button
id=
"send-button"
>
Send
</button>
</body>
</html>
src/jabber_chatbox/jabber_chatbox.css
0 → 100644
View file @
58b39fb5
html
{
height
:
100%
;
}
body
{
height
:
100%
;
}
#talk
{
padding
:
10px
;
height
:
82%
;
border
:
solid
1px
#aaa
;
font-family
:
monospace
;
overflow
:
auto
;
}
#talk-input
{
width
:
80%
;
height
:
5%
;
border
:
solid
1px
#aaa
;
font-family
:
monospace
;
overflow
:
auto
;
float
:
left
;
}
#send-button
{
width
:
10%
;
height
:
5%
;
float
:
left
;
}
src/jabber_chatbox/jabber_chatbox.js
0 → 100644
View file @
58b39fb5
/*globals window, document, RSVP, XMLSerializer, DOMParser,
rJS, $, DOMParser, Strophe, $msg*/
(
function
(
$
,
gadget
)
{
"
use strict
"
;
var
main
,
parseXML
=
function
(
xmlString
)
{
return
new
DOMParser
()
.
parseFromString
(
xmlString
,
'
text/xml
'
)
.
children
[
0
];
};
function
Chat
(
jid
,
name
)
{
this
.
jid
=
jid
;
this
.
name
=
name
;
}
Chat
.
prototype
.
sendInput
=
function
()
{
var
message
=
$
(
'
#talk-input
'
).
val
(),
messageStanzas
;
$
(
'
#talk-input
'
).
val
(
""
);
if
(
message
)
{
$
(
'
#talk
'
).
append
(
'
<p>Me:
'
+
message
+
'
</p>
'
);
messageStanzas
=
this
.
getMessageStanzas
(
message
);
main
.
send
(
messageStanzas
);
}
};
Chat
.
prototype
.
getMessageStanzas
=
function
(
message
)
{
return
$msg
({
to
:
this
.
jid
,
type
:
"
chat
"
}).
c
(
'
body
'
).
t
(
message
).
toString
();
};
gadget
.
declareAcquiredMethod
(
'
send
'
,
'
send
'
)
.
declareMethod
(
'
initContact
'
,
function
(
jid
,
name
)
{
this
.
chat
=
new
Chat
(
jid
,
name
);
$
(
'
#contact
'
).
html
(
jid
);
return
this
.
chat
;
})
.
declareMethod
(
'
receive
'
,
function
(
message
)
{
var
xmlMessage
=
parseXML
(
message
);
$
(
'
#talk
'
).
append
(
'
<p>
'
+
Strophe
.
getBareJidFromJid
(
$
(
xmlMessage
).
attr
(
'
from
'
))
+
'
:
'
+
$
(
xmlMessage
).
find
(
'
body
'
).
text
()
+
'
</p>
'
);
})
.
ready
(
function
(
g
)
{
main
=
g
;
$
(
'
#send-button
'
).
click
(
function
()
{
g
.
chat
.
sendInput
();
});
$
(
"
#talk-input
"
).
keypress
(
function
(
e
)
{
if
(
e
.
charCode
===
13
)
{
e
.
preventDefault
();
g
.
chat
.
sendInput
();
}
});
});
}(
$
,
rJS
(
window
)));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment