Skip to content

Instantly share code, notes, and snippets.

@pimlinders
Last active September 14, 2017 14:39
Show Gist options
  • Save pimlinders/9625fb60ed594bc1a1064b7cc0072fcb to your computer and use it in GitHub Desktop.
Save pimlinders/9625fb60ed594bc1a1064b7cc0072fcb to your computer and use it in GitHub Desktop.
Copy existing and select static web sites.
/* Get site selection */
var sites = document.getElementById('id_sites').querySelectorAll('option');
selected_values = [];
for (var i=0; i<sites.length; i+=1) {
var site = sites[i];
if (site.selected === true) {
selected_values.push(site.value);
}
}
console.log('[' + selected_values.toString() + ']');
/*
Make site selection
Update sites_values if need be
*/
var sites = document.getElementById('id_sites').querySelectorAll('option'),
sites_values = [152,59,48,38,111,56,147,114,42,184,136,115,39,25,63,64,182,116,27,24,178,153,83,156,91,188,28,52,154,2,23,60,137,146,125,155,171,149,166,150,69,161,30,58,139,162,151,143,185,51,70,26,50,82,134,81,72,180,3,163,87,124,33,173,187,181,118,112,62,157,164,80,61,119,138,120,73,35,85,176,121,34,44,66,204,71,110,45,122,67,46,93,86,165,175,144,183,36,158,159,49,75,92,160,88,31,76,47,177,32,29,55,53,179,148,108,117,90,74,54,68,113,89,186,172,8,174,84,77,78,168,167,123],
selected_sites = [];
for (var i=0; i<sites.length; i+=1) {
var site = sites[i];
if (sites_values.indexOf(parseInt(site.value)) !== -1) {
site.selected = true;
selected_sites.push(site.text);
}
else {
site.selected = false;
}
}
console.log(JSON.stringify(selected_sites));
@mitchthorson
Copy link

hey man, one site was missing from this script (northjersey.com). I forked and made an update, but might want to make the change here too:

https://gist.github.com/mitchthorson/81cae455779b7dd4810343c2698e2800/revisions

@pimlinders
Copy link
Author

updated

@pimlinders
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment