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
f4e3f9d2
Commit
f4e3f9d2
authored
Aug 20, 2014
by
Thibaut Frain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added basic new messages notification on contactlist gadget
parent
26c08d12
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
86 additions
and
11 deletions
+86
-11
dev/jabberclient/jabberclient.js
dev/jabberclient/jabberclient.js
+12
-4
dev/jabberclient_chatbox/jabberclient_chatbox.js
dev/jabberclient_chatbox/jabberclient_chatbox.js
+2
-1
dev/jabberclient_contactlist/index.html
dev/jabberclient_contactlist/index.html
+9
-0
dev/jabberclient_contactlist/jabberclient_contactlist.js
dev/jabberclient_contactlist/jabberclient_contactlist.js
+14
-2
src/jabberclient/jabberclient.js
src/jabberclient/jabberclient.js
+17
-3
src/jabberclient_chatbox/jabberclient_chatbox.js
src/jabberclient_chatbox/jabberclient_chatbox.js
+3
-0
src/jabberclient_contactlist/index.html
src/jabberclient_contactlist/index.html
+9
-0
src/jabberclient_contactlist/jabberclient_contactlist.js
src/jabberclient_contactlist/jabberclient_contactlist.js
+20
-1
No files found.
dev/jabberclient/jabberclient.js
View file @
f4e3f9d2
...
...
@@ -37,7 +37,7 @@
}).
allowPublicAcquisition
(
"
receive
"
,
function
(
datas
)
{
datas
=
datas
[
0
];
console
.
log
(
"
[xmpp datas input] :
"
+
datas
);
var
xmlInput
=
parseXML
(
datas
);
var
xmlInput
=
parseXML
(
datas
)
,
gadget
=
this
;
if
(
isRoster
(
xmlInput
))
{
return
this
.
getDeclaredGadget
(
"
contactlist
"
).
push
(
function
(
contactlist_gadget
)
{
return
contactlist_gadget
.
receiveRoster
(
datas
);
...
...
@@ -45,11 +45,15 @@
}
if
(
isPresence
(
xmlInput
))
{
return
this
.
getDeclaredGadget
(
"
contactlist
"
).
push
(
function
(
contactlist_gadget
)
{
contactlist_gadget
.
receivePresence
(
datas
);
return
contactlist_gadget
.
receivePresence
(
datas
);
});
}
if
(
isMessage
(
xmlInput
))
{
return
this
.
getDeclaredGadget
(
"
chatbox
"
).
push
(
function
(
chatbox_gadget
)
{
return
this
.
getDeclaredGadget
(
"
contactlist
"
).
push
(
function
(
contactlist_gadget
)
{
return
contactlist_gadget
.
receiveMessage
(
datas
);
}).
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
"
chatbox
"
);
}).
push
(
function
(
chatbox_gadget
)
{
return
chatbox_gadget
.
receive
(
datas
);
});
}
...
...
@@ -82,7 +86,11 @@
});
}).
allowPublicAcquisition
(
"
getHash
"
,
function
(
options
)
{
return
this
.
aq_pleasePublishMyState
(
options
[
0
]);
}).
declareAcquiredMethod
(
"
pleaseRedirectMyHash
"
,
"
pleaseRedirectMyHash
"
).
allowPublicAcquisition
(
"
renderConnection
"
,
function
()
{
}).
declareAcquiredMethod
(
"
pleaseRedirectMyHash
"
,
"
pleaseRedirectMyHash
"
).
allowPublicAcquisition
(
"
messagesAreRead
"
,
function
(
jid
)
{
return
this
.
getDeclaredGadget
(
"
contactlist
"
).
push
(
function
(
contactlist_gadget
)
{
return
contactlist_gadget
.
messagesAreRead
(
jid
[
0
]);
});
}).
allowPublicAcquisition
(
"
renderConnection
"
,
function
()
{
return
this
.
aq_pleasePublishMyState
({
page
:
"
connection
"
}).
push
(
this
.
pleaseRedirectMyHash
.
bind
(
this
));
...
...
dev/jabberclient_chatbox/jabberclient_chatbox.js
View file @
f4e3f9d2
...
...
@@ -90,7 +90,8 @@
}
}
});
}).
declareAcquiredMethod
(
"
send
"
,
"
send
"
).
declareMethod
(
"
receive
"
,
function
(
datas
)
{
return
this
.
messagesAreRead
(
options
.
current_contact_jid
);
}).
declareAcquiredMethod
(
"
messagesAreRead
"
,
"
messagesAreRead
"
).
declareAcquiredMethod
(
"
send
"
,
"
send
"
).
declareMethod
(
"
receive
"
,
function
(
datas
)
{
var
xmlMessage
=
parseXML
(
datas
),
from
=
Strophe
.
getBareJidFromJid
(
$
(
xmlMessage
).
attr
(
"
from
"
)),
to
=
Strophe
.
getBareJidFromJid
(
$
(
xmlMessage
).
attr
(
"
to
"
)),
time
=
getTime
(),
content
=
$
(
xmlMessage
).
find
(
"
body
"
).
text
(),
message
=
new
Message
(
from
,
to
,
time
,
content
);
if
(
!
this
.
props
.
talks
[
from
])
{
this
.
props
.
talks
[
from
]
=
new
Talk
(
from
);
...
...
dev/jabberclient_contactlist/index.html
View file @
f4e3f9d2
...
...
@@ -21,6 +21,9 @@
alt
=
"
offline
"
class
=
"
ui-li-icon ui-corner-none
"
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
{{
#
if
new_message
}}
&
nbsp
&
nbsp
[
new
message
(
s
)]
{{
/
if
}}
<
/li
>
</script>
...
...
@@ -30,6 +33,9 @@
alt
=
"
online
"
class
=
"
ui-li-icon ui-corner-none
"
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
{{
#
if
new_message
}}
&
nbsp
&
nbsp
[
new
message
(
s
)]
{{
/
if
}}
<
/a></
li
>
</script>
...
...
@@ -39,6 +45,9 @@
alt
=
"
{{status}}
"
class
=
"
ui-li-icon ui-corner-none
"
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
&
nbsp
&
nbsp
({{
status
}})
{{
#
if
new_message
}}
&
nbsp
&
nbsp
[
new
message
(
s
)]
{{
/
if
}}
<
/a></
li
>
</script>
...
...
dev/jabberclient_contactlist/jabberclient_contactlist.js
View file @
f4e3f9d2
...
...
@@ -7,7 +7,7 @@
function
parseXML
(
xmlString
)
{
return
new
DOMParser
().
parseFromString
(
xmlString
,
"
text/xml
"
).
children
[
0
];
}
function
updateContactElement
(
gadget
,
contact
)
{
function
updateContactElement
(
gadget
,
contact
,
new_message
,
messages_read
)
{
var
template
,
options
=
{};
if
(
contact
.
el
)
{
contact
.
el
.
remove
();
...
...
@@ -22,6 +22,7 @@
}
options
.
jid
=
contact
.
jid
;
options
.
name
=
contact
.
name
;
options
.
new_message
=
new_message
||
false
;
return
gadget
.
getConnectionJID
().
push
(
function
(
connection_jid
)
{
return
gadget
.
getHash
({
page
:
"
chatbox
"
,
...
...
@@ -31,6 +32,11 @@
}).
push
(
function
(
hash
)
{
options
.
hash
=
hash
;
contact
.
el
=
$
(
template
(
options
));
}).
push
(
function
()
{
if
(
options
.
new_message
||
messages_read
)
{
gadget
.
contactList
.
el
.
prepend
(
contact
.
el
);
gadget
.
contactList
.
el
.
listview
(
"
refresh
"
);
}
});
}
function
updateContact
(
gadget
,
contact
,
presence
)
{
...
...
@@ -94,7 +100,13 @@
});
}
}
gadget
.
declareAcquiredMethod
(
"
getHash
"
,
"
getHash
"
).
declareAcquiredMethod
(
"
getConnectionJID
"
,
"
getConnectionJID
"
).
declareAcquiredMethod
(
"
send
"
,
"
send
"
).
declareAcquiredMethod
(
"
openChat
"
,
"
openChat
"
).
declareMethod
(
"
receiveRoster
"
,
function
(
roster
)
{
gadget
.
declareAcquiredMethod
(
"
getHash
"
,
"
getHash
"
).
declareAcquiredMethod
(
"
getConnectionJID
"
,
"
getConnectionJID
"
).
declareAcquiredMethod
(
"
send
"
,
"
send
"
).
declareAcquiredMethod
(
"
openChat
"
,
"
openChat
"
).
declareMethod
(
"
messagesAreRead
"
,
function
(
jid
)
{
var
contact
=
this
.
contactList
.
list
[
jid
];
return
updateContactElement
(
this
,
contact
,
false
,
true
);
}).
declareMethod
(
"
receiveMessage
"
,
function
(
message
)
{
var
xmlMessage
=
parseXML
(
message
),
jid
=
Strophe
.
getBareJidFromJid
(
$
(
xmlMessage
).
attr
(
"
from
"
)),
contact
=
this
.
contactList
.
list
[
jid
];
return
updateContactElement
(
this
,
contact
,
true
);
}).
declareMethod
(
"
receiveRoster
"
,
function
(
roster
)
{
this
.
contactList
=
new
ContactList
(
this
,
parseXML
(
roster
));
}).
declareMethod
(
"
receivePresence
"
,
function
(
presence
)
{
return
updateContactList
(
this
,
parseXML
(
presence
));
...
...
src/jabberclient/jabberclient.js
View file @
f4e3f9d2
...
...
@@ -53,7 +53,8 @@
.
allowPublicAcquisition
(
'
receive
'
,
function
(
datas
)
{
datas
=
datas
[
0
];
console
.
log
(
'
[xmpp datas input] :
'
+
datas
);
var
xmlInput
=
parseXML
(
datas
);
var
xmlInput
=
parseXML
(
datas
),
gadget
=
this
;
if
(
isRoster
(
xmlInput
))
{
return
this
.
getDeclaredGadget
(
"
contactlist
"
)
...
...
@@ -64,11 +65,17 @@
if
(
isPresence
(
xmlInput
))
{
return
this
.
getDeclaredGadget
(
"
contactlist
"
)
.
push
(
function
(
contactlist_gadget
)
{
contactlist_gadget
.
receivePresence
(
datas
);
return
contactlist_gadget
.
receivePresence
(
datas
);
});
}
if
(
isMessage
(
xmlInput
))
{
return
this
.
getDeclaredGadget
(
"
chatbox
"
)
return
this
.
getDeclaredGadget
(
"
contactlist
"
)
.
push
(
function
(
contactlist_gadget
)
{
return
contactlist_gadget
.
receiveMessage
(
datas
);
})
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
"
chatbox
"
);
})
.
push
(
function
(
chatbox_gadget
)
{
return
chatbox_gadget
.
receive
(
datas
);
});
...
...
@@ -121,6 +128,13 @@
.
declareAcquiredMethod
(
"
pleaseRedirectMyHash
"
,
"
pleaseRedirectMyHash
"
)
.
allowPublicAcquisition
(
"
messagesAreRead
"
,
function
(
jid
)
{
return
this
.
getDeclaredGadget
(
'
contactlist
'
)
.
push
(
function
(
contactlist_gadget
)
{
return
contactlist_gadget
.
messagesAreRead
(
jid
[
0
]);
});
})
.
allowPublicAcquisition
(
'
renderConnection
'
,
function
()
{
return
this
.
aq_pleasePublishMyState
({
page
:
"
connection
"
})
.
push
(
this
.
pleaseRedirectMyHash
.
bind
(
this
));
...
...
src/jabberclient_chatbox/jabberclient_chatbox.js
View file @
f4e3f9d2
...
...
@@ -124,8 +124,11 @@
}
}
});
return
this
.
messagesAreRead
(
options
.
current_contact_jid
);
})
.
declareAcquiredMethod
(
'
messagesAreRead
'
,
"
messagesAreRead
"
)
.
declareAcquiredMethod
(
'
send
'
,
'
send
'
)
.
declareMethod
(
'
receive
'
,
function
(
datas
)
{
...
...
src/jabberclient_contactlist/index.html
View file @
f4e3f9d2
...
...
@@ -21,6 +21,9 @@
alt
=
"
offline
"
class
=
"
ui-li-icon ui-corner-none
"
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
{{
#
if
new_message
}}
&
nbsp
&
nbsp
[
new
message
(
s
)]
{{
/
if
}}
<
/li
>
</script>
...
...
@@ -30,6 +33,9 @@
alt
=
"
online
"
class
=
"
ui-li-icon ui-corner-none
"
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
{{
#
if
new_message
}}
&
nbsp
&
nbsp
[
new
message
(
s
)]
{{
/
if
}}
<
/a></
li
>
</script>
...
...
@@ -39,6 +45,9 @@
alt
=
"
{{status}}
"
class
=
"
ui-li-icon ui-corner-none
"
>
{{
name
}}
&
nbsp
&
nbsp
{{
jid
}}
&
nbsp
&
nbsp
({{
status
}})
{{
#
if
new_message
}}
&
nbsp
&
nbsp
[
new
message
(
s
)]
{{
/
if
}}
<
/a></
li
>
</script>
...
...
src/jabberclient_contactlist/jabberclient_contactlist.js
View file @
f4e3f9d2
...
...
@@ -22,7 +22,7 @@
.
children
[
0
];
}
function
updateContactElement
(
gadget
,
contact
)
{
function
updateContactElement
(
gadget
,
contact
,
new_message
,
messages_read
)
{
var
template
,
options
=
{};
if
(
contact
.
el
)
{
contact
.
el
.
remove
();
}
...
...
@@ -36,6 +36,7 @@
}
options
.
jid
=
contact
.
jid
;
options
.
name
=
contact
.
name
;
options
.
new_message
=
new_message
||
false
;
return
gadget
.
getConnectionJID
()
.
push
(
function
(
connection_jid
)
{
return
gadget
.
getHash
({
...
...
@@ -47,6 +48,12 @@
.
push
(
function
(
hash
)
{
options
.
hash
=
hash
;
contact
.
el
=
$
(
template
(
options
));
})
.
push
(
function
()
{
if
(
options
.
new_message
||
messages_read
)
{
gadget
.
contactList
.
el
.
prepend
(
contact
.
el
);
gadget
.
contactList
.
el
.
listview
(
'
refresh
'
);
}
});
}
...
...
@@ -134,6 +141,18 @@
.
declareAcquiredMethod
(
'
openChat
'
,
'
openChat
'
)
.
declareMethod
(
'
messagesAreRead
'
,
function
(
jid
)
{
var
contact
=
this
.
contactList
.
list
[
jid
];
return
updateContactElement
(
this
,
contact
,
false
,
true
);
})
.
declareMethod
(
'
receiveMessage
'
,
function
(
message
)
{
var
xmlMessage
=
parseXML
(
message
),
jid
=
Strophe
.
getBareJidFromJid
(
$
(
xmlMessage
).
attr
(
'
from
'
)),
contact
=
this
.
contactList
.
list
[
jid
];
return
updateContactElement
(
this
,
contact
,
true
);
})
.
declareMethod
(
'
receiveRoster
'
,
function
(
roster
)
{
this
.
contactList
=
new
ContactList
(
this
,
parseXML
(
roster
));
})
...
...
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