WP Live Chat Support - Version 2.10

Version Description

  • Included a .PO file for internationalization
Download this release

Release Info

Developer WP-LiveChat
Plugin Icon 128x128 WP Live Chat Support
Version 2.10
Comparing to
See all releases

Code changes from version 2.9 to 2.10

css/wplcstyle.css CHANGED
@@ -1,68 +1,68 @@
1
- #wp-live-chat input[type="button"] { width: auto }
2
- #wp-live-chat input[type="text"] { width:150px; border:1px solid #CCC; }
3
- #wp-live-chat textarea { width:145px; height:40px; border:1px solid #CCC; }
4
- #wplc_chatbox {
5
- border: 1px solid #CCC;
6
- overflow: auto;
7
- padding:5px;
8
- height:200px;
9
- overflow:auto;
10
- width:230px;
11
- margin-left:5px;
12
- }
13
- #wp-live-chat td { padding:5px; padding-left:10px; }
14
- #wp-live-chat table { border: 0 !important; }
15
- #wp-live-chat table td { border: 0 !important; }
16
- #wp-live-chat h4 { font-size:20px; margin:3px; }
17
- #wp-live-chat p { font-size:14px; margin:3px; }
18
- #wp-live-chat #wplc-sb { font-size:14px; font-weight:bold; }
19
- #wp-live-chat-4 { padding-top:8px; }
20
- #wp-live-chat {
21
- box-shadow: 5px 5px 5px #888;
22
- border:2px solid #888;
23
- position:fixed;
24
- bottom:0px;
25
- z-index:105;
26
- display:block;
27
- background: #fff;
28
- width:250px;
29
-
30
- }
31
- #wp-live-chat-1 {
32
- background: #73BE28;
33
- cursor: pointer;
34
- padding:5px;
35
- padding-left:20px;
36
- padding-right:20px;
37
- font-size:14px;
38
-
39
- color:#FFF;
40
- }
41
- #wp-live-chat-minimize { position:absolute; right:23px; top:15px; width:10px; cursor: pointer; height:3px; background:#FFF; }
42
- #wp-live-chat-close { position:absolute; right:5px; top:4px; width:10px; cursor: pointer; font-weight:bold; }
43
- #wp-live-chat-2-info {
44
- font-size:11px;
45
- display:block;
46
- width:212px;
47
- margin-left:auto;
48
- margin-right:auto;
49
- margin-top:10px;
50
- overflow:auto;
51
- border:1px solid #ccc;
52
- padding:2px;
53
- }
54
- #wp-live-chat-2-img {
55
- float:left;
56
- padding:5px;
57
- }
58
- #wplc_chatmsg {
59
- width:215px !important;
60
- margin-left:10px;
61
- border:1px solid #9D9D9D;
62
-
63
- }
64
- .wplc_offline {
65
- font-size:12px;
66
- font-weight:bold;
67
- }
68
  .wplc_logo_class { max-width: 220px; }
1
+ #wp-live-chat input[type="button"] { width: auto }
2
+ #wp-live-chat input[type="text"] { width:150px; border:1px solid #CCC; }
3
+ #wp-live-chat textarea { width:145px; height:40px; border:1px solid #CCC; }
4
+ #wplc_chatbox {
5
+ border: 1px solid #CCC;
6
+ overflow: auto;
7
+ padding:5px;
8
+ height:200px;
9
+ overflow:auto;
10
+ width:230px;
11
+ margin-left:5px;
12
+ }
13
+ #wp-live-chat td { padding:5px; padding-left:10px; }
14
+ #wp-live-chat table { border: 0 !important; }
15
+ #wp-live-chat table td { border: 0 !important; }
16
+ #wp-live-chat h4 { font-size:20px; margin:3px; }
17
+ #wp-live-chat p { font-size:14px; margin:3px; }
18
+ #wp-live-chat #wplc-sb { font-size:14px; font-weight:bold; }
19
+ #wp-live-chat-4 { padding-top:8px; }
20
+ #wp-live-chat {
21
+ box-shadow: 5px 5px 5px #888;
22
+ border:2px solid #888;
23
+ position:fixed;
24
+ bottom:0px;
25
+ z-index:105;
26
+ display:block;
27
+ background: #fff;
28
+ width:250px;
29
+
30
+ }
31
+ #wp-live-chat-1 {
32
+ background: #73BE28;
33
+ cursor: pointer;
34
+ padding:5px;
35
+ padding-left:20px;
36
+ padding-right:20px;
37
+ font-size:14px;
38
+
39
+ color:#FFF;
40
+ }
41
+ #wp-live-chat-minimize { position:absolute; right:23px; top:15px; width:10px; cursor: pointer; height:3px; background:#FFF; }
42
+ #wp-live-chat-close { position:absolute; right:5px; top:4px; width:10px; cursor: pointer; font-weight:bold; }
43
+ #wp-live-chat-2-info {
44
+ font-size:11px;
45
+ display:block;
46
+ width:212px;
47
+ margin-left:auto;
48
+ margin-right:auto;
49
+ margin-top:10px;
50
+ overflow:auto;
51
+ border:1px solid #ccc;
52
+ padding:2px;
53
+ }
54
+ #wp-live-chat-2-img {
55
+ float:left;
56
+ padding:5px;
57
+ }
58
+ #wplc_chatmsg {
59
+ width:215px !important;
60
+ margin-left:10px;
61
+ border:1px solid #9D9D9D;
62
+
63
+ }
64
+ .wplc_offline {
65
+ font-size:12px;
66
+ font-weight:bold;
67
+ }
68
  .wplc_logo_class { max-width: 220px; }
