Permalink
...
Comparing changes
Open a pull request
- 1 commit
- 8 files changed
- 0 commit comments
- 1 contributor
Commits on Mar 13, 2015
|
|
ctrlcctrlv |
8aad0de
|
Unified
Split
Showing
with
52 additions
and 13 deletions.
- +1 −1 inc/config.php
- +0 −1 inc/instance-config.php
- +50 −10 js/auto-reload.js
- BIN static/favicon-error.ico
- BIN static/favicon-quoted.ico
- BIN static/favicon-reply.ico
- BIN static/favicon.ico
- +1 −1 templates/header.html
View
2
inc/config.php
| @@ -1230,7 +1230,7 @@ function($matches) { | ||
| // $config['url_javascript'] = 'http://static.example.org/main.js'; | ||
| // Website favicon. | ||
| - // $config['url_favicon'] = '/favicon.gif'; | ||
| + $config['url_favicon'] = 'static/favicon.ico'; | ||
| // EXPERIMENTAL: Try not to build pages when we shouldn't have to. | ||
| $config['try_smarter'] = true; | ||
View
1
inc/instance-config.php
| @@ -113,7 +113,6 @@ | ||
| $config['additional_javascript'][] = 'js/local-time.js'; | ||
| $config['additional_javascript'][] = 'js/no-animated-gif.js'; | ||
| $config['additional_javascript'][] = 'js/expand.js'; | ||
| - $config['additional_javascript'][] = 'js/titlebar-notifications.js'; | ||
| $config['additional_javascript'][] = 'js/auto-reload.js'; | ||
| $config['additional_javascript'][] = 'js/options/user-css.js'; | ||
| $config['additional_javascript'][] = 'js/options/user-js.js'; | ||
View
60
js/auto-reload.js
| @@ -8,7 +8,7 @@ | ||
| * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org> | ||
| * Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net> | ||
| * Copyright (c) 2013 undido <firekid109@hotmail.com> | ||
| - * Copyright (c) 2014 Fredrick Brennan <admin@8chan.co> | ||
| + * Copyright (c) 2014-2015 Fredrick Brennan <admin@8chan.co> | ||
| * | ||
| * Usage: | ||
| * $config['additional_javascript'][] = 'js/jquery.min.js'; | ||
| @@ -17,34 +17,69 @@ | ||
| * | ||
| */ | ||
| +function makeIcon(mode){ | ||
| + var favicon = $("link[rel='shortcut icon']"); | ||
| -au = false; | ||
| -auto_reload_enabled = true; // for watch.js to interop | ||
| + if (!favicon.length) { | ||
| + var favicon = $('<link rel="shortcut icon"></link>').appendTo('head'); | ||
| + } | ||
| -function makeIcon(){ | ||
| - if(au) return; | ||
| - au = true; | ||
| - $("link[rel='icon']").attr("href", "../static/favicon_au.png"); | ||
| + $("link[rel='shortcut icon']").attr("href", configRoot+"static/favicon"+(mode?"-"+mode:"")+".ico"); | ||
| } | ||
| ++function(){ | ||
| +var notify = false; | ||
| +auto_reload_enabled = true; // for watch.js to interop | ||
| + | ||
| $(document).ready(function(){ | ||
| // Adds Options panel item | ||
| if (typeof localStorage.auto_thread_update === 'undefined') { | ||
| localStorage.auto_thread_update = 'true'; //default value | ||
| } | ||
| if (window.Options && Options.get_tab('general')) { | ||
| - Options.extend_tab('general', '<label id="auto-thread-update"><input type="checkbox">' + _('Auto update thread') + '</label>'); | ||
| + Options.extend_tab("general", "<fieldset><legend>"+_("Auto update")+"</legend>" | ||
| + + ('<label id="auto-thread-update"><input type="checkbox">' + _('Auto update thread') + '</label>') | ||
| + + ('<label id="auto_thread_desktop_notifications"><input type="checkbox">' + _('Show desktop notifications when users quote me') + '</label>') | ||
| + + ('<label id="auto_thread_desktop_notifications_all"><input type="checkbox">' + _('Show desktop notifications on all replies') + '</label>') | ||
| + + '</fieldset>'); | ||
| + | ||
| $('#auto-thread-update>input').on('click', function() { | ||
| if ($('#auto-thread-update>input').is(':checked')) { | ||
| localStorage.auto_thread_update = 'true'; | ||
| } else { | ||
| localStorage.auto_thread_update = 'false'; | ||
| } | ||
| }); | ||
| + | ||
| + $('#auto_thread_desktop_notifications>input,#auto_thread_desktop_notifications_all>input').on('click', function() { | ||
| + if (!("Notification" in window)) return; | ||
| + | ||
| + var setting = $(this).parent().attr('id'); | ||
| + | ||
| + if ($(this).is(':checked')) { | ||
| + Notification.requestPermission(); | ||
| + if (Notification.permission === "granted") { | ||
| + localStorage[setting] = 'true'; | ||
| + } | ||
| + } else { | ||
| + localStorage[setting] = 'false'; | ||
| + } | ||
| + }); | ||
| + | ||
| if (localStorage.auto_thread_update === 'true') { | ||
| $('#auto-thread-update>input').prop('checked', true); | ||
| } | ||
| + | ||
| + if (localStorage.auto_thread_desktop_notifications === 'true') { | ||
| + $('#auto_thread_desktop_notifications>input').prop('checked', true); | ||
| + notify = "mention"; | ||
| + } | ||
| + | ||
| + if (localStorage.auto_thread_desktop_notifications_all === 'true') { | ||
| + $('#auto_thread_desktop_notifications_all>input').prop('checked', true); | ||
| + notify = "all"; | ||
| + } | ||
| } | ||
| // not thread | ||
| @@ -84,6 +119,7 @@ $(document).ready(function(){ | ||
| document.title = "("+new_posts+") "+title; | ||
| } else { | ||
| document.title = title; | ||
| + makeIcon(false); | ||
| } | ||
| }; | ||
| } | ||
| @@ -178,7 +214,11 @@ $(document).ready(function(){ | ||
| if($('#' + id).length == 0) { | ||
| if (!new_posts) { | ||
| first_new_post = this; | ||
| - makeIcon(); | ||
| + makeIcon('reply'); | ||
| + if (notify === "all" || (notify === "mention" && $(this).find('.own_post').length)) { | ||
| + var body = $(this).children('.body').html().replace(/<br\s*[\/]?>/gi, "\n"); | ||
| + var n = new Notification("New reply to "+$('title').text(), {body: $('<div/>').html(body).text()}); | ||
| + } | ||
| } | ||
| $(this).insertAfter($('div.post:not(.post-hover):last').next()).after('<br class="clear">'); | ||
| new_posts++; | ||
| @@ -264,4 +304,4 @@ $(document).ready(function(){ | ||
| auto_update(poll_interval_delay); | ||
| } | ||
| }); | ||
| - | ||
| +}(); | ||
View
BIN
static/favicon-error.ico
Binary file not shown.
View
BIN
static/favicon-quoted.ico
Binary file not shown.
View
BIN
static/favicon-reply.ico
Binary file not shown.
View
BIN
static/favicon.ico
Binary file not shown.
View
2
templates/header.html
| @@ -1,5 +1,5 @@ | ||
| <link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}"> | ||
| - {% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}">{% endif %} | ||
| + {% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.root }}{{ config.url_favicon }}">{% endif %} | ||
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes"> | ||
| {% if config.meta_keywords %}<meta name="keywords" content="{{ config.meta_keywords }}">{% endif %} | ||