Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chat_webview
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abookCommunication
chat_webview
Commits
51c13e76
Commit
51c13e76
authored
Jul 13, 2021
by
Kim Peace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed for chat room
parent
dbb5490c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
472 additions
and
444 deletions
+472
-444
public_new/chat_change_room_name.html
+2
-0
public_new/chat_room.html
+3
-0
public_new/js/Models/roominfo.js
+2
-1
public_new/js/common/native-bridge-datasource.js
+3
-3
public_new/js/views/chats/chat-room-message.js
+302
-0
public_new/js/views/chats/chat-room-search.js
+135
-0
public_new/js/views/chats/chat-room.js
+25
-440
No files found.
public_new/chat_change_room_name.html
View file @
51c13e76
...
...
@@ -81,6 +81,8 @@
<script
src=
"./js/Models/userinfo.js"
></script>
<!-- View -->
<script
src=
"./js/views/chats/chat-room.js"
></script>
<script
src=
"./js/views/chats/chat-room-search.js"
></script>
<script
src=
"./js/views/chats/chat-room-message.js"
></script>
<script
src=
"./js/views/chats/management/chat-room-change.js"
></script>
<script>
...
...
public_new/chat_room.html
View file @
51c13e76
...
...
@@ -170,6 +170,9 @@
<!-- View -->
<script
src=
"./js/utils/chat-media-handler.js"
></script>
<script
src=
"./js/views/chats/chat-room.js"
></script>
<script
src=
"./js/views/chats/chat-room-search.js"
></script>
<script
src=
"./js/views/chats/chat-room-message.js"
></script>
<script
src=
"./js/views/contact/namecard.js"
></script>
<script
src=
"./js/common/loading.js"
></script>
<script>
...
...
public_new/js/Models/roominfo.js
View file @
51c13e76
...
...
@@ -15,4 +15,4 @@ var RoomInfo = class {
}
};
var
roomInfo
=
new
RoomInfo
(
NativeBridgeDataSource
.
getRoomInfo
());
var
roomInfo
=
new
RoomInfo
(
NativeBridgeDataSource
.
getRoomInfo
());
\ No newline at end of file
public_new/js/common/native-bridge-datasource.js
View file @
51c13e76
...
...
@@ -262,14 +262,14 @@ NativeBridgeDataSource.getGroupByName = function (groupName) {
}
};
NativeBridgeDataSource
.
getUsersInRoom
=
function
(
roomI
d
)
{
NativeBridgeDataSource
.
getUsersInRoom
=
function
(
roomI
D
)
{
if
(
deviceInfo
.
isiOS
())
{
return
JSON
.
parse
(
callNativeApp
(
NATIVE_KEY_IOS
.
getUsersInRoom
,
{
roomId
:
roomI
d
})
callNativeApp
(
NATIVE_KEY_IOS
.
getUsersInRoom
,
{
roomId
:
roomI
D
})
);
}
else
if
(
deviceInfo
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getUsersInRoom
(
roomI
d
));
return
JSON
.
parse
(
android
.
getUsersInRoom
(
roomI
D
));
}
};
...
...
public_new/js/views/chats/chat-room-message.js
0 → 100644
View file @
51c13e76
const
userMessageTemplate
=
getTemplate
(
TemplateURL
.
USER_MESSAGE
);
const
myMessageTemplate
=
getTemplate
(
TemplateURL
.
MY_MESSAGE
);
const
systemMessageTemplate
=
getTemplate
(
TemplateURL
.
SYSTEM_MESSAGE
);
const
collaborationMessageTemplate
=
getTemplate
(
TemplateURL
.
OPEN_COLLABORATION_MESSAGE
);
/***********************
* Search Messages
***********************/
ChatRoom
.
appendSearchMessages
=
function
(
messages
,
unwrappedWorkVal
=
""
)
{
let
workVal
=
unwrappedWorkVal
;
messages
.
forEach
(
function
(
message
)
{
let
html
=
ChatRoom
.
renderMessageForSearchMessage
(
message
);
workVal
=
html
+
workVal
;
});
$
(
".overlay_src_msg"
).
prepend
(
workVal
);
};
ChatRoom
.
renderMessageForSearchMessage
=
function
(
message
)
{
let
template
=
ChatRoom
.
getChatMessageTemplate
(
message
.
messageType
,
message
.
shopMemberId
);
let
messageTime
=
CHAT_UTIL
.
formatDate
(
message
.
insertDate
);
message
.
profileUrl
=
ChatRoom
.
parseUserProfileURL
(
message
.
profileUrl
);
message
.
message
=
message
.
message
.
toString
()
.
replaceAll
(
"?fileName="
,
"?sid="
+
currentUserInfo
.
sid
+
"&fileName="
);
let
html
=
Mustache
.
render
(
template
,
{
text
:
message
.
message
,
from
:
message
.
loginId
,
shopMemberId
:
message
.
shopMemberId
,
profileImage
:
message
.
profileUrl
,
createdAtDay
:
messageTime
.
createdAtDay
,
createdAtTime
:
messageTime
.
createdAtTime
,
});
return
message
.
message
.
includes
(
"attachedImages"
)
||
message
.
message
.
includes
(
"attachedVideos"
)
?
CHAT_UTIL
.
htmlDecode
(
html
)
:
html
;
};
/***********************
* Send Messages
***********************/
ChatRoom
.
sendMessage
=
function
(
e
)
{
const
messageTextBox
=
$
(
"#messageInput"
);
const
message
=
messageTextBox
.
val
().
length
>
0
?
encodeURIComponent
(
messageTextBox
.
val
())
:
""
;
messageTextBox
.
val
(
""
);
if
(
message
.
length
>
0
)
{
const
sendData
=
message
+
messageSeperator
+
MessageType
.
TEXT
;
CHAT_SOCKET
.
emitCreateMessage
(
sendData
,
0
);
}
$
(
".message_input_form"
).
focus
();
};
/***********************
* Load Messages
***********************/
ChatRoom
.
loadMessages
=
function
(
joinRoomID
,
joinRoomName
)
{
let
roomID
=
joinRoomID
.
replace
(
/
[
'"
]
+/g
,
""
);
roomName
=
joinRoomName
;
// 画面更新
if
(
serverInfo
.
isOnline
==
"true"
)
{
Common
.
refreshForOnline
();
NativeBridgeDelegate
.
updateMessages
(
roomID
);
}
else
{
Common
.
refreshForOffline
();
}
// setup ルームタイトル
$
(
"#roomTitle"
).
text
(
roomName
).
data
(
"roomName"
,
roomName
);
// ルームメニュー表示設定
ChatRoom
.
configureRoomMenu
();
// ユーザー表示
ChatRoom
.
appendAttendedUsers
(
roomID
);
// メッセージ表示
ChatRoom
.
prependMessage
(
roomID
);
// スクロール調整
let
jQueryMessages
=
$
(
"#messages"
);
ChatRoom
.
waitForLoadingImage
(
jQueryMessages
,
ChatRoom
.
scrollToBottom
);
ChatRoom
.
waitForLoadingVideo
(
jQueryMessages
,
ChatRoom
.
scrollToBottom
);
// iOS用スクロールoffset調整
if
(
deviceInfo
.
isiOS
())
{
$
(
window
).
on
(
"load"
,
function
()
{
ChatRoom
.
scrollToBottom
();
});
}
};
ChatRoom
.
configureRoomMenu
=
function
()
{
const
roomType
=
NativeBridgeDataSource
.
getRoomType
();
if
(
roomType
==
ChatRoomType
.
DM
)
{
$
(
"#roomMenu"
).
removeClass
(
"none"
);
}
else
{
$
(
"#roomMenu"
).
addClass
(
"none"
);
}
};
ChatRoom
.
appendAttendedUsers
=
function
(
roomID
)
{
console
.
log
(
"peacekim:: ChatRoom.appendAttendedUsers start with RoomID: "
+
roomID
);
const
topUserListTemplate
=
getTemplate
(
TemplateURL
.
CHATROOM_USER_LIST
);
const
filterUserListTemplate
=
getTemplate
(
TemplateURL
.
CHATROOM_USER_FILTER_LIST
);
const
users
=
NativeBridgeDataSource
.
getUsersInRoom
(
roomID
);
// ユーザーリスト表示
users
.
forEach
(
function
(
user
)
{
user
.
profileUrl
=
Common
.
getProfileImgUrl
(
user
.
profileUrl
);
});
let
html
=
Mustache
.
render
(
topUserListTemplate
,
{
userList
:
users
,
});
let
obj
=
jQuery
.
parseHTML
(
html
);
$
(
"#user_list"
).
append
(
obj
);
// フィルタリングユーザーリスト表示
let
filterHtml
=
Mustache
.
render
(
filterUserListTemplate
,
{
userList
:
users
,
});
let
filterObj
=
jQuery
.
parseHTML
(
filterHtml
);
$
(
"#filter"
).
append
(
filterObj
);
};
ChatRoom
.
prependMessage
=
function
(
roomID
)
{
const
messages
=
NativeBridgeDataSource
.
getMessages
(
roomID
);
const
now
=
new
Date
();
// メッセージ文字列の生成
let
workVal
=
""
;
var
checkBeforeDate
=
""
;
var
beforeDate
=
""
;
messages
.
forEach
(
function
(
message
)
{
// プロフィールURL設定
message
.
profileUrl
=
ChatRoom
.
parseUserProfileURL
(
message
.
profileUrl
);
const
messageCreatedTime
=
CHAT_UTIL
.
formatDate
(
message
.
insertDate
).
createdAt
;
// #36147
message
.
message
=
message
.
message
.
toString
()
.
replaceAll
(
"?fileName="
,
"?sid="
+
currentUserInfo
.
sid
+
"&fileName="
);
// 日付表示のため、今年なのか、本日なのかを判定
const
isOtherYear
=
now
.
getFullYear
()
!=
message
.
insertDate
.
substring
(
0
,
4
);
const
isToday
=
messageCreatedTime
.
includes
(
":"
)
?
true
:
false
;
// 日付ラーベル表示
if
(
messageCreatedTime
!=
checkBeforeDate
&&
checkBeforeDate
!=
""
)
{
const
html
=
ChatRoom
.
renderDateLabelMessage
(
systemMessageTemplate
,
beforeDate
);
workVal
=
html
+
workVal
;
}
checkBeforeDate
=
messageCreatedTime
;
beforeDate
=
message
.
insertDate
;
const
html
=
ChatRoom
.
renderMessage
(
message
,
isToday
,
isOtherYear
);
workVal
=
html
+
workVal
;
});
// メッセージの画面描画
$
(
"#messages"
).
prepend
(
workVal
);
};
ChatRoom
.
renderDateLabelMessage
=
function
(
template
,
beforeDate
)
{
let
messageDay
=
CHAT_UTIL
.
systemDay
(
beforeDate
);
return
Mustache
.
render
(
template
,
{
year
:
messageDay
.
year
+
getLocalizedString
(
"year"
),
month
:
messageDay
.
month
+
getLocalizedString
(
"month"
),
day
:
messageDay
.
day
+
getLocalizedString
(
"day"
),
dow
:
CHAT_UTIL
.
findDow
(
messageDay
.
dow
),
});
};
ChatRoom
.
getChatMessageTemplate
=
function
(
messageType
,
senderID
)
{
if
(
senderID
==
currentUserInfo
.
shopMemberId
)
{
return
myMessageTemplate
;
}
else
if
(
messageType
==
MessageType
.
SYSTEM
)
{
return
systemMessageTemplate
;
}
else
{
return
userMessageTemplate
;
}
};
ChatRoom
.
parseUserProfileURL
=
function
(
profileURL
)
{
if
(
profileURL
)
{
return
Common
.
getProfileImgUrl
(
profileURL
);
}
else
{
return
Common
.
getProfileImgUrl
(
""
);
}
};
ChatRoom
.
renderMessage
=
function
(
message
,
isToday
,
isOtherYear
)
{
if
(
message
.
messageType
==
MessageType
.
COMMUNICATIONSTART
||
message
.
messageType
==
MessageType
.
COMMUNICATIONEND
)
{
return
ChatRoom
.
renderCollaborationMessage
(
message
,
isToday
,
isOtherYear
);
}
else
{
return
ChatRoom
.
renderChatMessage
(
message
,
isToday
,
isOtherYear
);
}
};
ChatRoom
.
renderCollaborationMessage
=
function
(
message
,
isToday
,
isOtherYear
)
{
const
collaborationInfo
=
JSON
.
parse
(
message
.
message
);
const
userInCollaboration
=
JSON
.
parse
(
NativeBridgeDataSource
.
getUserInfoList
(
collaborationInfo
.
userList
)
);
const
displayUserList
=
ChatRoom
.
getDisplayUserList
(
userInCollaboration
);
const
meetingID
=
ChatRoom
.
getMeetingID
(
collaborationInfo
);
const
messageTime
=
CHAT_UTIL
.
formatDate
(
message
.
insertDate
);
const
createdAtYear
=
message
.
insertDate
.
substring
(
0
,
4
)
+
getLocalizedString
(
"year"
)
+
" "
;
const
html
=
Mustache
.
render
(
collaborationMessageTemplate
,
{
messageId
:
message
.
messageId
,
roomName
:
roomName
,
userCount
:
userInCollaboration
.
length
,
userList
:
displayUserList
,
insertDate
:
message
.
insertDate
,
collaborationType
:
collaborationInfo
.
collaborationType
,
meetingId
:
meetingID
,
isToday
:
isToday
,
createdAtDay
:
messageTime
.
createdAtDay
,
createdAtTime
:
messageTime
.
createdAtTime
,
createdAtYear
:
createdAtYear
,
isOtherYear
:
isOtherYear
,
isEnded
:
message
.
messageType
==
MessageType
.
COMMUNICATIONEND
?
true
:
false
,
});
return
message
.
message
.
includes
(
"attachedImages"
)
||
message
.
message
.
includes
(
"attachedVideos"
)
?
CHAT_UTIL
.
htmlDecode
(
html
)
:
html
;
};
ChatRoom
.
getMeetingID
=
function
(
collaborationInfo
)
{
if
(
typeof
collaborationInfo
.
meetingId
!=
"undefined"
)
{
return
collaborationInfo
.
meetingId
;
}
else
{
return
0
;
}
};
ChatRoom
.
getDisplayUserList
=
function
(
userList
)
{
userList
.
forEach
(
function
(
user
)
{
user
.
profileUrl
=
Common
.
getProfileImgUrl
(
user
.
profileUrl
);
});
return
userList
.
length
>
3
?
userList
.
slice
(
0
,
3
)
:
userList
;
};
ChatRoom
.
renderChatMessage
=
function
(
message
,
isToday
,
isOtherYear
)
{
const
template
=
ChatRoom
.
getChatMessageTemplate
(
message
.
messageType
,
message
.
shopMemberId
);
const
messageTime
=
CHAT_UTIL
.
formatDate
(
message
.
insertDate
);
const
createdAtYear
=
message
.
insertDate
.
substring
(
0
,
4
)
+
getLocalizedString
(
"year"
)
+
" "
;
const
html
=
Mustache
.
render
(
template
,
{
text
:
message
.
message
,
from
:
message
.
loginId
,
messageId
:
message
.
messageId
,
shopMemberId
:
message
.
shopMemberId
,
profileImage
:
message
.
profileUrl
,
createdAtDay
:
messageTime
.
createdAtDay
,
createdAtTime
:
messageTime
.
createdAtTime
,
createdAtYear
:
createdAtYear
,
unreadCount
:
message
.
unreadCount
,
isOtherYear
:
isOtherYear
,
isToday
:
isToday
,
});
return
message
.
message
.
includes
(
"attachedImages"
)
||
message
.
message
.
includes
(
"attachedVideos"
)
?
CHAT_UTIL
.
htmlDecode
(
html
)
:
html
;
};
public_new/js/views/chats/chat-room-search.js
0 → 100644
View file @
51c13e76
ChatRoom
.
bindSearchUI
=
function
()
{
const
chatSearchForm
=
$
(
".chat_room_src_form"
);
const
chatSearchInput
=
$
(
'.chat_room_src_form input[type="search"]'
);
const
searchMessage
=
$
(
"#searchMessage"
);
// 検索アイコン押下イベント
$
(
".nav_item_wrap .search_menu"
).
click
(
function
()
{
$
(
".nav_item_wrap"
).
addClass
(
"none"
);
$
(
".footer-wrap"
).
addClass
(
"none"
);
chatSearchForm
.
removeClass
(
"none"
);
$
(
".room_container"
).
addClass
(
"none"
);
$
(
".overlay_src_msg"
).
removeClass
(
"none"
);
// フィルタ表示
$
(
"#filter"
).
removeClass
(
"none"
);
$
(
"#user_list"
).
addClass
(
"none"
);
chatSearchInput
.
focus
();
searchMessage
.
addClass
(
"onfocus"
);
$
(
".chat_list"
).
removeClass
(
"none"
);
});
$
(
".chat_room_src_form .cancel"
).
click
(
function
()
{
$
(
".nav_item_wrap"
).
removeClass
(
"none"
);
$
(
".footer-wrap"
).
removeClass
(
"none"
);
chatSearchForm
.
addClass
(
"none"
);
$
(
".chat_room_src_form input"
).
val
(
""
);
$
(
".room_container"
).
removeClass
(
"none"
);
$
(
".overlay_src_msg"
).
empty
();
// ユーザーリスト表示
$
(
"#filter"
).
addClass
(
"none"
);
$
(
"#user_list"
).
removeClass
(
"none"
);
chatSearchInput
.
blur
();
searchMessage
.
removeClass
(
"onfocus"
);
$
(
".chat_list"
).
addClass
(
"none"
);
ChatRoom
.
scrollToBottom
();
});
chatSearchInput
.
click
(
function
()
{
if
(
searchMessage
.
hasClass
(
"onfocus"
))
{
searchMessage
.
removeClass
(
"onfocus"
);
searchMessage
.
blur
();
}
else
{
searchMessage
.
addClass
(
"onfocus"
);
searchMessage
.
focus
();
}
});
searchMessage
.
blur
(
function
()
{
searchMessage
.
removeClass
(
"onfocus"
);
});
// チャットルーム
// メッセージ検索イベント
chatSearchInput
.
keyup
(
function
(
e
)
{
let
workVal
=
""
;
const
keyword
=
chatSearchInput
.
val
();
const
enterKeyPressed
=
e
.
key
==
"Enter"
||
e
.
KeyCode
==
13
;
if
(
enterKeyPressed
)
{
if
(
keyword
!=
""
&&
keyword
.
length
!=
0
)
{
chatSearchInput
.
blur
();
return
;
}
}
else
if
(
keyword
==
""
||
keyword
.
length
<
2
)
{
$
(
".overlay_src_msg"
).
empty
();
return
;
}
ChatRoom
.
searchMessage
(
keyword
,
workVal
);
if
(
enterKeyPressed
)
{
searchMessage
.
removeClass
(
"onfocus"
);
chatSearchInput
.
blur
();
return
;
}
});
// iOSキーボード変換検知用
chatSearchInput
.
on
(
"compositionend"
,
function
()
{
if
(
deviceInfo
.
isIOS
())
{
let
workVal
=
""
;
var
keyword
=
chatSearchInput
.
val
();
ChatRoom
.
searchMessage
(
keyword
,
workVal
);
}
});
ChatRoom
.
bindUserFilteredMessage
();
// フィルタ選択イベント
$
(
document
).
on
(
"click"
,
"#filter .img_wrap"
,
function
(
event
)
{
// チェックアイコン追加
$
(
this
).
toggleClass
(
"filter"
);
});
};
ChatRoom
.
bindUserFilteredMessage
=
function
()
{
$
(
document
).
on
(
"click"
,
".filter_img"
,
function
(
event
)
{
const
keyword
=
$
(
'.chat_room_src_form input[type="search"]'
).
val
();
$
(
".overlay_src_msg"
).
empty
();
let
checkedUserList
=
ChatRoom
.
getCheckedUserList
();
if
(
keyword
.
length
==
1
)
{
return
;
}
const
messages
=
NativeBridgeDataSource
.
searchMessages
(
keyword
,
checkedUserList
.
join
(
","
)
);
ChatRoom
.
appendSearchMessages
(
messages
);
});
};
// メッセージ検索
ChatRoom
.
searchMessage
=
function
(
keyword
,
workVal
)
{
$
(
".overlay_src_msg"
).
empty
();
let
checkedUserList
=
ChatRoom
.
getCheckedUserList
();
const
messages
=
NativeBridgeDataSource
.
searchMessages
(
keyword
,
checkedUserList
.
join
(
","
)
);
ChatRoom
.
appendSearchMessages
(
messages
,
workVal
);
if
(
messages
.
length
==
0
)
{
const
noResultMsg
=
getNoResultMessage
();
$
(
".overlay_src_msg"
).
append
(
noResultMsg
);
}
};
ChatRoom
.
getCheckedUserList
=
function
()
{
let
checkedUserList
=
[];
$
(
".img_wrap.filter"
).
each
(
function
(
user
)
{
const
selectedUser
=
$
(
".img_wrap.filter"
)[
user
];
checkedUserList
.
push
(
$
(
selectedUser
).
data
(
"user-id"
));
});
return
checkedUserList
;
};
public_new/js/views/chats/chat-room.js
View file @
51c13e76
var
beforeHeight
=
window
.
innerHeight
;
var
beforeWidth
=
window
.
innerWidth
;
var
beforeScroll
;
var
roomName
=
""
;
var
ChatRoom
=
{};
window
.
onscroll
=
function
()
{
...
...
@@ -29,24 +29,33 @@ window.onscroll = function () {
};
document
.
addEventListener
(
"DOMContentLoaded"
,
function
()
{
bindSearchUI
();
// 検索イベントバインディング
ChatRoom
.
bindSearchUI
();
// 画面サイズ変更イベントバインディング
ChatRoom
.
bindResize
();
// メッセージ入力イベントバインディング
ChatRoom
.
bindMessageInput
();
});
var
footerHeight
=
$
(
".footer-wrap"
).
height
();
ChatRoom
.
bindResize
=
function
()
{
const
footerHeight
=
$
(
".footer-wrap"
).
height
();
window
.
addEventListener
(
"resize"
,
function
()
{
var
afterHeight
=
window
.
innerHeight
;
var
afterWidth
=
window
.
innerWidth
;
var
moreScroll
=
beforeHeight
-
afterHeight
;
const
footerHeight
=
$
(
".footer_content_b"
).
height
();
const
footer
B
Height
=
$
(
".footer_content_b"
).
height
();
if
(
beforeHeight
>
afterHeight
&&
beforeHeight
-
afterHeight
>
50
)
{
if
(
deviceInfo
.
isiOS
())
{
window
.
scrollTo
(
0
,
beforeScroll
+
moreScroll
);
}
else
if
(
beforeWidth
==
afterWidth
)
{
//キーボード表示時
$
(
".room_container"
).
css
(
"margin-bottom"
,
0
);
window
.
scrollTo
(
0
,
beforeScroll
+
moreScroll
-
footerHeight
);
window
.
scrollTo
(
0
,
beforeScroll
+
moreScroll
-
footer
B
Height
);
}
else
{
//画面回転時
window
.
scrollTo
(
0
,
beforeScroll
+
moreScroll
*
2
-
footerHeight
);
window
.
scrollTo
(
0
,
beforeScroll
+
moreScroll
*
2
-
footer
B
Height
);
}
}
else
if
(
beforeHeight
<
afterHeight
)
{
$
(
".room_container"
).
css
(
"margin-bottom"
,
footerHeight
);
...
...
@@ -54,16 +63,18 @@ document.addEventListener("DOMContentLoaded", function () {
window
.
scrollTo
(
0
,
beforeScroll
+
moreScroll
);
}
else
if
(
beforeWidth
==
afterWidth
)
{
//キーボード非表示
window
.
scrollTo
(
0
,
beforeScroll
+
moreScroll
+
footerHeight
);
window
.
scrollTo
(
0
,
beforeScroll
+
moreScroll
+
footer
B
Height
);
}
else
{
//画面回転時
window
.
scrollTo
(
0
,
beforeScroll
+
moreScroll
*
2
+
footerHeight
);
window
.
scrollTo
(
0
,
beforeScroll
+
moreScroll
*
2
+
footer
B
Height
);
}
}
beforeHeight
=
window
.
innerHeight
;
beforeWidth
=
window
.
innerWidth
;
});
};
ChatRoom
.
bindMessageInput
=
function
()
{
$
(
"#messageInput"
).
focusin
(
function
(
e
)
{
beforeHeight
=
window
.
innerHeight
;
beforeWidth
=
window
.
innerWidth
;
...
...
@@ -89,225 +100,6 @@ document.addEventListener("DOMContentLoaded", function () {
}
},
10
);
});
});
var
bindSearchUI
=
function
()
{
const
chatSearchForm
=
$
(
".chat_room_src_form"
);
const
chatSearchInput
=
$
(
'.chat_room_src_form input[type="search"]'
);
const
searchMessage
=
$
(
"#searchMessage"
);
// 検索アイコン押下イベント
$
(
".nav_item_wrap .search_menu"
).
click
(
function
()
{
$
(
".nav_item_wrap"
).
addClass
(
"none"
);
$
(
".footer-wrap"
).
addClass
(
"none"
);
chatSearchForm
.
removeClass
(
"none"
);
$
(
".room_container"
).
addClass
(
"none"
);
$
(
".overlay_src_msg"
).
removeClass
(
"none"
);
// フィルタ表示
$
(
"#filter"
).
removeClass
(
"none"
);
$
(
"#user_list"
).
addClass
(
"none"
);
chatSearchInput
.
focus
();
searchMessage
.
addClass
(
"onfocus"
);
$
(
".chat_list"
).
removeClass
(
"none"
);
});
$
(
".chat_room_src_form .cancel"
).
click
(
function
()
{
$
(
".nav_item_wrap"
).
removeClass
(
"none"
);
$
(
".footer-wrap"
).
removeClass
(
"none"
);
chatSearchForm
.
addClass
(
"none"
);
$
(
".chat_room_src_form input"
).
val
(
""
);
$
(
".room_container"
).
removeClass
(
"none"
);
$
(
".overlay_src_msg"
).
empty
();
// ユーザーリスト表示
$
(
"#filter"
).
addClass
(
"none"
);
$
(
"#user_list"
).
removeClass
(
"none"
);
chatSearchInput
.
blur
();
searchMessage
.
removeClass
(
"onfocus"
);
$
(
".chat_list"
).
addClass
(
"none"
);
ChatRoom
.
scrollToBottom
();
});
chatSearchInput
.
click
(
function
()
{
if
(
searchMessage
.
hasClass
(
"onfocus"
))
{
searchMessage
.
removeClass
(
"onfocus"
);
searchMessage
.
blur
();
}
else
{
searchMessage
.
addClass
(
"onfocus"
);
searchMessage
.
focus
();
}
});
searchMessage
.
blur
(
function
()
{
searchMessage
.
removeClass
(
"onfocus"
);
});
// チャットルーム
// メッセージ検索イベント
chatSearchInput
.
keyup
(
function
(
e
)
{
let
workVal
=
""
;
const
keyword
=
chatSearchInput
.
val
();
const
enterKeyPressed
=
e
.
key
==
"Enter"
||
e
.
KeyCode
==
13
;
if
(
enterKeyPressed
)
{
if
(
keyword
!=
""
&&
keyword
.
length
!=
0
)
{
chatSearchInput
.
blur
();
return
;
}
}
else
if
(
keyword
==
""
||
keyword
.
length
<
2
)
{
$
(
".overlay_src_msg"
).
empty
();
return
;
}
ChatRoom
.
searchMessage
(
keyword
,
workVal
);
if
(
enterKeyPressed
)
{
searchMessage
.
removeClass
(
"onfocus"
);
chatSearchInput
.
blur
();
return
;
}
});
// iOSキーボード変換検知用
chatSearchInput
.
on
(
"compositionend"
,
function
()
{
if
(
deviceInfo
.
isIOS
())
{
let
workVal
=
""
;
var
keyword
=
chatSearchInput
.
val
();
ChatRoom
.
searchMessage
(
keyword
,
workVal
);
}
});
$
(
document
).
on
(
"click"
,
".filter_img"
,
function
(
event
)
{
let
workVal
=
""
;
var
keyword
=
chatSearchInput
.
val
();
$
(
".overlay_src_msg"
).
empty
();
let
checkedUserList
=
getCheckedUserList
();
if
(
keyword
.
length
==
1
)
{
return
;
}
const
messages
=
NativeBridgeDataSource
.
searchMessages
(
keyword
,
checkedUserList
.
join
(
","
)
);
const
userMessageTemplate
=
getTemplate
(
TemplateURL
.
USER_MESSAGE
);
const
myMessageTemplate
=
getTemplate
(
TemplateURL
.
MY_MESSAGE
);
let
jQueryMessages
=
$
(
".overlay_src_msg"
);
messages
.
forEach
(
function
(
message
)
{
let
template
=
userMessageTemplate
;
if
(
message
.
shopMemberId
==
currentUserInfo
.
shopMemberId
)
{
template
=
myMessageTemplate
;
}
if
(
message
.
messageType
==
MessageType
.
SYSTEM
)
{
template
=
systemMessageTemplate
;
}
let
messageTime
=
CHAT_UTIL
.
formatDate
(
message
.
insertDate
);
// ユーザの様式を読み込む
if
(
message
.
profileUrl
)
{
message
.
profileUrl
=
Common
.
getProfileImgUrl
(
message
.
profileUrl
);
}
else
{
message
.
profileUrl
=
Common
.
getProfileImgUrl
(
""
);
}
message
.
message
=
message
.
message
.
toString
();
var
replacePath
=
message
.
message
;
replacePath
=
replacePath
.
replaceAll
(
"?fileName="
,
"?sid="
+
currentUserInfo
.
sid
+
"&fileName="
);
message
.
message
=
replacePath
;
let
html
=
Mustache
.
render
(
template
,
{
text
:
message
.
message
,
from
:
message
.
loginId
,
shopMemberId
:
message
.
shopMemberId
,
profileImage
:
message
.
profileUrl
,
createdAtDay
:
messageTime
.
createdAtDay
,
createdAtTime
:
messageTime
.
createdAtTime
,
});
html
=
message
.
message
.
includes
(
"attachedImages"
)
||
message
.
message
.
includes
(
"attachedVideos"
)
?
CHAT_UTIL
.
htmlDecode
(
html
)
:
html
;
workVal
=
html
+
workVal
;
});
jQueryMessages
.
prepend
(
workVal
);
});
// フィルタ選択イベント
$
(
document
).
on
(
"click"
,
"#filter .img_wrap"
,
function
(
event
)
{
// チェックアイコン追加
$
(
this
).
toggleClass
(
"filter"
);
});
};
var
getCheckedUserList
=
function
()
{
let
checkedUserList
=
[];
$
(
".img_wrap.filter"
).
each
(
function
(
user
)
{
const
selectedUser
=
$
(
".img_wrap.filter"
)[
user
];
checkedUserList
.
push
(
$
(
selectedUser
).
data
(
"user-id"
));
});
return
checkedUserList
;
};
// メッセージ検索
ChatRoom
.
searchMessage
=
function
(
keyword
,
workVal
)
{
$
(
".overlay_src_msg"
).
empty
();
var
checkedUserList
=
[];
$
(
".img_wrap.filter"
).
each
(
function
(
user
)
{
const
selectedUser
=
$
(
".img_wrap.filter"
)[
user
];
checkedUserList
.
push
(
$
(
selectedUser
).
data
(
"user-id"
));
});
var
messages
=
NativeBridgeDataSource
.
searchMessages
(
keyword
,
checkedUserList
.
join
(
","
)
);
var
userMessageTemplate
=
getTemplate
(
TemplateURL
.
USER_MESSAGE
);
var
myMessageTemplate
=
getTemplate
(
TemplateURL
.
MY_MESSAGE
);
let
jQueryMessages
=
$
(
".overlay_src_msg"
);
messages
.
forEach
(
function
(
message
)
{
let
template
=
userMessageTemplate
;
if
(
message
.
shopMemberId
==
currentUserInfo
.
shopMemberId
)
{
template
=
myMessageTemplate
;
}
if
(
message
.
messageType
==
MessageType
.
SYSTEM
)
{
template
=
systemMessageTemplate
;
}
let
messageTime
=
CHAT_UTIL
.
formatDate
(
message
.
insertDate
);
let
messageTime
=
CHAT_UTIL
.
formatDate
(
message
.
insertDate
);
if
(
message
.
profileUrl
)
{
message
.
profileUrl
=
Common
.
getProfileImgUrl
(
message
.
profileUrl
);
}
else
{
message
.
profileUrl
=
Common
.
getProfileImgUrl
(
""
);
}
message
.
message
=
message
.
message
.
toString
();
var
replacePath
=
message
.
message
;
replacePath
=
replacePath
.
replaceAll
(
"?fileName="
,
"?sid="
+
currentUserInfo
.
sid
+
"&fileName="
);
message
.
message
=
replacePath
;
let
html
=
Mustache
.
render
(
template
,
{
text
:
message
.
message
,
from
:
message
.
loginId
,
shopMemberId
:
message
.
shopMemberId
,
profileImage
:
message
.
profileUrl
,
createdAtDay
:
messageTime
.
createdAtDay
,
createdAtTime
:
messageTime
.
createdAtTime
,
});
html
=
message
.
message
.
includes
(
"attachedImages"
)
||
message
.
message
.
includes
(
"attachedVideos"
)
?
CHAT_UTIL
.
htmlDecode
(
html
)
:
html
;
workVal
=
html
+
workVal
;
});
jQueryMessages
.
prepend
(
workVal
);
if
(
messages
.
length
==
0
)
{
const
noResultMsg
=
getNoResultMessage
();
jQueryMessages
.
append
(
noResultMsg
);
}
};
// 下スクロールでユーザーリストを非表示
...
...
@@ -371,222 +163,15 @@ ChatRoom.startCollaboration = function (collaborationType) {
NativeBridgeDelegate
.
startCollaboration
(
collaborationType
);
};
ChatRoom
.
sendMessage
=
function
(
e
)
{
const
messageTextBox
=
$
(
"#messageInput"
);
const
message
=
messageTextBox
.
val
().
length
>
0
?
encodeURIComponent
(
messageTextBox
.
val
())
:
""
;
messageTextBox
.
val
(
""
);
if
(
message
.
length
>
0
)
{
const
sendData
=
message
+
messageSeperator
+
MessageType
.
TEXT
;
CHAT_SOCKET
.
emitCreateMessage
(
sendData
,
0
);
}
$
(
".message_input_form"
).
focus
();
};
ChatRoom
.
loadMessages
=
function
(
roomId
,
joinRoomName
)
{
roomName
=
joinRoomName
;
if
(
serverInfo
.
isOnline
==
"true"
)
{
Common
.
refreshForOnline
();
NativeBridgeDelegate
.
updateMessages
(
roomId
);
}
else
{
Common
.
refreshForOffline
();
}
const
roomType
=
NativeBridgeDataSource
.
getRoomType
();
if
(
roomType
==
ChatRoomType
.
DM
)
{
$
(
"#roomMenu"
).
removeClass
(
"none"
);
}
var
messages
=
NativeBridgeDataSource
.
getMessages
(
roomId
);
var
usersInRoom
=
NativeBridgeDataSource
.
getUsersInRoom
(
roomId
);
$
(
"#roomTitle"
).
text
(
roomName
).
data
(
"roomName"
,
roomName
);
let
jQueryMessages
=
$
(
"#messages"
);
var
topUserListTemplate
=
getTemplate
(
TemplateURL
.
CHATROOM_USER_LIST
);
var
filterUserListTemplate
=
getTemplate
(
TemplateURL
.
CHATROOM_USER_FILTER_LIST
);
usersInRoom
.
forEach
(
function
(
user
)
{
user
.
profileUrl
=
Common
.
getProfileImgUrl
(
user
.
profileUrl
);
});
let
html
=
Mustache
.
render
(
topUserListTemplate
,
{
userList
:
usersInRoom
,
});
let
obj
=
jQuery
.
parseHTML
(
html
);
$
(
"#user_list"
).
append
(
obj
);
let
filterHtml
=
Mustache
.
render
(
filterUserListTemplate
,
{
userList
:
usersInRoom
,
});
let
filterObj
=
jQuery
.
parseHTML
(
filterHtml
);
$
(
"#filter"
).
append
(
filterObj
);
ChatRoom
.
prependMessage
(
messages
);
ChatRoom
.
waitForLoadingImage
(
jQueryMessages
,
ChatRoom
.
scrollToBottom
);
ChatRoom
.
waitForLoadingVideo
(
jQueryMessages
,
ChatRoom
.
scrollToBottom
);
if
(
deviceInfo
.
isiOS
())
{
$
(
window
).
on
(
"load"
,
function
()
{
ChatRoom
.
scrollToBottom
();
});
}
};
ChatRoom
.
prependMessage
=
function
(
messages
)
{
var
now
=
new
Date
();
let
jQueryMessages
=
$
(
"#messages"
);
// メッセージ文字列の生成
let
workVal
=
""
;
var
userMessageTemplate
=
getTemplate
(
TemplateURL
.
USER_MESSAGE
);
var
myMessageTemplate
=
getTemplate
(
TemplateURL
.
MY_MESSAGE
);
var
systemMessageTemplate
=
getTemplate
(
TemplateURL
.
SYSTEM_MESSAGE
);
var
openCollaborationMessageTemplate
=
getTemplate
(
TemplateURL
.
OPEN_COLLABORATION_MESSAGE
);
var
checkBeforeDate
=
""
;
var
beforeDate
=
""
;
messages
.
forEach
(
function
(
message
)
{
let
template
=
userMessageTemplate
;
if
(
message
.
shopMemberId
==
currentUserInfo
.
shopMemberId
)
{
template
=
myMessageTemplate
;
}
if
(
message
.
messageType
==
MessageType
.
SYSTEM
)
{
template
=
systemMessageTemplate
;
}
if
(
message
.
messageType
==
MessageType
.
COMMUNICATIONSTART
||
message
.
messageType
==
MessageType
.
COMMUNICATIONEND
)
{
template
=
openCollaborationMessageTemplate
;
}
let
messageTime
=
CHAT_UTIL
.
formatDate
(
message
.
insertDate
);
// ユーザの様式を読み込む
if
(
message
.
profileUrl
)
{
message
.
profileUrl
=
Common
.
getProfileImgUrl
(
message
.
profileUrl
);
}
else
{
message
.
profileUrl
=
Common
.
getProfileImgUrl
(
""
);
}
// #36147
message
.
message
=
message
.
message
.
toString
();
var
replacePath
=
message
.
message
;
replacePath
=
replacePath
.
replaceAll
(
"?fileName="
,
"?sid="
+
currentUserInfo
.
sid
+
"&fileName="
);
message
.
message
=
replacePath
;
/* if (message.message contain) {
}*/
var
isOtherYear
=
false
;
var
isToday
=
false
;
if
(
messageTime
.
createdAt
.
includes
(
":"
))
{
isToday
=
true
;
}
if
(
now
.
getFullYear
()
!=
message
.
insertDate
.
substring
(
0
,
4
))
{
isOtherYear
=
true
;
}
if
(
messageTime
.
createdAtDay
!=
checkBeforeDate
&&
checkBeforeDate
!=
""
)
{
let
messageDay
=
CHAT_UTIL
.
systemDay
(
beforeDate
);
let
html
=
Mustache
.
render
(
systemMessageTemplate
,
{
year
:
messageDay
.
year
+
getLocalizedString
(
"year"
),
month
:
messageDay
.
month
+
getLocalizedString
(
"month"
),
day
:
messageDay
.
day
+
getLocalizedString
(
"day"
),
dow
:
CHAT_UTIL
.
findDow
(
messageDay
.
dow
),
});
workVal
=
html
+
workVal
;
}
checkBeforeDate
=
messageTime
.
createdAtDay
;
beforeDate
=
message
.
insertDate
;
if
(
message
.
messageType
==
MessageType
.
COMMUNICATIONSTART
||
message
.
messageType
==
MessageType
.
COMMUNICATIONEND
)
{
const
collaborationInfo
=
JSON
.
parse
(
message
.
message
);
const
userInCollaboration
=
JSON
.
parse
(
NativeBridgeDataSource
.
getUserInfoList
(
collaborationInfo
.
userList
)
);
var
meetingId
=
0
;
if
(
typeof
collaborationInfo
.
meetingId
!=
"undefined"
)
{
meetingId
=
collaborationInfo
.
meetingId
;
}
userInCollaboration
.
forEach
(
function
(
user
)
{
user
.
profileUrl
=
Common
.
getProfileImgUrl
(
user
.
profileUrl
);
});
let
html
=
Mustache
.
render
(
template
,
{
messageId
:
message
.
messageId
,
roomName
:
roomName
,
userCount
:
userInCollaboration
.
length
,
userList
:
userInCollaboration
.
length
>
3
?
userInCollaboration
.
slice
(
0
,
3
)
:
userInCollaboration
,
insertDate
:
message
.
insertDate
,
collaborationType
:
collaborationInfo
.
collaborationType
,
meetingId
:
meetingId
,
isToday
:
isToday
,
createdAtDay
:
messageTime
.
createdAtDay
,
createdAtTime
:
messageTime
.
createdAtTime
,
createdAtYear
:
message
.
insertDate
.
substring
(
0
,
4
)
+
getLocalizedString
(
"year"
)
+
" "
,
isOtherYear
:
isOtherYear
,
isEnded
:
message
.
messageType
==
MessageType
.
COMMUNICATIONEND
?
true
:
false
,
});
html
=
message
.
message
.
includes
(
"attachedImages"
)
||
message
.
message
.
includes
(
"attachedVideos"
)
?
CHAT_UTIL
.
htmlDecode
(
html
)
:
html
;
workVal
=
html
+
workVal
;
}
else
{
let
html
=
Mustache
.
render
(
template
,
{
text
:
message
.
message
,
from
:
message
.
loginId
,
messageId
:
message
.
messageId
,
shopMemberId
:
message
.
shopMemberId
,
profileImage
:
message
.
profileUrl
,
createdAtDay
:
messageTime
.
createdAtDay
,
createdAtTime
:
messageTime
.
createdAtTime
,
createdAtYear
:
message
.
insertDate
.
substring
(
0
,
4
)
+
getLocalizedString
(
"year"
)
+
" "
,
unreadCount
:
message
.
unreadCount
,
isOtherYear
:
isOtherYear
,
isToday
:
isToday
,
});
html
=
message
.
message
.
includes
(
"attachedImages"
)
||
message
.
message
.
includes
(
"attachedVideos"
)
?
CHAT_UTIL
.
htmlDecode
(
html
)
:
html
;
workVal
=
html
+
workVal
;
}
});
// メッセージの画面描画
jQueryMessages
.
prepend
(
workVal
);
};
// 画像の読み込みが全て終わったタイミングでコールバック実行
// FIXME 追加読み込みの場合は差分の画像のみ監視すべきだが、現状新規入室時にしか対応出来ていない。
ChatRoom
.
waitForLoadingVideo
=
function
(
div
,
callback
)
{
Common
.
showLoadingIndicator
();
// var imgs = document.getElementsByTagName("video");
var
video
=
div
.
find
(
"video"
);
var
count
=
video
.
length
;
let
video
=
div
.
find
(
"video"
);
let
count
=
video
.
length
;
if
(
count
==
0
)
callback
();
var
loaded
=
0
;
let
loaded
=
0
;
video
.
each
(
function
()
{
this
.
addEventListener
(
"loadeddata"
,
function
(
e
)
{
loaded
++
;
...
...
@@ -599,10 +184,10 @@ ChatRoom.waitForLoadingVideo = function (div, callback) {
};
ChatRoom
.
waitForLoadingImage
=
function
(
div
,
callback
)
{
var
imgs
=
div
.
find
(
"img"
);
var
count
=
imgs
.
length
;
let
imgs
=
div
.
find
(
"img"
);
let
count
=
imgs
.
length
;
if
(
count
==
0
)
callback
();
var
loaded
=
0
;
let
loaded
=
0
;
imgs
.
one
(
"load"
,
function
(
e
)
{
// イメージが読み込まれた
...
...
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