mirror of https://github.com/zulip/zulip.git
eslint: Enable space-infix-ops rule.
More about rule at https://eslint.org/docs/rules/space-infix-ops
This commit is contained in:
parent
c6738889a9
commit
cc03f9fb8f
|
@ -361,7 +361,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"space-in-parens": 2,
|
"space-in-parens": 2,
|
||||||
"space-infix-ops": 0,
|
"space-infix-ops": 2,
|
||||||
"spaced-comment": 0,
|
"spaced-comment": 0,
|
||||||
"strict": 0,
|
"strict": 0,
|
||||||
"template-curly-spacing": "error",
|
"template-curly-spacing": "error",
|
||||||
|
|
|
@ -166,7 +166,7 @@ exports.select_item_via_typeahead = function (field_selector, str, item) {
|
||||||
|
|
||||||
var tah = $(field_selector).data().typeahead;
|
var tah = $(field_selector).data().typeahead;
|
||||||
tah.mouseenter({
|
tah.mouseenter({
|
||||||
currentTarget: $('.typeahead:visible li:contains("'+item+'")')[0],
|
currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0],
|
||||||
});
|
});
|
||||||
tah.select();
|
tah.select();
|
||||||
}, {field_selector:field_selector, str: str, item: item});
|
}, {field_selector:field_selector, str: str, item: item});
|
||||||
|
@ -271,7 +271,7 @@ exports.then_send_message = function (type, params) {
|
||||||
// 'table' here).
|
// 'table' here).
|
||||||
exports.get_rendered_messages = function (table) {
|
exports.get_rendered_messages = function (table) {
|
||||||
return casper.evaluate(function (table) {
|
return casper.evaluate(function (table) {
|
||||||
var tbl = $('#'+table);
|
var tbl = $('#' + table);
|
||||||
return {
|
return {
|
||||||
headings: $.map(tbl.find('.recipient_row .message-header-contents'), function (elem) {
|
headings: $.map(tbl.find('.recipient_row .message-header-contents'), function (elem) {
|
||||||
var $clone = $(elem).clone(true);
|
var $clone = $(elem).clone(true);
|
||||||
|
@ -349,7 +349,7 @@ exports.trim = function (str) {
|
||||||
// Call get_rendered_messages and then check that the last few headings and
|
// Call get_rendered_messages and then check that the last few headings and
|
||||||
// bodies match the specified arrays.
|
// bodies match the specified arrays.
|
||||||
exports.expected_messages = function (table, headings, bodies) {
|
exports.expected_messages = function (table, headings, bodies) {
|
||||||
casper.test.assertVisible('#'+table, table + ' is visible');
|
casper.test.assertVisible('#' + table, table + ' is visible');
|
||||||
|
|
||||||
var msg = exports.get_rendered_messages(table);
|
var msg = exports.get_rendered_messages(table);
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ function search_silent_user(str, item) {
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
casper.waitUntilVisible('#silent_user', function () {
|
casper.waitUntilVisible('#silent_user', function () {
|
||||||
casper.test.info("Empty feed for silent user visible.");
|
casper.test.info("Empty feed for silent user visible.");
|
||||||
var expected_message = "\n You haven't received any messages sent by this user yet!"+
|
var expected_message = "\n You haven't received any messages sent by this user yet!" +
|
||||||
"\n ";
|
"\n ";
|
||||||
this.test.assertEquals(casper.fetchText('#silent_user'), expected_message);
|
this.test.assertEquals(casper.fetchText('#silent_user'), expected_message);
|
||||||
});
|
});
|
||||||
|
@ -192,7 +192,7 @@ function search_non_existing_user(str, item) {
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
casper.waitUntilVisible('#non_existing_user', function () {
|
casper.waitUntilVisible('#non_existing_user', function () {
|
||||||
casper.test.info("Empty feed for non existing user visible.");
|
casper.test.info("Empty feed for non existing user visible.");
|
||||||
var expected_message = "\n This user does not exist!"+
|
var expected_message = "\n This user does not exist!" +
|
||||||
"\n ";
|
"\n ";
|
||||||
this.test.assertEquals(casper.fetchText('#non_existing_user'), expected_message);
|
this.test.assertEquals(casper.fetchText('#non_existing_user'), expected_message);
|
||||||
});
|
});
|
||||||
|
|
|
@ -299,7 +299,7 @@ function select_from_suggestions(item) {
|
||||||
casper.evaluate(function (item) {
|
casper.evaluate(function (item) {
|
||||||
var tah = $('.create_default_stream').data().typeahead;
|
var tah = $('.create_default_stream').data().typeahead;
|
||||||
tah.mouseenter({
|
tah.mouseenter({
|
||||||
currentTarget: $('.typeahead:visible li:contains("'+item+'")')[0],
|
currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0],
|
||||||
});
|
});
|
||||||
tah.select();
|
tah.select();
|
||||||
}, {item: item});
|
}, {item: item});
|
||||||
|
@ -320,21 +320,21 @@ casper.then(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
casper.waitUntilVisible('.default_stream_row[id='+stream_name+']', function () {
|
casper.waitUntilVisible('.default_stream_row[id=' + stream_name + ']', function () {
|
||||||
casper.test.assertSelectorHasText('.default_stream_row[id='+stream_name+'] .default_stream_name', stream_name);
|
casper.test.assertSelectorHasText('.default_stream_row[id=' + stream_name + '] .default_stream_name', stream_name);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
casper.waitUntilVisible('.default_stream_row[id='+stream_name+']', function () {
|
casper.waitUntilVisible('.default_stream_row[id=' + stream_name + ']', function () {
|
||||||
casper.test.assertSelectorHasText('.default_stream_row[id='+stream_name+'] .default_stream_name', stream_name);
|
casper.test.assertSelectorHasText('.default_stream_row[id=' + stream_name + '] .default_stream_name', stream_name);
|
||||||
casper.click('.default_stream_row[id='+stream_name+'] button.remove-default-stream');
|
casper.click('.default_stream_row[id=' + stream_name + '] button.remove-default-stream');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
casper.waitWhileVisible('.default_stream_row[id='+stream_name+']', function () {
|
casper.waitWhileVisible('.default_stream_row[id=' + stream_name + ']', function () {
|
||||||
casper.test.assertDoesntExist('.default_stream_row[id='+stream_name+']');
|
casper.test.assertDoesntExist('.default_stream_row[id=' + stream_name + ']');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -387,8 +387,8 @@ function simulate_list_items(items) {
|
||||||
$('#user_presences').set_find_results('li.user_sidebar_entry', list);
|
$('#user_presences').set_find_results('li.user_sidebar_entry', list);
|
||||||
|
|
||||||
_.each(items, (item, i) => {
|
_.each(items, (item, i) => {
|
||||||
item.next = () => items[i+1] || {length: 0};
|
item.next = () => items[i + 1] || {length: 0};
|
||||||
item.prev = () => items[i-1] || {length: 0};
|
item.prev = () => items[i - 1] || {length: 0};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -349,8 +349,8 @@ run_test('markdown_shortcuts', () => {
|
||||||
global.document.execCommand = function (cmd, bool, markdown) {
|
global.document.execCommand = function (cmd, bool, markdown) {
|
||||||
var compose_textarea = $("#compose-textarea");
|
var compose_textarea = $("#compose-textarea");
|
||||||
var value = compose_textarea.val();
|
var value = compose_textarea.val();
|
||||||
$("#compose-textarea").val(value.substring(0, compose_textarea.range().start)+
|
$("#compose-textarea").val(value.substring(0, compose_textarea.range().start) +
|
||||||
markdown+value.substring(compose_textarea.range().end, value.length));
|
markdown + value.substring(compose_textarea.range().end, value.length));
|
||||||
};
|
};
|
||||||
|
|
||||||
$("#compose-textarea").range = function () {
|
$("#compose-textarea").range = function () {
|
||||||
|
@ -359,7 +359,7 @@ run_test('markdown_shortcuts', () => {
|
||||||
end: range_start + range_length,
|
end: range_start + range_length,
|
||||||
length: range_length,
|
length: range_length,
|
||||||
range: noop,
|
range: noop,
|
||||||
text: $("#compose-textarea").val().substring(range_start, range_length+range_start),
|
text: $("#compose-textarea").val().substring(range_start, range_length + range_start),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
$('#compose-textarea').caret = noop;
|
$('#compose-textarea').caret = noop;
|
||||||
|
|
|
@ -58,7 +58,7 @@ run_test('pills', () => {
|
||||||
pills = {
|
pills = {
|
||||||
pill: {},
|
pill: {},
|
||||||
};
|
};
|
||||||
all_pills= {};
|
all_pills = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
var appendValue_called;
|
var appendValue_called;
|
||||||
|
|
|
@ -936,7 +936,7 @@ run_test('begins_typeahead', () => {
|
||||||
|
|
||||||
var all_items = _.map(['all', 'everyone', 'stream'], function (mention) {
|
var all_items = _.map(['all', 'everyone', 'stream'], function (mention) {
|
||||||
return {
|
return {
|
||||||
special_item_text: 'translated: ' + mention +" (Notify stream)",
|
special_item_text: 'translated: ' + mention + " (Notify stream)",
|
||||||
email: mention,
|
email: mention,
|
||||||
pm_recipient_count: Infinity,
|
pm_recipient_count: Infinity,
|
||||||
full_name: mention,
|
full_name: mention,
|
||||||
|
@ -1130,7 +1130,7 @@ run_test('content_highlighter', () => {
|
||||||
run_test('typeahead_results', () => {
|
run_test('typeahead_results', () => {
|
||||||
var all_items = _.map(['all', 'everyone', 'stream'], function (mention) {
|
var all_items = _.map(['all', 'everyone', 'stream'], function (mention) {
|
||||||
return {
|
return {
|
||||||
special_item_text: 'translated: ' + mention +" (Notify stream)",
|
special_item_text: 'translated: ' + mention + " (Notify stream)",
|
||||||
email: mention,
|
email: mention,
|
||||||
pm_recipient_count: Infinity,
|
pm_recipient_count: Infinity,
|
||||||
full_name: mention,
|
full_name: mention,
|
||||||
|
|
|
@ -54,7 +54,7 @@ run_test('get_editability', () => {
|
||||||
realm_message_content_edit_limit_seconds: 10,
|
realm_message_content_edit_limit_seconds: 10,
|
||||||
};
|
};
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
var current_timestamp = now/1000;
|
var current_timestamp = now / 1000;
|
||||||
message.timestamp = current_timestamp - 60;
|
message.timestamp = current_timestamp - 60;
|
||||||
// Have 55+10 > 60 seconds from message.timestamp to edit the message; we're good!
|
// Have 55+10 > 60 seconds from message.timestamp to edit the message; we're good!
|
||||||
assert.equal(get_editability(message, 55), editability_types.FULL);
|
assert.equal(get_editability(message, 55), editability_types.FULL);
|
||||||
|
|
|
@ -270,7 +270,7 @@ run_test('last_sent_by_me', () => {
|
||||||
run_test('local_echo', () => {
|
run_test('local_echo', () => {
|
||||||
var list = new MessageList({});
|
var list = new MessageList({});
|
||||||
list.append([{id:10}, {id:20}, {id:30}, {id:20.02}, {id:20.03}, {id:40}, {id:50}, {id:60}]);
|
list.append([{id:10}, {id:20}, {id:30}, {id:20.02}, {id:20.03}, {id:40}, {id:50}, {id:60}]);
|
||||||
list._local_only= {20.02: {id:20.02}, 20.03: {id:20.03}};
|
list._local_only = {20.02: {id:20.02}, 20.03: {id:20.03}};
|
||||||
|
|
||||||
assert.equal(list.closest_id(10), 10);
|
assert.equal(list.closest_id(10), 10);
|
||||||
assert.equal(list.closest_id(20), 20);
|
assert.equal(list.closest_id(20), 20);
|
||||||
|
@ -294,8 +294,8 @@ run_test('local_echo', () => {
|
||||||
list.append([
|
list.append([
|
||||||
{id:10}, {id:20}, {id:30}, {id:20.02}, {id:20.03}, {id:40},
|
{id:10}, {id:20}, {id:30}, {id:20.02}, {id:20.03}, {id:40},
|
||||||
{id:50}, {id: 50.01}, {id: 50.02}, {id:60}]);
|
{id:50}, {id: 50.01}, {id: 50.02}, {id:60}]);
|
||||||
list._local_only= {20.02: {id:20.02}, 20.03: {id:20.03},
|
list._local_only = {20.02: {id:20.02}, 20.03: {id:20.03},
|
||||||
50.01: {id: 50.01}, 50.02: {id: 50.02}};
|
50.01: {id: 50.01}, 50.02: {id: 50.02}};
|
||||||
|
|
||||||
assert.equal(list.closest_id(10), 10);
|
assert.equal(list.closest_id(10), 10);
|
||||||
assert.equal(list.closest_id(20), 20);
|
assert.equal(list.closest_id(20), 20);
|
||||||
|
|
|
@ -398,7 +398,7 @@ run_test('with_external_user', () => {
|
||||||
|
|
||||||
var exit_button = $.create('fake-pill-exit');
|
var exit_button = $.create('fake-pill-exit');
|
||||||
pill_stub.set_find_results('.exit', exit_button);
|
pill_stub.set_find_results('.exit', exit_button);
|
||||||
var exit_button_called=false;
|
var exit_button_called = false;
|
||||||
exit_button.css = function (property, value) {
|
exit_button.css = function (property, value) {
|
||||||
exit_button_called = true;
|
exit_button_called = true;
|
||||||
assert.equal(property, 'opacity');
|
assert.equal(property, 'opacity');
|
||||||
|
|
|
@ -1564,7 +1564,7 @@ run_test('embedded_bot_config_item', () => {
|
||||||
};
|
};
|
||||||
var html = render('embedded_bot_config_item', args);
|
var html = render('embedded_bot_config_item', args);
|
||||||
assert.equal($(html).attr('name'), args.botname);
|
assert.equal($(html).attr('name'), args.botname);
|
||||||
assert.equal($(html).attr('id'), args.botname+'_'+args.key);
|
assert.equal($(html).attr('id'), args.botname + '_' + args.key);
|
||||||
assert.equal($(html).find('label').text(), args.key);
|
assert.equal($(html).find('label').text(), args.key);
|
||||||
assert.equal($(html).find('input').attr('placeholder'), args.value);
|
assert.equal($(html).find('input').attr('placeholder'), args.value);
|
||||||
});
|
});
|
||||||
|
|
|
@ -324,7 +324,7 @@ run_test('sort_recipients', () => {
|
||||||
assert.deepEqual(recipients_email, expected);
|
assert.deepEqual(recipients_email, expected);
|
||||||
|
|
||||||
// Reset matches
|
// Reset matches
|
||||||
matches.splice(matches.length-1, 1);
|
matches.splice(matches.length - 1, 1);
|
||||||
|
|
||||||
// full_name starts with same character but emails are 'all'
|
// full_name starts with same character but emails are 'all'
|
||||||
var small_matches = [
|
var small_matches = [
|
||||||
|
|
|
@ -286,7 +286,7 @@ run_test('num_unread_for_topic', () => {
|
||||||
assert.deepEqual(missing_topics, []);
|
assert.deepEqual(missing_topics, []);
|
||||||
|
|
||||||
for (i = 0; i < num_msgs; i += 1) {
|
for (i = 0; i < num_msgs; i += 1) {
|
||||||
message.id = i+1;
|
message.id = i + 1;
|
||||||
unread.mark_as_read(message.id);
|
unread.mark_as_read(message.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ run_test('upload_error', () => {
|
||||||
assert.equal($("#compose-error-msg").text(), msg);
|
assert.equal($("#compose-error-msg").text(), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test(err, msg, server_response=null, file={}) {
|
function test(err, msg, server_response = null, file = {}) {
|
||||||
setup_test();
|
setup_test();
|
||||||
file.lastModified = 1549958107000;
|
file.lastModified = 1549958107000;
|
||||||
upload_opts.error(err, server_response, file);
|
upload_opts.error(err, server_response, file);
|
||||||
|
|
|
@ -200,27 +200,27 @@ run_test('all_and_everyone_mentions_regexp', () => {
|
||||||
];
|
];
|
||||||
|
|
||||||
var i;
|
var i;
|
||||||
for (i=0; i<messages_with_all_mentions.length; i += 1) {
|
for (i = 0; i < messages_with_all_mentions.length; i += 1) {
|
||||||
assert(util.is_all_or_everyone_mentioned(messages_with_all_mentions[i]));
|
assert(util.is_all_or_everyone_mentioned(messages_with_all_mentions[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<messages_with_everyone_mentions.length; i += 1) {
|
for (i = 0; i < messages_with_everyone_mentions.length; i += 1) {
|
||||||
assert(util.is_all_or_everyone_mentioned(messages_with_everyone_mentions[i]));
|
assert(util.is_all_or_everyone_mentioned(messages_with_everyone_mentions[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<messages_with_stream_mentions.length; i += 1) {
|
for (i = 0; i < messages_with_stream_mentions.length; i += 1) {
|
||||||
assert(util.is_all_or_everyone_mentioned(messages_with_stream_mentions[i]));
|
assert(util.is_all_or_everyone_mentioned(messages_with_stream_mentions[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<messages_without_all_mentions.length; i += 1) {
|
for (i = 0; i < messages_without_all_mentions.length; i += 1) {
|
||||||
assert(!util.is_all_or_everyone_mentioned(messages_without_everyone_mentions[i]));
|
assert(!util.is_all_or_everyone_mentioned(messages_without_everyone_mentions[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<messages_without_everyone_mentions.length; i += 1) {
|
for (i = 0; i < messages_without_everyone_mentions.length; i += 1) {
|
||||||
assert(!util.is_all_or_everyone_mentioned(messages_without_everyone_mentions[i]));
|
assert(!util.is_all_or_everyone_mentioned(messages_without_everyone_mentions[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<messages_without_stream_mentions.length; i += 1) {
|
for (i = 0; i < messages_without_stream_mentions.length; i += 1) {
|
||||||
assert(!util.is_all_or_everyone_mentioned(messages_without_stream_mentions[i]));
|
assert(!util.is_all_or_everyone_mentioned(messages_without_stream_mentions[i]));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -88,7 +88,7 @@ function short_tb(tb) {
|
||||||
return tb;
|
return tb;
|
||||||
}
|
}
|
||||||
|
|
||||||
return lines.splice(0, i+1).join('\n') + '\n(...)\n';
|
return lines.splice(0, i + 1).join('\n') + '\n(...)\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up bugdown comparison helper
|
// Set up bugdown comparison helper
|
||||||
|
|
|
@ -109,7 +109,7 @@ function diff_strings(string_0, string_1) {
|
||||||
} else if (line.startsWith("?")) {
|
} else if (line.startsWith("?")) {
|
||||||
changes_list = parse_questionmark_line(line);
|
changes_list = parse_questionmark_line(line);
|
||||||
output_lines[output_lines.length - 1] = apply_color(
|
output_lines[output_lines.length - 1] = apply_color(
|
||||||
output_lines[output_lines.length -1], changes_list);
|
output_lines[output_lines.length - 1], changes_list);
|
||||||
} else {
|
} else {
|
||||||
output_lines.push(line);
|
output_lines.push(line);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ exports.sRGB_to_linear = function (v) {
|
||||||
// Compute luminance (CIE Y stimulus) from linear intensity
|
// Compute luminance (CIE Y stimulus) from linear intensity
|
||||||
// of sRGB / Rec. 709 primaries.
|
// of sRGB / Rec. 709 primaries.
|
||||||
exports.rgb_luminance = function (channel) {
|
exports.rgb_luminance = function (channel) {
|
||||||
return 0.2126*channel[0] + 0.7152*channel[1] + 0.0722*channel[2];
|
return 0.2126 * channel[0] + 0.7152 * channel[1] + 0.0722 * channel[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert luminance (photometric, CIE Y)
|
// Convert luminance (photometric, CIE Y)
|
||||||
|
@ -27,12 +27,12 @@ exports.rgb_luminance = function (channel) {
|
||||||
exports.luminance_to_lightness = function (luminance) {
|
exports.luminance_to_lightness = function (luminance) {
|
||||||
var v;
|
var v;
|
||||||
if (luminance <= (216 / 24389)) {
|
if (luminance <= (216 / 24389)) {
|
||||||
v = (841 / 108)*luminance + (4 / 29);
|
v = (841 / 108) * luminance + (4 / 29);
|
||||||
} else {
|
} else {
|
||||||
v = Math.pow(luminance, 1/3);
|
v = Math.pow(luminance, 1 / 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 116*v - 16;
|
return 116 * v - 16;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getDecimalColor = function (hexcolor) {
|
exports.getDecimalColor = function (hexcolor) {
|
||||||
|
|
|
@ -160,7 +160,7 @@ exports.maybe_scroll_up_selected_message = function () {
|
||||||
var cover = selected_row.offset().top + selected_row.height()
|
var cover = selected_row.offset().top + selected_row.height()
|
||||||
- $("#compose").offset().top;
|
- $("#compose").offset().top;
|
||||||
if (cover > 0) {
|
if (cover > 0) {
|
||||||
message_viewport.user_initiated_animate_scroll(cover+5);
|
message_viewport.user_initiated_animate_scroll(cover + 5);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -391,9 +391,9 @@ exports.quote_and_reply = function (opts) {
|
||||||
idempotent: true,
|
idempotent: true,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (textarea.val() === "") {
|
if (textarea.val() === "") {
|
||||||
textarea.val("```quote\n" + data.raw_content +"\n```\n");
|
textarea.val("```quote\n" + data.raw_content + "\n```\n");
|
||||||
} else {
|
} else {
|
||||||
textarea.val(textarea.val() + "\n```quote\n" + data.raw_content +"\n```\n");
|
textarea.val(textarea.val() + "\n```quote\n" + data.raw_content + "\n```\n");
|
||||||
}
|
}
|
||||||
$("#compose-textarea").trigger("autosize.resize");
|
$("#compose-textarea").trigger("autosize.resize");
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,7 +30,7 @@ function get_or_set(fieldname, keep_leading_whitespace) {
|
||||||
// because the DOM element might not exist yet when get_or_set
|
// because the DOM element might not exist yet when get_or_set
|
||||||
// is called.
|
// is called.
|
||||||
return function (newval) {
|
return function (newval) {
|
||||||
var elem = $('#'+fieldname);
|
var elem = $('#' + fieldname);
|
||||||
var oldval = elem.val();
|
var oldval = elem.val();
|
||||||
if (newval !== undefined) {
|
if (newval !== undefined) {
|
||||||
elem.val(newval);
|
elem.val(newval);
|
||||||
|
|
|
@ -281,8 +281,8 @@ exports.tokenize_compose_str = function (s) {
|
||||||
// Code block must start on a new line
|
// Code block must start on a new line
|
||||||
if (i === 2) {
|
if (i === 2) {
|
||||||
return s.slice(0);
|
return s.slice(0);
|
||||||
} else if (i > 2 && s[i-3] === "\n") {
|
} else if (i > 2 && s[i - 3] === "\n") {
|
||||||
return s.slice(i-2);
|
return s.slice(i - 2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '#':
|
case '#':
|
||||||
|
@ -290,7 +290,7 @@ exports.tokenize_compose_str = function (s) {
|
||||||
case ':':
|
case ':':
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
return s.slice(i);
|
return s.slice(i);
|
||||||
} else if (/[\s(){}\[\]]/.test(s[i-1])) {
|
} else if (/[\s(){}\[\]]/.test(s[i - 1])) {
|
||||||
return s.slice(i);
|
return s.slice(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -446,7 +446,7 @@ exports.content_typeahead_selected = function (item) {
|
||||||
if (beginning.lastIndexOf(":") === 0 ||
|
if (beginning.lastIndexOf(":") === 0 ||
|
||||||
beginning.charAt(beginning.lastIndexOf(":") - 1) === " " ||
|
beginning.charAt(beginning.lastIndexOf(":") - 1) === " " ||
|
||||||
beginning.charAt(beginning.lastIndexOf(":") - 1) === "\n") {
|
beginning.charAt(beginning.lastIndexOf(":") - 1) === "\n") {
|
||||||
beginning = (beginning.substring(0, beginning.length - this.token.length - 1)+ ":" + item.emoji_name + ": ");
|
beginning = (beginning.substring(0, beginning.length - this.token.length - 1) + ":" + item.emoji_name + ": ");
|
||||||
} else {
|
} else {
|
||||||
beginning = (beginning.substring(0, beginning.length - this.token.length - 1) + " :" + item.emoji_name + ": ");
|
beginning = (beginning.substring(0, beginning.length - this.token.length - 1) + " :" + item.emoji_name + ": ");
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ exports.setup_page = function (callback) {
|
||||||
data_array.push([id, data[id]]);
|
data_array.push([id, data[id]]);
|
||||||
});
|
});
|
||||||
var data_sorted = data_array.sort(function (draft_a,draft_b) {
|
var data_sorted = data_array.sort(function (draft_a,draft_b) {
|
||||||
return draft_a[1].updatedAt-draft_b[1].updatedAt;
|
return draft_a[1].updatedAt - draft_b[1].updatedAt;
|
||||||
});
|
});
|
||||||
_.each(data_sorted, function (data_element) {
|
_.each(data_sorted, function (data_element) {
|
||||||
var draft = data_element[1];
|
var draft = data_element[1];
|
||||||
|
@ -314,7 +314,7 @@ function drafts_initialize_focus(event_name) {
|
||||||
|
|
||||||
var draft_element;
|
var draft_element;
|
||||||
if (event_name === "up_arrow") {
|
if (event_name === "up_arrow") {
|
||||||
draft_element = document.querySelectorAll('[data-draft-id="' + draft_id_arrow[draft_id_arrow.length-1] + '"]');
|
draft_element = document.querySelectorAll('[data-draft-id="' + draft_id_arrow[draft_id_arrow.length - 1] + '"]');
|
||||||
} else if (event_name === "down_arrow") {
|
} else if (event_name === "down_arrow") {
|
||||||
draft_element = document.querySelectorAll('[data-draft-id="' + draft_id_arrow[0] + '"]');
|
draft_element = document.querySelectorAll('[data-draft-id="' + draft_id_arrow[0] + '"]');
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,7 @@ exports.drafts_handle_events = function (e, event_key) {
|
||||||
if (document.activeElement.parentElement.hasAttribute("data-draft-id")) {
|
if (document.activeElement.parentElement.hasAttribute("data-draft-id")) {
|
||||||
exports.restore_draft(focused_draft);
|
exports.restore_draft(focused_draft);
|
||||||
} else {
|
} else {
|
||||||
var first_draft = draft_id_arrow[draft_id_arrow.length-1];
|
var first_draft = draft_id_arrow[draft_id_arrow.length - 1];
|
||||||
exports.restore_draft(first_draft);
|
exports.restore_draft(first_draft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ exports.launch = function () {
|
||||||
var draft_list = drafts.draft_model.get();
|
var draft_list = drafts.draft_model.get();
|
||||||
var draft_id_list = Object.getOwnPropertyNames(draft_list);
|
var draft_id_list = Object.getOwnPropertyNames(draft_list);
|
||||||
if (draft_id_list.length > 0) {
|
if (draft_id_list.length > 0) {
|
||||||
var last_draft = draft_id_list[draft_id_list.length-1];
|
var last_draft = draft_id_list[draft_id_list.length - 1];
|
||||||
var last_draft_element = document.querySelectorAll('[data-draft-id="' + last_draft + '"]');
|
var last_draft_element = document.querySelectorAll('[data-draft-id="' + last_draft + '"]');
|
||||||
var focus_element = last_draft_element[0].children[0];
|
var focus_element = last_draft_element[0].children[0];
|
||||||
focus_element.focus();
|
focus_element.focus();
|
||||||
|
|
|
@ -548,7 +548,7 @@ exports.emoji_select_tab = function (elt) {
|
||||||
var elt_height = elt.height();
|
var elt_height = elt.height();
|
||||||
var currently_selected = "";
|
var currently_selected = "";
|
||||||
section_head_offsets.forEach(function (o) {
|
section_head_offsets.forEach(function (o) {
|
||||||
if (scrolltop + elt_height/2 >= o.position_y) {
|
if (scrolltop + elt_height / 2 >= o.position_y) {
|
||||||
currently_selected = o.section;
|
currently_selected = o.section;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -563,7 +563,7 @@ exports.emoji_select_tab = function (elt) {
|
||||||
}
|
}
|
||||||
if (currently_selected) {
|
if (currently_selected) {
|
||||||
$('.emoji-popover-tab-item.active').removeClass('active');
|
$('.emoji-popover-tab-item.active').removeClass('active');
|
||||||
$('.emoji-popover-tab-item[data-tab-name="'+currently_selected+'"]').addClass('active');
|
$('.emoji-popover-tab-item[data-tab-name="' + currently_selected + '"]').addClass('active');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -621,10 +621,10 @@ function describe_unescaped(operators) {
|
||||||
var more_parts = _.map(operators, function (elem) {
|
var more_parts = _.map(operators, function (elem) {
|
||||||
var operand = elem.operand;
|
var operand = elem.operand;
|
||||||
var canonicalized_operator = Filter.canonicalize_operator(elem.operator);
|
var canonicalized_operator = Filter.canonicalize_operator(elem.operator);
|
||||||
if (canonicalized_operator ==='is') {
|
if (canonicalized_operator === 'is') {
|
||||||
return describe_is_operator(elem);
|
return describe_is_operator(elem);
|
||||||
}
|
}
|
||||||
if (canonicalized_operator ==='has') {
|
if (canonicalized_operator === 'has') {
|
||||||
// search_suggestion.get_suggestions takes care that this message will
|
// search_suggestion.get_suggestions takes care that this message will
|
||||||
// only be shown if the `has` operator is not at the last.
|
// only be shown if the `has` operator is not at the last.
|
||||||
var valid_has_operands = ['image', 'images', 'link', 'links', 'attachment', 'attachments'];
|
var valid_has_operands = ['image', 'images', 'link', 'links', 'attachment', 'attachments'];
|
||||||
|
|
|
@ -72,7 +72,7 @@ exports.save_narrow = function (operators) {
|
||||||
exports.parse_narrow = function (hash) {
|
exports.parse_narrow = function (hash) {
|
||||||
var i;
|
var i;
|
||||||
var operators = [];
|
var operators = [];
|
||||||
for (i=1; i<hash.length; i+=2) {
|
for (i = 1; i < hash.length; i += 2) {
|
||||||
// We don't construct URLs with an odd number of components,
|
// We don't construct URLs with an odd number of components,
|
||||||
// but the user might write one.
|
// but the user might write one.
|
||||||
try {
|
try {
|
||||||
|
@ -82,7 +82,7 @@ exports.parse_narrow = function (hash) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var operand = hash_util.decode_operand(operator, hash[i+1] || '');
|
var operand = hash_util.decode_operand(operator, hash[i + 1] || '');
|
||||||
var negated = false;
|
var negated = false;
|
||||||
if (operator[0] === '-') {
|
if (operator[0] === '-') {
|
||||||
negated = true;
|
negated = true;
|
||||||
|
|
|
@ -47,7 +47,7 @@ function create_bot(full_name, short_name, bot_avatar_file, stream_name,
|
||||||
formData.append('csrfmiddlewaretoken', csrf_token);
|
formData.append('csrfmiddlewaretoken', csrf_token);
|
||||||
formData.append('full_name', full_name);
|
formData.append('full_name', full_name);
|
||||||
formData.append('short_name', short_name);
|
formData.append('short_name', short_name);
|
||||||
formData.append('file-'+0, bot_avatar_file);
|
formData.append('file-' + 0, bot_avatar_file);
|
||||||
channel.post({
|
channel.post({
|
||||||
url: '/json/bots',
|
url: '/json/bots',
|
||||||
data: formData,
|
data: formData,
|
||||||
|
|
|
@ -104,7 +104,7 @@ exports.maybe_advance_to_recently_sent_message = function (messages) {
|
||||||
|
|
||||||
// Iterate backwards to find the last message sent_by_me, stopping at
|
// Iterate backwards to find the last message sent_by_me, stopping at
|
||||||
// the pointer position.
|
// the pointer position.
|
||||||
for (i = messages.length-1; i>=0; i -= 1) {
|
for (i = messages.length - 1; i >= 0; i -= 1) {
|
||||||
var id = messages[i].id;
|
var id = messages[i].id;
|
||||||
if (id <= selected_id) {
|
if (id <= selected_id) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3,7 +3,7 @@ var message_fetch = (function () {
|
||||||
var exports = {};
|
var exports = {};
|
||||||
|
|
||||||
var consts = {
|
var consts = {
|
||||||
backfill_idle_time: 10*1000,
|
backfill_idle_time: 10 * 1000,
|
||||||
error_retry_time: 5000,
|
error_retry_time: 5000,
|
||||||
backfill_batch_size: 1000,
|
backfill_batch_size: 1000,
|
||||||
narrow_before: 50,
|
narrow_before: 50,
|
||||||
|
@ -315,7 +315,7 @@ exports.initialize = function () {
|
||||||
// If we fall through here, we need to keep fetching more data, and
|
// If we fall through here, we need to keep fetching more data, and
|
||||||
// we'll call back to the function we're in.
|
// we'll call back to the function we're in.
|
||||||
var messages = data.messages;
|
var messages = data.messages;
|
||||||
var latest_id = messages[messages.length-1].id;
|
var latest_id = messages[messages.length - 1].id;
|
||||||
|
|
||||||
exports.load_messages({
|
exports.load_messages({
|
||||||
anchor: latest_id.toFixed(),
|
anchor: latest_id.toFixed(),
|
||||||
|
|
|
@ -89,7 +89,7 @@ MessageListData.prototype = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var last_msg = this._items[n-1];
|
var last_msg = this._items[n - 1];
|
||||||
|
|
||||||
return (last_msg.id === this._selected_id);
|
return (last_msg.id === this._selected_id);
|
||||||
},
|
},
|
||||||
|
|
|
@ -312,9 +312,9 @@ exports.recenter_view = function (message, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_above || opts.force_center) {
|
if (is_above || opts.force_center) {
|
||||||
exports.set_message_position(message_top, message_height, viewport_info, 1/2);
|
exports.set_message_position(message_top, message_height, viewport_info, 1 / 2);
|
||||||
} else if (is_below) {
|
} else if (is_below) {
|
||||||
exports.set_message_position(message_top, message_height, viewport_info, 1/7);
|
exports.set_message_position(message_top, message_height, viewport_info, 1 / 7);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -334,8 +334,8 @@ exports.keep_pointer_in_view = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
var info = message_viewport.message_viewport_info();
|
var info = message_viewport.message_viewport_info();
|
||||||
var top_threshold = info.visible_top + (1/10 * info.visible_height);
|
var top_threshold = info.visible_top + (1 / 10 * info.visible_height);
|
||||||
var bottom_threshold = info.visible_top + (9/10 * info.visible_height);
|
var bottom_threshold = info.visible_top + (9 / 10 * info.visible_height);
|
||||||
|
|
||||||
function message_is_far_enough_down() {
|
function message_is_far_enough_down() {
|
||||||
if (message_viewport.at_top()) {
|
if (message_viewport.at_top()) {
|
||||||
|
|
|
@ -144,7 +144,7 @@ exports.redraw_title = function () {
|
||||||
n = 'infinite';
|
n = 'infinite';
|
||||||
}
|
}
|
||||||
|
|
||||||
current_favicon = previous_favicon = '/static/images/favicon/favicon-'+n+'.png';
|
current_favicon = previous_favicon = '/static/images/favicon/favicon-' + n + '.png';
|
||||||
} else {
|
} else {
|
||||||
current_favicon = previous_favicon = '/static/favicon.ico?v=2';
|
current_favicon = previous_favicon = '/static/favicon.ico?v=2';
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,7 +373,7 @@ exports.render_actions_remind_popover = function (element, id) {
|
||||||
trigger: "manual",
|
trigger: "manual",
|
||||||
});
|
});
|
||||||
elt.popover("show");
|
elt.popover("show");
|
||||||
current_flatpickr_instance = $('.remind.custom[data-message-id="'+message.id+'"]').flatpickr({
|
current_flatpickr_instance = $('.remind.custom[data-message-id="' + message.id + '"]').flatpickr({
|
||||||
enableTime: true,
|
enableTime: true,
|
||||||
clickOpens: false,
|
clickOpens: false,
|
||||||
defaultDate: moment().format(),
|
defaultDate: moment().format(),
|
||||||
|
|
|
@ -9,10 +9,10 @@ function registerCodeSection($codeSection) {
|
||||||
const language = this.dataset.language;
|
const language = this.dataset.language;
|
||||||
|
|
||||||
$li.removeClass("active");
|
$li.removeClass("active");
|
||||||
$li.filter("[data-language="+language+"]").addClass("active");
|
$li.filter("[data-language=" + language + "]").addClass("active");
|
||||||
|
|
||||||
$blocks.removeClass("active");
|
$blocks.removeClass("active");
|
||||||
$blocks.filter("[data-language="+language+"]").addClass("active");
|
$blocks.filter("[data-language=" + language + "]").addClass("active");
|
||||||
});
|
});
|
||||||
|
|
||||||
$li.eq(0).click();
|
$li.eq(0).click();
|
||||||
|
|
|
@ -95,7 +95,7 @@ function preserve_state(send_after_reload, save_pointer, save_narrow, save_compo
|
||||||
//
|
//
|
||||||
// TODO: Remove the now-unnecessary URL-encoding logic above and
|
// TODO: Remove the now-unnecessary URL-encoding logic above and
|
||||||
// just pass the actual data structures through local storage.
|
// just pass the actual data structures through local storage.
|
||||||
var token = util.random_int(0, 1024*1024*1024*1024);
|
var token = util.random_int(0, 1024 * 1024 * 1024 * 1024);
|
||||||
|
|
||||||
ls.set("reload:" + token, url);
|
ls.set("reload:" + token, url);
|
||||||
window.location.replace("#reload:" + token);
|
window.location.replace("#reload:" + token);
|
||||||
|
@ -262,9 +262,9 @@ exports.initiate = function (options) {
|
||||||
// while composing. If they finish or cancel the compose, wait
|
// while composing. If they finish or cancel the compose, wait
|
||||||
// until they're idle again
|
// until they're idle again
|
||||||
var idle_control;
|
var idle_control;
|
||||||
var unconditional_timeout = 1000*60*30 + util.random_int(0, 1000*60*5);
|
var unconditional_timeout = 1000 * 60 * 30 + util.random_int(0, 1000 * 60 * 5);
|
||||||
var composing_timeout = 1000*60*5 + util.random_int(0, 1000*60);
|
var composing_timeout = 1000 * 60 * 5 + util.random_int(0, 1000 * 60);
|
||||||
var home_timeout = 1000*60 + util.random_int(0, 1000*60);
|
var home_timeout = 1000 * 60 + util.random_int(0, 1000 * 60);
|
||||||
var compose_done_handler;
|
var compose_done_handler;
|
||||||
var compose_started_handler;
|
var compose_started_handler;
|
||||||
|
|
||||||
|
|
|
@ -216,8 +216,8 @@ function get_events(options) {
|
||||||
undefined,
|
undefined,
|
||||||
ex.stack);
|
ex.stack);
|
||||||
}
|
}
|
||||||
var retry_sec = Math.min(90, Math.exp(get_events_failures/2));
|
var retry_sec = Math.min(90, Math.exp(get_events_failures / 2));
|
||||||
get_events_timeout = setTimeout(get_events, retry_sec*1000);
|
get_events_timeout = setTimeout(get_events, retry_sec * 1000);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -418,7 +418,7 @@ exports.set_up = function () {
|
||||||
|
|
||||||
form_data.append('csrfmiddlewaretoken', csrf_token);
|
form_data.append('csrfmiddlewaretoken', csrf_token);
|
||||||
jQuery.each(file_input[0].files, function (i, file) {
|
jQuery.each(file_input[0].files, function (i, file) {
|
||||||
form_data.append('file-'+i, file);
|
form_data.append('file-' + i, file);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#user-avatar-source").hide();
|
$("#user-avatar-source").hide();
|
||||||
|
|
|
@ -184,7 +184,7 @@ exports.set_up = function () {
|
||||||
var selected_embedded_bot = 'converter';
|
var selected_embedded_bot = 'converter';
|
||||||
$('#select_service_name').val(selected_embedded_bot); // TODO: Use 'select a bot'.
|
$('#select_service_name').val(selected_embedded_bot); // TODO: Use 'select a bot'.
|
||||||
$('#config_inputbox').children().hide();
|
$('#config_inputbox').children().hide();
|
||||||
$("[name*='"+selected_embedded_bot+"']").show();
|
$("[name*='" + selected_embedded_bot + "']").show();
|
||||||
|
|
||||||
$('#download_botserverrc').click(function () {
|
$('#download_botserverrc').click(function () {
|
||||||
var OUTGOING_WEBHOOK_BOT_TYPE_INT = 3;
|
var OUTGOING_WEBHOOK_BOT_TYPE_INT = 3;
|
||||||
|
@ -243,13 +243,13 @@ exports.set_up = function () {
|
||||||
} else if (bot_type === EMBEDDED_BOT_TYPE) {
|
} else if (bot_type === EMBEDDED_BOT_TYPE) {
|
||||||
formData.append('service_name', service_name);
|
formData.append('service_name', service_name);
|
||||||
var config_data = {};
|
var config_data = {};
|
||||||
$("#config_inputbox [name*='"+service_name+"'] input").each(function () {
|
$("#config_inputbox [name*='" + service_name + "'] input").each(function () {
|
||||||
config_data[$(this).attr('name')] = $(this).val();
|
config_data[$(this).attr('name')] = $(this).val();
|
||||||
});
|
});
|
||||||
formData.append('config_data', JSON.stringify(config_data));
|
formData.append('config_data', JSON.stringify(config_data));
|
||||||
}
|
}
|
||||||
jQuery.each($('#bot_avatar_file_input')[0].files, function (i, file) {
|
jQuery.each($('#bot_avatar_file_input')[0].files, function (i, file) {
|
||||||
formData.append('file-'+i, file);
|
formData.append('file-' + i, file);
|
||||||
});
|
});
|
||||||
loading.make_indicator(spinner, {text: i18n.t('Creating bot')});
|
loading.make_indicator(spinner, {text: i18n.t('Creating bot')});
|
||||||
channel.post({
|
channel.post({
|
||||||
|
@ -265,7 +265,7 @@ exports.set_up = function () {
|
||||||
$('#create_payload_url').val('');
|
$('#create_payload_url').val('');
|
||||||
$('#payload_url_inputbox').hide();
|
$('#payload_url_inputbox').hide();
|
||||||
$('#config_inputbox').hide();
|
$('#config_inputbox').hide();
|
||||||
$("[name*='"+service_name+"'] input").each(function () {
|
$("[name*='" + service_name + "'] input").each(function () {
|
||||||
$(this).val('');
|
$(this).val('');
|
||||||
});
|
});
|
||||||
$('#create_bot_type').val(GENERIC_BOT_TYPE);
|
$('#create_bot_type').val(GENERIC_BOT_TYPE);
|
||||||
|
@ -311,7 +311,7 @@ exports.set_up = function () {
|
||||||
$("#select_service_name").on("change", function () {
|
$("#select_service_name").on("change", function () {
|
||||||
$('#config_inputbox').children().hide();
|
$('#config_inputbox').children().hide();
|
||||||
var selected_bot = $('#select_service_name :selected').val();
|
var selected_bot = $('#select_service_name :selected').val();
|
||||||
$("[name*='"+selected_bot+"']").show();
|
$("[name*='" + selected_bot + "']").show();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#active_bots_list").on("click", "button.delete_bot", function (e) {
|
$("#active_bots_list").on("click", "button.delete_bot", function (e) {
|
||||||
|
@ -421,7 +421,7 @@ exports.set_up = function () {
|
||||||
formData.append('config_data', JSON.stringify(config_data));
|
formData.append('config_data', JSON.stringify(config_data));
|
||||||
}
|
}
|
||||||
jQuery.each(file_input[0].files, function (i, file) {
|
jQuery.each(file_input[0].files, function (i, file) {
|
||||||
formData.append('file-'+i, file);
|
formData.append('file-' + i, file);
|
||||||
});
|
});
|
||||||
loading.make_indicator(spinner, {text: 'Editing bot'});
|
loading.make_indicator(spinner, {text: 'Editing bot'});
|
||||||
edit_button.hide();
|
edit_button.hide();
|
||||||
|
@ -442,7 +442,7 @@ exports.set_up = function () {
|
||||||
// when the user had a previous uploaded avatar. Only the content
|
// when the user had a previous uploaded avatar. Only the content
|
||||||
// changes, so we version it to get an uncached copy.
|
// changes, so we version it to get an uncached copy.
|
||||||
image_version += 1;
|
image_version += 1;
|
||||||
image.find('img').attr('src', data.avatar_url+'&v='+image_version.toString());
|
image.find('img').attr('src', data.avatar_url + '&v=' + image_version.toString());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (xhr) {
|
error: function (xhr) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ exports.set_up = function () {
|
||||||
channel.get({
|
channel.get({
|
||||||
url: '/json/invites',
|
url: '/json/invites',
|
||||||
idempotent: true,
|
idempotent: true,
|
||||||
timeout: 10*1000,
|
timeout: 10 * 1000,
|
||||||
success: exports.on_load_success,
|
success: exports.on_load_success,
|
||||||
error: failed_listing_invites,
|
error: failed_listing_invites,
|
||||||
});
|
});
|
||||||
|
|
|
@ -90,7 +90,7 @@ function get_subsection_property_types(subsection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.get_realm_time_limits_in_minutes = function (property) {
|
exports.get_realm_time_limits_in_minutes = function (property) {
|
||||||
var val = (page_params[property]/ 60).toFixed(1);
|
var val = (page_params[property] / 60).toFixed(1);
|
||||||
if (parseFloat(val, 10) === parseInt(val, 10)) {
|
if (parseFloat(val, 10) === parseInt(val, 10)) {
|
||||||
val = parseInt(val, 10);
|
val = parseInt(val, 10);
|
||||||
}
|
}
|
||||||
|
@ -200,23 +200,23 @@ var time_limit_dropdown_values = {
|
||||||
},
|
},
|
||||||
upto_two_min: {
|
upto_two_min: {
|
||||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("2 minutes")}),
|
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("2 minutes")}),
|
||||||
seconds: 2*60,
|
seconds: 2 * 60,
|
||||||
},
|
},
|
||||||
upto_ten_min: {
|
upto_ten_min: {
|
||||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("10 minutes")}),
|
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("10 minutes")}),
|
||||||
seconds: 10*60,
|
seconds: 10 * 60,
|
||||||
},
|
},
|
||||||
upto_one_hour: {
|
upto_one_hour: {
|
||||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 hour")}),
|
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 hour")}),
|
||||||
seconds: 60*60,
|
seconds: 60 * 60,
|
||||||
},
|
},
|
||||||
upto_one_day: {
|
upto_one_day: {
|
||||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 day")}),
|
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 day")}),
|
||||||
seconds: 24*60*60,
|
seconds: 24 * 60 * 60,
|
||||||
},
|
},
|
||||||
upto_one_week: {
|
upto_one_week: {
|
||||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 week")}),
|
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 week")}),
|
||||||
seconds: 7*24*60*60,
|
seconds: 7 * 24 * 60 * 60,
|
||||||
},
|
},
|
||||||
custom_limit: {
|
custom_limit: {
|
||||||
text: i18n.t("Up to N minutes after posting"),
|
text: i18n.t("Up to N minutes after posting"),
|
||||||
|
@ -443,7 +443,7 @@ exports.sync_realm_settings = function (property) {
|
||||||
} else if (property === 'invite_required' || property === 'invite_by_admins_only') {
|
} else if (property === 'invite_required' || property === 'invite_by_admins_only') {
|
||||||
property = 'user_invite_restriction';
|
property = 'user_invite_restriction';
|
||||||
}
|
}
|
||||||
var element = $('#id_realm_'+property);
|
var element = $('#id_realm_' + property);
|
||||||
if (element.length) {
|
if (element.length) {
|
||||||
discard_property_element_changes(element);
|
discard_property_element_changes(element);
|
||||||
}
|
}
|
||||||
|
@ -515,15 +515,15 @@ exports.set_up = function () {
|
||||||
_.each(changing_property_types, function (v, k) {
|
_.each(changing_property_types, function (v, k) {
|
||||||
var field = changing_property_types[k];
|
var field = changing_property_types[k];
|
||||||
if (field.type === 'bool') {
|
if (field.type === 'bool') {
|
||||||
data[k] = JSON.stringify($('#id_realm_'+k).prop('checked'));
|
data[k] = JSON.stringify($('#id_realm_' + k).prop('checked'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (field.type === 'text') {
|
if (field.type === 'text') {
|
||||||
data[k] = JSON.stringify($('#id_realm_'+k).val().trim());
|
data[k] = JSON.stringify($('#id_realm_' + k).val().trim());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (field.type === 'integer') {
|
if (field.type === 'integer') {
|
||||||
data[k] = JSON.stringify(parseInt($("#id_realm_"+k).val().trim(), 10));
|
data[k] = JSON.stringify(parseInt($("#id_realm_" + k).val().trim(), 10));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
|
@ -989,7 +989,7 @@ exports.set_up = function () {
|
||||||
|
|
||||||
form_data.append('csrfmiddlewaretoken', csrf_token);
|
form_data.append('csrfmiddlewaretoken', csrf_token);
|
||||||
jQuery.each(file_input[0].files, function (i, file) {
|
jQuery.each(file_input[0].files, function (i, file) {
|
||||||
form_data.append('file-'+i, file);
|
form_data.append('file-' + i, file);
|
||||||
});
|
});
|
||||||
|
|
||||||
var spinner = $("#upload_icon_spinner").expectOne();
|
var spinner = $("#upload_icon_spinner").expectOne();
|
||||||
|
|
|
@ -211,7 +211,7 @@ exports.set_up = function () {
|
||||||
channel.get({
|
channel.get({
|
||||||
url: '/json/users',
|
url: '/json/users',
|
||||||
idempotent: true,
|
idempotent: true,
|
||||||
timeout: 10*1000,
|
timeout: 10 * 1000,
|
||||||
success: exports.on_load_success,
|
success: exports.on_load_success,
|
||||||
error: failed_listing_users,
|
error: failed_listing_users,
|
||||||
});
|
});
|
||||||
|
|
|
@ -287,7 +287,7 @@ Socket.prototype = {
|
||||||
// immediately reconnect when the page is refreshing
|
// immediately reconnect when the page is refreshing
|
||||||
return 30;
|
return 30;
|
||||||
}
|
}
|
||||||
return Math.min(90, Math.exp(this._connection_failures/2)) * 1000;
|
return Math.min(90, Math.exp(this._connection_failures / 2)) * 1000;
|
||||||
},
|
},
|
||||||
|
|
||||||
_try_to_reconnect: function Socket__try_to_reconnect(opts) {
|
_try_to_reconnect: function Socket__try_to_reconnect(opts) {
|
||||||
|
|
|
@ -166,7 +166,7 @@ function populate_messages_sent_over_time(data) {
|
||||||
|
|
||||||
var start_dates = data.end_times.map(function (timestamp) {
|
var start_dates = data.end_times.map(function (timestamp) {
|
||||||
// data.end_times are the ends of hour long intervals.
|
// data.end_times are the ends of hour long intervals.
|
||||||
return new Date(timestamp*1000 - 60*60*1000);
|
return new Date(timestamp * 1000 - 60 * 60 * 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
function aggregate_data(aggregation) {
|
function aggregate_data(aggregation) {
|
||||||
|
@ -211,7 +211,7 @@ function populate_messages_sent_over_time(data) {
|
||||||
return {
|
return {
|
||||||
dates: dates, values: values,
|
dates: dates, values: values,
|
||||||
last_value_is_partial: !is_boundary(new Date(
|
last_value_is_partial: !is_boundary(new Date(
|
||||||
start_dates[start_dates.length-1].getTime() + 60*60*1000))};
|
start_dates[start_dates.length - 1].getTime() + 60 * 60 * 1000))};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate traces
|
// Generate traces
|
||||||
|
@ -235,7 +235,7 @@ function populate_messages_sent_over_time(data) {
|
||||||
var weekly_traces = make_traces(info.dates, info.values, 'bar', date_formatter);
|
var weekly_traces = make_traces(info.dates, info.values, 'bar', date_formatter);
|
||||||
|
|
||||||
var dates = data.end_times.map(function (timestamp) {
|
var dates = data.end_times.map(function (timestamp) {
|
||||||
return new Date(timestamp*1000);
|
return new Date(timestamp * 1000);
|
||||||
});
|
});
|
||||||
values = {human: partial_sums(data.everyone.human), bot: partial_sums(data.everyone.bot),
|
values = {human: partial_sums(data.everyone.human), bot: partial_sums(data.everyone.bot),
|
||||||
me: partial_sums(data.user.human)};
|
me: partial_sums(data.user.human)};
|
||||||
|
@ -314,7 +314,7 @@ function round_to_percentages(values, total) {
|
||||||
if (x === 0) {
|
if (x === 0) {
|
||||||
return '0%';
|
return '0%';
|
||||||
}
|
}
|
||||||
var unrounded = x/total*100;
|
var unrounded = x / total * 100;
|
||||||
|
|
||||||
var precision = Math.min(
|
var precision = Math.min(
|
||||||
6, // this is the max precision (two #, 4 decimal points; 99.9999%).
|
6, // this is the max precision (two #, 4 decimal points; 99.9999%).
|
||||||
|
@ -340,8 +340,8 @@ function compute_summary_chart_data(time_series_data, num_steps, labels_) {
|
||||||
num_steps = time_series_data[key].length;
|
num_steps = time_series_data[key].length;
|
||||||
}
|
}
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
for (var i=1; i<=num_steps; i+=1) {
|
for (var i = 1; i <= num_steps; i += 1) {
|
||||||
sum += time_series_data[key][time_series_data[key].length-i];
|
sum += time_series_data[key][time_series_data[key].length - i];
|
||||||
}
|
}
|
||||||
data[key] = sum;
|
data[key] = sum;
|
||||||
}
|
}
|
||||||
|
@ -356,10 +356,10 @@ function compute_summary_chart_data(time_series_data, num_steps, labels_) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!$.isEmptyObject(data)) {
|
if (!$.isEmptyObject(data)) {
|
||||||
labels[labels.length-1] = "Other";
|
labels[labels.length - 1] = "Other";
|
||||||
for (key in data) {
|
for (key in data) {
|
||||||
if (data.hasOwnProperty(key)) {
|
if (data.hasOwnProperty(key)) {
|
||||||
values[labels.length-1] += data[key];
|
values[labels.length - 1] += data[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,7 @@ function populate_messages_sent_by_client(data) {
|
||||||
var everyone_month = compute_summary_chart_data(
|
var everyone_month = compute_summary_chart_data(
|
||||||
data.everyone, 30, data.display_order.slice(0, 12));
|
data.everyone, 30, data.display_order.slice(0, 12));
|
||||||
var label_values = [];
|
var label_values = [];
|
||||||
for (var i=0; i<everyone_month.values.length; i+=1) {
|
for (var i = 0; i < everyone_month.values.length; i += 1) {
|
||||||
label_values.push({
|
label_values.push({
|
||||||
label: everyone_month.labels[i],
|
label: everyone_month.labels[i],
|
||||||
value: everyone_month.labels[i] === "Other" ? -1 : everyone_month.values[i],
|
value: everyone_month.labels[i] === "Other" ? -1 : everyone_month.values[i],
|
||||||
|
@ -403,7 +403,7 @@ function populate_messages_sent_by_client(data) {
|
||||||
plot_data.labels.reverse();
|
plot_data.labels.reverse();
|
||||||
plot_data.percentages.reverse();
|
plot_data.percentages.reverse();
|
||||||
var annotations = {values: [], labels: [], text: []};
|
var annotations = {values: [], labels: [], text: []};
|
||||||
for (var i=0; i<plot_data.values.length; i+=1) {
|
for (var i = 0; i < plot_data.values.length; i += 1) {
|
||||||
if (plot_data.values[i] > 0) {
|
if (plot_data.values[i] > 0) {
|
||||||
annotations.values.push(plot_data.values[i]);
|
annotations.values.push(plot_data.values[i]);
|
||||||
annotations.labels.push(plot_data.labels[i]);
|
annotations.labels.push(plot_data.labels[i]);
|
||||||
|
@ -515,7 +515,7 @@ function populate_messages_sent_by_client(data) {
|
||||||
}
|
}
|
||||||
// prevent standard hash navigation (avoid blinking in IE)
|
// prevent standard hash navigation (avoid blinking in IE)
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var pos = $id.offset().top+$('.page-content')[0].scrollTop-50;
|
var pos = $id.offset().top + $('.page-content')[0].scrollTop - 50;
|
||||||
$('.page-content').animate({scrollTop: pos + "px"}, 500);
|
$('.page-content').animate({scrollTop: pos + "px"}, 500);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ function populate_messages_sent_by_message_type(data) {
|
||||||
function make_plot_data(time_series_data, num_steps) {
|
function make_plot_data(time_series_data, num_steps) {
|
||||||
var plot_data = compute_summary_chart_data(time_series_data, num_steps, data.display_order);
|
var plot_data = compute_summary_chart_data(time_series_data, num_steps, data.display_order);
|
||||||
var labels = [];
|
var labels = [];
|
||||||
for (var i=0; i<plot_data.labels.length; i+=1) {
|
for (var i = 0; i < plot_data.labels.length; i += 1) {
|
||||||
labels.push(plot_data.labels[i] + ' (' + plot_data.percentages[i] + ')');
|
labels.push(plot_data.labels[i] + ' (' + plot_data.percentages[i] + ')');
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
@ -646,7 +646,7 @@ function populate_number_of_users(data) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var end_dates = data.end_times.map(function (timestamp) {
|
var end_dates = data.end_times.map(function (timestamp) {
|
||||||
return new Date(timestamp*1000);
|
return new Date(timestamp * 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
var text = end_dates.map(function (date) {
|
var text = end_dates.map(function (date) {
|
||||||
|
|
|
@ -179,8 +179,8 @@ exports.get_color_class = _.memoize(function (color) {
|
||||||
|
|
||||||
// CSS colors are specified in the sRGB color space.
|
// CSS colors are specified in the sRGB color space.
|
||||||
// Convert to linear intensity values.
|
// Convert to linear intensity values.
|
||||||
for (i=0; i<3; i += 1) {
|
for (i = 0; i < 3; i += 1) {
|
||||||
channel[i] = colorspace.sRGB_to_linear(mult * parseInt(match[i+1], 16));
|
channel[i] = colorspace.sRGB_to_linear(mult * parseInt(match[i + 1], 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute perceived lightness as CIE L*.
|
// Compute perceived lightness as CIE L*.
|
||||||
|
|
|
@ -289,7 +289,7 @@ exports.bulk_set_stream_property = function (sub_data) {
|
||||||
return channel.post({
|
return channel.post({
|
||||||
url: '/json/users/me/subscriptions/properties',
|
url: '/json/users/me/subscriptions/properties',
|
||||||
data: {subscription_data: JSON.stringify(sub_data)},
|
data: {subscription_data: JSON.stringify(sub_data)},
|
||||||
timeout: 10*1000,
|
timeout: 10 * 1000,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ exports.wrap_exclude = function (lst, val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var inners = [
|
var inners = [
|
||||||
exports.sub_list_generator(lst, i+1, lst.length),
|
exports.sub_list_generator(lst, i + 1, lst.length),
|
||||||
exports.sub_list_generator(lst, 0, i),
|
exports.sub_list_generator(lst, 0, i),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ exports.reverse_wrap_exclude = function (lst, val) {
|
||||||
|
|
||||||
var inners = [
|
var inners = [
|
||||||
exports.reverse_sub_list_generator(lst, 0, i),
|
exports.reverse_sub_list_generator(lst, 0, i),
|
||||||
exports.reverse_sub_list_generator(lst, i+1, lst.length),
|
exports.reverse_sub_list_generator(lst, i + 1, lst.length),
|
||||||
];
|
];
|
||||||
|
|
||||||
return exports.chain(inners);
|
return exports.chain(inners);
|
||||||
|
|
Loading…
Reference in New Issue