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) {
169 // e.preventDefault();
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 removeOldMessages: function () {
207 jQuery(".xc_conversation_container").empty();
208 jQuery(".xc_conversation_container").html('<p class="xc_message_intro" data-id="-10">' + xChatty.Lang.FirstMessageText + '</p>');
210 resetDefaultState: function() {
211 xChatty.config.signedUp = false;
212 xChatty.config.visitor = {
216 jQuery(".xc_conversation_container").empty();
217 jQuery(".xc_conversation_container").html('<p class="xc_message_intro" data-id="-10">' + xChatty.Lang.FirstMessageText + '</p>');
218 jQuery(".xc_exit_chat_confirmation_wrapper").hide();
219 jQuery(".xc_btn_exit_chat").show();
220 jQuery(".xc_chat_head").trigger("click");
222 enquirySubmit: function(e) {
224 if (xChatty.config.processingEnquiry)
226 var validationErrors = {};
227 var signupForm = jQuery(".xc_form_enquiry");
228 jQuery('.xc_form_enquiry :input').each(function () {
229 var el = jQuery(this);
230 if (el.val() === el.attr('placeholder')) {
233 if ((jQuery.trim(el.val()) === '' || el.val() === el.attr('placeholder')) && el.attr('required') === 'required' ) {
234 validationErrors[el.attr('id')] = ['Please enter the field ' + el.attr('data-label')];
237 // if (jQuery.trim(jQuery(".xc_input_enquiry_fullname").val()) === '' || jQuery(".xc_input_enquiry_fullname").val() === jQuery(".xc_input_enquiry_fullname").attr("placeholder")) {
238 // validationErrors["fullname"] = [xChatty.Lang.ValidationUsernameRequired];
240 // if (jQuery.trim(jQuery(".xc_input_enquiry_email").val()) === '' || jQuery(".xc_input_enquiry_email").val() === jQuery(".xc_input_enquiry_email").attr("placeholder")) {
241 // validationErrors["email"] = [xChatty.Lang.ValidationEmailRequired];
243 // if (jQuery.trim(jQuery(".xc_input_enquiry_message").val()) === '' || jQuery(".xc_input_enquiry_message").val() === jQuery(".xc_input_enquiry_message").attr("placeholder")) {
244 // validationErrors["message"] = [xChatty.Lang.ValidationEnquiryRequired];
246 // if (validationErrors.hasOwnProperty("fullname") || validationErrors.hasOwnProperty("email") || validationErrors.hasOwnProperty("message")) {
247 // xChatty.renderNotifications(validationErrors, true);
250 if (Object.keys(validationErrors).length > 0) {
251 xChatty.renderNotifications(validationErrors,true);
254 xChatty.config.processingEnquiry = true;
255 var enquiryForm = jQuery(this);
256 enquiryForm.addClass("xc_enquiry_sending");
257 var formData = jQuery(this).serializeArray();
259 name: 'data[Enquiry][websiteId]',
260 value: xChatty.config.websiteId
263 name: 'data[Enquiry][current_page]',
264 value: encodeURIComponent(encodeURIComponent(document.URL))
266 xChatty.handleAjaxSubmitCall(formData, enquiryForm);
269 handleAjaxSubmitCall: function(formData, enquiryForm) {
271 url: xChatty.config.rootPath + "submit",
274 jsonpCallback: xChatty.getJsonpCallbackName(),
275 success: function(result) {
276 if (result.success === true) {
277 jQuery(".xc_notifications_wrapper").slideUp();
278 xChatty.clearNotifications();
279 jQuery(".xc_form_enquiry")[0].reset();
280 var notifications = {
281 success: [xChatty.Lang.EnquirySubmitSuccess]
283 xChatty.renderNotifications(notifications, false);
285 xChatty.renderNotifications(result.errors, true);
287 xChatty.config.processingEnquiry = false;
288 enquiryForm.removeClass("xc_enquiry_sending");
289 jQuery(".xc_chat_container input, .xc_chat_container textarea").trigger("blur");
291 error: function(err) {
293 'message': 'Service temporarily unavailable. We back as soon as possible!'
295 xChatty.renderErrors(error, true);
296 xChatty.config.timerSendMessages = setTimeout(function() {
297 xChatty.handleAjaxSubmitCall(formData, enquiryForm);
302 onSendSubmit: function() {
303 var message = jQuery.trim(jQuery(".xc_input_message").val());
304 message = jQuery('<p>' + message + '</p>').text();
305 jQuery(".xc_input_message").val(message);
306 if (message === "" || jQuery(".xc_input_message").val() === jQuery(".xc_input_message").attr("placeholder"))
308 if (xChatty.config.processingSend)
310 var messageForm = jQuery(this);
311 messageForm.addClass("xc_message_sending");
312 xChatty.config.processingSend = true;
313 var formData = jQuery(".xc_form_reply").serializeArray();
315 name: 'data[Message][current_page]',
316 value: encodeURIComponent(encodeURIComponent(document.URL))
319 name: 'data[last_id]',
320 value: xChatty.getMaxId()
323 name: 'data[is_new_page]',
324 value: xChatty.config.isNewPage
326 xChatty.config.isNewPage = false;
327 jQuery(".xc_input_message").val("");
330 tmpMessage.id = xChatty.getMaxId() + 999;
331 tmpMessage.fullname = xChatty.config.visitor.fullname;
332 tmpMessage.body = message;
333 tmpMessage.createdAt = new Date();
334 xChatty.addMessageToChat(tmpMessage, {
337 xChatty.scrollBottom(false);
338 xChatty.handleAjaxSendCall(formData, tmpMessage, messageForm);
341 handleAjaxSendCall: function(formData, tmpMessage, messageForm) {
343 url: xChatty.config.rootPath + "send",
346 jsonpCallback: xChatty.getJsonpCallbackName(),
347 success: function(result) {
348 if (result.success === true) {
349 jQuery(".xc_notifications_wrapper").slideUp();
350 jQuery("[data-id=" + tmpMessage.id + "]").remove();
351 // xChatty.addMessageToChat(result.data);
352 xChatty.addMessageToChat(result.messages[0]);
353 for (var k = 0; k < result.messages.length; k++) {
354 xChatty.addMessageToChat(result.messages[k]);
356 if (result.messages.length > 0)
357 xChatty.scrollBottom(true);
358 xChatty.config.processingSend = false;
359 messageForm.removeClass("xc_message_sending");
361 jQuery("[data-id=" + tmpMessage.id + "]").css('border', '1px dashed #f00');
364 error: function(err) {
366 'message': 'Service temporarily unavailable. We back as soon as possible!'
368 xChatty.renderErrors(error, true);
369 xChatty.config.timerSendMessages = setTimeout(function() {
370 xChatty.handleAjaxSendCall(formData, tmpMessage, messageForm);
375 headerClick: function(e) {
377 // if (!xChatty.config.signedUp && (e.originalEvent !== undefined) && !jQuery(".xc_chat_toggle_container").is(":visible") && xChatty.config.hasSession !== true) {
378 // jQuery('<form method="post" action="' + xChatty.config.rootPath + 'discussions/session_redir"><input type="hidden" name="data[referer]" value="' + window.location + '" /></form>').submit();
380 jQuery(".xc_notification_badge_number").fadeOut();
381 jQuery(".xc_notification_badge_number").html('');
382 jQuery(".xc_chat_container").removeClass('xc_has_unread_messages');
383 if (!xChatty.config.signedUp) {
384 if (xChatty.config.isOnline) {
385 jQuery(".xc_signup_wrapper").show();
386 jQuery(".xc_conversation").hide();
387 jQuery(".xc_enquiry_wrapper").hide();
389 jQuery(".xc_enquiry_wrapper").show();
390 jQuery(".xc_signup_wrapper").hide();
391 jQuery(".xc_conversation").hide();
394 jQuery(".xc_enquiry_wrapper").hide();
395 jQuery(".xc_signup_wrapper").hide();
396 jQuery(".xc_conversation").show();
398 var wasClosed = jQuery(".xc_chat_toggle_container").is(":visible");
399 jQuery(".xc_chat_toggle_container").slideToggle("fast", function() {
400 xChatty.scrollBottom(true);
402 jQuery(".xc_chat_container").addClass("xc_box_open");
403 jQuery(".xc_chat_container").trigger("chatOpen", true);
407 jQuery(".xc_chat_container").addClass("xc_chat_closing");
408 jQuery(".xc_chat_container").animate({
413 complete: function() {
414 jQuery(".xc_chat_container").animate({
419 complete: function() {}
421 jQuery(".xc_chat_container").removeClass("xc_box_open");
422 jQuery(".xc_chat_container").removeClass("xc_chat_closing");
423 jQuery(".xc_chat_container").trigger("chatOpen", false);
427 jQuery(".xc_input_message").focus();
429 if (e.originalEvent !== undefined) {
430 xChatty.readMessages();
432 xChatty.checkStatus(true);
434 // signUpClick: function(e) {
435 // e.preventDefault();
436 // jQuery(".xc_form_signup").submit();
438 signUpSubmit: function(e) {
440 if (xChatty.config.processingSignUp)
442 var validationErrors = {};
443 var signupForm = jQuery(".xc_form_signup");
444 jQuery('.xc_form_signup :input').each(function () {
445 var el = jQuery(this);
446 if (el.val() === el.attr('placeholder')) {
449 if ((jQuery.trim(el.val()) === '' || el.val() === el.attr('placeholder')) && el.attr('required') === 'required' ) {
450 validationErrors[el.attr('id')] = ['Please enter the field ' + el.attr('data-label')];
453 // if (jQuery.trim(jQuery(".xc_input_fullname").val()) === '' || jQuery(".xc_input_fullname").val() === jQuery(".xc_input_fullname").attr("placeholder")) {
454 // validationErrors["fullname"] = [xChatty.Lang.ValidationUsernameRequired];
456 // if (!xChatty.config.hideEmail && (jQuery.trim(jQuery(".xc_input_email").val()) === '' || jQuery(".xc_input_email").val() === jQuery(".xc_input_email").attr("placeholder"))) {
457 // validationErrors["email"] = [xChatty.Lang.ValidationEmailRequired];
459 // if (validationErrors.hasOwnProperty("fullname") || validationErrors.hasOwnProperty("email")) {
460 // xChatty.renderNotifications(validationErrors, true);
463 if (Object.keys(validationErrors).length > 0) {
464 xChatty.renderNotifications(validationErrors,true);
467 var now = new Date();
468 var dateStr = now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate() + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
469 jQuery(".xc_input_visitor_time").val(dateStr);
470 var formData = jQuery(".xc_form_signup").serializeArray();
472 name: 'chatWebsiteId' ,
473 value: xChatty.config.websiteId
475 if (xChatty.config.hideEmail) {
477 name: 'data[Discussion][email]',
478 value: 'not.provided@example.com'
482 url: xChatty.config.rootPath + "signup",
485 jsonpCallback: xChatty.getJsonpCallbackName(),
486 success: function(result) {
487 if (result.success === true) {
488 jQuery(".xc_notifications_wrapper").slideUp();
489 xChatty.config.processingSignUp = true;
490 xChatty.config.visitor.fullname = jQuery(".xc_input_fullname").val();
491 xChatty.config.visitor.avatar = CryptoJS.MD5(jQuery.trim(jQuery(".xc_input_email").val()).toLowerCase());
492 xChatty.clearNotifications();
493 // xChatty.config.signedUp = true;
494 xChatty.setHeaderText();
495 xChatty.disableSignUpForm('xc_form_signup',true);
496 xChatty.removeOldMessages();
497 xChatty.checkStatus();
499 // xChatty.handleNoAgentResponse();
501 // xChatty.readMessages();
502 // jQuery(".xc_signup_wrapper").hide();
503 // jQuery(".xc_conversation").show();
504 // xChatty.scrollBottom(false);
506 xChatty.renderNotifications(result.errors, true);
509 error: function(err) {
511 'message': 'Service temporarily unavailable. We back as soon as possible!'
513 xChatty.renderErrors(error, true);
515 complete: function() {
516 // xChatty.config.processingSignUp = false;
520 setHeaderText: function() {
521 if (xChatty.config.signedUp === true)
522 jQuery(".xc_chat_head-title").html(xChatty.Lang.HeaderCurrentlyChatting);
523 else if (xChatty.config.signedUp === false && xChatty.config.processingSignUp === true)
524 jQuery(".xc_chat_head-title").html('Waiting for connection...');
525 else if (xChatty.config.isOnline === true)
526 jQuery(".xc_chat_head-title").html(xChatty.Lang.HeaderOnline);
528 jQuery(".xc_chat_head-title").html(xChatty.Lang.HeaderOffline);
530 getHTMLTemplate: function() {
532 url: xChatty.config.rootPath + xChatty.config.websiteId + '/html',
535 success: function (data) {
536 if (jQuery(".xc_chat_container").length === 0) {
537 for (i in xChatty.Lang) {
538 data = data.replace(new RegExp("{" + i + "}", "gm"), xChatty.Lang[i]);
540 jQuery('body').append(data);
542 if (jQuery("#xc_stylesheet").length === 0) {
543 var xcCss = document.createElement('link');
544 xcCss.setAttribute('rel', 'stylesheet');
545 xcCss.type = 'text/css';
546 xcCss.id = 'xc_stylesheet';
547 xcCss.href = xChatty.config.rootPath + xChatty.config.websiteId + "/styles";
548 document.body.appendChild(xcCss);
550 if(xChatty.config.downloadTranscript) {
551 jQuery(".xc_download_transcript_container").show();
553 jQuery(".xc_download_transcript_container").hide();
555 xChatty.checkStatus();
559 checkStatus: function(async) {
560 clearTimeout(xChatty.config.timerCheckStatus);
562 if (xChatty.config.isInitialStatusCheck)
564 name: 'data[referer]',
565 value: encodeURIComponent(encodeURIComponent(document.referrer))
569 name: 'data[open_state]',
570 value: (jQuery(".xc_chat_toggle_container").is(":visible") && !jQuery(".xc_chat_container").hasClass("xc_chat_closing"))
573 url: xChatty.config.rootPath + "status",
577 jsonpCallback: xChatty.getJsonpCallbackName(),
578 success: function(result) {
579 jQuery(".xc_notifications_wrapper").slideUp();
580 var wasSignedUp = xChatty.config.signedUp;
581 if (result.success) {
582 xChatty.config.visitor.fullname = result.fullname;
583 xChatty.config.visitor.avatar = result.avatar;
584 xChatty.config.signedUp = result.signed_up;
585 xChatty.config.isOnline = result.online;
586 xChatty.config.hasSessionSaf = result.has_session_saf;
588 if (result.success && result.signed_up === false && xChatty.config.signedUp) {
589 xChatty.resetDefaultState();
591 if (xChatty.config.isOnline) {
592 jQuery(".xc_chat_container").addClass("xc_state_online").removeClass("xc_state_offline").fadeIn();
594 jQuery(".xc_chat_container").removeClass("xc_state_online").addClass("xc_state_offline");
596 if (!xChatty.config.signedUp) {
597 if (xChatty.config.isOnline) {
598 jQuery(".xc_signup_wrapper").show();
599 jQuery(".xc_conversation").hide();
600 jQuery(".xc_enquiry_wrapper").hide();
602 jQuery(".xc_enquiry_wrapper").show();
603 jQuery(".xc_signup_wrapper").hide();
604 jQuery(".xc_conversation").hide();
607 if (xChatty.config.isOnline) {
608 xChatty.clearNotifications();
610 var notifications = {
611 offline: [xChatty.Lang.OperatorOfflineMessage]
613 xChatty.renderNotifications(notifications, true);
616 var wasInitialStatusCheck = xChatty.config.isInitialStatusCheck;
617 if (xChatty.config.isInitialStatusCheck === true) {
618 xChatty.config.isInitialStatusCheck = false;
619 xChatty.config.muteNotificationSoundOnce = true;
620 xChatty.setHeaderText();
622 if (result.open_state === true) {
623 xChatty.config.restoreOpenState = true;
626 if (result.success && result.signed_up === true && wasSignedUp === false && wasInitialStatusCheck === false) {
627 jQuery(".xc_enquiry_wrapper").hide();
628 jQuery(".xc_signup_wrapper").hide();
629 jQuery(".xc_conversation").show();
630 xChatty.readMessages();
633 if(!wasSignedUp && result.signed_up === true && xChatty.config.processingSignUp) {
634 xChatty.config.processingSignUp = false;
635 xChatty.disableSignUpForm('xc_form_signup',false);
636 xChatty.setHeaderText();
639 if (!wasSignedUp && xChatty.config.processingSignUp && result.is_unserved) {
640 xChatty.config.processingSignUp = false;
642 'message': 'In this moment all agents are busy. Try again!'
644 xChatty.renderErrors(error, true);
645 xChatty.setHeaderText();
646 xChatty.disableSignUpForm('xc_form_signup',false);
649 // if(wasSignedUp && result.signed_up === true) {
650 // xChatty.readMessages(false);
651 // // var duration = xChatty.calculateTimeOutDuration();
652 // // xChatty.config.timerReadMessages = setTimeout(function() {
653 // // xChatty.readMessages(false);
658 error: function(err) {
660 'message': 'Service temporarily unavailable. We back as soon as possible!'
662 xChatty.renderErrors(error, true);
664 complete: function() {
665 xChatty.setHeaderText();
666 var duration = xChatty.calculateStatusTimeOutDuration();
667 xChatty.config.timerCheckStatus = setTimeout(function() {
668 xChatty.checkStatus(true);
673 getJsonpCallbackName: function() {
674 var callback = 'xChatty_';
675 var cStr = parseInt(new Date().getTime() / 1000).toString().substring(5) + (Math.random() + ' ').substring(5, 10);
676 var mult = parseInt(cStr.charAt(Math.floor(Math.random() * cStr.length)));
677 mult = (mult === 0 || mult === 1) ? mult + 2 : mult;
678 var cStr = mult.toString() + cStr.toString() + (cStr * mult).toString();
679 callback += cStr.toString().split("").reverse().join("");
682 timerNotifications: null,
683 renderNotifications: function(errorMessages, isError) {
685 jQuery(".xc_notifications_wrapper").removeClass("xc_notification_success");
686 jQuery(".xc_notifications_wrapper").addClass("xc_notification_error");
688 jQuery(".xc_notifications_wrapper").addClass("xc_notification_success");
689 jQuery(".xc_notifications_wrapper").removeClass("xc_notification_error");
691 jQuery(".xc_notifications_wrapper ul.xc_errorlist").html("");
692 for (k in errorMessages) {
693 for (var l = 0; l < errorMessages[k].length; l++)
694 jQuery(".xc_notifications_wrapper ul.xc_errorlist").append(jQuery("<li>" + errorMessages[k][l] + "</li>"));
696 jQuery(".xc_notifications_wrapper").slideDown();
697 clearTimeout(xChatty.timerNotifications);
698 xChatty.timerNotifications = setTimeout(function() {
699 jQuery(".xc_notifications_wrapper").slideUp();
702 renderErrors: function(error, isError) {
704 jQuery(".xc_notifications_wrapper").removeClass("xc_notification_success");
705 jQuery(".xc_notifications_wrapper").addClass("xc_notification_error");
707 jQuery(".xc_notifications_wrapper").addClass("xc_notification_success");
708 jQuery(".xc_notifications_wrapper").removeClass("xc_notification_error");
710 jQuery(".xc_notifications_wrapper ul.xc_errorlist").html("");
711 jQuery(".xc_notifications_wrapper ul.xc_errorlist").append(jQuery("<li>" + error.message + "</li>"));
712 jQuery(".xc_notifications_wrapper").slideDown();
713 // clearTimeout(xChatty.timerNotifications);
714 // xChatty.timerNotifications = setTimeout(function() {
715 // jQuery(".xc_notifications_wrapper").slideUp();
718 clearNotifications: function() {
719 jQuery(".xc_notifications_wrapper").hide();
720 jQuery(".xc_notifications_wrapper ul.xc_errorlist").html("");
722 btnNotificationsCloseClick: function(e) {
724 jQuery(".xc_notifications_wrapper").slideUp();
726 messageKeyUp: function(e) {
729 if (e.keyCode === 13 && !jQuery(this).hasClass("xc_input_enquiry_message")) {
730 jQuery(this).parents('form').submit();
733 messageKeyDownWait: false,
734 messageKeyDown: function(e) {
735 if (xChatty.messageKeyDownWait === true) {
738 xChatty.messageKeyDownWait = true;
739 setTimeout(function() {
740 xChatty.messageKeyDownWait = false;
744 // url: xChatty.config.rootPath + "discussions/composing",
745 // dataType: "jsonp",
746 // jsonpCallback: xChatty.getJsonpCallbackName(),
747 // success: function(result) {},
748 // complete: function() {}
751 sendClick: function(e) {
753 jQuery('form.xc_form_reply').submit();
755 addMessageToChat: function(message, options) {
756 var isConfirmed = "";
758 if ((typeof options !== 'undefined' && options.confirmed === false) && xChatty.config.visitor.fullname === message.fullname)
759 isConfirmed = " xc_submission_pending";
760 else if (typeof options === 'undefined' && xChatty.config.visitor.fullname === message.fullname)
761 isConfirmed = " xc_submission_confirmed";
762 if (jQuery(".xc_conversation_container [data-id=" + message.id + "]").length === 0) {
764 fullname = message.User.fullname;
766 if (message.ChatVisitor) {
767 fullname = message.ChatVisitor.fullname;
770 jQuery(".xc_conversation_container .xc_message_intro").remove();
771 var mTime = ('0' + new Date(message.createdAt).getHours()).slice(-2) + ":" + ('0' + new Date(message.createdAt).getMinutes()).slice(-2);
772 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>");
773 jQuery(".xc_conversation_container").append(newMessage);
774 jQuery('.xc_conversation_container').children().sort(function(a, b) {
775 var aF = parseInt(jQuery(a).attr("data-id"));
776 var bF = parseInt(jQuery(b).attr("data-id"));
783 }).appendTo('.xc_conversation_container');
786 prepareMessageText: function(text) {
789 s: [' :-D ', ' :D '],
793 s: [' :-S ', ' :S '],
801 s: [' ;-( ', ' ;( '],
829 s: [' :-| ', ' :| '],
837 s: [' :-P ', ' :P '],
849 s: [' :-( ', ' :( '],
853 s: [' :-) ', ' :) '],
857 s: [' :-O ', ' :O '],
873 s: [' ;-) ', ' ;) '],
877 text = " " + text + " ";
878 for (var i = 0; i < smilies.length; i++) {
879 for (var j = 0; j < smilies[i].s.length; j++) {
880 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> ';
881 var regex = new RegExp(xChatty.escapeRegExp(smilies[i].s[j]), 'g');
882 text = text.replace(regex, smilie);
885 var wAddress = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
886 var eAddress = /\w+@[a-zA-Z_]+?(?:\.[a-zA-Z]{2,6})+/gim;
887 text = text.replace(wAddress, '<a href="$&">$&</a>').replace(eAddress, '<a href="mailto:$&">$&</a>');
888 var tmp = jQuery("<div>" + text + "<div>");
889 tmp.find("a").each(function() {
890 if (jQuery(this).attr("href").indexOf(document.domain) === -1) {
891 jQuery(this).attr("target", "_blank").addClass("xc_link_external");
893 jQuery(this).addClass("xc_link_internal");
896 var regex = new RegExp(xChatty.escapeRegExp("{XC_REP}"), 'g');
897 text = jQuery(tmp).html().replace(regex, xChatty.config.assetBase);
898 return jQuery.trim(text).replace(/\n/g, '<br />');
900 escapeRegExp: function(str) {
901 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
903 loadMore: function() {
904 xChatty.readMessages(true);
906 readMessages: function(loadMore) {
908 // clearTimeout(xChatty.config.timerReadMessages);
909 if (!xChatty.config.signedUp) {
912 if (xChatty.config.isNewPage) {}
913 var requestData = [];
914 if (loadMore === true) {
916 name: 'data[first_id]',
917 value: xChatty.getMinId()
920 name: 'data[load_more]',
925 name: 'data[last_id]',
926 value: xChatty.getMaxId()
929 name: 'data[is_new_page]',
930 value: xChatty.config.isNewPage
935 url: xChatty.config.rootPath + "read",
937 jsonpCallback: xChatty.getJsonpCallbackName(),
938 success: function(result) {
939 if (result.success === true) {
940 jQuery(".xc_notifications_wrapper").slideUp();
941 var scrollToElem = jQuery("[data-id=" + xChatty.getMinId() + "]");
942 for (var i = 0; i < result.messages.length; i++) {
943 xChatty.addMessageToChat(result.messages[i]);
946 jQuery(".xc_btn_load_more").remove();
947 // if (result.messages.length >= 20 && jQuery(".xc_btn_load_more").length === 0) {
948 // jQuery(".xc_conversation_container").prepend(jQuery("<a href=\"#\" data-id=\"-10\" class=\"xc_btn_load_more xc_btn_style\">Load More</a>"));
949 // jQuery(".xc_btn_load_more").on("click", xChatty.loadMore);
951 if (result.composing === true && result.messages.length === 0) {
952 jQuery(".xc_composing_container").html(xChatty.Lang.OperatorComposing.replace("{fullname}", result.composing_fullname)).slideDown();
954 jQuery(".xc_composing_container").slideUp();
956 if (result.messages.length > 0) {
957 jQuery(".xc_composing_container").slideUp();
959 if (!loadMore && result.messages.length > 0) {
960 xChatty.playNotificationSound();
961 xChatty.scrollBottom(true);
962 if (!xChatty.config.isNewPage && !jQuery(".xc_conversation_container").is(":visible")) {
963 jQuery(".xc_chat_container").animate({
969 jQuery(".xc_chat_container").animate({
972 jQuery(this).animate({
975 jQuery(this).animate({
978 jQuery(this).animate({
980 }, 200, function() {});
984 jQuery(".xc_notification_badge_number").fadeIn();
985 var newVal = (isNaN(parseInt(jQuery(".xc_notification_badge_number").html())) ? 0 : parseInt(jQuery(".xc_notification_badge_number").html())) + result.messages.length;
986 jQuery(".xc_notification_badge_number").html(newVal);
987 jQuery(".xc_chat_container").addClass('xc_has_unread_messages');
989 } else if (loadMore) {
990 xChatty.scrollToElement(scrollToElem);
992 if (result.messages.length === 0)
993 xChatty.config.decayHistory++;
995 xChatty.config.decayHistory = 0;
996 // var duration = xChatty.calculateTimeOutDuration();
998 // xChatty.config.timerReadMessages = setTimeout(function() {
999 // xChatty.readMessages(false);
1002 } else if (result.success === false) {
1003 xChatty.checkStatus(true);
1005 xChatty.config.isNewPage = false;
1007 error: function(err) {
1009 'message': 'Service temporarily unavailable. We back as soon as possible!'
1011 xChatty.renderErrors(error, true);
1013 complete: function() {
1014 var duration = xChatty.calculateTimeOutDuration();
1016 xChatty.config.timerReadMessages = setTimeout(function() {
1017 xChatty.readMessages(false);
1023 playNotificationSound: function() {
1024 if (xChatty.config.isNewPage || (xChatty.config.windowFocused && jQuery(".xc_conversation_container").is(":visible")) || xChatty.config.muteNotificationSoundOnce) {
1025 xChatty.config.muteNotificationSoundOnce = false;
1028 jQuery("#xc_auto_tag").remove();
1029 var soundWav = xChatty.config.assetBase + "?resource=notification/xc_blubb.wav";
1030 var soundMp3 = xChatty.config.assetBase + "?resource=notification/xc_blubb.mp3";
1031 var soundOgg = xChatty.config.assetBase + "?resource=notification/xc_blubb.ogg";
1032 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');
1034 calculateTimeOutDuration: function() {
1035 if (!jQuery(".xc_conversation_container").is(":visible"))
1037 var calcTimeOut = (parseFloat(xChatty.config.decayHistory / 10) * 1000);
1038 if (calcTimeOut > 10000)
1040 if (calcTimeOut > xChatty.config.defaultTimeout) {
1043 return xChatty.config.defaultTimeout;
1045 calculateStatusTimeOutDuration: function() {
1046 if (jQuery(".xc_signup_wrapper").is(":visible") && xChatty.config.processingSignUp)
1047 return xChatty.config.defaultTimeout;
1050 getMaxId: function() {
1051 if (jQuery(".xc_chatrow").length === 0)
1053 var numbers = jQuery(".xc_chatrow").map(function() {
1054 return parseFloat(this.getAttribute('data-id')) || -Infinity;
1056 return Math.max.apply(Math, numbers);
1058 getMinId: function() {
1059 if (jQuery(".xc_chatrow").length === 0)
1061 var numbers = jQuery(".xc_chatrow").map(function() {
1062 return parseFloat(this.getAttribute('data-id')) || -Infinity;
1064 return Math.min.apply(Math, numbers);
1066 scrollBottom: function(animate) {
1068 jQuery(".xc_conversation_container").scrollTop(jQuery(".xc_conversation_container")[0].scrollHeight);
1070 jQuery(".xc_conversation_container").animate({
1071 scrollTop: jQuery(".xc_conversation_container")[0].scrollHeight
1074 scrollToElement: function(elem) {
1075 var offset = jQuery(elem).offset().top + (jQuery(elem).height() * 2) - jQuery(".xc_conversation_container").height();
1076 jQuery(".xc_conversation_container").animate({
1080 disableSignUpForm: function(form, enable)Â {
1081 jQuery("." + form + " :input").attr("disabled", enable);
1082 jQuery("." + form + " :button").prop("disabled", enable);
1084 browserTest: function(test) {
1085 var isOpera = !!(window.opera && window.opera.version);
1086 var isFirefox = xChatty.testStyle('MozBoxSizing');
1087 var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
1088 var isChrome = !isSafari && xChatty.testStyle('WebkitTransform');
1089 var isIE = false || xChatty.testStyle('msTransform');
1090 var browserValue = {
1092 'Firefox': isFirefox,
1097 return browserValue[test];
1099 testStyle: function(property) {
1100 return property in document.documentElement.style;
1102 checkIfMobileDevice: function() {
1103 var n = (navigator.userAgent || navigator.vendor || window.opera);
1104 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));
1108 function xcLoadJS(xcCallback) {
1109 var script = document.createElement("script")
1110 script.type = "text/javascript";
1111 if (script.readyState) {
1112 script.onreadystatechange = function() {
1113 if (script.readyState == "loaded" || script.readyState == "complete") {
1114 script.onreadystatechange = null;
1119 script.onload = function() {
1123 script.src = "http://code.jquery.com/jquery-2.1.4.min.js";
1124 var ph = document.getElementsByTagName('script')[0];
1125 ph.parentNode.insertBefore(script, ph);
1129 if (typeof jQuery == 'undefined') {
1130 xcLoadJS(function() {
1132 jQuery(document).ready(function() {
1133 xChatty.getHTMLTemplate();
1139 jQuery(document).ready(function() {
1140 xChatty.getHTMLTemplate();
1147 * The code below this is not covered by the CodeCanyon Regular License.
1148 * Feel free to re-use the code below as per your requirements whilst following
1149 * the respective licensing terms.
1153 code.google.com/p/crypto-js
1154 (c) 2009-2013 by Jeff Mott. All rights reserved.
1155 code.google.com/p/crypto-js/wiki/License
1157 var CryptoJS = CryptoJS || function(s, p) {
1162 extend: function(b) {
1166 h.hasOwnProperty("init") || (h.init = function() {
1167 h.$super.init.apply(this, arguments)
1169 h.init.prototype = h;
1173 create: function() {
1174 var b = this.extend();
1175 b.init.apply(b, arguments);
1178 init: function() {},
1179 mixIn: function(b) {
1180 for (var h in b) b.hasOwnProperty(h) && (this[h] = b[h]);
1181 b.hasOwnProperty("toString") && (this.toString = b.toString)
1184 return this.init.prototype.extend(this)
1187 q = l.WordArray = r.extend({
1188 init: function(b, h) {
1189 b = this.words = b || [];
1190 this.sigBytes = h != p ? h : 4 * b.length
1192 toString: function(b) {
1193 return (b || t).stringify(this)
1195 concat: function(b) {
1202 for (var g = 0; g < b; g++) h[j + g >>> 2] |= (a[g >>> 2] >>> 24 - 8 * (g % 4) & 255) << 24 - 8 * ((j + g) % 4);
1203 else if (65535 < a.length)
1204 for (g = 0; g < b; g += 4) h[j + g >>> 2] = a[g >>> 2];
1205 else h.push.apply(h, a);
1212 b[h >>> 2] &= 4294967295 << 32 - 8 * (h % 4);
1213 b.length = s.ceil(h / 4)
1216 var b = r.clone.call(this);
1217 b.words = this.words.slice(0);
1220 random: function(b) {
1221 for (var h = [], a = 0; a < b; a += 4) h.push(4294967296 * s.random() | 0);
1222 return new q.init(h, b)
1227 stringify: function(b) {
1230 for (var g = [], j = 0; j < b; j++) {
1231 var k = a[j >>> 2] >>> 24 - 8 * (j % 4) & 255;
1232 g.push((k >>> 4).toString(16));
1233 g.push((k & 15).toString(16))
1237 parse: function(b) {
1238 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);
1239 return new q.init(g, a / 2)
1243 stringify: function(b) {
1246 for (var g = [], j = 0; j < b; j++) g.push(String.fromCharCode(a[j >>> 2] >>> 24 - 8 * (j % 4) & 255));
1249 parse: function(b) {
1250 for (var a = b.length, g = [], j = 0; j < a; j++) g[j >>> 2] |= (b.charCodeAt(j) & 255) << 24 - 8 * (j % 4);
1251 return new q.init(g, a)
1255 stringify: function(b) {
1257 return decodeURIComponent(escape(a.stringify(b)))
1259 throw Error("Malformed UTF-8 data");
1262 parse: function(b) {
1263 return a.parse(unescape(encodeURIComponent(b)))
1266 g = l.BufferedBlockAlgorithm = r.extend({
1268 this._data = new q.init;
1269 this._nDataBytes = 0
1271 _append: function(b) {
1272 "string" == typeof b && (b = u.parse(b));
1273 this._data.concat(b);
1274 this._nDataBytes += b.sigBytes
1276 _process: function(b) {
1282 m = b ? s.ceil(m) : s.max((m | 0) - this._minBufferSize, 0);
1284 j = s.min(4 * b, j);
1286 for (var l = 0; l < b; l += k) this._doProcessBlock(g, l);
1290 return new q.init(l, j)
1293 var b = r.clone.call(this);
1294 b._data = this._data.clone();
1299 l.Hasher = g.extend({
1302 this.cfg = this.cfg.extend(b);
1309 update: function(b) {
1314 finalize: function(b) {
1315 b && this._append(b);
1316 return this._doFinalize()
1319 _createHelper: function(b) {
1320 return function(a, g) {
1321 return (new b.init(g)).finalize(a)
1324 _createHmacHelper: function(b) {
1325 return function(a, g) {
1326 return (new k.HMAC.init(b, g)).finalize(a)
1330 var k = m.algo = {};
1334 function p(a, k, b, h, l, j, m) {
1335 a = a + (k & b | ~k & h) + l + m;
1336 return (a << j | a >>> 32 - j) + k
1339 function m(a, k, b, h, l, j, m) {
1340 a = a + (k & h | b & ~h) + l + m;
1341 return (a << j | a >>> 32 - j) + k
1344 function l(a, k, b, h, l, j, m) {
1345 a = a + (k ^ b ^ h) + l + m;
1346 return (a << j | a >>> 32 - j) + k
1349 function n(a, k, b, h, l, j, m) {
1350 a = a + (b ^ (k | ~h)) + l + m;
1351 return (a << j | a >>> 32 - j) + k
1353 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;
1354 q = q.MD5 = t.extend({
1355 _doReset: function() {
1356 this._hash = new v.init([1422584193, 4023233417, 2562383102, 271423878])
1358 _doProcessBlock: function(g, k) {
1359 for (var b = 0; 16 > b; b++) {
1362 g[h] = (w << 8 | w >>> 24) & 16711935 | (w << 24 | w >>> 8) & 4278255360
1364 var b = this._hash.words,
1385 c = p(c, d, e, f, h, 7, a[0]),
1386 f = p(f, c, d, e, w, 12, a[1]),
1387 e = p(e, f, c, d, j, 17, a[2]),
1388 d = p(d, e, f, c, q, 22, a[3]),
1389 c = p(c, d, e, f, r, 7, a[4]),
1390 f = p(f, c, d, e, s, 12, a[5]),
1391 e = p(e, f, c, d, t, 17, a[6]),
1392 d = p(d, e, f, c, u, 22, a[7]),
1393 c = p(c, d, e, f, v, 7, a[8]),
1394 f = p(f, c, d, e, x, 12, a[9]),
1395 e = p(e, f, c, d, y, 17, a[10]),
1396 d = p(d, e, f, c, z, 22, a[11]),
1397 c = p(c, d, e, f, A, 7, a[12]),
1398 f = p(f, c, d, e, B, 12, a[13]),
1399 e = p(e, f, c, d, C, 17, a[14]),
1400 d = p(d, e, f, c, D, 22, a[15]),
1401 c = m(c, d, e, f, w, 5, a[16]),
1402 f = m(f, c, d, e, t, 9, a[17]),
1403 e = m(e, f, c, d, z, 14, a[18]),
1404 d = m(d, e, f, c, h, 20, a[19]),
1405 c = m(c, d, e, f, s, 5, a[20]),
1406 f = m(f, c, d, e, y, 9, a[21]),
1407 e = m(e, f, c, d, D, 14, a[22]),
1408 d = m(d, e, f, c, r, 20, a[23]),
1409 c = m(c, d, e, f, x, 5, a[24]),
1410 f = m(f, c, d, e, C, 9, a[25]),
1411 e = m(e, f, c, d, q, 14, a[26]),
1412 d = m(d, e, f, c, v, 20, a[27]),
1413 c = m(c, d, e, f, B, 5, a[28]),
1414 f = m(f, c, d, e, j, 9, a[29]),
1415 e = m(e, f, c, d, u, 14, a[30]),
1416 d = m(d, e, f, c, A, 20, a[31]),
1417 c = l(c, d, e, f, s, 4, a[32]),
1418 f = l(f, c, d, e, v, 11, a[33]),
1419 e = l(e, f, c, d, z, 16, a[34]),
1420 d = l(d, e, f, c, C, 23, a[35]),
1421 c = l(c, d, e, f, w, 4, a[36]),
1422 f = l(f, c, d, e, r, 11, a[37]),
1423 e = l(e, f, c, d, u, 16, a[38]),
1424 d = l(d, e, f, c, y, 23, a[39]),
1425 c = l(c, d, e, f, B, 4, a[40]),
1426 f = l(f, c, d, e, h, 11, a[41]),
1427 e = l(e, f, c, d, q, 16, a[42]),
1428 d = l(d, e, f, c, t, 23, a[43]),
1429 c = l(c, d, e, f, x, 4, a[44]),
1430 f = l(f, c, d, e, A, 11, a[45]),
1431 e = l(e, f, c, d, D, 16, a[46]),
1432 d = l(d, e, f, c, j, 23, a[47]),
1433 c = n(c, d, e, f, h, 6, a[48]),
1434 f = n(f, c, d, e, u, 10, a[49]),
1435 e = n(e, f, c, d, C, 15, a[50]),
1436 d = n(d, e, f, c, s, 21, a[51]),
1437 c = n(c, d, e, f, A, 6, a[52]),
1438 f = n(f, c, d, e, q, 10, a[53]),
1439 e = n(e, f, c, d, y, 15, a[54]),
1440 d = n(d, e, f, c, w, 21, a[55]),
1441 c = n(c, d, e, f, v, 6, a[56]),
1442 f = n(f, c, d, e, D, 10, a[57]),
1443 e = n(e, f, c, d, t, 15, a[58]),
1444 d = n(d, e, f, c, B, 21, a[59]),
1445 c = n(c, d, e, f, r, 6, a[60]),
1446 f = n(f, c, d, e, z, 10, a[61]),
1447 e = n(e, f, c, d, j, 15, a[62]),
1448 d = n(d, e, f, c, x, 21, a[63]);
1449 b[0] = b[0] + c | 0;
1450 b[1] = b[1] + d | 0;
1451 b[2] = b[2] + e | 0;
1454 _doFinalize: function() {
1457 b = 8 * this._nDataBytes,
1459 k[h >>> 5] |= 128 << 24 - h % 32;
1460 var l = s.floor(b / 4294967296);
1461 k[(h + 64 >>> 9 << 4) + 15] = (l << 8 | l >>> 24) & 16711935 | (l << 24 | l >>> 8) & 4278255360;
1462 k[(h + 64 >>> 9 << 4) + 14] = (b << 8 | b >>> 24) & 16711935 | (b << 24 | b >>> 8) & 4278255360;
1463 a.sigBytes = 4 * (k.length + 1);
1467 for (b = 0; 4 > b; b++) h = k[b], k[b] = (h << 8 | h >>> 24) & 16711935 | (h << 24 | h >>> 8) & 4278255360;
1471 var a = t.clone.call(this);
1472 a._hash = this._hash.clone();
1476 r.MD5 = t._createHelper(q);
1477 r.HmacMD5 = t._createHmacHelper(q)