Difference between revisions of "Template:Northeastern Boston/Javascript"

Line 1: Line 1:
 
<html>
 
<html>
 
<script>
 
<script>
 +
 +
changeSVGChildrenColor = function(element, color) {
 +
$(element).children().each(function ()
 +
{ $(this).css('fill', color); }
 +
)
 +
}
  
 
$(document).ready(function() {
 
$(document).ready(function() {
 
$('#comingSoon').height($(window).height());
 
$('#comingSoon').height($(window).height());
 
});
 
});
 +
 +
document.getElementById("comingSoon").addEventListener("load", function() {
 +
    var doc = this.getSVGDocument();
 +
    logo = doc.getElementById('Logo_Logo');
 +
    colorGradient(logo,'#26db80','#50e2de', 10, 30);
 +
 +
    /*var rect = doc.querySelector("rect"); // suppose our image contains a <rect>
 +
    rect.setAttribute("fill", "green");*/
 +
});
 +
 +
colorGradient = function (element, start, stop, numberOfColors, opm) {
 +
var numberOfItems = numberOfColors;
 +
var rainbow = new Rainbow();
 +
rainbow.setNumberRange(1, numberOfItems);
 +
rainbow.setSpectrum(start, stop);
 +
var colors = [];
 +
for (var i = 1; i <= numberOfItems; i++) {
 +
    var hexColour = rainbow.colourAt(i);
 +
    colors[i - 1] = '#' + hexColour;
 +
}
 +
var reversed = [];
 +
$(colors).each(function(i) {reversed[i] = this});
 +
reversed.reverse();
 +
oscillation =  jQuery.merge(colors, reversed);
 +
 +
 +
/*var interval = setInterval(function () {changeColor(element, oscillation[i % (numberOfColors * 2)]);}, 1000}); */
 +
var i = 0;
 +
var interval = setInterval(function ()
 +
{ changeSVGChildrenColor(element, oscillation[i % (numberOfColors * 2)]);
 +
i += 1;
 +
}, 300);
 +
 +
}
 +
 +
changeColor = function(element, color) {
 +
$(element).css('color', color);
 +
}
 +
  
 
</script>
 
</script>
 
</html>
 
</html>

Revision as of 02:50, 16 July 2015