1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-29 09:44:28 +01:00
vichan/js/disable-styles.js

36 lines
1.4 KiB
JavaScript
Raw Normal View History

2014-11-20 20:39:20 +01:00
/* Adds a checkbox in the General options tab to disable and enable board style sheets. */
2014-11-20 21:12:40 +01:00
$(document).ready(function () {
2014-11-20 20:39:20 +01:00
var disableStyles = localStorage['disablestylesheet'] ? true : false;
2014-11-20 21:12:40 +01:00
/* only search for and disable board stylesheets if the user is on a page that uses them */
if(active_page == 'ukko' || active_page == 'thread' || active_page == 'index' || active_page == 'catalog')
{
var i = 0
while(i<document.styleSheets.length) {
var protAndHost = window.location.protocol + '//' + window.location.host
if(document.styleSheets[i].href == protAndHost + $('link[id="stylesheet"]').attr('href'))
{
var sheet = i
document.styleSheets[sheet].disabled = disableStyles
break
}
i++
2014-11-20 20:39:20 +01:00
}
}
2014-11-20 21:12:40 +01:00
/* add the option on all pages so that the user doesn't need to goto a board to toggle it */
2014-11-20 20:39:20 +01:00
if (window.Options && Options.get_tab('general')){
Options.extend_tab('general','<label id=\'disablestyle\'><input type=\'checkbox\' />' + ' Disable board specific style sheets' + '</label>')
2014-11-20 21:12:40 +01:00
$('#disablestyle').find('input').prop('checked', disableStyles)
2014-11-20 20:39:20 +01:00
}
2014-11-20 21:12:40 +01:00
$('#disablestyle').on('change', function() {
2014-11-20 20:39:20 +01:00
if(disableStyles) {
2014-11-20 21:12:40 +01:00
delete localStorage.disablestylesheet
2014-11-20 20:39:20 +01:00
} else {
2014-11-20 21:12:40 +01:00
localStorage.disablestylesheet = true
2014-11-20 20:39:20 +01:00
}
2014-11-20 21:12:40 +01:00
disableStyles =! disableStyles
if(active_page == 'ukko' || active_page == 'thread' || active_page == 'index' || active_page == 'catalog') document.styleSheets[sheet].disabled = disableStyles
2014-11-20 20:39:20 +01:00
})
2014-11-20 21:12:40 +01:00
})