Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
cb94fd19
Commit
cb94fd19
authored
Mar 30, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update isImage to not use jQuery
Updates #814
parent
24942d6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
src/utils.js
src/utils.js
+17
-8
No files found.
src/utils.js
View file @
cb94fd19
...
@@ -46,11 +46,20 @@
...
@@ -46,11 +46,20 @@
var
isImage
=
function
(
url
)
{
var
isImage
=
function
(
url
)
{
var
deferred
=
new
$
.
Deferred
();
var
deferred
=
new
$
.
Deferred
();
$
(
"
<img>
"
,
{
var
img
=
new
Image
();
src
:
url
,
var
timer
=
window
.
setTimeout
(
function
()
{
error
:
deferred
.
reject
,
deferred
.
reject
();
load
:
deferred
.
resolve
img
=
null
;
});
},
3000
);
img
.
onerror
=
img
.
onabort
=
function
()
{
clearTimeout
(
timer
);
deferred
.
reject
();
};
img
.
onload
=
function
()
{
clearTimeout
(
timer
);
deferred
.
resolve
(
img
);
};
img
.
src
=
url
;
return
deferred
.
promise
();
return
deferred
.
promise
();
};
};
...
@@ -86,12 +95,12 @@
...
@@ -86,12 +95,12 @@
}
}
$obj
.
html
(
x
);
$obj
.
html
(
x
);
_
.
forEach
(
list
,
function
(
url
)
{
_
.
forEach
(
list
,
function
(
url
)
{
isImage
(
url
).
then
(
function
(
ev
)
{
isImage
(
url
).
then
(
function
(
img
)
{
var
prot
=
url
.
indexOf
(
'
http://
'
)
===
0
||
url
.
indexOf
(
'
https://
'
)
===
0
?
''
:
'
http://
'
;
var
prot
=
url
.
indexOf
(
'
http://
'
)
===
0
||
url
.
indexOf
(
'
https://
'
)
===
0
?
''
:
'
http://
'
;
var
escaped_url
=
encodeURI
(
decodeURI
(
url
)).
replace
(
/
[
!'()
]
/g
,
escape
).
replace
(
/
\*
/g
,
"
%2A
"
);
var
escaped_url
=
encodeURI
(
decodeURI
(
url
)).
replace
(
/
[
!'()
]
/g
,
escape
).
replace
(
/
\*
/g
,
"
%2A
"
);
var
new_url
=
'
<a target="_blank" rel="noopener" href="
'
+
prot
+
escaped_url
+
'
">
'
+
url
+
'
</a>
'
;
var
new_url
=
'
<a target="_blank" rel="noopener" href="
'
+
prot
+
escaped_url
+
'
">
'
+
url
+
'
</a>
'
;
ev
.
target
.
className
=
'
chat-image
'
;
img
.
className
=
'
chat-image
'
;
x
=
x
.
replace
(
new_url
,
ev
.
target
.
outerHTML
);
x
=
x
.
replace
(
new_url
,
img
.
outerHTML
);
$obj
.
throttledHTML
(
x
);
$obj
.
throttledHTML
(
x
);
});
});
});
});
...
...
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