functions.php CHANGED
@@ -1,467 +1,467 @@
1
- <?php
2
-
3
- function wplc_log_user_on_page($name,$email) {
4
- global $wpdb;
5
- global $wplc_tblname_chats;
6
-
7
- $ins_array = array(
8
- 'status' => '5',
9
- 'timestamp' => date("Y-m-d H:i:s"),
10
- 'name' => $name,
11
- 'email' => $email,
12
- 'ip' => $_SERVER['REMOTE_ADDR'],
13
- 'url' => $_SERVER['HTTP_REFERER'],
14
- 'last_active_timestamp' => date("Y-m-d H:i:s")
15
- );
16
-
17
- $rows_affected = $wpdb->insert( $wplc_tblname_chats, $ins_array );
18
-
19
- $lastid = $wpdb->insert_id;
20
-
21
-
22
- return $lastid;
23
-
24
- }
25
- function wplc_update_user_on_page($cid) {
26
- global $wpdb;
27
- global $wplc_tblname_chats;
28
-
29
- $query =
30
- "
31
- UPDATE $wplc_tblname_chats
32
- SET
33
- `url` = '".$_SERVER['HTTP_REFERER']."',
34
- `last_active_timestamp` = '".date("Y-m-d H:i:s")."',
35
- `ip` = '".$_SERVER['REMOTE_ADDR']."',
36
- `status` = '5'
37
-
38
- WHERE `id` = '$cid'
39
- LIMIT 1
40
- ";
41
- $results = $wpdb->query($query);
42
- return $query;
43
-
44
-
45
-
46
- }
47
-
48
-
49
-
50
- function wplc_record_chat_msg($from,$cid,$msg) {
51
- global $wpdb;
52
- global $wplc_tblname_msgs;
53
-
54
- if ($from == "1") {
55
- $fromname = wplc_return_chat_name($cid);
56
- $orig = '2';
57
- }
58
- else {
59
- $fromname = "admin";
60
- $orig = '1';
61
- }
62
-
63
- $ins_array = array(
64
- 'chat_sess_id' => $cid,
65
- 'timestamp' => date("Y-m-d H:i:s"),
66
- 'from' => $fromname,
67
- 'msg' => $msg,
68
- 'status' => 0,
69
- 'originates' => $orig
70
- );
71
- $rows_affected = $wpdb->insert( $wplc_tblname_msgs, $ins_array );
72
-
73
- wplc_update_active_timestamp($cid);
74
- wplc_change_chat_status($cid,3);
75
- return true;
76
-
77
-
78
- }
79
-
80
- function wplc_update_active_timestamp($cid) {
81
- global $wpdb;
82
- global $wplc_tblname_chats;
83
- $results = $wpdb->get_results(
84
- "
85
- UPDATE $wplc_tblname_chats
86
- SET `last_active_timestamp` = '".date("Y-m-d H:i:s")."'
87
- WHERE `id` = '$cid'
88
- LIMIT 1
89
- "
90
- );
91
- wplc_change_chat_status($cid,3);
92
- return true;
93
-
94
- }
95
-
96
- function wplc_return_chat_name($cid) {
97
- global $wpdb;
98
- global $wplc_tblname_chats;
99
- $results = $wpdb->get_results(
100
- "
101
- SELECT *
102
- FROM $wplc_tblname_chats
103
- WHERE `id` = '$cid'
104
- "
105
- );
106
- foreach ($results as $result) {
107
- return $result->name;
108
- }
109
-
110
- }
111
- function wplc_list_chats() {
112
-
113
- global $wpdb;
114
- global $wplc_tblname_chats;
115
-
116
- $results = $wpdb->get_results(
117
- "
118
- SELECT *
119
- FROM $wplc_tblname_chats
120
- WHERE `status` = 3 OR `status` = 2
121
- ORDER BY `timestamp` ASC
122
-
123
- "
124
- );
125
- echo "
126
-
127
-
128
- <table class=\"wp-list-table widefat fixed \" cellspacing=\"0\">
129
- <thead>
130
- <tr>
131
- <th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>".__("IP","wplivechat")."</span></th>
132
- <th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>".__("Name","wplivechat")."</span></th>
133
- <th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">".__("Email","wplivechat")."</th>
134
- <th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">".__("URL","wplivechat")."</th>
135
- <th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">".__("Status","wplivechat")."</th>
136
- <th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>".__("Action","wplivechat")."</span></th>
137
- </tr>
138
- </thead>
139
- <tbody id=\"the-list\" class='list:wp_list_text_link'>
140
- ";
141
-
142
- if (!$results) {
143
- echo "<tr><td></td><td>".__("No chat sessions available at the moment","wplivechat")."</td></tr>";
144
- }
145
- else {
146
- foreach ($results as $result) {
147
- unset($trstyle);
148
- unset($actions);
149
- $wplc_c++;
150
-
151
- if ($result->status == 2) {
152
- $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
153
- $actions = "<a href=\"#\" onclick=\"window.open('$url', 'mywindow".$result->id."', 'location=no,status=1,scrollbars=1,width=500,height=650');return false;\">Accept Chat</a>";
154
- $trstyle = "style='background-color:#FFFBE4; height:30px;'";
155
- }
156
- if ($result->status == 3) {
157
- $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
158
- $actions = "<a href=\"#\" onclick=\"window.open('$url', 'mywindow".$result->id."', 'location=no,status=1,scrollbars=1,width=500,height=650');return false;\">Open Chat Window</a>";
159
- $trstyle = "style='background-color:#F7FCFE; height:30px;'";
160
- }
161
-
162
-
163
- echo "<tr id=\"record_".$result->id."\" $trstyle>";
164
- echo "<td class='chat_id column-chat_d'>".$result->ip."</td>";
165
- echo "<td class='chat_name column_chat_name' id='chat_name_".$result->id."'><img src=\"http://www.gravatar.com/avatar/".md5($result->email)."?s=40\" /> ".$result->name."</td>";
166
- echo "<td class='chat_email column_chat_email' id='chat_email_".$result->id."'>".$result->email."</td>";
167
- echo "<td class='chat_name column_chat_url' id='chat_url_".$result->id."'>".$result->url."</td>";
168
- echo "<td class='chat_status column_chat_status' id='chat_status_".$result->id."'><strong>".wplc_return_status($result->status)."</strong></td>";if ($wplc_c>1) { $actions = wplc_get_msg(); }
169
- echo "<td class='chat_action column-chat_action' id='chat_action_".$result->id."'>$actions</td>";
170
- echo "</tr>";
171
-
172
- }
173
- }
174
- echo "</table><br /><br />";
175
-
176
-
177
- }
178
-
179
-
180
-
181
-
182
- function wplc_return_user_chat_messages($cid) {
183
- global $wpdb;
184
- global $wplc_tblname_msgs;
185
- $results = $wpdb->get_results(
186
- "
187
- SELECT *
188
- FROM $wplc_tblname_msgs
189
- WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '1'
190
- ORDER BY `timestamp` ASC
191
-
192
- "
193
- );
194
- $msg_hist = "";
195
- foreach ($results as $result) {
196
- $id = $result->id;
197
- $from = $result->from;
198
-
199
- $msg = stripslashes($result->msg);
200
- //$timestamp = strtotime($result->timestamp);
201
- //$timeshow = date("H:i",$timestamp);
202
- $msg_hist .= "<strong>$from</strong>: $msg<br />";
203
-
204
- }
205
-
206
- return $msg_hist;
207
-
208
-
209
- }
210
-
211
-
212
- function wplc_change_chat_status($id,$status) {
213
- global $wpdb;
214
- global $wplc_tblname_chats;
215
- $results = $wpdb->get_results(
216
- "
217
- UPDATE $wplc_tblname_chats
218
- SET `status` = '$status'
219
- WHERE `id` = '$id'
220
- LIMIT 1
221
- "
222
- );
223
- return true;
224
-
225
- }
226
-
227
-
228
- function wplc_return_chat_messages($cid) {
229
- global $wpdb;
230
- global $wplc_tblname_msgs;
231
- $results = $wpdb->get_results(
232
- "
233
- SELECT *
234
- FROM $wplc_tblname_msgs
235
- WHERE `chat_sess_id` = '$cid'
236
- ORDER BY `timestamp` ASC
237
- LIMIT 0, 100
238
- "
239
- );
240
- foreach ($results as $result) {
241
- $from = $result->from;
242
- $msg = $result->msg;
243
- $timestamp = strtotime($result->timestamp);
244
- $timeshow = date("H:i:s",$timestamp);
245
- $msg_hist .= "<strong>$from</strong>: $msg<br />";
246
-
247
- }
248
- return $msg_hist;
249
-
250
-
251
- }
252
-
253
-
254
- function wplc_mark_as_read_user_chat_messages($cid) {
255
- global $wpdb;
256
- global $wplc_tblname_msgs;
257
- $results = $wpdb->get_results(
258
- "
259
- SELECT *
260
- FROM $wplc_tblname_msgs
261
- WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '1'
262
- ORDER BY `timestamp` DESC
263
-
264
- "
265
- );
266
-
267
-
268
- foreach ($results as $result) {
269
- $id = $result->id;
270
- $check = $wpdb->query(
271
- "
272
- UPDATE $wplc_tblname_msgs
273
- SET `status` = 1
274
- WHERE `id` = '$id'
275
- LIMIT 1
276
-
277
- "
278
- );
279
- }
280
- return "ok";
281
-
282
-
283
- }
284
-
285
- function wplc_return_admin_chat_messages($cid) {
286
- global $wpdb;
287
- global $wplc_tblname_msgs;
288
- $results = $wpdb->get_results(
289
- "
290
- SELECT *
291
- FROM $wplc_tblname_msgs
292
- WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '2'
293
- ORDER BY `timestamp` ASC
294
-
295
- "
296
- );
297
- $msg_hist = "";
298
- foreach ($results as $result) {
299
- $id = $result->id;
300
- $from = $result->from;
301
-
302
- $msg = stripslashes($result->msg);
303
- //$timestamp = strtotime($result->timestamp);
304
- //$timeshow = date("H:i",$timestamp);
305
- $msg_hist .= "<strong>$from</strong>: $msg<br />";
306
-
307
- }
308
-
309
- return $msg_hist;
310
-
311
-
312
- }
313
- function wplc_mark_as_read_admin_chat_messages($cid) {
314
- global $wpdb;
315
- global $wplc_tblname_msgs;
316
- $results = $wpdb->get_results(
317
- "
318
- SELECT *
319
- FROM $wplc_tblname_msgs
320
- WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '2'
321
- ORDER BY `timestamp` DESC
322
-
323
- "
324
- );
325
-
326
-
327
- foreach ($results as $result) {
328
- $id = $result->id;
329
- $check = $wpdb->query(
330
- "
331
- UPDATE $wplc_tblname_msgs
332
- SET `status` = 1
333
- WHERE `id` = '$id'
334
- LIMIT 1
335
-
336
- "
337
- );
338
- }
339
- return "ok";
340
-
341
-
342
- }
343
-
344
-
345
-
346
-
347
-
348
-
349
-
350
- function wplc_return_chat_status($cid) {
351
- global $wpdb;
352
- global $wplc_tblname_chats;
353
- $results = $wpdb->get_results(
354
- "
355
- SELECT *
356
- FROM $wplc_tblname_chats
357
- WHERE `id` = '$cid'
358
- "
359
- );
360
- foreach ($results as $result) {
361
- return $result->status;
362
- }
363
- }
364
-
365
-
366
- function wplc_return_status($status) {
367
- if ($status == 1) {
368
- return "complete";
369
- }
370
- if ($status == 2) {
371
- return "pending";
372
- }
373
- if ($status == 3) {
374
- return "active";
375
- }
376
- if ($status == 4) {
377
- return "deleted";
378
- }
379
- if ($status == 5) {
380
- return "browsing";
381
- }
382
- if ($status == 6) {
383
- return "requesting chat";
384
- }
385
- }
386
-
387
-
388
- function wplc_user_initiate_chat($name,$email,$cid = null) {
389
- global $wpdb;
390
- global $wplc_tblname_chats;
391
-
392
- if (function_exists("wplc_list_chats_pro")) { /* check if functions-pro is around */
393
- wplc_pro_notify_via_email();
394
- }
395
-
396
- if ($cid != null) { /* change from a visitor to a chat */
397
- $query =
398
- "
399
- UPDATE $wplc_tblname_chats
400
- SET
401
- `status` = '2',
402
- `timestamp` = '".date("Y-m-d H:i:s")."',
403
- `name` = '$name',
404
- `email` = '$email',
405
- `ip` = '".$_SERVER['REMOTE_ADDR']."',
406
- `url` = '".$_SERVER['HTTP_REFERER']."',
407
- `last_active_timestamp` = '".date("Y-m-d H:i:s")."'
408
-
409
- WHERE `id` = '$cid'
410
- LIMIT 1
411
- ";
412
- $results = $wpdb->query($query);
413
- return $cid;
414
- }
415
- else { // create new ID for the chat
416
- $ins_array = array(
417
- 'status' => '2',
418
- 'timestamp' => date("Y-m-d H:i:s"),
419
- 'name' => $name,
420
- 'email' => $email,
421
- 'ip' => $_SERVER['REMOTE_ADDR'],
422
- 'url' => $_SERVER['HTTP_REFERER'],
423
- 'last_active_timestamp' => date("Y-m-d H:i:s")
424
- );
425
- $rows_affected = $wpdb->insert( $wplc_tblname_chats, $ins_array );
426
- $lastid = $wpdb->insert_id;
427
- return $lastid;
428
- }
429
-
430
- }
431
-
432
-
433
-
434
- function wplc_get_msg() {
435
- return "<a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=morechats\" title=\"".__("Get Pro Add-on to accept more chats","wplivechat")."\" target=\"_BLANK\">Get Pro Add-on to accept more chats</a>";
436
- }
437
- function wplc_update_chat_statuses() {
438
-
439
- global $wpdb;
440
- global $wplc_tblname_chats;
441
- $results = $wpdb->get_results(
442
- "
443
- SELECT *
444
- FROM $wplc_tblname_chats
445
- WHERE `status` = '2' OR `status` = '3' OR `status` = '5'
446
- "
447
- );
448
- foreach ($results as $result) {
449
- $id = $result->id;
450
- $timestamp = strtotime($result->last_active_timestamp);
451
- if ($result->status == 2) {
452
- if ((time() - $timestamp) >= 60) { // 1 minute max
453
- wplc_change_chat_status($id,0);
454
- }
455
- }
456
- else if ($result->status == 3) {
457
- if ((time() - $timestamp) >= 600) { // 10 minute max
458
- wplc_change_chat_status($id,1);
459
- }
460
- }
461
- else if ($result->status == 5) {
462
- if ((time() - $timestamp) >= 120) { // 2 minute timeout
463
- wplc_change_chat_status($id,7); // 7 - timedout
464
- }
465
- }
466
- }
467
- }
1
+ <?php
2
+
3
+ function wplc_log_user_on_page($name,$email) {
4
+ global $wpdb;
5
+ global $wplc_tblname_chats;
6
+
7
+ $ins_array = array(
8
+ 'status' => '5',
9
+ 'timestamp' => date("Y-m-d H:i:s"),
10
+ 'name' => $name,
11
+ 'email' => $email,
12
+ 'ip' => $_SERVER['REMOTE_ADDR'],
13
+ 'url' => $_SERVER['HTTP_REFERER'],
14
+ 'last_active_timestamp' => date("Y-m-d H:i:s")
15
+ );
16
+
17
+ $rows_affected = $wpdb->insert( $wplc_tblname_chats, $ins_array );
18
+
19
+ $lastid = $wpdb->insert_id;
20
+
21
+
22
+ return $lastid;
23
+
24
+ }
25
+ function wplc_update_user_on_page($cid) {
26
+ global $wpdb;
27
+ global $wplc_tblname_chats;
28
+
29
+ $query =
30
+ "
31
+ UPDATE $wplc_tblname_chats
32
+ SET
33
+ `url` = '".$_SERVER['HTTP_REFERER']."',
34
+ `last_active_timestamp` = '".date("Y-m-d H:i:s")."',
35
+ `ip` = '".$_SERVER['REMOTE_ADDR']."',
36
+ `status` = '5'
37
+
38
+ WHERE `id` = '$cid'
39
+ LIMIT 1
40
+ ";
41
+ $results = $wpdb->query($query);
42
+ return $query;
43
+
44
+
45
+
46
+ }
47
+
48
+
49
+
50
+ function wplc_record_chat_msg($from,$cid,$msg) {
51
+ global $wpdb;
52
+ global $wplc_tblname_msgs;
53
+
54
+ if ($from == "1") {
55
+ $fromname = wplc_return_chat_name($cid);
56
+ $orig = '2';
57
+ }
58
+ else {
59
+ $fromname = "admin";
60
+ $orig = '1';
61
+ }
62
+
63
+ $ins_array = array(
64
+ 'chat_sess_id' => $cid,
65
+ 'timestamp' => date("Y-m-d H:i:s"),
66
+ 'from' => $fromname,
67
+ 'msg' => $msg,
68
+ 'status' => 0,
69
+ 'originates' => $orig
70
+ );
71
+ $rows_affected = $wpdb->insert( $wplc_tblname_msgs, $ins_array );
72
+
73
+ wplc_update_active_timestamp($cid);
74
+ wplc_change_chat_status($cid,3);
75
+ return true;
76
+
77
+
78
+ }
79
+
80
+ function wplc_update_active_timestamp($cid) {
81
+ global $wpdb;
82
+ global $wplc_tblname_chats;
83
+ $results = $wpdb->get_results(
84
+ "
85
+ UPDATE $wplc_tblname_chats
86
+ SET `last_active_timestamp` = '".date("Y-m-d H:i:s")."'
87
+ WHERE `id` = '$cid'
88
+ LIMIT 1
89
+ "
90
+ );
91
+ wplc_change_chat_status($cid,3);
92
+ return true;
93
+
94
+ }
95
+
96
+ function wplc_return_chat_name($cid) {
97
+ global $wpdb;
98
+ global $wplc_tblname_chats;
99
+ $results = $wpdb->get_results(
100
+ "
101
+ SELECT *
102
+ FROM $wplc_tblname_chats
103
+ WHERE `id` = '$cid'
104
+ "
105
+ );
106
+ foreach ($results as $result) {
107
+ return $result->name;
108
+ }
109
+
110
+ }
111
+ function wplc_list_chats() {
112
+
113
+ global $wpdb;
114
+ global $wplc_tblname_chats;
115
+
116
+ $results = $wpdb->get_results(
117
+ "
118
+ SELECT *
119
+ FROM $wplc_tblname_chats
120
+ WHERE `status` = 3 OR `status` = 2
121
+ ORDER BY `timestamp` ASC
122
+
123
+ "
124
+ );
125
+ echo "
126
+
127
+
128
+ <table class=\"wp-list-table widefat fixed \" cellspacing=\"0\">
129
+ <thead>
130
+ <tr>
131
+ <th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>".__("IP","wplivechat")."</span></th>
132
+ <th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>".__("Name","wplivechat")."</span></th>
133
+ <th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">".__("Email","wplivechat")."</th>
134
+ <th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">".__("URL","wplivechat")."</th>
135
+ <th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">".__("Status","wplivechat")."</th>
136
+ <th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>".__("Action","wplivechat")."</span></th>
137
+ </tr>
138
+ </thead>
139
+ <tbody id=\"the-list\" class='list:wp_list_text_link'>
140
+ ";
141
+
142
+ if (!$results) {
143
+ echo "<tr><td></td><td>".__("No chat sessions available at the moment","wplivechat")."</td></tr>";
144
+ }
145
+ else {
146
+ foreach ($results as $result) {
147
+ unset($trstyle);
148
+ unset($actions);
149
+ $wplc_c++;
150
+
151
+ if ($result->status == 2) {
152
+ $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
153
+ $actions = "<a href=\"#\" onclick=\"window.open('$url', 'mywindow".$result->id."', 'location=no,status=1,scrollbars=1,width=500,height=650');return false;\">Accept Chat</a>";
154
+ $trstyle = "style='background-color:#FFFBE4; height:30px;'";
155
+ }
156
+ if ($result->status == 3) {
157
+ $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
158
+ $actions = "<a href=\"#\" onclick=\"window.open('$url', 'mywindow".$result->id."', 'location=no,status=1,scrollbars=1,width=500,height=650');return false;\">Open Chat Window</a>";
159
+ $trstyle = "style='background-color:#F7FCFE; height:30px;'";
160
+ }
161
+
162
+
163
+ echo "<tr id=\"record_".$result->id."\" $trstyle>";
164
+ echo "<td class='chat_id column-chat_d'>".$result->ip."</td>";
165
+ echo "<td class='chat_name column_chat_name' id='chat_name_".$result->id."'><img src=\"http://www.gravatar.com/avatar/".md5($result->email)."?s=40\" /> ".$result->name."</td>";
166
+ echo "<td class='chat_email column_chat_email' id='chat_email_".$result->id."'>".$result->email."</td>";
167
+ echo "<td class='chat_name column_chat_url' id='chat_url_".$result->id."'>".$result->url."</td>";
168
+ echo "<td class='chat_status column_chat_status' id='chat_status_".$result->id."'><strong>".wplc_return_status($result->status)."</strong></td>";if ($wplc_c>1) { $actions = wplc_get_msg(); }
169
+ echo "<td class='chat_action column-chat_action' id='chat_action_".$result->id."'>$actions</td>";
170
+ echo "</tr>";
171
+
172
+ }
173
+ }
174
+ echo "</table><br /><br />";
175
+
176
+
177
+ }
178
+
179
+
180
+
181
+
182
+ function wplc_return_user_chat_messages($cid) {
183
+ global $wpdb;
184
+ global $wplc_tblname_msgs;
185
+ $results = $wpdb->get_results(
186
+ "
187
+ SELECT *
188
+ FROM $wplc_tblname_msgs
189
+ WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '1'
190
+ ORDER BY `timestamp` ASC
191
+
192
+ "
193
+ );
194
+ $msg_hist = "";
195
+ foreach ($results as $result) {
196
+ $id = $result->id;
197
+ $from = $result->from;
198
+
199
+ $msg = stripslashes($result->msg);
200
+ //$timestamp = strtotime($result->timestamp);
201
+ //$timeshow = date("H:i",$timestamp);
202
+ $msg_hist .= "<strong>$from</strong>: $msg<br />";
203
+
204
+ }
205
+
206
+ return $msg_hist;
207
+
208
+
209
+ }
210
+
211
+
212
+ function wplc_change_chat_status($id,$status) {
213
+ global $wpdb;
214
+ global $wplc_tblname_chats;
215
+ $results = $wpdb->get_results(
216
+ "
217
+ UPDATE $wplc_tblname_chats
218
+ SET `status` = '$status'
219
+ WHERE `id` = '$id'
220
+ LIMIT 1
221
+ "
222
+ );
223
+ return true;
224
+
225
+ }
226
+
227
+
228
+ function wplc_return_chat_messages($cid) {
229
+ global $wpdb;
230
+ global $wplc_tblname_msgs;
231
+ $results = $wpdb->get_results(
232
+ "
233
+ SELECT *
234
+ FROM $wplc_tblname_msgs
235
+ WHERE `chat_sess_id` = '$cid'
236
+ ORDER BY `timestamp` ASC
237
+ LIMIT 0, 100
238
+ "
239
+ );
240
+ foreach ($results as $result) {
241
+ $from = $result->from;
242
+ $msg = $result->msg;
243
+ $timestamp = strtotime($result->timestamp);
244
+ $timeshow = date("H:i:s",$timestamp);
245
+ $msg_hist .= "<strong>$from</strong>: $msg<br />";
246
+
247
+ }
248
+ return $msg_hist;
249
+
250
+
251
+ }
252
+
253
+
254
+ function wplc_mark_as_read_user_chat_messages($cid) {
255
+ global $wpdb;
256
+ global $wplc_tblname_msgs;
257
+ $results = $wpdb->get_results(
258
+ "
259
+ SELECT *
260
+ FROM $wplc_tblname_msgs
261
+ WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '1'
262
+ ORDER BY `timestamp` DESC
263
+
264
+ "
265
+ );
266
+
267
+
268
+ foreach ($results as $result) {
269
+ $id = $result->id;
270
+ $check = $wpdb->query(
271
+ "
272
+ UPDATE $wplc_tblname_msgs
273
+ SET `status` = 1
274
+ WHERE `id` = '$id'
275
+ LIMIT 1
276
+
277
+ "
278
+ );
279
+ }
280
+ return "ok";
281
+
282
+
283
+ }
284
+
285
+ function wplc_return_admin_chat_messages($cid) {
286
+ global $wpdb;
287
+ global $wplc_tblname_msgs;
288
+ $results = $wpdb->get_results(
289
+ "
290
+ SELECT *
291
+ FROM $wplc_tblname_msgs
292
+ WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '2'
293
+ ORDER BY `timestamp` ASC
294
+
295
+ "
296
+ );
297
+ $msg_hist = "";
298
+ foreach ($results as $result) {
299
+ $id = $result->id;
300
+ $from = $result->from;
301
+
302
+ $msg = stripslashes($result->msg);
303
+ //$timestamp = strtotime($result->timestamp);
304
+ //$timeshow = date("H:i",$timestamp);
305
+ $msg_hist .= "<strong>$from</strong>: $msg<br />";
306
+
307
+ }
308
+
309
+ return $msg_hist;
310
+
311
+
312
+ }
313
+ function wplc_mark_as_read_admin_chat_messages($cid) {
314
+ global $wpdb;
315
+ global $wplc_tblname_msgs;
316
+ $results = $wpdb->get_results(
317
+ "
318
+ SELECT *
319
+ FROM $wplc_tblname_msgs
320
+ WHERE `chat_sess_id` = '$cid' AND `status` = '0' AND `originates` = '2'
321
+ ORDER BY `timestamp` DESC
322
+
323
+ "
324
+ );
325
+
326
+
327
+ foreach ($results as $result) {
328
+ $id = $result->id;
329
+ $check = $wpdb->query(
330
+ "
331
+ UPDATE $wplc_tblname_msgs
332
+ SET `status` = 1
333
+ WHERE `id` = '$id'
334
+ LIMIT 1
335
+
336
+ "
337
+ );
338
+ }
339
+ return "ok";
340
+
341
+
342
+ }
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+ function wplc_return_chat_status($cid) {
351
+ global $wpdb;
352
+ global $wplc_tblname_chats;
353
+ $results = $wpdb->get_results(
354
+ "
355
+ SELECT *
356
+ FROM $wplc_tblname_chats
357
+ WHERE `id` = '$cid'
358
+ "
359
+ );
360
+ foreach ($results as $result) {
361
+ return $result->status;
362
+ }
363
+ }
364
+
365
+
366
+ function wplc_return_status($status) {
367
+ if ($status == 1) {
368
+ return "complete";
369
+ }
370
+ if ($status == 2) {
371
+ return "pending";
372
+ }
373
+ if ($status == 3) {
374
+ return "active";
375
+ }
376
+ if ($status == 4) {
377
+ return "deleted";
378
+ }
379
+ if ($status == 5) {
380
+ return "browsing";
381
+ }
382
+ if ($status == 6) {
383
+ return "requesting chat";
384
+ }
385
+ }
386
+
387
+
388
+ function wplc_user_initiate_chat($name,$email,$cid = null) {
389
+ global $wpdb;
390
+ global $wplc_tblname_chats;
391
+
392
+ if (function_exists("wplc_list_chats_pro")) { /* check if functions-pro is around */
393
+ wplc_pro_notify_via_email();
394
+ }
395
+
396
+ if ($cid != null) { /* change from a visitor to a chat */
397
+ $query =
398
+ "
399
+ UPDATE $wplc_tblname_chats
400
+ SET
401
+ `status` = '2',
402
+ `timestamp` = '".date("Y-m-d H:i:s")."',
403
+ `name` = '$name',
404
+ `email` = '$email',
405
+ `ip` = '".$_SERVER['REMOTE_ADDR']."',
406
+ `url` = '".$_SERVER['HTTP_REFERER']."',
407
+ `last_active_timestamp` = '".date("Y-m-d H:i:s")."'
408
+
409
+ WHERE `id` = '$cid'
410
+ LIMIT 1
411
+ ";
412
+ $results = $wpdb->query($query);
413
+ return $cid;
414
+ }
415
+ else { // create new ID for the chat
416
+ $ins_array = array(
417
+ 'status' => '2',
418
+ 'timestamp' => date("Y-m-d H:i:s"),
419
+ 'name' => $name,
420
+ 'email' => $email,
421
+ 'ip' => $_SERVER['REMOTE_ADDR'],
422
+ 'url' => $_SERVER['HTTP_REFERER'],
423
+ 'last_active_timestamp' => date("Y-m-d H:i:s")
424
+ );
425
+ $rows_affected = $wpdb->insert( $wplc_tblname_chats, $ins_array );
426
+ $lastid = $wpdb->insert_id;
427
+ return $lastid;
428
+ }
429
+
430
+ }
431
+
432
+
433
+
434
+ function wplc_get_msg() {
435
+ return "<a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=morechats\" title=\"".__("Get Pro Add-on to accept more chats","wplivechat")."\" target=\"_BLANK\">Get Pro Add-on to accept more chats</a>";
436
+ }
437
+ function wplc_update_chat_statuses() {
438
+
439
+ global $wpdb;
440
+ global $wplc_tblname_chats;
441
+ $results = $wpdb->get_results(
442
+ "
443
+ SELECT *
444
+ FROM $wplc_tblname_chats
445
+ WHERE `status` = '2' OR `status` = '3' OR `status` = '5'
446
+ "
447
+ );
448
+ foreach ($results as $result) {
449
+ $id = $result->id;
450
+ $timestamp = strtotime($result->last_active_timestamp);
451
+ if ($result->status == 2) {
452
+ if ((time() - $timestamp) >= 60) { // 1 minute max
453
+ wplc_change_chat_status($id,0);
454
+ }
455
+ }
456
+ else if ($result->status == 3) {
457
+ if ((time() - $timestamp) >= 600) { // 10 minute max
458
+ wplc_change_chat_status($id,1);
459
+ }
460
+ }
461
+ else if ($result->status == 5) {
462
+ if ((time() - $timestamp) >= 120) { // 2 minute timeout
463
+ wplc_change_chat_status($id,7); // 7 - timedout
464
+ }
465
+ }
466
+ }
467
+ }
js/jquery-cookie.js CHANGED
@@ -1,72 +1,72 @@
1
- /*!
2
- * jQuery Cookie Plugin v1.3
3
- * https://github.com/carhartl/jquery-cookie
4
- *
5
- * Copyright 2011, Klaus Hartl
6
- * Dual licensed under the MIT or GPL Version 2 licenses.
7
- * http://www.opensource.org/licenses/mit-license.php
8
- * http://www.opensource.org/licenses/GPL-2.0
9
- */
10
- (function ($, document, undefined) {
11
-
12
- var pluses = /\+/g;
13
-
14
- function raw(s) {
15
- return s;
16
- }
17
-
18
- function decoded(s) {
19
- return decodeURIComponent(s.replace(pluses, ' '));
20
- }
21
-
22
- var config = $.cookie = function (key, value, options) {
23
-
24
- // write
25
- if (value !== undefined) {
26
- options = $.extend({}, config.defaults, options);
27
-
28
- if (value === null) {
29
- options.expires = -1;
30
- }
31
-
32
- if (typeof options.expires === 'number') {
33
- var days = options.expires, t = options.expires = new Date();
34
- t.setDate(t.getDate() + days);
35
- }
36
-
37
- value = config.json ? JSON.stringify(value) : String(value);
38
-
39
- return (document.cookie = [
40
- encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
41
- options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
42
- options.path ? '; path=' + options.path : '',
43
- options.domain ? '; domain=' + options.domain : '',
44
- options.secure ? '; secure' : ''
45
- ].join(''));
46
- }
47
-
48
- // read
49
- var decode = config.raw ? raw : decoded;
50
- var cookies = document.cookie.split('; ');
51
- for (var i = 0, l = cookies.length; i < l; i++) {
52
- var parts = cookies[i].split('=');
53
- if (decode(parts.shift()) === key) {
54
- var cookie = decode(parts.join('='));
55
- return config.json ? JSON.parse(cookie) : cookie;
56
- }
57
- }
58
-
59
- return null;
60
- };
61
-
62
- config.defaults = {};
63
-
64
- $.removeCookie = function (key, options) {
65
- if ($.cookie(key) !== null) {
66
- $.cookie(key, null, options);
67
- return true;
68
- }
69
- return false;
70
- };
71
-
72
  })(jQuery, document);
1
+ /*!
2
+ * jQuery Cookie Plugin v1.3
3
+ * https://github.com/carhartl/jquery-cookie
4
+ *
5
+ * Copyright 2011, Klaus Hartl
6
+ * Dual licensed under the MIT or GPL Version 2 licenses.
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.opensource.org/licenses/GPL-2.0
9
+ */
10
+ (function ($, document, undefined) {
11
+
12
+ var pluses = /\+/g;
13
+
14
+ function raw(s) {
15
+ return s;
16
+ }
17
+
18
+ function decoded(s) {
19
+ return decodeURIComponent(s.replace(pluses, ' '));
20
+ }
21
+
22
+ var config = $.cookie = function (key, value, options) {
23
+
24
+ // write
25
+ if (value !== undefined) {
26
+ options = $.extend({}, config.defaults, options);
27
+
28
+ if (value === null) {
29
+ options.expires = -1;
30
+ }
31
+
32
+ if (typeof options.expires === 'number') {
33
+ var days = options.expires, t = options.expires = new Date();
34
+ t.setDate(t.getDate() + days);
35
+ }
36
+
37
+ value = config.json ? JSON.stringify(value) : String(value);
38
+
39
+ return (document.cookie = [
40
+ encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
41
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
42
+ options.path ? '; path=' + options.path : '',
43
+ options.domain ? '; domain=' + options.domain : '',
44
+ options.secure ? '; secure' : ''
45
+ ].join(''));
46
+ }
47
+
48
+ // read
49
+ var decode = config.raw ? raw : decoded;
50
+ var cookies = document.cookie.split('; ');
51
+ for (var i = 0, l = cookies.length; i < l; i++) {
52
+ var parts = cookies[i].split('=');
53
+ if (decode(parts.shift()) === key) {
54
+ var cookie = decode(parts.join('='));
55
+ return config.json ? JSON.parse(cookie) : cookie;
56
+ }
57
+ }
58
+
59
+ return null;
60
+ };
61
+
62
+ config.defaults = {};
63
+
64
+ $.removeCookie = function (key, options) {
65
+ if ($.cookie(key) !== null) {
66
+ $.cookie(key, null, options);
67
+ return true;
68
+ }
69
+ return false;
70
+ };
71
+
72
  })(jQuery, document);
