Fixed naming and /ws location for web sockets.

This commit is contained in:
Martin Edenhofer 2015-11-25 12:44:26 +01:00
parent 66d56ff9e2
commit f41ef67dab
3 changed files with 72 additions and 72 deletions

View file

@ -8,7 +8,7 @@ do($ = window.jQuery, window) ->
class ZammadChat class ZammadChat
defaults: defaults:
chat_id: undefined chatId: undefined
show: true show: true
target: $('body') target: $('body')
host: '' host: ''
@ -80,9 +80,9 @@ do($ = window.jQuery, window) ->
@log 'notice', 'Chat: Browser not supported!' @log 'notice', 'Chat: Browser not supported!'
return return
if !options.chat_id if !options.chatId
@state = 'unsupported' @state = 'unsupported'
@log 'error', 'Chat: need chat id as option!' @log 'error', 'Chat: need chatId as option!'
return return
@options = $.extend {}, @defaults, options @options = $.extend {}, @defaults, options
@ -111,7 +111,7 @@ do($ = window.jQuery, window) ->
@sendMessage() @sendMessage()
send: (event, data = {}) => send: (event, data = {}) =>
data.chat_id = @options.chat_id data.chat_id = @options.chatId
@log 'debug', 'ws:send', event, data @log 'debug', 'ws:send', event, data
pipe = JSON.stringify pipe = JSON.stringify
event: event event: event
@ -447,7 +447,7 @@ do($ = window.jQuery, window) ->
protocol = 'ws://' protocol = 'ws://'
if window.location.protocol is 'https:' if window.location.protocol is 'https:'
protocol = 'wss://' protocol = 'wss://'
@options.host = "#{ protocol }#{ scriptHost }" @options.host = "#{ protocol }#{ scriptHost }/ws"
wsConnect: => wsConnect: =>
@detectHost() if !@options.host @detectHost() if !@options.host

View file

@ -8,7 +8,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
scriptHost = myScript.src.match('.*://([^:/]*).*')[1]; scriptHost = myScript.src.match('.*://([^:/]*).*')[1];
ZammadChat = (function() { ZammadChat = (function() {
ZammadChat.prototype.defaults = { ZammadChat.prototype.defaults = {
chat_id: void 0, chatId: void 0,
show: true, show: true,
target: $('body'), target: $('body'),
host: '', host: '',
@ -139,9 +139,9 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
this.log('notice', 'Chat: Browser not supported!'); this.log('notice', 'Chat: Browser not supported!');
return; return;
} }
if (!options.chat_id) { if (!options.chatId) {
this.state = 'unsupported'; this.state = 'unsupported';
this.log('error', 'Chat: need chat id as option!'); this.log('error', 'Chat: need chatId as option!');
return; return;
} }
this.options = $.extend({}, this.defaults, options); this.options = $.extend({}, this.defaults, options);
@ -173,7 +173,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
if (data == null) { if (data == null) {
data = {}; data = {};
} }
data.chat_id = this.options.chat_id; data.chat_id = this.options.chatId;
this.log('debug', 'ws:send', event, data); this.log('debug', 'ws:send', event, data);
pipe = JSON.stringify({ pipe = JSON.stringify({
event: event, event: event,
@ -551,7 +551,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
if (window.location.protocol === 'https:') { if (window.location.protocol === 'https:') {
protocol = 'wss://'; protocol = 'wss://';
} }
return this.options.host = "" + protocol + scriptHost; return this.options.host = "" + protocol + scriptHost + "/ws";
}; };
ZammadChat.prototype.wsConnect = function() { ZammadChat.prototype.wsConnect = function() {
@ -683,67 +683,6 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
return window.ZammadChat = ZammadChat; return window.ZammadChat = ZammadChat;
})(window.jQuery, window); })(window.jQuery, window);
if (!window.zammadChatTemplates) {
window.zammadChatTemplates = {};
}
window.zammadChatTemplates["agent"] = function (__obj) {
if (!__obj) __obj = {};
var __out = [], __capture = function(callback) {
var out = __out, result;
__out = [];
callback.call(this);
result = __out.join('');
__out = out;
return __safe(result);
}, __sanitize = function(value) {
if (value && value.ecoSafe) {
return value;
} else if (typeof value !== 'undefined' && value != null) {
return __escape(value);
} else {
return '';
}
}, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
__safe = __obj.safe = function(value) {
if (value && value.ecoSafe) {
return value;
} else {
if (!(typeof value !== 'undefined' && value != null)) value = '';
var result = new String(value);
result.ecoSafe = true;
return result;
}
};
if (!__escape) {
__escape = __obj.escape = function(value) {
return ('' + value)
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
};
}
(function() {
(function() {
if (this.agent.avatar) {
__out.push('\n<img class="zammad-chat-agent-avatar" src="');
__out.push(__sanitize(this.agent.avatar));
__out.push('">\n');
}
__out.push('\n<span class="zammad-chat-agent-sentence">\n <span class="zammad-chat-agent-name">');
__out.push(__sanitize(this.agent.name));
__out.push('</span>\n</span>');
}).call(this);
}).call(__obj);
__obj.safe = __objSafe, __obj.escape = __escape;
return __out.join('');
};
/*! /*!
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42): * "THE BEER-WARE LICENSE" (Revision 42):
@ -821,6 +760,67 @@ jQuery.fn.autoGrow = function(options) {
}); });
}; };
if (!window.zammadChatTemplates) {
window.zammadChatTemplates = {};
}
window.zammadChatTemplates["agent"] = function (__obj) {
if (!__obj) __obj = {};
var __out = [], __capture = function(callback) {
var out = __out, result;
__out = [];
callback.call(this);
result = __out.join('');
__out = out;
return __safe(result);
}, __sanitize = function(value) {
if (value && value.ecoSafe) {
return value;
} else if (typeof value !== 'undefined' && value != null) {
return __escape(value);
} else {
return '';
}
}, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
__safe = __obj.safe = function(value) {
if (value && value.ecoSafe) {
return value;
} else {
if (!(typeof value !== 'undefined' && value != null)) value = '';
var result = new String(value);
result.ecoSafe = true;
return result;
}
};
if (!__escape) {
__escape = __obj.escape = function(value) {
return ('' + value)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
};
}
(function() {
(function() {
if (this.agent.avatar) {
__out.push('\n<img class="zammad-chat-agent-avatar" src="');
__out.push(__sanitize(this.agent.avatar));
__out.push('">\n');
}
__out.push('\n<span class="zammad-chat-agent-sentence">\n <span class="zammad-chat-agent-name">');
__out.push(__sanitize(this.agent.name));
__out.push('</span>\n</span>');
}).call(this);
}).call(__obj);
__obj.safe = __objSafe, __obj.escape = __escape;
return __out.join('');
};
if (!window.zammadChatTemplates) { if (!window.zammadChatTemplates) {
window.zammadChatTemplates = {}; window.zammadChatTemplates = {};
} }

File diff suppressed because one or more lines are too long