Made all JS code JSLint compliant.
--- a/app/soc/content/js/blog-081117.js Tue Aug 25 15:55:26 2009 +0100
+++ b/app/soc/content/js/blog-081117.js Tue Aug 25 15:58:30 2009 +0100
@@ -17,17 +17,19 @@
this.container_ = container;
}
-BlogPreview.prototype.show = function(url, entries_num, title, title_link) {
+BlogPreview.prototype.show = function (url, entries_num, title, title_link) {
var feed = new google.feeds.Feed(url);
var preview = this;
- feed.setNumEntries(entries_num)
- feed.load(function(result) {
+ feed.setNumEntries(entries_num);
+ feed.load(function (result) {
preview.render_(result, title, title_link);
});
-}
+};
-BlogPreview.prototype.render_ = function(result, title, title_link) {
- if (!result.feed || !result.feed.entries) return;
+BlogPreview.prototype.render_ = function (result, title, title_link) {
+ if (!result.feed || !result.feed.entries) {
+ return;
+ }
while (this.container_.firstChild) {
this.container_.removeChild(this.container_.firstChild);
}
@@ -52,20 +54,20 @@
}
this.createDiv_(div, "snippet", entry.contentSnippet);
}
-}
+};
-BlogPreview.prototype.createDiv_ = function(parent, className, opt_text) {
+BlogPreview.prototype.createDiv_ = function (parent, className, opt_text) {
return this.createElement_("div", parent, className, opt_text);
-}
+};
-BlogPreview.prototype.createLink_ = function(parent, href, text) {
+BlogPreview.prototype.createLink_ = function (parent, href, text) {
var link = this.createElement_("a", parent, "", text);
link.href = href;
return link;
-}
+};
-BlogPreview.prototype.createElement_ = function(tagName, parent, className,
- opt_text) {
+BlogPreview.prototype.createElement_ = function (tagName, parent, className,
+ opt_text) {
var div = document.createElement(tagName);
div.className = className;
parent.appendChild(div);
@@ -73,5 +75,5 @@
div.appendChild(document.createTextNode(opt_text));
}
return div;
-}
+};
--- a/app/soc/content/js/bulk-review-090304.js Tue Aug 25 15:55:26 2009 +0100
+++ b/app/soc/content/js/bulk-review-090304.js Tue Aug 25 15:58:30 2009 +0100
@@ -1,99 +1,119 @@
-$(document).ready(function() {
- $("#applications_progress_bar").progressBar({showText: false});
+jQuery(document).ready(function () {
+ jQuery("#applications_progress_bar").progressBar({showText: false});
});
-function bulkReviewInit(bulk_review_link,button) {
- // get the JSON object with details of every application for bulk acceptance
- $.getJSON(bulk_review_link+"?_="+(new Date().getTime()),
- function(data){
- // If there are applications to review...
- if (data.nr_applications != 0) {
- //...then fade out the button, show the progress bar and call the function for review
- $("[id^=button_bulk_]").fadeOut("slow",
- function() {
- $("#applications_progress_bar").progressBar(0);
- $("#description_done").html("");
- $("#applications_progress_bar").fadeIn("slow", bulkReview(data));
- }
- );
- }else {
- var no_organization_text="No organizations to ";
- if ($(button).attr("id").indexOf("reject")!=-1) {
- no_organization_text+="reject";
- }
- else {
- no_organization_text+="accept";
- }
- $("#description_done").html("<strong>"+no_organization_text+"</strong>");
- }
- }
- );
-}
+function bulkReview(data) {
+ // some global constants
+ var GLOBAL_LINK = data.link;
+ var TOTAL_APPLICATIONS = data.nr_applications;
-function bulkReview(data) {
- // some global constants
- var GLOBAL_LINK = data.link;
- var TOTAL_APPLICATIONS = data.nr_applications;
-
- // some global variables set needed for internal iteration
- var application_index = 0;
- // number of iteration is not taken from data.nr_applications
- // to ensure avoidance of array out of bounds errors
- var total_index = data.applications.length;
+ // some global variables set needed for internal iteration
+ var application_index = 0;
+ // number of iteration is not taken from data.nr_applications
+ // to ensure avoidance of array out of bounds errors
+ var total_index = data.applications.length;
- // call immediately the function for review
- // real iteration is inside
- setTimeout(function(){
- var error_happened = false;
+ // call immediately the function for review
+ // real iteration is inside
+ setTimeout(
+ function () {
+ var error_happened = false;
+ var application = data.applications[application_index];
+ var current_application = application_index + 1;
+ // regular expression to find a valid scope path
+ // inside matching parenthesis
+ var re = /\((\w*)\)/;
+ var scope_path = GLOBAL_LINK.match(re)[1];
+ // the URL is obtained by using the scope path found
+ // in the matching parenthesis
+ var url_to_call = GLOBAL_LINK.replace(re, application[scope_path]);
+ // now we can call the URL found
+ jQuery.ajax({
+ async: false,
+ cache: false,
+ url: url_to_call,
+ timeout: 10000,
+ success: function (data) {
+ if (data) {
+ // update progress bar percentage and description
+ var percentage =
+ Math.floor(100 * (current_application) / (TOTAL_APPLICATIONS));
+ jQuery("#description_progressbar").html([
+ " Processed application ", application.name,
+ " (", current_application, "/", TOTAL_APPLICATIONS, ")"
+ ].join(""));
+ jQuery("#applications_progress_bar").progressBar(percentage);
+ }
+ },
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
+ // if there is an error return the button and
+ // leave a try again message
+ error_happened = true;
+ jQuery("[id^=button_bulk_]").fadeIn(
+ "slow",
+ function () {
+ jQuery("#description_done").html([
+ "<strong class='error'>",
+ " Error encountered, try again",
+ "</strong>"
+ ].join(""));
+ }
+ );
+ }
+ });
+ // if there were no errors, continue the iteration
+ if (!error_happened) {
+ // prepare for new iteration and then recall this function
+ application_index++;
+ if (application_index < total_index) {
+ setTimeout(arguments.callee, 0);
+ }
+ else {
+ // all ok, tell the user we are done
+ jQuery("#applications_progress_bar").fadeOut(
+ "slow",
+ function () {
+ jQuery("#applications_progress_bar").progressBar(0);
+ jQuery("[id^=button_bulk_]").fadeIn("slow");
+ }
+ );
+ jQuery("#description_progressbar").html("");
+ jQuery("#description_done").html("<strong>Done!</strong>");
+ }
+ }
+ },
+ 0
+ );
+}
- var application = data.applications[application_index];
- var current_application = application_index + 1;
- // regular expression to find a valid scope path inside matching parenthesis
- var re = /\((\w*)\)/;
- var scope_path = GLOBAL_LINK.match(re)[1];
- // the URL is obtained by using the scope path found in the matching parenthesis
- var url_to_call = GLOBAL_LINK.replace(re, eval("application." + scope_path));
- // now we can call the URL found
- $.ajax({
- async: false,
- cache: false,
- url: url_to_call,
- timeout: 10000,
- success: function(data) {
- if (data) {
- // update progress bar percentage and description
- var percentage = Math.floor(100 * (current_application) / (TOTAL_APPLICATIONS));
- $("#description_progressbar").html(" Processed application " + application.name + " (" + (current_application) + "/" + TOTAL_APPLICATIONS + ")");
- $("#applications_progress_bar").progressBar(percentage);
- }
- },
- error: function(XMLHttpRequest, textStatus, errorThrown) {
- // if there is an error return the button and leave a try again message
- error_happened = true;
- $("[id^=button_bulk_]").fadeIn("slow", function() {
- $("#description_done").html("<strong class='error'> Error encountered, try again</strong>");
- });
- }
- });
- // if there were no errors, continue the iteration
- if (!error_happened) {
- // prepare for new iteration and then recall this function
- application_index++;
- if (application_index < total_index) {
- setTimeout(arguments.callee, 0);
- }
- else {
- // all ok, tell the user we are done
- $("#applications_progress_bar").fadeOut("slow",
- function() {
- $("#applications_progress_bar").progressBar(0);
- $("[id^=button_bulk_]").fadeIn("slow");
- }
- );
- $("#description_progressbar").html("");
- $("#description_done").html("<strong>Done!</strong>");
- }
- }
- },0);
+function bulkReviewInit(bulk_review_link, button) {
+ // get the JSON object with details of every application for bulk acceptance
+ jQuery.getJSON(
+ bulk_review_link + "?_=" + (new Date().getTime()),
+ function (data) {
+ // If there are applications to review...
+ if (data.nr_applications !== 0) {
+ //...then fade out the button, show the progress bar and call the function for review
+ jQuery("[id^=button_bulk_]").fadeOut(
+ "slow",
+ function () {
+ jQuery("#applications_progress_bar").progressBar(0);
+ jQuery("#description_done").html("");
+ jQuery("#applications_progress_bar").fadeIn("slow", bulkReview(data));
+ }
+ );
+ }
+ else {
+ var no_organization_text = "No organizations to ";
+ if (jQuery(button).attr("id").indexOf("reject") !== -1) {
+ no_organization_text += "reject";
+ }
+ else {
+ no_organization_text += "accept";
+ }
+ jQuery("#description_done").html("<strong>" + no_organization_text + "</strong>");
+ }
+ }
+ );
}
--- a/app/soc/content/js/datetime-loader-090304.js Tue Aug 25 15:55:26 2009 +0100
+++ b/app/soc/content/js/datetime-loader-090304.js Tue Aug 25 15:58:30 2009 +0100
@@ -1,5 +1,6 @@
-$(function()
-{
-$('.datetime-pick').datetimepicker();
-});
+jQuery(
+ function () {
+ jQuery('.datetime-pick').datetimepicker();
+ }
+);
--- a/app/soc/content/js/datetimepicker-090304.js Tue Aug 25 15:55:26 2009 +0100
+++ b/app/soc/content/js/datetimepicker-090304.js Tue Aug 25 15:58:30 2009 +0100
@@ -1,10 +1,12 @@
-$(function() {
- $('.datetime-pick').datetimepicker();
- $('.date-pick').datetimepicker({
- 'pickDateOnly' : true,
- 'defaultDate' : new Date('01/01/1974'),
- 'timeFormat' : '',
- 'yearRange' : '1900:2008'
- });
- });
+jQuery(
+ function () {
+ jQuery('.datetime-pick').datetimepicker();
+ jQuery('.date-pick').datetimepicker({
+ 'pickDateOnly': true,
+ 'defaultDate': new Date('01/01/1974'),
+ 'timeFormat': '',
+ 'yearRange': '1900:2008'
+ });
+ }
+);
--- a/app/soc/content/js/duplicate-slots-090505.js Tue Aug 25 15:55:26 2009 +0100
+++ b/app/soc/content/js/duplicate-slots-090505.js Tue Aug 25 15:58:30 2009 +0100
@@ -1,105 +1,102 @@
-var duplicateSlots = new function() {
+(function () {
+ var duplicateSlots = window.duplicateSlots = function () {
+ };
// this variable will contain all the org details, and filled
// incrementally
var orgs_details = {};
// this variable will contain all student/proposal data details,
// filled incrementally
- var assigned_proposals = new Array();
-
- // public function to begin iterating load of JSONs and then call printing
- // of duplicates
-
- this.showDuplicatesInit = function() {
-
- html_string = '';
- // Remember this object for Javascript scoping
- var this_object = this;
- var NUMBER_OF_ORGS = number_of_orgs;
- var OFFSET_LENGTH = offset_length;
- // Variables to handle progress bar updating
- var ITERATIONS = (number_of_orgs % offset_length)==0 ? Math.floor(number_of_orgs/offset_length) : Math.floor(number_of_orgs/offset_length)+1;
-
- if (ITERATIONS==0) {
- $("#div_duplicate_slots").html("<strong>No org slots to process</strong>");
- return;
- }
-
- var successful_calls = 0;
+ var assigned_proposals = [];
- $("#id_button_duplicate_slots").fadeOut("slow",
- function() {
- $("#duplicates_progress_bar").progressBar(0);
- $("#description_done").html("");
- // For every ajax success, bind this function to update user feedback
- $(this).bind("ajaxSuccess", function() {
- successful_calls++;
- var percentage = Math.floor(100 * (successful_calls) / (ITERATIONS));
- $("#duplicates_progress_bar").progressBar(percentage);
- $("#description_progressbar").html(" Processed orgs chunk " + (successful_calls) + "/" + ITERATIONS);
- // If this is the last call, feedback the user and print the duplicates data
- if (successful_calls==ITERATIONS) {
- $("#applications_progress_bar").fadeOut("slow",
- function() {
- $("#duplicates_progress_bar").progressBar(0);
- $("#id_button_duplicate_slots").fadeIn("slow");
- }
- );
- $("#description_progressbar").html("");
- $("#description_done").html("<strong> Done!</strong>");
- $("#duplicates_progress_bar").fadeOut("slow",
- function() {
- $("#id_button_duplicate_slots").val("Recalculate").fadeIn("slow",
- function() {
- // Call printing to HTML function with correct scope
- printDuplicatesAndSendJSON.call(this_object);
- }
- );
- }
- );
- }
- });
- // Call the showDuplicates function for the first time with correct scope
- $("#duplicates_progress_bar").fadeIn("slow", showDuplicates.apply(this_object,[url_to_query,OFFSET_LENGTH,NUMBER_OF_ORGS]));
+ // public function to output actual HTML out of the data (cached or not)
+ duplicateSlots.showDuplicatesHtml =
+ function (orgs_details, student, student_key, proposals) {
+ /*jslint undef:false */
+ if (html_string === '') {
+ jQuery("#div_duplicate_slots").html('');
+ html_string = '<ul>';
}
- );
- }
-
- function showDuplicates(url_to_query,OFFSET_LENGTH,NUMBER_OF_ORGS) {
- var current_offset = 0;
- orgs_details = {};
- assigned_proposals = new Array();
+ html_string += [
+ '<li>',
+ ' Student: ',
+ ' <strong>',
+ ' <a href="/student/show/', student_key, '">', student.name,
+ '</a>',
+ ' </strong> ',
+ '(<a href="mailto:', student.contact, '">', student.contact, '</a>)'
+ ].join("");
+ html_string += '<ul>';
+ jQuery(proposals).each(
+ function (intIndex, proposal) {
+ html_string += [
+ '<li>',
+ ' Organization: ',
+ ' <a href="/org/show/', proposal.org_key, '">',
+ orgs_details[proposal.org_key].name,
+ '</a>, admin: ', orgs_details[proposal.org_key].admin_name,
+ ' (<a href="mailto:',
+ orgs_details[proposal.org_key].admin_email,
+ '">',
+ orgs_details[proposal.org_key].admin_email, '</a>)</li>'
+ ].join("");
+ html_string += [
+ '<ul>',
+ ' <li>',
+ 'Proposal: ',
+ '<a href="/student_proposal/show/', proposal.proposal_key, '">',
+ proposal.proposal_title, '</a>',
+ ' </li>',
+ '</ul>'
+ ].join("");
+ }
+ );
+ html_string += '</ul></li>';
+ html_string += '</ul>';
+ jQuery("#div_duplicate_slots").html(html_string);
+ /*jslint undef:true */
+ };
- // Here Ajax call is handled
- setTimeout(function() {
- $.ajax({
- cache:false,
- mode: "sync",
- type: "GET",
- timeout: 1000000,
- dataType: "json",
- url: "/program/assigned_proposals/"+url_to_query+"?limit="+OFFSET_LENGTH+"&offset="+current_offset,
- success: function (data, textStatus) {
- if (data) {
- // Load JSON data
- loadSingleJSONData(data);
- }
- },
- error: function(XMLHttpRequest, textStatus, errorThrown) {
- // if there is an error return the button and leave a try again message
- if (XMLHttpRequest!=undefined) {
- $("#id_button_duplicate_slots").fadeIn("slow", function() {
- $("#description_done").html("<strong class='error'> Error encountered, try again</strong>");
- });
- }
- }
- });
- current_offset+=OFFSET_LENGTH;
- if (current_offset<NUMBER_OF_ORGS) {
- setTimeout(arguments.callee,1);
+ // private function to generate the JSON to send for caching and calling
+ // the actual function that will print the data
+ function printDuplicatesAndSendJSON() {
+ // JSON skeleton that need to be sent to the server
+ var to_json = {
+ "data": {
+ "orgs" : orgs_details,
+ "students": {}
+ }
+ };
+ // for every student...
+ jQuery.each(assigned_proposals, function (student_key, student) {
+ var accepted_proposals = student.proposals.length;
+ // if accepted proposal are less than 2, then ignore and
+ // continue the iteration
+ if (accepted_proposals < 2) {
+ return true;
}
- },1);
- // This prevent page reloading after each ajax call
- return false;
+ // push this student to the caching JSON
+ to_json.data.students[student_key] = student;
+ var proposals = student.proposals;
+ // call the function that prints the output html
+ duplicateSlots.showDuplicatesHtml(
+ orgs_details, student, student_key, proposals
+ );
+ });
+ /*jslint undef:false */
+ if (html_string === "") {
+ /*jslint undef:true */
+ jQuery("#div_duplicate_slots")
+ .html("<strong>No duplicate slots found</strong>");
+ }
+ // at the end, send the JSON for caching purposes
+ jQuery.ajax({
+ url: location.href,
+ type: 'POST',
+ processData: true,
+ data: {result: JSON.stringify(to_json)},
+ contentType: 'application/json',
+ dataType: 'json'
+ });
}
// private function to load a JSON and pushing the data to the
@@ -107,19 +104,21 @@
function loadSingleJSONData(data) {
if (data) {
// pushing org details
- for (var org_key in data.data.orgs) {
- orgs_details[org_key] = data.data.orgs[org_key];
- }
+ jQuery.each(data.data.orgs, function (org_key, organization) {
+ orgs_details[org_key] = organization;
+ });
// pushing proposals
- $(data.data.proposals).each(
- function(intIndex, proposal) {
+ jQuery(data.data.proposals).each(
+ function (intIndex, proposal) {
// if this student_key is not yet present
- if (assigned_proposals[proposal.student_key]==undefined) {
+ if (assigned_proposals[proposal.student_key] === undefined) {
// create the object and insert general info
assigned_proposals[proposal.student_key] = {};
- assigned_proposals[proposal.student_key].name = proposal.student_name;
- assigned_proposals[proposal.student_key].contact = proposal.student_contact;
- assigned_proposals[proposal.student_key].proposals = new Array();
+ assigned_proposals[proposal.student_key].name =
+ proposal.student_name;
+ assigned_proposals[proposal.student_key].contact =
+ proposal.student_contact;
+ assigned_proposals[proposal.student_key].proposals = [];
}
// anyway, push the accepted proposals
assigned_proposals[proposal.student_key].proposals.push(
@@ -134,58 +133,130 @@
}
}
- // private function to generate the JSON to send for caching and calling
- // the actual function that will print the data
- function printDuplicatesAndSendJSON() {
- // JSON skeleton that need to be sent to the server
- var to_json = {
- "data": {
- "orgs" : orgs_details,
- "students": {}
- }
- }
- // for every student...
- for (var student_key in assigned_proposals) {
- var accepted_proposals = assigned_proposals[student_key].proposals.length;
- // if accepted proposal are less than 2, then ignore and continue the iteration
- if (accepted_proposals<2) continue;
- var student = assigned_proposals[student_key];
- // push this student to the caching JSON
- to_json.data.students[student_key] = student;
- var proposals = student.proposals;
- // call the function that prints the output html
- this.showDuplicatesHtml(orgs_details,student,student_key,proposals);
- }
- if (html_string=="") {
- $("#div_duplicate_slots").html("<strong>No duplicate slots found</strong>");
- }
- // at the end, send the JSON for caching purposes
- $.ajax({
- url: location.href,
- type: 'POST',
- processData: true,
- data: {result: JSON.stringify(to_json)},
- contentType: 'application/json',
- dataType: 'json',
- });
+ function showDuplicates(url_to_query, OFFSET_LENGTH, NUMBER_OF_ORGS) {
+ var current_offset = 0;
+ orgs_details = {};
+ assigned_proposals = [];
+
+ // Here Ajax call is handled
+ setTimeout(
+ function () {
+ jQuery.ajax({
+ cache: false,
+ mode: "sync",
+ type: "GET",
+ timeout: 1000000,
+ dataType: "json",
+ url: [
+ "/program/assigned_proposals/", url_to_query,
+ "?limit=", OFFSET_LENGTH,
+ "&offset=", current_offset
+ ].join(""),
+ success: function (data, textStatus) {
+ if (data) {
+ // Load JSON data
+ loadSingleJSONData(data);
+ }
+ },
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
+ // if there is an error return the button and
+ // leave a try again message
+ if (XMLHttpRequest !== undefined) {
+ jQuery("#id_button_duplicate_slots").fadeIn("slow",
+ function () {
+ jQuery("#description_done").html([
+ "<strong class='error'> ",
+ "Error encountered, try again",
+ "</strong>"
+ ].join(""));
+ }
+ );
+ }
+ }
+ });
+ current_offset += OFFSET_LENGTH;
+ if (current_offset < NUMBER_OF_ORGS) {
+ setTimeout(arguments.callee, 1);
+ }
+ },
+ 1
+ );
+ // This prevent page reloading after each ajax call
+ return false;
}
- // public function to output actual HTML out of the data (cached or not)
- this.showDuplicatesHtml = function(orgs_details,student,student_key,proposals) {
- if (html_string == '') {
- $("#div_duplicate_slots").html('');
- html_string='<ul>';
+ // public function to begin iterating load of JSONs and then call printing
+ // of duplicates
+
+ duplicateSlots.showDuplicatesInit = function () {
+ /*jslint undef:false */
+ html_string = '';
+ // Remember this object for Javascript scoping
+ var this_object = this;
+ var NUMBER_OF_ORGS = number_of_orgs;
+ var OFFSET_LENGTH = offset_length;
+ /*jslint undef:true */
+ // Variables to handle progress bar updating
+ var ITERATIONS = (number_of_orgs % offset_length) === 0 ?
+ Math.floor(number_of_orgs / offset_length) :
+ Math.floor(number_of_orgs / offset_length) + 1;
+
+ if (ITERATIONS === 0) {
+ jQuery("#div_duplicate_slots")
+ .html("<strong>No org slots to process</strong>");
+ return;
}
- html_string+= '<li>Student: <strong><a href="/student/show/'+student_key+'">'+student.name+'</a></strong> (<a href="mailto:'+student.contact+'">'+student.contact+'</a>)';
- html_string+='<ul>';
- $(proposals).each(
- function (intIndex, proposal) {
- html_string+='<li>Organization: <a href="/org/show/'+proposal.org_key+'">'+orgs_details[proposal.org_key].name+'</a>, admin: '+orgs_details[proposal.org_key].admin_name+' (<a href="mailto:'+orgs_details[proposal.org_key].admin_email+'">'+orgs_details[proposal.org_key].admin_email+'</a>)</li>';
- html_string+='<ul><li>Proposal: <a href="/student_proposal/show/'+proposal.proposal_key+'">'+proposal.proposal_title+'</a></li></ul>';
+
+ var successful_calls = 0;
+
+ jQuery("#id_button_duplicate_slots").fadeOut("slow",
+ function () {
+ jQuery("#duplicates_progress_bar").progressBar(0);
+ jQuery("#description_done").html("");
+ // For every ajax success, bind this function to update user feedback
+ jQuery(this).bind("ajaxSuccess", function () {
+ successful_calls++;
+ var percentage = Math.floor(100 * (successful_calls) / (ITERATIONS));
+ jQuery("#duplicates_progress_bar").progressBar(percentage);
+ jQuery("#description_progressbar").html([
+ " Processed orgs chunk ", successful_calls, "/", ITERATIONS
+ ].join(""));
+ // If this is the last call, feedback the user and
+ // print the duplicates data
+ if (successful_calls === ITERATIONS) {
+ jQuery("#applications_progress_bar").fadeOut("slow",
+ function () {
+ jQuery("#duplicates_progress_bar").progressBar(0);
+ jQuery("#id_button_duplicate_slots").fadeIn("slow");
+ }
+ );
+ jQuery("#description_progressbar").html("");
+ jQuery("#description_done").html("<strong> Done!</strong>");
+ jQuery("#duplicates_progress_bar").fadeOut("slow",
+ function () {
+ jQuery("#id_button_duplicate_slots").val("Recalculate").fadeIn(
+ "slow",
+ function () {
+ // Call printing to HTML function with correct scope
+ printDuplicatesAndSendJSON.call(this_object);
+ }
+ );
+ }
+ );
+ }
+ });
+ // Call the showDuplicates function for the first time
+ // with correct scope
+ jQuery("#duplicates_progress_bar").fadeIn(
+ "slow",
+ showDuplicates.apply(
+ this_object,
+ /*jslint undef:false */
+ [url_to_query, OFFSET_LENGTH, NUMBER_OF_ORGS]
+ /*jslint undef:true */
+ )
+ );
}
);
- html_string+='</ul></li>';
- html_string+='</ul>';
- $("#div_duplicate_slots").html(html_string);
- }
-}
+ };
+}());
\ No newline at end of file
--- a/app/soc/content/js/map-090730.js Tue Aug 25 15:55:26 2009 +0100
+++ b/app/soc/content/js/map-090730.js Tue Aug 25 15:58:30 2009 +0100
@@ -1,10 +1,13 @@
-role_profile_gmap = new function(){
+(function () {
+ var role_profile_gmap = window.role_profile_gmap = function () {
+ };
+
// Create global variables
var map;
var marker;
var geocoder;
- // The following strings can be customized to reflect ids in the page.
+ // The following strings can be customized to reflect ids in the page.
// You can also add or remove fields used for GMap Geocoding in
// the JSON address object
@@ -48,62 +51,75 @@
id: "#id_res_postalcode",
old_value: ""
}
- }
+ };
// Save current address fields in the JSON Object
function saveOldAddress() {
- for (var a in address) {
- address[a].old_value = $(address[a].id).val();
- }
+ jQuery.each(address, function (level, level_details) {
+ level_details.old_value = jQuery(level_details.id).val();
+ });
}
// Return true if the user has edited address fields
function isNewAddress() {
- for (var a in address) {
- if ($(address[a].id).val() != address[a].old_value) return true;
- }
- return false;
+ var is_new = false;
+ jQuery.each(address, function (level, level_details) {
+ if (jQuery(level_details.id).val() !== level_details.old_value) {
+ is_new = true;
+ return false;
+ }
+ });
+ return is_new;
}
// Write saved lat and lng values to page fields
function setLatLngFields() {
- $(field_lat).val(current_lat);
- $(field_lng).val(current_lng);
+ jQuery(field_lat).val(current_lat);
+ jQuery(field_lng).val(current_lng);
}
// Read lat and lng fields and store them
function readLatLngFields() {
- current_lat = $(field_lat).val();
- current_lng = $(field_lng).val();
+ current_lat = jQuery(field_lat).val();
+ current_lng = jQuery(field_lng).val();
}
- // This function reads address fields, merge them and uses
+ // This function reads address fields, merge them and uses
// GMap API geocoding to find the first hit
- // Using geocoding http://code.google.com/intl/it-IT/apis/maps/documentation/services.html#Geocoding
+ // Using geocoding
+ // http://code.google.com/intl/it-IT/apis/maps/documentation/
+ // services.html#Geocoding
function calculateAddress() {
// If the user has really edited address fields...
if (isNewAddress()) {
// Merge address fields
var address_string = "";
- for (var a in address) {
- address_string+=$(address[a].id).val();
- if (a!=address.length-1) {address_string+=","};
- }
+ jQuery.each(address, function (level, level_details) {
+ address_string += jQuery(level_details.id).val() + ",";
+ });
// Ask GMap API for geocoding
geocoder.getLatLng(
address_string,
- function(point) {
+ function (point) {
// If a point is found
if (point) {
// Save the current address in the JSON object
saveOldAddress();
// Set the new zoom, map center and marker coords
var zoom_set = world_zoom;
- if ($(address.street.id).val()!="") zoom_set = address_zoom;
- else if ($(address.city.id).val()!="") zoom_set = city_zoom;
- else if ($(address.state.id).val()!="") zoom_set = state_zoom;
- else if ($(address.country.id).val()!="") zoom_set = country_zoom;
+ if (jQuery(address.street.id).val() !== "") {
+ zoom_set = address_zoom;
+ }
+ else if (jQuery(address.city.id).val() !== "") {
+ zoom_set = city_zoom;
+ }
+ else if (jQuery(address.state.id).val() !== "") {
+ zoom_set = state_zoom;
+ }
+ else if (jQuery(address.country.id).val() !== "") {
+ zoom_set = country_zoom;
+ }
map.setCenter(point, zoom_set);
marker.setPoint(point);
map.clearOverlays();
@@ -120,12 +136,12 @@
}
// Public function to load the map
- this.map_load = function() {
+ role_profile_gmap.map_load = function () {
// All can happen only if there is gmap compatible browser.
// TODO: Fallback in case the browser is not compatible
- if (GBrowserIsCompatible()) {
- // Save the address fields. This is useful if the page is being edited
- // to not update blindly the lat/lng fields with GMap geocoding if
+ if (window.GBrowserIsCompatible()) {
+ // Save the address fields. This is useful if the page is being edited
+ // to not update blindly the lat/lng fields with GMap geocoding if
// blurring an address field
saveOldAddress();
var starting_point;
@@ -133,36 +149,38 @@
var show_marker = true;
// Create the map and add small controls
- map = new GMap2(document.getElementById(map_div));
- map.addControl(new GSmallMapControl());
- map.addControl(new GMapTypeControl());
+ map = new window.GMap2(document.getElementById(map_div));
+ map.addControl(new window.GSmallMapControl());
+ map.addControl(new window.GMapTypeControl());
// Instantiate a global geocoder for future use
- geocoder = new GClientGeocoder();
+ geocoder = new window.GClientGeocoder();
- // If lat and lng fields are not void (the page is being edited) then
- // update the starting coords, modify the zoom level and tells following
+ // If lat and lng fields are not void (the page is being edited) then
+ // update the starting coords, modify the zoom level and tells following
// code to show the marker
- if ($(field_lat).val()!="" && $(field_lng).val()!="") {
+ if (jQuery(field_lat).val() !== "" && jQuery(field_lng).val() !== "") {
readLatLngFields();
zoom_selected = address_zoom;
show_marker = true;
}
-
+
// Set map center, marker coords and show it if this is an editing
- starting_point = new GLatLng(current_lat,current_lng);
+ starting_point = new window.GLatLng(current_lat, current_lng);
map.setCenter(starting_point, zoom_selected);
- marker = new GMarker(starting_point, {draggable:true});
- if (show_marker) map.addOverlay(marker);
-
+ marker = new window.GMarker(starting_point, {draggable: true});
+ if (show_marker) {
+ map.addOverlay(marker);
+ }
+
// Adds a new event listener to geocode the address when an address
// field is blurred
- for (var a in address) {
- $(address[a].id).blur(calculateAddress);
- }
-
+ jQuery.each(address, function (level, level_details) {
+ jQuery(level_details.id).blur(calculateAddress);
+ });
+
// Adds a new event listener: if the marker has been dragged around...
- GEvent.addListener(marker, "dragend", function() {
+ window.GEvent.addListener(marker, "dragend", function () {
// Update internal variables with current marker coords...
current_lat = marker.getPoint().lat();
current_lng = marker.getPoint().lng();
@@ -170,54 +188,56 @@
setLatLngFields();
});
}
- }
-};
+ };
+}());
-org_home_gmap = new function(){
+(function () {
+ var org_home_gmap = window.org_home_gmap = function () {
+ };
// Global variables
var map;
// HTML div tag where map needs to be inserted
var map_div = "org_home_map";
-
+
// Setup required icons
- var base_icon = new GIcon();
+ var base_icon = new window.GIcon();
base_icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
- base_icon.iconSize = new GSize(20, 34);
- base_icon.shadowSize = new GSize(37, 34);
- base_icon.iconAnchor = new GPoint(9, 34);
- base_icon.infoWindowAnchor = new GPoint(9, 2);
- base_icon.infoShadowAnchor = new GPoint(18, 25);
- var student_icon = new GIcon(base_icon);
+ base_icon.iconSize = new window.GSize(20, 34);
+ base_icon.shadowSize = new window.GSize(37, 34);
+ base_icon.iconAnchor = new window.GPoint(9, 34);
+ base_icon.infoWindowAnchor = new window.GPoint(9, 2);
+ base_icon.infoShadowAnchor = new window.GPoint(18, 25);
+ var student_icon = new window.GIcon(base_icon);
student_icon.image = "http://www.google.com/mapfiles/marker.png";
- var mentor_icon = new GIcon(base_icon);
+ var mentor_icon = new window.GIcon(base_icon);
mentor_icon.image = "/soc/content/images/mentor-marker.png";
// Map load function
- this.map_load = function(map_data) {
+ org_home_gmap.map_load = function (map_data) {
- if (GBrowserIsCompatible()) {
+ if (window.GBrowserIsCompatible()) {
// Create the map and add small controls
- map = new GMap2(document.getElementById(map_div));
- map.addControl(new GLargeMapControl());
- map.addControl(new GMapTypeControl());
+ map = new window.GMap2(document.getElementById(map_div));
+ map.addControl(new window.GLargeMapControl());
+ map.addControl(new window.GMapTypeControl());
// Set map center and initial zoom level
- map.setCenter(new GLatLng(0, 0), 1);
+ map.setCenter(new window.GLatLng(0, 0), 1);
var mentors = {};
var students = {};
var projects = {};
var polylines = [];
- jQuery.each(map_data.people, function(key, person) {
+ jQuery.each(map_data.people, function (key, person) {
if (person.type === "student") {
students[key] = {
"name": person.name,
"lat": person.lat,
"long": person.long,
"projects": person.projects
- }
+ };
}
if (person.type === "mentor") {
mentors[key] = {
@@ -239,31 +259,41 @@
current_student.long !== null &&
current_mentor.lat !== null &&
current_mentor.long !== null) {
- polylines.push([[current_student.lat,current_student.long],[current_mentor.lat,current_mentor.long]]);
+ /*jslint white: false */
+ polylines.push([
+ [current_student.lat, current_student.long],
+ [current_mentor.lat, current_mentor.long]
+ ]);
+ /*jslint white: true */
}
});
// Iterate over students
- jQuery.each(students, function(key, person) {
+ jQuery.each(students, function (key, person) {
var html = "";
var marker = null;
- if (person.lat!==null && person.long!==null) {
- point = new GLatLng(person.lat,
- person.long);
+ if (person.lat !== null && person.long !== null) {
+ var point = new window.GLatLng(person.lat, person.long);
- marker = new GMarker(point, student_icon);
- html = "<strong>" + person.name + "</strong><br />";
- html += "<span style='font-style:italic;'>Student</span><br />";
- html += "<div style='height:100px;width:300px;overflow:auto;font-size:70%'>";
+ marker = new window.GMarker(point, student_icon);
+ html = [
+ "<strong>", person.name, "</strong><br />",
+ "<span style='font-style:italic;'>Student</span><br />",
+ "<div style='height:100px;width:300px;",
+ "overflow:auto;font-size:70%'>"
+ ].join("");
// iterate through projects
jQuery.each(person.projects, function () {
var current_project = map_data.projects[this];
- html += "<a href='"+ current_project.redirect + "'>" + current_project.title + "</a><br />";
- html += "Mentor: " + current_project.mentor_name + "<br />";
+ html += [
+ "<a href='", current_project.redirect, "'>",
+ current_project.title, "</a><br />",
+ "Mentor: ", current_project.mentor_name, "<br />"
+ ].join("");
});
- html+= "</div>";
- GEvent.addListener(marker, "click", function() {
+ html += "</div>";
+ window.GEvent.addListener(marker, "click", function () {
marker.openInfoWindowHtml(html);
});
@@ -272,27 +302,32 @@
});
// Iterate over mentors
- jQuery.each(mentors, function(key, person) {
+ jQuery.each(mentors, function (key, person) {
var html = "";
var marker = null;
- if (person.lat!==null && person.long!==null) {
- point = new GLatLng(person.lat,
- person.long);
+ if (person.lat !== null && person.long !== null) {
+ var point = new window.GLatLng(person.lat, person.long);
- marker = new GMarker(point, mentor_icon);
- html = "<strong>" + person.name + "</strong><br />";
- html += "<span style='font-style:italic;'>Mentor</span><br />";
- html += "<div style='height:100px;width:300px;overflow:auto;font-size:70%'>";
+ marker = new window.GMarker(point, mentor_icon);
+ html = [
+ "<strong>", person.name, "</strong><br />",
+ "<span style='font-style:italic;'>Mentor</span><br />",
+ "<div style='height:100px;width:300px;",
+ "overflow:auto;font-size:70%'>"
+ ].join("");
// iterate through projects
jQuery.each(person.projects, function () {
var current_project = map_data.projects[this];
- html += "<a href='"+ current_project.redirect + "'>" + current_project.title + "</a><br />";
- html += "Student: " + current_project.student_name + "<br />";
+ html += [
+ "<a href='", current_project.redirect, "'>",
+ current_project.title, "</a><br />",
+ "Student: ", current_project.student_name, "<br />"
+ ].join("");
});
- html+= "</div>";
+ html += "</div>";
- GEvent.addListener(marker, "click", function() {
+ window.GEvent.addListener(marker, "click", function () {
marker.openInfoWindowHtml(html);
});
@@ -301,12 +336,12 @@
});
// Draw all polylines
- jQuery.each(polylines, function() {
- var from = new GLatLng(this[0][0],this[0][1]);
- var to = new GLatLng(this[1][0],this[1][1]);
- var polyline = new GPolyline([from, to], "#ff0000", 3);
+ jQuery.each(polylines, function () {
+ var from = new window.GLatLng(this[0][0], this[0][1]);
+ var to = new window.GLatLng(this[1][0], this[1][1]);
+ var polyline = new window.GPolyline([from, to], "#ff0000", 3);
map.addOverlay(polyline);
});
}
- }
-};
+ };
+}());
--- a/app/soc/content/js/menu-081108.js Tue Aug 25 15:55:26 2009 +0100
+++ b/app/soc/content/js/menu-081108.js Tue Aug 25 15:58:30 2009 +0100
@@ -1,22 +1,24 @@
-$(function() {
+jQuery(function () {
+ var new_item_text = "(new)";
+ jQuery('#menu li.expandable').find('a').each(function () {
+ if (jQuery(this).text().indexOf(new_item_text) > -1) {
+ jQuery(this).css('color', 'red');
+ }
+ });
- var new_item_text = "(new)"
- $('#menu li.expandable').find('a').each(function(){
- if ($(this).text().indexOf(new_item_text) > -1)
- $(this).css('color', 'red');
- });
-
- $('#side #menu li.expandable > a').dblclick(function() {
- window.location = $(this).attr('href');
- })
- $('#side #menu li.expandable > span').toggle(function() {
- $(this).find("img").attr('src', '/soc/content/images/plus.gif')
+ jQuery('#side #menu li.expandable > a').dblclick(function () {
+ window.location = jQuery(this).attr('href');
+ });
+
+ jQuery('#side #menu li.expandable > span').toggle(function () {
+ jQuery(this).find("img").attr('src', '/soc/content/images/plus.gif')
.end().parent().children("ul").toggle();
- }, function() {
- $(this).find("img").attr('src', '/soc/content/images/minus.gif')
+ }, function () {
+ jQuery(this).find("img").attr('src', '/soc/content/images/minus.gif')
.end().parent().children("ul").toggle();
return false;
});
- $('#side #menu li.expandable > span').contents()
+
+ jQuery('#side #menu li.expandable > span').contents()
.before('<img src="/soc/content/images/minus.gif" />');
-});
+});
--- a/app/soc/content/js/slot-allocator-090320.js Tue Aug 25 15:55:26 2009 +0100
+++ b/app/soc/content/js/slot-allocator-090320.js Tue Aug 25 15:58:30 2009 +0100
@@ -9,29 +9,52 @@
"<p id='p_remaining_slots'></p>",
"<p id='p_total_slots'></p></div>",
"<div class='tooltip-bottom'></div>",
- "</div>",
- ].join('');
+ "</div>"
+].join('');
+
+jQuery.postJSON = function (post_url, to_json, callback) {
+ jQuery.ajax({
+ url: post_url,
+ type: 'POST',
+ processData: true,
+ data: {result: JSON.stringify(to_json)},
+ contentType: 'application/json',
+ dataType: 'json',
+ success: callback
+ });
+};
-$.postJSON = function (post_url, to_json, callback) {
- $.ajax({
- url: post_url,
- type: 'POST',
- processData: true,
- data: {result: JSON.stringify(to_json)},
- contentType: 'application/json',
- dataType: 'json',
- success: callback,
- });
-};
+function updateCurrentSlots() {
+ current_allocated_slots = 0;
+ jQuery.each(current_slots, function (org_id, org_details) {
+ current_allocated_slots =
+ current_allocated_slots + Number(org_details.slots);
+ });
+}
+
+function updateOverlay() {
+ updateCurrentSlots();
+ var remaining_slots = window.MAX_AVAILABLE_SLOTS - current_allocated_slots;
+ jQuery("#p_assigned_slots")
+ .html("<strong>Assigned slots:</strong> " + current_allocated_slots);
+ jQuery("#p_remaining_slots")
+ .html("<strong>Remaining slots:</strong> " + remaining_slots);
+}
function updateFromJSON(data) {
if (data) {
- $(data.data).each(
- function (intIndex,item) {
- $("#id_spin_slot_count_"+item.link_id).val(item.slots);
- current_slots[item.link_id] = {slots: item.slots, locked: item.locked, adjustment: item.adjustment};
- $("#id_locked_slot_"+item.link_id).attr("checked",item.locked);
- $("#id_spin_adjustment_count_"+item.link_id).val(item.adjustment);
+ jQuery(data.data).each(
+ function (intIndex, item) {
+ jQuery("#id_spin_slot_count_" + item.link_id).val(item.slots);
+ current_slots[item.link_id] = {
+ slots: item.slots,
+ locked: item.locked,
+ adjustment: item.adjustment
+ };
+ jQuery("#id_locked_slot_" + item.link_id)
+ .attr("checked", item.locked);
+ jQuery("#id_spin_adjustment_count_" + item.link_id)
+ .val(item.adjustment);
}
);
updateOverlay();
@@ -39,61 +62,49 @@
}
function retrieveJSON() {
- $.getJSON(RETURN_URL+"?_="+(new Date().getTime()), function(data) {
- if (data) {
- updateFromJSON(data);
+ jQuery.getJSON(
+ window.RETURN_URL + "?_=" + (new Date().getTime()),
+ function (data) {
+ if (data) {
+ updateFromJSON(data);
+ }
}
- }
);
}
function reCalculate() {
- url = RETURN_URL+"?_="+(new Date().getTime())
- $.postJSON(url, current_slots, updateFromJSON);
+ var url = window.RETURN_URL + "?_=" + (new Date().getTime());
+ jQuery.postJSON(url, current_slots, updateFromJSON);
}
function submit() {
- url = RETURN_URL+"?submit=1&_="+(new Date().getTime())
- $.postJSON(url, current_slots, updateFromJSON);
+ var url = window.RETURN_URL + "?submit=1&_=" + (new Date().getTime());
+ jQuery.postJSON(url, current_slots, updateFromJSON);
}
function load() {
- url = RETURN_URL+"?load=1&_="+(new Date().getTime())
- $.postJSON(url, current_slots, updateFromJSON);
+ var url = window.RETURN_URL + "?load=1&_=" + (new Date().getTime());
+ jQuery.postJSON(url, current_slots, updateFromJSON);
}
-function updateOverlay() {
- updateCurrentSlots();
- var remaining_slots = MAX_AVAILABLE_SLOTS - current_allocated_slots;
- $("#p_assigned_slots").html("<strong>Assigned slots:</strong> "+current_allocated_slots);
- $("#p_remaining_slots").html("<strong>Remaining slots:</strong> "+remaining_slots);
-}
-
-function updateCurrentSlots() {
- current_allocated_slots = 0;
- for (var org_id in current_slots) {
- current_allocated_slots = current_allocated_slots+new Number(current_slots[org_id].slots);
- }
-}
-
-function lockSlots (checkbox) {
- var locked = $(checkbox).attr("checked");
+function lockSlots(checkbox) {
+ var locked = jQuery(checkbox).attr("checked");
var re = /^id_locked_slot_(\w*)/;
var org_link_id = checkbox.id.match(re)[1];
current_slots[org_link_id].locked = locked;
}
-function assignSlots (counter) {
+function assignSlots(counter) {
var re = /^id_spin_slot_count_(\w*)/;
var org_link_id = counter.id.match(re)[1];
- current_slots[org_link_id].slots = $(counter).val();
+ current_slots[org_link_id].slots = jQuery(counter).val();
updateCurrentSlots();
updateOverlay();
}
-function assignAdjustment (counter) {
+function assignAdjustment(counter) {
var re = /^id_spin_adjustment_count_(\w*)/;
var org_link_id = counter.id.match(re)[1];
- current_slots[org_link_id].adjustment = $(counter).val();
+ current_slots[org_link_id].adjustment = jQuery(counter).val();
}
--- a/app/soc/content/js/survey-edit-090708.js Tue Aug 25 15:55:26 2009 +0100
+++ b/app/soc/content/js/survey-edit-090708.js Tue Aug 25 15:58:30 2009 +0100
@@ -454,8 +454,10 @@
(function ($) {
$(function () {
- var del_li = ["<a class='delete_item' id='del_",
- "' ><img src='/soc/content/images/minus.gif'/></a> "];
+ var del_li = [
+ "<a class='delete_item' id='del_",
+ "' ><img src='/soc/content/images/minus.gif'/></a> "
+ ];
// Confirmation dialog for deleting list/choice-field item from survey
$("#delete_item_dialog").dialog({
@@ -503,7 +505,7 @@
'<span id="', id_, '" class="editable_option" name="', id_,
'__field">', name, '</span>', '<input type="hidden" id="', id_,
'__field" name="', id_, '__field" value="',
- name.replace(/\"/g,'"'), '" >', '</li>'
+ name.replace(/\"/g, '"'), '" >', '</li>'
].join(""));
ol.append(
@@ -717,7 +719,7 @@
'<span id="' + id_ + '" class="editable_option" name="',
id_, '__field">', oname, '</span>', '<input ',
'type="hidden" id="', id_, '__field" name="', id_,
- '__field" value="', oname.replace(/\"/g,'"'), '" >', '</li>'
+ '__field" value="', oname.replace(/\"/g, '"'), '" >', '</li>'
].join(""));
ol.append(option_html.prepend(
del_li.join(option_html.attr('id'))));
--- a/app/soc/content/js/survey-take-090708.js Tue Aug 25 15:55:26 2009 +0100
+++ b/app/soc/content/js/survey-take-090708.js Tue Aug 25 15:58:30 2009 +0100
@@ -54,9 +54,11 @@
.find('.pick_multi').each(
function () {
$(this).find('input').each(
+ /*jslint white: false */
function () {
// if $(this).attr('checked', 'true');});
}
+ /*jslint white: true */
);
}
);
@@ -142,12 +144,12 @@
* == Customize Comment Appearance ==
*/
- var comments = widget.find('td > .comment');
- comments.each(function(){
- $(this).parents('tr:first')
+ var comments = widget.find('td > .comment');
+ comments.each(function () {
+ $(this).parents('tr:first')
.prev().css({'margin-top': '-10px'})
.find('label').css({'font-size': '11px'});
- });
+ });
});
}(jQuery));