js/jscolor.js CHANGED
@@ -1,995 +1,995 @@
1
- /**
2
- * jscolor, JavaScript Color Picker
3
- *
4
- * @version 1.4.1
5
- * @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html
6
- * @author Jan Odvarko, http://odvarko.cz
7
- * @created 2008-06-15
8
- * @updated 2013-04-08
9
- * @link http://jscolor.com
10
- */
11
-
12
-
13
- var jscolor = {
14
-
15
-
16
- dir : '', // location of jscolor directory (leave empty to autodetect)
17
- bindClass : 'color', // class name
18
- binding : true, // automatic binding via <input class="...">
19
- preloading : true, // use image preloading?
20
-
21
-
22
- install : function() {
23
- jscolor.addEvent(window, 'load', jscolor.init);
24
- },
25
-
26
-
27
- init : function() {
28
- if(jscolor.binding) {
29
- jscolor.bind();
30
- }
31
- if(jscolor.preloading) {
32
- jscolor.preload();
33
- }
34
- },
35
-
36
-
37
- getDir : function() {
38
- if(!jscolor.dir) {
39
- var detected = jscolor.detectDir();
40
- jscolor.dir = detected!==false ? detected : 'jscolor/';
41
- }
42
- return jscolor.dir;
43
- },
44
-
45
-
46
- detectDir : function() {
47
- var base = location.href;
48
-
49
- var e = document.getElementsByTagName('base');
50
- for(var i=0; i<e.length; i+=1) {
51
- if(e[i].href) { base = e[i].href; }
52
- }
53
-
54
- var e = document.getElementsByTagName('script');
55
- for(var i=0; i<e.length; i+=1) {
56
- if(e[i].src && /(^|\/)jscolor\.js([?#].*)?$/i.test(e[i].src)) {
57
- var src = new jscolor.URI(e[i].src);
58
- var srcAbs = src.toAbsolute(base);
59
- srcAbs.path = srcAbs.path.replace(/[^\/]+$/, ''); // remove filename
60
- srcAbs.query = null;
61
- srcAbs.fragment = null;
62
- return srcAbs.toString();
63
- }
64
- }
65
- return false;
66
- },
67
-
68
-
69
- bind : function() {
70
- var matchClass = new RegExp('(^|\\s)('+jscolor.bindClass+')\\s*(\\{[^}]*\\})?', 'i');
71
- var e = document.getElementsByTagName('input');
72
- for(var i=0; i<e.length; i+=1) {
73
- var m;
74
- if(!e[i].color && e[i].className && (m = e[i].className.match(matchClass))) {
75
- var prop = {};
76
- if(m[3]) {
77
- try {
78
- prop = (new Function ('return (' + m[3] + ')'))();
79
- } catch(eInvalidProp) {}
80
- }
81
- e[i].color = new jscolor.color(e[i], prop);
82
- }
83
- }
84
- },
85
-
86
-
87
- preload : function() {
88
- for(var fn in jscolor.imgRequire) {
89
- if(jscolor.imgRequire.hasOwnProperty(fn)) {
90
- jscolor.loadImage(fn);
91
- }
92
- }
93
- },
94
-
95
-
96
- images : {
97
- pad : [ 181, 101 ],
98
- sld : [ 16, 101 ],
99
- cross : [ 15, 15 ],
100
- arrow : [ 7, 11 ]
101
- },
102
-
103
-
104
- imgRequire : {},
105
- imgLoaded : {},
106
-
107
-
108
- requireImage : function(filename) {
109
- jscolor.imgRequire[filename] = true;
110
- },
111
-
112
-
113
- loadImage : function(filename) {
114
- if(!jscolor.imgLoaded[filename]) {
115
- jscolor.imgLoaded[filename] = new Image();
116
- jscolor.imgLoaded[filename].src = jscolor.getDir()+filename;
117
- }
118
- },
119
-
120
-
121
- fetchElement : function(mixed) {
122
- return typeof mixed === 'string' ? document.getElementById(mixed) : mixed;
123
- },
124
-
125
-
126
- addEvent : function(el, evnt, func) {
127
- if(el.addEventListener) {
128
- el.addEventListener(evnt, func, false);
129
- } else if(el.attachEvent) {
130
- el.attachEvent('on'+evnt, func);
131
- }
132
- },
133
-
134
-
135
- fireEvent : function(el, evnt) {
136
- if(!el) {
137
- return;
138
- }
139
- if(document.createEvent) {
140
- var ev = document.createEvent('HTMLEvents');
141
- ev.initEvent(evnt, true, true);
142
- el.dispatchEvent(ev);
143
- } else if(document.createEventObject) {
144
- var ev = document.createEventObject();
145
- el.fireEvent('on'+evnt, ev);
146
- } else if(el['on'+evnt]) { // alternatively use the traditional event model (IE5)
147
- el['on'+evnt]();
148
- }
149
- },
150
-
151
-
152
- getElementPos : function(e) {
153
- var e1=e, e2=e;
154
- var x=0, y=0;
155
- if(e1.offsetParent) {
156
- do {
157
- x += e1.offsetLeft;
158
- y += e1.offsetTop;
159
- } while(e1 = e1.offsetParent);
160
- }
161
- while((e2 = e2.parentNode) && e2.nodeName.toUpperCase() !== 'BODY') {
162
- x -= e2.scrollLeft;
163
- y -= e2.scrollTop;
164
- }
165
- return [x, y];
166
- },
167
-
168
-
169
- getElementSize : function(e) {
170
- return [e.offsetWidth, e.offsetHeight];
171
- },
172
-
173
-
174
- getRelMousePos : function(e) {
175
- var x = 0, y = 0;
176
- if (!e) { e = window.event; }
177
- if (typeof e.offsetX === 'number') {
178
- x = e.offsetX;
179
- y = e.offsetY;
180
- } else if (typeof e.layerX === 'number') {
181
- x = e.layerX;
182
- y = e.layerY;
183
- }
184
- return { x: x, y: y };
185
- },
186
-
187
-
188
- getViewPos : function() {
189
- if(typeof window.pageYOffset === 'number') {
190
- return [window.pageXOffset, window.pageYOffset];
191
- } else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
192
- return [document.body.scrollLeft, document.body.scrollTop];
193
- } else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
194
- return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
195
- } else {
196
- return [0, 0];
197
- }
198
- },
199
-
200
-
201
- getViewSize : function() {
202
- if(typeof window.innerWidth === 'number') {
203
- return [window.innerWidth, window.innerHeight];
204
- } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
205
- return [document.body.clientWidth, document.body.clientHeight];
206
- } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
207
- return [document.documentElement.clientWidth, document.documentElement.clientHeight];
208
- } else {
209
- return [0, 0];
210
- }
211
- },
212
-
213
-
214
- URI : function(uri) { // See RFC3986
215
-
216
- this.scheme = null;
217
- this.authority = null;
218
- this.path = '';
219
- this.query = null;
220
- this.fragment = null;
221
-
222
- this.parse = function(uri) {
223
- var m = uri.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/);
224
- this.scheme = m[3] ? m[2] : null;
225
- this.authority = m[5] ? m[6] : null;
226
- this.path = m[7];
227
- this.query = m[9] ? m[10] : null;
228
- this.fragment = m[12] ? m[13] : null;
229
- return this;
230
- };
231
-
232
- this.toString = function() {
233
- var result = '';
234
- if(this.scheme !== null) { result = result + this.scheme + ':'; }
235
- if(this.authority !== null) { result = result + '//' + this.authority; }
236
- if(this.path !== null) { result = result + this.path; }
237
- if(this.query !== null) { result = result + '?' + this.query; }
238
- if(this.fragment !== null) { result = result + '#' + this.fragment; }
239
- return result;
240
- };
241
-
242
- this.toAbsolute = function(base) {
243
- var base = new jscolor.URI(base);
244
- var r = this;
245
- var t = new jscolor.URI;
246
-
247
- if(base.scheme === null) { return false; }
248
-
249
- if(r.scheme !== null && r.scheme.toLowerCase() === base.scheme.toLowerCase()) {
250
- r.scheme = null;
251
- }
252
-
253
- if(r.scheme !== null) {
254
- t.scheme = r.scheme;
255
- t.authority = r.authority;
256
- t.path = removeDotSegments(r.path);
257
- t.query = r.query;
258
- } else {
259
- if(r.authority !== null) {
260
- t.authority = r.authority;
261
- t.path = removeDotSegments(r.path);
262
- t.query = r.query;
263
- } else {
264
- if(r.path === '') {
265
- t.path = base.path;
266
- if(r.query !== null) {
267
- t.query = r.query;
268
- } else {
269
- t.query = base.query;
270
- }
271
- } else {
272
- if(r.path.substr(0,1) === '/') {
273
- t.path = removeDotSegments(r.path);
274
- } else {
275
- if(base.authority !== null && base.path === '') {
276
- t.path = '/'+r.path;
277
- } else {
278
- t.path = base.path.replace(/[^\/]+$/,'')+r.path;
279
- }
280
- t.path = removeDotSegments(t.path);
281
- }
282
- t.query = r.query;
283
- }
284
- t.authority = base.authority;
285
- }
286
- t.scheme = base.scheme;
287
- }
288
- t.fragment = r.fragment;
289
-
290
- return t;
291
- };
292
-
293
- function removeDotSegments(path) {
294
- var out = '';
295
- while(path) {
296
- if(path.substr(0,3)==='../' || path.substr(0,2)==='./') {
297
- path = path.replace(/^\.+/,'').substr(1);
298
- } else if(path.substr(0,3)==='/./' || path==='/.') {
299
- path = '/'+path.substr(3);
300
- } else if(path.substr(0,4)==='/../' || path==='/..') {
301
- path = '/'+path.substr(4);
302
- out = out.replace(/\/?[^\/]*$/, '');
303
- } else if(path==='.' || path==='..') {
304
- path = '';
305
- } else {
306
- var rm = path.match(/^\/?[^\/]*/)[0];
307
- path = path.substr(rm.length);
308
- out = out + rm;
309
- }
310
- }
311
- return out;
312
- }
313
-
314
- if(uri) {
315
- this.parse(uri);
316
- }
317
-
318
- },
319
-
320
-
321
- //
322
- // Usage example:
323
- // var myColor = new jscolor.color(myInputElement)
324
- //
325
-
326
- color : function(target, prop) {
327
-
328
-
329
- this.required = true; // refuse empty values?
330
- this.adjust = true; // adjust value to uniform notation?
331
- this.hash = false; // prefix color with # symbol?
332
- this.caps = true; // uppercase?
333
- this.slider = true; // show the value/saturation slider?
334
- this.valueElement = target; // value holder
335
- this.styleElement = target; // where to reflect current color
336
- this.onImmediateChange = null; // onchange callback (can be either string or function)
337
- this.hsv = [0, 0, 1]; // read-only 0-6, 0-1, 0-1
338
- this.rgb = [1, 1, 1]; // read-only 0-1, 0-1, 0-1
339
- this.minH = 0; // read-only 0-6
340
- this.maxH = 6; // read-only 0-6
341
- this.minS = 0; // read-only 0-1
342
- this.maxS = 1; // read-only 0-1
343
- this.minV = 0; // read-only 0-1
344
- this.maxV = 1; // read-only 0-1
345
-
346
- this.pickerOnfocus = true; // display picker on focus?
347
- this.pickerMode = 'HSV'; // HSV | HVS
348
- this.pickerPosition = 'bottom'; // left | right | top | bottom
349
- this.pickerSmartPosition = true; // automatically adjust picker position when necessary
350
- this.pickerButtonHeight = 20; // px
351
- this.pickerClosable = false;
352
- this.pickerCloseText = 'Close';
353
- this.pickerButtonColor = 'ButtonText'; // px
354
- this.pickerFace = 10; // px
355
- this.pickerFaceColor = 'ThreeDFace'; // CSS color
356
- this.pickerBorder = 1; // px
357
- this.pickerBorderColor = 'ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight'; // CSS color
358
- this.pickerInset = 1; // px
359
- this.pickerInsetColor = 'ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow'; // CSS color
360
- this.pickerZIndex = 10000;
361
-
362
-
363
- for(var p in prop) {
364
- if(prop.hasOwnProperty(p)) {
365
- this[p] = prop[p];
366
- }
367
- }
368
-
369
-
370
- this.hidePicker = function() {
371
- if(isPickerOwner()) {
372
- removePicker();
373
- }
374
- };
375
-
376
-
377
- this.showPicker = function() {
378
- if(!isPickerOwner()) {
379
- var tp = jscolor.getElementPos(target); // target pos
380
- var ts = jscolor.getElementSize(target); // target size
381
- var vp = jscolor.getViewPos(); // view pos
382
- var vs = jscolor.getViewSize(); // view size
383
- var ps = getPickerDims(this); // picker size
384
- var a, b, c;
385
- switch(this.pickerPosition.toLowerCase()) {
386
- case 'left': a=1; b=0; c=-1; break;
387
- case 'right':a=1; b=0; c=1; break;
388
- case 'top': a=0; b=1; c=-1; break;
389
- default: a=0; b=1; c=1; break;
390
- }
391
- var l = (ts[b]+ps[b])/2;
392
-
393
- // picker pos
394
- if (!this.pickerSmartPosition) {
395
- var pp = [
396
- tp[a],
397
- tp[b]+ts[b]-l+l*c
398
- ];
399
- } else {
400
- var pp = [
401
- -vp[a]+tp[a]+ps[a] > vs[a] ?
402
- (-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) :
403
- tp[a],
404
- -vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ?
405
- (-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) :
406
- (tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c)
407
- ];
408
- }
409
- drawPicker(pp[a], pp[b]);
410
- }
411
- };
412
-
413
-
414
- this.importColor = function() {
415
- if(!valueElement) {
416
- this.exportColor();
417
- } else {
418
- if(!this.adjust) {
419
- if(!this.fromString(valueElement.value, leaveValue)) {
420
- styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
421
- styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
422
- styleElement.style.color = styleElement.jscStyle.color;
423
- this.exportColor(leaveValue | leaveStyle);
424
- }
425
- } else if(!this.required && /^\s*$/.test(valueElement.value)) {
426
- valueElement.value = '';
427
- styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
428
- styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
429
- styleElement.style.color = styleElement.jscStyle.color;
430
- this.exportColor(leaveValue | leaveStyle);
431
-
432
- } else if(this.fromString(valueElement.value)) {
433
- // OK
434
- } else {
435
- this.exportColor();
436
- }
437
- }
438
- };
439
-
440
-
441
- this.exportColor = function(flags) {
442
- if(!(flags & leaveValue) && valueElement) {
443
- var value = this.toString();
444
- if(this.caps) { value = value.toUpperCase(); }
445
- if(this.hash) { value = '#'+value; }
446
- valueElement.value = value;
447
- }
448
- if(!(flags & leaveStyle) && styleElement) {
449
- styleElement.style.backgroundImage = "none";
450
- styleElement.style.backgroundColor =
451
- '#'+this.toString();
452
- styleElement.style.color =
453
- 0.213 * this.rgb[0] +
454
- 0.715 * this.rgb[1] +
455
- 0.072 * this.rgb[2]
456
- < 0.5 ? '#FFF' : '#000';
457
- }
458
- if(!(flags & leavePad) && isPickerOwner()) {
459
- redrawPad();
460
- }
461
- if(!(flags & leaveSld) && isPickerOwner()) {
462
- redrawSld();
463
- }
464
- };
465
-
466
-
467
- this.fromHSV = function(h, s, v, flags) { // null = don't change
468
- if(h !== null) { h = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, h)); }
469
- if(s !== null) { s = Math.max(0.0, this.minS, Math.min(1.0, this.maxS, s)); }
470
- if(v !== null) { v = Math.max(0.0, this.minV, Math.min(1.0, this.maxV, v)); }
471
-
472
- this.rgb = HSV_RGB(
473
- h===null ? this.hsv[0] : (this.hsv[0]=h),
474
- s===null ? this.hsv[1] : (this.hsv[1]=s),
475
- v===null ? this.hsv[2] : (this.hsv[2]=v)
476
- );
477
-
478
- this.exportColor(flags);
479
- };
480
-
481
-
482
- this.fromRGB = function(r, g, b, flags) { // null = don't change
483
- if(r !== null) { r = Math.max(0.0, Math.min(1.0, r)); }
484
- if(g !== null) { g = Math.max(0.0, Math.min(1.0, g)); }
485
- if(b !== null) { b = Math.max(0.0, Math.min(1.0, b)); }
486
-
487
- var hsv = RGB_HSV(
488
- r===null ? this.rgb[0] : r,
489
- g===null ? this.rgb[1] : g,
490
- b===null ? this.rgb[2] : b
491
- );
492
- if(hsv[0] !== null) {
493
- this.hsv[0] = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, hsv[0]));
494
- }
495
- if(hsv[2] !== 0) {
496
- this.hsv[1] = hsv[1]===null ? null : Math.max(0.0, this.minS, Math.min(1.0, this.maxS, hsv[1]));
497
- }
498
- this.hsv[2] = hsv[2]===null ? null : Math.max(0.0, this.minV, Math.min(1.0, this.maxV, hsv[2]));
499
-
500
- // update RGB according to final HSV, as some values might be trimmed
501
- var rgb = HSV_RGB(this.hsv[0], this.hsv[1], this.hsv[2]);
502
- this.rgb[0] = rgb[0];
503
- this.rgb[1] = rgb[1];
504
- this.rgb[2] = rgb[2];
505
-
506
- this.exportColor(flags);
507
- };
508
-
509
-
510
- this.fromString = function(hex, flags) {
511
- var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);
512
- if(!m) {
513
- return false;
514
- } else {
515
- if(m[1].length === 6) { // 6-char notation
516
- this.fromRGB(
517
- parseInt(m[1].substr(0,2),16) / 255,
518
- parseInt(m[1].substr(2,2),16) / 255,
519
- parseInt(m[1].substr(4,2),16) / 255,
520
- flags
521
- );
522
- } else { // 3-char notation
523
- this.fromRGB(
524
- parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255,
525
- parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255,
526
- parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255,
527
- flags
528
- );
529
- }
530
- return true;
531
- }
532
- };
533
-
534
-
535
- this.toString = function() {
536
- return (
537
- (0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) +
538
- (0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) +
539
- (0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1)
540
- );
541
- };
542
-
543
-
544
- function RGB_HSV(r, g, b) {
545
- var n = Math.min(Math.min(r,g),b);
546
- var v = Math.max(Math.max(r,g),b);
547
- var m = v - n;
548
- if(m === 0) { return [ null, 0, v ]; }
549
- var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m);
550
- return [ h===6?0:h, m/v, v ];
551
- }
552
-
553
-
554
- function HSV_RGB(h, s, v) {
555
- if(h === null) { return [ v, v, v ]; }
556
- var i = Math.floor(h);
557
- var f = i%2 ? h-i : 1-(h-i);
558
- var m = v * (1 - s);
559
- var n = v * (1 - s*f);
560
- switch(i) {
561
- case 6:
562
- case 0: return [v,n,m];
563
- case 1: return [n,v,m];
564
- case 2: return [m,v,n];
565
- case 3: return [m,n,v];
566
- case 4: return [n,m,v];
567
- case 5: return [v,m,n];
568
- }
569
- }
570
-
571
-
572
- function removePicker() {
573
- delete jscolor.picker.owner;
574
- document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB);
575
- }
576
-
577
-
578
- function drawPicker(x, y) {
579
- if(!jscolor.picker) {
580
- jscolor.picker = {
581
- box : document.createElement('div'),
582
- boxB : document.createElement('div'),
583
- pad : document.createElement('div'),
584
- padB : document.createElement('div'),
585
- padM : document.createElement('div'),
586
- sld : document.createElement('div'),
587
- sldB : document.createElement('div'),
588
- sldM : document.createElement('div'),
589
- btn : document.createElement('div'),
590
- btnS : document.createElement('span'),
591
- btnT : document.createTextNode(THIS.pickerCloseText)
592
- };
593
- for(var i=0,segSize=4; i<jscolor.images.sld[1]; i+=segSize) {
594
- var seg = document.createElement('div');
595
- seg.style.height = segSize+'px';
596
- seg.style.fontSize = '1px';
597
- seg.style.lineHeight = '0';
598
- jscolor.picker.sld.appendChild(seg);
599
- }
600
- jscolor.picker.sldB.appendChild(jscolor.picker.sld);
601
- jscolor.picker.box.appendChild(jscolor.picker.sldB);
602
- jscolor.picker.box.appendChild(jscolor.picker.sldM);
603
- jscolor.picker.padB.appendChild(jscolor.picker.pad);
604
- jscolor.picker.box.appendChild(jscolor.picker.padB);
605
- jscolor.picker.box.appendChild(jscolor.picker.padM);
606
- jscolor.picker.btnS.appendChild(jscolor.picker.btnT);
607
- jscolor.picker.btn.appendChild(jscolor.picker.btnS);
608
- jscolor.picker.box.appendChild(jscolor.picker.btn);
609
- jscolor.picker.boxB.appendChild(jscolor.picker.box);
610
- }
611
-
612
- var p = jscolor.picker;
613
-
614
- // controls interaction
615
- p.box.onmouseup =
616
- p.box.onmouseout = function() { target.focus(); };
617
- p.box.onmousedown = function() { abortBlur=true; };
618
- p.box.onmousemove = function(e) {
619
- if (holdPad || holdSld) {
620
- holdPad && setPad(e);
621
- holdSld && setSld(e);
622
- if (document.selection) {
623
- document.selection.empty();
624
- } else if (window.getSelection) {
625
- window.getSelection().removeAllRanges();
626
- }
627
- dispatchImmediateChange();
628
- }
629
- };
630
- if('ontouchstart' in window) { // if touch device
631
- p.box.addEventListener('touchmove', function(e) {
632
- var event={
633
- 'offsetX': e.touches[0].pageX-touchOffset.X,
634
- 'offsetY': e.touches[0].pageY-touchOffset.Y
635
- };
636
- if (holdPad || holdSld) {
637
- holdPad && setPad(event);
638
- holdSld && setSld(event);
639
- dispatchImmediateChange();
640
- }
641
- e.stopPropagation(); // prevent move "view" on broswer
642
- e.preventDefault(); // prevent Default - Android Fix (else android generated only 1-2 touchmove events)
643
- }, false);
644
- }
645
- p.padM.onmouseup =
646
- p.padM.onmouseout = function() { if(holdPad) { holdPad=false; jscolor.fireEvent(valueElement,'change'); } };
647
- p.padM.onmousedown = function(e) {
648
- // if the slider is at the bottom, move it up
649
- switch(modeID) {
650
- case 0: if (THIS.hsv[2] === 0) { THIS.fromHSV(null, null, 1.0); }; break;
651
- case 1: if (THIS.hsv[1] === 0) { THIS.fromHSV(null, 1.0, null); }; break;
652
- }
653
- holdSld=false;
654
- holdPad=true;
655
- setPad(e);
656
- dispatchImmediateChange();
657
- };
658
- if('ontouchstart' in window) {
659
- p.padM.addEventListener('touchstart', function(e) {
660
- touchOffset={
661
- 'X': e.target.offsetParent.offsetLeft,
662
- 'Y': e.target.offsetParent.offsetTop
663
- };
664
- this.onmousedown({
665
- 'offsetX':e.touches[0].pageX-touchOffset.X,
666
- 'offsetY':e.touches[0].pageY-touchOffset.Y
667
- });
668
- });
669
- }
670
- p.sldM.onmouseup =
671
- p.sldM.onmouseout = function() { if(holdSld) { holdSld=false; jscolor.fireEvent(valueElement,'change'); } };
672
- p.sldM.onmousedown = function(e) {
673
- holdPad=false;
674
- holdSld=true;
675
- setSld(e);
676
- dispatchImmediateChange();
677
- };
678
- if('ontouchstart' in window) {
679
- p.sldM.addEventListener('touchstart', function(e) {
680
- touchOffset={
681
- 'X': e.target.offsetParent.offsetLeft,
682
- 'Y': e.target.offsetParent.offsetTop
683
- };
684
- this.onmousedown({
685
- 'offsetX':e.touches[0].pageX-touchOffset.X,
686
- 'offsetY':e.touches[0].pageY-touchOffset.Y
687
- });
688
- });
689
- }
690
-
691
- // picker
692
- var dims = getPickerDims(THIS);
693
- p.box.style.width = dims[0] + 'px';
694
- p.box.style.height = dims[1] + 'px';
695
-
696
- // picker border
697
- p.boxB.style.position = 'absolute';
698
- p.boxB.style.clear = 'both';
699
- p.boxB.style.left = x+'px';
700
- p.boxB.style.top = y+'px';
701
- p.boxB.style.zIndex = THIS.pickerZIndex;
702
- p.boxB.style.border = THIS.pickerBorder+'px solid';
703
- p.boxB.style.borderColor = THIS.pickerBorderColor;
704
- p.boxB.style.background = THIS.pickerFaceColor;
705
-
706
- // pad image
707
- p.pad.style.width = jscolor.images.pad[0]+'px';
708
- p.pad.style.height = jscolor.images.pad[1]+'px';
709
-
710
- // pad border
711
- p.padB.style.position = 'absolute';
712
- p.padB.style.left = THIS.pickerFace+'px';
713
- p.padB.style.top = THIS.pickerFace+'px';
714
- p.padB.style.border = THIS.pickerInset+'px solid';
715
- p.padB.style.borderColor = THIS.pickerInsetColor;
716
-
717
- // pad mouse area
718
- p.padM.style.position = 'absolute';
719
- p.padM.style.left = '0';
720
- p.padM.style.top = '0';
721
- p.padM.style.width = THIS.pickerFace + 2*THIS.pickerInset + jscolor.images.pad[0] + jscolor.images.arrow[0] + 'px';
722
- p.padM.style.height = p.box.style.height;
723
- p.padM.style.cursor = 'crosshair';
724
-
725
- // slider image
726
- p.sld.style.overflow = 'hidden';
727
- p.sld.style.width = jscolor.images.sld[0]+'px';
728
- p.sld.style.height = jscolor.images.sld[1]+'px';
729
-
730
- // slider border
731
- p.sldB.style.display = THIS.slider ? 'block' : 'none';
732
- p.sldB.style.position = 'absolute';
733
- p.sldB.style.right = THIS.pickerFace+'px';
734
- p.sldB.style.top = THIS.pickerFace+'px';
735
- p.sldB.style.border = THIS.pickerInset+'px solid';
736
- p.sldB.style.borderColor = THIS.pickerInsetColor;
737
-
738
- // slider mouse area
739
- p.sldM.style.display = THIS.slider ? 'block' : 'none';
740
- p.sldM.style.position = 'absolute';
741
- p.sldM.style.right = '0';
742
- p.sldM.style.top = '0';
743
- p.sldM.style.width = jscolor.images.sld[0] + jscolor.images.arrow[0] + THIS.pickerFace + 2*THIS.pickerInset + 'px';
744
- p.sldM.style.height = p.box.style.height;
745
- try {
746
- p.sldM.style.cursor = 'pointer';
747
- } catch(eOldIE) {
748
- p.sldM.style.cursor = 'hand';
749
- }
750
-
751
- // "close" button
752
- function setBtnBorder() {
753
- var insetColors = THIS.pickerInsetColor.split(/\s+/);
754
- var pickerOutsetColor = insetColors.length < 2 ? insetColors[0] : insetColors[1] + ' ' + insetColors[0] + ' ' + insetColors[0] + ' ' + insetColors[1];
755
- p.btn.style.borderColor = pickerOutsetColor;
756
- }
757
- p.btn.style.display = THIS.pickerClosable ? 'block' : 'none';
758
- p.btn.style.position = 'absolute';
759
- p.btn.style.left = THIS.pickerFace + 'px';
760
- p.btn.style.bottom = THIS.pickerFace + 'px';
761
- p.btn.style.padding = '0 15px';
762
- p.btn.style.height = '18px';
763
- p.btn.style.border = THIS.pickerInset + 'px solid';
764
- setBtnBorder();
765
- p.btn.style.color = THIS.pickerButtonColor;
766
- p.btn.style.font = '12px sans-serif';
767
- p.btn.style.textAlign = 'center';
768
- try {
769
- p.btn.style.cursor = 'pointer';
770
- } catch(eOldIE) {
771
- p.btn.style.cursor = 'hand';
772
- }
773
- p.btn.onmousedown = function () {
774
- THIS.hidePicker();
775
- };
776
- p.btnS.style.lineHeight = p.btn.style.height;
777
-
778
- // load images in optimal order
779
- switch(modeID) {
780
- case 0: var padImg = 'hs.png'; break;
781
- case 1: var padImg = 'hv.png'; break;
782
- }
783
- p.padM.style.backgroundImage = "url('"+jscolor.getDir()+"cross.gif')";
784
- p.padM.style.backgroundRepeat = "no-repeat";
785
- p.sldM.style.backgroundImage = "url('"+jscolor.getDir()+"arrow.gif')";
786
- p.sldM.style.backgroundRepeat = "no-repeat";
787
- p.pad.style.backgroundImage = "url('"+jscolor.getDir()+padImg+"')";
788
- p.pad.style.backgroundRepeat = "no-repeat";
789
- p.pad.style.backgroundPosition = "0 0";
790
-
791
- // place pointers
792
- redrawPad();
793
- redrawSld();
794
-
795
- jscolor.picker.owner = THIS;
796
- document.getElementsByTagName('body')[0].appendChild(p.boxB);
797
- }
798
-
799
-
800
- function getPickerDims(o) {
801
- var dims = [
802
- 2*o.pickerInset + 2*o.pickerFace + jscolor.images.pad[0] +
803
- (o.slider ? 2*o.pickerInset + 2*jscolor.images.arrow[0] + jscolor.images.sld[0] : 0),
804
- o.pickerClosable ?
805
- 4*o.pickerInset + 3*o.pickerFace + jscolor.images.pad[1] + o.pickerButtonHeight :
806
- 2*o.pickerInset + 2*o.pickerFace + jscolor.images.pad[1]
807
- ];
808
- return dims;
809
- }
810
-
811
-
812
- function redrawPad() {
813
- // redraw the pad pointer
814
- switch(modeID) {
815
- case 0: var yComponent = 1; break;
816
- case 1: var yComponent = 2; break;
817
- }
818
- var x = Math.round((THIS.hsv[0]/6) * (jscolor.images.pad[0]-1));
819
- var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.pad[1]-1));
820
- jscolor.picker.padM.style.backgroundPosition =
821
- (THIS.pickerFace+THIS.pickerInset+x - Math.floor(jscolor.images.cross[0]/2)) + 'px ' +
822
- (THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.cross[1]/2)) + 'px';
823
-
824
- // redraw the slider image
825
- var seg = jscolor.picker.sld.childNodes;
826
-
827
- switch(modeID) {
828
- case 0:
829
- var rgb = HSV_RGB(THIS.hsv[0], THIS.hsv[1], 1);
830
- for(var i=0; i<seg.length; i+=1) {
831
- seg[i].style.backgroundColor = 'rgb('+
832
- (rgb[0]*(1-i/seg.length)*100)+'%,'+
833
- (rgb[1]*(1-i/seg.length)*100)+'%,'+
834
- (rgb[2]*(1-i/seg.length)*100)+'%)';
835
- }
836
- break;
837
- case 1:
838
- var rgb, s, c = [ THIS.hsv[2], 0, 0 ];
839
- var i = Math.floor(THIS.hsv[0]);
840
- var f = i%2 ? THIS.hsv[0]-i : 1-(THIS.hsv[0]-i);
841
- switch(i) {
842
- case 6:
843
- case 0: rgb=[0,1,2]; break;
844
- case 1: rgb=[1,0,2]; break;
845
- case 2: rgb=[2,0,1]; break;
846
- case 3: rgb=[2,1,0]; break;
847
- case 4: rgb=[1,2,0]; break;
848
- case 5: rgb=[0,2,1]; break;
849
- }
850
- for(var i=0; i<seg.length; i+=1) {
851
- s = 1 - 1/(seg.length-1)*i;
852
- c[1] = c[0] * (1 - s*f);
853
- c[2] = c[0] * (1 - s);
854
- seg[i].style.backgroundColor = 'rgb('+
855
- (c[rgb[0]]*100)+'%,'+
856
- (c[rgb[1]]*100)+'%,'+
857
- (c[rgb[2]]*100)+'%)';
858
- }
859
- break;
860
- }
861
- }
862
-
863
-
864
- function redrawSld() {
865
- // redraw the slider pointer
866
- switch(modeID) {
867
- case 0: var yComponent = 2; break;
868
- case 1: var yComponent = 1; break;
869
- }
870
- var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.sld[1]-1));
871
- jscolor.picker.sldM.style.backgroundPosition =
872
- '0 ' + (THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.arrow[1]/2)) + 'px';
873
- }
874
-
875
-
876
- function isPickerOwner() {
877
- return jscolor.picker && jscolor.picker.owner === THIS;
878
- }
879
-
880
-
881
- function blurTarget() {
882
- if(valueElement === target) {
883
- THIS.importColor();
884
- }
885
- if(THIS.pickerOnfocus) {
886
- THIS.hidePicker();
887
- }
888
- }
889
-
890
-
891
- function blurValue() {
892
- if(valueElement !== target) {
893
- THIS.importColor();
894
- }
895
- }
896
-
897
-
898
- function setPad(e) {
899
- var mpos = jscolor.getRelMousePos(e);
900
- var x = mpos.x - THIS.pickerFace - THIS.pickerInset;
901
- var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
902
- switch(modeID) {
903
- case 0: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), 1 - y/(jscolor.images.pad[1]-1), null, leaveSld); break;
904
- case 1: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), null, 1 - y/(jscolor.images.pad[1]-1), leaveSld); break;
905
- }
906
- }
907
-
908
-
909
- function setSld(e) {
910
- var mpos = jscolor.getRelMousePos(e);
911
- var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
912
- switch(modeID) {
913
- case 0: THIS.fromHSV(null, null, 1 - y/(jscolor.images.sld[1]-1), leavePad); break;
914
- case 1: THIS.fromHSV(null, 1 - y/(jscolor.images.sld[1]-1), null, leavePad); break;
915
- }
916
- }
917
-
918
-
919
- function dispatchImmediateChange() {
920
- if (THIS.onImmediateChange) {
921
- var callback;
922
- if (typeof THIS.onImmediateChange === 'string') {
923
- callback = new Function (THIS.onImmediateChange);
924
- } else {
925
- callback = THIS.onImmediateChange;
926
- }
927
- callback.call(THIS);
928
- }
929
- }
930
-
931
-
932
- var THIS = this;
933
- var modeID = this.pickerMode.toLowerCase()==='hvs' ? 1 : 0;
934
- var abortBlur = false;
935
- var
936
- valueElement = jscolor.fetchElement(this.valueElement),
937
- styleElement = jscolor.fetchElement(this.styleElement);
938
- var
939
- holdPad = false,
940
- holdSld = false,
941
- touchOffset = {};
942
- var
943
- leaveValue = 1<<0,
944
- leaveStyle = 1<<1,
945
- leavePad = 1<<2,
946
- leaveSld = 1<<3;
947
-
948
- // target
949
- jscolor.addEvent(target, 'focus', function() {
950
- if(THIS.pickerOnfocus) { THIS.showPicker(); }
951
- });
952
- jscolor.addEvent(target, 'blur', function() {
953
- if(!abortBlur) {
954
- window.setTimeout(function(){ abortBlur || blurTarget(); abortBlur=false; }, 0);
955
- } else {
956
- abortBlur = false;
957
- }
958
- });
959
-
960
- // valueElement
961
- if(valueElement) {
962
- var updateField = function() {
963
- THIS.fromString(valueElement.value, leaveValue);
964
- dispatchImmediateChange();
965
- };
966
- jscolor.addEvent(valueElement, 'keyup', updateField);
967
- jscolor.addEvent(valueElement, 'input', updateField);
968
- jscolor.addEvent(valueElement, 'blur', blurValue);
969
- valueElement.setAttribute('autocomplete', 'off');
970
- }
971
-
972
- // styleElement
973
- if(styleElement) {
974
- styleElement.jscStyle = {
975
- backgroundImage : styleElement.style.backgroundImage,
976
- backgroundColor : styleElement.style.backgroundColor,
977
- color : styleElement.style.color
978
- };
979
- }
980
-
981
- // require images
982
- switch(modeID) {
983
- case 0: jscolor.requireImage('hs.png'); break;
984
- case 1: jscolor.requireImage('hv.png'); break;
985
- }
986
- jscolor.requireImage('cross.gif');
987
- jscolor.requireImage('arrow.gif');
988
-
989
- this.importColor();
990
- }
991
-
992
- };
993
-
994
-
995
- jscolor.install();
1
+ /**
2
+ * jscolor, JavaScript Color Picker
3
+ *
4
+ * @version 1.4.1
5
+ * @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html
6
+ * @author Jan Odvarko, http://odvarko.cz
7
+ * @created 2008-06-15
8
+ * @updated 2013-04-08
9
+ * @link http://jscolor.com
10
+ */
11
+
12
+
13
+ var jscolor = {
14
+
15
+
16
+ dir : '', // location of jscolor directory (leave empty to autodetect)
17
+ bindClass : 'color', // class name
18
+ binding : true, // automatic binding via <input class="...">
19
+ preloading : true, // use image preloading?
20
+
21
+
22
+ install : function() {
23
+ jscolor.addEvent(window, 'load', jscolor.init);
24
+ },
25
+
26
+
27
+ init : function() {
28
+ if(jscolor.binding) {
29
+ jscolor.bind();
30
+ }
31
+ if(jscolor.preloading) {
32
+ jscolor.preload();
33
+ }
34
+ },
35
+
36
+
37
+ getDir : function() {
38
+ if(!jscolor.dir) {
39
+ var detected = jscolor.detectDir();
40
+ jscolor.dir = detected!==false ? detected : 'jscolor/';
41
+ }
42
+ return jscolor.dir;
43
+ },
44
+
45
+
46
+ detectDir : function() {
47
+ var base = location.href;
48
+
49
+ var e = document.getElementsByTagName('base');
50
+ for(var i=0; i<e.length; i+=1) {
51
+ if(e[i].href) { base = e[i].href; }
52
+ }
53
+
54
+ var e = document.getElementsByTagName('script');
55
+ for(var i=0; i<e.length; i+=1) {
56
+ if(e[i].src && /(^|\/)jscolor\.js([?#].*)?$/i.test(e[i].src)) {
57
+ var src = new jscolor.URI(e[i].src);
58
+ var srcAbs = src.toAbsolute(base);
59
+ srcAbs.path = srcAbs.path.replace(/[^\/]+$/, ''); // remove filename
60
+ srcAbs.query = null;
61
+ srcAbs.fragment = null;
62
+ return srcAbs.toString();
63
+ }
64
+ }
65
+ return false;
66
+ },
67
+
68
+
69
+ bind : function() {
70
+ var matchClass = new RegExp('(^|\\s)('+jscolor.bindClass+')\\s*(\\{[^}]*\\})?', 'i');
71
+ var e = document.getElementsByTagName('input');
72
+ for(var i=0; i<e.length; i+=1) {
73
+ var m;
74
+ if(!e[i].color && e[i].className && (m = e[i].className.match(matchClass))) {
75
+ var prop = {};
76
+ if(m[3]) {
77
+ try {
78
+ prop = (new Function ('return (' + m[3] + ')'))();
79
+ } catch(eInvalidProp) {}
80
+ }
81
+ e[i].color = new jscolor.color(e[i], prop);
82
+ }
83
+ }
84
+ },
85
+
86
+
87
+ preload : function() {
88
+ for(var fn in jscolor.imgRequire) {
89
+ if(jscolor.imgRequire.hasOwnProperty(fn)) {
90
+ jscolor.loadImage(fn);
91
+ }
92
+ }
93
+ },
94
+
95
+
96
+ images : {
97
+ pad : [ 181, 101 ],
98
+ sld : [ 16, 101 ],
99
+ cross : [ 15, 15 ],
100
+ arrow : [ 7, 11 ]
101
+ },
102
+
103
+
104
+ imgRequire : {},
105
+ imgLoaded : {},
106
+
107
+
108
+ requireImage : function(filename) {
109
+ jscolor.imgRequire[filename] = true;
110
+ },
111
+
112
+
113
+ loadImage : function(filename) {
114
+ if(!jscolor.imgLoaded[filename]) {
115
+ jscolor.imgLoaded[filename] = new Image();
116
+ jscolor.imgLoaded[filename].src = jscolor.getDir()+filename;
117
+ }
118
+ },
119
+
120
+
121
+ fetchElement : function(mixed) {
122
+ return typeof mixed === 'string' ? document.getElementById(mixed) : mixed;
123
+ },
124
+
125
+
126
+ addEvent : function(el, evnt, func) {
127
+ if(el.addEventListener) {
128
+ el.addEventListener(evnt, func, false);
129
+ } else if(el.attachEvent) {
130
+ el.attachEvent('on'+evnt, func);
131
+ }
132
+ },
133
+
134
+
135
+ fireEvent : function(el, evnt) {
136
+ if(!el) {
137
+ return;
138
+ }
139
+ if(document.createEvent) {
140
+ var ev = document.createEvent('HTMLEvents');
141
+ ev.initEvent(evnt, true, true);
142
+ el.dispatchEvent(ev);
143
+ } else if(document.createEventObject) {
144
+ var ev = document.createEventObject();
145
+ el.fireEvent('on'+evnt, ev);
146
+ } else if(el['on'+evnt]) { // alternatively use the traditional event model (IE5)
147
+ el['on'+evnt]();
148
+ }
149
+ },
150
+
151
+
152
+ getElementPos : function(e) {
153
+ var e1=e, e2=e;
154
+ var x=0, y=0;
155
+ if(e1.offsetParent) {
156
+ do {
157
+ x += e1.offsetLeft;
158
+ y += e1.offsetTop;
159
+ } while(e1 = e1.offsetParent);
160
+ }
161
+ while((e2 = e2.parentNode) && e2.nodeName.toUpperCase() !== 'BODY') {
162
+ x -= e2.scrollLeft;
163
+ y -= e2.scrollTop;
164
+ }
165
+ return [x, y];
166
+ },
167
+
168
+
169
+ getElementSize : function(e) {
170
+ return [e.offsetWidth, e.offsetHeight];
171
+ },
172
+
173
+
174
+ getRelMousePos : function(e) {
175
+ var x = 0, y = 0;
176
+ if (!e) { e = window.event; }
177
+ if (typeof e.offsetX === 'number') {
178
+ x = e.offsetX;
179
+ y = e.offsetY;
180
+ } else if (typeof e.layerX === 'number') {
181
+ x = e.layerX;
182
+ y = e.layerY;
183
+ }
184
+ return { x: x, y: y };
185
+ },
186
+
187
+
188
+ getViewPos : function() {
189
+ if(typeof window.pageYOffset === 'number') {
190
+ return [window.pageXOffset, window.pageYOffset];
191
+ } else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
192
+ return [document.body.scrollLeft, document.body.scrollTop];
193
+ } else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
194
+ return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
195
+ } else {
196
+ return [0, 0];
197
+ }
198
+ },
199
+
200
+
201
+ getViewSize : function() {
202
+ if(typeof window.innerWidth === 'number') {
203
+ return [window.innerWidth, window.innerHeight];
204
+ } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
205
+ return [document.body.clientWidth, document.body.clientHeight];
206
+ } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
207
+ return [document.documentElement.clientWidth, document.documentElement.clientHeight];
208
+ } else {
209
+ return [0, 0];
210
+ }
211
+ },
212
+
213
+
214
+ URI : function(uri) { // See RFC3986
215
+
216
+ this.scheme = null;
217
+ this.authority = null;
218
+ this.path = '';
219
+ this.query = null;
220
+ this.fragment = null;
221
+
222
+ this.parse = function(uri) {
223
+ var m = uri.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/);
224
+ this.scheme = m[3] ? m[2] : null;
225
+ this.authority = m[5] ? m[6] : null;
226
+ this.path = m[7];
227
+ this.query = m[9] ? m[10] : null;
228
+ this.fragment = m[12] ? m[13] : null;
229
+ return this;
230
+ };
231
+
232
+ this.toString = function() {
233
+ var result = '';
234
+ if(this.scheme !== null) { result = result + this.scheme + ':'; }
235
+ if(this.authority !== null) { result = result + '//' + this.authority; }
236
+ if(this.path !== null) { result = result + this.path; }
237
+ if(this.query !== null) { result = result + '?' + this.query; }
238
+ if(this.fragment !== null) { result = result + '#' + this.fragment; }
239
+ return result;
240
+ };
241
+
242
+ this.toAbsolute = function(base) {
243
+ var base = new jscolor.URI(base);
244
+ var r = this;
245
+ var t = new jscolor.URI;
246
+
247
+ if(base.scheme === null) { return false; }
248
+
249
+ if(r.scheme !== null && r.scheme.toLowerCase() === base.scheme.toLowerCase()) {
250
+ r.scheme = null;
251
+ }
252
+
253
+ if(r.scheme !== null) {
254
+ t.scheme = r.scheme;
255
+ t.authority = r.authority;
256
+ t.path = removeDotSegments(r.path);
257
+ t.query = r.query;
258
+ } else {
259
+ if(r.authority !== null) {
260
+ t.authority = r.authority;
261
+ t.path = removeDotSegments(r.path);
262
+ t.query = r.query;
263
+ } else {
264
+ if(r.path === '') {
265
+ t.path = base.path;
266
+ if(r.query !== null) {
267
+ t.query = r.query;
268
+ } else {
269
+ t.query = base.query;
270
+ }
271
+ } else {
272
+ if(r.path.substr(0,1) === '/') {
273
+ t.path = removeDotSegments(r.path);
274
+ } else {
275
+ if(base.authority !== null && base.path === '') {
276
+ t.path = '/'+r.path;
277
+ } else {
278
+ t.path = base.path.replace(/[^\/]+$/,'')+r.path;
279
+ }
280
+ t.path = removeDotSegments(t.path);
281
+ }
282
+ t.query = r.query;
283
+ }
284
+ t.authority = base.authority;
285
+ }
286
+ t.scheme = base.scheme;
287
+ }
288
+ t.fragment = r.fragment;
289
+
290
+ return t;
291
+ };
292
+
293
+ function removeDotSegments(path) {
294
+ var out = '';
295
+ while(path) {
296
+ if(path.substr(0,3)==='../' || path.substr(0,2)==='./') {
297
+ path = path.replace(/^\.+/,'').substr(1);
298
+ } else if(path.substr(0,3)==='/./' || path==='/.') {
299
+ path = '/'+path.substr(3);
300
+ } else if(path.substr(0,4)==='/../' || path==='/..') {
301
+ path = '/'+path.substr(4);
302
+ out = out.replace(/\/?[^\/]*$/, '');
303
+ } else if(path==='.' || path==='..') {
304
+ path = '';
305
+ } else {
306
+ var rm = path.match(/^\/?[^\/]*/)[0];
307
+ path = path.substr(rm.length);
308
+ out = out + rm;
309
+ }
310
+ }
311
+ return out;
312
+ }
313
+
314
+ if(uri) {
315
+ this.parse(uri);
316
+ }
317
+
318
+ },
319
+
320
+
321
+ //
322
+ // Usage example:
323
+ // var myColor = new jscolor.color(myInputElement)
324
+ //
325
+
326
+ color : function(target, prop) {
327
+
328
+
329
+ this.required = true; // refuse empty values?
330
+ this.adjust = true; // adjust value to uniform notation?
331
+ this.hash = false; // prefix color with # symbol?
332
+ this.caps = true; // uppercase?
333
+ this.slider = true; // show the value/saturation slider?
334
+ this.valueElement = target; // value holder
335
+ this.styleElement = target; // where to reflect current color
336
+ this.onImmediateChange = null; // onchange callback (can be either string or function)
337
+ this.hsv = [0, 0, 1]; // read-only 0-6, 0-1, 0-1
338
+ this.rgb = [1, 1, 1]; // read-only 0-1, 0-1, 0-1
339
+ this.minH = 0; // read-only 0-6
340
+ this.maxH = 6; // read-only 0-6
341
+ this.minS = 0; // read-only 0-1
342
+ this.maxS = 1; // read-only 0-1
343
+ this.minV = 0; // read-only 0-1
344
+ this.maxV = 1; // read-only 0-1
345
+
346
+ this.pickerOnfocus = true; // display picker on focus?
347
+ this.pickerMode = 'HSV'; // HSV | HVS
348
+ this.pickerPosition = 'bottom'; // left | right | top | bottom
349
+ this.pickerSmartPosition = true; // automatically adjust picker position when necessary
350
+ this.pickerButtonHeight = 20; // px
351
+ this.pickerClosable = false;
352
+ this.pickerCloseText = 'Close';
353
+ this.pickerButtonColor = 'ButtonText'; // px
354
+ this.pickerFace = 10; // px
355
+ this.pickerFaceColor = 'ThreeDFace'; // CSS color
356
+ this.pickerBorder = 1; // px
357
+ this.pickerBorderColor = 'ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight'; // CSS color
358
+ this.pickerInset = 1; // px
359
+ this.pickerInsetColor = 'ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow'; // CSS color
360
+ this.pickerZIndex = 10000;
361
+
362
+
363
+ for(var p in prop) {
364
+ if(prop.hasOwnProperty(p)) {
365
+ this[p] = prop[p];
366
+ }
367
+ }
368
+
369
+
370
+ this.hidePicker = function() {
371
+ if(isPickerOwner()) {
372
+ removePicker();
373
+ }
374
+ };
375
+
376
+
377
+ this.showPicker = function() {
378
+ if(!isPickerOwner()) {
379
+ var tp = jscolor.getElementPos(target); // target pos
380
+ var ts = jscolor.getElementSize(target); // target size
381
+ var vp = jscolor.getViewPos(); // view pos
382
+ var vs = jscolor.getViewSize(); // view size
383
+ var ps = getPickerDims(this); // picker size
384
+ var a, b, c;
385
+ switch(this.pickerPosition.toLowerCase()) {
386
+ case 'left': a=1; b=0; c=-1; break;
387
+ case 'right':a=1; b=0; c=1; break;
388
+ case 'top': a=0; b=1; c=-1; break;
389
+ default: a=0; b=1; c=1; break;
390
+ }
391
+ var l = (ts[b]+ps[b])/2;
392
+
393
+ // picker pos
394
+ if (!this.pickerSmartPosition) {
395
+ var pp = [
396
+ tp[a],
397
+ tp[b]+ts[b]-l+l*c
398
+ ];
399
+ } else {
400
+ var pp = [
401
+ -vp[a]+tp[a]+ps[a] > vs[a] ?
402
+ (-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) :
403
+ tp[a],
404
+ -vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ?
405
+ (-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) :
406
+ (tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c)
407
+ ];
408
+ }
409
+ drawPicker(pp[a], pp[b]);
410
+ }
411
+ };
412
+
413
+
414
+ this.importColor = function() {
415
+ if(!valueElement) {
416
+ this.exportColor();
417
+ } else {
418
+ if(!this.adjust) {
419
+ if(!this.fromString(valueElement.value, leaveValue)) {
420
+ styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
421
+ styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
422
+ styleElement.style.color = styleElement.jscStyle.color;
423
+ this.exportColor(leaveValue | leaveStyle);
424
+ }
425
+ } else if(!this.required && /^\s*$/.test(valueElement.value)) {
426
+ valueElement.value = '';
427
+ styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
428
+ styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
429
+ styleElement.style.color = styleElement.jscStyle.color;
430
+ this.exportColor(leaveValue | leaveStyle);
431
+
432
+ } else if(this.fromString(valueElement.value)) {
433
+ // OK
434
+ } else {
435
+ this.exportColor();
436
+ }
437
+ }
438
+ };
439
+
440
+
441
+ this.exportColor = function(flags) {
442
+ if(!(flags & leaveValue) && valueElement) {
443
+ var value = this.toString();
444
+ if(this.caps) { value = value.toUpperCase(); }
445
+ if(this.hash) { value = '#'+value; }
446
+ valueElement.value = value;
447
+ }
448
+ if(!(flags & leaveStyle) && styleElement) {
449
+ styleElement.style.backgroundImage = "none";
450
+ styleElement.style.backgroundColor =
451
+ '#'+this.toString();
452
+ styleElement.style.color =
453
+ 0.213 * this.rgb[0] +
454
+ 0.715 * this.rgb[1] +
455
+ 0.072 * this.rgb[2]
456
+ < 0.5 ? '#FFF' : '#000';
457
+ }
458
+ if(!(flags & leavePad) && isPickerOwner()) {
459
+ redrawPad();
460
+ }
461
+ if(!(flags & leaveSld) && isPickerOwner()) {
462
+ redrawSld();
463
+ }
464
+ };
465
+
466
+
467
+ this.fromHSV = function(h, s, v, flags) { // null = don't change
468
+ if(h !== null) { h = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, h)); }
469
+ if(s !== null) { s = Math.max(0.0, this.minS, Math.min(1.0, this.maxS, s)); }
470
+ if(v !== null) { v = Math.max(0.0, this.minV, Math.min(1.0, this.maxV, v)); }
471
+
472
+ this.rgb = HSV_RGB(
473
+ h===null ? this.hsv[0] : (this.hsv[0]=h),
474
+ s===null ? this.hsv[1] : (this.hsv[1]=s),
475
+ v===null ? this.hsv[2] : (this.hsv[2]=v)
476
+ );
477
+
478
+ this.exportColor(flags);
479
+ };
480
+
481
+
482
+ this.fromRGB = function(r, g, b, flags) { // null = don't change
483
+ if(r !== null) { r = Math.max(0.0, Math.min(1.0, r)); }
484
+ if(g !== null) { g = Math.max(0.0, Math.min(1.0, g)); }
485
+ if(b !== null) { b = Math.max(0.0, Math.min(1.0, b)); }
486
+
487
+ var hsv = RGB_HSV(
488
+ r===null ? this.rgb[0] : r,
489
+ g===null ? this.rgb[1] : g,
490
+ b===null ? this.rgb[2] : b
491
+ );
492
+ if(hsv[0] !== null) {
493
+ this.hsv[0] = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, hsv[0]));
494
+ }
495
+ if(hsv[2] !== 0) {
496
+ this.hsv[1] = hsv[1]===null ? null : Math.max(0.0, this.minS, Math.min(1.0, this.maxS, hsv[1]));
497
+ }
498
+ this.hsv[2] = hsv[2]===null ? null : Math.max(0.0, this.minV, Math.min(1.0, this.maxV, hsv[2]));
499
+
500
+ // update RGB according to final HSV, as some values might be trimmed
501
+ var rgb = HSV_RGB(this.hsv[0], this.hsv[1], this.hsv[2]);
502
+ this.rgb[0] = rgb[0];
503
+ this.rgb[1] = rgb[1];
504
+ this.rgb[2] = rgb[2];
505
+
506
+ this.exportColor(flags);
507
+ };
508
+
509
+
510
+ this.fromString = function(hex, flags) {
511
+ var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);
512
+ if(!m) {
513
+ return false;
514
+ } else {
515
+ if(m[1].length === 6) { // 6-char notation
516
+ this.fromRGB(
517
+ parseInt(m[1].substr(0,2),16) / 255,
518
+ parseInt(m[1].substr(2,2),16) / 255,
519
+ parseInt(m[1].substr(4,2),16) / 255,
520
+ flags
521
+ );
522
+ } else { // 3-char notation
523
+ this.fromRGB(
524
+ parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255,
525
+ parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255,
526
+ parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255,
527
+ flags
528
+ );
529
+ }
530
+ return true;
531
+ }
532
+ };
533
+
534
+
535
+ this.toString = function() {
536
+ return (
537
+ (0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) +
538
+ (0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) +
539
+ (0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1)
540
+ );
541
+ };
542
+
543
+
544
+ function RGB_HSV(r, g, b) {
545
+ var n = Math.min(Math.min(r,g),b);
546
+ var v = Math.max(Math.max(r,g),b);
547
+ var m = v - n;
548
+ if(m === 0) { return [ null, 0, v ]; }
549
+ var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m);
550
+ return [ h===6?0:h, m/v, v ];
551
+ }
552
+
553
+
554
+ function HSV_RGB(h, s, v) {
555
+ if(h === null) { return [ v, v, v ]; }
556
+ var i = Math.floor(h);
557
+ var f = i%2 ? h-i : 1-(h-i);
558
+ var m = v * (1 - s);
559
+ var n = v * (1 - s*f);
560
+ switch(i) {
561
+ case 6:
562
+ case 0: return [v,n,m];
563
+ case 1: return [n,v,m];
564
+ case 2: return [m,v,n];
565
+ case 3: return [m,n,v];
566
+ case 4: return [n,m,v];
567
+ case 5: return [v,m,n];
568
+ }
569
+ }
570
+
571
+
572
+ function removePicker() {
573
+ delete jscolor.picker.owner;
574
+ document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB);
575
+ }
576
+
577
+
578
+ function drawPicker(x, y) {
579
+ if(!jscolor.picker) {
580
+ jscolor.picker = {
581
+ box : document.createElement('div'),
582
+ boxB : document.createElement('div'),
583
+ pad : document.createElement('div'),
584
+ padB : document.createElement('div'),
585
+ padM : document.createElement('div'),
586
+ sld : document.createElement('div'),
587
+ sldB : document.createElement('div'),
588
+ sldM : document.createElement('div'),
589
+ btn : document.createElement('div'),
590
+ btnS : document.createElement('span'),
591
+ btnT : document.createTextNode(THIS.pickerCloseText)
592
+ };
593
+ for(var i=0,segSize=4; i<jscolor.images.sld[1]; i+=segSize) {
594
+ var seg = document.createElement('div');
595
+ seg.style.height = segSize+'px';
596
+ seg.style.fontSize = '1px';
597
+ seg.style.lineHeight = '0';
598
+ jscolor.picker.sld.appendChild(seg);
599
+ }
600
+ jscolor.picker.sldB.appendChild(jscolor.picker.sld);
601
+ jscolor.picker.box.appendChild(jscolor.picker.sldB);
602
+ jscolor.picker.box.appendChild(jscolor.picker.sldM);
603
+ jscolor.picker.padB.appendChild(jscolor.picker.pad);
604
+ jscolor.picker.box.appendChild(jscolor.picker.padB);
605
+ jscolor.picker.box.appendChild(jscolor.picker.padM);
606
+ jscolor.picker.btnS.appendChild(jscolor.picker.btnT);
607
+ jscolor.picker.btn.appendChild(jscolor.picker.btnS);
608
+ jscolor.picker.box.appendChild(jscolor.picker.btn);
609
+ jscolor.picker.boxB.appendChild(jscolor.picker.box);
610
+ }
611
+
612
+ var p = jscolor.picker;
613
+
614
+ // controls interaction
615
+ p.box.onmouseup =
616
+ p.box.onmouseout = function() { target.focus(); };
617
+ p.box.onmousedown = function() { abortBlur=true; };
618
+ p.box.onmousemove = function(e) {
619
+ if (holdPad || holdSld) {
620
+ holdPad && setPad(e);
621
+ holdSld && setSld(e);
622
+ if (document.selection) {
623
+ document.selection.empty();
624
+ } else if (window.getSelection) {
625
+ window.getSelection().removeAllRanges();
626
+ }
627
+ dispatchImmediateChange();
628
+ }
629
+ };
630
+ if('ontouchstart' in window) { // if touch device
631
+ p.box.addEventListener('touchmove', function(e) {
632
+ var event={
633
+ 'offsetX': e.touches[0].pageX-touchOffset.X,
634
+ 'offsetY': e.touches[0].pageY-touchOffset.Y
635
+ };
636
+ if (holdPad || holdSld) {
637
+ holdPad && setPad(event);
638
+ holdSld && setSld(event);
639
+ dispatchImmediateChange();
640
+ }
641
+ e.stopPropagation(); // prevent move "view" on broswer
642
+ e.preventDefault(); // prevent Default - Android Fix (else android generated only 1-2 touchmove events)
643
+ }, false);
644
+ }
645
+ p.padM.onmouseup =
646
+ p.padM.onmouseout = function() { if(holdPad) { holdPad=false; jscolor.fireEvent(valueElement,'change'); } };
647
+ p.padM.onmousedown = function(e) {
648
+ // if the slider is at the bottom, move it up
649
+ switch(modeID) {
650
+ case 0: if (THIS.hsv[2] === 0) { THIS.fromHSV(null, null, 1.0); }; break;
651
+ case 1: if (THIS.hsv[1] === 0) { THIS.fromHSV(null, 1.0, null); }; break;
652
+ }
653
+ holdSld=false;
654
+ holdPad=true;
655
+ setPad(e);
656
+ dispatchImmediateChange();
657
+ };
658
+ if('ontouchstart' in window) {
659
+ p.padM.addEventListener('touchstart', function(e) {
660
+ touchOffset={
661
+ 'X': e.target.offsetParent.offsetLeft,
662
+ 'Y': e.target.offsetParent.offsetTop
663
+ };
664
+ this.onmousedown({
665
+ 'offsetX':e.touches[0].pageX-touchOffset.X,
666
+ 'offsetY':e.touches[0].pageY-touchOffset.Y
667
+ });
668
+ });
669
+ }
670
+ p.sldM.onmouseup =
671
+ p.sldM.onmouseout = function() { if(holdSld) { holdSld=false; jscolor.fireEvent(valueElement,'change'); } };
672
+ p.sldM.onmousedown = function(e) {
673
+ holdPad=false;
674
+ holdSld=true;
675
+ setSld(e);
676
+ dispatchImmediateChange();
677
+ };
678
+ if('ontouchstart' in window) {
679
+ p.sldM.addEventListener('touchstart', function(e) {
680
+ touchOffset={
681
+ 'X': e.target.offsetParent.offsetLeft,
682
+ 'Y': e.target.offsetParent.offsetTop
683
+ };
684
+ this.onmousedown({
685
+ 'offsetX':e.touches[0].pageX-touchOffset.X,
686
+ 'offsetY':e.touches[0].pageY-touchOffset.Y
687
+ });
688
+ });
689
+ }
690
+
691
+ // picker
692
+ var dims = getPickerDims(THIS);
693
+ p.box.style.width = dims[0] + 'px';
694
+ p.box.style.height = dims[1] + 'px';
695
+
696
+ // picker border
697
+ p.boxB.style.position = 'absolute';
698
+ p.boxB.style.clear = 'both';
699
+ p.boxB.style.left = x+'px';
700
+ p.boxB.style.top = y+'px';
701
+ p.boxB.style.zIndex = THIS.pickerZIndex;
702
+ p.boxB.style.border = THIS.pickerBorder+'px solid';
703
+ p.boxB.style.borderColor = THIS.pickerBorderColor;
704
+ p.boxB.style.background = THIS.pickerFaceColor;
705
+
706
+ // pad image
707
+ p.pad.style.width = jscolor.images.pad[0]+'px';
708
+ p.pad.style.height = jscolor.images.pad[1]+'px';
709
+
710
+ // pad border
711
+ p.padB.style.position = 'absolute';
712
+ p.padB.style.left = THIS.pickerFace+'px';
713
+ p.padB.style.top = THIS.pickerFace+'px';
714
+ p.padB.style.border = THIS.pickerInset+'px solid';
715
+ p.padB.style.borderColor = THIS.pickerInsetColor;
716
+
717
+ // pad mouse area
718
+ p.padM.style.position = 'absolute';
719
+ p.padM.style.left = '0';
720
+ p.padM.style.top = '0';
721
+ p.padM.style.width = THIS.pickerFace + 2*THIS.pickerInset + jscolor.images.pad[0] + jscolor.images.arrow[0] + 'px';
722
+ p.padM.style.height = p.box.style.height;
723
+ p.padM.style.cursor = 'crosshair';
724
+
725
+ // slider image
726
+ p.sld.style.overflow = 'hidden';
727
+ p.sld.style.width = jscolor.images.sld[0]+'px';
728
+ p.sld.style.height = jscolor.images.sld[1]+'px';
729
+
730
+ // slider border
731
+ p.sldB.style.display = THIS.slider ? 'block' : 'none';
732
+ p.sldB.style.position = 'absolute';
733
+ p.sldB.style.right = THIS.pickerFace+'px';
734
+ p.sldB.style.top = THIS.pickerFace+'px';
735
+ p.sldB.style.border = THIS.pickerInset+'px solid';
736
+ p.sldB.style.borderColor = THIS.pickerInsetColor;
737
+
738
+ // slider mouse area
739
+ p.sldM.style.display = THIS.slider ? 'block' : 'none';
740
+ p.sldM.style.position = 'absolute';
741
+ p.sldM.style.right = '0';
742
+ p.sldM.style.top = '0';
743
+ p.sldM.style.width = jscolor.images.sld[0] + jscolor.images.arrow[0] + THIS.pickerFace + 2*THIS.pickerInset + 'px';
744
+ p.sldM.style.height = p.box.style.height;
745
+ try {
746
+ p.sldM.style.cursor = 'pointer';
747
+ } catch(eOldIE) {
748
+ p.sldM.style.cursor = 'hand';
749
+ }
750
+
751
+ // "close" button
752
+ function setBtnBorder() {
753
+ var insetColors = THIS.pickerInsetColor.split(/\s+/);
754
+ var pickerOutsetColor = insetColors.length < 2 ? insetColors[0] : insetColors[1] + ' ' + insetColors[0] + ' ' + insetColors[0] + ' ' + insetColors[1];
755
+ p.btn.style.borderColor = pickerOutsetColor;
756
+ }
757
+ p.btn.style.display = THIS.pickerClosable ? 'block' : 'none';
758
+ p.btn.style.position = 'absolute';
759
+ p.btn.style.left = THIS.pickerFace + 'px';
760
+ p.btn.style.bottom = THIS.pickerFace + 'px';
761
+ p.btn.style.padding = '0 15px';
762
+ p.btn.style.height = '18px';
763
+ p.btn.style.border = THIS.pickerInset + 'px solid';
764
+ setBtnBorder();
765
+ p.btn.style.color = THIS.pickerButtonColor;
766
+ p.btn.style.font = '12px sans-serif';
767
+ p.btn.style.textAlign = 'center';
768
+ try {
769
+ p.btn.style.cursor = 'pointer';
770
+ } catch(eOldIE) {
771
+ p.btn.style.cursor = 'hand';
772
+ }
773
+ p.btn.onmousedown = function () {
774
+ THIS.hidePicker();
775
+ };
776
+ p.btnS.style.lineHeight = p.btn.style.height;
777
+
778
+ // load images in optimal order
779
+ switch(modeID) {
780
+ case 0: var padImg = 'hs.png'; break;
781
+ case 1: var padImg = 'hv.png'; break;
782
+ }
783
+ p.padM.style.backgroundImage = "url('"+jscolor.getDir()+"cross.gif')";
784
+ p.padM.style.backgroundRepeat = "no-repeat";
785
+ p.sldM.style.backgroundImage = "url('"+jscolor.getDir()+"arrow.gif')";
786
+ p.sldM.style.backgroundRepeat = "no-repeat";
787
+ p.pad.style.backgroundImage = "url('"+jscolor.getDir()+padImg+"')";
788
+ p.pad.style.backgroundRepeat = "no-repeat";
789
+ p.pad.style.backgroundPosition = "0 0";
790
+
791
+ // place pointers
792
+ redrawPad();
793
+ redrawSld();
794
+
795
+ jscolor.picker.owner = THIS;
796
+ document.getElementsByTagName('body')[0].appendChild(p.boxB);
797
+ }
798
+
799
+
800
+ function getPickerDims(o) {
801
+ var dims = [
802
+ 2*o.pickerInset + 2*o.pickerFace + jscolor.images.pad[0] +
803
+ (o.slider ? 2*o.pickerInset + 2*jscolor.images.arrow[0] + jscolor.images.sld[0] : 0),
804
+ o.pickerClosable ?
805
+ 4*o.pickerInset + 3*o.pickerFace + jscolor.images.pad[1] + o.pickerButtonHeight :
806
+ 2*o.pickerInset + 2*o.pickerFace + jscolor.images.pad[1]
807
+ ];
808
+ return dims;
809
+ }
810
+
811
+
812
+ function redrawPad() {
813
+ // redraw the pad pointer
814
+ switch(modeID) {
815
+ case 0: var yComponent = 1; break;
816
+ case 1: var yComponent = 2; break;
817
+ }
818
+ var x = Math.round((THIS.hsv[0]/6) * (jscolor.images.pad[0]-1));
819
+ var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.pad[1]-1));
820
+ jscolor.picker.padM.style.backgroundPosition =
821
+ (THIS.pickerFace+THIS.pickerInset+x - Math.floor(jscolor.images.cross[0]/2)) + 'px ' +
822
+ (THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.cross[1]/2)) + 'px';
823
+
824
+ // redraw the slider image
825
+ var seg = jscolor.picker.sld.childNodes;
826
+
827
+ switch(modeID) {
828
+ case 0:
829
+ var rgb = HSV_RGB(THIS.hsv[0], THIS.hsv[1], 1);
830
+ for(var i=0; i<seg.length; i+=1) {
831
+ seg[i].style.backgroundColor = 'rgb('+
832
+ (rgb[0]*(1-i/seg.length)*100)+'%,'+
833
+ (rgb[1]*(1-i/seg.length)*100)+'%,'+
834
+ (rgb[2]*(1-i/seg.length)*100)+'%)';
835
+ }
836
+ break;
837
+ case 1:
838
+ var rgb, s, c = [ THIS.hsv[2], 0, 0 ];
839
+ var i = Math.floor(THIS.hsv[0]);
840
+ var f = i%2 ? THIS.hsv[0]-i : 1-(THIS.hsv[0]-i);
841
+ switch(i) {
842
+ case 6:
843
+ case 0: rgb=[0,1,2]; break;
844
+ case 1: rgb=[1,0,2]; break;
845
+ case 2: rgb=[2,0,1]; break;
846
+ case 3: rgb=[2,1,0]; break;
847
+ case 4: rgb=[1,2,0]; break;
848
+ case 5: rgb=[0,2,1]; break;
849
+ }
850
+ for(var i=0; i<seg.length; i+=1) {
851
+ s = 1 - 1/(seg.length-1)*i;
852
+ c[1] = c[0] * (1 - s*f);
853
+ c[2] = c[0] * (1 - s);
854
+ seg[i].style.backgroundColor = 'rgb('+
855
+ (c[rgb[0]]*100)+'%,'+
856
+ (c[rgb[1]]*100)+'%,'+
857
+ (c[rgb[2]]*100)+'%)';
858
+ }
859
+ break;
860
+ }
861
+ }
862
+
863
+
864
+ function redrawSld() {
865
+ // redraw the slider pointer
866
+ switch(modeID) {
867
+ case 0: var yComponent = 2; break;
868
+ case 1: var yComponent = 1; break;
869
+ }
870
+ var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.sld[1]-1));
871
+ jscolor.picker.sldM.style.backgroundPosition =
872
+ '0 ' + (THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.arrow[1]/2)) + 'px';
873
+ }
874
+
875
+
876
+ function isPickerOwner() {
877
+ return jscolor.picker && jscolor.picker.owner === THIS;
878
+ }
879
+
880
+
881
+ function blurTarget() {
882
+ if(valueElement === target) {
883
+ THIS.importColor();
884
+ }
885
+ if(THIS.pickerOnfocus) {
886
+ THIS.hidePicker();
887
+ }
888
+ }
889
+
890
+
891
+ function blurValue() {
892
+ if(valueElement !== target) {
893
+ THIS.importColor();
894
+ }
895
+ }
896
+
897
+
898
+ function setPad(e) {
899
+ var mpos = jscolor.getRelMousePos(e);
900
+ var x = mpos.x - THIS.pickerFace - THIS.pickerInset;
901
+ var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
902
+ switch(modeID) {
903
+ case 0: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), 1 - y/(jscolor.images.pad[1]-1), null, leaveSld); break;
904
+ case 1: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), null, 1 - y/(jscolor.images.pad[1]-1), leaveSld); break;
905
+ }
906
+ }
907
+
908
+
909
+ function setSld(e) {
910
+ var mpos = jscolor.getRelMousePos(e);
911
+ var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
912
+ switch(modeID) {
913
+ case 0: THIS.fromHSV(null, null, 1 - y/(jscolor.images.sld[1]-1), leavePad); break;
914
+ case 1: THIS.fromHSV(null, 1 - y/(jscolor.images.sld[1]-1), null, leavePad); break;
915
+ }
916
+ }
917
+
918
+
919
+ function dispatchImmediateChange() {
920
+ if (THIS.onImmediateChange) {
921
+ var callback;
922
+ if (typeof THIS.onImmediateChange === 'string') {
923
+ callback = new Function (THIS.onImmediateChange);
924
+ } else {
925
+ callback = THIS.onImmediateChange;
926
+ }
927
+ callback.call(THIS);
928
+ }
929
+ }
930
+
931
+
932
+ var THIS = this;
933
+ var modeID = this.pickerMode.toLowerCase()==='hvs' ? 1 : 0;
934
+ var abortBlur = false;
935
+ var
936
+ valueElement = jscolor.fetchElement(this.valueElement),
937
+ styleElement = jscolor.fetchElement(this.styleElement);
938
+ var
939
+ holdPad = false,
940
+ holdSld = false,
941
+ touchOffset = {};
942
+ var
943
+ leaveValue = 1<<0,
944
+ leaveStyle = 1<<1,
945
+ leavePad = 1<<2,
946
+ leaveSld = 1<<3;
947
+
948
+ // target
949
+ jscolor.addEvent(target, 'focus', function() {
950
+ if(THIS.pickerOnfocus) { THIS.showPicker(); }
951
+ });
952
+ jscolor.addEvent(target, 'blur', function() {
953
+ if(!abortBlur) {
954
+ window.setTimeout(function(){ abortBlur || blurTarget(); abortBlur=false; }, 0);
955
+ } else {
956
+ abortBlur = false;
957
+ }
958
+ });
959
+
960
+ // valueElement
961
+ if(valueElement) {
962
+ var updateField = function() {
963
+ THIS.fromString(valueElement.value, leaveValue);
964
+ dispatchImmediateChange();
965
+ };
966
+ jscolor.addEvent(valueElement, 'keyup', updateField);
967
+ jscolor.addEvent(valueElement, 'input', updateField);
968
+ jscolor.addEvent(valueElement, 'blur', blurValue);
969
+ valueElement.setAttribute('autocomplete', 'off');
970
+ }
971
+
972
+ // styleElement
973
+ if(styleElement) {
974
+ styleElement.jscStyle = {
975
+ backgroundImage : styleElement.style.backgroundImage,
976
+ backgroundColor : styleElement.style.backgroundColor,
977
+ color : styleElement.style.color
978
+ };
979
+ }
980
+
981
+ // require images
982
+ switch(modeID) {
983
+ case 0: jscolor.requireImage('hs.png'); break;
984
+ case 1: jscolor.requireImage('hv.png'); break;
985
+ }
986
+ jscolor.requireImage('cross.gif');
987
+ jscolor.requireImage('arrow.gif');
988
+
989
+ this.importColor();
990
+ }
991
+
992
+ };
993
+
994
+
995
+ jscolor.install();
js/wplc_tabs.js CHANGED
@@ -1,3 +1,3 @@
1
- jQuery("document").ready(function() {
2
- jQuery("#wplc_tabs").tabs();
3
  });
