mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 02:17:19 +00:00
Move "page parameters" (email, enter_sends, etc) into a single object
(imported from commit 842b2371bf6364982f1358f1cd2d91118c7fb2bf)
This commit is contained in:
@@ -52,33 +52,36 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
{% autoescape off %}
|
{% autoescape off %}
|
||||||
|
var page_params = {
|
||||||
|
|
||||||
{# Not escaped, because it's guaranteed by the model to be an integer. #}
|
{# Not escaped, because it's guaranteed by the model to be an integer. #}
|
||||||
var initial_pointer = {{ user_profile.pointer }};
|
initial_pointer: {{ user_profile.pointer }},
|
||||||
|
|
||||||
var poll_timeout = {{ poll_timeout }};
|
poll_timeout: {{ poll_timeout }},
|
||||||
|
|
||||||
var fullname = "{{ user_profile.full_name|escapejs }}";
|
fullname: "{{ user_profile.full_name|escapejs }}",
|
||||||
var email = "{{ user_profile.user.email|escapejs }}";
|
email: "{{ user_profile.user.email|escapejs }}",
|
||||||
var domain = "{{ user_profile.realm.domain|escapejs }}";
|
domain: "{{ user_profile.realm.domain|escapejs }}",
|
||||||
var have_initial_messages = {{ have_initial_messages|escapejs }};
|
have_initial_messages: {{ have_initial_messages|escapejs }},
|
||||||
var desktop_notifications_enabled = {{ desktop_notifications_enabled|escapejs }};
|
desktop_notifications_enabled: {{ desktop_notifications_enabled|escapejs }},
|
||||||
var enter_sends = {{ enter_sends|escapejs }};
|
enter_sends: {{ enter_sends|escapejs }},
|
||||||
var debug_mode = {% if debug %} true {% else %} false {% endif %};
|
debug_mode: {% if debug %} true {% else %} false {% endif %},
|
||||||
var needs_tutorial = {{ needs_tutorial|escapejs }};
|
needs_tutorial: {{ needs_tutorial|escapejs }},
|
||||||
|
|
||||||
{# We use JSONEncoderForHTML to generate "streams". #}
|
{# We use JSONEncoderForHTML to generate "streams". #}
|
||||||
var stream_list = {{ streams }};
|
stream_list: {{ streams }},
|
||||||
|
|
||||||
var people_list = [
|
|
||||||
{% for person in people %}
|
|
||||||
{ 'email': "{{ person.email|escapejs }}",
|
|
||||||
'full_name': "{{ person.full_name|escapejs }}" },
|
|
||||||
{% endfor %}
|
|
||||||
];
|
|
||||||
|
|
||||||
|
people_list: [
|
||||||
|
{% for person in people %}
|
||||||
|
{ 'email': "{{ person.email|escapejs }}",
|
||||||
|
'full_name': "{{ person.full_name|escapejs }}" },
|
||||||
|
{% endfor %}
|
||||||
|
]
|
||||||
|
};
|
||||||
{% endautoescape %}
|
{% endautoescape %}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@@ -6,9 +6,7 @@ var globals =
|
|||||||
' $ jQuery Spinner Handlebars XDate'
|
' $ jQuery Spinner Handlebars XDate'
|
||||||
|
|
||||||
// index.html
|
// index.html
|
||||||
+ ' initial_pointer email stream_list people_list have_initial_messages'
|
+ ' page_params'
|
||||||
+ ' fullname desktop_notifications_enabled enter_sends domain poll_timeout'
|
|
||||||
+ ' debug_mode needs_tutorial'
|
|
||||||
|
|
||||||
// common.js
|
// common.js
|
||||||
+ ' status_classes'
|
+ ' status_classes'
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ function focus_ping() {
|
|||||||
age = now - presence.website.timestamp;
|
age = now - presence.website.timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (email !== this_email) {
|
if (page_params.email !== this_email) {
|
||||||
var status = 'idle';
|
var status = 'idle';
|
||||||
if (presence.website !== undefined
|
if (presence.website !== undefined
|
||||||
&& presence.website.status === ACTIVE && age >= 0) {
|
&& presence.website.status === ACTIVE && age >= 0) {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ BlueslipError.prototype = Error.prototype;
|
|||||||
return func.blueslip_wrapper;
|
return func.blueslip_wrapper;
|
||||||
}
|
}
|
||||||
var new_func = function blueslip_wrapper() {
|
var new_func = function blueslip_wrapper() {
|
||||||
if (debug_mode) {
|
if (page_params.debug_mode) {
|
||||||
return func.apply(this, arguments);
|
return func.apply(this, arguments);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -230,13 +230,13 @@ exports.info = function blueslip_info (msg) {
|
|||||||
|
|
||||||
exports.warn = function blueslip_warn (msg) {
|
exports.warn = function blueslip_warn (msg) {
|
||||||
console.warn(msg);
|
console.warn(msg);
|
||||||
if (debug_mode) {
|
if (page_params.debug_mode) {
|
||||||
console.trace();
|
console.trace();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.error = function blueslip_error (msg) {
|
exports.error = function blueslip_error (msg) {
|
||||||
if (debug_mode) {
|
if (page_params.debug_mode) {
|
||||||
throw new BlueslipError(msg);
|
throw new BlueslipError(msg);
|
||||||
} else {
|
} else {
|
||||||
console.error(msg);
|
console.error(msg);
|
||||||
@@ -245,7 +245,7 @@ exports.error = function blueslip_error (msg) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.fatal = function blueslip_fatal (msg) {
|
exports.fatal = function blueslip_fatal (msg) {
|
||||||
if (! debug_mode) {
|
if (! page_params.debug_mode) {
|
||||||
report_error(msg, Error().stack, {show_ui_msg: true});
|
report_error(msg, Error().stack, {show_ui_msg: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,8 +95,8 @@ function handle_keydown(e) {
|
|||||||
// want to change focus right away in the private_message_recipient box since it
|
// want to change focus right away in the private_message_recipient box since it
|
||||||
// takes the typeaheads a little time to open after the user finishes typing, which
|
// takes the typeaheads a little time to open after the user finishes typing, which
|
||||||
// can lead to the focus moving without the autocomplete having a chance to happen.
|
// can lead to the focus moving without the autocomplete having a chance to happen.
|
||||||
if ((domain === "humbughq.com" && nextFocus === "compose-send-button") ||
|
if ((page_params.domain === "humbughq.com" && nextFocus === "compose-send-button") ||
|
||||||
(domain !== "humbughq.com" && nextFocus)) {
|
(page_params.domain !== "humbughq.com" && nextFocus)) {
|
||||||
ui.focus_on(nextFocus);
|
ui.focus_on(nextFocus);
|
||||||
nextFocus = false;
|
nextFocus = false;
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ function handle_keydown(e) {
|
|||||||
// (Unless shift is being held down, which we *do* want to insert a linebreak)
|
// (Unless shift is being held down, which we *do* want to insert a linebreak)
|
||||||
if (e.target.id === "new_message_content"
|
if (e.target.id === "new_message_content"
|
||||||
&& code === 13 && !e.shiftKey
|
&& code === 13 && !e.shiftKey
|
||||||
&& enter_sends) {
|
&& page_params.enter_sends) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if ($("#compose-send-button").attr('disabled') !== "disabled") {
|
if ($("#compose-send-button").attr('disabled') !== "disabled") {
|
||||||
$("#compose-send-button").attr('disabled', 'disabled');
|
$("#compose-send-button").attr('disabled', 'disabled');
|
||||||
@@ -158,8 +158,8 @@ exports.initialize = function () {
|
|||||||
|
|
||||||
$("#enter_sends").click(function () {
|
$("#enter_sends").click(function () {
|
||||||
var send_button = $("#compose-send-button");
|
var send_button = $("#compose-send-button");
|
||||||
enter_sends = $("#enter_sends").is(":checked");
|
page_params.enter_sends = $("#enter_sends").is(":checked");
|
||||||
if (enter_sends) {
|
if (page_params.enter_sends) {
|
||||||
send_button.fadeOut();
|
send_button.fadeOut();
|
||||||
} else {
|
} else {
|
||||||
send_button.fadeIn();
|
send_button.fadeIn();
|
||||||
@@ -168,11 +168,11 @@ exports.initialize = function () {
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
url: '/json/change_enter_sends',
|
url: '/json/change_enter_sends',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {'enter_sends': enter_sends}
|
data: {'enter_sends': page_params.enter_sends}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$("#enter_sends").prop('checked', enter_sends);
|
$("#enter_sends").prop('checked', page_params.enter_sends);
|
||||||
if (enter_sends) $("#compose-send-button").hide();
|
if (page_params.enter_sends) $("#compose-send-button").hide();
|
||||||
|
|
||||||
// limit number of items so the list doesn't fall off the screen
|
// limit number of items so the list doesn't fall off the screen
|
||||||
$( "#stream" ).typeahead({
|
$( "#stream" ).typeahead({
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function parse_narrow(hash) {
|
|||||||
if (current_msg_list.selected_id() !== -1) {
|
if (current_msg_list.selected_id() !== -1) {
|
||||||
new_selection = current_msg_list.selected_id();
|
new_selection = current_msg_list.selected_id();
|
||||||
} else {
|
} else {
|
||||||
new_selection = initial_pointer;
|
new_selection = page_params.initial_pointer;
|
||||||
}
|
}
|
||||||
narrow.activate(operators, {
|
narrow.activate(operators, {
|
||||||
then_select_id: new_selection,
|
then_select_id: new_selection,
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ MessageList.prototype = {
|
|||||||
|
|
||||||
message.dom_id = table_name + message.id;
|
message.dom_id = table_name + message.id;
|
||||||
|
|
||||||
if (message.sender_email === email) {
|
if (message.sender_email === page_params.email) {
|
||||||
message.stamp = ui.get_gravatar_stamp();
|
message.stamp = ui.get_gravatar_stamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ function browser_desktop_notifications_on () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.initialize = function () {
|
exports.initialize = function () {
|
||||||
names = fullname.toLowerCase().split(" ");
|
names = page_params.fullname.toLowerCase().split(" ");
|
||||||
names.push(email.split("@")[0].toLowerCase());
|
names.push(page_params.email.split("@")[0].toLowerCase());
|
||||||
names.push("all");
|
names.push("all");
|
||||||
names.push("everyone");
|
names.push("everyone");
|
||||||
names.push("<strong>" + fullname.toLowerCase() + "</strong>");
|
names.push("<strong>" + page_params.fullname.toLowerCase() + "</strong>");
|
||||||
|
|
||||||
$(window).focus(function () {
|
$(window).focus(function () {
|
||||||
window_has_focus = true;
|
window_has_focus = true;
|
||||||
@@ -43,7 +43,7 @@ exports.initialize = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).click(function () {
|
$(document).click(function () {
|
||||||
if (!desktop_notifications_enabled || asked_permission_already) {
|
if (!page_params.desktop_notifications_enabled || asked_permission_already) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.webkitNotifications.checkPermission() !== 0) { // 0 is PERMISSION_ALLOWED
|
if (window.webkitNotifications.checkPermission() !== 0) { // 0 is PERMISSION_ALLOWED
|
||||||
@@ -59,7 +59,7 @@ exports.update_title_count = function () {
|
|||||||
|
|
||||||
var new_message_count = unread_in_current_view();
|
var new_message_count = unread_in_current_view();
|
||||||
document.title = (new_message_count ? ("(" + new_message_count + ") ") : "")
|
document.title = (new_message_count ? ("(" + new_message_count + ") ") : "")
|
||||||
+ domain + " - Humbug";
|
+ page_params.domain + " - Humbug";
|
||||||
|
|
||||||
// IE doesn't support PNG favicons, *shrug*
|
// IE doesn't support PNG favicons, *shrug*
|
||||||
if (! $.browser.msie) {
|
if (! $.browser.msie) {
|
||||||
@@ -163,7 +163,7 @@ exports.speaking_at_me = function (message) {
|
|||||||
var found_match = false, indexof, after_name, after_atname;
|
var found_match = false, indexof, after_name, after_atname;
|
||||||
var punctuation = /[\.,-\/#!$%\^&\*;:{}=\-_`~()\+\?\[\]\s<>]/;
|
var punctuation = /[\.,-\/#!$%\^&\*;:{}=\-_`~()\+\?\[\]\s<>]/;
|
||||||
|
|
||||||
if (domain === "mit.edu") {
|
if (page_params.domain === "mit.edu") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,10 +199,10 @@ exports.received_messages = function (messages) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$.each(messages, function (index, message) {
|
$.each(messages, function (index, message) {
|
||||||
if (message.sender_email !== email && narrow.message_in_home(message)) {
|
if (message.sender_email !== page_params.email && narrow.message_in_home(message)) {
|
||||||
title_needs_update = true;
|
title_needs_update = true;
|
||||||
|
|
||||||
if (desktop_notifications_enabled &&
|
if (page_params.desktop_notifications_enabled &&
|
||||||
browser_desktop_notifications_on() &&
|
browser_desktop_notifications_on() &&
|
||||||
(message.type === "private" ||
|
(message.type === "private" ||
|
||||||
exports.speaking_at_me(message))) {
|
exports.speaking_at_me(message))) {
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ exports.update_typeahead = function () {
|
|||||||
var streams = $.map(subs.subscribed_streams(), function(elt,idx) {
|
var streams = $.map(subs.subscribed_streams(), function(elt,idx) {
|
||||||
return {action: 'stream', query: elt};
|
return {action: 'stream', query: elt};
|
||||||
});
|
});
|
||||||
var people = $.map(people_list, function(elt,idx) {
|
var people = $.map(page_params.people_list, function(elt,idx) {
|
||||||
return {action: 'private_message', query: elt};
|
return {action: 'private_message', query: elt};
|
||||||
});
|
});
|
||||||
var senders = $.map(people_list, function(elt,idx) {
|
var senders = $.map(page_params.people_list, function(elt,idx) {
|
||||||
return {action: 'sender', query: elt};
|
return {action: 'sender', query: elt};
|
||||||
});
|
});
|
||||||
var options = streams.concat(people).concat(senders);
|
var options = streams.concat(people).concat(senders);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ var csrf_token;
|
|||||||
$(function () {
|
$(function () {
|
||||||
// Display loading indicator. This disappears after the first
|
// Display loading indicator. This disappears after the first
|
||||||
// get_updates completes.
|
// get_updates completes.
|
||||||
if (have_initial_messages) {
|
if (page_params.have_initial_messages) {
|
||||||
util.make_loading_indicator($('#page_loading_indicator'), 'Loading...');
|
util.make_loading_indicator($('#page_loading_indicator'), 'Loading...');
|
||||||
} else {
|
} else {
|
||||||
util.show_first_run_message();
|
util.show_first_run_message();
|
||||||
|
|||||||
@@ -80,11 +80,11 @@ exports.maybe_toggle_all_messages = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function should_render_subscribers() {
|
function should_render_subscribers() {
|
||||||
return domain !== 'mit.edu';
|
return page_params.domain !== 'mit.edu';
|
||||||
}
|
}
|
||||||
|
|
||||||
function should_list_all_streams() {
|
function should_list_all_streams() {
|
||||||
return domain !== 'mit.edu';
|
return page_params.domain !== 'mit.edu';
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_table_stream_color(table, stream_name, color) {
|
function update_table_stream_color(table, stream_name, color) {
|
||||||
@@ -299,7 +299,7 @@ function mark_subscribed(stream_name, attrs) {
|
|||||||
var settings = settings_for_sub(sub);
|
var settings = settings_for_sub(sub);
|
||||||
if (sub.render_subscribers && settings.hasClass('in')) {
|
if (sub.render_subscribers && settings.hasClass('in')) {
|
||||||
var members = settings.find(".subscriber_list_container ul");
|
var members = settings.find(".subscriber_list_container ul");
|
||||||
add_to_member_list(members, fullname, email);
|
add_to_member_list(members, page_params.fullname, page_params.email);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the swatch and subscription settings
|
// Display the swatch and subscription settings
|
||||||
@@ -525,12 +525,12 @@ function ajaxSubscribe(stream) {
|
|||||||
var res = $.parseJSON(xhr.responseText);
|
var res = $.parseJSON(xhr.responseText);
|
||||||
if (!$.isEmptyObject(res.already_subscribed)) {
|
if (!$.isEmptyObject(res.already_subscribed)) {
|
||||||
// Display the canonical stream capitalization.
|
// Display the canonical stream capitalization.
|
||||||
true_stream_name = res.already_subscribed[email][0];
|
true_stream_name = res.already_subscribed[page_params.email][0];
|
||||||
ui.report_success("Already subscribed to " + true_stream_name,
|
ui.report_success("Already subscribed to " + true_stream_name,
|
||||||
$("#subscriptions-status"));
|
$("#subscriptions-status"));
|
||||||
} else {
|
} else {
|
||||||
// Display the canonical stream capitalization.
|
// Display the canonical stream capitalization.
|
||||||
true_stream_name = res.subscribed[email][0];
|
true_stream_name = res.subscribed[page_params.email][0];
|
||||||
}
|
}
|
||||||
mark_subscribed(true_stream_name);
|
mark_subscribed(true_stream_name);
|
||||||
},
|
},
|
||||||
@@ -592,7 +592,7 @@ function ajaxSubscribeForCreation(stream, principals, invite_only) {
|
|||||||
exports.tutorial_subscribe_or_add_me_to = function (stream_name) {
|
exports.tutorial_subscribe_or_add_me_to = function (stream_name) {
|
||||||
var stream_status = compose.check_stream_existence(stream_name);
|
var stream_status = compose.check_stream_existence(stream_name);
|
||||||
if (stream_status === 'does-not-exist') {
|
if (stream_status === 'does-not-exist') {
|
||||||
ajaxSubscribeForCreation(stream_name, [email], false);
|
ajaxSubscribeForCreation(stream_name, [page_params.email], false);
|
||||||
} else {
|
} else {
|
||||||
ajaxSubscribe(stream_name);
|
ajaxSubscribe(stream_name);
|
||||||
}
|
}
|
||||||
@@ -615,9 +615,9 @@ function people_cmp(person1, person2) {
|
|||||||
|
|
||||||
function show_new_stream_modal() {
|
function show_new_stream_modal() {
|
||||||
var people_minus_you_and_maybe_humbuggers = [];
|
var people_minus_you_and_maybe_humbuggers = [];
|
||||||
$.each(people_list, function (idx, person) {
|
$.each(page_params.people_list, function (idx, person) {
|
||||||
if (person.email !== email &&
|
if (person.email !== page_params.email &&
|
||||||
(domain === "humbughq.com" ||
|
(page_params.domain === "humbughq.com" ||
|
||||||
person.email.split('@')[1] !== "humbughq.com"
|
person.email.split('@')[1] !== "humbughq.com"
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@@ -635,8 +635,8 @@ function show_new_stream_modal() {
|
|||||||
$(function () {
|
$(function () {
|
||||||
var i;
|
var i;
|
||||||
// Populate stream_info with data handed over to client-side template.
|
// Populate stream_info with data handed over to client-side template.
|
||||||
for (i = 0; i < stream_list.length; i++) {
|
for (i = 0; i < page_params.stream_list.length; i++) {
|
||||||
create_sub(stream_list[i].name, stream_list[i]);
|
create_sub(page_params.stream_list[i].name, page_params.stream_list[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#add_new_subscription").on("submit", function (e) {
|
$("#add_new_subscription").on("submit", function (e) {
|
||||||
@@ -665,7 +665,7 @@ $(function () {
|
|||||||
principals.push($(this).val());
|
principals.push($(this).val());
|
||||||
});
|
});
|
||||||
// You are always subscribed to streams you create.
|
// You are always subscribed to streams you create.
|
||||||
principals.push(email);
|
principals.push(page_params.email);
|
||||||
ajaxSubscribeForCreation(stream,
|
ajaxSubscribeForCreation(stream,
|
||||||
principals,
|
principals,
|
||||||
$('#stream_creation_form input[name=privacy]:checked').val() === "invite-only"
|
$('#stream_creation_form input[name=privacy]:checked').val() === "invite-only"
|
||||||
@@ -723,7 +723,7 @@ $(function () {
|
|||||||
if (data.subscribed.hasOwnProperty(principal)) {
|
if (data.subscribed.hasOwnProperty(principal)) {
|
||||||
error_elem.addClass("hide");
|
error_elem.addClass("hide");
|
||||||
warning_elem.addClass("hide");
|
warning_elem.addClass("hide");
|
||||||
if (principal === email) {
|
if (principal === page_params.email) {
|
||||||
// mark_subscribed adds the user to the member list
|
// mark_subscribed adds the user to the member list
|
||||||
mark_subscribed(stream);
|
mark_subscribed(stream);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -120,12 +120,12 @@ function wait_for_message(time_to_wait_sec, condition) {
|
|||||||
var script = [];
|
var script = [];
|
||||||
|
|
||||||
function make_script() {
|
function make_script() {
|
||||||
my_tutorial_stream = 'tutorial-' + email.split('@')[0];
|
my_tutorial_stream = 'tutorial-' + page_params.email.split('@')[0];
|
||||||
my_tutorial_stream = my_tutorial_stream.substring(0, 30);
|
my_tutorial_stream = my_tutorial_stream.substring(0, 30);
|
||||||
|
|
||||||
// Try to guess at one of your main streams.
|
// Try to guess at one of your main streams.
|
||||||
// This is problematic because it might end up being 'commits' or something.
|
// This is problematic because it might end up being 'commits' or something.
|
||||||
var main_stream_name = domain.split('.')[0];
|
var main_stream_name = page_params.domain.split('.')[0];
|
||||||
var my_streams = subs.subscribed_streams();
|
var my_streams = subs.subscribed_streams();
|
||||||
|
|
||||||
if (my_streams.length <= 2) {
|
if (my_streams.length <= 2) {
|
||||||
@@ -145,7 +145,7 @@ function make_script() {
|
|||||||
|
|
||||||
script = [
|
script = [
|
||||||
go(sleep, 1000), // The first message seems to sometimes get eaten in Chrome otherwise.
|
go(sleep, 1000), // The first message seems to sometimes get eaten in Chrome otherwise.
|
||||||
go2(stream_message, "tutorial", "Hello, " + fullname + "!"),
|
go2(stream_message, "tutorial", "Hello, " + page_params.fullname + "!"),
|
||||||
go(sleep, 2000),
|
go(sleep, 2000),
|
||||||
go2(stream_message, "tutorial", "Welcome to Humbug!"),
|
go2(stream_message, "tutorial", "Welcome to Humbug!"),
|
||||||
go(sleep, 2000),
|
go(sleep, 2000),
|
||||||
@@ -291,7 +291,7 @@ exports.is_running = function () {
|
|||||||
exports.initialize = function () {
|
exports.initialize = function () {
|
||||||
make_script();
|
make_script();
|
||||||
// Global variable populated by the server code
|
// Global variable populated by the server code
|
||||||
if (needs_tutorial) {
|
if (page_params.needs_tutorial) {
|
||||||
exports.start();
|
exports.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ exports.update_all_recipients = function (recipients) {
|
|||||||
|
|
||||||
exports.update_your_recipients = function (recipients) {
|
exports.update_your_recipients = function (recipients) {
|
||||||
$.each(recipients, function (idx, recipient_data) {
|
$.each(recipients, function (idx, recipient_data) {
|
||||||
if (recipient_data.email !== email) {
|
if (recipient_data.email !== page_params.email) {
|
||||||
add_to_known_recipients(recipient_data, true);
|
add_to_known_recipients(recipient_data, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ $(function () {
|
|||||||
$("img.gravatar-profile").bind('load', resizehandler);
|
$("img.gravatar-profile").bind('load', resizehandler);
|
||||||
|
|
||||||
// We don't have a stream list at MIT.
|
// We don't have a stream list at MIT.
|
||||||
if (domain === "mit.edu") {
|
if (page_params.domain === "mit.edu") {
|
||||||
$("#stream_filters").remove();
|
$("#stream_filters").remove();
|
||||||
$("#stream_filters_sep").remove();
|
$("#stream_filters_sep").remove();
|
||||||
}
|
}
|
||||||
@@ -727,7 +727,7 @@ $(function () {
|
|||||||
update_gravatars();
|
update_gravatars();
|
||||||
|
|
||||||
if (result.enable_desktop_notifications !== undefined) {
|
if (result.enable_desktop_notifications !== undefined) {
|
||||||
desktop_notifications_enabled = result.enable_desktop_notifications;
|
page_params.desktop_notifications_enabled = result.enable_desktop_notifications;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_status.removeClass(status_classes)
|
settings_status.removeClass(status_classes)
|
||||||
@@ -789,7 +789,7 @@ $(function () {
|
|||||||
resizehandler();
|
resizehandler();
|
||||||
hack_for_floating_recipient_bar();
|
hack_for_floating_recipient_bar();
|
||||||
|
|
||||||
typeahead_helper.update_all_recipients(people_list);
|
typeahead_helper.update_all_recipients(page_params.people_list);
|
||||||
composebox_typeahead.initialize();
|
composebox_typeahead.initialize();
|
||||||
search.initialize();
|
search.initialize();
|
||||||
notifications.initialize();
|
notifications.initialize();
|
||||||
@@ -984,7 +984,7 @@ exports.add_narrow_filter = function(name, type, uri) {
|
|||||||
* This will not be as much of an issue once we do prioritization of streams
|
* This will not be as much of an issue once we do prioritization of streams
|
||||||
* in the list.
|
* in the list.
|
||||||
*/
|
*/
|
||||||
if (domain === "mit.edu" && type === "stream") {
|
if (page_params.domain === "mit.edu" && type === "stream") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1057,8 +1057,8 @@ exports.set_presence_list = function (users, presence_info) {
|
|||||||
$('#user_presences').append(entry);
|
$('#user_presences').append(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (domain !== "mit.edu") {
|
if (page_params.domain !== "mit.edu") {
|
||||||
add_entry(fullname, email, 'active');
|
add_entry(page_params.fullname, page_params.email, 'active');
|
||||||
}
|
}
|
||||||
|
|
||||||
$.each(users, function (idx, email) {
|
$.each(users, function (idx, email) {
|
||||||
|
|||||||
@@ -34,12 +34,12 @@ var server_furthest_read = -1;
|
|||||||
var pointer_update_in_flight = false;
|
var pointer_update_in_flight = false;
|
||||||
|
|
||||||
function add_person(person) {
|
function add_person(person) {
|
||||||
people_list.push(person);
|
page_params.people_list.push(person);
|
||||||
people_dict[person.email] = person;
|
people_dict[person.email] = person;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
$.each(people_list, function (idx, person) {
|
$.each(page_params.people_list, function (idx, person) {
|
||||||
people_dict[person.email] = person;
|
people_dict[person.email] = person;
|
||||||
});
|
});
|
||||||
// The special account feedback@humbughq.com is used for in-app
|
// The special account feedback@humbughq.com is used for in-app
|
||||||
@@ -113,7 +113,7 @@ function get_private_message_recipient(message, attr) {
|
|||||||
var recipient, i;
|
var recipient, i;
|
||||||
var other_recipients = $.grep(message.display_recipient,
|
var other_recipients = $.grep(message.display_recipient,
|
||||||
function (element, index) {
|
function (element, index) {
|
||||||
return element.email !== email;
|
return element.email !== page_params.email;
|
||||||
});
|
});
|
||||||
if (other_recipients.length === 0) {
|
if (other_recipients.length === 0) {
|
||||||
// private message with oneself
|
// private message with oneself
|
||||||
@@ -214,7 +214,7 @@ function message_unread(message) {
|
|||||||
var sent_by_human = ['website', 'iphone', 'android']
|
var sent_by_human = ['website', 'iphone', 'android']
|
||||||
.indexOf(message.client.toLowerCase()) !== -1;
|
.indexOf(message.client.toLowerCase()) !== -1;
|
||||||
|
|
||||||
if (message.sender_email === email && sent_by_human) {
|
if (message.sender_email === page_params.email && sent_by_human) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,8 +389,8 @@ function send_pointer_update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
furthest_read = initial_pointer;
|
furthest_read = page_params.initial_pointer;
|
||||||
server_furthest_read = initial_pointer;
|
server_furthest_read = page_params.initial_pointer;
|
||||||
|
|
||||||
// We only send pointer updates when the user has been idle for a
|
// We only send pointer updates when the user has been idle for a
|
||||||
// short while to avoid hammering the server
|
// short while to avoid hammering the server
|
||||||
@@ -449,7 +449,7 @@ function add_message_metadata(message, dummy) {
|
|||||||
|
|
||||||
involved_people = message.display_recipient;
|
involved_people = message.display_recipient;
|
||||||
|
|
||||||
if (message.sender_email === email) {
|
if (message.sender_email === page_params.email) {
|
||||||
typeahead_helper.update_your_recipients(involved_people);
|
typeahead_helper.update_your_recipients(involved_people);
|
||||||
} else {
|
} else {
|
||||||
typeahead_helper.update_all_recipients(involved_people);
|
typeahead_helper.update_all_recipients(involved_people);
|
||||||
@@ -596,7 +596,7 @@ function get_updates(options) {
|
|||||||
url: '/json/get_updates',
|
url: '/json/get_updates',
|
||||||
data: get_updates_params,
|
data: get_updates_params,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: poll_timeout,
|
timeout: page_params.poll_timeout,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (! data) {
|
if (! data) {
|
||||||
// The server occasionally returns no data during a
|
// The server occasionally returns no data during a
|
||||||
@@ -769,7 +769,8 @@ $(function () {
|
|||||||
// We fall back to the closest selected id, as the user may have removed
|
// We fall back to the closest selected id, as the user may have removed
|
||||||
// a stream from the home before already
|
// a stream from the home before already
|
||||||
if (home_msg_list.selected_id() === -1) {
|
if (home_msg_list.selected_id() === -1) {
|
||||||
home_msg_list.select_id(initial_pointer, {then_scroll: true, use_closest: true});
|
home_msg_list.select_id(page_params.initial_pointer,
|
||||||
|
{then_scroll: true, use_closest: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
// catch the user up
|
// catch the user up
|
||||||
@@ -801,9 +802,9 @@ $(function () {
|
|||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_initial_messages) {
|
if (page_params.have_initial_messages) {
|
||||||
load_old_messages({
|
load_old_messages({
|
||||||
anchor: initial_pointer,
|
anchor: page_params.initial_pointer,
|
||||||
num_before: 200,
|
num_before: 200,
|
||||||
num_after: 200,
|
num_after: 200,
|
||||||
msg_list: home_msg_list,
|
msg_list: home_msg_list,
|
||||||
@@ -839,7 +840,7 @@ function load_more_messages(msg_list) {
|
|||||||
ui.show_loading_more_messages_indicator();
|
ui.show_loading_more_messages_indicator();
|
||||||
load_more_enabled = false;
|
load_more_enabled = false;
|
||||||
if (msg_list.first() === undefined) {
|
if (msg_list.first() === undefined) {
|
||||||
oldest_message_id = initial_pointer;
|
oldest_message_id = page_params.initial_pointer;
|
||||||
} else {
|
} else {
|
||||||
oldest_message_id = msg_list.first().id;
|
oldest_message_id = msg_list.first().id;
|
||||||
}
|
}
|
||||||
@@ -941,7 +942,7 @@ function fast_forward_pointer(btn) {
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: '/json/get_profile',
|
url: '/json/get_profile',
|
||||||
data: {email: email},
|
data: {email: page_params.email},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
mark_all_as_read(function () {
|
mark_all_as_read(function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user