The version of vichan running on lainchan.org
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.0KB

  1. $('document').ready(function () {
  2. var autoScroll = localStorage['autoScroll'] ? true : false;
  3. if (window.Options && Options.get_tab('general')){
  4. Options.extend_tab('general','<label id=\'autoScroll\'><input type=\'checkbox\' />' + ' Scroll to new posts' + '</label>');
  5. $('#autoScroll').find('input').prop('checked', autoScroll);
  6. }
  7. $('#autoScroll').on('change', function() {
  8. if(autoScroll) {
  9. delete localStorage.autoScroll;
  10. } else {
  11. localStorage.autoScroll = true;
  12. }
  13. autoScroll =! autoScroll
  14. if(active_page == 'thread')
  15. $('input.auto-scroll').prop('checked', autoScroll);
  16. });
  17. if (active_page == 'thread') {
  18. $('span[id="updater"]').children('a').after(' (<input class="auto-scroll" type="checkbox"></input> Scroll to New posts)');
  19. $('input.auto-scroll').prop('checked', autoScroll);
  20. $(document).on('new_post', function (e, post) {
  21. if ($('input.auto-scroll').prop('checked'))
  22. {
  23. scrollTo(0, $(post).offset().top - window.innerHeight + $(post).outerHeight(true));
  24. }
  25. });
  26. }
  27. });