~williamvds/firmstep-test

fa1b0464ec7e30d5f6952e6edbe98009f2a96eaf — williamvds 6 years ago 4adb4ec
clear button functionality
2 files changed, 14 insertions(+), 1 deletions(-)

M index.html
M js/app.js
M index.html => index.html +1 -1
@@ 45,7 45,7 @@
							<label><input type="checkbox" value=12>12 Mpx</label>
							<label><input type="checkbox" value=15>15 Mpx</label>
						</div>
						<button>Clear filters</button>
						<button type="button" onclick="clearFilters()">Clear filters</button>
					</form>
				</div>
			</div>

M js/app.js => js/app.js +13 -0
@@ 113,6 113,19 @@ function filterListener(par) {
  applyFilters();
}

function clearFilters() {
  var inputs = document.getElementsByTagName('input');
  for (var k in inputs) {
    var input = inputs[k];
    if (typeof input !== 'object') continue;

    input.checked = false;
    input.onchange();
  }

  applyFilters();
}

document.addEventListener('DOMContentLoaded', function() {
  ajax('products.json', function(dict) {
    phoneDetails = dict;