summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorReed Garmsen <rgarmsen2295@gmail.com>2015-07-24 14:13:19 -0700
committerReed Garmsen <rgarmsen2295@gmail.com>2015-07-27 08:39:28 -0700
commit52bf726ddfaa0d5010ce7a80fe1f03a485df9279 (patch)
treee941ae9276f106f5dbf3209d9e69bac50d603760 /web
parent85ff151b71a5b0a488b7a8c3f0978b5d0ee8e280 (diff)
downloadchat-52bf726ddfaa0d5010ce7a80fe1f03a485df9279.tar.gz
chat-52bf726ddfaa0d5010ce7a80fe1f03a485df9279.tar.bz2
chat-52bf726ddfaa0d5010ce7a80fe1f03a485df9279.zip
Fixes issue with images not displaying due to window.origin not being defined in IE10
Diffstat (limited to 'web')
-rw-r--r--web/react/components/file_preview.jsx2
-rw-r--r--web/react/components/post_body.jsx4
-rw-r--r--web/react/components/post_right.jsx4
-rw-r--r--web/react/components/view_image.jsx6
-rw-r--r--web/react/utils/utils.jsx10
5 files changed, 16 insertions, 10 deletions
diff --git a/web/react/components/file_preview.jsx b/web/react/components/file_preview.jsx
index fdd12feec..7c1db3e10 100644
--- a/web/react/components/file_preview.jsx
+++ b/web/react/components/file_preview.jsx
@@ -24,7 +24,7 @@ module.exports = React.createClass({
if (filename.indexOf("/api/v1/files/get") != -1) {
filename = filename.split("/api/v1/files/get")[1];
}
- filename = window.location.origin + "/api/v1/files/get" + filename;
+ filename = utils.getWindowLocationOrigin() + "/api/v1/files/get" + filename;
if (type === "image") {
previews.push(
diff --git a/web/react/components/post_body.jsx b/web/react/components/post_body.jsx
index 7871f52b7..a71fa9e8f 100644
--- a/web/react/components/post_body.jsx
+++ b/web/react/components/post_body.jsx
@@ -32,7 +32,7 @@ module.exports = React.createClass({
if (fileInfo.path.indexOf("/api/v1/files/get") != -1) {
fileInfo.path = fileInfo.path.split("/api/v1/files/get")[1];
}
- fileInfo.path = window.location.origin + "/api/v1/files/get" + fileInfo.path;
+ fileInfo.path = utils.getWindowLocationOrigin() + "/api/v1/files/get" + fileInfo.path;
if (type === "image") {
$('<img/>').attr('src', fileInfo.path+'_thumb.jpg').load(function(path, name){ return function() {
@@ -112,7 +112,7 @@ module.exports = React.createClass({
if (fileInfo.path.indexOf("/api/v1/files/get") != -1) {
fileInfo.path = fileInfo.path.split("/api/v1/files/get")[1];
}
- fileInfo.path = window.location.origin + "/api/v1/files/get" + fileInfo.path;
+ fileInfo.path = utils.getWindowLocationOrigin() + "/api/v1/files/get" + fileInfo.path;
if (type === "image") {
if (i < Constants.MAX_DISPLAY_FILES) {
diff --git a/web/react/components/post_right.jsx b/web/react/components/post_right.jsx
index 567be1962..8097a181e 100644
--- a/web/react/components/post_right.jsx
+++ b/web/react/components/post_right.jsx
@@ -98,7 +98,7 @@ RootPost = React.createClass({
if (fileInfo.path.indexOf("/api/v1/files/get") != -1) {
fileInfo.path = fileInfo.path.split("/api/v1/files/get")[1];
}
- fileInfo.path = window.location.origin + "/api/v1/files/get" + fileInfo.path;
+ fileInfo.path = utils.getWindowLocationOrigin() + "/api/v1/files/get" + fileInfo.path;
if (ftype === "image") {
var url = fileInfo.path.replace(re1, '%20').replace(re2, '%28').replace(re3, '%29');
@@ -208,7 +208,7 @@ CommentPost = React.createClass({
if (fileInfo.path.indexOf("/api/v1/files/get") != -1) {
fileInfo.path = fileInfo.path.split("/api/v1/files/get")[1];
}
- fileInfo.path = window.location.origin + "/api/v1/files/get" + fileInfo.path;
+ fileInfo.path = utils.getWindowLocationOrigin() + "/api/v1/files/get" + fileInfo.path;
if (type === "image") {
var url = fileInfo.path.replace(re1, '%20').replace(re2, '%28').replace(re3, '%29');
diff --git a/web/react/components/view_image.jsx b/web/react/components/view_image.jsx
index c107de4d7..7b096c629 100644
--- a/web/react/components/view_image.jsx
+++ b/web/react/components/view_image.jsx
@@ -40,7 +40,7 @@ module.exports = React.createClass({
if (fileInfo.path.indexOf("/api/v1/files/get") !== -1) {
fileInfo.path = fileInfo.path.split("/api/v1/files/get")[1];
}
- fileInfo.path = window.location.origin + "/api/v1/files/get" + fileInfo.path;
+ fileInfo.path = utils.getWindowLocationOrigin() + "/api/v1/files/get" + fileInfo.path;
src = fileInfo['path'] + '_preview.jpg';
}
@@ -148,7 +148,7 @@ module.exports = React.createClass({
if (info.path.indexOf("/api/v1/files/get") !== -1) {
info.path = info.path.split("/api/v1/files/get")[1];
}
- info.path = window.location.origin + "/api/v1/files/get" + info.path;
+ info.path = utils.getWindowLocationOrigin() + "/api/v1/files/get" + info.path;
preview_filename = info['path'] + '_preview.jpg';
}
@@ -166,7 +166,7 @@ module.exports = React.createClass({
if (download_link.indexOf("/api/v1/files/get") !== -1) {
download_link = download_link.split("/api/v1/files/get")[1];
}
- download_link = window.location.origin + "/api/v1/files/get" + download_link;
+ download_link = utils.getWindowLocationOrigin() + "/api/v1/files/get" + download_link;
return (
<div className="modal fade image_modal" ref="modal" id={this.props.modalId} tabIndex="-1" role="dialog" aria-hidden="true">
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 00580af6e..98dae9084 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -22,8 +22,6 @@ module.exports.cleanUpUrlable = function(input) {
return cleaned;
};
-
-
module.exports.isTestDomain = function() {
if ((/^localhost/).test(window.location.hostname))
@@ -838,3 +836,11 @@ module.exports.getDisplayName = function(user) {
}
}
};
+
+//IE10 does not set window.location.origin automatically so this must be called instead when using it
+module.exports.getWindowLocationOrigin = function() {
+ if (!window.location.origin) {
+ window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
+ }
+ return window.location.origin;
+};