Skip to content

Instantly share code, notes, and snippets.

@gotmayonase
Created October 15, 2015 22:50
Show Gist options
  • Save gotmayonase/9a3faffb1a71ab1e1f2a to your computer and use it in GitHub Desktop.
Save gotmayonase/9a3faffb1a71ab1e1f2a to your computer and use it in GitHub Desktop.
$('.glyphicon-check').map(function(i, e) {
var $e = $(e)
var variant = $e.parents('.variant');
var snippet = $e.parents('.snippet');
var variant_name = $(variant).find('.variant-name').val();
var snippet_name = $(snippet).find('.panel-title').clone().children().remove().end().text();
return snippet_name + '--' + variant_name;
}).toArray().join(',');
function parse_assigments(string) {
var assignments = {};
$.each(string.split(','), function(i,e) {
var _split = e.split('--');
assignments[_split[0]] = _split[1];
});
$.each($('.snippet'), function(i, snippet){
var snippet_name = $(snippet).find('.panel-title').clone().children().remove().end().text();
variant = assignments[snippet_name];
var button = $(snippet).find('input[value="' + variant + '"]').parents('.variant').find('.variant-choice button:not(.active)');
if(button.length == 1) {
button.click();
console.log('Found 1 inactive button for: ' + snippet_name + ' -- ' + variant)
} else if(button.length > 1) {
console.log('Found more than 1 button for: ' + snippet_name + ' -- ' + variant);
} else {
console.log('None found for: ' + snippet_name + ' -- ' + variant);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment