mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	js: Automatically convert var to let and const in most files.
This commit was originally automatically generated using `tools/lint --only=eslint --fix`. It was then modified by tabbott to contain only changes to a set of files that are unlikely to result in significant merge conflicts with any open pull request, excluding about 20 files. His plan is to merge the remaining changes with more precise care, potentially involving merging parts of conflicting pull requests before running the `eslint --fix` operation. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							f7245e9ec6
						
					
				
				
					commit
					28f3dfa284
				
			@@ -1,8 +1,8 @@
 | 
			
		||||
var autosize = require('autosize');
 | 
			
		||||
const autosize = require('autosize');
 | 
			
		||||
 | 
			
		||||
function update_lock_icon_for_stream(stream_name) {
 | 
			
		||||
    var icon = $("#compose-lock-icon");
 | 
			
		||||
    var streamfield = $("#stream_message_recipient_stream");
 | 
			
		||||
    const icon = $("#compose-lock-icon");
 | 
			
		||||
    const streamfield = $("#stream_message_recipient_stream");
 | 
			
		||||
    if (stream_data.get_invite_only(stream_name)) {
 | 
			
		||||
        icon.show();
 | 
			
		||||
        streamfield.addClass("lock-padding");
 | 
			
		||||
@@ -48,14 +48,14 @@ function get_focus_area(msg_type, opts) {
 | 
			
		||||
exports._get_focus_area = get_focus_area;
 | 
			
		||||
 | 
			
		||||
exports.set_focus = function (msg_type, opts) {
 | 
			
		||||
    var focus_area = get_focus_area(msg_type, opts);
 | 
			
		||||
    const focus_area = get_focus_area(msg_type, opts);
 | 
			
		||||
    if (focus_area === undefined) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (window.getSelection().toString() === "" ||
 | 
			
		||||
         opts.trigger !== "message click") {
 | 
			
		||||
        var elt = $(focus_area);
 | 
			
		||||
        const elt = $(focus_area);
 | 
			
		||||
        elt.focus().select();
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
@@ -135,7 +135,7 @@ exports.complete_starting_tasks = function (msg_type, opts) {
 | 
			
		||||
// (In particular, if there's a color associated with it,
 | 
			
		||||
//  have that color be reflected here too.)
 | 
			
		||||
exports.decorate_stream_bar = function (stream_name) {
 | 
			
		||||
    var color = stream_data.get_color(stream_name);
 | 
			
		||||
    const color = stream_data.get_color(stream_name);
 | 
			
		||||
    update_lock_icon_for_stream(stream_name);
 | 
			
		||||
    $("#stream-message .message_header_stream")
 | 
			
		||||
        .css('background-color', color)
 | 
			
		||||
@@ -151,7 +151,7 @@ exports.maybe_scroll_up_selected_message = function () {
 | 
			
		||||
        // scroll the compose box to avoid it.
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    var selected_row = current_msg_list.selected_row();
 | 
			
		||||
    const selected_row = current_msg_list.selected_row();
 | 
			
		||||
 | 
			
		||||
    if (selected_row.height() > message_viewport.height() - 100) {
 | 
			
		||||
        // For very tall messages whose height is close to the entire
 | 
			
		||||
@@ -161,7 +161,7 @@ exports.maybe_scroll_up_selected_message = function () {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var cover = selected_row.offset().top + selected_row.height()
 | 
			
		||||
    const cover = selected_row.offset().top + selected_row.height()
 | 
			
		||||
        - $("#compose").offset().top;
 | 
			
		||||
    if (cover > 0) {
 | 
			
		||||
        message_viewport.user_initiated_animate_scroll(cover + 20);
 | 
			
		||||
@@ -169,7 +169,7 @@ exports.maybe_scroll_up_selected_message = function () {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function fill_in_opts_from_current_narrowed_view(msg_type, opts) {
 | 
			
		||||
    var default_opts = {
 | 
			
		||||
    let default_opts = {
 | 
			
		||||
        message_type: msg_type,
 | 
			
		||||
        stream: '',
 | 
			
		||||
        topic: '',
 | 
			
		||||
@@ -178,7 +178,7 @@ function fill_in_opts_from_current_narrowed_view(msg_type, opts) {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // Set default parameters based on the current narrowed view.
 | 
			
		||||
    var compose_opts = narrow_state.set_compose_defaults();
 | 
			
		||||
    const compose_opts = narrow_state.set_compose_defaults();
 | 
			
		||||
    default_opts = _.extend(default_opts, compose_opts);
 | 
			
		||||
    opts = _.extend(default_opts, opts);
 | 
			
		||||
    return opts;
 | 
			
		||||
@@ -194,7 +194,7 @@ function same_recipient_as_before(msg_type, opts) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.update_placeholder_text = function (opts) {
 | 
			
		||||
    var placeholder_text = compose_ui.compute_placeholder_text(opts);
 | 
			
		||||
    const placeholder_text = compose_ui.compute_placeholder_text(opts);
 | 
			
		||||
    $('#compose-textarea').attr('placeholder', placeholder_text);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -217,7 +217,7 @@ exports.start = function (msg_type, opts) {
 | 
			
		||||
        opts.private_message_recipient = '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var subbed_streams = stream_data.subscribed_subs();
 | 
			
		||||
    const subbed_streams = stream_data.subscribed_subs();
 | 
			
		||||
    if (subbed_streams.length === 1 && (opts.trigger === "new topic button" || opts.trigger === "compose_hotkey" && msg_type === "stream")) {
 | 
			
		||||
        opts.stream = subbed_streams[0].name;
 | 
			
		||||
    }
 | 
			
		||||
@@ -273,7 +273,7 @@ exports.cancel = function () {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.respond_to_message = function (opts) {
 | 
			
		||||
    var msg_type;
 | 
			
		||||
    let msg_type;
 | 
			
		||||
    // Before initiating a reply to a message, if there's an
 | 
			
		||||
    // in-progress composition, snapshot it.
 | 
			
		||||
    drafts.update_draft();
 | 
			
		||||
@@ -287,10 +287,10 @@ exports.respond_to_message = function (opts) {
 | 
			
		||||
            compose.nonexistent_stream_reply_error();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        var current_filter = narrow_state.filter();
 | 
			
		||||
        var first_term = current_filter.operators()[0];
 | 
			
		||||
        var first_operator = first_term.operator;
 | 
			
		||||
        var first_operand = first_term.operand;
 | 
			
		||||
        const current_filter = narrow_state.filter();
 | 
			
		||||
        const first_term = current_filter.operators()[0];
 | 
			
		||||
        const first_operator = first_term.operator;
 | 
			
		||||
        const first_operand = first_term.operand;
 | 
			
		||||
 | 
			
		||||
        if (first_operator === "stream" && !stream_data.is_subscribed(first_operand)) {
 | 
			
		||||
            compose.nonexistent_stream_reply_error();
 | 
			
		||||
@@ -304,7 +304,7 @@ exports.respond_to_message = function (opts) {
 | 
			
		||||
            msg_type = 'private';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var new_opts = fill_in_opts_from_current_narrowed_view(msg_type, opts);
 | 
			
		||||
        const new_opts = fill_in_opts_from_current_narrowed_view(msg_type, opts);
 | 
			
		||||
        exports.start(new_opts.message_type, new_opts);
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
@@ -313,14 +313,14 @@ exports.respond_to_message = function (opts) {
 | 
			
		||||
        unread_ops.notify_server_message_read(message);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var stream = '';
 | 
			
		||||
    var topic = '';
 | 
			
		||||
    let stream = '';
 | 
			
		||||
    let topic = '';
 | 
			
		||||
    if (message.type === "stream") {
 | 
			
		||||
        stream = message.stream;
 | 
			
		||||
        topic = util.get_message_topic(message);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var pm_recipient = message.reply_to;
 | 
			
		||||
    let pm_recipient = message.reply_to;
 | 
			
		||||
    if (message.type === "private") {
 | 
			
		||||
        if (opts.reply_type === "personal") {
 | 
			
		||||
            // reply_to for private messages is everyone involved, so for
 | 
			
		||||
@@ -344,8 +344,8 @@ exports.respond_to_message = function (opts) {
 | 
			
		||||
 | 
			
		||||
exports.reply_with_mention = function (opts) {
 | 
			
		||||
    exports.respond_to_message(opts);
 | 
			
		||||
    var message = current_msg_list.selected_message();
 | 
			
		||||
    var mention = people.get_mention_syntax(message.sender_full_name, message.sender_id);
 | 
			
		||||
    const message = current_msg_list.selected_message();
 | 
			
		||||
    const mention = people.get_mention_syntax(message.sender_full_name, message.sender_id);
 | 
			
		||||
    compose_ui.insert_syntax_and_focus(mention);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -395,9 +395,9 @@ exports.on_topic_narrow = function () {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.quote_and_reply = function (opts) {
 | 
			
		||||
    var textarea = $("#compose-textarea");
 | 
			
		||||
    var message_id = current_msg_list.selected_id();
 | 
			
		||||
    var message = current_msg_list.selected_message();
 | 
			
		||||
    const textarea = $("#compose-textarea");
 | 
			
		||||
    const message_id = current_msg_list.selected_id();
 | 
			
		||||
    const message = current_msg_list.selected_message();
 | 
			
		||||
 | 
			
		||||
    if (compose_state.has_message_content()) {
 | 
			
		||||
        // The user already started typing a message,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user