| 1 |
"use strict"; |
| 2 |
|
| 3 |
function updatePlatforms() { |
| 4 |
var doFilter = document.getElementById("platform-filter").checked; |
| 5 |
$(".library-platform").removeClass("library-platform-required"); |
| 6 |
if (doFilter) { |
| 7 |
$("#platform-filter-group").show(); |
| 8 |
} else { |
| 9 |
$("#platform-filter-group").hide(); |
| 10 |
$(".library-row").removeClass("not-available").removeClass("available"); |
| 11 |
return; |
| 12 |
} |
| 13 |
|
| 14 |
var platformCheckboxes = $(".platform-checkbox"); |
| 15 |
var wantedPlatforms = []; |
| 16 |
platformCheckboxes.each(function(idx, checkbox) { |
| 17 |
if (checkbox.checked) { |
| 18 |
var platform = checkbox.getAttribute("data-platform"); |
| 19 |
wantedPlatforms.push(platform); |
| 20 |
} |
| 21 |
}); |
| 22 |
for (var idx=0; idx < wantedPlatforms.length; ++idx) { |
| 23 |
var platform = wantedPlatforms[idx]; |
| 24 |
$(".library-platform-" + platform).addClass("library-platform-required"); |
| 25 |
}; |
| 26 |
$(".library-row").each(function(idx, tr) { |
| 27 |
var fwPlatforms = tr.getAttribute("data-platforms").split(","); |
| 28 |
var show = wantedPlatforms.every(function(platform) { |
| 29 |
return fwPlatforms.indexOf(platform) != -1; |
| 30 |
}); |
| 31 |
if (show) { |
| 32 |
$(tr).removeClass("not-available").addClass("available"); |
| 33 |
} else { |
| 34 |
$(tr).removeClass("available").addClass("not-available"); |
| 35 |
} |
| 36 |
}); |
| 37 |
} |
| 38 |
|
| 39 |
var g_noteTip; |
| 40 |
var g_currentlyDescribedElement; |
| 41 |
|
| 42 |
function initNoteTip() { |
| 43 |
g_noteTip = new NoteTip(); |
| 44 |
g_noteTip.onHide = function() { |
| 45 |
g_currentlyDescribedElement = null; |
| 46 |
} |
| 47 |
|
| 48 |
$(".library-platform > a").click(function() { |
| 49 |
if (g_currentlyDescribedElement == this) { |
| 50 |
g_noteTip.hide(); |
| 51 |
} else { |
| 52 |
g_currentlyDescribedElement = this; |
| 53 |
var text = this.getAttribute("data-note"); |
| 54 |
g_noteTip.setText(text); |
| 55 |
g_noteTip.show(this); |
| 56 |
} |
| 57 |
return false; |
| 58 |
}); |
| 59 |
} |
| 60 |
|
| 61 |
function main() { |
| 62 |
$("#platform-filter").click(updatePlatforms); |
| 63 |
$(".platform-checkbox").click(updatePlatforms); |
| 64 |
initNoteTip(); |
| 65 |
} |