diff --git a/dr_api.js b/dr_api.js new file mode 100644 index 0000000..798013f --- /dev/null +++ b/dr_api.js @@ -0,0 +1,3241 @@ +/** + * digital ROCK jQuery based Javascript API + * + * @link http://www.digitalrock.de + * @author Ralf Becker + * @copyright 2010-18 by RalfBecker@digitalROCK.de + * @version $Id: dr_api.js 1250 2015-06-18 06:49:01Z ralfbecker $ + */ + +/** + * Widgets defined in this file: + * + * - DrWidget: universal widget, which can display all data-types and implement reload-free / in-place navigation + * - Resultlist: displays results and rankings, inherits from Startlist + * - Startlist: displays startlists and implementes automatic scrolling and rotation through multiple results + * - Results: displays top results of multiple categories and allows to change competition + * - Starters: displays registration data + * - Competitions: displays calendar, allows to change year and optional filter + * - Profile: display profile of an athlete based on a html template + * - ResultTemplate: displays result based on a html template + * - Aggregated: displays an aggregated ranking: national team ranking, GER sektionenwertung or SUI regionalzentren + * - DrBaseWidget: virtual base of all widgets implements json(p) loading of data + * - DrTable: creates and updates a table from data and a column definition, used by most widgets + * + * In almost all cases you only need to use DrWidget as shown in following example: + * + * + * + * + * + *
+ * + * + * @link http://www.digitalrock.de/egroupware/ranking/README describes available parameters for json url + * @link https://developers.google.com/webmasters/ajax-crawling/ describes supported ajax crawling scheme + * @link http://svn.outdoor-training.de/repos/trunk/ranking/inc/class.ranking_widget.inc.php php class implementing ajax crawling + */ + +/** + * Example with multi-result scrolling (use c= and r= for cat and route) + * + * http://www.digitalrock.de/egroupware/ranking/sitemgr/digitalrock/eliste.html?comp=1251&cat=1&route=2&detail=0&rotate=c=1,r=2:c=2,r=2 + * + * You can also supply an optional parameter w= (think of German "Wettkampf" as "c" was already taken) to rotate though different competitions (the first of which is specified by the "comp" parameter in the original URL. + * + * Example https://www.digitalrock.de/egroupware/ranking/sitemgr/digitalrock/eliste.html?comp=1395&beamer=1&cat=1&route=0&rotate=w=1395,c=1,r=0:w=1396,c=1,r=0 + * + * The interesting part here is rotate=w=1395,c=1,r=0:w=1396,c=1,r=0 + */ + +/** + * Show nation specific footer + * + * @param {jQuery|String} selector where to show the footer + * @param {String} nation + */ +function showFooterByNation(selector, nation) { + var jelem = jQuery(selector); + var footer = "/icc_footer.inc.php"; + switch (nation) { + case "GER": + footer = "/dav_footer.inc.php"; + break; + case "SUI": + footer = "/sac_footer.inc.php p:not(.register)"; + break; + } + jelem.load(footer, function () { + jelem.fadeIn("slow"); + }); +} + +/** + * Show category specific footer + * + * @param {jQuery|String} selector where to show the footer + * @param {Number|String} cat default read it from cat parameter of document + */ +function showFooterByCat(selector, cat) { + if (!cat) + cat = (document.location.href.match(/cat=([a-z]{3}|\d+)/i) || [])[1]; + var national_cats = { + GER: [ + 212, 211, 207, 294, 205, 14, 202, 201, 296, 200, 206, 213, 4, 215, 13, + 108, 12, 11, 66, 7, 226, 223, 217, 216, 214, 25, 54, 109, 107, 106, 67, + 48, 49, 50, 51, 52, 53, 110, 111, 113, 114, 28, 27, 26, 112, 115, + ], + SUI: [ + 47, 46, 44, 116, 30, 35, 69, 68, 43, 41, 209, 208, 219, 222, 31, 32, 33, + 34, 36, 37, 38, 39, + ], + }; + for (var nation in national_cats) { + if ( + cat.toUpperCase() === nation || + national_cats[nation].indexOf(parseInt(cat)) >= 0 + ) { + showFooterByNation(selector, nation); + return; + } + } + showFooterByNation(selector); +} + +/** + * Baseclass for all widgets + * + * We only use jQuery() here (not $() or $j()!) to be able to run as well inside EGroupware as with stock jQuery from googleapis. + */ +var DrBaseWidget = (function () { + /** + * Constructor for all widgets from given json url + * + * Table get appended to specified _container + * + * @param _container + * @param _json_url url for data to load + */ + function DrBaseWidget(_container, _json_url) { + this.json_url = _json_url; + this.container = jQuery( + typeof _container == "string" ? "#" + _container : _container + ); + this.container.addClass(this.constructor.name); + } + /** + * Install update method as popstate or hashchange handler + */ + DrBaseWidget.prototype.installPopState = function () { + // add popstate or hashchange (IE8,9) event listener, to use browser back button for navigation + // some browsers, eg. Chrome, generate a pop on inital page-load + // to prevent loading page initially twice, we store initial location + this.prevent_initial_pop = location.href; + var initial_params = this.json_url.replace(/^.*(#!|#|\?)/, "") || ""; + var that = this; + jQuery(window).bind( + window.history.pushState ? "popstate" : "hashchange", + function (e) { + if ( + !that.prevent_initial_pop || + that.prevent_initial_pop != location.href + ) { + that.update(location.hash || location.query || initial_params); + } + delete that.prevent_initial_pop; + } + ); + }; + /** + * Update Widget from json_url + * + * To be able to cache jsonp requests in CDN, we have to use the same callback. + * Using same callback leads to problems with concurrent requests: failed: parsererror (jsonp was not called) + * To work around that we queue jsonp request, if there's already one running. + * + * Queue is maintained globally in DrBaseWidget.jsonp_queue, as requests come from different objects! + * + * @param {boolean} ignore_queue used internally to start next object in queue without requeing it + */ + DrBaseWidget.prototype.update = function (ignore_queue) { + // remove our own parameters and current year from json url to improve caching + var url = this.json_url + .replace(/(detail|beamer|rotate|toc)=[^&]*(&|$)/, "") + .replace(new RegExp("year=" + new Date().getFullYear() + "(&|$)"), "") + .replace(/&$/, ""); + + // do we need a jsonp request + var jsonp = + this.json_url.indexOf("//") != -1 && + this.json_url.split("/", 3) != location.href.split("/", 3); + if (typeof DrBaseWidget.jsonp_queue == "undefined") + DrBaseWidget.jsonp_queue = []; + if (!ignore_queue && jsonp) { + // add us to the queue + DrBaseWidget.jsonp_queue.push(this); + } + // if there's only one in the queue (or no queueing necessary: no jsonp) --> send ajax request + if (ignore_queue || !jsonp || DrBaseWidget.jsonp_queue.length == 1) { + jQuery.ajax({ + url: url, + async: true, + context: this, + data: "", + dataType: jsonp ? "jsonp" : "json", + jsonpCallback: "jsonp", // otherwise jQuery generates a random name, not cachable by CDN + cache: true, + type: "GET", + success: function (_data) { + // if we are first object in queue, remove us + if (DrBaseWidget.jsonp_queue[0] === this) + DrBaseWidget.jsonp_queue.shift(); + // if someone left in queue, run it's update ignore the queue + if (DrBaseWidget.jsonp_queue.length) + DrBaseWidget.jsonp_queue[0].update(true); + this.handleResponse(_data); + }, + error: function (_xmlhttp, _err, _status) { + // need same handling as success + if (DrBaseWidget.jsonp_queue[0] === this) + DrBaseWidget.jsonp_queue.shift(); + if (DrBaseWidget.jsonp_queue.length) + DrBaseWidget.jsonp_queue[0].update(true); + //if (_err != 'timeout') alert('Ajax request to '+this.json_url+' failed: '+_err+(_status?' ('+_status+')':'')); + // schedule update again after 60sec + this.update_handle = window.setTimeout( + jQuery.proxy(this.update, this, ignore_queue), + 60000 + ); + }, + }); + } + }; + /** + * Callback for loading data via ajax + * + * Virtual, need to be implemented in inheriting objects! + * + * @param _data + */ + DrBaseWidget.prototype.handleResponse = function (_data) { + throw ( + "No handleResponse implemented in " + + this.constructor.name + + " inheriting from DrBaseWidget!" + ); + }; + /** + * Add list with see also links, if not beamer or toc disabled + * + * @param _see_also + */ + DrBaseWidget.prototype.seeAlso = function (_see_also) { + this.container.find("ul.seeAlso").remove(); + + if ( + typeof _see_also != "undefined" && + _see_also.length > 0 && + !this.json_url.match(/toc=0/) && + !this.json_url.match(/beamer=1/) + ) { + var ul = jQuery(document.createElement("ul")).attr("class", "seeAlso"); + ul.prepend(document.createTextNode(this.lang("See also:"))); + for (var i = 0; i < _see_also.length; ++i) { + var tag = jQuery(document.createElement("li")); + ul.append(tag); + if (_see_also[i].url) { + var a = jQuery(document.createElement("a")).attr( + "href", + _see_also[i].url + ); + tag.append(a); + if (this.navigateTo) { + a.click(this.navigateTo); + } + tag = a; + } + tag.text(_see_also[i].name); + } + this.container.append(ul); + } + }; + /** + * Replace attribute named from with one name to and value keeping the order of the attributes + * + * @param {object} obj + * @param {string} from + * @param {string} to + * @param {*} value + */ + DrBaseWidget.prototype.replace_attribute = function (obj, from, to, value) { + var found = false; + for (var attr in obj) { + if (!found) { + if (attr == from) { + found = true; + delete obj[attr]; + obj[to] = value; + } + } else { + var val = obj[attr]; + delete obj[attr]; + obj[attr] = val; + } + } + }; + /** + * Replace "nation" column with what's specified in "display_athlete" on competition + * + * @param {string} _display_athlete + * @param {string} _nation + */ + DrBaseWidget.prototype.replace_nation = function (_display_athlete, _nation) { + switch (_display_athlete) { + case "none": + delete this.columns.nation; + break; + case "city": + case "pc_city": + this.replace_attribute(this.columns, "nation", "city", "City"); + break; + case "federation": + case "fed_and_parent": + var fed_label = "Federation"; + switch (_nation) { + case "GER": + fed_label = "DAV Sektion"; + break; + case "SUI": + fed_label = "Sektion"; + break; + } + this.replace_attribute(this.columns, "nation", "federation", fed_label); + break; + } + }; + /** + * Format a date according to browser local format + * + * @param {string} _ymd yyyy-mm-dd string or everything understood by date constructor + * @returns {string} + */ + DrBaseWidget.prototype.formatDate = function (_ymd) { + if (!_ymd || typeof _ymd != "string") return ""; + + var date = new Date(_ymd); + + return date.toLocaleDateString().replace(/[0-9]+\./g, function (_match) { + return _match.length <= 2 ? "0" + _match : _match; + }); + }; + + /** + * Translate english phrase into user language + * + * @param {string} _msg + * @returns {string} + */ + DrBaseWidget.prototype.lang = function (_msg) { + if (_msg === null) { + return ""; + } + if (typeof _msg !== "string" && _msg) { + console.log("Cannot translate an object", _msg); + return _msg; + } + var translation = _msg; + + if (typeof dr_translations !== "undefined") { + if (typeof DrBaseWidget.user_lang === "undefined") { + var language = + (navigator.languages && navigator.languages[0]) || // Chrome / Firefox + navigator.language || // All browsers + navigator.userLanguage; // IE <= 10 + DrBaseWidget.user_lang = language.replace(/-[A-Z]+/, ""); + } + if ( + dr_translations[_msg] && + dr_translations[_msg][DrBaseWidget.user_lang] + ) { + translation = dr_translations[_msg][DrBaseWidget.user_lang]; + } + } + if (arguments.length == 1) return translation; + + if (arguments.length == 2) return translation.replace("%1", arguments[1]); + + // to cope with arguments containing '%2' (eg. an urlencoded path like a referer), + // we first replace all placeholders '%N' with '|%N|' and then we replace all '|%N|' with arguments[N] + translation = translation.replace(/%([0-9]+)/g, "|%$1|"); + for (var i = 1; i < arguments.length; ++i) { + translation = translation.replace("|%" + i + "|", arguments[i]); + } + return translation; + }; + + return DrBaseWidget; +})(); + +/** + * DrTable helper to construct table from colum-defition and data + */ +var DrTable = (function () { + /** + * Constructor for table with given data and columns + * + * Table get appended to specified _container + * + * @param _data array with data for each participant + * @param _columns hash with column name => header + * @param _sort column name to sort by + * @param _ascending + * @param _quota quota if quota line should be drawn in result + * @param _navigateTo click method for profiles + * @param _showUnranked if true AND _sort=='result_rank' show participants without rank, default do NOT show them + */ + function DrTable( + _data, + _columns, + _sort, + _ascending, + _quota, + _navigateTo, + _showUnranked + ) { + this.data = _data; + this.columns = _columns; + if (typeof _sort == "undefined") for (_sort in _columns) break; + this.sort = _sort; + if (typeof _ascending == "undefined") _ascending = true; + this.ascending = _ascending; + this.quota = parseInt(_quota); + this.navigateTo = _navigateTo; + this.showUnranked = _showUnranked ? true : false; + // hash with PerId => tr containing athlete + this.athletes = {}; + + this.sortData(); + + // header + this.dom = document.createElement("table"); + jQuery(this.dom).addClass("DrTable"); + var thead = document.createElement("thead"); + jQuery(this.dom).append(thead); + var row = this.createRow(this.columns, "th"); + jQuery(thead).append(row); + + // athletes + var tbody = jQuery(document.createElement("tbody")); + jQuery(this.dom).append(tbody); + + for (var i = 0; i < this.data.length; ++i) { + var data = this.data[i]; + + if (Array.isArray(data.results)) { + // category with result + if (typeof this.column_count == "undefined") { + this.column_count = 0; + for (var c in this.columns) ++this.column_count; + } + if (typeof data.name != "undefined") { + row = document.createElement("tr"); + var th = jQuery(document.createElement("th")); + th.attr("colspan", this.column_count); + th.text(data.name); + if (typeof data.url != "undefined") { + var a = jQuery(document.createElement("a")); + a.attr("href", data.url); + a.text(this.lang("Complete Results")); + if (this.navigateTo || typeof data.click != "undefined") + a.click(this.navigateTo || data.click); + th.append(a); + } + jQuery(row).append(th); + tbody.append(row); + } + for (var j = 0; j < data.results.length; ++j) { + tbody.append(this.createRow(data.results[j])); + } + } // single result row + else { + if ( + this.sort == "result_rank" && + ((typeof data.result_rank == "undefined" && !this.showUnranked) || + data.result_rank < 1) + ) { + break; // no more ranked competitiors + } + tbody.append(this.createRow(data)); + } + } + //console.log(this.athletes); + } + + DrTable.prototype.lang = DrBaseWidget.prototype.lang; + + /** + * Update table with new data, trying to re-use existing rows + * + * @param _data array with data for each participant + * @param _quota quota if quota line should be drawn in result + */ + DrTable.prototype.update = function (_data, _quota) { + this.data = _data; + if (typeof _quota != "undefined") this.quota = parseInt(_quota); + //console.log(this.data); + this.sortData(); + + var tbody = this.dom.firstChild.nextSibling; + var pos; + + // uncomment to test update: reverses the list on every call + //if (this.data[0].PerId == tbody.firstChild.id) this.data.reverse(); + + var athletes = this.athletes; + this.athletes = {}; + + for (var i = 0; i < this.data.length; ++i) { + var data = this.data[i]; + var row; + if (data.PerId != "undefined") { + row = athletes[data.PerId]; + } else if (data.team_id != "undefined") { + row = athletes[data.team_id]; + } + if ( + this.sort == "result_rank" && + (typeof data.result_rank == "undefined" || data.result_rank < 1) + ) { + break; // no more ranked competitiors + } + // search athlete in tbody + if (typeof row != "undefined") { + //jQuery(row).detach(); + //this.updateRow(row,data); + jQuery(row).remove(); + } + //else + { + row = this.createRow(data); + } + // no child in tbody --> append row + if (typeof pos == "undefined") { + jQuery(tbody).prepend(row); + } else { + jQuery(pos).after(row); + } + pos = row; + } + // remove further rows / athletes not in this.data + if (typeof pos != "undefined" && typeof pos.nextSibling != "undefined") { + jQuery("#" + pos.id + " ~ tr").remove(); + } + }; + + /** + * Update given data-row with changed content + * + * @param {object} _row + * @param {object} _data + * @todo + */ + DrTable.prototype.updateRow = function (_row, _data) {}; + + /** + * Create new data-row with all columns from this.columns + * + * @param {object} _data + * @param {string} [_tag=td] + */ + DrTable.prototype.createRow = function (_data, _tag) { + //console.log(_data); + if (typeof _tag == "undefined") _tag = "td"; + var row = document.createElement("tr"); + if (typeof _data.PerId != "undefined" && _data.PerId > 0) { + row.id = _data.PerId; + if (_data.className) { + row.className = _data.className; + if (row.className.match(/hideNames/)) + row.title = this.lang("Athlete asked not to show his name anymore."); + } + this.athletes[_data.PerId] = row; + } else if (typeof _data.team_id != "undefined" && _data.team_id > 0) { + row.id = _data.team_id; + this.athletes[_data.team_id] = row; + } + var span = 1; + for (var col in this.columns) { + if (--span > 0) continue; + + var url = _data.url; + + // if object has a special getter func, call it + var col_data; + if (typeof this.columns[col] == "function") { + col_data = this.columns[col].call(this, _data, _tag, col); + } else { + col_data = _data[col]; + } + // allow /-delemited expressions to index into arrays and objects + if (typeof col_data == "undefined" && col.indexOf("/") != -1) { + var parts = col.split("/"); + col_data = _data; + for (var p in parts) { + col = parts[p]; + if (col == "lastname" || col == "firstname") url = col_data.url; + if (typeof col_data != "undefined") col_data = col_data[col]; + } + } else if (col.indexOf("/") != -1) + col = col.substr(col.lastIndexOf("/") + 1); + + var tag = document.createElement(_tag); + tag.className = col; + jQuery(row).append(tag); + + // add pstambl link to name & vorname + if ( + typeof url != "undefined" && + (col == "lastname" || col == "firstname") + ) { + var a = document.createElement("a"); + a.href = url; + a.target = "pstambl"; + if (this.navigateTo && url.indexOf("#") != -1) + jQuery(a).click(this.navigateTo); + jQuery(tag).append(a); + tag = a; + } + if ( + typeof _data.fed_url != "undefined" && + (col == "nation" || col == "federation") + ) { + var a = document.createElement("a"); + a.href = _data.fed_url; + a.target = "_blank"; + jQuery(tag).append(a); + tag = a; + } + if (typeof col_data == "object" && col_data) { + if (typeof col_data.nodeName != "undefined") { + jQuery(tag).append(col_data); + } else { + if (col_data.colspan > 1) tag.colSpan = span = col_data.colspan; + if (col_data.className) tag.className = col_data.className; + if (col_data.title) tag.title = col_data.title; + if (col_data.url || col_data.click) { + var a = document.createElement("a"); + a.href = col_data.url || "#"; + if (col_data.click || this.navigateTo) { + jQuery(a).click(col_data.click || this.navigateTo); + } + jQuery(tag).append(a); + tag = a; + } + if (col_data.nodes) { + jQuery(tag).append(col_data.nodes); + } else { + jQuery(tag).text(col_data.label); + } + } + } else { + jQuery(tag).text(typeof col_data != "undefined" ? col_data : ""); + span = 1; + } + } + // add or remove quota line + if ( + this.sort == "result_rank" && + this.quota && + _data.result_rank && + parseInt(_data.result_rank) >= 1 && + parseInt(_data.result_rank) > this.quota + ) { + row.className = "quota_line"; + delete this.quota; // to set quota line only once + } + return row; + }; + + /** + * Sort data according to sort criteria + * + * @todo get using this.sortNummeric callback working + */ + DrTable.prototype.sortData = function () { + function sortResultRank(_a, _b) { + var rank_a = _a["result_rank"]; + if (typeof rank_a == "undefined" || rank_a < 1) rank_a = 9999; + var rank_b = _b["result_rank"]; + if (typeof rank_b == "undefined" || rank_b < 1) rank_b = 9999; + var ret = rank_a - rank_b; + + if (!ret) ret = _a["lastname"] > _b["lastname"] ? 1 : -1; + if (!ret) ret = _a["firstname"] > _b["firstname"] ? 1 : -1; + + return ret; + } + + switch (this.sort) { + case false: // dont sort + break; + + case "result_rank": + // not necessary as server returns them sorted this way + //this.data.sort(sortResultRank); + break; + + default: + var sort = this.sort; + this.data.sort(function (_a, _b) { + var a = sort == "start_order" ? parseInt(_a[sort]) : _a[sort]; + var b = sort == "start_order" ? parseInt(_b[sort]) : _b[sort]; + return a == b ? 0 : a < b ? -1 : 1; + //return _a[sort] == _b[sort] ? 0 : (_a[sort] < _b[sort] ? -1 : 1); + }); + break; + } + if (!this.ascending) this.data.reverse(); + }; + return DrTable; +})(); + +/** + * Startlist widget inheriting from DrBaseWidget + */ +var Startlist = (function () { + /** + * Constructor for startlist from given json url + * + * Table get appended to specified _container + * + * @param _container + * @param _json_url url for data to load + * @param {boolean} _no_navigation do NOT display TOC + */ + function Startlist(_container, _json_url, _no_navigation) { + DrBaseWidget.prototype.constructor.call(this, _container, _json_url); + this.no_navigation = _no_navigation; + // do not continue, as constructor is called when inheriting from Startlist without parameters! + if (typeof _container == "undefined") return; + + // Variables needed for scrolling in upDown + // scroll speed + this.scroll_by = 1; + // scroll interval, miliseconds (will be changed on resized windows where scroll_by is increased, so a constant scrolling speed is maintained) + this.scroll_interval = 20; + // current scrolling direction. 1: down, -1: up + this.scroll_dir = 1; + // sleep on the borders for sleep_for seconds + this.sleep_for = 4; + // margin in which to reverse scrolling + // CAUTION: At the beginning, we scroll pixelwise through the margin, one pixel each sleep_for seconds. Do not change the margin unless you know what you do. + this.margin = 2; + + // helper variable + var now = new Date(); + this.sleep_until = now.getTime() + 10000; + this.first_run = true; + this.do_rotate = false; + + this.update(); + + if (this.json_url.match(/rotate=/)) { + var list = this; + // 20110716: This doesn't seem to be needed anymore. Comment it for now. + //window.scrollBy(0, 20); + this.scroll_interval_handle = window.setInterval(function () { + list.upDown(); + }, 20); + } + } + // inherit from DrBaseWidget + Startlist.prototype = new DrBaseWidget(); + Startlist.prototype.constructor = Startlist; + + /** + * Callback for loading data via ajax + * + * @param _data route data object + */ + Startlist.prototype.handleResponse = function (_data) { + //console.log(_data); + var detail = this.json_url.match(/detail=([^&]+)/); + if (detail) detail = detail[1]; + + switch (_data.discipline) { + case "speedrelay": + this.startlist_cols = + detail === null + ? { + // default detail + start_order: this.lang("StartNr"), + team_name: this.lang("Teamname"), + "athletes/0/lastname": this.lang("Athlete #1"), + "athletes/1/lastname": this.lang("Athlete #2"), + "athletes/2/lastname": this.lang("Athlete #3"), + } + : detail + ? { + // detail=1 + start_order: this.lang("StartNr"), + team_name: this.lang("Teamname"), + //'team_nation': 'Nation', + "athletes/0/lastname": { + label: this.lang("Athlete #1"), + colspan: 3, + }, + "athletes/0/firstname": "", + "athletes/0/result_time": "", + "athletes/1/lastname": { + label: this.lang("Athlete #2"), + colspan: 3, + }, + "athletes/1/firstname": "", + "athletes/1/result_time": "", + "athletes/2/lastname": { + label: this.lang("Athlete #3"), + colspan: 3, + }, + "athletes/2/firstname": "", + "athletes/2/result_time": "", + } + : { + // detail=0 + start_order: this.lang("StartNr"), + team_name: this.lang("Teamname"), + team_nation: this.lang("Nation"), + }; + break; + + case "combined": + this.result_cols.final_points = this.lang("Final Points"); + delete this.result_cols.start_number; // table is far too big anyway + // fall through + default: + this.startlist_cols = { + start_order: { label: this.lang("StartNr"), colspan: 2 }, + start_number: "", + lastname: { label: this.lang("Name"), colspan: 2 }, + firstname: "", + birthyear: this.lang("Birthyear"), + nation: this.lang("Nation"), + }; + break; + } + + // if quali_preselected and heat = 1||2, we have to use a function to get either start_order or text "preselected" + if ( + _data.quali_preselected && + (_data.route_order == 0 || _data.route_order == 1) + ) { + var quali_preselected = _data.quali_preselected; + var start_order = this.startlist_cols.start_order; + this.startlist_cols.start_order = function (_data, _tag, col) { + if (_tag == "th") return start_order; + if (_data.ranking <= quali_preselected) + return this.lang("Vorqualifiziert"); //'preselected'; + return _data[col]; + }; + } + + var sort; + // if we have no result columns or no ranked participant, show a startlist + if ( + typeof this.result_cols == "undefined" || + (_data.participants[0] && + !_data.participants[0].result_rank && + _data.discipline != "ranking") + ) { + this.columns = this.startlist_cols; + sort = "start_order"; + this.container.attr("class", "Startlist"); + } + // if we are a result showing a startlist AND have now a ranked participant + // --> switch back to result + else { + this.columns = this.result_cols; + sort = "result_rank"; + } + + this.replace_nation(_data.display_athlete, _data.nation); + + // fix route_names containing only one or two qualifications are send as array because index 0 and 1 + if (Array.isArray(_data.route_names)) { + var route_names = _data.route_names; + delete _data.route_names; + _data.route_names = {}; + for (var i = 0; i < route_names.length; ++i) { + _data.route_names[i] = route_names[i]; + } + } + + // keep route_names to detect additional routes on updates + if (typeof this.route_names == "undefined") { + this.route_names = _data.route_names; + } + // remove whole table, if the discipline is speed and the number of route_names changes + if (_data.discipline == "speed" && this.json_url.match(/route=-1/)) { + // && this.route_names != _data.route_names) + for (var i = 2; i < 10; i++) { + if (typeof _data.route_names[i] != typeof this.route_names[i]) { + // there was an update of the route_names array + this.route_names = _data.route_names; + jQuery(this.container).empty(); + delete this.table; + break; + } + } + } + // remove whole table, if discipline or startlist/resultlist (detemined by sort) changed + if ( + (this.discipline && this.discipline != _data.discipline) || + (this.sort && this.sort != sort) || + _data.route_order != this.route_order || // switching heats (they can have different columns) + detail !== this.detail || // switching detail on/off + this.json_url != this.last_json_url + ) { + jQuery(this.container).empty(); + delete this.table; + } + this.discipline = _data.discipline; + this.sort = sort; + this.route_order = _data.route_order; + this.detail = detail; + this.last_json_url = this.json_url; + + if (typeof this.table == "undefined") { + // for general result use one column per heat + if (this.columns.result && _data.route_names && _data.route_order == -1) { + delete this.columns.result; + // show final first and 2. quali behind 1. quali: eg. 3, 2, 0, 1 + var routes = []; + if (_data.route_names["1"]) routes.push("1"); + for (var id in _data.route_names) { + if (id != "-1" && id != "1") routes.push(id); + } + routes.reverse(); + for (var i = 0; i < routes.length; ++i) { + var route = routes[i]; + // for ranking, we add link to results + if (_data.discipline == "ranking") { + var id = route.replace(/ $/, ""); // remove space append to force js to keep the order + var comp_cat = id.split("_"); + this.columns["result" + id] = { + label: _data.route_names[route], + url: + "#!comp=" + + comp_cat[0] + + "&cat=" + + (comp_cat[1] || _data.cat.GrpId), + }; + } else { + this.columns["result" + route] = _data.route_names[route]; + } + } + // evtl. add points column + if (_data.participants[0] && _data.participants[0].quali_points) { + this.columns["quali_points"] = this.lang("Points"); + // delete single qualification results + if (this.no_navigation) { + delete this.columns.result0; + delete this.columns.result1; + if (_data.discipline == "combined") delete this.columns.result2; + this.columns["quali_points"] = + _data.discipline == "combined" + ? this.lang("Quali.") + : this.lang("Qualification"); + } + } + if ( + _data.discipline == "combined" && + _data.participants[0] && + typeof _data.participants[0].final_points == "undefined" + ) { + delete this.columns.final_points; + } + title_prefix = ""; + } + if ( + this.columns.result && + _data.participants[0] && + _data.participants[0].rank_prev_heat && + !this.json_url.match(/detail=0/) + ) { + this.columns["rank_prev_heat"] = this.lang("previous heat"); + } + + // competition + this.comp_header = jQuery(document.createElement("h1")); + jQuery(this.container).append(this.comp_header); + this.comp_header.addClass("compHeader"); + // result date + this.result_date = jQuery(document.createElement("h3")); + jQuery(this.container).append(this.result_date); + this.result_date.addClass("resultDate"); + // route header + this.header = jQuery(document.createElement("h1")); + jQuery(this.container).append(this.header); + this.header.addClass("listHeader"); + + // display a toc with all available heats, if not explicitly disabled (toc=0) or beamer + this.displayToc(_data); + + // create new table + if (!_data.error && _data.participants.length) { + this.table = new DrTable( + _data.participants, + this.columns, + this.sort, + true, + _data.route_result ? _data.route_quota : null, + this.navigateTo, + _data.discipline == "ranking" && + (detail || !_data.participants[0].result_rank) + ); + if (_data.participants[0].result_rank) + jQuery(this.table.dom).addClass(_data.discipline); + jQuery(this.container).append(this.table.dom); + } + + this.seeAlso(_data.see_also); + } else { + // update a toc with all available heats, if not explicitly disabled (toc=0) or beamer + this.displayToc(_data); + + // update existing table + this.table.update( + _data.participants, + _data.route_result ? _data.route_quota : null + ); + } + // set/update header line + this.setHeader(_data); + + // if route is NOT offical, update list every 10 sec, of category not offical update every 5min (to get new heats) + if (!_data.category_offical && this.discipline != "ranking") { + var list = this; + this.update_handle = window.setTimeout(function () { + list.update(); + }, _data.expires * 1000); + //console.log('setting up refresh in '+_data.expires+' seconds'); + } + }; + /** + * Create or update TOC (list of available routes for navigation) + * + * Can be disabled via "toc=0" or "beamer=1" in json_url. Always disabled for rankings. + * + * @param _data route data object + */ + Startlist.prototype.displayToc = function (_data) { + if ( + this.json_url.match(/toc=0/) || + this.json_url.match(/beamer=1/) || + this.discipline == "ranking" || + this.no_navigation + ) { + return; // --> no toc + } + var toc = this.container.find("ul.listToc"); + var new_toc = !toc.length; + if (new_toc) toc = jQuery(document.createElement("ul")).addClass("listToc"); + else toc.empty(); + + var href = location.href.replace(/\?(.*)#/, "#"); // prevent query and hash messing up navigation + for (var r in _data.route_names) { + if (r != this.route_order) { + var li = jQuery(document.createElement("li")); + var a = jQuery(document.createElement("a")); + a.text(_data.route_names[r].replace(" - ", "-")); + var reg_exp = /route=[^&]+/; + var url = href.replace(reg_exp, "route=" + r); + if (url.indexOf("route=") == -1) url += "&route=" + r; + a.attr("href", url); + if (this.navigateTo) { + a.click(this.navigateTo); + } else { + var that = this; + a.click(function (e) { + that.json_url = that.json_url.replace( + reg_exp, + this.href.match(reg_exp)[0] + ); + if (that.json_url.indexOf("route=") == -1) + that.json_url += "&route=" + r; + that.update(); + e.preventDefault(); + }); + } + li.append(a); + toc.prepend(li); + } + } + // only add toc, if we have more then one route + if (!new_toc) { + // already added + } else if (toc.children().length) { + jQuery(this.container).append(toc); + } else { + toc.remove(); + } + // add category toc + if (typeof _data.categorys == "undefined") return; + var toc = this.container.find("ul.listCatToc"); + var new_toc = !toc.length; + if (new_toc) + toc = jQuery(document.createElement("ul")).addClass("listCatToc"); + else toc.empty(); + var cats = this.shortenNames(_data.categorys, "name"); + for (var i = 0; i < cats.length; ++i) { + var cat = cats[i]; + if (cat.GrpId != _data.GrpId) { + var li = jQuery(document.createElement("li")); + var a = jQuery(document.createElement("a")); + a.text(cat.name); + var reg_exp = /cat=[^&]+/; + var url = href.replace(reg_exp, "cat=" + cat.GrpId); + if (url.indexOf("cat=") == -1) url += "&cat=" + cat.GrpId; + a.attr("href", url); + if (this.navigateTo) { + a.click(this.navigateTo); + } else { + var that = this; + a.click(function (e) { + that.json_url = that.json_url.replace( + reg_exp, + this.href.match(reg_exp)[0] + ); + if (that.json_url.indexOf("cat=") == -1) + that.json_url += "cat=" + cat.GrpId; + that.update(); + e.preventDefault(); + }); + } + li.append(a); + toc.append(li); + } + } + // only add toc, if we have more then one route + if (!new_toc) { + // already added + } else if (toc.children().length) { + jQuery(this.container).append(toc); + } else { + toc.remove(); + } + }; + /** + * Shorten several names by removing parts common to all and remove spacing (eg. "W O M E N" --> "WOMEN") + * + * shortenNames["M E N speed", "W O M E N speed"]) returns ["MEN", "WOMEN"] + * + * @param {array} names array of strings or objects with attribute attr + * @param {string} attr attribute name to use or undefined + * @return {array} + */ + Startlist.prototype.shortenNames = function (names, attr) { + if (!jQuery.isArray(names) || !names.length) return names; + var split_by_regexp = / +/; + var spacing_regexp = /([A-Z]) ([A-Z])/; + var strs = []; + for (var i = 0; i < names.length; ++i) { + var name = names[i]; + if (attr) name = name[attr]; + do { + var n = name; + name = name.replace(spacing_regexp, "$1$2"); + } while (n != name); + strs.push(name.split(split_by_regexp)); + } + var first = [].concat(strs[0]); + for (var i = 0; i < first.length; ++i) { + for (var j = 1; j < strs.length; ++j) { + if (jQuery.inArray(first[i], strs[j]) == -1) { + break; + } + } + if (j == strs.length) { + // in all strings --> remove first[i] from all strings + for (var j = 0; j < strs.length; ++j) { + strs[j].splice(jQuery.inArray(first[i], strs[j]), 1); + } + } + } + for (var j = 0; j < strs.length; ++j) { + strs[j] = strs[j].join(" "); + if (attr) { + names[j][attr] = strs[j]; + } else { + names[j] = strs[j]; + } + } + return names; + }; + /** + * Set header with a (provisional) Result or Startlist prefix + * + * @param _data + * @return + */ + Startlist.prototype.setHeader = function (_data) { + var title_prefix = + (this.sort == "start_order" + ? this.lang("Startlist") + : _data.route_result + ? this.lang("Result") + : this.lang("provisional Result")) + ": "; + + var header = _data.route_name; + // if NOT detail=0 and not for general result, add prefix before route name + if (!this.json_url.match(/detail=0/) && _data.route_order != -1) + header = title_prefix + header; + + document.title = header; + + this.comp_header.empty(); + this.comp_header.text(_data.comp_name); + this.result_date.empty(); + if (_data.error) { + this.result_date.text(_data.error); + this.result_date.removeClass("resultDate"); + this.result_date.addClass("error"); + } else if (_data.route_result) { + this.result_date.text(_data.route_result); + this.result_date.prepend( + document.createTextNode(this.lang("As of") + " ") + ); + this.result_date.append( + document.createTextNode(" " + this.lang("after")) + ); + } + this.header.empty(); + this.header.text(header); + }; + /** + * Return the current scrolling position, which is the top of the current view. + */ + Startlist.prototype.currentTopPosition = function () { + var y = 0; + if (window.pageYOffset) { + // all other browsers + y = window.pageYOffset; + } else if (document.body && document.body.scrollTop) { + // IE + y = document.body.scrollTop; + } + return y; + }; + + Startlist.prototype.upDown = function () { + // check whether to sleep + var now = new Date(); + var now_ms = now.getTime(); + if (now_ms < this.sleep_until) { + // sleep: in this case we do nothing + return; + } + + if (this.do_rotate) { + // we scheduled a rotation. Do it and then return. + this.rotateURL(); + // wait for the page to build + this.sleep_until = now.getTime() + 1000; + this.first_run = true; + this.do_rotate = false; + // reset scroll_by and scroll_interval, which might have been changed when the windows was resized. + this.scroll_by = 1; + this.scroll_interval = 20; + //console.log("reset scroll_by to " + this.scroll_by); + return; + } + + // Get current position + var y = 0; + var viewHeight = window.innerHeight; + var pageHeight = document.body.offsetHeight; + + y = this.currentTopPosition(); + + // Do the scrolling + window.scrollBy(0, this.scroll_by * this.scroll_dir); + + // Check, if scrolling worked + var new_y = 0; + new_y = this.currentTopPosition(); + if (y == new_y) { + this.scroll_by += 1; + //console.log("increased scroll_by to " + this.scroll_by); + // reconfigure the scroll interval to maintain a constant speed + this.scroll_interval *= this.scroll_by; + this.scroll_interval /= this.scroll_by - 1; + //console.log("scroll_interval is now " + this.scroll_interval + " ms"); + window.clearInterval(this.scroll_interval_handle); + var list = this; + this.scroll_interval_handle = window.setInterval(function () { + list.upDown(); + }, this.scroll_interval); + } + + // Set scrolling and sleeping parameters accordingly + var scrollTopPosition = y; + var scrollBottomPosition = y + viewHeight; + //alert("pageYOffset(y)="+pageYOffset+", innerHeight(wy)="+innerHeight+", offsetHeight(dy)="+document.body.offsetHeight); + var do_sleep = 0; + if (pageHeight <= viewHeight) { + // No scrolling at all + //console.log("Showing whole page"); + do_sleep = 2; + this.do_rotate = true; + } else if ( + this.scroll_dir != -1 && + pageHeight - scrollBottomPosition <= this.margin + ) { + // UP + this.scroll_dir = -1; + this.first_run = false; + do_sleep = 1; + } else if (this.scroll_dir != 1 && scrollTopPosition <= this.margin) { + // DOWN + this.scroll_dir = 1; + if (!this.first_run) { + do_sleep = 1; + this.do_rotate = true; + } + } + + // Arm the sleep timer + //if (do_sleep > 0) { console.log("Sleeping for " + do_sleep * this.sleep_for + " seconds"); } + this.sleep_until = now.getTime() + this.sleep_for * 1000 * do_sleep; + }; + + Startlist.prototype.rotateURL = function () { + var rotate_url_matches = this.json_url.match(/rotate=([^&]+)/); + if (rotate_url_matches) { + var urls = rotate_url_matches[1]; + //console.log(urls); + + var current_comp = this.json_url.match(/comp=([^&]+)/)[1]; + var current_cat = this.json_url.match(/cat=([^&]+)/)[1]; + var current_route = this.json_url.match(/route=([^&]+)/)[1]; + //console.log(current_cat); + + var next = urls.match( + "(?:^|:|w=" + + current_comp + + ",)" + + "c=" + + current_cat + + ",r=" + + current_route + + ":(?:w=([0-9_a-z]+),)?" + + "c=([0-9_a-z]+),r=(-?[\\d]+)" + ); + //console.log(next); + if (!next) { + // at the end of the list, take the first argument + next = urls.match( + "^(?:w=([0-9_a-z]+),)?" + "c=([0-9_a-z]+),r=(-?[\\d]+)" + ); + //console.log("starting over"); + //console.log(next); + } + + // We might not find a next competition in the rotate parameter + var next_comp = current_comp; + if (next[1]) { + next_comp = next[1]; + } + + // Extract category and route + var next_cat = next[2]; + var next_route = next[3]; + //console.log("current_cat = " + current_cat + ", current_route = " + current_route + ", next_cat = " + next_cat + ", next_route = " + next_route); + this.json_url = this.json_url.replace( + /comp=[0-9_a-z]+/, + "comp=" + next_comp + ); + this.json_url = this.json_url.replace( + /cat=[0-9_a-z]+/, + "cat=" + next_cat + ); + this.json_url = this.json_url.replace( + /route=[\d]+/, + "route=" + next_route + ); + //console.log(this.json_url); + + // cancel the currently pending request before starting a new one. + window.clearTimeout(this.update_handle); + this.update(); + } + }; + return Startlist; +})(); + +/** + * Resultlist widget inheriting from Startlist + */ +var Resultlist = (function () { + /** + * Constructor for result from given json url + * + * Table get appended to specified _container + * + * @param _container + * @param _json_url url for data to load + * @param {boolean} _no_navigation + */ + function Resultlist(_container, _json_url, _no_navigation) { + Startlist.prototype.constructor.call( + this, + _container, + _json_url, + _no_navigation + ); + } + // inherit from Startlist + Resultlist.prototype = new Startlist(); + Resultlist.prototype.constructor = Resultlist; + + /** + * Callback for loading data via ajax + * + * Reimplemented to use different columns depending on discipline + * + * @param _data route data object + */ + Resultlist.prototype.handleResponse = function (_data) { + var detail = this.json_url.match(/detail=([^&]+)/); + + switch (_data.discipline) { + case "speedrelay": + this.result_cols = !detail + ? { + // default detail + result_rank: this.lang("Rank"), + team_name: this.lang("Teamname"), + "athletes/0/lastname": this.lang("Athlete #1"), + "athletes/1/lastname": this.lang("Athlete #2"), + "athletes/2/lastname": this.lang("Athlete #3"), + result: this.lang("Sum"), + } + : detail[1] == "1" + ? { + // detail=1 + result_rank: this.lang("Rank"), + team_name: this.lang("Teamname"), + //'team_nation': this.lang('Nation'), + "athletes/0/lastname": { + label: this.lang("Athlete #1"), + colspan: 3, + }, + "athletes/0/firstname": "", + "athletes/0/result_time": "", + "athletes/1/lastname": { + label: this.lang("Athlete #2"), + colspan: 3, + }, + "athletes/1/firstname": "", + "athletes/1/result_time": "", + "athletes/2/lastname": { + label: this.lang("Athlete #3"), + colspan: 3, + }, + "athletes/2/firstname": "", + "athletes/2/result_time": "", + result: this.lang("Sum"), + } + : { + // detail=0 + result_rank: this.lang("Rank"), + team_name: this.lang("Teamname"), + team_nation: this.lang("Nation"), + result: this.lang("Sum"), + }; + break; + + case "ranking": + this.result_cols = { + result_rank: this.lang("Rank"), + lastname: { label: this.lang("Name"), colspan: 2 }, + firstname: "", + nation: this.lang("Nation"), + points: this.lang("Points"), + result: this.lang("Result"), + }; + // default columns for SUI ranking with NO details + if ((!detail || detail[1] == "0") && _data.nation == "SUI") { + this.result_cols = { + result_rank: this.lang("Rank"), + lastname: { label: this.lang("Name"), colspan: 2 }, + firstname: "", + birthyear: this.lang("Agegroup"), + city: this.lang("City"), + federation: "Sektion", + rgz: "Regionalzentrum", + points: this.lang("Points"), + result: this.lang("Result"), + }; + } + if ( + (!detail || detail[1] == "0") && + _data.participants[0] && + _data.participants[0].result_rank + ) { + delete this.result_cols.result; + // allow to click on points to show single results + this.result_cols.points = { + label: this.result_cols.points, + url: location.href + "&detail=1", + }; + // add calculation to see-also links + if (typeof _data.see_also == "undefined") _data.see_also = []; + _data.see_also.push({ + name: this.lang("calculation of this ranking"), + url: location.href + "&detail=1", + }); + } + break; + + default: + // default columns for SUI ranking with NO details + if ((!detail || detail[1] == "0") && _data.nation == "SUI") { + this.result_cols = { + result_rank: this.lang("Rank"), + lastname: { label: this.lang("Name"), colspan: 2 }, + firstname: "", + birthyear: this.lang("Agegroup"), + city: this.lang("City"), + federation: this.lang("Sektion"), + rgz: this.lang("Regionalzentrum"), + result: this.lang("Result"), + }; + } else { + this.result_cols = + detail && detail[1] == "0" + ? { + result_rank: this.lang("Rank"), + lastname: { label: this.lang("Name"), colspan: 2 }, + firstname: "", + nation: this.lang("Nation"), + result: this.lang("Result"), + } + : { + result_rank: this.lang("Rank"), + lastname: { label: this.lang("Name"), colspan: 2 }, + firstname: "", + nation: this.lang("Nation"), + start_number: this.lang("StartNr"), + result: this.lang("Result"), + }; + } + // for boulder heats use new display, but not for general result! + if ( + _data.discipline.substr(0, 7) == "boulder" && + _data.route_order != -1 + ) { + delete this.result_cols.result; + var that = this; + var num_problems = parseInt(_data.route_num_problems); + this.result_cols.boulder = function (_data, _tag) { + return that.getBoulderResult.call(that, _data, _tag, num_problems); + }; + //Resultlist.prototype.getBoulderResult; + if (!detail || detail[1] != 0) + this.result_cols.result = this.lang("Sum"); + } + break; + } + // remove start-number column if no start-numbers used (determined on first participant only) + if ( + typeof this.result_cols.start_number != "undefined" && + !_data.participants[0].start_number + ) { + delete this.result_cols.start_number; + } + Startlist.prototype.handleResponse.call(this, _data); + align_td_nbsp("table.DrTable td"); + + if ( + _data.discipline == "ranking" && + !_data.error && + ((detail && detail[1] == "1") || !_data.participants[0].result_rank) && + (_data.max_comp || _data.max_disciplines) + ) { + var tfoot = jQuery(document.createElement("tfoot")); + jQuery(this.table.dom).append(tfoot); + var th = jQuery(document.createElement("th")); + tfoot.append(jQuery(document.createElement("tr")).append(th)); + var cols = 0; + for (var c in this.result_cols) cols++; + th.attr("colspan", cols); + th.attr("class", "footer"); + var max_disciplines = ""; + if (_data.max_disciplines) { + for (var discipline in _data.max_disciplines) { + max_disciplines += + (max_disciplines ? ", " : "") + + discipline[0].toUpperCase() + + discipline.slice(1) + + ": " + + _data.max_disciplines[discipline]; + } + } + if (_data.nation) { + th.html( + (_data.max_comp + ? "Für " + + (_data.cup ? "den " + _data.cup.name : "die Rangliste") + + " zählen die " + + _data.max_comp + + " besten Ergebnisse. " + : "") + + (max_disciplines + ? " Maximal zählende Ergebnisse pro Disziplin: " + + max_disciplines + + ". " + : "") + + "Nicht zählende Ergebnisse sind eingeklammert. " + + (_data.min_disciplines + ? "
Teilnahme an mindestens " + + _data.min_disciplines + + " Disziplinen ist erforderlich. " + : "") + + (_data.drop_equally + ? "Streichresultate erfolgen in allen Disziplinen gleichmäßig. " + : "") + ); + } else { + th.html( + (_data.max_comp + ? _data.max_comp + + " best competition results are counting for " + + (_data.cup ? _data.cup.name : "the ranking") + + ". " + : "") + + (max_disciplines + ? "Maximum number of counting results per discipline: " + + max_disciplines + + ". " + : "") + + "Not counting points are in brackets. " + + (_data.min_disciplines + ? "
Participation in at least " + + _data.min_disciplines + + " disciplines is required." + : "") + + (_data.drop_equally + ? "Not counting results are selected from all disciplines equally." + : "") + ); + } + } + if ( + _data.statistics && + (_data.discipline == "selfscore" || this.json_url.match("&stats=")) + ) { + if (!jQuery("#jqplot-css").length) { + var ranking_url = this.json_url.replace(/json.php.*$/, ""); + var jqplot_url = + this.json_url.replace(/ranking\/json.php.*$/, "") + + "vendor/npm-asset/as-jqplot/dist/"; + jQuery("", { + id: "jqplot-css", + href: jqplot_url + "jquery.jqplot.min.css", + type: "text/css", + }).appendTo("head"); + var load = [ + jqplot_url + "jquery.jqplot.min.js", + // not sure why bar-renderer does not work :( + //jqplot_url+'plugins/jqplot.barRenderer.min.js', + jqplot_url + "plugins/jqplot.highlighter.min.js", + ranking_url + "js/dr_statistics.js?" + _data.dr_statistics, + ]; + for (var i = 0; i < load.length; ++i) { + load[i] = jQuery.ajax({ + url: load[i], + dataType: "script", + cache: true, // no cache buster! + }); + } + var container = this.container; + jQuery.when.apply(jQuery, load).done(function () { + dr_statistics(container, _data); + }); + // dono why, but above done is not always executed, if files are already cached + window.setTimeout(function () { + typeof window.dr_statistics != "undefined" && + dr_statistics(container, _data); + }, 100); + } else { + dr_statistics(this.container, _data); + } + } + }; + + /** + * Get DOM nodes for display of graphical boulder-result + * + * @param _data + * @param _tag 'th' for header, 'td' for data rows + * @param _num_problems + * @return DOM node + */ + Resultlist.prototype.getBoulderResult = function ( + _data, + _tag, + _num_problems + ) { + if (_tag == "th") return "Result"; + + var tag = document.createElement("div"); + + for (var i = 1; i <= _num_problems; ++i) { + var boulder = document.createElement("div"); + var result = _data["boulder" + i]; + if (result && result != "z0" && result != "b0") { + var top_tries = result.match(/t([0-9]+)/); + var bonus_tries = result.match(/(b|z)([0-9]+)/); + if (top_tries) { + boulder.className = "boulderTop"; + var top_text = document.createElement("div"); + top_text.className = "topTries"; + jQuery(top_text).text(top_tries[1]); + jQuery(boulder).append(top_text); + } else { + boulder.className = "boulderBonus"; + } + var bonus_text = document.createElement("div"); + bonus_text.className = "bonusTries"; + jQuery(bonus_text).text(bonus_tries[2]); + jQuery(boulder).append(bonus_text); + } else { + boulder.className = result ? "boulderNone" : "boulder"; + } + jQuery(tag).append(boulder); + } + return tag; + }; + return Resultlist; +})(); + +/** + * Results widget inheriting from DrBaseWidget + */ +var Results = (function () { + /** + * Constructor for results from given json url + * + * Table get appended to specified _container + * + * @param _container + * @param _json_url url for data to load + * @param {boolean} _no_navigation do not show competition chooser + */ + function Results(_container, _json_url, _no_navigation) { + DrBaseWidget.prototype.constructor.call(this, _container, _json_url); + this.no_navigation = _no_navigation; + + this.update(); + } + // inherite from DrBaseWidget + Results.prototype = new DrBaseWidget(); + Results.prototype.constructor = Results; + /** + * Callback for loading data via ajax + * + * @param _data route data object + */ + Results.prototype.handleResponse = function (_data) { + this.columns = { + result_rank: this.lang("Rank"), + lastname: { label: this.lang("Name"), colspan: 2 }, + firstname: "", + nation: this.lang("Nation"), + }; + this.replace_nation(_data.display_athlete, _data.nation); + + if (typeof this.table == "undefined") { + // competition chooser + if (!this.no_navigation) { + this.comp_chooser = jQuery(document.createElement("select")); + this.comp_chooser.addClass("compChooser"); + this.container.append(this.comp_chooser); + var that = this; + this.comp_chooser.change(function (e) { + that.json_url = that.json_url.replace( + /comp=[^&]+/, + "comp=" + this.value + ); + if (that.navigateTo) that.navigateTo(that.json_url); + else that.update(); + }); + } + // competition + this.comp_header = jQuery(document.createElement("h1")); + this.comp_header.addClass("compHeader"); + this.container.append(this.comp_header); + // result date + this.comp_date = jQuery(document.createElement("h3")); + this.comp_date.addClass("resultDate"); + this.container.append(this.comp_date); + } else { + jQuery(this.table.dom).remove(); + if (!this.no_navigation) this.comp_chooser.empty(); + this.comp_header.empty(); + this.comp_date.empty(); + } + // fill competition chooser + if (!this.no_navigation) { + var option = jQuery(document.createElement("option")); + option.text(this.lang("Select another competition ...")); + this.comp_chooser.append(option); + for (var i = 0; i < _data.competitions.length; ++i) { + var competition = _data.competitions[i]; + if (_data.WetId == competition.WetId) continue; // we dont show current competition + option = jQuery(document.createElement("option")); + option.attr({ value: competition.WetId, title: competition.date_span }); + option.text(competition.name); + this.comp_chooser.append(option); + } + } + this.comp_header.text(_data.name); + this.comp_date.text(_data.date_span); + + for (var i = 0; i < _data.categorys.length; ++i) { + var cat = _data.categorys[i]; + var that = this; + cat.click = function (e) { + that.showCompleteResult(e); + }; + } + + // create new table + this.table = new DrTable( + _data.categorys, + this.columns, + "result_rank", + true, + null, + this.navigateTo + ); + + this.container.append(this.table.dom); + + this.seeAlso(_data.see_also); + }; + /** + * Switch from Results (of all categories) to Resultlist (of a single category) + * + * @param e + */ + Results.prototype.showCompleteResult = function (e) { + this.container.empty(); + this.container.removeClass("Results"); + new Resultlist( + this.container, + this.json_url.replace(/\?.*$/, e.target.href.match(/\?.*$/)[0]) + ); + e.preventDefault(); + }; + return Results; +})(); + +/** + * Starters / registration widget inheriting from DrBaseWidget + */ +var Starters = (function () { + /** + * Constructor for results from given json url + * + * Table get appended to specified _container + * + * @param _container + * @param _json_url url for data to load + */ + function Starters(_container, _json_url) { + DrBaseWidget.prototype.constructor.call(this, _container, _json_url); + + this.update(); + } + // inherite from DrBaseWidget + Starters.prototype = new DrBaseWidget(); + Starters.prototype.constructor = Starters; + /** + * Callback for loading data via ajax + * + * @param _data route data object + */ + Starters.prototype.handleResponse = function (_data) { + this.data = _data; + if (typeof this.table == "undefined") { + // competition + this.comp_header = jQuery(document.createElement("h1")); + this.comp_header.addClass("compHeader"); + this.container.append(this.comp_header); + // result date + this.comp_date = jQuery(document.createElement("h3")); + this.comp_date.addClass("resultDate"); + this.container.append(this.comp_date); + } else { + delete this.table; + this.comp_header.empty(); + this.comp_date.empty(); + } + this.comp_header.text(_data.name + " : " + _data.date_span); + if (_data.deadline) + this.comp_date.text(this.lang("Deadline") + ": " + _data.deadline); + + this.table = jQuery(document.createElement("table")).addClass("DrTable"); + this.container.append(this.table); + var thead = jQuery(document.createElement("thead")); + this.table.append(thead); + + // create header row + var row = jQuery(document.createElement("tr")); + var th = jQuery(document.createElement("th")); + th.text( + typeof _data.federations != "undefined" + ? this.lang("Federation") + : this.lang("Nation") + ); + if (!this.json_url.match(/no_fed=1/)) row.append(th); + var cats = {}; + for (var i = 0; i < _data.categorys.length; ++i) { + var th = jQuery(document.createElement("th")); + th.addClass("category"); + th.text(_data.categorys[i].name); + row.append(th); + cats[_data.categorys[i].GrpId] = i; + } + thead.append(row); + + var tbody = jQuery(document.createElement("tbody")); + this.table.append(tbody); + + var fed; + this.fed_rows = []; + this.fed_rows_pos = []; + var num_competitors = 0; + for (var i = 0; i < _data.athletes.length; ++i) { + var athlete = _data.athletes[i]; + // evtl. create new row for federation/nation + if ( + (typeof fed == "undefined" || fed != athlete.reg_fed_id) && + !this.json_url.match(/no_fed=1/) + ) { + this.fillUpFedRows(); + // reset fed rows to empty + this.fed_rows = []; + this.fed_rows_pos = []; + } + // find rows with space in column of category + var cat_col = cats[athlete.cat]; + for (var r = 0; r < this.fed_rows.length; ++r) { + if (this.fed_rows_pos[r] <= cat_col) break; + } + if (r == this.fed_rows.length) { + // create a new fed-row + row = jQuery(document.createElement("tr")); + tbody.append(row); + th = jQuery(document.createElement("th")); + if (!this.json_url.match(/no_fed=1/)) row.append(th); + this.fed_rows.push(row); + this.fed_rows_pos.push(0); + if (typeof fed == "undefined" || fed != athlete.reg_fed_id) { + fed = athlete.reg_fed_id; + th.text(this.federation(athlete.reg_fed_id)); + th.addClass("federation"); + } + } + this.fillUpFedRow(r, cat_col); + // create athlete cell + var td = jQuery(document.createElement("td")); + td.addClass("athlete"); + var lastname = jQuery(document.createElement("span")) + .addClass("lastname") + .text(athlete.lastname); + var firstname = jQuery(document.createElement("span")) + .addClass("firstname") + .text(athlete.firstname); + td.append(lastname).append(firstname); + this.fed_rows[r].append(td); + this.fed_rows_pos[r]++; + // do not count + if (athlete.cat != 120) num_competitors++; + } + this.fillUpFedRows(); + + var tfoot = jQuery(document.createElement("tfoot")); + this.table.append(tfoot); + var th = jQuery(document.createElement("th")); + tfoot.append(jQuery(document.createElement("tr")).append(th)); + th.attr("colspan", 1 + _data.categorys.length); + th.text( + this.lang( + "Total of %1 athletes registered in all categories.", + num_competitors + ) + ); + }; + /** + * Fill a single fed-row up to a given position with empty td's + * + * @param {number} _r row-number + * @param {number} _to column-number, default whole row + */ + Starters.prototype.fillUpFedRow = function (_r, _to) { + if (typeof _to == "undefined") _to = this.data.categorys.length; + while (this.fed_rows_pos[_r] < _to) { + var td = jQuery(document.createElement("td")); + this.fed_rows[_r].append(td); + this.fed_rows_pos[_r]++; + } + }; + /** + * Fill up all fed rows with empty td's + */ + Starters.prototype.fillUpFedRows = function () { + for (var r = 0; r < this.fed_rows.length; ++r) { + this.fillUpFedRow(r); + } + }; + /** + * Get name of federation specified by given id + * + * @param _fed_id + * @returns string with name + */ + Starters.prototype.federation = function (_fed_id) { + if (typeof this.data.federations == "undefined") { + return _fed_id; // nation of int. competition + } + for (var i = 0; i < this.data.federations.length; ++i) { + var fed = this.data.federations[i]; + if (fed.fed_id == _fed_id) return fed.shortcut || fed.name; + } + }; + return Starters; +})(); + +/** + * Profile widget inheriting from DrBaseWidget + */ +var Profile = (function () { + /** + * Constructor for profile from given json url + * + * Table get appended to specified _container + * + * @param _container + * @param _json_url url for data to load + * @param _template optional string with html-template + * @param _remove_leading_slash fix Joomla behavior of adding a slash to " + + cat.name + + "\n"; + } + select += "\n"; + return select; + } + var parts = placeholder.split("/"); + var data = _data; + for (var i = 0; i < parts.length; ++i) { + if (typeof data[parts[i]] == "undefined" || !data[parts[i]]) { + return parts[i] === "N" ? match : ""; + } + data = data[parts[i]]; + } + switch (placeholder) { + case "practice": + data += + " " + + that.lang("years, since") + + " " + + (new Date().getFullYear() - data); + break; + case "height": + data += " cm"; + break; + case "weight": + data += " kg"; + break; + } + return data; + } + ); + // replace result data + var bestResults = this.bestResults; + var that = this; + html = html.replace(/[\s]*\n?/g, function (match) { + if (match.indexOf("$$results/N/") == -1) return match; + + // find and mark N best results + var year = new Date().getFullYear(); + var limits = []; + for (var i = 0; i < _data.results.length; ++i) { + var result = _data.results[i]; + result.weight = + result.rank / 2 + (year - parseInt(result.date)) + 4 * !result.nation; + // maintain array of N best competitions (least weight) + if ( + limits.length < bestResults || + result.weight < limits[limits.length - 1] + ) { + var limit = 0; + for (var l = 0; l < limits.length; ++l) { + limit = limits[l]; + if (limit > result.weight) break; + } + if (limit < result.weight && l == limits.length - 1) + l = limits.length; + limits = limits + .slice(0, l) + .concat([result.weight]) + .concat(limits.slice(l, bestResults - 1 - l)); + } + } + var weight_limit = limits.pop(); + + var rows = ""; + var l = 0; + for (var i = 0; i < _data.results.length; ++i) { + var result = _data.results[i]; + if ( + match.indexOf("$$results/N/weightClass$$") >= 0 && + (result.weight > weight_limit || ++l > bestResults) + ) { + result.weightClass = "profileResultHidden"; + } + rows += match.replace( + that.pattern_results, + function (match, placeholder) { + switch (placeholder) { + case "cat_name+name": + return ( + (result.GrpId != _data.GrpId ? result.cat_name + ": " : "") + + result.name + ); + case "date": + return that.formatDate(result.date); + default: + return typeof result[placeholder] != "undefined" + ? result[placeholder] + : ""; + } + } + ); + } + return rows; + }); + this.container.html(html); + // remove links with empty href + this.container.find('a[href=""]').replaceWith(function () { + return jQuery(this).contents(); + }); + // remove images with empty src + this.container.find('img[src=""]').remove(); + // hide rows with profileHideRowIfEmpty, if ALL td.profileHideRowIfEmpty are empty + this.container.find("tr.profileHideRowIfEmpty").each(function (index, row) { + var tds = jQuery(row).children("td.profileHideRowIfEmpty"); + if (tds.length == tds.filter(":empty").length) { + jQuery(row).hide(); + } + }); + // install click handler from DrWidget + if (this.navigateTo) + this.container + .find('.profileData a:not(a[href^="javascript:"])') + .click(this.navigateTo); + // bind chooseCategory handler (works with multiple templates) + var that = this; + this.container.find("select.chooseCategory").change(function (e) { + that.chooseCategory.call(that, this.value); + e.stopImmediatePropagation(); + return false; + }); + }; + /** + * toggle between best results and all results + */ + Profile.prototype.toggleResults = function () { + var hidden_rows = this.container.find("tr.profileResultHidden"); + var display = hidden_rows.length + ? jQuery(hidden_rows[0]).css("display") + : "none"; + hidden_rows.css("display", display == "none" ? "table-row" : "none"); + }; + /** + * choose a given category for rankings + * + * @param {string} GrpId + */ + Profile.prototype.chooseCategory = function (GrpId) { + var cat_regexp = /([#&])cat=([^&]+)/; + function replace_cat(str, GrpId) { + if (str.match(cat_regexp)) { + return str.replace(cat_regexp, "$1cat=" + GrpId); + } + return str + "&cat=" + GrpId; + } + location.hash = replace_cat(location.hash, GrpId); + this.json_url = replace_cat(this.json_url, GrpId); + this.update(); + }; + /** + * Default template for Profile widget + */ + Profile.prototype.template = + "
\n" + + '\n' + + " \n" + + " \n" + + ' \n' + + " \n" + + ' \n' + + " \n" + + " \n" + + "
\n" + + '

\n' + + ' $$firstname$$\n' + + ' $$lastname$$\n' + + "

\n" + + '

$$nation$$

\n' + + '

$$federation$$

\n' + + "
\n" + + '\n' + + " \n" + + " \n" + + " \n" + + ' \n' + + " \n" + + ' \n' + + " \n" + + ' \n' + + ' \n' + + " \n" + + ' \n' + + " \n" + + ' \n' + + " \n" + + ' \n' + + " \n" + + ' \n' + + " \n" + + ' \n' + + " \n" + + ' \n' + + ' \n' + + " \n" + + ' \n' + + ' \n' + + ' \n' + + " \n" + + ' \n' + + ' \n' + + ' \n' + + " \n" + + ' \n' + + ' \n' + + ' \n' + + " \n" + + ' \n' + + ' \n' + + " \n" + + ' \n' + + ' \n' + + " \n" + + " \n" + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + " \n" + + " \n" + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + " \n" + + ' \n' + + ' \n' + + " \n" + + " \n" + + " \n" + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + " \n" + + " \n" + + "
age:$$age$$year of birth:$$birthdate$$
place of birth:$$birthplace$$
height:$$height$$weight:$$weight$$
address:$$postcode$$ $$city$$$$street$$
practicing climbing for:$$practice$$
professional climber (if not, profession):$$professional$$
other sports practiced:$$other_sports$$
$$freetext$$
Category: $$categoryChooser$$
$$rankings/0/name$$:$$rankings/0/rank$$$$rankings/1/name$$:$$rankings/1/rank$$
$$rankings/2/name$$:$$rankings/2/rank$$$$rankings/3/name$$:$$rankings/3/rank$$
best results / all results:
$$results/N/rank$$$$results/N/cat_name+name$$$$results/N/date$$
\n" + + "
\n"; + return Profile; +})(); + +/** + * ResultTemplate widget inheriting from DrBaseWidget + */ +var ResultTemplate = (function () { + /** + * Constructor for ResultTemplate from given json url + * + * Table get appended to specified _container + * + * @param _container + * @param _json_url url for data to load + * @param _template optional string with html-template + */ + function ResultTemplate(_container, _json_url, _template) { + DrBaseWidget.prototype.constructor.call(this, _container, _json_url); + + if (_template) this.template = _template; + else this.template = this.container.html(); + this.container.empty(); + + this.update(); + } + // inherite from DrBaseWidget + ResultTemplate.prototype = new DrBaseWidget(); + ResultTemplate.prototype.constructor = ResultTemplate; + /** + * Callback for loading data via ajax + * + * @param _data route data object + */ + ResultTemplate.prototype.handleResponse = function (_data) { + // if route is NOT offical, update list every 10 sec + if (!_data.route_result && typeof this.update_handle == "undefined") { + var list = this; + this.update_handle = window.setInterval(function () { + list.update(); + }, 10000); + } + // if route is offical stop reload + else if (_data.route_result && this.update_handle) { + window.clearInterval(this.update_handle); + delete this.update_handle; + } + + // replace non-result data + var pattern = /\$\$([^$]+)\$\$/g; + var html = this.template.replace(pattern, function (match, placeholder) { + var parts = placeholder.split("/"); + var data = _data; + for (var i = 0; i < parts.length; ++i) { + if (typeof data[parts[i]] == "undefined" || !data[parts[i]]) { + return parts[i] === "N" ? match : ""; + } + data = data[parts[i]]; + } + switch (placeholder) { + } + return data; + }); + // replace result data + pattern = /\$\$participants\/N\/([^$]+)\$\$/g; + html = html.replace(/[\s]*\n?/g, function (match) { + if (match.indexOf("$$participants/N/") == -1) return match; + + var rows = ""; + for (var i = 0; i < _data.participants.length; ++i) { + var result = _data.participants[i]; + rows += match.replace(pattern, function (match, placeholder) { + switch (placeholder) { + default: + return typeof result[placeholder] != "undefined" + ? result[placeholder] + : ""; + } + }); + } + return rows; + }); + + // replace container + this.container.html(html); + }; + return ResultTemplate; +})(); + +/** + * Competitions / calendar widget inheriting from DrBaseWidget + */ +var Competitions = (function () { + /** + * Constructor for ompetitions / calendar from given json url + * + * Table get appended to specified _container + * + * @param _container + * @param _json_url url for data to load + * @param _filters object with filters and optional _comp_url + * {string} _filters._comp_url url to use as link with added WetId for competition name + */ + function Competitions(_container, _json_url, _filters) { + DrBaseWidget.prototype.constructor.call(this, _container, _json_url); + if (typeof _filters != "undefined") { + this.filters = _filters; + if (typeof _filters._comp_url != "undefined") { + this.comp_url = _filters._comp_url; + delete this.filters._comp_url; + } + if (typeof _filters._comp_url_label != "undefined") { + this.comp_url_label = _filters._comp_url_label; + delete this.filters._comp_url_label; + } + } + this.year_regexp = /([&?])year=(\d+)/; + + this.update(); + } + // inherite from DrBaseWidget + Competitions.prototype = new DrBaseWidget(); + Competitions.prototype.constructor = Competitions; + /** + * Callback for loading data via ajax + * + * @param _data route data object + */ + Competitions.prototype.handleResponse = function (_data) { + this.container.empty(); + + var year = this.json_url.match(this.year_regexp); + year = year ? parseInt(year[2]) : new Date().getFullYear(); + var h1 = jQuery(document.createElement("h1")).text( + this.lang("Calendar") + " " + year + ); + this.container.append(h1); + + var filter = jQuery(document.createElement("div")).addClass("filter"); + var select = jQuery(document.createElement("select")).attr("name", "year"); + var years = _data.years || [year + 1, year, year - 1]; + for (var i = 0; i < years.length; ++i) { + var y = years[i]; + var option = jQuery(document.createElement("option")).attr("value", y); + option.text(y); + if (year == y) option.attr("selected", "selected"); + select.append(option); + } + var that = this; + select.change(function (e) { + that.changeYear(this.value); + }); + select.attr("style", "margin-right: 5px"); + filter.append(select); + + if ( + typeof this.filters != "undefied" && + !jQuery.isEmptyObject(this.filters) + ) { + select = jQuery(document.createElement("select")).attr("name", "filter"); + for (var f in this.filters) { + var option = jQuery(document.createElement("option")).attr( + "value", + this.filters[f] + ); + option.text(f); + if (decodeURI(this.json_url).indexOf(this.filters[f]) != -1) + option.attr("selected", "selected"); + select.append(option); + } + select.change(function (e) { + that.changeFilter(this.value); + }); + filter.append(select); + } + this.container.append(filter); + var competitions = jQuery(document.createElement("div")).addClass( + "competitions" + ); + this.container.append(competitions); + var now = new Date(); + // until incl. Wednesday (=3) we display competitions from last week first, after that from this week + var week_to_display = now.getWeek() - (now.getDay() <= 3 ? 1 : 0); + var closest, closest_dist; + + for (var i = 0; i < _data.competitions.length; ++i) { + var competition = _data.competitions[i]; + + var comp_div = jQuery(document.createElement("div")).addClass( + "competition" + ); + var title = jQuery(document.createElement("div")) + .addClass("title") + .text(competition.name); + if (this.comp_url) { + title = jQuery(document.createElement("a")) + .attr({ href: this.comp_url + competition.WetId }) + .append(title); + } + comp_div.append(title); + comp_div.append( + jQuery(document.createElement("div")) + .addClass("date") + .text(competition.date_span) + ); + var cats_ul = jQuery(document.createElement("ul")).addClass("cats"); + var have_cats = false; + var links = { + homepage: this.lang("Event Website"), + info: this.lang("Regulation"), + info2: this.lang("Info Sheet"), + startlist: this.lang("Startlist"), + result: this.lang("Result"), + }; + // add comp_url as first link with given label + if (this.comp_url && this.comp_url_label) { + links = jQuery.extend({ comp_url: this.comp_url_label }, links); + competition.comp_url = this.comp_url + competition.WetId; + } + if (typeof competition.cats == "undefined") competition.cats = []; + for (var c = 0; c < competition.cats.length; ++c) { + var cat = competition.cats[c]; + var url = ""; + if (typeof cat.status != "undefined") { + switch (cat.status) { + case 4: // registration + links.starters = this.lang("Starters"); + competition.starters = + "#!type=starters&comp=" + competition.WetId; + break; + case 2: // startlist in result-service + case 1: // result in result-service + case 0: // result in ranking (ToDo: need extra export, as it might not be in result-service) + url = "#!comp=" + competition.WetId + "&cat=" + cat.GrpId; + break; + } + } + var cat_li = jQuery(document.createElement("li")); + if (url != "") { + var a = jQuery(document.createElement("a")).attr("href", url); + a.text(cat.name); + if (this.navigateTo) a.click(this.navigateTo); + cat_li.append(a); + } else { + cat_li.text(cat.name); + } + cats_ul.append(cat_li); + have_cats = true; + } + var links_ul = jQuery(document.createElement("ul")).addClass("links"); + var have_links = false; + for (var l in links) { + if (typeof competition[l] == "undefined" || competition[l] === null) + continue; + var a = jQuery(document.createElement("a")); + a.attr("href", competition[l]); + if (l == "comp_url" && this.comp_url[0] == "/"); + else if (l != "starters") a.attr("target", "_blank"); + else if (this.navigateTo) a.click(this.navigateTo); + a.text(links[l]); + links_ul.append( + jQuery(document.createElement("li")) + .addClass(l + "Link") + .append(a) + ); + have_links = true; + } + if (have_links) comp_div.append(links_ul); + if (have_cats) comp_div.append(cats_ul); + competitions.append(comp_div); + + var dist = Math.abs( + new Date(competition.date).getWeek() - week_to_display + ); + if (typeof closest_dist == "undefined" || dist < closest_dist) { + closest_dist = dist; + closest = comp_div[0]; + } + } + if (closest && year == new Date().getFullYear()) { + // need to delay scrolling a bit, layout seems to need some time + window.setTimeout(function () { + closest.parentElement.scrollTop = + closest.offsetTop + closest.parentElement.offsetTop; + }, 100); + } + }; + Competitions.prototype.changeYear = function (year) { + if (this.json_url.match(this.year_regexp)) { + this.json_url = this.json_url.replace(this.year_regexp, "$1year=" + year); + } else { + if (this.json_url.substr(-1) != "?") + this.json_url += this.json_url.indexOf("?") == -1 ? "?" : "&"; + this.json_url += "year=" + year; + } + if (this.navigateTo) { + this.navigateTo(this.json_url); + } else { + this.update(); + } + }; + Competitions.prototype.changeFilter = function (filter) { + if (this.json_url.indexOf("?") == -1) { + this.json_url += "?" + filter; + } else { + var year = this.json_url.match(this.year_regexp); + this.json_url = this.json_url.replace( + /\?.*$/, + "?" + (year && year[2] ? "year=" + year[2] + "&" : "") + filter + ); + } + if (this.navigateTo) { + this.navigateTo(this.json_url); + } else { + this.update(); + } + }; + return Competitions; +})(); + +/** + * Aggregated rankings widget inheriting from DrBaseWidget + */ +var Aggregated = (function () { + /** + * Constructor for aggregated rankings (nat. team ranking, sektionenwertung, ...) from given json url + * + * Table get appended to specified _container + * + * @param _container + * @param _json_url url for data to load + */ + function Aggregated(_container, _json_url) { + DrBaseWidget.prototype.constructor.call(this, _container, _json_url); + + this.update(); + } + // inherite from DrBaseWidget + Aggregated.prototype = new DrBaseWidget(); + Aggregated.prototype.constructor = Aggregated; + /** + * Callback for loading data via ajax + * + * @param _data route data object + */ + Aggregated.prototype.handleResponse = function (_data) { + var that = this; + + // if we are not controlled by DrWidget, install our own navigation + if (!this.navigateTo) { + this.navigateTo = function (e) { + document.location.hash = this.href.replace(/^.*#!/, ""); + e.preventDefault(); + }; + this.update = function () { + that.json_url = + that.json_url.replace(/&(cup|comp|cat)=[^&]+/, "") + + "&" + + document.location.hash.substr(1); + DrBaseWidget.prototype.update.call(that); + }; + this.installPopState(); + } + this.columns = { + rank: this.lang("Rank"), + nation: { label: _data.aggregated_name, colspan: 2 }, + name: _data.aggregated_name, + points: { label: this.lang("Points") }, + }; + if (location.hash.indexOf("detail=1") == -1) { + this.columns.points.click = function (e) { + var hidden_cols = that.container.find(".result,.calculationHidden"); + var display = hidden_cols.length + ? jQuery(hidden_cols[0]).css("display") + : "none"; + hidden_cols.css("display", display == "none" ? "table-cell" : "none"); + location.hash += "&detail=1"; + e.preventDefault(); + }; + // add calculation to see-also links + if (typeof _data.see_also == "undefined") _data.see_also = []; + _data.see_also.push({ + name: "calculation of this ranking", + url: location.href + "&detail=1", + }); + } + if (_data.aggregate_by != "nation") delete this.columns.nation; + + if (typeof this.table == "undefined") { + this.ranking_name = jQuery(document.createElement("h1")).addClass( + "rankingName" + ); + this.container.append(this.ranking_name); + + // cup or competition + this.header = jQuery(document.createElement("h2")).addClass( + "rankingHeader" + ); + this.container.append(this.header); + + // category names + this.header2 = jQuery(document.createElement("h3")).addClass( + "rankingHeader2" + ); + this.container.append(this.header2); + } else { + jQuery(this.table.dom).remove(); + this.header.empty(); + this.header2.empty(); + } + this.ranking_name.text(_data.name); + this.header.text(_data.cup_name || _data.comp_name); + // if we filter by cat display categories as 2. header + if (_data.cat_filter) { + if (_data.cat_name) { + // category name given, use it but upcase and space it + this.header2.text(_data.cat_name.toUpperCase().split("").join(" ")); + } else { + var names = ""; + for (var i in _data.categorys) { + names += (names ? ", " : "") + _data.categorys[i].name; + } + this.header2.text(names); + } + } + + // make _data available to other methods + this.data = _data; + + var comps = []; + for (var c in _data.competitions) comps.push(_data.competitions[c]); + // use competition columns for more then one comp. and international or SUI + if (comps.length > 1 && (!_data.nation || _data.nation == "SUI")) { + comps.sort(function (a, b) { + return a.date < b.date ? 1 : -1; + }); + for (var c = 0; c < comps.length; ++c) { + this.columns["result" + comps[c].WetId] = function ( + _data, + _tag, + _name + ) { + return that.comp_column.call(that, _data, _tag, _name); + }; + } + } // otherwise use category header + else { + var cats = []; + for (var c in _data.categorys) cats.push(_data.categorys[c]); + cats.sort(function (a, b) { + return a.name < b.name ? -1 : 1; + }); + for (var c = 0; c < cats.length; ++c) { + this.columns["result" + cats[c].GrpId] = function (_data, _tag, _name) { + return that.cat_column.call(that, _data, _tag, _name); + }; + } + } + if (!_data.use_cup_points) { + // display all ranking points with 2 digits + for (var f = 0; f < _data.federations.length; ++f) { + _data.federations[f].points = _data.federations[f].points.toFixed(2); + } + } + // create new table + this.table = new DrTable( + _data.federations, + this.columns, + false, + true, + null, + this.navigateTo + ); + + // add table footer with note about how many results are counting + var tfoot = jQuery(document.createElement("tfoot")); + jQuery(this.table.dom).append(tfoot); + var th = jQuery(document.createElement("th")).addClass("result"); + if (this.json_url.indexOf("detail=1") == -1) + th.addClass("calculationHidden"); + tfoot.append(jQuery(document.createElement("tr")).append(th)); + var cols = 0; + for (var c in this.columns) cols++; + th.attr("colspan", cols); + th.text( + this.lang( + "For %1 %2 best results per competition and category are counting.", + _data.name, + _data.best_results + ) + + " " + + this.lang("Not counting results are in brackets.") + ); + + this.container.append(this.table.dom); + + this.seeAlso(_data.see_also); + }; + /** + * Display a competition column + * + * @param _data + * @param _tag tag 'th' for header or 'td' for data row + * @param _name column-name + */ + Aggregated.prototype.comp_column = function (_data, _tag, _name) { + var id = _name.substr(6); + var ret = { className: "result" }; + if (this.json_url.indexOf("detail=1") == -1) + ret.className += " calculationHidden"; + if (_tag == "th") { + // use comp. shortcut plus date as column header + ret.label = + (this.data.competitions[id].short || + this.data.competitions[id].name.replace(/^.* - /, "")) + + "\n" + + this.formatDate(this.data.competitions[id].date); + // add comp to url evtl. replacing cup + ret.url = + location.href.indexOf("cup=") == -1 + ? location.href + + (location.href.indexOf("#!") == -1 ? "#!" : "&") + + "comp=" + + id + : location.href.replace(/(cup)=[^&]+/, "comp=" + id); + // nat. team ranking selects a cat, if none given, need to add it to not get a different selected + if (this.data.cat_filter && ret.url.indexOf("cat=") == -1) + ret.url += "&cat=" + this.data.cat_filter; + // keep in detailed view + if (ret.url.indexOf("detail=1") == -1) ret.url += "&detail=1"; + ret.title = this.data.competitions[id].name; + } else if ( + this.data.cat_filter && + this.data.cat_filter.indexOf(",") == -1 + ) { + ret.label = ""; + ret.nodes = this.results(id, "WetId", _data.counting); + } else { + ret.label = _data.comps[id]; + } + return ret; + }; + /** + * Display a category column + * + * @param _data + * @param _tag tag 'th' for header or 'td' for data row + * @param _name column-name + */ + Aggregated.prototype.cat_column = function (_data, _tag, _name) { + var id = _name.substr(6); + var ret = { className: "result" }; + if (this.json_url.indexOf("detail=1") == -1) + ret.className += " calculationHidden"; + if (_tag == "th") { + ret.label = this.data.categorys[id].name; + // get less wide headers by inserting a newline + ret.label = ret.label + .replace(/(lead|speed|boulder)/, "\n$1") + .replace(/(männliche|weibliche|male|female) */, "$1\n"); + if (!this.data.comp_filter && !this.data.cat_filter) { + ret.url = location.href + "&cat=" + id; + // keep in detailed view + if (ret.url.indexOf("detail=1") == -1) ret.url += "&detail=1"; + } + } else if (!this.data.comp_filter && !this.data.cat_filter) { + // sektionenwertung + var points = 0.0; + for (var r = 0; r < _data.counting.length; ++r) { + var result = _data.counting[r]; + if (result.GrpId == id) { + points += result.points; + } + } + ret.label = points.toFixed(2); + } else { + ret.label = ""; + ret.nodes = this.results(id, "GrpId", _data.counting); + } + return ret; + }; + Aggregated.prototype.results = function (_id, _attr, _results) { + var cols = ["rank", "lastname", "firstname", "points"]; + var nodes; + for (var r = 0; r < _results.length; ++r) { + var result = _results[r]; + if (result[_attr] == _id) { + if (typeof nodes == "undefined") { + nodes = jQuery(document.createElement("div")).addClass("resultRows"); + } + var div = jQuery(document.createElement("div")).addClass("resultRow"); + for (var c = 0; c < cols.length; ++c) { + var col = cols[c]; + var span = jQuery(document.createElement("span")).addClass(col); + span.text( + col != "points" || this.data.use_cup_points + ? result[col] + : result[col].toFixed(2) + ); + div.append(span); + } + nodes.append(div); + } + } + return nodes; + }; + return Aggregated; +})(); + +/** + * Universal widget to display all data specified by _json_url or location + */ +var DrWidget = (function () { + /** + * call appropriate widget to display data specified by _json_url or location + * + * @param _container + * @param _json_url url for data to load + * @param _arg3 object with widget specific 3. argument, eg. { Competitions: {filters}, Profile: 'template-id' } + */ + function DrWidget(_container, _json_url, _arg3) { + DrBaseWidget.prototype.constructor.call(this, _container, _json_url); + + this.arg3 = _arg3 || {}; + + var matches = this.json_url.match(/\?.*$/); + this.update(matches ? matches[0] : null); + + // install this.update as PopState handler + this.installPopState(); + } + // inherit from DrBaseWidget + DrWidget.prototype = new DrBaseWidget(); + DrWidget.prototype.constructor = DrWidget; + /** + * Navigate to a certain result-page + * + * @param _params default if not specified first location.hash then location.search + * @param {DrBaseWidget} _widget to clear evtl. pending update timer + */ + DrWidget.prototype.navigateTo = function (_params, _widget) { + // clear pending update timer of widget, to stay on new widget we navigate to now + if (_widget && _widget.update_handle) { + window.clearTimeout(_widget.update_handle); + delete _widget.update_handle; + } + delete this.prevent_initial_pop; + // check if we have an ordinary link without hash or query, eg. result PDF + if (!_params.match(/(#|\?)/)) { + document.location = _params; + } + var params = "!" + _params.replace(/^.*(#!|#|\?)/, ""); + + // update location hash, to reflect current page-content + if (document.location.hash != "#" + params) document.location.hash = params; + }; + DrWidget.prototype.update = function (_params) { + var params = _params || location.hash || location.search; + params = params.replace(/^.*(#!|#|\?)/, ""); + + this.json_url = this.json_url.replace(/\?.*$/, "") + "?" + params; + + // check which widget is needed to render requested content + function hasParam(_param, _value) { + if (typeof _value == "undefined") _value = ""; + return params.indexOf(_param + "=" + _value) != -1; + } + var widget; + if ( + hasParam("type", "nat_team_ranking") || + hasParam("type", "sektionenwertung") || + hasParam("type", "regionalzentren") + ) { + widget = "Aggregated"; + } else if (hasParam("person")) { + widget = "Profile"; + } else if (hasParam("cat") && !hasParam("comp")) { + widget = "Resultlist"; // ranking uses Resultlist! + } else if (hasParam("nation") || !hasParam("comp")) { + widget = "Competitions"; + } else if (hasParam("comp") && hasParam("type", "starters")) { + widget = "Starters"; + } else if ((hasParam("comp") && !hasParam("cat")) || hasParam("filter")) { + widget = "Results"; + } else if (hasParam("type", "startlist")) { + widget = "Startlist"; + } else { + widget = "Resultlist"; + } + // check if widget is currently instancated and only need to update or need to be instancated + if ( + typeof this.widget == "undefined" || + this.widget.constructor != window[widget] + ) { + this.container.html(""); // following .empty() does NOT work in IE8 Grrrr + this.container.empty(); + // do a new of objects whos name is stored in widget + this.widget = Object.create(window[widget].prototype); + // Object.create, does NOT call constructor, so do it now manually + window[widget].call( + this.widget, + this.container, + this.json_url, + this.arg3[widget] + ); + var that = this; + this.widget.navigateTo = function (e) { + if (typeof e == "string") { + that.navigateTo(e, that.widget); + } else { + that.navigateTo(this.href, that.widget); + e.preventDefault(); + } + }; + } else { + this.widget.json_url = this.json_url; + this.widget.update(); + } + }; + return DrWidget; +})(); + +/** + * Widget to let user choose a competition and category to show its result + * + * Chooser selectboxes stay visible, when user navigates in result eg. to show a profile + */ +var ResultChooser = (function () { + /** + * call appropriate widget to display data specified by _json_url or location + * + * @param _container + * @param _json_url url for data to load + * @param {object} _arg3 object with 3. parameter to pass to widget used to display results + */ + function ResultChooser(_container, _json_url, _arg3) { + DrBaseWidget.prototype.constructor.call( + this, + _container, + _json_url.replace(/&cat=[^&]+/, "") + ); + + this.arg3 = _arg3 || { + Results: true, // show NO own navigation + Startlist: true, + Resultlist: true, + }; + + var matches = this.json_url.match(/\?.*$/); + this.update(matches ? matches[0] : null); + + this.comp_chooser = this.cat_chooser = undefined; + var matches = _json_url.match(/&cat=([^&]+)/); + this.cat = matches ? matches[1] : undefined; + + this.widget = undefined; + + // install this.update as PopState handler + //this.installPopState(); + } + // inherit from DrBaseWidget + ResultChooser.prototype = new DrBaseWidget(); + ResultChooser.prototype.constructor = ResultChooser; + /** + * Callback for loading data via ajax + * + * @param _data route data object + */ + ResultChooser.prototype.handleResponse = function (_data) { + if (!this.comp_chooser) { + // competition chooser + this.comp_chooser = jQuery(document.createElement("select")); + this.comp_chooser.addClass("compChooser"); + this.container.append(this.comp_chooser); + var that = this; + this.comp_chooser.change(function (e) { + that.json_url = that.json_url + .replace(/comp=[^&]+/, "comp=" + this.value) + .replace(/&cat=[^&]+/, ""); + that.update(); + }); + this.cat_chooser = jQuery(document.createElement("select")); + this.cat_chooser.addClass("catChooser"); + this.container.append(this.cat_chooser); + this.cat_chooser.change(function (e) { + that.cat = this.value; + that.json_url = that.json_url.replace( + /comp=[^&]+/, + "comp=" + that.comp_chooser.val() + ); + if (!that.cat) that.json_url = that.json_url.replace(/&cat=[^&]+/, ""); + else if (that.json_url.search("cat=") == -1) + that.json_url += "&cat=" + this.value; + else + that.json_url = that.json_url.replace( + /cat=[^&]+/, + "cat=" + this.value + ); + that.widget.navigateTo(that.json_url); + }); + } else { + this.comp_chooser.empty(); + this.cat_chooser.empty(); + } + // fill competition chooser + for (var i = 0; i < _data.competitions.length; ++i) { + var competition = _data.competitions[i]; + var option = jQuery(document.createElement("option")); + option.attr({ value: competition.WetId, title: competition.date_span }); + option.text(competition.name); + if (competition.WetId == _data.WetId) option.attr("selected", true); + this.comp_chooser.append(option); + } + // fill category chooser + var option = jQuery(document.createElement("option")); + option.attr("value", ""); + option.text(this.lang("Select a single category to show ...")); + this.cat_chooser.append(option); + var cat_found = false; + for (var i = 0; i < _data.categorys.length; ++i) { + var cat = _data.categorys[i]; + option = jQuery(document.createElement("option")); + option.attr("value", cat.GrpId); + option.text(cat.name); + if (cat.GrpId == this.cat) { + option.attr("selected", true); + cat_found = true; + } + this.cat_chooser.append(option); + } + if (!cat_found) this.cat = undefined; + + if (!this.widget) { + var widget_container = jQuery(document.createElement("div")).appendTo( + this.container + ); + this.widget = new DrWidget( + widget_container, + this.json_url + (this.cat ? "&cat=" + this.cat : ""), + this.arg3 + ); + } else { + this.widget.navigateTo( + this.json_url + (this.cat ? "&cat=" + this.cat : "") + ); + } + }; + return ResultChooser; +})(); + +/** + * Dynamically load a css file + * + * @param href url to css file + */ +function load_css(href) { + //Get the head node and append a new link node with the stylesheet url to it + var headID = document.getElementsByTagName("head")[0]; + var cssnode = document.createElement("link"); + cssnode.type = "text/css"; + cssnode.rel = "stylesheet"; + cssnode.href = href; + headID.appendChild(cssnode); +} + +/** + * Align non-breaking-space separated parts of text in a td by wrapping them in equally sized spans + * + * @param {string|jQuery} elems + */ +function align_td_nbsp(elems) { + jQuery(elems).replaceWith(function () { + var parts = jQuery(this) + .contents() + .text() + .split(/\u00A0+/); + if (parts.length == 1) return jQuery(this).clone(); + var prefix = '
'; + var postfix = "
"; + return jQuery( + "" + prefix + parts.join(postfix + prefix) + postfix + "" + ).addClass(this.className); + }); +} + +/** + * Some compatibilty functions to cope with older javascript implementations + */ +if (!Array.isArray) { + Array.isArray = function (vArg) { + return Object.prototype.toString.call(vArg) === "[object Array]"; + }; +} + +if (!Object.create) { + Object.create = function (o) { + function F() {} + F.prototype = o; + return new F(); + }; +} + +if (!Date.getWeek) { + Date.prototype.getWeek = function () { + var onejan = new Date(this.getFullYear(), 0, 1); + return Math.ceil(((this - onejan) / 86400000 + onejan.getDay() + 1) / 7); + }; +} diff --git a/dr_list.css b/dr_list.css new file mode 100644 index 0000000..421130f --- /dev/null +++ b/dr_list.css @@ -0,0 +1,324 @@ +/** + * digital ROCK CSS for jQuery based Javascript API + * + * @link http://www.digitalrock.de + * @author Ralf Becker + * @copyright 2010-13 by RalfBecker@digitalROCK.de + * @version $Id$ + */ + + table.DrTable { + width: 100%; +} + +/** + * Background etc. for header rows + */ +table.DrTable thead, table.DrTable tbody th { + background-color: #c0c0c0; +} +/** + * Background etc. for body rows + */ +table.DrTable tbody { + background-color: #f0f0f0; +} +/** + * Center all columns by default + */ +table.DrTable th, table.DrTable td { + text-align: center; +} +/** + * Left justify text columns like name + */ +table.DrTable th.lastname, table.DrTable td.lastname, table.DrTable td.firstname, table.DrTable td.boulder, +table.DrTable td.team_name, table.DrTable tbody th, .Starters table.DrTable th, .Starters table.DrTable td, +table.DrTable th.federation, table.DrTable td.federation, table.DrTable th.rgz, table.DrTable td.rgz, +table.DrTable th.city, table.DrTable td.city, table.DrTable th.footer { + padding-left: 5px; + text-align: left; +} +table.DrTable td.final_points, table.DrTable td.quali_points { + padding-right: 5px; + text-align: right; +} +table.DrTable td.final_points { + padding-right: 15px; +} +table.DrTable tbody th a { + padding-left: 10px; + font-weight: normal; +} +table.DrTable.boulder2018 tbody td[class^="result"] { + min-width: 6em; +} +table.DrTable.boulder2018 tbody td.result_rank { + min-width: 0; +} +/** + * alignment of multiple values in a column by align_td_nbsp function + */ +table.DrTable td div.tdAlign2 { width: 30%; display: inline-block; } +table.DrTable td div.tdAlign2:first-child { width: 60%; display: inline-block; } +table.DrTable td div.tdAlign3 { width: 20%; display: inline-block; } +table.DrTable td div.tdAlign3:first-child { width: 40%; display: inline-block; } +table.DrTable td div.tdAlign4 { width: 16%; display: inline-block; } +table.DrTable td div.tdAlign4:first-child { width: 50%; display: inline-block; } +/** + * Capitalize names + */ +.lastname { + text-transform: uppercase; +} +.Starters .lastname:after { + content: ", "; +} + +/** + * Hide names (this is only for show, no real name below filter) + */ +tr.hideNames .lastname, tr.hideNames .firstname { + -webkit-filter: blur(2px) grayscale(1) opacity(50%); + filter: blur(2px) grayscale(1) opacity(50%); +} + +/** + * Format the header + */ +.Results h1, .Startlist h1, .Resultlist h1, .Starters h1, .Profile h1 { + padding: 0; + margin: 0; + font-size: 20pt; + font-weight: bold; +} + +.Results h3, .Profile h3, .Profile h2 { + padding: 0; + margin: 0; + font-weight: normal; +} + +.Results select.compChooser { + width: 100%; +} + +/** + * Quota line + */ +.quota_line > td { + border-top: 2px solid black; +} + +/** + * See also links + */ +ul.seeAlso li { + display: block ! important; +} + +/** + * Result column + */ +.result { + white-space: nowrap; +} + +/** + * Toc row + */ +ul.listToc, ul.listCatToc { + padding: 0; + margin: 0; + float: left; +} +ul.listCatToc { + float: right; +} +ul.listToc li, ul.listCatToc li { + display: inline-block; + margin-right: 15px !important; + text-transform: uppercase; + line-height: 1.2; +} +ul.listCatToc li { + text-transform: none; +} + +/** + * New boulder result display + */ +div.boulder, div.boulderNone, div.boulderTop, div.boulderBonus { + width: 24px; + height: 24px; + display: inline-block; + margin-right: 2px; + background-size: 100%; + position: relative; +} +td.boulder > div { + white-space: nowrap; + text-align: center; +} + +div.boulderNone { + background-image: url(../../templates/default/images/boulderNone.png); +} + +div.boulderTop { + background-image: url(../../templates/default/images/boulderTop.png); +} + +div.boulderBonus { + background-image: url(../../templates/default/images/boulderBonus.png); +} + +div.bonusTries, div.topTries { + position: absolute; + font-size: 90%; + font-weight: bold; + color: white; +} +div.bonusTries { + right: 3px; + bottom: 1px; + line-height: 1; +} +div.topTries { + left: 3px; + top: 1px; + line-height: 1; +} + +/** + * Profile page + */ +div.Profile { + display: inline-block; +} +.profileHeader, .profileData { + width: 100%; +} +.profileHeader .profileNation { + margin: 5px 0 5px 0; +} +.profileLogo { + text-align: right; +} +.profileRank:after, .profileResultRank:after { + content: "."; +} +.profileData td { + font-style: italic; +} +td.profileAge, td.profileBirthdate, td.profileBirthplace, td.profileCity, td.profileStreet, td.profileRank, +td.profilePractice, td.profileOtherSports, td.profileProfessional, td.profileHeight, td.profileWeight { + font-weight: bold; + font-style: normal; +} +.profileResult td, h1, h3, td.profileRanglist { + font-style: normal; +} +td.profileRanglist { + white-space: nowrap; +} +.profileResultHidden { + display: none; +} +tr.profileMarginTop > td { + padding-top: 10px; +} +.profileResultHeader td { + font-weight: bold; + font-style: normal; + font-size: 120%; +} +.profileData td:first-child { + width: 2em; +} +/** + * Aggregated rankings + */ +.Aggregated th.nation, .Aggregated td.nation, .Aggregated td.name, .Aggregated th.name { + text-align: left; + padding-left: 3px; +} +.Aggregated td.name, .Aggregated th.result, .Aggregated td.result { + line-height: 1.3; + white-space: pre-wrap; +} +.Aggregated td.calculationHidden, .Aggregated th.calculationHidden { + display: none; +} +.Aggregated div.resultRows, .Aggregated div.resultRow { + width: 100%; + text-align: left; +} +.Aggregated td.result span +{ + padding-right: 1ex; +} +.Aggregated td.result span.rank { + display: inline-block; + width: 1.5em; +} +.Aggregated td.result span.rank:after, .Aggregated td.rank:after { + content: "."; +} +.Aggregated td.result span.points { + float: right; +} +.Aggregated .rankingHeader2 { + white-space: pre; +} +/** + * ResultChooser widget + */ +.ResultChooser > select { + display: block; + width: 100%; +} + +/** + * Resultlist + */ +.Resultlist h3.resultDate:empty { + display: none; +} +.error:empty { + display: none; +} +.error { + color: red; + font-style: italic; +} + +/** + * Fix some CSS on www.ifsc-climbing.org + */ +section#gkMainbody table.profileHeader thead tr:hover td, section#gkMainbody table.profileData thead tr:hover td { + background-color: black; +} +section#gkMainbody table.DrTable thead, section#gkMainbody table.DrTable tbody{ + background-color: inherit; + background-color: rgba(0,0,0,0.75); +} +/* do NOT show start-numbers on ifsc-website */ +section#gkMainbody .Resultlist table.DrTable .start_number { + display: none; +} +/* display wide lists over right _WORLDCOMP. menu, not under it */ +section#gkMainbody table.DrTable { + position: relative; + z-index: 1; +} +/* hide digitalROCK logo */ +section#gkMainbody td.profileLogo { + display: none; +} + +/* footer */ +div.footer { + display: hidden; + color: gray; +} diff --git a/dr_translations.js b/dr_translations.js new file mode 100644 index 0000000..4421839 --- /dev/null +++ b/dr_translations.js @@ -0,0 +1,122 @@ +var dr_translations = { + after: { + de: "nach", + }, + Agegroup: { + de: "Jahrgang", + }, + "Athlete #1": { + de: "Athlete #1", + }, + "Athlete #2": { + de: "Athlete #2", + }, + "Athlete #3": { + de: "Athlete #3", + }, + "Athlete asked not to show his name anymore.": { + de: "Der Athlet hat gebeten seinen Namen nicht mehr anzuzeigen.", + }, + "As of": { + de: "Stand", + }, + Birthyear: { + de: "Jahrgang", + }, + Calendar: { + de: "Kalender", + }, + City: { + de: "Stadt", + }, + Deadline: { + de: "Anmeldeschluss", + }, + "Event Website": { + de: "Event Webseite", + }, + "Final Points": { + de: "Final Punkte", + }, + "For %1 %2 best results per competition and category are counting.": { + de: "Für %1 zählen die %2 besten Ergebnisse pro Wettkampf und Kategorie.", + }, + "Info Sheet": { + de: "Infoblatt", + }, + Name: { + de: "Name", + }, + Nation: { + de: "Nation", + }, + "Not counting results are in brackets.": { + de: "Nicht zählende Ergebnise sind in Klammern.", + }, + Points: { + de: "Punkte", + }, + Qualification: { + de: "Qualifikation", + }, + Rank: { + de: "Rang", + }, + Regionalzentrum: { + de: "Regionalzentrum", + }, + Regulation: { + de: "Regulation", + }, + Result: { + de: "Ergebnis", + }, + "See also:": { + de: "Siehe auch:", + }, + Sektion: { + de: "Sektion", + }, + "Select a single category to show ...": { + de: "Einzelne Kategorie zum Anzeigen auswählen ...", + }, + "Select another competition ...": { + de: "Anderen Wettkampf auswählen ...", + }, + StartNr: { + de: "StartNr", + }, + Starters: { + de: "Meldeliste", + }, + Startlist: { + de: "Startliste", + }, + Sum: { + de: "Summe", + }, + Teamname: { + de: "Teamname", + }, + "Total of %1 athletes registered in all categories.": { + de: "Total of %1 athletes registered in all categories.", + }, + Vorqualifiziert: { + de: "Vorqualifiziert", + }, + "calculation of this ranking": { + de: "Berechnung dieser Rangliste", + }, + "Complete Results": { + de: "komplettes Ergebnis", + }, + "previous heat": { + de: "vorherige Runde", + }, + "provisional Result": { + de: "provisorisches Ergebnis", + }, + "years, since": { + de: "Jahre, seit", + }, +}; diff --git a/index.html b/index.html new file mode 100644 index 0000000..8c8280c --- /dev/null +++ b/index.html @@ -0,0 +1,64 @@ + + + + + + + + + + + +
+ + + + diff --git a/jquery.min.js b/jquery.min.js new file mode 100644 index 0000000..73f33fb --- /dev/null +++ b/jquery.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.11.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ +!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="".trim,l={},m="1.11.0",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(n.isPlainObject(c)||(b=n.isArray(c)))?(b?(b=!1,f=a&&n.isArray(a)?a:[]):f=a&&n.isPlainObject(a)?a:{},g[d]=n.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray||function(a){return"array"===n.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==n.type(a)||a.nodeType||n.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(l.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&n.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:k&&!k.call("\ufeff\xa0")?function(a){return null==a?"":k.call(a)}:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),n.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||n.guid++,e):void 0},now:function(){return+new Date},support:l}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s="sizzle"+-new Date,t=a.document,u=0,v=0,w=eb(),x=eb(),y=eb(),z=function(a,b){return a===b&&(j=!0),0},A="undefined",B=1<<31,C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=D.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",M=L.replace("w","w#"),N="\\["+K+"*("+L+")"+K+"*(?:([*^$|!~]?=)"+K+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+M+")|)|)"+K+"*\\]",O=":("+L+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+N.replace(3,8)+")*)|.*)\\)|)",P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(O),U=new RegExp("^"+M+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L.replace("w","w*")+")"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=/'|\\/g,ab=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),bb=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{G.apply(D=H.call(t.childNodes),t.childNodes),D[t.childNodes.length].nodeType}catch(cb){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function db(a,b,d,e){var f,g,h,i,j,m,p,q,u,v;if((b?b.ownerDocument||b:t)!==l&&k(b),b=b||l,d=d||[],!a||"string"!=typeof a)return d;if(1!==(i=b.nodeType)&&9!==i)return[];if(n&&!e){if(f=Z.exec(a))if(h=f[1]){if(9===i){if(g=b.getElementById(h),!g||!g.parentNode)return d;if(g.id===h)return d.push(g),d}else if(b.ownerDocument&&(g=b.ownerDocument.getElementById(h))&&r(b,g)&&g.id===h)return d.push(g),d}else{if(f[2])return G.apply(d,b.getElementsByTagName(a)),d;if((h=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(h)),d}if(c.qsa&&(!o||!o.test(a))){if(q=p=s,u=b,v=9===i&&a,1===i&&"object"!==b.nodeName.toLowerCase()){m=ob(a),(p=b.getAttribute("id"))?q=p.replace(_,"\\$&"):b.setAttribute("id",q),q="[id='"+q+"'] ",j=m.length;while(j--)m[j]=q+pb(m[j]);u=$.test(a)&&mb(b.parentNode)||b,v=m.join(",")}if(v)try{return G.apply(d,u.querySelectorAll(v)),d}catch(w){}finally{p||b.removeAttribute("id")}}}return xb(a.replace(P,"$1"),b,d,e)}function eb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function fb(a){return a[s]=!0,a}function gb(a){var b=l.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function hb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function ib(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||B)-(~a.sourceIndex||B);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function jb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function kb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function lb(a){return fb(function(b){return b=+b,fb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function mb(a){return a&&typeof a.getElementsByTagName!==A&&a}c=db.support={},f=db.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},k=db.setDocument=function(a){var b,e=a?a.ownerDocument||a:t,g=e.defaultView;return e!==l&&9===e.nodeType&&e.documentElement?(l=e,m=e.documentElement,n=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){k()},!1):g.attachEvent&&g.attachEvent("onunload",function(){k()})),c.attributes=gb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=gb(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(e.getElementsByClassName)&&gb(function(a){return a.innerHTML="
",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=gb(function(a){return m.appendChild(a).id=s,!e.getElementsByName||!e.getElementsByName(s).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==A&&n){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){var c=typeof a.getAttributeNode!==A&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==A?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==A&&n?b.getElementsByClassName(a):void 0},p=[],o=[],(c.qsa=Y.test(e.querySelectorAll))&&(gb(function(a){a.innerHTML="",a.querySelectorAll("[t^='']").length&&o.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||o.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll(":checked").length||o.push(":checked")}),gb(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&o.push("name"+K+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||o.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),o.push(",.*:")})),(c.matchesSelector=Y.test(q=m.webkitMatchesSelector||m.mozMatchesSelector||m.oMatchesSelector||m.msMatchesSelector))&&gb(function(a){c.disconnectedMatch=q.call(a,"div"),q.call(a,"[s!='']:x"),p.push("!=",O)}),o=o.length&&new RegExp(o.join("|")),p=p.length&&new RegExp(p.join("|")),b=Y.test(m.compareDocumentPosition),r=b||Y.test(m.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},z=b?function(a,b){if(a===b)return j=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===t&&r(t,a)?-1:b===e||b.ownerDocument===t&&r(t,b)?1:i?I.call(i,a)-I.call(i,b):0:4&d?-1:1)}:function(a,b){if(a===b)return j=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],k=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:i?I.call(i,a)-I.call(i,b):0;if(f===g)return ib(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)k.unshift(c);while(h[d]===k[d])d++;return d?ib(h[d],k[d]):h[d]===t?-1:k[d]===t?1:0},e):l},db.matches=function(a,b){return db(a,null,null,b)},db.matchesSelector=function(a,b){if((a.ownerDocument||a)!==l&&k(a),b=b.replace(S,"='$1']"),!(!c.matchesSelector||!n||p&&p.test(b)||o&&o.test(b)))try{var d=q.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return db(b,l,null,[a]).length>0},db.contains=function(a,b){return(a.ownerDocument||a)!==l&&k(a),r(a,b)},db.attr=function(a,b){(a.ownerDocument||a)!==l&&k(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!n):void 0;return void 0!==f?f:c.attributes||!n?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},db.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},db.uniqueSort=function(a){var b,d=[],e=0,f=0;if(j=!c.detectDuplicates,i=!c.sortStable&&a.slice(0),a.sort(z),j){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return i=null,a},e=db.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=db.selectors={cacheLength:50,createPseudo:fb,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ab,bb),a[3]=(a[4]||a[5]||"").replace(ab,bb),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||db.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&db.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return V.CHILD.test(a[0])?null:(a[3]&&void 0!==a[4]?a[2]=a[4]:c&&T.test(c)&&(b=ob(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ab,bb).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=w[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&w(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==A&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=db.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),t=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&t){k=q[s]||(q[s]={}),j=k[a]||[],n=j[0]===u&&j[1],m=j[0]===u&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[u,n,m];break}}else if(t&&(j=(b[s]||(b[s]={}))[a])&&j[0]===u)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(t&&((l[s]||(l[s]={}))[a]=[u,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||db.error("unsupported pseudo: "+a);return e[s]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?fb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:fb(function(a){var b=[],c=[],d=g(a.replace(P,"$1"));return d[s]?fb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:fb(function(a){return function(b){return db(a,b).length>0}}),contains:fb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:fb(function(a){return U.test(a||"")||db.error("unsupported lang: "+a),a=a.replace(ab,bb).toLowerCase(),function(b){var c;do if(c=n?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===m},focus:function(a){return a===l.activeElement&&(!l.hasFocus||l.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:lb(function(){return[0]}),last:lb(function(a,b){return[b-1]}),eq:lb(function(a,b,c){return[0>c?c+b:c]}),even:lb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:lb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:lb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:lb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function qb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=v++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[u,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[s]||(b[s]={}),(h=i[d])&&h[0]===u&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function rb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function sb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function tb(a,b,c,d,e,f){return d&&!d[s]&&(d=tb(d)),e&&!e[s]&&(e=tb(e,f)),fb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||wb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:sb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=sb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=sb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ub(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],i=g||d.relative[" "],j=g?1:0,k=qb(function(a){return a===b},i,!0),l=qb(function(a){return I.call(b,a)>-1},i,!0),m=[function(a,c,d){return!g&&(d||c!==h)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>j;j++)if(c=d.relative[a[j].type])m=[qb(rb(m),c)];else{if(c=d.filter[a[j].type].apply(null,a[j].matches),c[s]){for(e=++j;f>e;e++)if(d.relative[a[e].type])break;return tb(j>1&&rb(m),j>1&&pb(a.slice(0,j-1).concat({value:" "===a[j-2].type?"*":""})).replace(P,"$1"),c,e>j&&ub(a.slice(j,e)),f>e&&ub(a=a.slice(e)),f>e&&pb(a))}m.push(c)}return rb(m)}function vb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,i,j,k){var m,n,o,p=0,q="0",r=f&&[],s=[],t=h,v=f||e&&d.find.TAG("*",k),w=u+=null==t?1:Math.random()||.1,x=v.length;for(k&&(h=g!==l&&g);q!==x&&null!=(m=v[q]);q++){if(e&&m){n=0;while(o=a[n++])if(o(m,g,i)){j.push(m);break}k&&(u=w)}c&&((m=!o&&m)&&p--,f&&r.push(m))}if(p+=q,c&&q!==p){n=0;while(o=b[n++])o(r,s,g,i);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=E.call(j));s=sb(s)}G.apply(j,s),k&&!f&&s.length>0&&p+b.length>1&&db.uniqueSort(j)}return k&&(u=w,h=t),r};return c?fb(f):f}g=db.compile=function(a,b){var c,d=[],e=[],f=y[a+" "];if(!f){b||(b=ob(a)),c=b.length;while(c--)f=ub(b[c]),f[s]?d.push(f):e.push(f);f=y(a,vb(e,d))}return f};function wb(a,b,c){for(var d=0,e=b.length;e>d;d++)db(a,b[d],c);return c}function xb(a,b,e,f){var h,i,j,k,l,m=ob(a);if(!f&&1===m.length){if(i=m[0]=m[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&c.getById&&9===b.nodeType&&n&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(ab,bb),b)||[])[0],!b)return e;a=a.slice(i.shift().value.length)}h=V.needsContext.test(a)?0:i.length;while(h--){if(j=i[h],d.relative[k=j.type])break;if((l=d.find[k])&&(f=l(j.matches[0].replace(ab,bb),$.test(i[0].type)&&mb(b.parentNode)||b))){if(i.splice(h,1),a=f.length&&pb(i),!a)return G.apply(e,f),e;break}}}return g(a,m)(f,b,!n,e,$.test(a)&&mb(b.parentNode)||b),e}return c.sortStable=s.split("").sort(z).join("")===s,c.detectDuplicates=!!j,k(),c.sortDetached=gb(function(a){return 1&a.compareDocumentPosition(l.createElement("div"))}),gb(function(a){return a.innerHTML="
","#"===a.firstChild.getAttribute("href")})||hb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&gb(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||hb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),gb(function(a){return null==a.getAttribute("disabled")})||hb(J,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),db}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return n.inArray(a,b)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;e>b;b++)if(n.contains(d[b],this))return!0}));for(b=0;e>b;b++)n.find(a,d[b],c);return c=this.pushStack(e>1?n.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=a.document,A=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,B=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:A.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:z,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=z.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return y.find(a);this.length=1,this[0]=d}return this.context=z,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};B.prototype=n.fn,y=n(z);var C=/^(?:parents|prev(?:Until|All))/,D={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!n(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b,c=n(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(n.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?n.inArray(this[0],n(a)):n.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function E(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return E(a,"nextSibling")},prev:function(a){return E(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return n.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(D[a]||(e=n.unique(e)),C.test(a)&&(e=e.reverse())),this.pushStack(e)}});var F=/\S+/g,G={};function H(a){var b=G[a]={};return n.each(a.match(F)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?G[a]||H(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&n.each(arguments,function(a,c){var d;while((d=n.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var I;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){if(a===!0?!--n.readyWait:!n.isReady){if(!z.body)return setTimeout(n.ready);n.isReady=!0,a!==!0&&--n.readyWait>0||(I.resolveWith(z,[n]),n.fn.trigger&&n(z).trigger("ready").off("ready"))}}});function J(){z.addEventListener?(z.removeEventListener("DOMContentLoaded",K,!1),a.removeEventListener("load",K,!1)):(z.detachEvent("onreadystatechange",K),a.detachEvent("onload",K))}function K(){(z.addEventListener||"load"===event.type||"complete"===z.readyState)&&(J(),n.ready())}n.ready.promise=function(b){if(!I)if(I=n.Deferred(),"complete"===z.readyState)setTimeout(n.ready);else if(z.addEventListener)z.addEventListener("DOMContentLoaded",K,!1),a.addEventListener("load",K,!1);else{z.attachEvent("onreadystatechange",K),a.attachEvent("onload",K);var c=!1;try{c=null==a.frameElement&&z.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!n.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}J(),n.ready()}}()}return I.promise(b)};var L="undefined",M;for(M in n(l))break;l.ownLast="0"!==M,l.inlineBlockNeedsLayout=!1,n(function(){var a,b,c=z.getElementsByTagName("body")[0];c&&(a=z.createElement("div"),a.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",b=z.createElement("div"),c.appendChild(a).appendChild(b),typeof b.style.zoom!==L&&(b.style.cssText="border:0;margin:0;width:1px;padding:1px;display:inline;zoom:1",(l.inlineBlockNeedsLayout=3===b.offsetWidth)&&(c.style.zoom=1)),c.removeChild(a),a=b=null)}),function(){var a=z.createElement("div");if(null==l.deleteExpando){l.deleteExpando=!0;try{delete a.test}catch(b){l.deleteExpando=!1}}a=null}(),n.acceptData=function(a){var b=n.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(O,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}n.data(a,b,c)}else c=void 0}return c}function Q(a){var b;for(b in a)if(("data"!==b||!n.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function R(a,b,d,e){if(n.acceptData(a)){var f,g,h=n.expando,i=a.nodeType,j=i?n.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||n.guid++:h),j[k]||(j[k]=i?{}:{toJSON:n.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=n.extend(j[k],b):j[k].data=n.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[n.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[n.camelCase(b)])):f=g,f +}}function S(a,b,c){if(n.acceptData(a)){var d,e,f=a.nodeType,g=f?n.cache:a,h=f?a[n.expando]:n.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){n.isArray(b)?b=b.concat(n.map(b,n.camelCase)):b in d?b=[b]:(b=n.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!Q(d):!n.isEmptyObject(d))return}(c||(delete g[h].data,Q(g[h])))&&(f?n.cleanData([a],!0):l.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}n.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?n.cache[a[n.expando]]:a[n.expando],!!a&&!Q(a)},data:function(a,b,c){return R(a,b,c)},removeData:function(a,b){return S(a,b)},_data:function(a,b,c){return R(a,b,c,!0)},_removeData:function(a,b){return S(a,b,!0)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=n.data(f),1===f.nodeType&&!n._data(f,"parsedAttrs"))){c=g.length;while(c--)d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d]));n._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){n.data(this,a)}):arguments.length>1?this.each(function(){n.data(this,a,b)}):f?P(f,a,n.data(f,a)):void 0},removeData:function(a){return this.each(function(){n.removeData(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=n._data(a,b),c&&(!d||n.isArray(c)?d=n._data(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return n._data(a,c)||n._data(a,c,{empty:n.Callbacks("once memory").add(function(){n._removeData(a,b+"queue"),n._removeData(a,c)})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},X=/^(?:checkbox|radio)$/i;!function(){var a=z.createDocumentFragment(),b=z.createElement("div"),c=z.createElement("input");if(b.setAttribute("className","t"),b.innerHTML="
a",l.leadingWhitespace=3===b.firstChild.nodeType,l.tbody=!b.getElementsByTagName("tbody").length,l.htmlSerialize=!!b.getElementsByTagName("link").length,l.html5Clone="<:nav>"!==z.createElement("nav").cloneNode(!0).outerHTML,c.type="checkbox",c.checked=!0,a.appendChild(c),l.appendChecked=c.checked,b.innerHTML="",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,a.appendChild(b),b.innerHTML="",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,l.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){l.noCloneEvent=!1}),b.cloneNode(!0).click()),null==l.deleteExpando){l.deleteExpando=!0;try{delete b.test}catch(d){l.deleteExpando=!1}}a=b=c=null}(),function(){var b,c,d=z.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(l[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),l[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var Y=/^(?:input|select|textarea)$/i,Z=/^key/,$=/^(?:mouse|contextmenu)|click/,_=/^(?:focusinfocus|focusoutblur)$/,ab=/^([^.]*)(?:\.(.+)|)$/;function bb(){return!0}function cb(){return!1}function db(){try{return z.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=n.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof n===L||a&&n.event.triggered===a.type?void 0:n.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(F)||[""],h=b.length;while(h--)f=ab.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=n.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=n.event.special[o]||{},l=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},i),(m=g[o])||(m=g[o]=[],m.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,l):m.push(l),n.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n.hasData(a)&&n._data(a);if(r&&(k=r.events)){b=(b||"").match(F)||[""],j=b.length;while(j--)if(h=ab.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=m.length;while(f--)g=m[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(m.splice(f,1),g.selector&&m.delegateCount--,l.remove&&l.remove.call(a,g));i&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(k)&&(delete r.handle,n._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,m,o=[d||z],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||z,3!==d.nodeType&&8!==d.nodeType&&!_.test(p+n.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[n.expando]?b:new n.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),k=n.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!n.isWindow(d)){for(i=k.delegateType||p,_.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||z)&&o.push(l.defaultView||l.parentWindow||a)}m=0;while((h=o[m++])&&!b.isPropagationStopped())b.type=m>1?i:k.bindType||p,f=(n._data(h,"events")||{})[b.type]&&n._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&n.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&n.acceptData(d)&&g&&d[p]&&!n.isWindow(d)){l=d[g],l&&(d[g]=null),n.event.triggered=p;try{d[p]()}catch(r){}n.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(n._data(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((n.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?n(c,this).index(i)>=0:n.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),ib=/^\s+/,jb=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,kb=/<([\w:]+)/,lb=/\s*$/g,sb={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:l.htmlSerialize?[0,"",""]:[1,"X
","
"]},tb=eb(z),ub=tb.appendChild(z.createElement("div"));sb.optgroup=sb.option,sb.tbody=sb.tfoot=sb.colgroup=sb.caption=sb.thead,sb.th=sb.td;function vb(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==L?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==L?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||n.nodeName(d,b)?f.push(d):n.merge(f,vb(d,b));return void 0===b||b&&n.nodeName(a,b)?n.merge([a],f):f}function wb(a){X.test(a.type)&&(a.defaultChecked=a.checked)}function xb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function yb(a){return a.type=(null!==n.find.attr(a,"type"))+"/"+a.type,a}function zb(a){var b=qb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ab(a,b){for(var c,d=0;null!=(c=a[d]);d++)n._data(c,"globalEval",!b||n._data(b[d],"globalEval"))}function Bb(a,b){if(1===b.nodeType&&n.hasData(a)){var c,d,e,f=n._data(a),g=n._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)n.event.add(b,c,h[c][d])}g.data&&(g.data=n.extend({},g.data))}}function Cb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!l.noCloneEvent&&b[n.expando]){e=n._data(b);for(d in e.events)n.removeEvent(b,d,e.handle);b.removeAttribute(n.expando)}"script"===c&&b.text!==a.text?(yb(b).text=a.text,zb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),l.html5Clone&&a.innerHTML&&!n.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&X.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}n.extend({clone:function(a,b,c){var d,e,f,g,h,i=n.contains(a.ownerDocument,a);if(l.html5Clone||n.isXMLDoc(a)||!hb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(ub.innerHTML=a.outerHTML,ub.removeChild(f=ub.firstChild)),!(l.noCloneEvent&&l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(d=vb(f),h=vb(a),g=0;null!=(e=h[g]);++g)d[g]&&Cb(e,d[g]);if(b)if(c)for(h=h||vb(a),d=d||vb(f),g=0;null!=(e=h[g]);g++)Bb(e,d[g]);else Bb(a,f);return d=vb(f,"script"),d.length>0&&Ab(d,!i&&vb(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k,m=a.length,o=eb(b),p=[],q=0;m>q;q++)if(f=a[q],f||0===f)if("object"===n.type(f))n.merge(p,f.nodeType?[f]:f);else if(mb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(kb.exec(f)||["",""])[1].toLowerCase(),k=sb[i]||sb._default,h.innerHTML=k[1]+f.replace(jb,"<$1>")+k[2],e=k[0];while(e--)h=h.lastChild;if(!l.leadingWhitespace&&ib.test(f)&&p.push(b.createTextNode(ib.exec(f)[0])),!l.tbody){f="table"!==i||lb.test(f)?""!==k[1]||lb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)n.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}n.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),l.appendChecked||n.grep(vb(p,"input"),wb),q=0;while(f=p[q++])if((!d||-1===n.inArray(f,d))&&(g=n.contains(f.ownerDocument,f),h=vb(o.appendChild(f),"script"),g&&Ab(h),c)){e=0;while(f=h[e++])pb.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=n.expando,j=n.cache,k=l.deleteExpando,m=n.event.special;null!=(d=a[h]);h++)if((b||n.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)m[e]?n.event.remove(d,e):n.removeEvent(d,e,g.handle);j[f]&&(delete j[f],k?delete d[i]:typeof d.removeAttribute!==L?d.removeAttribute(i):d[i]=null,c.push(f))}}}),n.fn.extend({text:function(a){return W(this,function(a){return void 0===a?n.text(this):this.empty().append((this[0]&&this[0].ownerDocument||z).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=xb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=xb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(vb(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&Ab(vb(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&n.cleanData(vb(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&n.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return W(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(gb,""):void 0;if(!("string"!=typeof a||nb.test(a)||!l.htmlSerialize&&hb.test(a)||!l.leadingWhitespace&&ib.test(a)||sb[(kb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(jb,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(vb(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(vb(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,k=this.length,m=this,o=k-1,p=a[0],q=n.isFunction(p);if(q||k>1&&"string"==typeof p&&!l.checkClone&&ob.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(k&&(i=n.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=n.map(vb(i,"script"),yb),f=g.length;k>j;j++)d=i,j!==o&&(d=n.clone(d,!0,!0),f&&n.merge(g,vb(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,n.map(g,zb),j=0;f>j;j++)d=g[j],pb.test(d.type||"")&&!n._data(d,"globalEval")&&n.contains(h,d)&&(d.src?n._evalUrl&&n._evalUrl(d.src):n.globalEval((d.text||d.textContent||d.innerHTML||"").replace(rb,"")));i=c=null}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=0,e=[],g=n(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),n(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Db,Eb={};function Fb(b,c){var d=n(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:n.css(d[0],"display");return d.detach(),e}function Gb(a){var b=z,c=Eb[a];return c||(c=Fb(a,b),"none"!==c&&c||(Db=(Db||n("