Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
b36a0c71
Commit
b36a0c71
authored
10 years ago
by
Kegan Dougal
Browse files
Options
Downloads
Patches
Plain Diff
Added utility function containsBingWord and hook up some css to it.
parent
a402e0c5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
webclient/app.css
+4
-0
4 additions, 0 deletions
webclient/app.css
webclient/components/matrix/event-handler-service.js
+41
-30
41 additions, 30 deletions
webclient/components/matrix/event-handler-service.js
webclient/room/room.html
+1
-1
1 addition, 1 deletion
webclient/room/room.html
with
46 additions
and
31 deletions
webclient/app.css
+
4
−
0
View file @
b36a0c71
...
@@ -538,6 +538,10 @@ a:active { color: #000; }
...
@@ -538,6 +538,10 @@ a:active { color: #000; }
color
:
#F00
;
color
:
#F00
;
}
}
.messageBing
{
color
:
#00F
;
}
#room-fullscreen-image
{
#room-fullscreen-image
{
position
:
absolute
;
position
:
absolute
;
top
:
0px
;
top
:
0px
;
...
...
This diff is collapsed.
Click to expand it.
webclient/components/matrix/event-handler-service.js
+
41
−
30
View file @
b36a0c71
...
@@ -45,6 +45,46 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
...
@@ -45,6 +45,46 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
var
eventMap
=
{};
var
eventMap
=
{};
$rootScope
.
presence
=
{};
$rootScope
.
presence
=
{};
// TODO: This is attached to the rootScope so .html can just go containsBingWord
// for determining classes so it is easy to highlight bing messages. It seems a
// bit strange to put the impl in this service though, but I can't think of a better
// file to put it in.
$rootScope
.
containsBingWord
=
function
(
content
)
{
if
(
!
content
)
{
return
false
;
}
var
bingWords
=
matrixService
.
config
().
bingWords
;
var
shouldBing
=
false
;
// case-insensitive name check for user_id OR display_name if they exist
var
myUserId
=
matrixService
.
config
().
user_id
;
if
(
myUserId
)
{
myUserId
=
myUserId
.
toLocaleLowerCase
();
}
var
myDisplayName
=
matrixService
.
config
().
display_name
;
if
(
myDisplayName
)
{
myDisplayName
=
myDisplayName
.
toLocaleLowerCase
();
}
if
(
(
myDisplayName
&&
content
.
toLocaleLowerCase
().
indexOf
(
myDisplayName
)
!=
-
1
)
||
(
myUserId
&&
content
.
toLocaleLowerCase
().
indexOf
(
myUserId
)
!=
-
1
)
)
{
shouldBing
=
true
;
}
// bing word list check
if
(
bingWords
&&
!
shouldBing
)
{
for
(
var
i
=
0
;
i
<
bingWords
.
length
;
i
++
)
{
// TODO: Should really be a word check, not a string of characters check.
// E.g. bing word is "coffee", "I have coffee" = bing, "I am a coffeepot" = no bing
// Currently it will bing for both.
if
(
content
.
indexOf
(
bingWords
[
i
])
!=
-
1
)
{
shouldBing
=
true
;
break
;
}
}
}
return
shouldBing
;
};
var
initialSyncDeferred
;
var
initialSyncDeferred
;
...
@@ -140,36 +180,7 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
...
@@ -140,36 +180,7 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
}
}
if
(
window
.
Notification
)
{
if
(
window
.
Notification
)
{
var
bingWords
=
matrixService
.
config
().
bingWords
;
var
shouldBing
=
$rootScope
.
containsBingWord
(
event
.
content
.
body
);
var
content
=
event
.
content
.
body
;
var
shouldBing
=
false
;
// case-insensitive name check for user_id OR display_name if they exist
var
myUserId
=
matrixService
.
config
().
user_id
;
if
(
myUserId
)
{
myUserId
=
myUserId
.
toLocaleLowerCase
();
}
var
myDisplayName
=
matrixService
.
config
().
display_name
;
if
(
myDisplayName
)
{
myDisplayName
=
myDisplayName
.
toLocaleLowerCase
();
}
if
(
(
myDisplayName
&&
content
.
toLocaleLowerCase
().
indexOf
(
myDisplayName
)
!=
-
1
)
||
(
myUserId
&&
content
.
toLocaleLowerCase
().
indexOf
(
myUserId
)
!=
-
1
)
)
{
shouldBing
=
true
;
}
// bing word list check
if
(
bingWords
&&
!
shouldBing
)
{
for
(
var
i
=
0
;
i
<
bingWords
.
length
;
i
++
)
{
// TODO: Should really be a word check, not a string of characters check.
// E.g. bing word is "coffee", "I have coffee" = bing, "I am a coffeepot" = no bing
// Currently it will bing for both.
if
(
content
.
indexOf
(
bingWords
[
i
])
!=
-
1
)
{
shouldBing
=
true
;
break
;
}
}
}
// TODO: Binging every message when idle doesn't make much sense. Can we use this more sensibly?
// TODO: Binging every message when idle doesn't make much sense. Can we use this more sensibly?
var
isIdle
=
(
document
.
hidden
||
matrixService
.
presence
.
unavailable
===
mPresence
.
getState
());
var
isIdle
=
(
document
.
hidden
||
matrixService
.
presence
.
unavailable
===
mPresence
.
getState
());
...
...
This diff is collapsed.
Click to expand it.
webclient/room/room.html
+
1
−
1
View file @
b36a0c71
...
@@ -105,7 +105,7 @@
...
@@ -105,7 +105,7 @@
<span
ng-show=
'msg.content.msgtype === "m.text"'
<span
ng-show=
'msg.content.msgtype === "m.text"'
class=
"message"
class=
"message"
ng-class=
"msg.echo_msg_state"
ng-class=
"
containsBingWord(msg.content.body) ? msg.echo_msg_state + ' messageBing' :
msg.echo_msg_state"
ng-bind-html=
"((msg.content.msgtype === 'm.text') ? msg.content.body : '') | linky:'_blank'"
/>
ng-bind-html=
"((msg.content.msgtype === 'm.text') ? msg.content.body : '') | linky:'_blank'"
/>
<span
ng-show=
'msg.type === "m.call.invite" && msg.user_id == state.user_id'
>
Outgoing Call
</span>
<span
ng-show=
'msg.type === "m.call.invite" && msg.user_id == state.user_id'
>
Outgoing Call
</span>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment