Changeset 35063
- Timestamp:
- 2021-04-12T17:30:09+12:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/js/eurovision.js
r35048 r35063 6 6 var glob_voting_country_and_points_width = (180+35); 7 7 8 function transpose_i(i,num_cols, num_rows) 9 { 8 9 var pp_country_lookup = { 10 "BosniaandHerzegovina": "Bosnia and Herzegovina", 11 "CzechRepublic": "Czech Republic", 12 "FederalRepublicofYugoslavia": "Federal Republic of Yugoslavia", 13 "NorthMacedonia": "North Macedonia", 14 "RepublicofMacedonia": "Republic of Macedonia", 15 "SanMarino": "San Marino", 16 "SerbiaandMontenegro": "Serbia and Montenegro", 17 "UnitedKingdom": "United Kingdom", 18 }; 19 20 function transpose_i(i,num_cols,num_rows,num_countries) 21 { 22 if (i >= num_countries) { 23 // out of range to tanspose, just return original value 24 return i; 25 } 26 27 var num_filler_gaps = (num_cols * num_rows) - num_countries; 28 var full_cols_until = num_cols - num_filler_gaps; 29 //console.log("full cols until = " + full_cols_until); 30 10 31 // Map 'i' to (x,y) position in grid layout 11 32 var x = (i % num_cols); 12 var y = Math.floor(i / num_cols); // affectint division13 33 var y = Math.floor(i / num_cols); // effectively int division 34 14 35 // Transpose, and then reverse engineer what value of 'i' the transposed position needs to be 15 36 var trans_x = y; … … 18 39 var trans_i = trans_y * num_rows + trans_x; 19 40 41 // Filler correction 42 //if ((x > full_cols_until) && (trans_y < (num_cols-1))) { 43 if (x > full_cols_until) { 44 trans_i = trans_i - (num_cols - x) 45 } 46 20 47 return trans_i; 21 48 } … … 50 77 51 78 for (var i=0; i<num_cells; i++) { 52 var trans_i = transpose_i(i,num_cols, num_rows );79 var trans_i = transpose_i(i,num_cols, num_rows, num_countries); 53 80 54 81 // By default, they country and points are set to be empty divs … … 70 97 if (typeof from_country_points !== 'undefined') { 71 98 var from_country_base = from_country.replace(/-(T|J)$/,""); 72 var pp_from_country = from_country_base; // in future look to putting spacing back in for countries like United Kingdom 99 100 var pp_from_country = from_country_base; 101 if (pp_country_lookup[pp_from_country]) { 102 pp_from_country = pp_country_lookup[pp_from_country]; 103 } 73 104 74 105 var hyphen_vote_type = from_country.match(/-(?:T|J)$/); … … 160 191 for (var i=0; i<num_cells; i++) { 161 192 162 var trans_i = transpose_i(i,num_cols, num_rows );193 var trans_i = transpose_i(i,num_cols, num_rows, num_countries); 163 194 164 195 var $to_country_name = $('<div>').attr("class","voting voting-country").append("");
Note:
See TracChangeset
for help on using the changeset viewer.