Skip to content

Commit 4fd7536

Browse files
committed
Whiteboard Added
1 parent 6b319b4 commit 4fd7536

File tree

12 files changed

+1900
-206
lines changed

12 files changed

+1900
-206
lines changed

app/Http/Controllers/KchatController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ function kchat(Request $request){
1717
// Insert Message and Update id in conversations
1818
if(!empty($request->message)){
1919

20+
$type = 0;
21+
22+
if(!empty($request->whiteboard)){
23+
$type = 1;
24+
}
25+
2026
$id = DB::table('messages')->insertGetId([
2127
'user_id' => Auth()->user()->id,
2228
'message' => $request->message,
2329
'conversation_id' => $request->chat,
2430
'created_at' => now(),
31+
'type' => $type,
2532
]);
2633

2734
DB::table('conversations')->where('id', $request->chat)->update(['message_id' => $id]);

app/Http/Controllers/MessageController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ function messages(Request $request){
3434
$conversation = $conversation[0];
3535

3636
if($request->role == 'admin'){
37-
return view('admin.msg',compact('chat','conversation'));
37+
return view('common.msg',compact('chat','conversation'));
3838
}
3939

40-
return view('user.msg',compact('chat','conversation'));
40+
return view('common.msg',compact('chat','conversation'));
4141
}
4242

4343
function UpdateConversation(Request $request){

bootstrap/Activity.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function save($title, $notification){
1717
'title' => $title,
1818
'notification' => $notification,
1919
'created_at' => now(),
20+
'updated_at' => now(),
2021
]);
2122
}
2223
}

bootstrap/Notification.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ function save($uid, $title, $notification){
2424
$user['title'] = $title;
2525
$user['notification'] = $notification;
2626
$user['photo'] = Auth()->user()->photo;
27+
$user['created_at'] = now();
28+
$user['updated_at'] = now();
2729
}
2830

2931
Notifications::insert($users);

public/css/emojionearea.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/css/kchat.css

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ img {
587587
}
588588

589589
.chat .chat-message {
590-
padding: 20px;
590+
padding: 5px;
591591
border-top: 2px solid #e9e9e9;
592592
}
593593

@@ -760,7 +760,6 @@ tbody tr:hover {
760760
}
761761

762762
input {
763-
display: block;
764763
font-size: 1rem;
765764
line-height: 1.5;
766765
color: #495057;
@@ -769,4 +768,21 @@ input {
769768
border: 1px solid #ced4da;
770769
border-radius: .25rem;
771770
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
771+
}
772+
773+
.row:after, .row:before {
774+
content: " ";
775+
display: table;
776+
clear: both;
777+
}
778+
779+
.span6 {
780+
float: left;
781+
width: 48%;
782+
padding: 1%;
783+
}
784+
785+
#whiteboard-model{
786+
width: 800px;
787+
margin: auto;
772788
}

public/css/msg.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,4 @@
250250
height: calc(100vh - 350px);
251251
overflow-x: auto
252252
}
253-
}
253+
}

public/js/chart - Copy.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

public/js/emojionearea.js

Lines changed: 1743 additions & 0 deletions
Large diffs are not rendered by default.

public/js/kchat.msg.js

Lines changed: 85 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,47 @@ typing = false;
44
OnLoadMsgs = true;
55
previous = false;
66
conversation_like = '';
7+
emojioneAreaElm = null;
8+
WhiteBoard = false;
79

