2015-09-16 06:28:00 +00:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
|
|
|
*/
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
window.Whisper = window.Whisper || {};
|
|
|
|
|
2016-04-10 01:33:47 +00:00
|
|
|
Whisper.DebugLogLinkView = Whisper.View.extend({
|
|
|
|
templateName: 'debug-log-link',
|
|
|
|
initialize: function(options) {
|
|
|
|
this.url = options.url;
|
|
|
|
},
|
|
|
|
render_attributes: function() {
|
2016-04-10 03:36:50 +00:00
|
|
|
return {
|
|
|
|
url: this.url,
|
|
|
|
reportIssue: i18n('reportIssue')
|
|
|
|
};
|
2016-04-10 01:33:47 +00:00
|
|
|
}
|
|
|
|
});
|
2015-09-16 06:28:00 +00:00
|
|
|
Whisper.DebugLogView = Whisper.View.extend({
|
|
|
|
templateName: 'debug-log',
|
2016-02-19 19:26:32 +00:00
|
|
|
className: 'debug-log modal',
|
2015-09-16 06:28:00 +00:00
|
|
|
initialize: function() {
|
|
|
|
this.render();
|
2017-10-04 21:40:35 +00:00
|
|
|
this.$('textarea').val(i18n('loading'));
|
|
|
|
|
|
|
|
window.log.fetch().then(function(text) {
|
|
|
|
this.$('textarea').val(text);
|
|
|
|
}.bind(this));
|
2015-09-16 06:28:00 +00:00
|
|
|
},
|
|
|
|
events: {
|
2016-02-22 20:17:54 +00:00
|
|
|
'click .submit': 'submit',
|
2015-09-16 06:28:00 +00:00
|
|
|
'click .close': 'close'
|
|
|
|
},
|
2015-12-26 07:01:22 +00:00
|
|
|
render_attributes: {
|
|
|
|
title: i18n('submitDebugLog'),
|
|
|
|
cancel: i18n('cancel'),
|
|
|
|
submit: i18n('submit'),
|
|
|
|
close: i18n('gotIt'),
|
|
|
|
debugLogExplanation: i18n('debugLogExplanation')
|
|
|
|
},
|
2015-09-16 06:28:00 +00:00
|
|
|
close: function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
this.remove();
|
|
|
|
},
|
|
|
|
submit: function(e) {
|
|
|
|
e.preventDefault();
|
2017-09-25 22:00:19 +00:00
|
|
|
var text = this.$('textarea').val();
|
|
|
|
if (text.length === 0) {
|
2016-02-22 21:58:47 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-09-25 22:00:19 +00:00
|
|
|
log.publish(text).then(function(url) {
|
2016-04-10 01:33:47 +00:00
|
|
|
var view = new Whisper.DebugLogLinkView({
|
|
|
|
url: url,
|
|
|
|
el: this.$('.result')
|
|
|
|
});
|
2016-02-22 20:43:05 +00:00
|
|
|
this.$('.loading').removeClass('loading');
|
2016-04-10 01:33:47 +00:00
|
|
|
view.render();
|
|
|
|
this.$('.link').focus().select();
|
2015-09-16 06:28:00 +00:00
|
|
|
}.bind(this));
|
2016-02-22 20:43:05 +00:00
|
|
|
this.$('.buttons, textarea').remove();
|
|
|
|
this.$('.result').addClass('loading');
|
2015-09-16 06:28:00 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
})();
|