@ -1,21 +1,19 @@
'use strict'
/* global dijit, __ */
'use strict' ;
let LABEL _BASE _INDEX = - 1024 ; /* not const because it's assigned at least once (by backend) */
let loading _progress = 0 ;
/* global dijit, __, App, Ajax */
/* error reporting shim */
// TODO: deprecated; remove
function exception _error ( e , e _compat , filename , lineno , colno ) {
/ * f u n c t i o n e x c e p t i o n _ e r r o r ( e , e _ c o m p a t , f i l e n a m e , l i n e n o , c o l n o ) {
if ( typeof e == "string" )
e = e _compat ;
App . Error . report ( e , { filename : filename , lineno : lineno , colno : colno } ) ;
}
} * /
/* xhr shorthand helpers */
/* exported xhrPost */
function xhrPost ( url , params , complete ) {
console . log ( "xhrPost:" , params ) ;
@ -31,6 +29,7 @@ function xhrPost(url, params, complete) {
} ) ;
}
/* exported xhrJson */
function xhrJson ( url , params , complete ) {
return new Promise ( ( resolve , reject ) => {
return xhrPost ( url , params ) . then ( ( reply ) => {
@ -58,6 +57,7 @@ Array.prototype.remove = function(s) {
/* common helpers not worthy of separate Dojo modules */
/* exported Lists */
const Lists = {
onRowChecked : function ( elem ) {
const checked = elem . domNode ? elem . attr ( "checked" ) : elem . checked ;
@ -87,7 +87,7 @@ const Lists = {
} ,
} ;
// noinspection JSUnusedGlobalSymbols
/* exported Tables */
const Tables = {
onRowChecked : function ( elem ) {
// account for dojo checkboxes
@ -133,6 +133,7 @@ const Tables = {
}
} ;
/* exported Cookie */
const Cookie = {
set : function ( name , value , lifetime ) {
const d = new Date ( ) ;
@ -152,12 +153,12 @@ const Cookie = {
} ,
delete : function ( name ) {
const expires = "expires=Thu, 01-Jan-1970 00:00:01 GMT" ;
document . cookie = name + "= " + "" + " ; " + expires ;
document . cookie = name + "= ; " + expires ;
}
} ;
/* runtime notifications */
/* exported Notify */
const Notify = {
KIND _GENERIC : 0 ,
KIND _INFO : 1 ,
@ -237,30 +238,8 @@ const Notify = {
}
} ;
// noinspection JSUnusedGlobalSymbols
function displayIfChecked ( checkbox , elemId ) {
if ( checkbox . checked ) {
Effect . Appear ( elemId , { duration : 0.5 } ) ;
} else {
Effect . Fade ( elemId , { duration : 0.5 } ) ;
}
}
/ * f u n c t i o n s t r i p _ t a g s ( s ) {
return s . replace ( /<\/?[^>]+(>|$)/g , "" ) ;
} * /
// noinspection JSUnusedGlobalSymbols
function label _to _feed _id ( label ) {
return LABEL _BASE _INDEX - 1 - Math . abs ( label ) ;
}
// noinspection JSUnusedGlobalSymbols
function feed _to _label _id ( feed ) {
return LABEL _BASE _INDEX - 1 + Math . abs ( feed ) ;
}
// http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac
/* exported getSelectionText */
function getSelectionText ( ) {
let text = "" ;
@ -281,36 +260,3 @@ function getSelectionText() {
return text . stripTags ( ) ;
}
// noinspection JSUnusedGlobalSymbols
function popupOpenUrl ( url ) {
const w = window . open ( "" ) ;
w . opener = null ;
w . location = url ;
}
// noinspection JSUnusedGlobalSymbols
function popupOpenArticle ( id ) {
const w = window . open ( "" ,
"ttrss_article_popup" ,
"height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no" ) ;
if ( w ) {
w . opener = null ;
w . location = "backend.php?op=article&method=view&mode=raw&html=1&zoom=1&id=" + id + "&csrf_token=" + App . getInitParam ( "csrf_token" ) ;
}
}
// htmlspecialchars()-alike for headlines data-content attribute
function escapeHtml ( text ) {
const map = {
'&' : '&' ,
'<' : '<' ,
'>' : '>' ,
'"' : '"' ,
"'" : '''
} ;
return text . replace ( /[&<>"']/g , function ( m ) { return map [ m ] ; } ) ;
}