Last active
September 25, 2015 19:08
-
-
Save defektive/78f1e30ab19a15dab662 to your computer and use it in GitHub Desktop.
Scriptlet for firework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CherryChapstick = (function (){ | |
// Here is a bookmarklet | |
// javascript:(function()%7Bvar%20CherryChapstick%20%3D%20(function%20()%7Bfunction%20setupDom%20()%7Bif(window._cherryChapstick)%20%7Breturn%3B%7Dwindow._cherryChapstick%20%3D%20true%3B%24(%22body%22).css(%22padding-top%22%2C%20%2260px%22)%3B%24(%22.navbar-default%22).addClass(%22navbar-fixed-top%22)%3B%24(%22.navbar-right%22).before(%24('%3Cul%20class%3D%22nav%20navbar-nav%22%3E%3Cli%3E%3Ca%20href%3D%22%23%22%20class%3D%22toggle-fragile%22%3EToggle%20Fragile%3C%2Fa%3E%3C%2Fli%3E%3C%2Ful%3E'))%3Bvar%20styles%20%3D%20%24(%22%3Cstyle%3E%3C%2Fstyle%3E%22)%3Bstyles.html(%22.result.panel.expanded%20.toggle-group-item%20.glyphicon-chevron-down%20%7Bdisplay%3A%20inline-block%7D%20body.expand-fragile%20.result.panel.panel-warning%2C%20.result.panel.expanded%20.list-group%20%7Bdisplay%3A%20block%7D%20.result.panel.expanded%20.toggle-group-item%20.glyphicon-chevron-right%2C%20.toggle-group-item%20.glyphicon-chevron-down%2C%20.result.panel%20.list-group%2C%20.result.panel.panel-warning%20%7Bdisplay%3A%20none%3B%7D%20.toggle-group-item%2C%20.burn-test-message%2C%20.burn-test-file%20%7Bmargin%3A%201px%205px%3B%20cursor%3A%20pointer%3B%7D%22)%3B%24(%22head%22).append(styles)%3B%24(%22.panel-danger%20.result-details%22).each(function%20(_i%2C%20el)%20%7Bel%20%3D%20%24(el)%3Bel.prepend(%24('%3Cdiv%20class%3D%22details-icon%20pull-left%20burn-test-message%22%20title%3D%22Remove%20failures%20with%20this%20message%22%3E%3Cspan%20class%3D%22text-danger%20glyphicon%20glyphicon-fire%22%3E%3C%2Fspan%3E%3C%2Fdiv%3E'))%3B%7D)%3B%24(%22.panel-danger%20.panel-footer%22).each(function%20(_i%2C%20el)%20%7Bel%20%3D%20%24(el)%3Bel.prepend(%24('%3Cdiv%20class%3D%22details-icon%20pull-left%20burn-test-file%22%20title%3D%22Remove%20failures%20in%20this%20file%22%3E%3Cspan%20class%3D%22text-danger%20glyphicon%20glyphicon-fire%22%3E%3C%2Fspan%3E%3C%2Fdiv%3E'))%3B%7D)%3B%24(%22.panel-danger%20.name-line%22).each(function%20(_i%2C%20el)%20%7Bel%20%3D%20%24(el)%3Bel.prepend(%24('%3Cdiv%20class%3D%22details-icon%20pull-left%20toggle-group-item%22%20title%3D%22Show%20Failure%20Details%22%3E%3Cspan%20class%3D%22text-danger%20glyphicon%20glyphicon-chevron-right%22%3E%3C%2Fspan%3E%3Cspan%20class%3D%22text-danger%20glyphicon%20glyphicon-chevron-down%22%3E%3C%2Fspan%3E%3C%2Fdiv%3E'))%3B%7D)%3B%7Dfunction%20CherryChapstick()%7BsetupDom()%3B%24(%22body%22).on('click'%2C%20'.burn-test-message'%2C%20CherryChapstick.prototype.handleMessageBurn.bind(this))%3B%24(%22body%22).on('click'%2C%20'.burn-test-file'%2C%20CherryChapstick.prototype.handleSpecBurn.bind(this))%3B%24(%22body%22).on('click'%2C%20'.panel-heading'%2C%20CherryChapstick.prototype.handleGroupItemToggle.bind(this))%3B%24(%22body%22).on('click'%2C%20'.toggle-fragile'%2C%20CherryChapstick.prototype.handleToggleFragile.bind(this))%3B%7DCherryChapstick.prototype.handleMessageBurn%20%3D%20function%20(event)%7Bvar%20message%20%3D%20%24(event.target).closest(%22.result-details%22).find(%22.details-text%22).text()%3Bthis.burnMessage(message)%3B%7D%3BCherryChapstick.prototype.handleSpecBurn%20%3D%20function%20(event)%7Bvar%20spec%20%3D%20%24(event.target).closest(%22.panel-footer%22).find(%22.fw-location%22).text().replace(%2F%5C%3A.%2B%24%2Fg%2C%20'')%3Bthis.burnSpec(spec)%3B%7D%3BCherryChapstick.prototype.handleGroupItemToggle%20%3D%20function%20(event)%7B%24(event.target).closest(%22.panel.result%22).toggleClass(%22expanded%22)%3B%7D%3BCherryChapstick.prototype.handleToggleFragile%20%3D%20function%20(event)%7B%24(%22body%22).toggleClass(%22expand-fragile%22)%3B%7D%3BCherryChapstick.prototype.burnMessage%20%3D%20function%20(message)%7B%24(%22.panel-danger%20.details-text%22).each(function%20(_i%2C%20el)%20%7Bel%20%3D%20%24(el)%3Bif(el.text()%20%3D%3D%20message)%20%7B%24(el.closest(%22.panel.result%22).remove())%3B%7D%7D)%3B%7D%3BCherryChapstick.prototype.burnSpec%20%3D%20function%20(spec)%7B%24(%22.panel-danger%20.fw-location%22).each(function%20(_i%2C%20el)%20%7Bel%20%3D%20%24(el)%3Bif(~el.text().indexOf(spec))%20%7B%24(el.closest(%22.panel.result%22).remove())%3B%7D%7D)%3B%7D%3Breturn%20new%20CherryChapstick%3B%7D)()%7D)() | |
function setupDom (){ | |
if(window._cherryChapstick) { | |
return; | |
} | |
window._cherryChapstick = true; | |
$("body").css("padding-top", "60px"); | |
$(".navbar-default").addClass("navbar-fixed-top"); | |
$(".navbar-right").before($('<ul class="nav navbar-nav"><li><a href="#" class="toggle-fragile">Toggle Fragile</a></li></ul>')); | |
var styles = $("<style></style>"); | |
styles.html(".result.panel.expanded .toggle-group-item .glyphicon-chevron-down {display: inline-block} body.expand-fragile .result.panel.panel-warning, .result.panel.expanded .list-group {display: block} .result.panel.expanded .toggle-group-item .glyphicon-chevron-right, .toggle-group-item .glyphicon-chevron-down, .result.panel .list-group, .result.panel.panel-warning {display: none;} .toggle-group-item, .burn-test-message, .burn-test-file {margin: 1px 5px; cursor: pointer;}"); | |
$("head").append(styles); | |
$(".panel-danger .result-details").each(function (_i, el) { | |
el = $(el); | |
el.prepend($('<div class="details-icon pull-left burn-test-message" title="Remove failures with this message"><span class="text-danger glyphicon glyphicon-fire"></span></div>')); | |
}); | |
$(".panel-danger .panel-footer").each(function (_i, el) { | |
el = $(el); | |
el.prepend($('<div class="details-icon pull-left burn-test-file" title="Remove failures in this file"><span class="text-danger glyphicon glyphicon-fire"></span></div>')); | |
}); | |
$(".panel-danger .name-line").each(function (_i, el) { | |
el = $(el); | |
el.prepend($('<div class="details-icon pull-left toggle-group-item" title="Show Failure Details"><span class="text-danger glyphicon glyphicon-chevron-right"></span><span class="text-danger glyphicon glyphicon-chevron-down"></span></div>')); | |
}); | |
} | |
function CherryChapstick(){ | |
setupDom(); | |
$("body").on('click', '.burn-test-message', CherryChapstick.prototype.handleMessageBurn.bind(this)); | |
$("body").on('click', '.burn-test-file', CherryChapstick.prototype.handleSpecBurn.bind(this)); | |
$("body").on('click', '.panel-heading', CherryChapstick.prototype.handleGroupItemToggle.bind(this)); | |
$("body").on('click', '.toggle-fragile', CherryChapstick.prototype.handleToggleFragile.bind(this)); | |
} | |
CherryChapstick.prototype.handleMessageBurn = function (event){ | |
var message = $(event.target).closest(".result-details").find(".details-text").text(); | |
this.burnMessage(message); | |
}; | |
CherryChapstick.prototype.handleSpecBurn = function (event){ | |
var spec = $(event.target).closest(".panel-footer").find(".fw-location").text().replace(/\:.+$/g, ''); | |
this.burnSpec(spec); | |
}; | |
CherryChapstick.prototype.handleGroupItemToggle = function (event){ | |
$(event.target).closest(".panel.result").toggleClass("expanded"); | |
}; | |
CherryChapstick.prototype.handleToggleFragile = function (event){ | |
$("body").toggleClass("expand-fragile"); | |
}; | |
CherryChapstick.prototype.burnMessage = function (message){ | |
$(".panel-danger .details-text").each(function (_i, el) { | |
el = $(el); | |
if(el.text() == message) { | |
$(el.closest(".panel.result").remove()); | |
} | |
}); | |
}; | |
CherryChapstick.prototype.burnSpec = function (spec){ | |
$(".panel-danger .fw-location").each(function (_i, el) { | |
el = $(el); | |
if(~el.text().indexOf(spec)) { | |
$(el.closest(".panel.result").remove()); | |
} | |
}); | |
}; | |
return new CherryChapstick; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment