Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updates to state-handling

  • Loading branch information...
commit 4dd6bc57e509b3fb5a4c5a1d26d89869b116a27b 1 parent c518c72
@tvroom tvroom authored
Showing with 67 additions and 56 deletions.
  1. +67 −56 plugins/Ajax/htdocs/images/common.js
View
123 plugins/Ajax/htdocs/images/common.js
@@ -3,21 +3,28 @@
// global settings, but a firehose might use a local settings object instead
var firehose_settings = {};
- firehose_settings.updates = Array(0);
- firehose_settings.updates_size = 0;
- firehose_settings.ordered = Array(0);
- firehose_settings.before = Array(0);
- firehose_settings.after = Array(0);
firehose_settings.startdate = '';
firehose_settings.duration = '';
+ firehose_settings.mode = '';
+ firehose_settings.color = '';
+ firehose_settings.orderby = '';
+ firehose_settings.orderdir = '';
+
firehose_settings.issue = '';
- firehose_settings.removed_first = '0';
- firehose_settings.future = null;
- firehose_settings.removals = null;
firehose_settings.is_embedded = 0;
firehose_settings.not_id = 0;
firehose_settings.section = 0;
+// Settings to port out of settings object
+ firehose_updates = Array(0);
+ firehose_updates_size = 0;
+ firehose_ordered = Array(0);
+ firehose_before = Array(0);
+ firehose_after = Array(0);
+ firehose_removed_first = '0';
+ firehose_removals = null;
+ firehose_future = null;
+
// globals we haven't yet decided to move into |firehose_settings|
var fh_play = 0;
var fh_is_timed_out = 0;
@@ -27,7 +34,6 @@ var fh_is_admin = 0;
var console_updating = 0;
var fh_colorslider;
var fh_ticksize;
-var fh_pageval = 0;
var fh_colors = Array(0);
var fh_use_jquery = 0;
var vendor_popup_timerids = Array(0);
@@ -556,16 +562,16 @@ function firehose_set_options(name, value) {
if (name == "fhfilter" && theForm) {
for (i=0; i< theForm.elements.length; i++) {
if (theForm.elements[i].name == "fhfilter") {
- params['fhfilter'] = theForm.elements[i].value;
+ firehose_settings.fhfilter = theForm.elements[i].value;
}
}
- page = 0;
+ firehose_settings.page = 0;
}
if (name != "color") {
for (i=0; i< pairs.length; i++) {
var el = pairs[i];
if (name == el[0] && value == el[1]) {
- params[name] = value;
+ firehose_settings[name] = value;
if ($(el[2])) {
$(el[2]).id = el[3];
if($(el[3])) {
@@ -613,8 +619,8 @@ function firehose_set_options(name, value) {
if (name == "issue") {
firehose_settings.issue = value;
firehose_settings.startdate = value;
- duration = 1;
- page = 0;
+ firehose_settings.duration = 1;
+ firehose_settings.page = 0;
var issuedate = firehose_settings.issue.substr(5,2) + "/" + firehose_settings.issue.substr(8,2) + "/" + firehose_settings.issue.substr(10,2);
if ($('fhcalendar')) {
@@ -624,8 +630,11 @@ function firehose_set_options(name, value) {
$('fhcalendar_pag')._widget.setDate(issuedate, "day");
}
}
+ if (name == "color") {
+ firehose_settings.color = value;
+ }
if (name == "pagesize") {
- page = 0;
+ firehose_settings.page = 0;
}
}
@@ -646,6 +655,9 @@ function firehose_set_options(name, value) {
}
params['section'] = firehose_settings.section;
+ for (i in firehose_settings) {
+ params[i] = firehose_settings[i];
+ }
ajax_update(params, '', handlers);
}
@@ -813,17 +825,17 @@ function json_update(response) {
function firehose_handle_update() {
- if (firehose_settings.updates.length > 0) {
- var el = firehose_settings.updates.pop();
+ if (firehose_updates.length > 0) {
+ var el = firehose_updates.pop();
var fh = 'firehose-' + el[1];
var wait_interval = 800;
if(el[0] == "add") {
- if (firehose_settings.before[el[1]] && $('firehose-' + firehose_settings.before[el[1]])) {
- new Insertion.After('firehose-' + firehose_settings.before[el[1]], el[2]);
+ if (firehose_before[el[1]] && $('firehose-' + firehose_before[el[1]])) {
+ new Insertion.After('firehose-' + firehose_before[el[1]], el[2]);
- } else if (firehose_settings.after[el[1]] && $('firehose-' + firehose_settings.after[el[1]])) {
- new Insertion.Before('firehose-' + firehose_settings.after[el[1]], el[2]);
+ } else if (firehose_after[el[1]] && $('firehose-' + firehose_after[el[1]])) {
+ new Insertion.Before('firehose-' + firehose_after[el[1]], el[2]);
} else if (insert_new_at == "bottom") {
new Insertion.Bottom('firehoselist', el[2]);
} else {
@@ -844,16 +856,16 @@ function firehose_handle_update() {
var myAnim = new YAHOO.util.Anim(fh, attributes);
myAnim.duration = 0.7;
- if (firehose_settings.updates_size > 10) {
+ if (firehose_updates_size > 10) {
myAnim.duration = myAnim.duration / 2;
wait_interval = wait_interval / 2;
}
- if (firehose_settings.updates_size > 20) {
+ if (firehose_updates_size > 20) {
myAnim.duration = myAnim.duration / 2;
wait_interval = wait_interval / 2;
}
- if (firehose_settings.updates_size > 30) {
+ if (firehose_updates_size > 30) {
myAnim.duration = myAnim.duration / 1.5;
wait_interval = wait_interval / 2;
}
@@ -889,16 +901,16 @@ function firehose_handle_update() {
myAnim.duration = 0.4;
wait_interval = 500;
- if (firehose_settings.updates_size > 10) {
+ if (firehose_updates_size > 10) {
myAnim.duration = myAnim.duration * 2;
- if (!firehose_settings.removed_first) {
+ if (!firehose_removed_first) {
wait_interval = wait_interval * 2;
} else {
wait_interval = 50;
}
}
- firehose_settings.removed_first = 1;
- if (firehose_settings.removals < 10 ) {
+ firehose_removed_first = 1;
+ if (firehose_removals < 10 ) {
myAnim.onComplete.subscribe(function() {
var elem = this.getEl();
if (elem && elem.parentNode) {
@@ -923,25 +935,25 @@ function firehose_handle_update() {
}
function firehose_reorder() {
- if (firehose_settings.ordered) {
+ if (firehose_ordered) {
var fhlist = $('firehoselist');
if (fhlist) {
var item_count = 0;
- for (i = 0; i < firehose_settings.ordered.length; i++) {
- if (/^\d+$/.test(firehose_settings.ordered[i])) {
+ for (i = 0; i < firehose_ordered.length; i++) {
+ if (/^\d+$/.test(firehose_ordered[i])) {
item_count++;
}
- var fhel = $('firehose-' + firehose_settings.ordered[i]);
+ var fhel = $('firehose-' + firehose_ordered[i]);
if (fhlist && fhel) {
fhlist.appendChild(fhel);
}
- if ( firehose_settings.future[firehose_settings.ordered[i]] ) {
- if ($("ttype-" + firehose_settings.ordered[i])) {
- $("ttype-" + firehose_settings.ordered[i]).className = "future";
+ if ( firehose_future[firehose_ordered[i]] ) {
+ if ($("ttype-" + firehose_ordered[i])) {
+ $("ttype-" + firehose_ordered[i]).className = "future";
}
} else {
- if ($("ttype-" + firehose_settings.ordered[i]) && $("ttype-" + firehose_settings.ordered[i]).className == "future") {
- $("ttype-" + firehose_settings.ordered[i]).className = "story";
+ if ($("ttype-" + firehose_ordered[i]) && $("ttype-" + firehose_ordered[i]).className == "future") {
+ $("ttype-" + firehose_ordered[i]).className = "story";
}
}
}
@@ -969,17 +981,17 @@ function firehose_get_updates_handler(transport) {
}
var response = eval_response(transport);
var processed = 0;
- firehose_settings.removals = response.update_data.removals;
- firehose_settings.ordered = response.ordered;
- firehose_settings.future = response.future;
- firehose_settings.before = Array(0);
- firehose_settings.after = Array(0);
- for (i = 0; i < firehose_settings.ordered.length; i++) {
+ firehose_removals = response.update_data.removals;
+ firehose_ordered = response.ordered;
+ firehose_future = response.future;
+ firehose_before = Array(0);
+ firehose_after = Array(0);
+ for (i = 0; i < firehose_ordered.length; i++) {
if (i > 0) {
- firehose_settings.before[firehose_settings.ordered[i]] = firehose_settings.ordered[i - 1];
+ firehose_before[firehose_ordered[i]] = firehose_ordered[i - 1];
}
- if (i < (firehose_settings.ordered.length - 1)) {
- firehose_settings.after[firehose_settings.ordered[i]] = firehose_settings.ordered[i + 1];
+ if (i < (firehose_ordered.length - 1)) {
+ firehose_after[firehose_ordered[i]] = firehose_ordered[i + 1];
}
}
if (response.html) {
@@ -987,9 +999,9 @@ function firehose_get_updates_handler(transport) {
processed = processed + 1;
}
if (response.updates) {
- firehose_settings.updates = response.updates;
- firehose_settings.updates_size = firehose_settings.updates.length;
- firehose_settings.removed_first = 0;
+ firehose_updates = response.updates;
+ firehose_updates_size = firehose_updates.length;
+ firehose_removed_first = 0;
processed = processed + 1;
firehose_handle_update();
}
@@ -1037,16 +1049,15 @@ function firehose_get_updates(options) {
params['op'] = 'firehose_get_updates';
params['ids'] = firehose_get_item_idstring();
params['updatetime'] = update_time;
- params['startdate'] = firehose_settings.startdate;
- params['duration'] = firehose_settings.duration;
- params['issue'] = firehose_settings.issue;
- params['section'] = firehose_settings.section;
- params['page'] = page;
- params['not_id'] = firehose_settings.not_id;
+
+ for (i in firehose_settings) {
+ params[i] = firehose_settings[i];
+ }
+
if ( firehose_settings.is_embedded ) {
params['embed'] = 1;
}
- params['fh_pageval'] = fh_pageval;
+ params['fh_pageval'] = firehose_settings.pageval;
if ($('busy')) {
$('busy').className = "";
}
Please sign in to comment.
Something went wrong with that request. Please try again.