Commit 22588ec6 authored by Dave Lane's avatar Dave Lane
Browse files

moved changes to where they belong in WEnotes.js, and re-made derivatives

parent eee60dca
This diff is collapsed.
......@@ -50,6 +50,7 @@ if ( !Date.prototype.toISOString ) {
// variables made public to simplify debugging/monitoring
var wendivs = [];
var wenlang = 'en_EN'; // set language to default...
var WEnotes = {};
var protocol = window.location.protocol + '//';
// hard coded locations of things
......@@ -524,9 +525,11 @@ var msg_counter = [];
tag = wendivs[ix].tag,
taglc = tag.toLowerCase(),
count = wendivs[ix].moreCount + 1,
language = wendivs[ix].language,
$wenm = $('#WEnotesMore' + ix),
$wenmdi = $('#WEnotesMoreDiv' + ix + ' img');
wenlang = language;
console.log('setting wenlang = '+language);
$wenmdi.show();
$wenm.hide();
if (tag === '_') {
......@@ -537,7 +540,8 @@ var msg_counter = [];
endkey: '"2011-01-01T00:00:00.000Z"',
descending: true,
include_docs: true,
limit: count
limit: count,
language: language
};
} else {
url = couchURL;
......@@ -547,7 +551,8 @@ var msg_counter = [];
endkey: '["' + taglc + '", "2011-01-01T00:00:00.000Z"]',
descending: true,
include_docs: true,
limit: count
limit: count,
language: language
};
}
......@@ -655,7 +660,7 @@ var msg_counter = [];
.triggerHandler('WEnotes', [dx.tag]);}, refreshtime);
},
success: function(data) {
//console.log("data = " + JSON.stringify(data));
console.log("data = " + JSON.stringify(data));
var i;
var lid = '.WEnotes';
var rows = data.rows;
......@@ -668,10 +673,21 @@ var msg_counter = [];
}
if (!dx.nomore && (data.total_rows - data.offset > rows.length)) {
wendivs[ix].nomore = true;
button_text = "More " + tag + " notes";
if (tag === '_') {
button_text = "More notes";
}
console.log('language for wendivs '+ix+' is ', data.language);
if (typeof data.language != undefined &&
data.language == 'fr_FR') {
button_text = "Des notes plus " + tag;
if (tag === '_') {
button_text = "Plus de notes";
}
console.log('chose fr_FR: '+button_text);
} else {
button_text = "More " + tag + " notes";
if (tag === '_') {
button_text = "More notes";
}
console.log('chose not-fr_FR: '+button_text);
}
$(lid).after('<div class="WEnotesMore" id="WEnotesMoreDiv' +
ix +'"><img src="' + protocol + 'wikieducator.org/skins/common/images/ajax-loader.gif" />' +
'<input id="WEnotesMore' + ix +
......@@ -825,16 +841,16 @@ var msg_counter = [];
console.log("==== looking for WEnotes class...");
$('div.WEnotes').each(function() {
var $thisd = $(this);
// get the other classes alongside WEnotes, e.g. WEnotes-20-lida101
// get the other classes alongside WEnotes, e.g. WEnotes-20-lida101-lida-fr_FR
var classes = $(this).attr('class').split(/\s+/);
// for each class, get useful info out of the class name
// in the example above, 20 is the 'count' of messages to show,
// and lida101 is the tag
// and lida101 is the tag, lida is the 'context', and fr_FR is the language
$.each(classes, function(i, v) {
console.log('==== v = ', v);
if (v.indexOf('WEnotes-') === 0) {
var tag;
var args = v.split('-', 3);
var args = v.split('-', 5);
if (args.length > 2) {
tag = args[2];
// add each class' details to a list for future reference
......@@ -842,11 +858,15 @@ var msg_counter = [];
$d: $thisd,
count: args[1], // how many of this to show
tag: tag, // from which tag
context: args[3],
language: args[4],
last: '2011-01-01T00:00:00.000Z',
first: '2999-12-31T23:59:59.999Z',
moreCount: 20 // how many more to show if the user clicks "show more"
});
wenlang = args[4];
console.log('wenlang for WEnote: '+wenlang);
// actually subscribe to the Faye services for the relevant combo
combo = '/WEnotes/' + ((tag === '_') ? '*' : tag.toLowerCase());
console.log('combo = ', combo);
......
......@@ -2440,15 +2440,16 @@ if ( !Date.prototype.toISOString ) {
// variables made public to simplify debugging/monitoring
var wendivs = [];
var wenlang = 'en_EN'; // set language to default...
var WEnotes = {};
var protocol = window.location.protocol + '//';
// hard coded locations of things
var fayeURL = 'faye.oerfoundation.org/faye/';
//var fayeURL = 'faye.dev.oerfoundation.org/faye/';
//var fayeURL = 'faye.oerfoundation.org/faye/';
var fayeURL = 'faye.dev.oerfoundation.org/faye/';
// scheme, host:port
// include trailing / on URL...
var couchHost = 'couch.oerfoundation.org/', couchDB = 'mentions';
//var couchHost = 'couch.dev.oerfoundation.org/', couchDB = 'mentions';
//var couchHost = 'couch.oerfoundation.org/', couchDB = 'mentions';
var couchHost = 'couch.dev.oerfoundation.org/', couchDB = 'mentions';
var msg_counter = [];
......@@ -2917,9 +2918,8 @@ var msg_counter = [];
language = wendivs[ix].language,
$wenm = $('#WEnotesMore' + ix),
$wenmdi = $('#WEnotesMoreDiv' + ix + ' img');
console.log('language = '+ language);
wenlang = language;
console.log('setting wenlang = '+language);
$wenmdi.show();
$wenm.hide();
if (tag === '_') {
......@@ -2946,8 +2946,8 @@ var msg_counter = [];
};
}
console.log("url1 = " + url);
console.log("options = " + options);
//console.log("url1 = " + url);
//console.log("options = " + options);
$.ajax({
url: url + makeCouchqs(options),
......@@ -3255,7 +3255,8 @@ var msg_counter = [];
moreCount: 20 // how many more to show if the user clicks "show more"
});
console.log('language for WEnote: '+args[4]);
wenlang = args[4];
console.log('wenlang for WEnote: '+wenlang);
// actually subscribe to the Faye services for the relevant combo
combo = '/WEnotes/' + ((tag === '_') ? '*' : tag.toLowerCase());
console.log('combo = ', combo);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment