h5ai/test/util/pin.js

39 lines
862 B
JavaScript
Raw Normal View History

2015-04-22 11:12:45 -04:00
(function () {
'use strict';
2015-04-22 17:50:16 -04:00
var title;
2015-04-29 08:23:15 -04:00
var htmlId;
2015-04-22 11:12:45 -04:00
var htmlClasses;
2015-04-29 08:23:15 -04:00
var bodyId;
var bodyClasses;
2015-04-22 11:12:45 -04:00
var $pinnedElements;
function pinHtml() {
2015-04-22 17:50:16 -04:00
title = document.title;
2015-04-29 08:23:15 -04:00
htmlId = $('html').attr('id');
2015-04-22 11:12:45 -04:00
htmlClasses = $('html').attr('class');
2015-04-29 08:23:15 -04:00
bodyId = $('body').attr('id');
bodyClasses = $('body').attr('class');
2015-04-22 11:12:45 -04:00
$pinnedElements = $('head,body').children();
}
function restoreHtml() {
2015-04-22 17:50:16 -04:00
document.title = title;
2015-04-29 08:23:15 -04:00
$('html').attr('id', htmlId);
2015-04-22 11:12:45 -04:00
$('html').attr('class', htmlClasses);
2015-04-29 08:23:15 -04:00
$('body').attr('id', bodyId);
$('body').attr('class', bodyClasses);
2015-04-22 11:12:45 -04:00
$('head,body').children().not($pinnedElements).remove();
2015-04-29 08:23:15 -04:00
if (window.localStorage && window.localStorage.clear) {
window.localStorage.clear();
}
2015-04-22 11:12:45 -04:00
}
window.util = window.util || {};
window.util.pinHtml = pinHtml;
window.util.restoreHtml = restoreHtml;
}());