1
+ jQuery("document").ready(function() {
2
+ jQuery("#wplc_tabs").tabs();
3
  });
js/wplc_u.js CHANGED
@@ -1,341 +1,341 @@
1
- /*
2
- * Cookie Stages
3
- *
4
- * 1 = no chat started - small box
5
- * 2 = chat window opens - enter username & email
6
- * 3 = awaiting admin to accept chat
7
- * 4 = Chat window - user and admin can now chat
8
- */
9
- jQuery(document).ready(function() {
10
-
11
-
12
-
13
- var wplc_user_auto_refresh = "";
14
- var wplc_user_auto_refresh_status = "";
15
-
16
- var wplc_check_cookie_id;
17
- var wplc_check_cookie_stage;
18
- var wplc_check_hide_cookie;
19
- var wplc_check_minimize_cookie;
20
-
21
- wplc_check_cookie_id = jQuery.cookie('wplc_cid');
22
- wplc_check_cookie_stage = jQuery.cookie('wplc_stage');
23
- wplc_check_hide_cookie = jQuery.cookie('wplc_hide');
24
- wplc_check_minimize_cookie = jQuery.cookie('wplc_minimize');
25
- //set cookie stage
26
- if(wplc_check_cookie_stage === null){
27
- jQuery.cookie('wplc_stage', 1, { expires: 1, path: '/' });
28
- wplc_check_cookie_stage = jQuery.cookie('wplc_stage');
29
- }
30
-
31
- function wplc_relay_user_stage(stage,cid) {
32
-
33
- if (cid.length) {
34
- var data = {
35
- action: 'wplc_relay_stage',
36
- security: wplc_nonce,
37
- stage: stage,
38
- cid: cid
39
- };
40
- } else {
41
- var data = {
42
- action: 'wplc_relay_stage',
43
- security: wplc_nonce,
44
- stage: stage
45
- };
46
- }
47
- jQuery.post(wplc_ajaxurl, data, function(response) {
48
- //console.log("wplc_relay_stage");
49
- });
50
- }
51
-
52
- /* minimize chat window */
53
- jQuery("#wp-live-chat-minimize").on("click", function() {
54
- jQuery("#wp-live-chat-1").show();
55
- jQuery("#wp-live-chat-1").css('cursor', 'pointer');
56
- jQuery("#wp-live-chat-2").hide();
57
- jQuery("#wp-live-chat-3").hide();
58
- jQuery("#wp-live-chat-4").hide();
59
- jQuery("#wp-live-chat-minimize").hide();
60
- jQuery.cookie('wplc_minimize', "yes", { expires: 1, path: '/' });
61
- var data = {
62
- action: 'wplc_user_minimize_chat',
63
- security: wplc_nonce,
64
- cid: wplc_check_cookie_id
65
- };
66
- jQuery.post(wplc_ajaxurl, data, function(response) {
67
- //console.log("wplc_user_close_chat");
68
- });
69
- });
70
- /* close chat window */
71
- jQuery("#wp-live-chat-close").on("click", function() {
72
- jQuery("#wp-live-chat").hide();
73
- jQuery("#wp-live-chat-1").hide();
74
- jQuery("#wp-live-chat-2").hide();
75
- jQuery("#wp-live-chat-3").hide();
76
- jQuery("#wp-live-chat-4").hide();
77
- jQuery("#wp-live-chat-minimize").hide();
78
- jQuery.cookie('wplc_hide', hide_chat, { expires: 1, path: '/' });
79
- jQuery.cookie('wplc_stage', "1", { expires: 1, path: '/' });
80
-
81
-
82
-
83
- var data = {
84
- action: 'wplc_user_close_chat',
85
- security: wplc_nonce,
86
- cid: wplc_check_cookie_id
87
- };
88
- jQuery.post(wplc_ajaxurl, data, function(response) {
89
- //console.log("wplc_user_close_chat");
90
- clearInterval(wplc_user_auto_refresh_status);
91
- clearInterval(wplc_user_auto_refresh);
92
-
93
- });
94
- });
95
-
96
-
97
- jQuery("#wp-live-chat-1").on("click", function() {
98
- //jQuery("#wp-live-chat-1").hide();
99
- jQuery("#wp-live-chat-1").css('cursor', 'default');
100
- jQuery.cookie('wplc_hide', "", { expires: 1, path: '/' });
101
- jQuery("#wp-live-chat-minimize").show();
102
- jQuery("#wp-live-chat-close").show();
103
-
104
- wplc_check_cookie_stage = jQuery.cookie('wplc_stage');
105
- if (wplc_check_cookie_stage === "4") {
106
- jQuery("#wp-live-chat-4").show();
107
- jQuery("#wplc_chatmsg").focus();
108
- jQuery("#wp-live-chat-2").hide();
109
- jQuery.cookie('wplc_minimize', "", { expires: 1, path: '/' });
110
- var data = {
111
- action: 'wplc_user_maximize_chat',
112
- security: wplc_nonce,
113
- cid: wplc_check_cookie_id
114
- };
115
- jQuery.post(wplc_ajaxurl, data, function(response) {
116
- //log("user maximized chat success");
117
- });
118
- }
119
- /*else if (wplc_check_cookie_stage === "2") {
120
- var data = {
121
- action: 'wplc_user_maximize_chat',
122
- security: wplc_nonce,
123
- cid: wplc_check_cookie_id
124
- };
125
- jQuery.post(wplc_ajaxurl, data, function(response) {
126
- //log("user maximized chat success");
127
- });
128
-
129
- jQuery("#wp-live-chat-2").show();
130
- //
131
- //Changed this to show chat window 2 as this seemed to be the issue where the chat would be minimized
132
- //without putting email or username in and then opened again and go straight into chat
133
- //
134
- //jQuery("#wp-live-chat-4").show();
135
- //jQuery("#wplc_chatmsg").focus();
136
- //jQuery("#wp-live-chat-2").hide();
137
- } */
138
- else if (wplc_check_cookie_stage === "1"){
139
- jQuery("#wp-live-chat-2").show();
140
- }
141
- });
142
-
143
- var wplc_user_waiting = null;
144
-
145
- jQuery("#wplc_start_chat_btn").on("click", function() {
146
- var wplc_name = jQuery("#wplc_name").val();
147
- var wplc_email = jQuery("#wplc_email").val();
148
- if (wplc_name.length <= 0) { alert("Please enter your name"); return false; }
149
- if (wplc_email.length <= 0) { alert("Please enter your email address"); return false; }
150
-
151
- jQuery("#wp-live-chat-2").hide();
152
- jQuery("#wp-live-chat-3").show();
153
-
154
- wplc_check_cookie_id = jQuery.cookie('wplc_cid');
155
- var wplc_chat_session_id;
156
-
157
- var data = {
158
- action: 'wplc_start_chat',
159
- security: wplc_nonce,
160
- name: wplc_name,
161
- email: wplc_email
162
- };
163
- jQuery.post(wplc_ajaxurl, data, function(response) {
164
- //console.log("wplc_start_chat");
165
- wplc_chat_session_id = response;
166
- wplc_check_cookie_id = response;
167
- wplc_user_waiting = setInterval(function (){wplc_user_await_session(wplc_chat_session_id);}, 5000);
168
-
169
- });
170
- });
171
-
172
- function wplc_user_await_session(cid) {
173
- var data = {
174
- action: 'wplc_user_awaiting_chat',
175
- security: wplc_nonce,
176
- id: cid
177
- };
178
- jQuery.post(wplc_ajaxurl, data, function(response) {
179
- //console.log("wplc_user_awaiting_chat");
180
-
181
- if (response == "3") {
182
- clearInterval(wplc_user_waiting);
183
- var wplc_name = jQuery("#wplc_name").val();
184
- jQuery("#wplc_cid").val(cid)
185
- jQuery("#wp-live-chat-3").hide();
186
- jQuery("#wp-live-chat-4").show();
187
- jQuery("#wplc_chatmsg").focus();
188
-
189
- // chat is now active
190
- jQuery.cookie('wplc_cid', cid, { expires: 1, path: '/' });
191
- jQuery.cookie('wplc_name', wplc_name, { expires: 1, path: '/' });
192
- jQuery.cookie('wplc_stage', 4, { expires: 1, path: '/' });
193
- wplc_user_auto_refresh = setInterval(function (){wpcl_user_auto_update_chat_box(cid);}, 3500);
194
- wplc_user_auto_refresh_status = setInterval(function (){wpcl_user_auto_update_chat_status(wplc_check_cookie_id);}, 3500);
195
-
196
- };
197
- });
198
- return;
199
- }
200
- jQuery("#wplc_chatmsg").keyup(function(event){
201
- if(event.keyCode == 13){
202
- jQuery("#wplc_send_msg").trigger("click");
203
- }
204
- });
205
-
206
- jQuery("#wplc_send_msg").on("click", function() {
207
- var wplc_cid = jQuery("#wplc_cid").val();
208
- var wplc_chat = jQuery("#wplc_chatmsg").val();
209
- var wplc_name = jQuery("#wplc_name").val();
210
- if (typeof wplc_name == "undefined" || wplc_name == null || wplc_name == "") {
211
- wplc_name = jQuery.cookie('wplc_name');
212
- }
213
- jQuery("#wplc_chatmsg").val('');
214
- jQuery("#wplc_chatbox").append("<strong>"+wplc_name+"</strong>: "+wplc_chat+"<br />");
215
- var height = jQuery('#wplc_chatbox')[0].scrollHeight;
216
- jQuery('#wplc_chatbox').scrollTop(height);
217
-
218
- var data = {
219
- action: 'wplc_user_send_msg',
220
- security: wplc_nonce,
221
- cid: wplc_cid,
222
- msg: wplc_chat
223
- };
224
- jQuery.post(wplc_ajaxurl, data, function(response) {
225
- //console.log("wplc_user_send_msg");
226
- });
227
-
228
- });
229
- function wpcl_user_auto_update_chat_status(cid) {
230
- var data = {
231
- action: 'wplc_update_user_chat_status',
232
- cid: cid,
233
- security: wplc_nonce
234
- };
235
- jQuery.post(wplc_ajaxurl, data, function(response) {
236
- if (response == "1") {
237
- jQuery("#wplc_chatbox").append("The chat has been ended by the operator.<br />");
238
- var height = jQuery('#wplc_chatbox')[0].scrollHeight;
239
- jQuery('#wplc_chatbox').scrollTop(height);
240
- jQuery.cookie('wplc_stage', '1', { path: '/' } );
241
- jQuery.cookie('wplc_hide', null, { path: '/' } );
242
- jQuery.cookie('wplc_cid', null, { path: '/' } );
243
- clearInterval(wplc_user_auto_refresh_status);
244
- jQuery("#wp-live-chat-minimize").hide();
245
- document.getElementById('wplc_chatmsg').disabled = true;
246
- }
247
- console.log("wplc_update_user_chat_response "+response);
248
- });
249
-
250
-
251
- }
252
-
253
- function wpcl_user_auto_update_chat_box(cid) {
254
- var data = {
255
- action: 'wplc_update_user_chat_boxes',
256
- cid: cid,
257
- security: wplc_nonce
258
- };
259
- jQuery.post(wplc_ajaxurl, data, function(response) {
260
- //console.log("wplc_update_user_chat_boxes");
261
- jQuery("#wplc_chatbox").append(response);
262
- var height = jQuery('#wplc_chatbox')[0].scrollHeight;
263
- jQuery('#wplc_chatbox').scrollTop(height);
264
-
265
- });
266
-
267
- }
268
-
269
-
270
- // user pushed the X button, dont show chat window
271
- if (wplc_check_hide_cookie === "yes" /*&& wplc_check_cookie_stage !== '1'*/) {
272
- jQuery("#wp-live-chat").hide();
273
- }
274
- // else if (wplc_check_cookie_stage === "1") {
275
- // jQuery("#wp-live-chat").hide();
276
- // }
277
- else {
278
-
279
- // First time visitor has visited the site, show chat window and set cookie
280
- if (typeof wplc_check_cookie_id === "undefined" || wplc_check_cookie_id == null) {
281
- wplc_dc = setTimeout(function (){jQuery("#wp-live-chat").css({ "display" : "block" }); wplc_relay_user_stage(1,''); }, window.wplc_delay);
282
- }
283
- // user has been here before, show different chat windows depending on which stage of the chat funnel he/she was in
284
- else {
285
-
286
- jQuery("#wplc_cid").val(wplc_check_cookie_id);
287
-
288
-
289
-
290
- jQuery("#wp-live-chat-1").show();
291
- jQuery("#wp-live-chat-2").hide();
292
- jQuery("#wp-live-chat-3").hide();
293
- jQuery("#wp-live-chat-4").hide();
294
- jQuery("#wp-live-chat-react").show();
295
- jQuery("#wp-live-chat-minimize").show();
296
- jQuery("#wp-live-chat-close").show();
297
-
298
-
299
-
300
- jQuery("#wp-live-chat").css({ "display" : "block" });
301
-
302
-
303
-
304
-
305
- var data = {
306
- action: 'wplc_user_reactivate_chat',
307
- security: wplc_nonce,
308
- cid: wplc_check_cookie_id
309
- };
310
- jQuery.post(wplc_ajaxurl, data, function(response) {
311
- //console.log("wplc_user_reactivate_chat");
312
- jQuery("#wp-live-chat-react").hide();
313
- jQuery("#wp-live-chat-4").show();
314
- jQuery("#wplc_chatmsg").focus();
315
- jQuery("#wp-live-chat-close").show();
316
- jQuery("#wp-live-chat-minimize").show();
317
-
318
- jQuery("#wplc_chatbox").append(response);
319
- var height = jQuery('#wplc_chatbox')[0].scrollHeight;
320
- jQuery('#wplc_chatbox').scrollTop(height);
321
-
322
- wplc_user_auto_refresh = setInterval(function (){wpcl_user_auto_update_chat_box(wplc_check_cookie_id);}, 3500);
323
- wplc_user_auto_refresh_status = setInterval(function (){wpcl_user_auto_update_chat_status(wplc_check_cookie_id);}, 3500);
324
- // set coorect curser
325
- jQuery("#wp-live-chat-1").css('cursor', 'default');
326
- //set correct cookie
327
- jQuery.cookie('wplc_stage', 4, { expires: 1, path: '/' });
328
- //if chat was minimized
329
- if(wplc_check_minimize_cookie === 'yes'){
330
- jQuery("#wp-live-chat-1").show();
331
- jQuery("#wp-live-chat-1").css('cursor', 'pointer');
332
- jQuery("#wp-live-chat-2").hide();
333
- jQuery("#wp-live-chat-3").hide();
334
- jQuery("#wp-live-chat-4").hide();
335
- jQuery("#wp-live-chat-minimize").hide();
336
- }
337
-
338
- });
339
- }
340
- }
341
  });
1
+ /*
2
+ * Cookie Stages
3
+ *
4
+ * 1 = no chat started - small box
5
+ * 2 = chat window opens - enter username & email
6
+ * 3 = awaiting admin to accept chat
7
+ * 4 = Chat window - user and admin can now chat
8
+ */
9
+ jQuery(document).ready(function() {
10
+
11
+
12
+
13
+ var wplc_user_auto_refresh = "";
14
+ var wplc_user_auto_refresh_status = "";
15
+
16
+ var wplc_check_cookie_id;
17
+ var wplc_check_cookie_stage;
18
+ var wplc_check_hide_cookie;
19
+ var wplc_check_minimize_cookie;
20
+
21
+ wplc_check_cookie_id = jQuery.cookie('wplc_cid');
22
+ wplc_check_cookie_stage = jQuery.cookie('wplc_stage');
23
+ wplc_check_hide_cookie = jQuery.cookie('wplc_hide');
24
+ wplc_check_minimize_cookie = jQuery.cookie('wplc_minimize');
25
+ //set cookie stage
26
+ if(wplc_check_cookie_stage === null){
27
+ jQuery.cookie('wplc_stage', 1, { expires: 1, path: '/' });
28
+ wplc_check_cookie_stage = jQuery.cookie('wplc_stage');
29
+ }
30
+
31
+ function wplc_relay_user_stage(stage,cid) {
32
+
33
+ if (cid.length) {
34
+ var data = {
35
+ action: 'wplc_relay_stage',
36
+ security: wplc_nonce,
37
+ stage: stage,
38
+ cid: cid
39
+ };
40
+ } else {
41
+ var data = {
42
+ action: 'wplc_relay_stage',
43
+ security: wplc_nonce,
44
+ stage: stage
45
+ };
46
+ }
47
+ jQuery.post(wplc_ajaxurl, data, function(response) {
48
+ //console.log("wplc_relay_stage");
49
+ });
50
+ }
51
+
52
+ /* minimize chat window */
53
+ jQuery("#wp-live-chat-minimize").on("click", function() {
54
+ jQuery("#wp-live-chat-1").show();
55
+ jQuery("#wp-live-chat-1").css('cursor', 'pointer');
56
+ jQuery("#wp-live-chat-2").hide();
57
+ jQuery("#wp-live-chat-3").hide();
58
+ jQuery("#wp-live-chat-4").hide();
59
+ jQuery("#wp-live-chat-minimize").hide();
60
+ jQuery.cookie('wplc_minimize', "yes", { expires: 1, path: '/' });
61
+ var data = {
62
+ action: 'wplc_user_minimize_chat',
63
+ security: wplc_nonce,
64
+ cid: wplc_check_cookie_id
65
+ };
66
+ jQuery.post(wplc_ajaxurl, data, function(response) {
67
+ //console.log("wplc_user_close_chat");
68
+ });
69
+ });
70
+ /* close chat window */
71
+ jQuery("#wp-live-chat-close").on("click", function() {
72
+ jQuery("#wp-live-chat").hide();
73
+ jQuery("#wp-live-chat-1").hide();
74
+ jQuery("#wp-live-chat-2").hide();
75
+ jQuery("#wp-live-chat-3").hide();
76
+ jQuery("#wp-live-chat-4").hide();
77
+ jQuery("#wp-live-chat-minimize").hide();
78
+ jQuery.cookie('wplc_hide', hide_chat, { expires: 1, path: '/' });
79
+ jQuery.cookie('wplc_stage', "1", { expires: 1, path: '/' });
80
+
81
+
82
+
83
+ var data = {
84
+ action: 'wplc_user_close_chat',
85
+ security: wplc_nonce,
86
+ cid: wplc_check_cookie_id
87
+ };
88
+ jQuery.post(wplc_ajaxurl, data, function(response) {
89
+ //console.log("wplc_user_close_chat");
90
+ clearInterval(wplc_user_auto_refresh_status);
91
+ clearInterval(wplc_user_auto_refresh);
92
+
93
+ });
94
+ });
95
+
96
+
97
+ jQuery("#wp-live-chat-1").on("click", function() {
98
+ //jQuery("#wp-live-chat-1").hide();
99
+ jQuery("#wp-live-chat-1").css('cursor', 'default');
100
+ jQuery.cookie('wplc_hide', "", { expires: 1, path: '/' });
101
+ jQuery("#wp-live-chat-minimize").show();
102
+ jQuery("#wp-live-chat-close").show();
103
+
104
+ wplc_check_cookie_stage = jQuery.cookie('wplc_stage');
105
+ if (wplc_check_cookie_stage === "4") {
106
+ jQuery("#wp-live-chat-4").show();
107
+ jQuery("#wplc_chatmsg").focus();
108
+ jQuery("#wp-live-chat-2").hide();
109
+ jQuery.cookie('wplc_minimize', "", { expires: 1, path: '/' });
110
+ var data = {
111
+ action: 'wplc_user_maximize_chat',
112
+ security: wplc_nonce,
113
+ cid: wplc_check_cookie_id
114
+ };
115
+ jQuery.post(wplc_ajaxurl, data, function(response) {
116
+ //log("user maximized chat success");
117
+ });
118
+ }
119
+ /*else if (wplc_check_cookie_stage === "2") {
120
+ var data = {
121
+ action: 'wplc_user_maximize_chat',
122
+ security: wplc_nonce,
123
+ cid: wplc_check_cookie_id
124
+ };
125
+ jQuery.post(wplc_ajaxurl, data, function(response) {
126
+ //log("user maximized chat success");
127
+ });
128
+
129
+ jQuery("#wp-live-chat-2").show();
130
+ //
131
+ //Changed this to show chat window 2 as this seemed to be the issue where the chat would be minimized
132
+ //without putting email or username in and then opened again and go straight into chat
133
+ //
134
+ //jQuery("#wp-live-chat-4").show();
135
+ //jQuery("#wplc_chatmsg").focus();
136
+ //jQuery("#wp-live-chat-2").hide();
137
+ } */
138
+ else if (wplc_check_cookie_stage === "1"){
139
+ jQuery("#wp-live-chat-2").show();
140
+ }
141
+ });
142
+
143
+ var wplc_user_waiting = null;
144
+
145
+ jQuery("#wplc_start_chat_btn").on("click", function() {
146
+ var wplc_name = jQuery("#wplc_name").val();
147
+ var wplc_email = jQuery("#wplc_email").val();
148
+ if (wplc_name.length <= 0) { alert("Please enter your name"); return false; }
149
+ if (wplc_email.length <= 0) { alert("Please enter your email address"); return false; }
150
+
151
+ jQuery("#wp-live-chat-2").hide();
152
+ jQuery("#wp-live-chat-3").show();
153
+
154
+ wplc_check_cookie_id = jQuery.cookie('wplc_cid');
155
+ var wplc_chat_session_id;
156
+
157
+ var data = {
158
+ action: 'wplc_start_chat',
159
+ security: wplc_nonce,
160
+ name: wplc_name,
161
+ email: wplc_email
162
+ };
163
+ jQuery.post(wplc_ajaxurl, data, function(response) {
164
+ //console.log("wplc_start_chat");
165
+ wplc_chat_session_id = response;
166
+ wplc_check_cookie_id = response;
167
+ wplc_user_waiting = setInterval(function (){wplc_user_await_session(wplc_chat_session_id);}, 5000);
168
+
169
+ });
170
+ });
171
+
172
+ function wplc_user_await_session(cid) {
173
+ var data = {
174
+ action: 'wplc_user_awaiting_chat',
175
+ security: wplc_nonce,
176
+ id: cid
177
+ };
178
+ jQuery.post(wplc_ajaxurl, data, function(response) {
179
+ //console.log("wplc_user_awaiting_chat");
180
+
181
+ if (response == "3") {
182
+ clearInterval(wplc_user_waiting);
183
+ var wplc_name = jQuery("#wplc_name").val();
184
+ jQuery("#wplc_cid").val(cid)
185
+ jQuery("#wp-live-chat-3").hide();
186
+ jQuery("#wp-live-chat-4").show();
187
+ jQuery("#wplc_chatmsg").focus();
188
+
189
+ // chat is now active
190
+ jQuery.cookie('wplc_cid', cid, { expires: 1, path: '/' });
191
+ jQuery.cookie('wplc_name', wplc_name, { expires: 1, path: '/' });
192
+ jQuery.cookie('wplc_stage', 4, { expires: 1, path: '/' });
193
+ wplc_user_auto_refresh = setInterval(function (){wpcl_user_auto_update_chat_box(cid);}, 3500);
194
+ wplc_user_auto_refresh_status = setInterval(function (){wpcl_user_auto_update_chat_status(wplc_check_cookie_id);}, 3500);
195
+
196
+ };
197
+ });
198
+ return;
199
+ }
200
+ jQuery("#wplc_chatmsg").keyup(function(event){
201
+ if(event.keyCode == 13){
202
+ jQuery("#wplc_send_msg").trigger("click");
203
+ }
204
+ });
205
+
206
+ jQuery("#wplc_send_msg").on("click", function() {
207
+ var wplc_cid = jQuery("#wplc_cid").val();
208
+ var wplc_chat = jQuery("#wplc_chatmsg").val();
209
+ var wplc_name = jQuery("#wplc_name").val();
210
+ if (typeof wplc_name == "undefined" || wplc_name == null || wplc_name == "") {
211
+ wplc_name = jQuery.cookie('wplc_name');
212
+ }
213
+ jQuery("#wplc_chatmsg").val('');
214
+ jQuery("#wplc_chatbox").append("<strong>"+wplc_name+"</strong>: "+wplc_chat+"<br />");
215
+ var height = jQuery('#wplc_chatbox')[0].scrollHeight;
216
+ jQuery('#wplc_chatbox').scrollTop(height);
217
+
218
+ var data = {
219
+ action: 'wplc_user_send_msg',
220
+ security: wplc_nonce,
221
+ cid: wplc_cid,
222
+ msg: wplc_chat
223
+ };
224
+ jQuery.post(wplc_ajaxurl, data, function(response) {
225
+ //console.log("wplc_user_send_msg");
226
+ });
227
+
228
+ });
229
+ function wpcl_user_auto_update_chat_status(cid) {
230
+ var data = {
231
+ action: 'wplc_update_user_chat_status',
232
+ cid: cid,
233
+ security: wplc_nonce
234
+ };
235
+ jQuery.post(wplc_ajaxurl, data, function(response) {
236
+ if (response == "1") {
237
+ jQuery("#wplc_chatbox").append("The chat has been ended by the operator.<br />");
238
+ var height = jQuery('#wplc_chatbox')[0].scrollHeight;
239
+ jQuery('#wplc_chatbox').scrollTop(height);
240
+ jQuery.cookie('wplc_stage', '1', { path: '/' } );
241
+ jQuery.cookie('wplc_hide', null, { path: '/' } );
242
+ jQuery.cookie('wplc_cid', null, { path: '/' } );
243
+ clearInterval(wplc_user_auto_refresh_status);
244
+ jQuery("#wp-live-chat-minimize").hide();
245
+ document.getElementById('wplc_chatmsg').disabled = true;
246
+ }
247
+ console.log("wplc_update_user_chat_response "+response);
248
+ });
249
+
250
+
251
+ }
252
+
253
+ function wpcl_user_auto_update_chat_box(cid) {
254
+ var data = {
255
+ action: 'wplc_update_user_chat_boxes',
256
+ cid: cid,
257
+ security: wplc_nonce
258
+ };
259
+ jQuery.post(wplc_ajaxurl, data, function(response) {
260
+ //console.log("wplc_update_user_chat_boxes");
261
+ jQuery("#wplc_chatbox").append(response);
262
+ var height = jQuery('#wplc_chatbox')[0].scrollHeight;
263
+ jQuery('#wplc_chatbox').scrollTop(height);
264
+
265
+ });
266
+
267
+ }
268
+
269
+
270
+ // user pushed the X button, dont show chat window
271
+ if (wplc_check_hide_cookie === "yes" /*&& wplc_check_cookie_stage !== '1'*/) {
272
+ jQuery("#wp-live-chat").hide();
273
+ }
274
+ // else if (wplc_check_cookie_stage === "1") {
275
+ // jQuery("#wp-live-chat").hide();
276
+ // }
277
+ else {
278
+
279
+ // First time visitor has visited the site, show chat window and set cookie
280
+ if (typeof wplc_check_cookie_id === "undefined" || wplc_check_cookie_id == null) {
281
+ wplc_dc = setTimeout(function (){jQuery("#wp-live-chat").css({ "display" : "block" }); wplc_relay_user_stage(1,''); }, window.wplc_delay);
282
+ }
283
+ // user has been here before, show different chat windows depending on which stage of the chat funnel he/she was in
284
+ else {
285
+
286
+ jQuery("#wplc_cid").val(wplc_check_cookie_id);
287
+
288
+
289
+
290
+ jQuery("#wp-live-chat-1").show();
291
+ jQuery("#wp-live-chat-2").hide();
292
+ jQuery("#wp-live-chat-3").hide();
293
+ jQuery("#wp-live-chat-4").hide();
294
+ jQuery("#wp-live-chat-react").show();
295
+ jQuery("#wp-live-chat-minimize").show();
296
+ jQuery("#wp-live-chat-close").show();
297
+
298
+
299
+
300
+ jQuery("#wp-live-chat").css({ "display" : "block" });
301
+
302
+
303
+
304
+
305
+ var data = {
306
+ action: 'wplc_user_reactivate_chat',
307
+ security: wplc_nonce,
308
+ cid: wplc_check_cookie_id
309
+ };
310
+ jQuery.post(wplc_ajaxurl, data, function(response) {
311
+ //console.log("wplc_user_reactivate_chat");
312
+ jQuery("#wp-live-chat-react").hide();
313
+ jQuery("#wp-live-chat-4").show();
314
+ jQuery("#wplc_chatmsg").focus();
315
+ jQuery("#wp-live-chat-close").show();
316
+ jQuery("#wp-live-chat-minimize").show();
317
+
318
+ jQuery("#wplc_chatbox").append(response);
319
+ var height = jQuery('#wplc_chatbox')[0].scrollHeight;
320
+ jQuery('#wplc_chatbox').scrollTop(height);
321
+
322
+ wplc_user_auto_refresh = setInterval(function (){wpcl_user_auto_update_chat_box(wplc_check_cookie_id);}, 3500);
323
+ wplc_user_auto_refresh_status = setInterval(function (){wpcl_user_auto_update_chat_status(wplc_check_cookie_id);}, 3500);
324
+ // set coorect curser
325
+ jQuery("#wp-live-chat-1").css('cursor', 'default');
326
+ //set correct cookie
327
+ jQuery.cookie('wplc_stage', 4, { expires: 1, path: '/' });
328
+ //if chat was minimized
329
+ if(wplc_check_minimize_cookie === 'yes'){
330
+ jQuery("#wp-live-chat-1").show();
331
+ jQuery("#wp-live-chat-1").css('cursor', 'pointer');
332
+ jQuery("#wp-live-chat-2").hide();
333
+ jQuery("#wp-live-chat-3").hide();
334
+ jQuery("#wp-live-chat-4").hide();
335
+ jQuery("#wp-live-chat-minimize").hide();
336
+ }
337
+
338
+ });
339
+ }
340
+ }
341
  });
