eslint: Enable space-infix-ops rule.

More about rule at  https://eslint.org/docs/rules/space-infix-ops
This commit is contained in:
Shubham Dhama 2018-06-05 00:43:07 +05:30
parent c6738889a9
commit cc03f9fb8f
46 changed files with 120 additions and 120 deletions

View File

@ -361,7 +361,7 @@
}
],
"space-in-parens": 2,
"space-infix-ops": 0,
"space-infix-ops": 2,
"spaced-comment": 0,
"strict": 0,
"template-curly-spacing": "error",

View File

@ -166,7 +166,7 @@ exports.select_item_via_typeahead = function (field_selector, str, item) {
var tah = $(field_selector).data().typeahead;
tah.mouseenter({
currentTarget: $('.typeahead:visible li:contains("'+item+'")')[0],
currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0],
});
tah.select();
}, {field_selector:field_selector, str: str, item: item});
@ -271,7 +271,7 @@ exports.then_send_message = function (type, params) {
// 'table' here).
exports.get_rendered_messages = function (table) {
return casper.evaluate(function (table) {
var tbl = $('#'+table);
var tbl = $('#' + table);
return {
headings: $.map(tbl.find('.recipient_row .message-header-contents'), function (elem) {
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
// bodies match the specified arrays.
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);

View File

@ -179,7 +179,7 @@ function search_silent_user(str, item) {
casper.then(function () {
casper.waitUntilVisible('#silent_user', function () {
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 ";
this.test.assertEquals(casper.fetchText('#silent_user'), expected_message);
});
@ -192,7 +192,7 @@ function search_non_existing_user(str, item) {
casper.then(function () {
casper.waitUntilVisible('#non_existing_user', function () {
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 ";
this.test.assertEquals(casper.fetchText('#non_existing_user'), expected_message);
});

View File

@ -299,7 +299,7 @@ function select_from_suggestions(item) {
casper.evaluate(function (item) {
var tah = $('.create_default_stream').data().typeahead;
tah.mouseenter({
currentTarget: $('.typeahead:visible li:contains("'+item+'")')[0],
currentTarget: $('.typeahead:visible li:contains("' + item + '")')[0],
});
tah.select();
}, {item: item});
@ -320,21 +320,21 @@ casper.then(function () {
});
casper.then(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.waitUntilVisible('.default_stream_row[id=' + stream_name + ']', function () {
casper.test.assertSelectorHasText('.default_stream_row[id=' + stream_name + '] .default_stream_name', stream_name);
});
});
casper.then(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.click('.default_stream_row[id='+stream_name+'] button.remove-default-stream');
casper.waitUntilVisible('.default_stream_row[id=' + stream_name + ']', function () {
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.then(function () {
casper.waitWhileVisible('.default_stream_row[id='+stream_name+']', function () {
casper.test.assertDoesntExist('.default_stream_row[id='+stream_name+']');
casper.waitWhileVisible('.default_stream_row[id=' + stream_name + ']', function () {
casper.test.assertDoesntExist('.default_stream_row[id=' + stream_name + ']');
});
});

View File

@ -387,8 +387,8 @@ function simulate_list_items(items) {
$('#user_presences').set_find_results('li.user_sidebar_entry', list);
_.each(items, (item, i) => {
item.next = () => items[i+1] || {length: 0};
item.prev = () => items[i-1] || {length: 0};
item.next = () => items[i + 1] || {length: 0};
item.prev = () => items[i - 1] || {length: 0};
});
}

View File

@ -349,8 +349,8 @@ run_test('markdown_shortcuts', () => {
global.document.execCommand = function (cmd, bool, markdown) {
var compose_textarea = $("#compose-textarea");
var value = compose_textarea.val();
$("#compose-textarea").val(value.substring(0, compose_textarea.range().start)+
markdown+value.substring(compose_textarea.range().end, value.length));
$("#compose-textarea").val(value.substring(0, compose_textarea.range().start) +
markdown + value.substring(compose_textarea.range().end, value.length));
};
$("#compose-textarea").range = function () {
@ -359,7 +359,7 @@ run_test('markdown_shortcuts', () => {
end: range_start + range_length,
length: range_length,
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;

View File

@ -58,7 +58,7 @@ run_test('pills', () => {
pills = {
pill: {},
};
all_pills= {};
all_pills = {};
};
var appendValue_called;

View File

@ -936,7 +936,7 @@ run_test('begins_typeahead', () => {
var all_items = _.map(['all', 'everyone', 'stream'], function (mention) {
return {
special_item_text: 'translated: ' + mention +" (Notify stream)",
special_item_text: 'translated: ' + mention + " (Notify stream)",
email: mention,
pm_recipient_count: Infinity,
full_name: mention,
@ -1130,7 +1130,7 @@ run_test('content_highlighter', () => {
run_test('typeahead_results', () => {
var all_items = _.map(['all', 'everyone', 'stream'], function (mention) {
return {
special_item_text: 'translated: ' + mention +" (Notify stream)",
special_item_text: 'translated: ' + mention + " (Notify stream)",
email: mention,
pm_recipient_count: Infinity,
full_name: mention,

View File

@ -54,7 +54,7 @@ run_test('get_editability', () => {
realm_message_content_edit_limit_seconds: 10,
};
var now = new Date();
var current_timestamp = now/1000;
var current_timestamp = now / 1000;
message.timestamp = current_timestamp - 60;
// Have 55+10 > 60 seconds from message.timestamp to edit the message; we're good!
assert.equal(get_editability(message, 55), editability_types.FULL);

View File

@ -270,7 +270,7 @@ run_test('last_sent_by_me', () => {
run_test('local_echo', () => {
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._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(20), 20);
@ -294,8 +294,8 @@ run_test('local_echo', () => {
list.append([
{id:10}, {id:20}, {id:30}, {id:20.02}, {id:20.03}, {id:40},
{id:50}, {id: 50.01}, {id: 50.02}, {id:60}]);
list._local_only= {20.02: {id:20.02}, 20.03: {id:20.03},
50.01: {id: 50.01}, 50.02: {id: 50.02}};
list._local_only = {20.02: {id:20.02}, 20.03: {id:20.03},
50.01: {id: 50.01}, 50.02: {id: 50.02}};
assert.equal(list.closest_id(10), 10);
assert.equal(list.closest_id(20), 20);

View File

@ -398,7 +398,7 @@ run_test('with_external_user', () => {
var exit_button = $.create('fake-pill-exit');
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_called = true;
assert.equal(property, 'opacity');

View File

@ -1564,7 +1564,7 @@ run_test('embedded_bot_config_item', () => {
};
var html = render('embedded_bot_config_item', args);
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('input').attr('placeholder'), args.value);
});

View File

@ -324,7 +324,7 @@ run_test('sort_recipients', () => {
assert.deepEqual(recipients_email, expected);
// Reset matches
matches.splice(matches.length-1, 1);
matches.splice(matches.length - 1, 1);
// full_name starts with same character but emails are 'all'
var small_matches = [

View File

@ -286,7 +286,7 @@ run_test('num_unread_for_topic', () => {
assert.deepEqual(missing_topics, []);
for (i = 0; i < num_msgs; i += 1) {
message.id = i+1;
message.id = i + 1;
unread.mark_as_read(message.id);
}

View File

@ -77,7 +77,7 @@ run_test('upload_error', () => {
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();
file.lastModified = 1549958107000;
upload_opts.error(err, server_response, file);

View File

@ -200,27 +200,27 @@ run_test('all_and_everyone_mentions_regexp', () => {
];
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]));
}
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]));
}
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]));
}
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]));
}
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]));
}
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]));
}
});

View File

@ -88,7 +88,7 @@ function short_tb(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

View File

@ -109,7 +109,7 @@ function diff_strings(string_0, string_1) {
} else if (line.startsWith("?")) {
changes_list = parse_questionmark_line(line);
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 {
output_lines.push(line);
}

View File

@ -17,7 +17,7 @@ exports.sRGB_to_linear = function (v) {
// Compute luminance (CIE Y stimulus) from linear intensity
// of sRGB / Rec. 709 primaries.
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)
@ -27,12 +27,12 @@ exports.rgb_luminance = function (channel) {
exports.luminance_to_lightness = function (luminance) {
var v;
if (luminance <= (216 / 24389)) {
v = (841 / 108)*luminance + (4 / 29);
v = (841 / 108) * luminance + (4 / 29);
} 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) {

View File

@ -160,7 +160,7 @@ exports.maybe_scroll_up_selected_message = function () {
var cover = selected_row.offset().top + selected_row.height()
- $("#compose").offset().top;
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,
success: function (data) {
if (textarea.val() === "") {
textarea.val("```quote\n" + data.raw_content +"\n```\n");
textarea.val("```quote\n" + data.raw_content + "\n```\n");
} 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");
},

View File

@ -30,7 +30,7 @@ function get_or_set(fieldname, keep_leading_whitespace) {
// because the DOM element might not exist yet when get_or_set
// is called.
return function (newval) {
var elem = $('#'+fieldname);
var elem = $('#' + fieldname);
var oldval = elem.val();
if (newval !== undefined) {
elem.val(newval);

View File

@ -281,8 +281,8 @@ exports.tokenize_compose_str = function (s) {
// Code block must start on a new line
if (i === 2) {
return s.slice(0);
} else if (i > 2 && s[i-3] === "\n") {
return s.slice(i-2);
} else if (i > 2 && s[i - 3] === "\n") {
return s.slice(i - 2);
}
break;
case '#':
@ -290,7 +290,7 @@ exports.tokenize_compose_str = function (s) {
case ':':
if (i === 0) {
return s.slice(i);
} else if (/[\s(){}\[\]]/.test(s[i-1])) {
} else if (/[\s(){}\[\]]/.test(s[i - 1])) {
return s.slice(i);
}
}
@ -446,7 +446,7 @@ exports.content_typeahead_selected = function (item) {
if (beginning.lastIndexOf(":") === 0 ||
beginning.charAt(beginning.lastIndexOf(":") - 1) === " " ||
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 {
beginning = (beginning.substring(0, beginning.length - this.token.length - 1) + " :" + item.emoji_name + ": ");
}

View File

@ -207,7 +207,7 @@ exports.setup_page = function (callback) {
data_array.push([id, data[id]]);
});
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) {
var draft = data_element[1];
@ -314,7 +314,7 @@ function drafts_initialize_focus(event_name) {
var draft_element;
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") {
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")) {
exports.restore_draft(focused_draft);
} 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);
}
}
@ -429,7 +429,7 @@ exports.launch = function () {
var draft_list = drafts.draft_model.get();
var draft_id_list = Object.getOwnPropertyNames(draft_list);
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 focus_element = last_draft_element[0].children[0];
focus_element.focus();

View File

@ -548,7 +548,7 @@ exports.emoji_select_tab = function (elt) {
var elt_height = elt.height();
var currently_selected = "";
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;
}
});
@ -563,7 +563,7 @@ exports.emoji_select_tab = function (elt) {
}
if (currently_selected) {
$('.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');
}
};

View File

@ -621,10 +621,10 @@ function describe_unescaped(operators) {
var more_parts = _.map(operators, function (elem) {
var operand = elem.operand;
var canonicalized_operator = Filter.canonicalize_operator(elem.operator);
if (canonicalized_operator ==='is') {
if (canonicalized_operator === 'is') {
return describe_is_operator(elem);
}
if (canonicalized_operator ==='has') {
if (canonicalized_operator === 'has') {
// search_suggestion.get_suggestions takes care that this message will
// only be shown if the `has` operator is not at the last.
var valid_has_operands = ['image', 'images', 'link', 'links', 'attachment', 'attachments'];

View File

@ -72,7 +72,7 @@ exports.save_narrow = function (operators) {
exports.parse_narrow = function (hash) {
var i;
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,
// but the user might write one.
try {
@ -82,7 +82,7 @@ exports.parse_narrow = function (hash) {
break;
}
var operand = hash_util.decode_operand(operator, hash[i+1] || '');
var operand = hash_util.decode_operand(operator, hash[i + 1] || '');
var negated = false;
if (operator[0] === '-') {
negated = true;

View File

@ -47,7 +47,7 @@ function create_bot(full_name, short_name, bot_avatar_file, stream_name,
formData.append('csrfmiddlewaretoken', csrf_token);
formData.append('full_name', full_name);
formData.append('short_name', short_name);
formData.append('file-'+0, bot_avatar_file);
formData.append('file-' + 0, bot_avatar_file);
channel.post({
url: '/json/bots',
data: formData,

View File

@ -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
// 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;
if (id <= selected_id) {
break;

View File

@ -3,7 +3,7 @@ var message_fetch = (function () {
var exports = {};
var consts = {
backfill_idle_time: 10*1000,
backfill_idle_time: 10 * 1000,
error_retry_time: 5000,
backfill_batch_size: 1000,
narrow_before: 50,
@ -315,7 +315,7 @@ exports.initialize = function () {
// If we fall through here, we need to keep fetching more data, and
// we'll call back to the function we're in.
var messages = data.messages;
var latest_id = messages[messages.length-1].id;
var latest_id = messages[messages.length - 1].id;
exports.load_messages({
anchor: latest_id.toFixed(),

View File

@ -89,7 +89,7 @@ MessageListData.prototype = {
return false;
}
var last_msg = this._items[n-1];
var last_msg = this._items[n - 1];
return (last_msg.id === this._selected_id);
},

View File

@ -312,9 +312,9 @@ exports.recenter_view = function (message, opts) {
}
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) {
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 top_threshold = info.visible_top + (1/10 * info.visible_height);
var bottom_threshold = info.visible_top + (9/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);
function message_is_far_enough_down() {
if (message_viewport.at_top()) {

View File

@ -144,7 +144,7 @@ exports.redraw_title = function () {
n = 'infinite';
}
current_favicon = previous_favicon = '/static/images/favicon/favicon-'+n+'.png';
current_favicon = previous_favicon = '/static/images/favicon/favicon-' + n + '.png';
} else {
current_favicon = previous_favicon = '/static/favicon.ico?v=2';
}

View File

@ -373,7 +373,7 @@ exports.render_actions_remind_popover = function (element, id) {
trigger: "manual",
});
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,
clickOpens: false,
defaultDate: moment().format(),

View File

@ -9,10 +9,10 @@ function registerCodeSection($codeSection) {
const language = this.dataset.language;
$li.removeClass("active");
$li.filter("[data-language="+language+"]").addClass("active");
$li.filter("[data-language=" + language + "]").addClass("active");
$blocks.removeClass("active");
$blocks.filter("[data-language="+language+"]").addClass("active");
$blocks.filter("[data-language=" + language + "]").addClass("active");
});
$li.eq(0).click();

View File

@ -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
// 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);
window.location.replace("#reload:" + token);
@ -262,9 +262,9 @@ exports.initiate = function (options) {
// while composing. If they finish or cancel the compose, wait
// until they're idle again
var idle_control;
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 home_timeout = 1000*60 + util.random_int(0, 1000*60);
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 home_timeout = 1000 * 60 + util.random_int(0, 1000 * 60);
var compose_done_handler;
var compose_started_handler;

View File

@ -216,8 +216,8 @@ function get_events(options) {
undefined,
ex.stack);
}
var retry_sec = Math.min(90, Math.exp(get_events_failures/2));
get_events_timeout = setTimeout(get_events, retry_sec*1000);
var retry_sec = Math.min(90, Math.exp(get_events_failures / 2));
get_events_timeout = setTimeout(get_events, retry_sec * 1000);
},
});
}

View File

@ -418,7 +418,7 @@ exports.set_up = function () {
form_data.append('csrfmiddlewaretoken', csrf_token);
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();

View File

@ -184,7 +184,7 @@ exports.set_up = function () {
var selected_embedded_bot = 'converter';
$('#select_service_name').val(selected_embedded_bot); // TODO: Use 'select a bot'.
$('#config_inputbox').children().hide();
$("[name*='"+selected_embedded_bot+"']").show();
$("[name*='" + selected_embedded_bot + "']").show();
$('#download_botserverrc').click(function () {
var OUTGOING_WEBHOOK_BOT_TYPE_INT = 3;
@ -243,13 +243,13 @@ exports.set_up = function () {
} else if (bot_type === EMBEDDED_BOT_TYPE) {
formData.append('service_name', service_name);
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();
});
formData.append('config_data', JSON.stringify(config_data));
}
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')});
channel.post({
@ -265,7 +265,7 @@ exports.set_up = function () {
$('#create_payload_url').val('');
$('#payload_url_inputbox').hide();
$('#config_inputbox').hide();
$("[name*='"+service_name+"'] input").each(function () {
$("[name*='" + service_name + "'] input").each(function () {
$(this).val('');
});
$('#create_bot_type').val(GENERIC_BOT_TYPE);
@ -311,7 +311,7 @@ exports.set_up = function () {
$("#select_service_name").on("change", function () {
$('#config_inputbox').children().hide();
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) {
@ -421,7 +421,7 @@ exports.set_up = function () {
formData.append('config_data', JSON.stringify(config_data));
}
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'});
edit_button.hide();
@ -442,7 +442,7 @@ exports.set_up = function () {
// when the user had a previous uploaded avatar. Only the content
// changes, so we version it to get an uncached copy.
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) {

View File

@ -57,7 +57,7 @@ exports.set_up = function () {
channel.get({
url: '/json/invites',
idempotent: true,
timeout: 10*1000,
timeout: 10 * 1000,
success: exports.on_load_success,
error: failed_listing_invites,
});

View File

@ -90,7 +90,7 @@ function get_subsection_property_types(subsection) {
}
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)) {
val = parseInt(val, 10);
}
@ -200,23 +200,23 @@ var time_limit_dropdown_values = {
},
upto_two_min: {
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("2 minutes")}),
seconds: 2*60,
seconds: 2 * 60,
},
upto_ten_min: {
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("10 minutes")}),
seconds: 10*60,
seconds: 10 * 60,
},
upto_one_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: {
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: {
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: {
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') {
property = 'user_invite_restriction';
}
var element = $('#id_realm_'+property);
var element = $('#id_realm_' + property);
if (element.length) {
discard_property_element_changes(element);
}
@ -515,15 +515,15 @@ exports.set_up = function () {
_.each(changing_property_types, function (v, k) {
var field = changing_property_types[k];
if (field.type === 'bool') {
data[k] = JSON.stringify($('#id_realm_'+k).prop('checked'));
data[k] = JSON.stringify($('#id_realm_' + k).prop('checked'));
return;
}
if (field.type === 'text') {
data[k] = JSON.stringify($('#id_realm_'+k).val().trim());
data[k] = JSON.stringify($('#id_realm_' + k).val().trim());
return;
}
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;
@ -989,7 +989,7 @@ exports.set_up = function () {
form_data.append('csrfmiddlewaretoken', csrf_token);
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();

View File

@ -211,7 +211,7 @@ exports.set_up = function () {
channel.get({
url: '/json/users',
idempotent: true,
timeout: 10*1000,
timeout: 10 * 1000,
success: exports.on_load_success,
error: failed_listing_users,
});

View File

@ -287,7 +287,7 @@ Socket.prototype = {
// immediately reconnect when the page is refreshing
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) {

View File

@ -166,7 +166,7 @@ function populate_messages_sent_over_time(data) {
var start_dates = data.end_times.map(function (timestamp) {
// 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) {
@ -211,7 +211,7 @@ function populate_messages_sent_over_time(data) {
return {
dates: dates, values: values,
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
@ -235,7 +235,7 @@ function populate_messages_sent_over_time(data) {
var weekly_traces = make_traces(info.dates, info.values, 'bar', date_formatter);
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),
me: partial_sums(data.user.human)};
@ -314,7 +314,7 @@ function round_to_percentages(values, total) {
if (x === 0) {
return '0%';
}
var unrounded = x/total*100;
var unrounded = x / total * 100;
var precision = Math.min(
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;
}
var sum = 0;
for (var i=1; i<=num_steps; i+=1) {
sum += time_series_data[key][time_series_data[key].length-i];
for (var i = 1; i <= num_steps; i += 1) {
sum += time_series_data[key][time_series_data[key].length - i];
}
data[key] = sum;
}
@ -356,10 +356,10 @@ function compute_summary_chart_data(time_series_data, num_steps, labels_) {
}
});
if (!$.isEmptyObject(data)) {
labels[labels.length-1] = "Other";
labels[labels.length - 1] = "Other";
for (key in data) {
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(
data.everyone, 30, data.display_order.slice(0, 12));
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: everyone_month.labels[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.percentages.reverse();
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) {
annotations.values.push(plot_data.values[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)
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);
});
}
@ -531,7 +531,7 @@ function populate_messages_sent_by_message_type(data) {
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 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] + ')');
}
return {
@ -646,7 +646,7 @@ function populate_number_of_users(data) {
};
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) {

View File

@ -179,8 +179,8 @@ exports.get_color_class = _.memoize(function (color) {
// CSS colors are specified in the sRGB color space.
// Convert to linear intensity values.
for (i=0; i<3; i += 1) {
channel[i] = colorspace.sRGB_to_linear(mult * parseInt(match[i+1], 16));
for (i = 0; i < 3; i += 1) {
channel[i] = colorspace.sRGB_to_linear(mult * parseInt(match[i + 1], 16));
}
// Compute perceived lightness as CIE L*.

View File

@ -289,7 +289,7 @@ exports.bulk_set_stream_property = function (sub_data) {
return channel.post({
url: '/json/users/me/subscriptions/properties',
data: {subscription_data: JSON.stringify(sub_data)},
timeout: 10*1000,
timeout: 10 * 1000,
});
};

View File

@ -108,7 +108,7 @@ exports.wrap_exclude = function (lst, val) {
}
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),
];
@ -127,7 +127,7 @@ exports.reverse_wrap_exclude = function (lst, val) {
var inners = [
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);