Rename class_list to stream_list.

(imported from commit c9f5b10acdb20d3e923cf7f32bc5a3f37aa40705)
This commit is contained in:
Tim Abbott 2012-10-10 17:26:01 -04:00
parent 081f82c50c
commit ef3b8a2ce5
5 changed files with 22 additions and 22 deletions

View File

@ -45,7 +45,7 @@
{% autoescape off %}
var initial_pointer = {{ user_profile.pointer }};
var email = "{{ user_profile.user.email }}";
var class_list = {{ streams }};
var stream_list = {{ streams }};
var people_list = {{ people }};
var have_initial_messages = {{ have_initial_messages }};
{% endautoescape %}

View File

@ -6,7 +6,7 @@ var globals =
' $ jQuery Spinner Handlebars XDate'
// index.html
+ ' initial_pointer email class_list people_list have_initial_messages'
+ ' initial_pointer email stream_list people_list have_initial_messages'
// compose.js
+ ' show_compose hide_compose toggle_compose compose_button'
@ -28,8 +28,8 @@ var globals =
+ ' loading_spinner templates'
// subscribe.js
+ ' fetch_subs sub_from_home subscribed_to class_list_hash'
+ ' add_to_class_list'
+ ' fetch_subs sub_from_home subscribed_to stream_list_hash'
+ ' add_to_stream_list'
// ui.js
+ ' register_onclick hide_email show_email'

View File

@ -27,7 +27,7 @@ function sub_from_home(stream, prompt_button) {
dataType: 'json',
timeout: 10*60*1000, // 10 minutes in ms
success: function (response) {
add_to_class_list(response.data);
add_to_stream_list(response.data);
$("#compose form").ajaxSubmit();
prompt_button.stop(true).fadeOut(500);
},
@ -37,36 +37,36 @@ function sub_from_home(stream, prompt_button) {
});
}
class_list_hash = [];
stream_list_hash = [];
function subscribed_to(class_name) {
return (class_list_hash[class_name.toLowerCase()] === true);
return (stream_list_hash[class_name.toLowerCase()] === true);
}
function case_insensitive_subscription_index(class_name) {
var i;
var name = class_name.toLowerCase();
for (i = 1; i < class_list.length; i++) {
if (name === class_list[i].toLowerCase()) {
for (i = 1; i < stream_list.length; i++) {
if (name === stream_list[i].toLowerCase()) {
return i;
}
}
return -1;
}
function add_to_class_list(class_name) {
function add_to_stream_list(class_name) {
if (!subscribed_to(class_name)) {
class_list.push(class_name);
class_list_hash[class_name.toLowerCase()] = true;
stream_list.push(class_name);
stream_list_hash[class_name.toLowerCase()] = true;
}
}
function remove_from_class_list(class_name) {
delete class_list_hash[class_name.toLowerCase()];
function remove_from_stream_list(class_name) {
delete stream_list_hash[class_name.toLowerCase()];
var removal_index = case_insensitive_subscription_index(class_name);
if (removal_index !== -1) {
class_list.splice(removal_index, 1);
stream_list.splice(removal_index, 1);
}
}
@ -77,7 +77,7 @@ $(function () {
success: function (resp, statusText, xhr, form) {
var name = $.parseJSON(xhr.responseText).data;
$('#subscriptions_table').find('button[value="' + name + '"]').parents('tr').remove();
remove_from_class_list(name);
remove_from_stream_list(name);
update_autocomplete();
report_success("Successfully removed subscription to " + name,
$("#subscriptions-status"));
@ -93,7 +93,7 @@ $(function () {
$("#new_subscription").val("");
var name = $.parseJSON(xhr.responseText).data;
$('#subscriptions_table').prepend(templates.subscription({subscription: name}));
add_to_class_list(name);
add_to_stream_list(name);
report_success("Successfully added subscription to " + name,
$("#subscriptions-status"));
$("#new_subscription").focus();

View File

@ -74,13 +74,13 @@ function mousemove() {
var autocomplete_needs_update = false;
function update_autocomplete() {
class_list.sort();
stream_list.sort();
instance_list.sort();
people_list.sort();
// limit number of items so the list doesn't fall off the screen
$( "#class" ).typeahead({
source: class_list,
source: stream_list,
items: 3
});
$( "#instance" ).typeahead({

View File

@ -38,9 +38,9 @@ $(function () {
send_status.hide();
$("#compose form").ajaxForm(options);
// Populate class_list_hash with data handed over to client-side template.
for (i = 0; i < class_list.length; i++) {
class_list_hash[class_list[i].toLowerCase()] = true;
// Populate stream_list_hash with data handed over to client-side template.
for (i = 0; i < stream_list.length; i++) {
stream_list_hash[stream_list[i].toLowerCase()] = true;
}
});