https://github.com/angular/angular
Raw File
Tip revision: 059e09c3be57722a2572157d89826b72018c4ca1 authored by Igor Minar on 15 December 2015, 11:01:04 UTC
chore(release): cut alpha.54 - rxjs bundle separation
Tip revision: 059e09c
url_params_to_form.js
// helper script that will read out the url parameters
// and store them in appropriate form fields on the page
(function() {
  var regex = /(\w+)=(\w+)/g;
  var search = decodeURIComponent(location.search);
  while (match = regex.exec(search)) {
    var name = match[1];
    var value = match[2];
    var els = document.querySelectorAll('input[name="'+name+'"]');
    var el;
    for (var i=0; i<els.length; i++) {
      el = els[i];
      if (el.type === 'radio' || el.type === 'checkbox') {
        el.checked = el.value === value;
      } else {
        el.value = value;
      }
    }
  }
})();
back to top