The Wayback Machine - https://web.archive.org/web/20151104000753/http://arstechnica.com/business/
');
var sprite_url = '//web.archive.org/web/20151104000753/http://cdn.arstechnica.net/wp-content/uploads/2015/09/lg-sprites.png';
var sprites = [
{label: 'logo', left: 961, top: 13, width: 47, height: 21, x: 0, y: 0},
{label: 'tv', left: 529, top: 5, width: 484, height: 338, x: 0, y: -40},
{label: 'not', left: 202, top: 87, width: 186, height: 16, x: 0, y: -400},
{label: 'new', left: 65, top: 125, width: 461, height: 16, x: 0, y: -450},
{label: 'rule', left: 235, top: 164, width: 119, height: 1, x: 0, y: -500},
{label: 'lgoledtv', left: 236, top: 189, width: 118, height: 18, x: 0, y: -540},
{label: 'experts', left: 236, top: 221, width: 121, height: 15, x: 0, y: -600},
{label: 'best', left: 222, top: 242, width: 37, height: 11, x: 0, y: -640},
{label: 'picture', left: 264, top: 242, width: 62, height: 11, x: 0, y: -680},
{label: 'ever', left: 331, top: 242, width: 39, height: 10, x: 0, y: -720},
{label: 'btn-learn', left: 162, top: 270, width: 112, height: 26, x: 0, y: -760},
{label: 'btn-lights', left: 293, top: 270, width: 135, height: 26, x: 0, y: -817},
{label: 'drag', left: 125, top: 315, width: 340, height: 15, x: 0, y: -930}
];
for (var q = 0; q < sprites.length; q++) {
var div = $('
'),
sprite = sprites[q];
div.attr('id', 'lg-sprite-' + sprite.label);
div.css({
'position': 'absolute',
'left': sprite.left + 'px',
'top': sprite.top + 'px',
'width': sprite.width + 'px',
'height': sprite.height + 'px',
'background-image': 'url(' + sprite_url + ')',
'background-repeat': 'no-repeat',
'background-position': sprite.x + 'px ' + sprite.y + 'px',
'opacity': '0'
});
pushdown.append(div);
}
// Add tracking pixels
var pixels = $('
');
pixels.append('
%20+%20')
');
pixels.append('
%20+%20')
');
pixels.append(tracking[day_label].bill_com);
pushdown.append(pixels);
// Place entire initialized pushdown
$('#pushdown-wrap').append(pushdown);
// Animate elements in
setTimeout((function() {
$('#lg-sprite-logo').animate({opacity:1}, {duration:1000});
}), 1000);
setTimeout((function() {
$('#lg-sprite-tv').animate({opacity:1}, {duration:4000});
}), 1500);
setTimeout((function() {
$('#lg-sprite-not').animate({opacity:1}, {duration:1000});
}), 2000);
setTimeout((function() {
$('#lg-sprite-new').animate({opacity:1}, {duration:1000});
}), 2500);
setTimeout((function() {
$('#lg-sprite-rule').animate({opacity:1}, {duration:1000});
}), 3000);
setTimeout((function() {
$('#lg-sprite-lgoledtv').animate({opacity:1}, {duration:1000});
}), 3000);
setTimeout((function() {
$('#lg-sprite-experts').animate({opacity:1}, {duration:1000});
}), 3500);
setTimeout((function() {
$('#lg-sprite-best').animate({opacity:1}, {duration:500});
}), 4000);
setTimeout((function() {
$('#lg-sprite-picture').animate({opacity:1}, {duration:500});
}), 4750);
setTimeout((function() {
$('#lg-sprite-ever').animate({opacity:1}, {duration:500});
}), 5500);
setTimeout((function() {
$('#lg-sprite-btn-learn').animate({opacity:1}, {duration:500});
}), 5750);
setTimeout((function() {
$('#lg-sprite-btn-lights').animate({opacity:1}, {duration:500});
}), 6000);
setTimeout((function() {
$('#lg-sprite-drag').animate({opacity:1}, {duration:500});
}), 6250);
// Button hovers
$('#lg-sprite-btn-learn, #lg-sprite-btn-lights').hover(
function() {
var btn = $(this),
bg_y = btn.css('background-position').split(' ')[1];
btn.css({'background-position': '-161px ' + bg_y});
},
function() {
var btn = $(this),
bg_y = btn.css('background-position').split(' ')[1];
btn.css({'background-position': '0px ' + bg_y});
}
);
// CTA button and entire div
$('#lg-sprite-btn-learn, #lg-pushdown').on('click', function() {
window.location = tracking[day_label].bill_clk + pixel_ts();
});
// Add lights-off button
var lights_on = false,
lights_btn = $('#lg-sprite-btn-lights')
scroll_pos = 0;
lights_btn.on('click', function(evt) {
evt.stopPropagation();
var canvas = $('#lg-canvas');
pixels.append('
%20+%20')
');
pixels.append('
%20+%20')
');
pixels.append(tracking.dark_com);
if (lights_on) {
// Turn off
lights_on = false;
lights_btn.css({'background-position': '0px -817px'});
canvas.css({
'z-index': '10'
});
body.css({
'overflow': 'auto'
});
pushdown.css({
'z-index': '10',
'left': '0'
});
// Track lights on with pixel
// Restore previous scroll position
$('html, body').stop().animate({scrollTop:scroll_pos}, {duration:300});
}
else {
// Turn on
lights_on = true;
lights_btn.css({'background-position': '0px -870px'});
var left_init = pushdown.offset().left,
left_final;
canvas.css({
'z-index': '90001'
});
body.css({
'overflow': 'hidden'
});
// Does scrollbar removal change width?
left_final = pushdown.offset().left;
pushdown.css({
'z-index': '90002',
'left': String(left_init - left_final) + 'px'
});
// Record scroll pos
scroll_pos = win.scrollTop();
// Track lights off with pixel
// Scroll to top for full ad
$('html, body').stop().animate({scrollTop:0}, {duration:300});
}
});
// Add logos
if (win.width() >= 1550) {
// Track addition of logos
pixels.append('
%20+%20')
');
pixels.append('
%20+%20')
');
pixels.append(tracking[day_label].wall_com);
var logos = $('
');
logos.find('img').on('click', function() {
window.location = tracking[day_label].wall_clk + pixel_ts();
});
$('body').append(logos);
win.scroll(function() {
var fade = null;
logos.css(
'top',
String(win.height()/2 - logos.find('img:last-child').height()/2) + 'px'
);
// Fade in or out
if (win.scrollTop() > 200) {
if (logos.hasClass('lg-logo-showing')) {
return;
}
logos.addClass('lg-logo-showing');
}
else {
if (logos.hasClass('lg-logo-showing')) {
logos.removeClass('lg-logo-showing');
}
}
});
}
// Add close button
var close_btn = $('
X
');
close_btn.on('click', function(evt) {
evt.stopPropagation();
if (!had_dark) {
body.removeClass("dark").addClass("light");
}
// Remove canvas, pushdown, logos, stylesheet
cvs.remove();
pushdown.remove();
$('#lg-logos').remove();
$('#lg-styles').remove();
body.css({'overflow': 'auto'});
// Set cookie
ars.create_cookie('lg_takeover', 'off', 100);
exp_tablet(false);
});
pushdown.append(close_btn);
// Cursor movement
// Thanks to AMAZING CODE from Nik Rowell
// http://codepen.io/nikrowell/pen/BNdaKV
// Ultraviolet
// ------------------------------------------------------
// Inspired by the album "Save Your Heart" by Lights and Motion
// http://labs.nikrowell.com/lightsandmotion/ultraviolet
// http://deepelmdigital.com/album/save-your-heart
var ctx,
hue,
buffer,
target = {},
tendrils = [],
settings = {};
settings.debug = false;
settings.friction = 0.5;
settings.trails = 10;
settings.size = 60;
settings.dampening = 0.25;
settings.tension = 0.98;
Math.TWO_PI = Math.PI * 2;
// ========================================================================================
// Oscillator
// ----------------------------------------------------------------------------------------
function Oscillator(options) {
this.init(options || {});
}
Oscillator.prototype = (function() {
var value = 0;
return {
init: function(options) {
this.phase = options.phase || 0;
this.offset = options.offset || 0;
this.frequency = options.frequency || 0.001;
this.amplitude = options.amplitude || 1;
},
update: function() {
this.phase += this.frequency;
value = this.offset + Math.sin(this.phase) * this.amplitude;
return value;
},
value: function() {
return value;
}
};
})();
// ========================================================================================
// Tendril
// ----------------------------------------------------------------------------------------
function Tendril(options) {
this.init(options || {});
}
Tendril.prototype = (function() {
function Node() {
this.x = 0;
this.y = 0;
this.vy = 0;
this.vx = 0;
}
return {
init: function(options) {
this.spring = options.spring + (Math.random() * 0.1) - 0.05;
this.friction = settings.friction + (Math.random() * 0.01) - 0.005;
this.nodes = [];
for(var i = 0, node; i < settings.size; i++) {
node = new Node();
node.x = target.x;
node.y = target.y;
this.nodes.push(node);
}
},
update: function() {
var spring = this.spring,
node = this.nodes[0];
node.vx += (target.x - node.x) * spring;
node.vy += (target.y - node.y) * spring;
for(var prev, i = 0, n = this.nodes.length; i < n; i++) {
node = this.nodes[i];
if(i > 0) {
prev = this.nodes[i - 1];
node.vx += (prev.x - node.x) * spring;
node.vy += (prev.y - node.y) * spring;
node.vx += prev.vx * settings.dampening;
node.vy += prev.vy * settings.dampening;
}
node.vx *= this.friction;
node.vy *= this.friction;
node.x += node.vx;
node.y += node.vy;
spring *= settings.tension;
}
},
draw: function() {
var x = this.nodes[0].x,
y = this.nodes[0].y,
a, b;
ctx.beginPath();
ctx.moveTo(x, y);
for(var i = 1, n = this.nodes.length - 2; i < n; i++) {
a = this.nodes[i];
b = this.nodes[i + 1];
x = (a.x + b.x) * 0.5;
y = (a.y + b.y) * 0.5;
ctx.quadraticCurveTo(a.x, a.y, x, y);
}
a = this.nodes[i];
b = this.nodes[i + 1];
ctx.quadraticCurveTo(a.x, a.y, b.x, b.y);
ctx.stroke();
ctx.closePath();
}
};
})();
// ----------------------------------------------------------------------------------------
function reset() {
tendrils = [];
for(var i = 0; i < settings.trails; i++) {
tendrils.push(new Tendril({
spring: 0.45 + 0.025 * (i / settings.trails)
}));
}
}
function loop() {
ctx.globalCompositeOperation = 'source-over';
ctx.fillStyle = 'rgba(8,5,16,0.4)';
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
ctx.globalCompositeOperation = 'lighter';
ctx.strokeStyle = 'hsla(' + Math.round(hue.update()) + ',90%,50%,0.5)';
ctx.lineWidth = 2;
for(var i = 0, tendril; i < settings.trails; i++) {
tendril = tendrils[i];
tendril.update();
tendril.draw();
}
requestAnimFrame(loop);
}
function resize() {
ctx.canvas.width = window.innerWidth;
ctx.canvas.height = window.innerHeight;
}
function mousemove(event) {
target.x = event.clientX
target.y = event.clientY;
}
window.requestAnimFrame = (function() {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(fn) { window.setTimeout(fn, 1000 / 60) };
})();
window.onload = function() {
ctx = document.getElementById('lg-canvas').getContext('2d');
hue = new Oscillator({
phase: Math.random() * Math.TWO_PI,
amplitude: 85,
frequency: 0.020,
offset: 285
});
document.body.addEventListener('orientationchange', resize);
window.addEventListener('resize', resize);
document.addEventListener('mousemove', mousemove);
target.x = $(window).width()/2;
target.y = 300;
resize();
reset();
loop();
};
};
var exp_tablet = function(add_tracking) {
add_tracking = typeof add_tracking !== 'undefined' ? add_tracking : true;
var img = '//web.archive.org/web/20151104000753/http://cdn.arstechnica.net/wp-content/uploads/2015/10/LG-OLED-Takeover-Unit.png',
// stylesheet = $("
');
pixels.css({'opacity': '0'});
pushdown.css({'background-color': 'black', 'position': 'relative'});
body.css({'background-color': 'black'});
// Add override styles
//body.append(stylesheet);
// Add dark styles
//body.removeClass("light").addClass("dark");
// Insert image with clickthrough
pushdown.append('