languages/wp-live-chat-support-default.mo ADDED
Binary file
languages/wp-live-chat-support-default.po ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "POT-Creation-Date: 2014-02-17 15:00+0200\n"
5
+ "PO-Revision-Date: 2014-02-17 15:00+0200\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.5.7\n"
12
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "X-Poedit-SearchPath-0: C:\\wamp\\www\\wordpress361\\wp-content\\plugins\\wp-"
15
+ "live-chat-support\n"
16
+
17
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/functions.php:131
18
+ msgid "IP"
19
+ msgstr ""
20
+
21
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/functions.php:132
22
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:152
23
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:70
24
+ msgid "Name"
25
+ msgstr ""
26
+
27
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/functions.php:133
28
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:156
29
+ msgid "Email"
30
+ msgstr ""
31
+
32
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/functions.php:134
33
+ msgid "URL"
34
+ msgstr ""
35
+
36
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/functions.php:135
37
+ msgid "Status"
38
+ msgstr ""
39
+
40
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/functions.php:136
41
+ msgid "Action"
42
+ msgstr ""
43
+
44
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/functions.php:143
45
+ msgid "No chat sessions available at the moment"
46
+ msgstr ""
47
+
48
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/functions.php:435
49
+ msgid "Get Pro Add-on to accept more chats"
50
+ msgstr ""
51
+
52
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:70
53
+ msgid "Live Chat"
54
+ msgstr ""
55
+
56
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:71
57
+ msgid "Settings"
58
+ msgstr ""
59
+
60
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:72
61
+ msgid "History"
62
+ msgstr ""
63
+
64
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:177
65
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:440
66
+ msgid "Send"
67
+ msgstr ""
68
+
69
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:385
70
+ msgid "With the Pro add-on of WP Live Chat Support, you can"
71
+ msgstr ""
72
+
73
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:385
74
+ msgid "see who's online and initiate chats"
75
+ msgstr ""
76
+
77
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:385
78
+ msgid "with your online visitors with the click of a button."
79
+ msgstr ""
80
+
81
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:385
82
+ msgid "Buy the Pro add-on now for only $24.95 once off. Free Updates FOREVER."
83
+ msgstr ""
84
+
85
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:385
86
+ msgid "Buy the Pro add-on now for only $24.95 once off. Free Updates Forever."
87
+ msgstr ""
88
+
89
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:430
90
+ msgid "End chat"
91
+ msgstr ""
92
+
93
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:577
94
+ msgid "User has minimized the chat window"
95
+ msgstr ""
96
+
97
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:583
98
+ msgid "User has opened the chat window"
99
+ msgstr ""
100
+
101
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:590
102
+ msgid "User has closed and ended the chat"
103
+ msgstr ""
104
+
105
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:697
106
+ msgid "WP Live Chat History"
107
+ msgstr ""
108
+
109
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:702
110
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:46
111
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:77
112
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:93
113
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:109
114
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:125
115
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:142
116
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:163
117
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:177
118
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:227
119
+ msgid "Pro Add-on"
120
+ msgstr ""
121
+
122
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/wp-live-chat-support.php:726
123
+ msgid "Your settings have been saved."
124
+ msgstr ""
125
+
126
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:6
127
+ msgid "WP Live Chat Support Settings"
128
+ msgstr ""
129
+
130
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:19
131
+ msgid "General Settings"
132
+ msgstr ""
133
+
134
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:20
135
+ msgid "Chat Box"
136
+ msgstr ""
137
+
138
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:21
139
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:152
140
+ msgid "Offline Messages"
141
+ msgstr ""
142
+
143
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:22
144
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:189
145
+ msgid "Styling"
146
+ msgstr ""
147
+
148
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:25
149
+ msgid "Main Settings"
150
+ msgstr ""
151
+
152
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:28
153
+ msgid "Chat enabled"
154
+ msgstr ""
155
+
156
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:31
157
+ msgid "Yes"
158
+ msgstr ""
159
+
160
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:32
161
+ msgid "No"
162
+ msgstr ""
163
+
164
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:38
165
+ msgid "Hide Chat"
166
+ msgstr ""
167
+
168
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:45
169
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:76
170
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:92
171
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:108
172
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:124
173
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:141
174
+ msgid "available in the"
175
+ msgstr ""
176
+
177
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:47
178
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:78
179
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:94
180
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:110
181
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:126
182
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:143
183
+ msgid "only"
184
+ msgstr ""
185
+
186
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:56
187
+ msgid "Chat Window Settings"
188
+ msgstr ""
189
+
190
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:59
191
+ msgid "Chat box alignment"
192
+ msgstr ""
193
+
194
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:62
195
+ msgid "Bottom left"
196
+ msgstr ""
197
+
198
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:63
199
+ msgid "Bottom right"
200
+ msgstr ""
201
+
202
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:86
203
+ msgid "Picture"
204
+ msgstr ""
205
+
206
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:89
207
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:105
208
+ msgid "Upload Image"
209
+ msgstr ""
210
+
211
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:102
212
+ msgid "Logo"
213
+ msgstr ""
214
+
215
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:118
216
+ msgid "Chat delay (seconds)"
217
+ msgstr ""
218
+
219
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:134
220
+ msgid "Chat notifications"
221
+ msgstr ""
222
+
223
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:138
224
+ msgid "Alert me via email as soon as someone wants to chat"
225
+ msgstr ""
226
+
227
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:156
228
+ msgid "Email Address"
229
+ msgstr ""
230
+
231
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:162
232
+ msgid "Get offline messages with the "
233
+ msgstr ""
234
+
235
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:171
236
+ msgid "Offline text"
237
+ msgstr ""
238
+
239
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:176
240
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:226
241
+ msgid "Edit these text fields using the "
242
+ msgstr ""
243
+
244
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:192
245
+ msgid "Chat box fill color"
246
+ msgstr ""
247
+
248
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:198
249
+ msgid "Chat box font color"
250
+ msgstr ""
251
+
252
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:205
253
+ msgid "First section text"
254
+ msgstr ""
255
+
256
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:212
257
+ msgid "Second section text"
258
+ msgstr ""
259
+
260
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:221
261
+ msgid "Reactivate chat section text"
262
+ msgstr ""
263
+
264
+ #: C:\wamp\www\wordpress361\wp-content\plugins\wp-live-chat-support/includes/settings_page.php:238
265
+ msgid "Save Settings"
266
+ msgstr ""
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
  === WP Live Chat Support ===
