3 * xChatty: xCally Shuttle WebChat Client
7 * @link http://www.xcally.com
13 websiteId: {{websiteId}},
14 signedUp: {{signedUp}},
15 windowFocused: {{windowFocused}},
16 isNewPage: {{isNewPage}},
17 processingSignUp: {{processingSignUp}},
18 processingEnquiry: {{processingEnquiry}},
19 processingSend: {{processingSend}},
24 timerReadMessages: {{timerReadMessages}},
25 timerCheckStatus: {{timerCheckStatus}},
26 timerSendMessages: '',
27 timerSignupResponse: '',
28 isOnline: {{isOnline}},
29 decayHistory: {{decayHistory}},
30 defaultTimeout: {{defaultTimeout}},
31 isInitialStatusCheck: {{isInitialStatusCheck}},
32 muteNotificationSoundOnce: {{muteNotificationSoundOnce}},
33 assetBase: '{{& assetBase}}',
34 rootPath: '{{& rootPath}}',
35 hasSessionSaf: {{hasSessionSaf}},
36 restoreOpenState: {{restoreOpenState}},
37 animateHover: {{animateHover}},
38 hideEmail: {{hideEmail}},
39 hideOffline: {{hideOffline}},
40 headerShape: '{{headerShape}}',
41 downloadTranscript: {{downloadTranscript}}
44 "HeaderCurrentlyChatting": "Live Chat",
45 "HeaderOnline": '{{HeaderOnline}}',
46 "HeaderOffline": "{{HeaderOffline}}",
47 "OperatorOfflineMessage": "It appears as if all operators are currently offline.",
48 "OfflineMessage": "{{{OfflineMessage}}}",
49 "OnlineMessage": '{{OnlineMessage}}',
50 "UsernamePlaceholder": '{{UsernamePlaceholder}}',
51 "EmailPlaceholder": '{{EmailPlaceholder}}',
52 "EnquiryMessagePlaceholder": "{{EnquiryMessagePlaceholder}}",
53 "EnquiryButtonText": "{{EnquiryButtonText}}",
54 "EnquirySubmitSuccess": "Your message was sucessfully submitted - we will contact you as soon as possible.",
55 "StartChatButtonText": '{{StartChatButtonText}}',
56 "OperatorComposing": "{fullname} is typing...",
57 "FirstMessageText": "",
58 "ExitChatButtonText": "Exit Chat",
59 "ExitChatQuestionText": "Are you sure?",
60 "ExitChatButtonConfirmText": "Yes",
61 "ExitChatButtonCancelText": "No",
62 "MessagePlaceholderText": "Your message...",
63 "MessageSendButtonText": "Send",
64 "ValidationEmailRequired": "Please enter your email address",
65 "ValidationEmailInvalid": "Please enter a valid email address",
66 "ValidationEmailMaxLength": "The email address may not exceed 85 characters",
67 "ValidationUsernameRequired": "Please enter your name",
68 "ValidationUsernameMaxLength": "The name may not exceed 45 characters",
69 "ValidationEnquiryRequired": "Please enter your enquiry",
70 "ValidationEnquiryMaxLength": "The enquiry may not exceed 1500 characters",
71 "ValidationMessageRequired": "Please enter your message",
72 "ValidationMessageMaxLength": "The message may not exceed 750 characters",
73 "DownloadTranscript": "Download Transcript"
76 jQuery(".xc_chat_container").css('margin-bottom', '-50px');
77 if (!xChatty.config.hideOffline)
78 jQuery(".xc_chat_container").show();
79 jQuery(".xc_chat_container").animate({
84 complete: function() {
85 if (xChatty.config.restoreOpenState) {
86 xChatty.config.isNewPage = true;
87 jQuery(".xc_chat_head").trigger("click");
91 xChatty.initAnimateHover();
92 jQuery(window).focus(function() {
93 xChatty.config.windowFocused = true;
95 jQuery(window).blur(function() {
96 xChatty.config.windowFocused = false;
98 jQuery(document).on("click", ".xc_chat_head", xChatty.headerClick);
99 jQuery(document).on("click", ".xc_btn_enquiry", xChatty.enquiryClick);
100 jQuery(document).on("submit", ".xc_form_enquiry", xChatty.enquirySubmit);
101 // jQuery(document).on("click", ".xc_btn_signup", xChatty.signUpClick);
102 jQuery(document).on("submit", ".xc_form_signup", xChatty.signUpSubmit);
103 jQuery(document).on("click", ".xc_btn_send", xChatty.sendClick);
104 jQuery(document).on("submit", ".xc_form_reply", xChatty.onSendSubmit);
105 jQuery(document).on("click", ".xc_btn_exit_chat", xChatty.btnExitChatClick);
106 jQuery(document).on("click", ".xc_btn_exit_chat_confirm", xChatty.btnExitChatConfirmClick);
107 jQuery(document).on("click", ".xc_btn_exit_chat_cancel", xChatty.btnExitChatCancelClick);
108 jQuery(document).on("click", ".xc_btn_notifications_close", xChatty.btnNotificationsCloseClick);
109 jQuery(document).on("keyup", ".xc_chat_container textarea, .xc_chat_container input", xChatty.messageKeyUp);
110 jQuery(document).on("keydown", ".xc_input_message", xChatty.messageKeyDown);
111 jQuery('[placeholder]').each(function() {
112 jQuery(this).css('color', '#ccc').val(jQuery(this).attr('placeholder'));
113 }).bind('focus', function() {
114 jQuery(this).css('color', 'inherit');
115 if (jQuery(this).val() === jQuery(this).attr('placeholder')) {
116 jQuery(this).val('');
118 }).bind('blur', function() {
119 if (jQuery(this).val() === '') {
120 jQuery(this).val(jQuery(this).attr('placeholder')).css('color', '#ccc');
123 xChatty.readMessages();
125 initAnimateHover: function() {
126 if (xChatty.config.animateHover !== true)
128 jQuery(".xc_chat_container").animate({
134 jQuery(".xc_chat_container").hover(function() {
135 jQuery(this).animate({
142 if (!jQuery(this).hasClass("xc_box_open"))
143 jQuery(this).animate({
150 jQuery(".xc_chat_container").bind("chatOpen", function(e, isOpen) {
152 jQuery(this).animate({
159 jQuery(this).animate({
168 enquiryClick: function(e) {
170 jQuery(".xc_form_enquiry").submit();
172 btnExitChatClick: function(e) {
174 jQuery(".xc_exit_chat_confirmation_wrapper").show();
177 btnExitChatConfirmClick: function(e) {
179 clearTimeout(xChatty.config.timerReadMessages);
180 clearTimeout(xChatty.config.timerCheckStatus);
181 var formData = jQuery(this).serializeArray();
183 name: 'data[sign_out]',
187 url: xChatty.config.rootPath + "signout",
190 jsonpCallback: xChatty.getJsonpCallbackName(),
191 success: function(result) {
192 if (result.success === true) {
193 xChatty.resetDefaultState();
196 complete: function() {
197 xChatty.checkStatus(true);
201 btnExitChatCancelClick: function(e) {
203 jQuery(".xc_exit_chat_confirmation_wrapper").hide();
204 jQuery(".xc_btn_exit_chat").show();
206 resetDefaultState: function() {
207 xChatty.config.signedUp = false;
208 xChatty.config.visitor = {
212 jQuery(".xc_conversation_container").empty();
213 jQuery(".xc_conversation_container").html('<p class="xc_message_intro" data-id="-10">' + xChatty.Lang.FirstMessageText + '</p>');
214 jQuery(".xc_exit_chat_confirmation_wrapper").hide();
215 jQuery(".xc_btn_exit_chat").show();
216 jQuery(".xc_chat_head").trigger("click");
218 enquirySubmit: function(e) {
220 if (xChatty.config.processingEnquiry)
222 var validationErrors = {};
223 if (jQuery.trim(jQuery(".xc_input_enquiry_fullname").val()) === '' || jQuery(".xc_input_enquiry_fullname").val() === jQuery(".xc_input_enquiry_fullname").attr("placeholder")) {
224 validationErrors["fullname"] = [xChatty.Lang.ValidationUsernameRequired];
226 if (jQuery.trim(jQuery(".xc_input_enquiry_email").val()) === '' || jQuery(".xc_input_enquiry_email").val() === jQuery(".xc_input_enquiry_email").attr("placeholder")) {
227 validationErrors["email"] = [xChatty.Lang.ValidationEmailRequired];
229 if (jQuery.trim(jQuery(".xc_input_enquiry_message").val()) === '' || jQuery(".xc_input_enquiry_message").val() === jQuery(".xc_input_enquiry_message").attr("placeholder")) {
230 validationErrors["message"] = [xChatty.Lang.ValidationEnquiryRequired];
232 if (validationErrors.hasOwnProperty("fullname") || validationErrors.hasOwnProperty("email") || validationErrors.hasOwnProperty("message")) {
233 xChatty.renderNotifications(validationErrors, true);
236 xChatty.config.processingEnquiry = true;
237 var enquiryForm = jQuery(this);
238 enquiryForm.addClass("xc_enquiry_sending");
239 var formData = jQuery(this).serializeArray();
241 name: 'data[Enquiry][websiteId]',
242 value: xChatty.config.websiteId
245 name: 'data[Enquiry][current_page]',
246 value: encodeURIComponent(encodeURIComponent(document.URL))
248 xChatty.handleAjaxSubmitCall(formData, enquiryForm);
251 handleAjaxSubmitCall: function(formData, enquiryForm) {
253 url: xChatty.config.rootPath + "submit",
256 jsonpCallback: xChatty.getJsonpCallbackName(),
257 success: function(result) {
258 if (result.success === true) {
259 jQuery(".xc_notifications_wrapper").slideUp();
260 xChatty.clearNotifications();
261 jQuery(".xc_form_enquiry")[0].reset();
262 var notifications = {
263 success: [xChatty.Lang.EnquirySubmitSuccess]
265 xChatty.renderNotifications(notifications, false);
267 xChatty.renderNotifications(result.errors, true);
269 xChatty.config.processingEnquiry = false;
270 enquiryForm.removeClass("xc_enquiry_sending");
271 jQuery(".xc_chat_container input, .xc_chat_container textarea").trigger("blur");
273 error: function(err) {
275 'message': 'Service temporarily unavailable. We back as soon as possible!'
277 xChatty.renderErrors(error, true);
278 xChatty.config.timerSendMessages = setTimeout(function() {
279 xChatty.handleAjaxSubmitCall(formData, enquiryForm);
284 onSendSubmit: function() {
285 var message = jQuery.trim(jQuery(".xc_input_message").val());
286 message = jQuery('<p>' + message + '</p>').text();
287 jQuery(".xc_input_message").val(message);
288 if (message === "" || jQuery(".xc_input_message").val() === jQuery(".xc_input_message").attr("placeholder"))
290 if (xChatty.config.processingSend)
292 var messageForm = jQuery(this);
293 messageForm.addClass("xc_message_sending");
294 xChatty.config.processingSend = true;
295 var formData = jQuery(".xc_form_reply").serializeArray();
297 name: 'data[Message][current_page]',
298 value: encodeURIComponent(encodeURIComponent(document.URL))
301 name: 'data[last_id]',
302 value: xChatty.getMaxId()
305 name: 'data[is_new_page]',
306 value: xChatty.config.isNewPage
308 xChatty.config.isNewPage = false;
309 jQuery(".xc_input_message").val("");
312 tmpMessage.id = xChatty.getMaxId() + 999;
313 tmpMessage.fullname = xChatty.config.visitor.fullname;
314 tmpMessage.body = message;
315 tmpMessage.createdAt = new Date();
316 xChatty.addMessageToChat(tmpMessage, {
319 xChatty.scrollBottom(false);
320 xChatty.handleAjaxSendCall(formData, tmpMessage, messageForm);
323 handleAjaxSendCall: function(formData, tmpMessage, messageForm) {
325 url: xChatty.config.rootPath + "send",
328 jsonpCallback: xChatty.getJsonpCallbackName(),
329 success: function(result) {
330 if (result.success === true) {
331 jQuery(".xc_notifications_wrapper").slideUp();
332 jQuery("[data-id=" + tmpMessage.id + "]").remove();
333 // xChatty.addMessageToChat(result.data);
334 xChatty.addMessageToChat(result.messages[0]);
335 for (var k = 0; k < result.messages.length; k++) {
336 xChatty.addMessageToChat(result.messages[k]);
338 if (result.messages.length > 0)
339 xChatty.scrollBottom(true);
340 xChatty.config.processingSend = false;
341 messageForm.removeClass("xc_message_sending");
343 jQuery("[data-id=" + tmpMessage.id + "]").css('border', '1px dashed #f00');
346 error: function(err) {
348 'message': 'Service temporarily unavailable. We back as soon as possible!'
350 xChatty.renderErrors(error, true);
351 xChatty.config.timerSendMessages = setTimeout(function() {
352 xChatty.handleAjaxSendCall(formData, tmpMessage, messageForm);
357 headerClick: function(e) {
359 // if (!xChatty.config.signedUp && (e.originalEvent !== undefined) && !jQuery(".xc_chat_toggle_container").is(":visible") && xChatty.config.hasSession !== true) {
360 // jQuery('<form method="post" action="' + xChatty.config.rootPath + 'discussions/session_redir"><input type="hidden" name="data[referer]" value="' + window.location + '" /></form>').submit();
362 jQuery(".xc_notification_badge_number").fadeOut();
363 jQuery(".xc_notification_badge_number").html('');
364 jQuery(".xc_chat_container").removeClass('xc_has_unread_messages');
365 if (!xChatty.config.signedUp) {
366 if (xChatty.config.isOnline) {
367 jQuery(".xc_signup_wrapper").show();
368 jQuery(".xc_conversation").hide();
369 jQuery(".xc_enquiry_wrapper").hide();
371 jQuery(".xc_enquiry_wrapper").show();
372 jQuery(".xc_signup_wrapper").hide();
373 jQuery(".xc_conversation").hide();
376 jQuery(".xc_enquiry_wrapper").hide();
377 jQuery(".xc_signup_wrapper").hide();
378 jQuery(".xc_conversation").show();
380 var wasClosed = jQuery(".xc_chat_toggle_container").is(":visible");
381 jQuery(".xc_chat_toggle_container").slideToggle("fast", function() {
382 xChatty.scrollBottom(true);
384 jQuery(".xc_chat_container").addClass("xc_box_open");
385 jQuery(".xc_chat_container").trigger("chatOpen", true);
389 jQuery(".xc_chat_container").addClass("xc_chat_closing");
390 jQuery(".xc_chat_container").animate({
395 complete: function() {
396 jQuery(".xc_chat_container").animate({
401 complete: function() {}
403 jQuery(".xc_chat_container").removeClass("xc_box_open");
404 jQuery(".xc_chat_container").removeClass("xc_chat_closing");
405 jQuery(".xc_chat_container").trigger("chatOpen", false);
409 jQuery(".xc_input_message").focus();
411 if (e.originalEvent !== undefined) {
412 xChatty.readMessages();
414 xChatty.checkStatus(true);
416 // signUpClick: function(e) {
417 // e.preventDefault();
418 // jQuery(".xc_form_signup").submit();
420 signUpSubmit: function(e) {
422 if (xChatty.config.processingSignUp)
424 var validationErrors = {};
425 var signupForm = jQuery(".xc_form_signup");
426 jQuery('.xc_form_signup input').each(function () {
427 var el = jQuery(this);
428 if ((jQuery.trim(el.val()) === '' || el.val() === el.attr('placeholder')) && el.attr('required') === 'required' ) {
429 validationErrors[el.attr('id')] = ['Please enter the field ' + el.attr('data-label')];
432 // if (jQuery.trim(jQuery(".xc_input_fullname").val()) === '' || jQuery(".xc_input_fullname").val() === jQuery(".xc_input_fullname").attr("placeholder")) {
433 // validationErrors["fullname"] = [xChatty.Lang.ValidationUsernameRequired];
435 // if (!xChatty.config.hideEmail && (jQuery.trim(jQuery(".xc_input_email").val()) === '' || jQuery(".xc_input_email").val() === jQuery(".xc_input_email").attr("placeholder"))) {
436 // validationErrors["email"] = [xChatty.Lang.ValidationEmailRequired];
438 // if (validationErrors.hasOwnProperty("fullname") || validationErrors.hasOwnProperty("email")) {
439 // xChatty.renderNotifications(validationErrors, true);
442 if (Object.keys(validationErrors).length > 0) {
443 xChatty.renderNotifications(validationErrors,true);
446 var now = new Date();
447 var dateStr = now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate() + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
448 jQuery(".xc_input_visitor_time").val(dateStr);
449 var formData = jQuery(".xc_form_signup").serializeArray();
451 name: 'chatWebsiteId' ,
452 value: xChatty.config.websiteId
454 if (xChatty.config.hideEmail) {
456 name: 'data[Discussion][email]',
457 value: 'not.provided@example.com'
461 url: xChatty.config.rootPath + "signup",
464 jsonpCallback: xChatty.getJsonpCallbackName(),
465 success: function(result) {
466 if (result.success === true) {
467 jQuery(".xc_notifications_wrapper").slideUp();
468 xChatty.config.processingSignUp = true;
469 xChatty.config.visitor.fullname = jQuery(".xc_input_fullname").val();
470 xChatty.config.visitor.avatar = CryptoJS.MD5(jQuery.trim(jQuery(".xc_input_email").val()).toLowerCase());
471 xChatty.clearNotifications();
472 // xChatty.config.signedUp = true;
473 xChatty.setHeaderText();
474 xChatty.disableSignUpForm('xc_form_signup',true);
475 xChatty.checkStatus();
477 // xChatty.handleNoAgentResponse();
479 // xChatty.readMessages();
480 // jQuery(".xc_signup_wrapper").hide();
481 // jQuery(".xc_conversation").show();
482 // xChatty.scrollBottom(false);
484 xChatty.renderNotifications(result.errors, true);
487 error: function(err) {
489 'message': 'Service temporarily unavailable. We back as soon as possible!'
491 xChatty.renderErrors(error, true);
493 complete: function() {
494 // xChatty.config.processingSignUp = false;
498 setHeaderText: function() {
499 if (xChatty.config.signedUp === true)
500 jQuery(".xc_chat_head-title").html(xChatty.Lang.HeaderCurrentlyChatting);
501 else if (xChatty.config.signedUp === false && xChatty.config.processingSignUp === true)
502 jQuery(".xc_chat_head-title").html('Waiting for connection...');
503 else if (xChatty.config.isOnline === true)
504 jQuery(".xc_chat_head-title").html(xChatty.Lang.HeaderOnline);
506 jQuery(".xc_chat_head-title").html(xChatty.Lang.HeaderOffline);
508 getHTMLTemplate: function() {
510 url: xChatty.config.rootPath + xChatty.config.websiteId + '/html',
513 success: function (data) {
514 if (jQuery(".xc_chat_container").length === 0) {
515 for (i in xChatty.Lang) {
516 data = data.replace(new RegExp("{" + i + "}", "gm"), xChatty.Lang[i]);
518 jQuery('body').append(data);
520 if (jQuery("#xc_stylesheet").length === 0) {
521 var xcCss = document.createElement('link');
522 xcCss.setAttribute('rel', 'stylesheet');
523 xcCss.type = 'text/css';
524 xcCss.id = 'xc_stylesheet';
525 xcCss.href = xChatty.config.rootPath + xChatty.config.websiteId + "/styles";
526 document.body.appendChild(xcCss);
528 if(xChatty.config.downloadTranscript) {
529 jQuery(".xc_download_transcript_container").show();
531 jQuery(".xc_download_transcript_container").hide();
533 xChatty.checkStatus();
537 checkStatus: function(async) {
538 clearTimeout(xChatty.config.timerCheckStatus);
540 if (xChatty.config.isInitialStatusCheck)
542 name: 'data[referer]',
543 value: encodeURIComponent(encodeURIComponent(document.referrer))
547 name: 'data[open_state]',
548 value: (jQuery(".xc_chat_toggle_container").is(":visible") && !jQuery(".xc_chat_container").hasClass("xc_chat_closing"))
551 url: xChatty.config.rootPath + "status",
555 jsonpCallback: xChatty.getJsonpCallbackName(),
556 success: function(result) {
557 jQuery(".xc_notifications_wrapper").slideUp();
558 var wasSignedUp = xChatty.config.signedUp;
559 if (result.success) {
560 xChatty.config.visitor.fullname = result.fullname;
561 xChatty.config.visitor.avatar = result.avatar;
562 xChatty.config.signedUp = result.signed_up;
563 xChatty.config.isOnline = result.online;
564 xChatty.config.hasSessionSaf = result.has_session_saf;
566 if (result.success && result.signed_up === false && xChatty.config.signedUp) {
567 xChatty.resetDefaultState();
569 if (xChatty.config.isOnline) {
570 jQuery(".xc_chat_container").addClass("xc_state_online").removeClass("xc_state_offline").fadeIn();
572 jQuery(".xc_chat_container").removeClass("xc_state_online").addClass("xc_state_offline");
574 if (!xChatty.config.signedUp) {
575 if (xChatty.config.isOnline) {
576 jQuery(".xc_signup_wrapper").show();
577 jQuery(".xc_conversation").hide();
578 jQuery(".xc_enquiry_wrapper").hide();
580 jQuery(".xc_enquiry_wrapper").show();
581 jQuery(".xc_signup_wrapper").hide();
582 jQuery(".xc_conversation").hide();
585 if (xChatty.config.isOnline) {
586 xChatty.clearNotifications();
588 var notifications = {
589 offline: [xChatty.Lang.OperatorOfflineMessage]
591 xChatty.renderNotifications(notifications, true);
594 var wasInitialStatusCheck = xChatty.config.isInitialStatusCheck;
595 if (xChatty.config.isInitialStatusCheck === true) {
596 xChatty.config.isInitialStatusCheck = false;
597 xChatty.config.muteNotificationSoundOnce = true;
598 xChatty.setHeaderText();
600 if (result.open_state === true) {
601 xChatty.config.restoreOpenState = true;
604 if (result.success && result.signed_up === true && wasSignedUp === false && wasInitialStatusCheck === false) {
605 jQuery(".xc_enquiry_wrapper").hide();
606 jQuery(".xc_signup_wrapper").hide();
607 jQuery(".xc_conversation").show();
608 xChatty.readMessages();
611 if(!wasSignedUp && result.signed_up === true && xChatty.config.processingSignUp) {
612 xChatty.config.processingSignUp = false;
613 xChatty.disableSignUpForm('xc_form_signup',false);
614 xChatty.setHeaderText();
617 if (!wasSignedUp && xChatty.config.processingSignUp && result.is_unserved) {
618 xChatty.config.processingSignUp = false;
620 'message': 'In this moment all agents are busy. Try again!'
622 xChatty.renderErrors(error, true);
623 xChatty.setHeaderText();
624 xChatty.disableSignUpForm('xc_form_signup',false);
627 // if(wasSignedUp && result.signed_up === true) {
628 // xChatty.readMessages(false);
629 // // var duration = xChatty.calculateTimeOutDuration();
630 // // xChatty.config.timerReadMessages = setTimeout(function() {
631 // // xChatty.readMessages(false);
636 error: function(err) {
638 'message': 'Service temporarily unavailable. We back as soon as possible!'
640 xChatty.renderErrors(error, true);
642 complete: function() {
643 xChatty.setHeaderText();
644 var duration = xChatty.calculateStatusTimeOutDuration();
645 xChatty.config.timerCheckStatus = setTimeout(function() {
646 xChatty.checkStatus(true);
651 getJsonpCallbackName: function() {
652 var callback = 'xChatty_';
653 var cStr = parseInt(new Date().getTime() / 1000).toString().substring(5) + (Math.random() + ' ').substring(5, 10);
654 var mult = parseInt(cStr.charAt(Math.floor(Math.random() * cStr.length)));
655 mult = (mult === 0 || mult === 1) ? mult + 2 : mult;
656 var cStr = mult.toString() + cStr.toString() + (cStr * mult).toString();
657 callback += cStr.toString().split("").reverse().join("");
660 timerNotifications: null,
661 renderNotifications: function(errorMessages, isError) {
663 jQuery(".xc_notifications_wrapper").removeClass("xc_notification_success");
664 jQuery(".xc_notifications_wrapper").addClass("xc_notification_error");
666 jQuery(".xc_notifications_wrapper").addClass("xc_notification_success");
667 jQuery(".xc_notifications_wrapper").removeClass("xc_notification_error");
669 jQuery(".xc_notifications_wrapper ul.xc_errorlist").html("");
670 for (k in errorMessages) {
671 for (var l = 0; l < errorMessages[k].length; l++)
672 jQuery(".xc_notifications_wrapper ul.xc_errorlist").append(jQuery("<li>" + errorMessages[k][l] + "</li>"));
674 jQuery(".xc_notifications_wrapper").slideDown();
675 clearTimeout(xChatty.timerNotifications);
676 xChatty.timerNotifications = setTimeout(function() {
677 jQuery(".xc_notifications_wrapper").slideUp();
680 renderErrors: function(error, isError) {
682 jQuery(".xc_notifications_wrapper").removeClass("xc_notification_success");
683 jQuery(".xc_notifications_wrapper").addClass("xc_notification_error");
685 jQuery(".xc_notifications_wrapper").addClass("xc_notification_success");
686 jQuery(".xc_notifications_wrapper").removeClass("xc_notification_error");
688 jQuery(".xc_notifications_wrapper ul.xc_errorlist").html("");
689 jQuery(".xc_notifications_wrapper ul.xc_errorlist").append(jQuery("<li>" + error.message + "</li>"));
690 jQuery(".xc_notifications_wrapper").slideDown();
691 // clearTimeout(xChatty.timerNotifications);
692 // xChatty.timerNotifications = setTimeout(function() {
693 // jQuery(".xc_notifications_wrapper").slideUp();
696 clearNotifications: function() {
697 jQuery(".xc_notifications_wrapper").hide();
698 jQuery(".xc_notifications_wrapper ul.xc_errorlist").html("");
700 btnNotificationsCloseClick: function(e) {
702 jQuery(".xc_notifications_wrapper").slideUp();
704 messageKeyUp: function(e) {
707 if (e.keyCode === 13 && !jQuery(this).hasClass("xc_input_enquiry_message")) {
708 jQuery(this).parents('form').submit();
711 messageKeyDownWait: false,
712 messageKeyDown: function(e) {
713 if (xChatty.messageKeyDownWait === true) {
716 xChatty.messageKeyDownWait = true;
717 setTimeout(function() {
718 xChatty.messageKeyDownWait = false;
722 // url: xChatty.config.rootPath + "discussions/composing",
723 // dataType: "jsonp",
724 // jsonpCallback: xChatty.getJsonpCallbackName(),
725 // success: function(result) {},
726 // complete: function() {}
729 sendClick: function(e) {
731 jQuery('form.xc_form_reply').submit();
733 addMessageToChat: function(message, options) {
734 var isConfirmed = "";
736 if ((typeof options !== 'undefined' && options.confirmed === false) && xChatty.config.visitor.fullname === message.fullname)
737 isConfirmed = " xc_submission_pending";
738 else if (typeof options === 'undefined' && xChatty.config.visitor.fullname === message.fullname)
739 isConfirmed = " xc_submission_confirmed";
740 if (jQuery(".xc_conversation_container [data-id=" + message.id + "]").length === 0) {
742 fullname = message.User.fullname;
744 if (message.ChatVisitor) {
745 fullname = message.ChatVisitor.fullname;
748 jQuery(".xc_conversation_container .xc_message_intro").remove();
749 var mTime = ('0' + new Date(message.createdAt).getHours()).slice(-2) + ":" + ('0' + new Date(message.createdAt).getMinutes()).slice(-2);
750 var newMessage = jQuery("<div style=\"clear: both\" class=\"xc_chatrow" + "\" data-id=\"" + message.id + "\"><div class=\"xc_time" + isConfirmed + "\">" + mTime + "</div><p><i style=\"background-image: url(http://www.gravatar.com/avatar/" + message.email + "?s=40&d=identicon);\" class=\"xc_avatar\"></i><span class=\"xc_fullname\">" + fullname + "</span> " + xChatty.prepareMessageText(message.body) + "</p></div>");
751 jQuery(".xc_conversation_container").append(newMessage);
752 jQuery('.xc_conversation_container').children().sort(function(a, b) {
753 var aF = parseInt(jQuery(a).attr("data-id"));
754 var bF = parseInt(jQuery(b).attr("data-id"));
761 }).appendTo('.xc_conversation_container');
764 prepareMessageText: function(text) {
767 s: [' :-D ', ' :D '],
771 s: [' :-S ', ' :S '],
779 s: [' ;-( ', ' ;( '],
807 s: [' :-| ', ' :| '],
815 s: [' :-P ', ' :P '],
827 s: [' :-( ', ' :( '],
831 s: [' :-) ', ' :) '],
835 s: [' :-O ', ' :O '],
851 s: [' ;-) ', ' ;) '],
855 text = " " + text + " ";
856 for (var i = 0; i < smilies.length; i++) {
857 for (var j = 0; j < smilies[i].s.length; j++) {
858 var smilie = ' <i style="background-image: url(' + ('{XC_REP}' + '?resource=smilies/' + smilies[i].r + '.png') + ');" class="xc_smilie" >' + jQuery.trim(smilies[i].s[j].toString()) + '</i> ';
859 var regex = new RegExp(xChatty.escapeRegExp(smilies[i].s[j]), 'g');
860 text = text.replace(regex, smilie);
863 var wAddress = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
864 var eAddress = /\w+@[a-zA-Z_]+?(?:\.[a-zA-Z]{2,6})+/gim;
865 text = text.replace(wAddress, '<a href="$&">$&</a>').replace(eAddress, '<a href="mailto:$&">$&</a>');
866 var tmp = jQuery("<div>" + text + "<div>");
867 tmp.find("a").each(function() {
868 if (jQuery(this).attr("href").indexOf(document.domain) === -1) {
869 jQuery(this).attr("target", "_blank").addClass("xc_link_external");
871 jQuery(this).addClass("xc_link_internal");
874 var regex = new RegExp(xChatty.escapeRegExp("{XC_REP}"), 'g');
875 text = jQuery(tmp).html().replace(regex, xChatty.config.assetBase);
876 return jQuery.trim(text).replace(/\n/g, '<br />');
878 escapeRegExp: function(str) {
879 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
881 loadMore: function() {
882 xChatty.readMessages(true);
884 readMessages: function(loadMore) {
886 // clearTimeout(xChatty.config.timerReadMessages);
887 if (!xChatty.config.signedUp) {
890 if (xChatty.config.isNewPage) {}
891 var requestData = [];
892 if (loadMore === true) {
894 name: 'data[first_id]',
895 value: xChatty.getMinId()
898 name: 'data[load_more]',
903 name: 'data[last_id]',
904 value: xChatty.getMaxId()
907 name: 'data[is_new_page]',
908 value: xChatty.config.isNewPage
913 url: xChatty.config.rootPath + "read",
915 jsonpCallback: xChatty.getJsonpCallbackName(),
916 success: function(result) {
917 if (result.success === true) {
918 jQuery(".xc_notifications_wrapper").slideUp();
919 var scrollToElem = jQuery("[data-id=" + xChatty.getMinId() + "]");
920 for (var i = 0; i < result.messages.length; i++) {
921 xChatty.addMessageToChat(result.messages[i]);
924 jQuery(".xc_btn_load_more").remove();
925 // if (result.messages.length >= 20 && jQuery(".xc_btn_load_more").length === 0) {
926 // jQuery(".xc_conversation_container").prepend(jQuery("<a href=\"#\" data-id=\"-10\" class=\"xc_btn_load_more xc_btn_style\">Load More</a>"));
927 // jQuery(".xc_btn_load_more").on("click", xChatty.loadMore);
929 if (result.composing === true && result.messages.length === 0) {
930 jQuery(".xc_composing_container").html(xChatty.Lang.OperatorComposing.replace("{fullname}", result.composing_fullname)).slideDown();
932 jQuery(".xc_composing_container").slideUp();
934 if (result.messages.length > 0) {
935 jQuery(".xc_composing_container").slideUp();
937 if (!loadMore && result.messages.length > 0) {
938 xChatty.playNotificationSound();
939 xChatty.scrollBottom(true);
940 if (!xChatty.config.isNewPage && !jQuery(".xc_conversation_container").is(":visible")) {
941 jQuery(".xc_chat_container").animate({
947 jQuery(".xc_chat_container").animate({
950 jQuery(this).animate({
953 jQuery(this).animate({
956 jQuery(this).animate({
958 }, 200, function() {});
962 jQuery(".xc_notification_badge_number").fadeIn();
963 var newVal = (isNaN(parseInt(jQuery(".xc_notification_badge_number").html())) ? 0 : parseInt(jQuery(".xc_notification_badge_number").html())) + result.messages.length;
964 jQuery(".xc_notification_badge_number").html(newVal);
965 jQuery(".xc_chat_container").addClass('xc_has_unread_messages');
967 } else if (loadMore) {
968 xChatty.scrollToElement(scrollToElem);
970 if (result.messages.length === 0)
971 xChatty.config.decayHistory++;
973 xChatty.config.decayHistory = 0;
974 // var duration = xChatty.calculateTimeOutDuration();
976 // xChatty.config.timerReadMessages = setTimeout(function() {
977 // xChatty.readMessages(false);
980 } else if (result.success === false) {
981 xChatty.checkStatus(true);
983 xChatty.config.isNewPage = false;
985 error: function(err) {
987 'message': 'Service temporarily unavailable. We back as soon as possible!'
989 xChatty.renderErrors(error, true);
991 complete: function() {
992 var duration = xChatty.calculateTimeOutDuration();
994 xChatty.config.timerReadMessages = setTimeout(function() {
995 xChatty.readMessages(false);
1001 playNotificationSound: function() {
1002 if (xChatty.config.isNewPage || (xChatty.config.windowFocused && jQuery(".xc_conversation_container").is(":visible")) || xChatty.config.muteNotificationSoundOnce) {
1003 xChatty.config.muteNotificationSoundOnce = false;
1006 jQuery("#xc_auto_tag").remove();
1007 var soundWav = xChatty.config.assetBase + "?resource=notification/xc_blubb.wav";
1008 var soundMp3 = xChatty.config.assetBase + "?resource=notification/xc_blubb.mp3";
1009 var soundOgg = xChatty.config.assetBase + "?resource=notification/xc_blubb.ogg";
1010 jQuery('<audio id="xc_auto_tag" autoplay="autoplay">').append(jQuery('<source>').attr('src', soundWav)).append(jQuery('<source>').attr('src', soundMp3)).append(jQuery('<source>').attr('src', soundOgg)).appendTo('body');
1012 calculateTimeOutDuration: function() {
1013 if (!jQuery(".xc_conversation_container").is(":visible"))
1015 var calcTimeOut = (parseFloat(xChatty.config.decayHistory / 10) * 1000);
1016 if (calcTimeOut > 10000)
1018 if (calcTimeOut > xChatty.config.defaultTimeout) {
1021 return xChatty.config.defaultTimeout;
1023 calculateStatusTimeOutDuration: function() {
1024 if (jQuery(".xc_signup_wrapper").is(":visible") && xChatty.config.processingSignUp)
1025 return xChatty.config.defaultTimeout;
1028 getMaxId: function() {
1029 if (jQuery(".xc_chatrow").length === 0)
1031 var numbers = jQuery(".xc_chatrow").map(function() {
1032 return parseFloat(this.getAttribute('data-id')) || -Infinity;
1034 return Math.max.apply(Math, numbers);
1036 getMinId: function() {
1037 if (jQuery(".xc_chatrow").length === 0)
1039 var numbers = jQuery(".xc_chatrow").map(function() {
1040 return parseFloat(this.getAttribute('data-id')) || -Infinity;
1042 return Math.min.apply(Math, numbers);
1044 scrollBottom: function(animate) {
1046 jQuery(".xc_conversation_container").scrollTop(jQuery(".xc_conversation_container")[0].scrollHeight);
1048 jQuery(".xc_conversation_container").animate({
1049 scrollTop: jQuery(".xc_conversation_container")[0].scrollHeight
1052 scrollToElement: function(elem) {
1053 var offset = jQuery(elem).offset().top + (jQuery(elem).height() * 2) - jQuery(".xc_conversation_container").height();
1054 jQuery(".xc_conversation_container").animate({
1058 disableSignUpForm: function(form, enable)Â {
1059 jQuery("." + form + " :input").attr("disabled", enable);
1060 jQuery("." + form + " :button").prop("disabled", enable);
1062 browserTest: function(test) {
1063 var isOpera = !!(window.opera && window.opera.version);
1064 var isFirefox = xChatty.testStyle('MozBoxSizing');
1065 var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
1066 var isChrome = !isSafari && xChatty.testStyle('WebkitTransform');
1067 var isIE = false || xChatty.testStyle('msTransform');
1068 var browserValue = {
1070 'Firefox': isFirefox,
1075 return browserValue[test];
1077 testStyle: function(property) {
1078 return property in document.documentElement.style;
1080 checkIfMobileDevice: function() {
1081 var n = (navigator.userAgent || navigator.vendor || window.opera);
1082 return /android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge|maemo|midp|mmp|netfront|opera m(ob|in)i|palm(os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows(ce|phone)|xda|xiino/i.test(n) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(n.substr(0, 4));
1086 function xcLoadJS(xcCallback) {
1087 var script = document.createElement("script")
1088 script.type = "text/javascript";
1089 if (script.readyState) {
1090 script.onreadystatechange = function() {
1091 if (script.readyState == "loaded" || script.readyState == "complete") {
1092 script.onreadystatechange = null;
1097 script.onload = function() {
1101 script.src = "http://code.jquery.com/jquery-2.1.4.min.js";
1102 var ph = document.getElementsByTagName('script')[0];
1103 ph.parentNode.insertBefore(script, ph);
1107 if (typeof jQuery == 'undefined') {
1108 xcLoadJS(function() {
1110 jQuery(document).ready(function() {
1111 xChatty.getHTMLTemplate();
1117 jQuery(document).ready(function() {
1118 xChatty.getHTMLTemplate();
1125 * The code below this is not covered by the CodeCanyon Regular License.
1126 * Feel free to re-use the code below as per your requirements whilst following
1127 * the respective licensing terms.
1131 code.google.com/p/crypto-js
1132 (c) 2009-2013 by Jeff Mott. All rights reserved.
1133 code.google.com/p/crypto-js/wiki/License
1135 var CryptoJS = CryptoJS || function(s, p) {
1140 extend: function(b) {
1144 h.hasOwnProperty("init") || (h.init = function() {
1145 h.$super.init.apply(this, arguments)
1147 h.init.prototype = h;
1151 create: function() {
1152 var b = this.extend();
1153 b.init.apply(b, arguments);
1156 init: function() {},
1157 mixIn: function(b) {
1158 for (var h in b) b.hasOwnProperty(h) && (this[h] = b[h]);
1159 b.hasOwnProperty("toString") && (this.toString = b.toString)
1162 return this.init.prototype.extend(this)
1165 q = l.WordArray = r.extend({
1166 init: function(b, h) {
1167 b = this.words = b || [];
1168 this.sigBytes = h != p ? h : 4 * b.length
1170 toString: function(b) {
1171 return (b || t).stringify(this)
1173 concat: function(b) {
1180 for (var g = 0; g < b; g++) h[j + g >>> 2] |= (a[g >>> 2] >>> 24 - 8 * (g % 4) & 255) << 24 - 8 * ((j + g) % 4);
1181 else if (65535 < a.length)
1182 for (g = 0; g < b; g += 4) h[j + g >>> 2] = a[g >>> 2];
1183 else h.push.apply(h, a);
1190 b[h >>> 2] &= 4294967295 << 32 - 8 * (h % 4);
1191 b.length = s.ceil(h / 4)
1194 var b = r.clone.call(this);
1195 b.words = this.words.slice(0);
1198 random: function(b) {
1199 for (var h = [], a = 0; a < b; a += 4) h.push(4294967296 * s.random() | 0);
1200 return new q.init(h, b)
1205 stringify: function(b) {
1208 for (var g = [], j = 0; j < b; j++) {
1209 var k = a[j >>> 2] >>> 24 - 8 * (j % 4) & 255;
1210 g.push((k >>> 4).toString(16));
1211 g.push((k & 15).toString(16))
1215 parse: function(b) {
1216 for (var a = b.length, g = [], j = 0; j < a; j += 2) g[j >>> 3] |= parseInt(b.substr(j, 2), 16) << 24 - 4 * (j % 8);
1217 return new q.init(g, a / 2)
1221 stringify: function(b) {
1224 for (var g = [], j = 0; j < b; j++) g.push(String.fromCharCode(a[j >>> 2] >>> 24 - 8 * (j % 4) & 255));
1227 parse: function(b) {
1228 for (var a = b.length, g = [], j = 0; j < a; j++) g[j >>> 2] |= (b.charCodeAt(j) & 255) << 24 - 8 * (j % 4);
1229 return new q.init(g, a)
1233 stringify: function(b) {
1235 return decodeURIComponent(escape(a.stringify(b)))
1237 throw Error("Malformed UTF-8 data");
1240 parse: function(b) {
1241 return a.parse(unescape(encodeURIComponent(b)))
1244 g = l.BufferedBlockAlgorithm = r.extend({
1246 this._data = new q.init;
1247 this._nDataBytes = 0
1249 _append: function(b) {
1250 "string" == typeof b && (b = u.parse(b));
1251 this._data.concat(b);
1252 this._nDataBytes += b.sigBytes
1254 _process: function(b) {
1260 m = b ? s.ceil(m) : s.max((m | 0) - this._minBufferSize, 0);
1262 j = s.min(4 * b, j);
1264 for (var l = 0; l < b; l += k) this._doProcessBlock(g, l);
1268 return new q.init(l, j)
1271 var b = r.clone.call(this);
1272 b._data = this._data.clone();
1277 l.Hasher = g.extend({
1280 this.cfg = this.cfg.extend(b);
1287 update: function(b) {
1292 finalize: function(b) {
1293 b && this._append(b);
1294 return this._doFinalize()
1297 _createHelper: function(b) {
1298 return function(a, g) {
1299 return (new b.init(g)).finalize(a)
1302 _createHmacHelper: function(b) {
1303 return function(a, g) {
1304 return (new k.HMAC.init(b, g)).finalize(a)
1308 var k = m.algo = {};
1312 function p(a, k, b, h, l, j, m) {
1313 a = a + (k & b | ~k & h) + l + m;
1314 return (a << j | a >>> 32 - j) + k
1317 function m(a, k, b, h, l, j, m) {
1318 a = a + (k & h | b & ~h) + l + m;
1319 return (a << j | a >>> 32 - j) + k
1322 function l(a, k, b, h, l, j, m) {
1323 a = a + (k ^ b ^ h) + l + m;
1324 return (a << j | a >>> 32 - j) + k
1327 function n(a, k, b, h, l, j, m) {
1328 a = a + (b ^ (k | ~h)) + l + m;
1329 return (a << j | a >>> 32 - j) + k
1331 for (var r = CryptoJS, q = r.lib, v = q.WordArray, t = q.Hasher, q = r.algo, a = [], u = 0; 64 > u; u++) a[u] = 4294967296 * s.abs(s.sin(u + 1)) | 0;
1332 q = q.MD5 = t.extend({
1333 _doReset: function() {
1334 this._hash = new v.init([1422584193, 4023233417, 2562383102, 271423878])
1336 _doProcessBlock: function(g, k) {
1337 for (var b = 0; 16 > b; b++) {
1340 g[h] = (w << 8 | w >>> 24) & 16711935 | (w << 24 | w >>> 8) & 4278255360
1342 var b = this._hash.words,
1363 c = p(c, d, e, f, h, 7, a[0]),
1364 f = p(f, c, d, e, w, 12, a[1]),
1365 e = p(e, f, c, d, j, 17, a[2]),
1366 d = p(d, e, f, c, q, 22, a[3]),
1367 c = p(c, d, e, f, r, 7, a[4]),
1368 f = p(f, c, d, e, s, 12, a[5]),
1369 e = p(e, f, c, d, t, 17, a[6]),
1370 d = p(d, e, f, c, u, 22, a[7]),
1371 c = p(c, d, e, f, v, 7, a[8]),
1372 f = p(f, c, d, e, x, 12, a[9]),
1373 e = p(e, f, c, d, y, 17, a[10]),
1374 d = p(d, e, f, c, z, 22, a[11]),
1375 c = p(c, d, e, f, A, 7, a[12]),
1376 f = p(f, c, d, e, B, 12, a[13]),
1377 e = p(e, f, c, d, C, 17, a[14]),
1378 d = p(d, e, f, c, D, 22, a[15]),
1379 c = m(c, d, e, f, w, 5, a[16]),
1380 f = m(f, c, d, e, t, 9, a[17]),
1381 e = m(e, f, c, d, z, 14, a[18]),
1382 d = m(d, e, f, c, h, 20, a[19]),
1383 c = m(c, d, e, f, s, 5, a[20]),
1384 f = m(f, c, d, e, y, 9, a[21]),
1385 e = m(e, f, c, d, D, 14, a[22]),
1386 d = m(d, e, f, c, r, 20, a[23]),
1387 c = m(c, d, e, f, x, 5, a[24]),
1388 f = m(f, c, d, e, C, 9, a[25]),
1389 e = m(e, f, c, d, q, 14, a[26]),
1390 d = m(d, e, f, c, v, 20, a[27]),
1391 c = m(c, d, e, f, B, 5, a[28]),
1392 f = m(f, c, d, e, j, 9, a[29]),
1393 e = m(e, f, c, d, u, 14, a[30]),
1394 d = m(d, e, f, c, A, 20, a[31]),
1395 c = l(c, d, e, f, s, 4, a[32]),
1396 f = l(f, c, d, e, v, 11, a[33]),
1397 e = l(e, f, c, d, z, 16, a[34]),
1398 d = l(d, e, f, c, C, 23, a[35]),
1399 c = l(c, d, e, f, w, 4, a[36]),
1400 f = l(f, c, d, e, r, 11, a[37]),
1401 e = l(e, f, c, d, u, 16, a[38]),
1402 d = l(d, e, f, c, y, 23, a[39]),
1403 c = l(c, d, e, f, B, 4, a[40]),
1404 f = l(f, c, d, e, h, 11, a[41]),
1405 e = l(e, f, c, d, q, 16, a[42]),
1406 d = l(d, e, f, c, t, 23, a[43]),
1407 c = l(c, d, e, f, x, 4, a[44]),
1408 f = l(f, c, d, e, A, 11, a[45]),
1409 e = l(e, f, c, d, D, 16, a[46]),
1410 d = l(d, e, f, c, j, 23, a[47]),
1411 c = n(c, d, e, f, h, 6, a[48]),
1412 f = n(f, c, d, e, u, 10, a[49]),
1413 e = n(e, f, c, d, C, 15, a[50]),
1414 d = n(d, e, f, c, s, 21, a[51]),
1415 c = n(c, d, e, f, A, 6, a[52]),
1416 f = n(f, c, d, e, q, 10, a[53]),
1417 e = n(e, f, c, d, y, 15, a[54]),
1418 d = n(d, e, f, c, w, 21, a[55]),
1419 c = n(c, d, e, f, v, 6, a[56]),
1420 f = n(f, c, d, e, D, 10, a[57]),
1421 e = n(e, f, c, d, t, 15, a[58]),
1422 d = n(d, e, f, c, B, 21, a[59]),
1423 c = n(c, d, e, f, r, 6, a[60]),
1424 f = n(f, c, d, e, z, 10, a[61]),
1425 e = n(e, f, c, d, j, 15, a[62]),
1426 d = n(d, e, f, c, x, 21, a[63]);
1427 b[0] = b[0] + c | 0;
1428 b[1] = b[1] + d | 0;
1429 b[2] = b[2] + e | 0;
1432 _doFinalize: function() {
1435 b = 8 * this._nDataBytes,
1437 k[h >>> 5] |= 128 << 24 - h % 32;
1438 var l = s.floor(b / 4294967296);
1439 k[(h + 64 >>> 9 << 4) + 15] = (l << 8 | l >>> 24) & 16711935 | (l << 24 | l >>> 8) & 4278255360;
1440 k[(h + 64 >>> 9 << 4) + 14] = (b << 8 | b >>> 24) & 16711935 | (b << 24 | b >>> 8) & 4278255360;
1441 a.sigBytes = 4 * (k.length + 1);
1445 for (b = 0; 4 > b; b++) h = k[b], k[b] = (h << 8 | h >>> 24) & 16711935 | (h << 24 | h >>> 8) & 4278255360;
1449 var a = t.clone.call(this);
1450 a._hash = this._hash.clone();
1454 r.MD5 = t._createHelper(q);
1455 r.HmacMD5 = t._createHmacHelper(q)