Commit 203c862e by Kim Peace

Divided for model in js

parent dc5fd359
...@@ -112,6 +112,10 @@ ...@@ -112,6 +112,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- view --> <!-- view -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -69,6 +69,10 @@ ...@@ -69,6 +69,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- view --> <!-- view -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -118,6 +118,10 @@ ...@@ -118,6 +118,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -146,6 +146,10 @@ ...@@ -146,6 +146,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -76,6 +76,10 @@ ...@@ -76,6 +76,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -75,6 +75,10 @@ ...@@ -75,6 +75,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -147,6 +147,10 @@ ...@@ -147,6 +147,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -83,6 +83,10 @@ ...@@ -83,6 +83,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -164,6 +164,11 @@ ...@@ -164,6 +164,11 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<script src="./js/Models/roominfo.js"></script>
<!-- Socket --> <!-- Socket -->
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
......
...@@ -145,6 +145,10 @@ ...@@ -145,6 +145,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- Socket --> <!-- Socket -->
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
......
...@@ -88,6 +88,10 @@ ...@@ -88,6 +88,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- Socket --> <!-- Socket -->
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
...@@ -137,6 +141,4 @@ ...@@ -137,6 +141,4 @@
}; };
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -149,6 +149,10 @@ ...@@ -149,6 +149,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- Socket --> <!-- Socket -->
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
......
...@@ -139,6 +139,10 @@ ...@@ -139,6 +139,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- Socket --> <!-- Socket -->
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
......
...@@ -84,6 +84,10 @@ ...@@ -84,6 +84,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- Socket --> <!-- Socket -->
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
......
...@@ -141,6 +141,10 @@ ...@@ -141,6 +141,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- Socket --> <!-- Socket -->
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
......
...@@ -195,6 +195,10 @@ ...@@ -195,6 +195,10 @@
<script src="./js/common/native-bridge-datasource.js"></script> <script src="./js/common/native-bridge-datasource.js"></script>
<script src="./js/common/common.js"></script> <script src="./js/common/common.js"></script>
<script src="./js/utils/chat-util.js"></script> <script src="./js/utils/chat-util.js"></script>
<!-- Models -->
<script src="./js/Models/deviceinfo.js"></script>
<script src="./js/Models/serverinfo.js"></script>
<script src="./js/Models/userinfo.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
NativeBridgeDataSource.getDeviceInfo = function () {
if (typeof android != "undefined") {
return JSON.parse(android.getDeviceInfo());
} else {
return JSON.parse(callNativeApp(NATIVE_KEY_IOS.getDeviceInfo, {}));
}
};
var DeviceInfo = class {
isMoble; // iphone or iPad
platform; // ios or android
constructor(deviceInfo) {
this.isMoble = deviceInfo.isMoble;
this.platform = deviceInfo.platform;
}
};
var deviceInfo = new DeviceInfo(NativeBridgeDataSource.getDeviceInfo());
NativeBridgeDataSource.getRoomInfo = function () {
if (typeof android != "undefined") {
return JSON.parse(android.getRoomInfo());
} else {
return JSON.parse(callNativeApp(NATIVE_KEY_IOS.getRoomInfo, {}));
}
};
var RoomInfo = class {
roomID;
roomName;
constructor(roomInfo) {
this.roomID = roomInfo.roomID;
this.roomName = roomInfo.roomName;
}
};
var roomInfo = new RoomInfo(NativeBridgeDataSource.getRoomInfo());
NativeBridgeDataSource.getServerInfo = function () {
if (typeof android != "undefined") {
return JSON.parse(android.getServerInfo());
} else {
return JSON.parse(callNativeApp(NATIVE_KEY_IOS.getServerInfo, {}));
}
};
var ServerInfo = class {
chatURL;
cmsURL;
isOnline;
constructor(serverInfo) {
this.chatURL = serverInfo.chatURL;
this.cmsURL = serverInfo.cmsURL;
this.isOnline = serverInfo.isOnline;
}
};
var serverInfo = new ServerInfo(NativeBridgeDataSource.getServerInfo());
\ No newline at end of file
NativeBridgeDataSource.getMyUserInfo = function() {
if (typeof android != "undefined") {
return JSON.parse(android.removeFavoriteGroup(groupID));
} else {
return JSON.parse(callNativeApp(NATIVE_KEY_IOS.currentUserInfo, { }));
}
}
var CurrentUserInfo = class {
sid;
loginId;
shopName;
shopMemberId;
languageCode;
constructor(userInfo) {
this.sid = userInfo.sid;
this.loginId = userInfo.loginId;
this.shopName = userInfo.shopName;
this.shopMemberId = userInfo.shopMemberId;
this.languageCode = userInfo.languageCode;
}
};
var currentUserInfo = new CurrentUserInfo(NativeBridgeDataSource.getMyUserInfo());
...@@ -99,112 +99,6 @@ CHAT_UI.isLandscapeMode = function () { ...@@ -99,112 +99,6 @@ CHAT_UI.isLandscapeMode = function () {
return $(window).width() > $(window).height(); return $(window).width() > $(window).height();
}; };
// this method call from android only for now
CHAT_UI.videoEncodeFail = function () {
alert(getLocalizedString("error_send_video"));
CHAT_UI.dismissLoadingIndicator();
};
// this method call from android only for now
CHAT_UI.videoEncodeEnd = function (encodedUri) {
var fileName = encodedUri.split("/")[encodedUri.split("/").length - 1];
var fileURL = "file:" + encodedUri;
var xhr = new XMLHttpRequest();
xhr.open("GET", fileURL);
xhr.responseType = "blob";
xhr.addEventListener("load", function () {
var formData = new FormData();
formData.append("image", xhr.response, fileName);
formData.append("sid", CHAT.globalLoginParameter.sid);
formData.append("roomId", CHAT.globalLoginParameter.roomId);
jQuery
.ajax({
async: true,
url: CMS_SERVER_URL + "/chatapi/file/upload",
type: "post",
data: formData,
contentType: false,
processData: false,
error: function () {
alert(getLocalizedString("error_send_video"));
CHAT_UI.dismissLoadingIndicator();
},
})
.done(function (res) {
if (CHAT_UTIL.isAndroid()) {
android.removeEncodedVideo(encodedUri);
}
var imgPath =
CMS_SERVER_URL +
"/chatapi/file/getImage?fileName=" +
res.fileName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
var imageName = res.fileName;
// uploadFileの判断
var extension = imageName
.substr(imageName.lastIndexOf(".") + 1)
.toLowerCase();
if (res.thumbnailPath && res.thumbnailPath.length > 0) {
imgPath =
CMS_SERVER_URL +
"/chatapi/file/getImage?fileName=" +
res.thumbImageFileName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
}
let downloadPath =
CMS_SERVER_URL +
"/chatapi/file/download?fileName=" +
imageName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
var videoSrc =
CMS_SERVER_URL +
"/chatapi/file/getImage?fileName=" +
res.fileName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
const totalDiv = $("<div/>", { id: "attachedImages" });
const videoTag = $("<video/>", {
controls: "true",
width: "auto",
style: "max-width:100%",
});
const source = $("<source/>", { src: videoSrc });
const downloadIcon = $("<a/>", {
href: downloadPath,
class: "fa fa-download",
download: res.fileName,
});
videoTag.append(source);
totalDiv.append(videoTag);
totalDiv.append(downloadIcon);
let text = totalDiv.prop("outerHTML");
let encodedText;
try {
encodedText = encodeURIComponent(text);
} catch (e) {
encodedText = text;
}
socket.emit(
"createMessage",
{
text: encodedText + messageSeperator + MessageType.VIDEO,
},
1
);
$(".overlay").removeClass("active undismissable");
$(".loader").removeClass("active");
CHAT_UI.dismissLoadingIndicator();
});
});
xhr.send();
};
CHAT_UI.htmlElementTextInitialize = function (languageCode) { CHAT_UI.htmlElementTextInitialize = function (languageCode) {
moment.locale(languageCode); moment.locale(languageCode);
setLanguage(languageCode); setLanguage(languageCode);
......
...@@ -363,6 +363,10 @@ getLoginParameter = function ( ...@@ -363,6 +363,10 @@ getLoginParameter = function (
CHAT_UI.htmlElementTextInitialize(languageCode); CHAT_UI.htmlElementTextInitialize(languageCode);
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
console.log("peacekim:: getLoginParameter called and currentUserInfo: "+currentUserInfo);
console.log("peacekim:: getLoginParameter called and deviceInfo: "+deviceInfo);
console.log("peacekim:: getLoginParameter called and chatRoomInfo: "+roomInfo);
console.log("peacekim:: getLoginParameter called and serverInfo: "+serverInfo);
}; };
// for android native call // for android native call
......
...@@ -121,6 +121,10 @@ const SOCKET_KEY = { ...@@ -121,6 +121,10 @@ const SOCKET_KEY = {
}; };
const NATIVE_KEY_IOS = { const NATIVE_KEY_IOS = {
currentUserInfo: "currentUserInfo",
getDeviceInfo: "getDeviceInfo",
getServerInfo: "getServerInfo",
getRoomInfo: "getRoomInfo",
getBeforeRoomType: "getBeforeRoomType", getBeforeRoomType: "getBeforeRoomType",
getRoomType: "getRoomType", getRoomType: "getRoomType",
removeFavoriteUser: "removeFavoriteUser", removeFavoriteUser: "removeFavoriteUser",
......
...@@ -78,3 +78,110 @@ $("#video-form").on("submit", function (e) { ...@@ -78,3 +78,110 @@ $("#video-form").on("submit", function (e) {
} }
} }
}); });
// this method call from android only for now
CHAT_UI.videoEncodeFail = function () {
alert(getLocalizedString("error_send_video"));
CHAT_UI.dismissLoadingIndicator();
};
// this method call from android only for now
CHAT_UI.videoEncodeEnd = function (encodedUri) {
var fileName = encodedUri.split("/")[encodedUri.split("/").length - 1];
var fileURL = "file:" + encodedUri;
var xhr = new XMLHttpRequest();
xhr.open("GET", fileURL);
xhr.responseType = "blob";
xhr.addEventListener("load", function () {
var formData = new FormData();
formData.append("image", xhr.response, fileName);
formData.append("sid", CHAT.globalLoginParameter.sid);
formData.append("roomId", CHAT.globalLoginParameter.roomId);
jQuery
.ajax({
async: true,
url: CMS_SERVER_URL + "/chatapi/file/upload",
type: "post",
data: formData,
contentType: false,
processData: false,
error: function () {
alert(getLocalizedString("error_send_video"));
CHAT_UI.dismissLoadingIndicator();
},
})
.done(function (res) {
if (CHAT_UTIL.isAndroid()) {
android.removeEncodedVideo(encodedUri);
}
var imgPath =
CMS_SERVER_URL +
"/chatapi/file/getImage?fileName=" +
res.fileName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
var imageName = res.fileName;
// uploadFileの判断
var extension = imageName
.substr(imageName.lastIndexOf(".") + 1)
.toLowerCase();
if (res.thumbnailPath && res.thumbnailPath.length > 0) {
imgPath =
CMS_SERVER_URL +
"/chatapi/file/getImage?fileName=" +
res.thumbImageFileName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
}
let downloadPath =
CMS_SERVER_URL +
"/chatapi/file/download?fileName=" +
imageName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
var videoSrc =
CMS_SERVER_URL +
"/chatapi/file/getImage?fileName=" +
res.fileName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
const totalDiv = $("<div/>", { id: "attachedImages" });
const videoTag = $("<video/>", {
controls: "true",
width: "auto",
style: "max-width:100%",
});
const source = $("<source/>", { src: videoSrc });
const downloadIcon = $("<a/>", {
href: downloadPath,
class: "fa fa-download",
download: res.fileName,
});
videoTag.append(source);
totalDiv.append(videoTag);
totalDiv.append(downloadIcon);
let text = totalDiv.prop("outerHTML");
let encodedText;
try {
encodedText = encodeURIComponent(text);
} catch (e) {
encodedText = text;
}
socket.emit(
"createMessage",
{
text: encodedText + messageSeperator + MessageType.VIDEO,
},
1
);
$(".overlay").removeClass("active undismissable");
$(".loader").removeClass("active");
CHAT_UI.dismissLoadingIndicator();
});
});
xhr.send();
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment