2017-11-20 06:10:04 +01:00
// Code generated by go generate; DO NOT EDIT.
2018-08-25 06:51:50 +02:00
package static // import "miniflux.app/ui/static"
2017-11-20 06:10:04 +01:00
2018-07-16 06:51:09 +02:00
var Javascripts = map [ string ] string {
2017-12-03 00:01:05 +01:00
"app" : ` ( function ( ) { ' use strict ' ; class DomHelper { static isVisible ( element ) { return element . offsetParent != = null ; }
2018-06-28 08:08:21 +02:00
static openNewTab ( url ) { let win = window . open ( "" ) ; win . opener = null ; win . location = url ; win . focus ( ) ; }
2017-12-03 00:01:05 +01:00
static scrollPageTo ( element ) { let windowScrollPosition = window . pageYOffset ; let windowHeight = document . documentElement . clientHeight ; let viewportPosition = windowScrollPosition + windowHeight ; let itemBottomPosition = element . offsetTop + element . offsetHeight ; if ( viewportPosition - itemBottomPosition < 0 || viewportPosition - element . offsetTop > windowHeight ) { window . scrollTo ( 0 , element . offsetTop - 10 ) ; } }
static getVisibleElements ( selector ) { let elements = document . querySelectorAll ( selector ) ; let result = [ ] ; for ( let i = 0 ; i < elements . length ; i ++ ) { if ( this . isVisible ( elements [ i ] ) ) { result . push ( elements [ i ] ) ; } }
2018-01-19 05:23:26 +01:00
return result ; }
static findParent ( element , selector ) { for ( ; element && element != = document ; element = element . parentNode ) { if ( element . classList . contains ( selector ) ) { return element ; } }
2018-07-11 05:41:27 +02:00
return null ; }
static hasPassiveEventListenerOption ( ) { var passiveSupported = false ; try { var options = Object . defineProperty ( { } , "passive" , { get : function ( ) { passiveSupported = true ; } } ) ; window . addEventListener ( "test" , options , options ) ; window . removeEventListener ( "test" , options , options ) ; } catch ( err ) { passiveSupported = false ; }
return passiveSupported ; } }
2019-07-18 05:27:39 +02:00
class TouchHandler { constructor ( ) { this . reset ( ) ; }
2017-12-03 00:01:05 +01:00
reset ( ) { this . touch = { start : { x : - 1 , y : - 1 } , move : { x : - 1 , y : - 1 } , element : null } ; }
calculateDistance ( ) { if ( this . touch . start . x >= - 1 && this . touch . move . x >= - 1 ) { let horizontalDistance = Math . abs ( this . touch . move . x - this . touch . start . x ) ; let verticalDistance = Math . abs ( this . touch . move . y - this . touch . start . y ) ; if ( horizontalDistance > 30 && verticalDistance < 70 ) { return this . touch . move . x - this . touch . start . x ; } }
return 0 ; }
findElement ( element ) { if ( element . classList . contains ( "touch-item" ) ) { return element ; }
2018-01-19 05:23:26 +01:00
return DomHelper . findParent ( element , "touch-item" ) ; }
2017-12-03 00:01:05 +01:00
onTouchStart ( event ) { if ( event . touches == = undefined || event . touches . length != = 1 ) { return ; }
this . reset ( ) ; this . touch . start . x = event . touches [ 0 ] . clientX ; this . touch . start . y = event . touches [ 0 ] . clientY ; this . touch . element = this . findElement ( event . touches [ 0 ] . target ) ; }
onTouchMove ( event ) { if ( event . touches == = undefined || event . touches . length != = 1 || this . element == = null ) { return ; }
2018-07-18 03:48:56 +02:00
this . touch . move . x = event . touches [ 0 ] . clientX ; this . touch . move . y = event . touches [ 0 ] . clientY ; let distance = this . calculateDistance ( ) ; let absDistance = Math . abs ( distance ) ; if ( absDistance > 0 ) { let opacity = 1 - ( absDistance > 75 ? 0.9 : absDistance / 75 * 0.9 ) ; let tx = distance > 75 ? 75 : ( distance <- 75 ? - 75 : distance ) ; this . touch . element . style . opacity = opacity ; this . touch . element . style . transform = "translateX(" + tx + "px)" ; event . preventDefault ( ) ; } }
2017-12-03 00:01:05 +01:00
onTouchEnd ( event ) { if ( event . touches == = undefined ) { return ; }
2019-07-18 05:27:39 +02:00
if ( this . touch . element != = null ) { let distance = Math . abs ( this . calculateDistance ( ) ) ; if ( distance > 75 ) { toggleEntryStatus ( this . touch . element ) ; }
2018-06-06 20:31:06 +02:00
this . touch . element . style . opacity = 1 ; this . touch . element . style . transform = "none" ; }
2017-12-03 00:01:05 +01:00
this . reset ( ) ; }
2019-07-18 05:27:39 +02:00
listen ( ) { let elements = document . querySelectorAll ( ".touch-item" ) ; let hasPassiveOption = DomHelper . hasPassiveEventListenerOption ( ) ; elements . forEach ( ( element ) = > { element . addEventListener ( "touchstart" , ( e ) = > this . onTouchStart ( e ) , hasPassiveOption ? { passive : true } : false ) ; element . addEventListener ( "touchmove" , ( e ) = > this . onTouchMove ( e ) , hasPassiveOption ? { passive : false } : false ) ; element . addEventListener ( "touchend" , ( e ) = > this . onTouchEnd ( e ) , hasPassiveOption ? { passive : true } : false ) ; element . addEventListener ( "touchcancel" , ( ) = > this . reset ( ) , hasPassiveOption ? { passive : true } : false ) ; } ) ; let entryContentElement = document . querySelector ( ".entry-content" ) ; if ( entryContentElement ) { let doubleTapTimers = { previous : null , next : null } ; const detectDoubleTap = ( doubleTapTimer , event ) = > { const timer = doubleTapTimers [ doubleTapTimer ] ; if ( timer == = null ) { doubleTapTimers [ doubleTapTimer ] = setTimeout ( ( ) = > { doubleTapTimers [ doubleTapTimer ] = null ; } , 200 ) ; } else { event . preventDefault ( ) ; goToPage ( doubleTapTimer ) ; } } ; entryContentElement . addEventListener ( "touchend" , ( e ) = > { if ( e . changedTouches [ 0 ] . clientX >= ( entryContentElement . offsetWidth / 2 ) ) { detectDoubleTap ( "next" , e ) ; } else { detectDoubleTap ( "previous" , e ) ; } } , hasPassiveOption ? { passive : false } : false ) ; entryContentElement . addEventListener ( "touchmove" , ( e ) = > { Object . keys ( doubleTapTimers ) . forEach ( timer = > doubleTapTimers [ timer ] = null ) ; } ) ; } } }
2019-10-07 01:24:39 +02:00
class KeyboardHandler { constructor ( ) { this . queue = [ ] ; this . shortcuts = { } ; this . triggers = [ ] ; }
on ( combination , callback ) { this . shortcuts [ combination ] = callback ; this . triggers . push ( combination . split ( " " ) [ 0 ] ) ; }
listen ( ) { document . onkeydown = ( event ) = > { let key = this . getKey ( event ) ; if ( this . isEventIgnored ( event , key ) || this . isModifierKeyDown ( event ) ) { return ; } else { event . preventDefault ( ) ; }
this . queue . push ( key ) ; for ( let combination in this . shortcuts ) { let keys = combination . split ( " " ) ; if ( keys . every ( ( value , index ) = > value == = this . queue [ index ] ) ) { this . queue = [ ] ; this . shortcuts [ combination ] ( event ) ; return ; }
2018-10-23 05:26:17 +02:00
if ( keys . length == = 1 && key == = keys [ 0 ] ) { this . queue = [ ] ; this . shortcuts [ combination ] ( event ) ; return ; } }
2017-11-20 06:10:04 +01:00
if ( this . queue . length >= 2 ) { this . queue = [ ] ; } } ; }
2019-10-07 01:24:39 +02:00
isEventIgnored ( event , key ) { return event . target . tagName == = "INPUT" || event . target . tagName == = "TEXTAREA" || ( this . queue . length < 1 && ! this . triggers . includes ( key ) ) ; }
2018-10-31 13:59:02 +01:00
isModifierKeyDown ( event ) { return event . getModifierState ( "Control" ) || event . getModifierState ( "Alt" ) || event . getModifierState ( "Meta" ) ; }
2017-11-20 06:10:04 +01:00
getKey ( event ) { const mapping = { ' Esc ':' Escape ',' Up ':' ArrowUp ',' Down ':' ArrowDown ',' Left ':' ArrowLeft ',' Right ':' ArrowRight ' } ; for ( let key in mapping ) { if ( mapping . hasOwnProperty ( key ) && key == = event . key ) { return mapping [ key ] ; } }
return event . key ; } }
2017-12-03 00:01:05 +01:00
class RequestBuilder { constructor ( url ) { this . callback = null ; this . url = url ; this . options = { method : "POST" , cache : "no-cache" , credentials : "include" , body : null , headers : new Headers ( { "Content-Type" : "application/json" , "X-Csrf-Token" : this . getCsrfToken ( ) } ) } ; }
withBody ( body ) { this . options . body = JSON . stringify ( body ) ; return this ; }
withCallback ( callback ) { this . callback = callback ; return this ; }
getCsrfToken ( ) { let element = document . querySelector ( "meta[name=X-CSRF-Token]" ) ; if ( element != = null ) { return element . getAttribute ( "value" ) ; }
return "" ; }
execute ( ) { fetch ( new Request ( this . url , this . options ) ) . then ( ( response ) = > { if ( this . callback ) { this . callback ( response ) ; } } ) ; } }
2017-12-29 01:27:54 +01:00
class ModalHandler { static exists ( ) { return document . getElementById ( "modal-container" ) != = null ; }
static open ( fragment ) { if ( ModalHandler . exists ( ) ) { return ; }
let container = document . createElement ( "div" ) ; container . id = "modal-container" ; container . appendChild ( document . importNode ( fragment , true ) ) ; document . body . appendChild ( container ) ; let closeButton = document . querySelector ( "a.btn-close-modal" ) ; if ( closeButton != = null ) { closeButton . onclick = ( event ) = > { event . preventDefault ( ) ; ModalHandler . close ( ) ; } ; } }
static close ( ) { let container = document . getElementById ( "modal-container" ) ; if ( container != = null ) { container . parentNode . removeChild ( container ) ; } } }
2019-07-18 05:27:39 +02:00
function onClick ( selector , callback , noPreventDefault ) { let elements = document . querySelectorAll ( selector ) ; elements . forEach ( ( element ) = > { element . onclick = ( event ) = > { if ( ! noPreventDefault ) { event . preventDefault ( ) ; }
callback ( event ) ; } ; } ) ; }
function toggleMainMenu ( ) { let menu = document . querySelector ( ".header nav ul" ) ; if ( DomHelper . isVisible ( menu ) ) { menu . style . display = "none" ; } else { menu . style . display = "block" ; }
let searchElement = document . querySelector ( ".header .search" ) ; if ( DomHelper . isVisible ( searchElement ) ) { searchElement . style . display = "none" ; } else { searchElement . style . display = "block" ; } }
function onClickMainMenuListItem ( event ) { let element = event . target ; if ( element . tagName == = "A" ) { window . location . href = element . getAttribute ( "href" ) ; } else { window . location . href = element . querySelector ( "a" ) . getAttribute ( "href" ) ; } }
2019-08-16 07:08:24 +02:00
function handleSubmitButtons ( ) { let elements = document . querySelectorAll ( "form" ) ; elements . forEach ( ( element ) = > { element . onsubmit = ( ) = > { let button = element . querySelector ( "button" ) ; if ( button ) { button . innerHTML = button . dataset . labelLoading ; button . disabled = true ; } } ; } ) ; }
2019-07-18 05:27:39 +02:00
function setFocusToSearchInput ( event ) { event . preventDefault ( ) ; event . stopPropagation ( ) ; let toggleSwitchElement = document . querySelector ( ".search-toggle-switch" ) ; if ( toggleSwitchElement ) { toggleSwitchElement . style . display = "none" ; }
2018-07-05 07:05:19 +02:00
let searchFormElement = document . querySelector ( ".search-form" ) ; if ( searchFormElement ) { searchFormElement . style . display = "block" ; }
let searchInputElement = document . getElementById ( "search-input" ) ; if ( searchInputElement ) { searchInputElement . focus ( ) ; searchInputElement . value = "" ; } }
2019-07-18 05:27:39 +02:00
function showKeyboardShortcuts ( ) { let template = document . getElementById ( "keyboard-shortcuts" ) ; if ( template != = null ) { ModalHandler . open ( template . content ) ; } }
2019-07-18 06:07:29 +02:00
function markPageAsRead ( ) { let items = DomHelper . getVisibleElements ( ".items .item" ) ; let entryIDs = [ ] ; items . forEach ( ( element ) = > { element . classList . add ( "item-status-read" ) ; entryIDs . push ( parseInt ( element . dataset . id , 10 ) ) ; } ) ; if ( entryIDs . length > 0 ) { updateEntriesStatus ( entryIDs , "read" , ( ) = > { let element = document . querySelector ( "a[data-action=markPageAsRead]" ) ; let showOnlyUnread = false ; if ( element ) { showOnlyUnread = element . dataset . showOnlyUnread || false ; }
2019-07-18 05:27:39 +02:00
if ( showOnlyUnread ) { window . location . reload ( ) ; } else { goToPage ( "next" , true ) ; } } ) ; } }
2019-10-07 05:55:15 +02:00
function handleEntryStatus ( element ) { let toasting = ! element ; let currentEntry = findEntry ( element ) ; if ( currentEntry ) { toggleEntryStatus ( currentEntry , toasting ) ; if ( isListView ( ) && currentEntry . classList . contains ( ' current - item ' ) ) { goToNextListItem ( ) ; } } }
function toggleEntryStatus ( element , toasting ) { let entryID = parseInt ( element . dataset . id , 10 ) ; let link = element . querySelector ( "a[data-toggle-status]" ) ; let currentStatus = link . dataset . value ; let newStatus = currentStatus == = "read" ? "unread" : "read" ; updateEntriesStatus ( [ entryID ] , newStatus ) ; if ( currentStatus == = "read" ) { link . innerHTML = link . dataset . labelRead ; link . dataset . value = "unread" ; if ( toasting ) { toast ( link . dataset . toastUnread ) ; } } else { link . innerHTML = link . dataset . labelUnread ; link . dataset . value = "read" ; if ( toasting ) { toast ( link . dataset . toastRead ) ; } }
2019-07-18 05:27:39 +02:00
if ( element . classList . contains ( "item-status-" + currentStatus ) ) { element . classList . remove ( "item-status-" + currentStatus ) ; element . classList . add ( "item-status-" + newStatus ) ; } }
function markEntryAsRead ( element ) { if ( element . classList . contains ( "item-status-unread" ) ) { element . classList . remove ( "item-status-unread" ) ; element . classList . add ( "item-status-read" ) ; let entryID = parseInt ( element . dataset . id , 10 ) ; updateEntriesStatus ( [ entryID ] , "read" ) ; } }
function updateEntriesStatus ( entryIDs , status , callback ) { let url = document . body . dataset . entriesStatusUrl ; let request = new RequestBuilder ( url ) ; request . withBody ( { entry_ids : entryIDs , status : status } ) ; request . withCallback ( callback ) ; request . execute ( ) ; if ( status == = "read" ) { decrementUnreadCounter ( 1 ) ; } else { incrementUnreadCounter ( 1 ) ; } }
2019-10-07 05:55:15 +02:00
function handleSaveEntry ( element ) { let toasting = ! element ; let currentEntry = findEntry ( element ) ; if ( currentEntry ) { saveEntry ( currentEntry . querySelector ( "a[data-save-entry]" ) , toasting ) ; } }
function saveEntry ( element , toasting ) { if ( ! element ) { return ; }
2019-07-18 05:27:39 +02:00
if ( element . dataset . completed ) { return ; }
2019-10-07 05:55:15 +02:00
element . innerHTML = element . dataset . labelLoading ; let request = new RequestBuilder ( element . dataset . saveUrl ) ; request . withCallback ( ( ) = > { element . innerHTML = element . dataset . labelDone ; element . dataset . completed = true ; if ( toasting ) { toast ( element . dataset . toastDone ) ; } } ) ; request . execute ( ) ; }
function handleBookmark ( element ) { let toasting = ! element ; let currentEntry = findEntry ( element ) ; if ( currentEntry ) { toggleBookmark ( currentEntry , toasting ) ; } }
function toggleBookmark ( parentElement , toasting ) { let element = parentElement . querySelector ( "a[data-toggle-bookmark]" ) ; if ( ! element ) { return ; }
element . innerHTML = element . dataset . labelLoading ; let request = new RequestBuilder ( element . dataset . bookmarkUrl ) ; request . withCallback ( ( ) = > { if ( element . dataset . value == = "star" ) { element . innerHTML = element . dataset . labelStar ; element . dataset . value = "unstar" ; if ( toasting ) { toast ( element . dataset . toastUnstar ) ; } } else { element . innerHTML = element . dataset . labelUnstar ; element . dataset . value = "star" ; if ( toasting ) { toast ( element . dataset . toastStar ) ; } } } ) ; request . execute ( ) ; }
2019-07-18 05:27:39 +02:00
function handleFetchOriginalContent ( ) { if ( isListView ( ) ) { return ; }
let element = document . querySelector ( "a[data-fetch-content-entry]" ) ; if ( ! element ) { return ; }
if ( element . dataset . completed ) { return ; }
element . innerHTML = element . dataset . labelLoading ; let request = new RequestBuilder ( element . dataset . fetchContentUrl ) ; request . withCallback ( ( response ) = > { element . innerHTML = element . dataset . labelDone ; element . dataset . completed = true ; response . json ( ) . then ( ( data ) = > { if ( data . hasOwnProperty ( "content" ) ) { document . querySelector ( ".entry-content" ) . innerHTML = data . content ; } } ) ; } ) ; request . execute ( ) ; }
2019-11-29 22:48:56 +01:00
function openOriginalLink ( openLinkInCurrentTab ) { let entryLink = document . querySelector ( ".entry h1 a" ) ; if ( entryLink != = null ) { if ( openLinkInCurrentTab ) { window . location . href = entryLink . getAttribute ( "href" ) ; } else { DomHelper . openNewTab ( entryLink . getAttribute ( "href" ) ) ; }
return ; }
2019-07-18 05:27:39 +02:00
let currentItemOriginalLink = document . querySelector ( ".current-item a[data-original-link]" ) ; if ( currentItemOriginalLink != = null ) { DomHelper . openNewTab ( currentItemOriginalLink . getAttribute ( "href" ) ) ; let currentItem = document . querySelector ( ".current-item" ) ; goToNextListItem ( ) ; markEntryAsRead ( currentItem ) ; } }
2020-01-07 07:02:02 +01:00
function openCommentLink ( openLinkInCurrentTab ) { if ( ! isListView ( ) ) { let entryLink = document . querySelector ( "a[data-comments-link]" ) ; if ( entryLink != = null ) { if ( openLinkInCurrentTab ) { window . location . href = entryLink . getAttribute ( "href" ) ; } else { DomHelper . openNewTab ( entryLink . getAttribute ( "href" ) ) ; }
return ; } } else { let currentItemCommentsLink = document . querySelector ( ".current-item a[data-comments-link]" ) ; if ( currentItemCommentsLink != = null ) { DomHelper . openNewTab ( currentItemCommentsLink . getAttribute ( "href" ) ) ; } } }
2019-07-18 05:27:39 +02:00
function openSelectedItem ( ) { let currentItemLink = document . querySelector ( ".current-item .item-title a" ) ; if ( currentItemLink != = null ) { window . location . href = currentItemLink . getAttribute ( "href" ) ; } }
function unsubscribeFromFeed ( ) { let unsubscribeLinks = document . querySelectorAll ( "[data-action=remove-feed]" ) ; if ( unsubscribeLinks . length == = 1 ) { let unsubscribeLink = unsubscribeLinks [ 0 ] ; let request = new RequestBuilder ( unsubscribeLink . dataset . url ) ; request . withCallback ( ( ) = > { if ( unsubscribeLink . dataset . redirectUrl ) { window . location . href = unsubscribeLink . dataset . redirectUrl ; } else { window . location . reload ( ) ; } } ) ; request . execute ( ) ; } }
function goToPage ( page , fallbackSelf ) { let element = document . querySelector ( "a[data-page=" + page + "]" ) ; if ( element ) { document . location . href = element . href ; } else if ( fallbackSelf ) { window . location . reload ( ) ; } }
function goToPrevious ( ) { if ( isListView ( ) ) { goToPreviousListItem ( ) ; } else { goToPage ( "previous" ) ; } }
function goToNext ( ) { if ( isListView ( ) ) { goToNextListItem ( ) ; } else { goToPage ( "next" ) ; } }
function goToFeedOrFeeds ( ) { if ( isEntry ( ) ) { let feedAnchor = document . querySelector ( "span.entry-website a" ) ; if ( feedAnchor != = null ) { window . location . href = feedAnchor . href ; } } else { goToPage ( ' feeds ' ) ; } }
function goToPreviousListItem ( ) { let items = DomHelper . getVisibleElements ( ".items .item" ) ; if ( items . length == = 0 ) { return ; }
2018-10-02 05:52:51 +02:00
if ( document . querySelector ( ".current-item" ) == = null ) { items [ 0 ] . classList . add ( "current-item" ) ; items [ 0 ] . querySelector ( ' . item - header a ' ) . focus ( ) ; return ; }
2020-01-08 22:52:36 +01:00
for ( let i = 0 ; i < items . length ; i ++ ) { if ( items [ i ] . classList . contains ( "current-item" ) ) { items [ i ] . classList . remove ( "current-item" ) ; let nextItem ; if ( i - 1 >= 0 ) { nextItem = items [ i - 1 ] ; } else { nextItem = items [ items . length - 1 ] ; }
nextItem . classList . add ( "current-item" ) ; DomHelper . scrollPageTo ( nextItem ) ; nextItem . querySelector ( ' . item - header a ' ) . focus ( ) ; break ; } } }
function goToNextListItem ( ) { let items = DomHelper . getVisibleElements ( ".items .item" ) ; if ( items . length == = 0 ) { return ; }
if ( document . querySelector ( ".current-item" ) == = null ) { items [ 0 ] . classList . add ( "current-item" ) ; items [ 0 ] . querySelector ( ' . item - header a ' ) . focus ( ) ; return ; }
for ( let i = 0 ; i < items . length ; i ++ ) { if ( items [ i ] . classList . contains ( "current-item" ) ) { items [ i ] . classList . remove ( "current-item" ) ; let nextItem ; if ( i + 1 < items . length ) { nextItem = items [ i + 1 ] ; } else { nextItem = items [ 0 ] ; }
nextItem . classList . add ( "current-item" ) ; DomHelper . scrollPageTo ( nextItem ) ; nextItem . querySelector ( ' . item - header a ' ) . focus ( ) ; break ; } } }
2019-07-18 05:27:39 +02:00
function decrementUnreadCounter ( n ) { updateUnreadCounterValue ( ( current ) = > { return current - n ; } ) ; }
function incrementUnreadCounter ( n ) { updateUnreadCounterValue ( ( current ) = > { return current + n ; } ) ; }
function updateUnreadCounterValue ( callback ) { let counterElements = document . querySelectorAll ( "span.unread-counter" ) ; counterElements . forEach ( ( element ) = > { let oldValue = parseInt ( element . textContent , 10 ) ; element . innerHTML = callback ( oldValue ) ; } ) ; if ( window . location . href . endsWith ( ' / unread ' ) ) { let oldValue = parseInt ( document . title . split ( '(' ) [ 1 ] , 10 ) ; let newValue = callback ( oldValue ) ; document . title = document . title . replace ( / ( . * ? ) \ ( \ d + \ ) ( . * ? ) / , function ( match , prefix , suffix , offset , string ) { return prefix + '(' + newValue + ')' + suffix ; } ) ; } }
function isEntry ( ) { return document . querySelector ( "section.entry" ) != = null ; }
function isListView ( ) { return document . querySelector ( ".items" ) != = null ; }
2019-07-26 04:02:39 +02:00
function findEntry ( element ) { if ( isListView ( ) ) { if ( element ) { return DomHelper . findParent ( element , "item" ) ; } else { return document . querySelector ( ".current-item" ) ; } } else { return document . querySelector ( ".entry" ) ; } }
2019-07-18 06:07:29 +02:00
function handleConfirmationMessage ( linkElement , callback ) { linkElement . style . display = "none" ; let containerElement = linkElement . parentNode ; let questionElement = document . createElement ( "span" ) ; let yesElement = document . createElement ( "a" ) ; yesElement . href = "#" ; yesElement . appendChild ( document . createTextNode ( linkElement . dataset . labelYes ) ) ; yesElement . onclick = ( event ) = > { event . preventDefault ( ) ; let loadingElement = document . createElement ( "span" ) ; loadingElement . className = "loading" ; loadingElement . appendChild ( document . createTextNode ( linkElement . dataset . labelLoading ) ) ; questionElement . remove ( ) ; containerElement . appendChild ( loadingElement ) ; callback ( linkElement . dataset . url , linkElement . dataset . redirectUrl ) ; } ; let noElement = document . createElement ( "a" ) ; noElement . href = "#" ; noElement . appendChild ( document . createTextNode ( linkElement . dataset . labelNo ) ) ; noElement . onclick = ( event ) = > { event . preventDefault ( ) ; linkElement . style . display = "inline" ; questionElement . remove ( ) ; } ; questionElement . className = "confirm" ; questionElement . appendChild ( document . createTextNode ( linkElement . dataset . labelQuestion + " " ) ) ; questionElement . appendChild ( yesElement ) ; questionElement . appendChild ( document . createTextNode ( ", " ) ) ; questionElement . appendChild ( noElement ) ; containerElement . appendChild ( questionElement ) ; }
2019-10-07 05:55:15 +02:00
function toast ( msg ) { if ( ! msg ) return ; document . querySelector ( ' . toast - wrap . toast - msg ' ) . innerHTML = msg ; let toastWrapper = document . querySelector ( ' . toast - wrap ' ) ; toastWrapper . classList . remove ( ' toastAnimate ' ) ; setTimeout ( function ( ) { toastWrapper . classList . add ( ' toastAnimate ' ) ; } , 100 ) ; }
2020-01-07 07:02:02 +01:00
document . addEventListener ( "DOMContentLoaded" , function ( ) { handleSubmitButtons ( ) ; if ( ! document . querySelector ( "body[data-disable-keyboard-shortcuts=true]" ) ) { let keyboardHandler = new KeyboardHandler ( ) ; keyboardHandler . on ( "g u" , ( ) = > goToPage ( "unread" ) ) ; keyboardHandler . on ( "g b" , ( ) = > goToPage ( "starred" ) ) ; keyboardHandler . on ( "g h" , ( ) = > goToPage ( "history" ) ) ; keyboardHandler . on ( "g f" , ( ) = > goToFeedOrFeeds ( ) ) ; keyboardHandler . on ( "g c" , ( ) = > goToPage ( "categories" ) ) ; keyboardHandler . on ( "g s" , ( ) = > goToPage ( "settings" ) ) ; keyboardHandler . on ( "ArrowLeft" , ( ) = > goToPrevious ( ) ) ; keyboardHandler . on ( "ArrowRight" , ( ) = > goToNext ( ) ) ; keyboardHandler . on ( "k" , ( ) = > goToPrevious ( ) ) ; keyboardHandler . on ( "p" , ( ) = > goToPrevious ( ) ) ; keyboardHandler . on ( "j" , ( ) = > goToNext ( ) ) ; keyboardHandler . on ( "n" , ( ) = > goToNext ( ) ) ; keyboardHandler . on ( "h" , ( ) = > goToPage ( "previous" ) ) ; keyboardHandler . on ( "l" , ( ) = > goToPage ( "next" ) ) ; keyboardHandler . on ( "o" , ( ) = > openSelectedItem ( ) ) ; keyboardHandler . on ( "v" , ( ) = > openOriginalLink ( ) ) ; keyboardHandler . on ( "V" , ( ) = > openOriginalLink ( true ) ) ; keyboardHandler . on ( "c" , ( ) = > openCommentLink ( ) ) ; keyboardHandler . on ( "C" , ( ) = > openCommentLink ( true ) ) ; keyboardHandler . on ( "m" , ( ) = > handleEntryStatus ( ) ) ; keyboardHandler . on ( "A" , ( ) = > markPageAsRead ( ) ) ; keyboardHandler . on ( "s" , ( ) = > handleSaveEntry ( ) ) ; keyboardHandler . on ( "d" , ( ) = > handleFetchOriginalContent ( ) ) ; keyboardHandler . on ( "f" , ( ) = > handleBookmark ( ) ) ; keyboardHandler . on ( "?" , ( ) = > showKeyboardShortcuts ( ) ) ; keyboardHandler . on ( "#" , ( ) = > unsubscribeFromFeed ( ) ) ; keyboardHandler . on ( "/" , ( e ) = > setFocusToSearchInput ( e ) ) ; keyboardHandler . on ( "Escape" , ( ) = > ModalHandler . close ( ) ) ; keyboardHandler . listen ( ) ; }
2019-07-26 04:02:39 +02:00
let touchHandler = new TouchHandler ( ) ; touchHandler . listen ( ) ; onClick ( "a[data-save-entry]" , ( event ) = > handleSaveEntry ( event . target ) ) ; onClick ( "a[data-toggle-bookmark]" , ( event ) = > handleBookmark ( event . target ) ) ; onClick ( "a[data-fetch-content-entry]" , ( ) = > handleFetchOriginalContent ( ) ) ; onClick ( "a[data-action=search]" , ( event ) = > setFocusToSearchInput ( event ) ) ; onClick ( "a[data-action=markPageAsRead]" , ( ) = > handleConfirmationMessage ( event . target , ( ) = > markPageAsRead ( ) ) ) ; onClick ( "a[data-toggle-status]" , ( event ) = > handleEntryStatus ( event . target ) ) ; onClick ( "a[data-confirm]" , ( event ) = > handleConfirmationMessage ( event . target , ( url , redirectURL ) = > { let request = new RequestBuilder ( url ) ; request . withCallback ( ( ) = > { if ( redirectURL ) { window . location . href = redirectURL ; } else { window . location . reload ( ) ; } } ) ; request . execute ( ) ; } ) ) ; if ( document . documentElement . clientWidth < 600 ) { onClick ( ".logo" , ( ) = > toggleMainMenu ( ) ) ; onClick ( ".header nav li" , ( event ) = > onClickMainMenuListItem ( event ) ) ; }
2018-07-16 06:51:09 +02:00
if ( "serviceWorker" in navigator ) { let scriptElement = document . getElementById ( "service-worker-script" ) ; if ( scriptElement ) { navigator . serviceWorker . register ( scriptElement . src ) ; } } } ) ; } ) ( ) ; ` ,
"sw" : ` 'use strict';self.addEventListener("fetch",(event)=> { if(event.request.url.includes("/feed/icon/")) { event.respondWith(caches.open("feed_icons").then((cache)=> { return cache.match(event.request).then((response)=> { return response||fetch(event.request).then((response)=> { cache.put(event.request,response.clone());return response;});});}));}}); ` ,
2017-11-20 06:10:04 +01:00
}
2018-07-16 06:51:09 +02:00
var JavascriptsChecksums = map [ string ] string {
2020-01-08 22:52:36 +01:00
"app" : "be87d5db4f4373b0a2db87952db4200888cff16e0a400130c931436d475a72d6" ,
2018-07-16 06:51:09 +02:00
"sw" : "55fffa223919cc18572788fb9c62fccf92166c0eb5d3a1d6f91c31f24d020be9" ,
2017-11-20 06:10:04 +01:00
}