2
  Contributors: WP-LiveChat
3
  Donate link: http://www.wp-livechat.com
4
- Tags: live chat, live support, chat plugin, live help, wordpress chat, customer support, chat, live chat plugin, live support plugin, live chat support plugin
5
  Requires at least: 3.5
6
  Tested up to: 3.8.1
7
  Stable tag: trunk
8
  License: GPLv2
9
 
10
- The most cost effective Live Chat plugin. Chat with your visitors for free!
11
 
12
  == Description ==
13
 
@@ -21,6 +21,7 @@ The most cost effective Live Chat plugin. Chat with your visitors for free! WP L
21
  ► No advertising or links
22
  ► No "Powered by" links on the live chat window
23
  ► No monthly live chat subscriptions needed
 
24
 
25
 
26
  = Pro Version Features =
@@ -83,6 +84,9 @@ Please review the live chat documentation on [our website](http://wp-livechat.co
83
 
84
  == Changelog ==
85
 
 
 
 
86
  = 2.9 =
87
  * Added comprehensive documentation
88
 
1
  === WP Live Chat Support ===
2
  Contributors: WP-LiveChat
3
  Donate link: http://www.wp-livechat.com
4
+ Tags: live chat, live support, chat plugin, live help, wordpress chat, customer support, chat, live chat plugin, live support plugin, live chat support plugin, chat plugin, support plugin, support, chat software, chat online, visitor chat, chat, free chat, free live chat, customer support, online support, live help, chat widget, customer help
5
  Requires at least: 3.5
6
  Tested up to: 3.8.1
7
  Stable tag: trunk
8
  License: GPLv2
9
 
10
+ The most cost effective Live Chat plugin. Provide live support for free!
11
 
12
  == Description ==
13
 
21
  ► No advertising or links
22
  ► No "Powered by" links on the live chat window
23
  ► No monthly live chat subscriptions needed
24
+ ► Provide live support for your site for free
25
 
26
 
27
  = Pro Version Features =
84
 
85
  == Changelog ==
86
 
87
+ = 2.10 =
88
+ * Included a .PO file for internationalization
89
+
90
  = 2.9 =
91
  * Added comprehensive documentation
92
 
wp-live-chat-support.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Live Chat Support
4
  Plugin URI: http://www.wp-livechat.com
5
  Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP Live Chat Support. No third party connection required!
6
- Version: 2.9
7
  Author: WP-LiveChat
8
  Author URI: http://www.wp-livechat.com
9
  */
@@ -17,7 +17,7 @@ global $wplc_tblname_chats;
17
  global $wplc_tblname_msgs;
18
  $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
19
  $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
20
- $wplc_version = "2.9";
21
 
22
  require_once (plugin_dir_path( __FILE__ )."functions.php");
23
  add_action('wp_ajax_wplc_admin_set_transient', 'wplc_action_callback');
3
  Plugin Name: WP Live Chat Support
4
  Plugin URI: http://www.wp-livechat.com
5
  Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP Live Chat Support. No third party connection required!
6
+ Version: 2.10
7
  Author: WP-LiveChat
8
  Author URI: http://www.wp-livechat.com
9
  */
17
  global $wplc_tblname_msgs;
18
  $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
19
  $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
20
+ $wplc_version = "2.10";
21
 
22
  require_once (plugin_dir_path( __FILE__ )."functions.php");
23
  add_action('wp_ajax_wplc_admin_set_transient', 'wplc_action_callback');