810
$(document).ready (function(){
9-
11+
12+
$("#post_msg").emojioneArea({
13+
pickerPosition: "top",
14+
tonesStyle: "bullet",
15+
events: {
16+
keypress: function (editor, event) {
17+
emojioneAreaElm = this;
18+
var keycode = (event.keyCode ? event.keyCode : event.which);
19+
if(keycode == '13'){
20+
post_msg();
21+
}
22+
}
23+
}
24+
});
25+
1026
function post_msg(){
11-
message = $("#post_msg").val();
27+
if(emojioneAreaElm != null){
28+
message = emojioneAreaElm.getText();
29+
emojioneAreaElm.setText('');
30+
}
31+
if(WhiteBoard){
32+
message = JSON.stringify(points);
33+
points = [];
34+
Clear();
35+
}
1236
$("#post_msg").val('');
1337
if (!(message && message.trim() !== '')) {
1438
return false;
1539
}
1640
KChatAjax();
1741
}
42+
43+
$("#WhiteBoardSend").on( "click", function () {
44+
WhiteBoard = true;
45+
post_msg();
46+
WhiteBoard = false;
47+
});
1848

1949
$("#post_msg_btn").on( "click", function () {
2050
post_msg();
@@ -23,14 +53,14 @@ $(document).ready (function(){
2353
$("#post_msg").keyup(function() {
2454
typing = true;
2555
});
26-
27-
$("#post_msg").keypress(function(event){
28-
var keycode = (event.keyCode ? event.keyCode : event.which);
29-
if(keycode == '13'){
30-
post_msg();
31-
}
32-
});
33-
56+
57+
$("#Messages").on("click", ".show_whiteboard", function(){
58+
Clear();
59+
points = jQuery.parseJSON($("<div/>").html(atob($(this).attr("data-msg"))).text());
60+
points.forEach(draw);
61+
$('#whiteboard').modal('show');
62+
});
63+
3464
function UpdateConversations(json){
3565

3666
if(json['chats'] != undefined){
@@ -66,6 +96,23 @@ $(document).ready (function(){
6696
</a>
6797
</li>
6898
`);
99+
if(element.type == 1){
100+
Conversation = $(`
101+
<li class="bounceInDown" id="conversation${ element.id }" >
102+
<a href="/messages/?chat=${ element.conversation_id }" class="clearfix">
103+
<img src="${ element.photo }" alt="" class="img-circle">
104+
<div class="friend-name">
105+
<strong>${ element.conversation_name }<!--i class="mdi mdi-star favorite"></i--></strong>
106+
</div>
107+
<div class="last-message text-muted"><strong>${ element.first_name } ${ element.last_name } : </strong><i class="fa fa-pencil-square-o fa" aria-hidden="true"></i></div>
108+
<small class="time text-muted timestamp"> ${ element.date } </small>
109+
<small class="chat-alert text-muted">
110+
<!-- i class="fa fa-check"></i-->
111+
</small>
112+
</a>
113+
</li>
114+
`);
115+
}
69116

70117
$('#MessageBox').prepend(Conversation);
71118

@@ -95,6 +142,18 @@ $(document).ready (function(){
95142
<div class="message other-message float-right"> ${ element.message } </div>
96143
</li>
97144
`);
145+
if(element.type == 1){
146+
element.message = btoa(element.message);
147+
messages = $(`
148+
<li class="clearfix" id="msg${ element.id }" >
149+
<div class="message-data text-right">
150+
<span class="message-data-time"><strong>${ element.first_name } ${ element.last_name }</strong>${ element.created_at }</span>
151+
<img src="${ element.photo }" alt="avatar">
152+
</div>
153+
<div class="float-right show_whiteboard" data-msg="${ element.message }" ><i class="fa fa-pencil-square-o fa-2x" aria-hidden="true"></i></div>
154+
</li>
155+
`);
156+
}
98157
}else{
99158
messages = $(`
100159
<li class="clearfix" id="msg${ element.id }" >
@@ -105,6 +164,18 @@ $(document).ready (function(){
105164
<div class="message other-message float-left"> ${ element.message } </div>
106165
</li>
107166
`);
167+
if(element.type == 1){
168+
element.message = btoa(element.message);
169+
messages = $(`
170+
<li class="clearfix" id="msg${ element.id }" >
171+
<div class="message-data text-left">
172+
<span class="message-data-time"><strong>${ element.first_name } ${ element.last_name }</strong>${ element.created_at }</span>
173+
<img src="${ element.photo }" alt="avatar">
174+
</div>
175+
<div class="float-left show_whiteboard" data-msg="${ element.message }" ><i class="fa fa-pencil-square-o fa-2x" aria-hidden="true"></i></div>
176+
</li>
177+
`);
178+
}
108179
}
109180

110181
if(json.previous){
@@ -158,6 +229,10 @@ $(document).ready (function(){
158229
typing = false;
159230
}
160231

232+
if(WhiteBoard){
233+
Data['whiteboard'] = true;
234+
}
235+
161236
if(previous){
162237
Data['previous'] = true;
163238
previous = false;
@@ -194,8 +269,6 @@ $(document).ready (function(){
194269
}
195270
});
196271
}
197-
198-
199272
}
200273

201274
// Define the initial interval time (in milliseconds)

0 commit comments

Comments
 (0)