@ -34,6 +34,11 @@ function sameDay (d1, d2) {
d2 = new Date ( d2 ) ;
return ( ( d1 . getFullYear ( ) == d2 . getFullYear ( ) ) && ( d1 . getMonth ( ) == d2 . getMonth ( ) ) && ( d1 . getDate ( ) == d2 . getDate ( ) ) ) ;
}
function sameMonth ( d1 , d2 ) { //5/29/16 by DW -- return true if the two dates are in the same month
d1 = new Date ( d1 ) ;
d2 = new Date ( d2 ) ;
return ( ( d1 . getFullYear ( ) == d2 . getFullYear ( ) ) && ( d1 . getMonth ( ) == d2 . getMonth ( ) ) ) ;
}
function dayGreaterThanOrEqual ( d1 , d2 ) { //9/2/14 by DW
d1 = new Date ( d1 ) ;
d1 . setHours ( 0 ) ;
@ -336,27 +341,32 @@ function stripMarkup (s) { //5/24/14 by DW
return ( s . replace ( /(<([^>]+)>)/ig , "" ) ) ;
}
function maxStringLength ( s , len , flWholeWordAtEnd , flAddElipses ) {
if ( flWholeWordAtEnd === undefined ) {
flWholeWordAtEnd = true ;
}
if ( flAddElipses === undefined ) { //6/2/14 by DW
flAddElipses = true ;
if ( ( s === undefined ) || ( s === null ) ) {
return ( "" ) ;
}
if ( s . length > len ) {
s = s . substr ( 0 , len ) ;
if ( flWholeWordAtEnd ) {
while ( s . length > 0 ) {
if ( s [ s . length - 1 ] == " " ) {
if ( flAddElipses ) {
s += "..." ;
else {
if ( flWholeWordAtEnd === undefined ) {
flWholeWordAtEnd = true ;
}
if ( flAddElipses === undefined ) { //6/2/14 by DW
flAddElipses = true ;
}
if ( s . length > len ) {
s = s . substr ( 0 , len ) ;
if ( flWholeWordAtEnd ) {
while ( s . length > 0 ) {
if ( s [ s . length - 1 ] == " " ) {
if ( flAddElipses ) {
s += "..." ;
}
break ;
}
break ;
s = s . substr ( 0 , s . length - 1 ) ; //pop last char
}
s = s . substr ( 0 , s . length - 1 ) ; //pop last char
}
}
return ( s ) ;
}
return ( s ) ;
}
function random ( lower , upper ) {
var range = upper - lower + 1 ;
@ -403,12 +413,13 @@ function readHttpFile (url, callback, timeoutInMilliseconds, headers) { //5/27/1
} ) ;
}
function readHttpFileThruProxy ( url , type , callback ) { //10/25/14 by DW
var urlReadFileApi = "http://pub2.fargo.io :5347/httpReadUrl" ;
var urlReadFileApi = "http://pub2.fargo.io /httpReadUrl"; //"http://pub2.fargo.io :5347/httpReadUrl";
if ( type === undefined ) {
type = "text/plain" ;
}
var urlAjax = urlReadFileApi + "?url=" + encodeURIComponent ( url ) + "&type=" + encodeURIComponent ( type ) ;
var jxhr = $ . ajax ( {
url : url ReadFileApi + "?url=" + encodeURIComponent ( url ) + "&type=" + encodeURIComponent ( type ) ,
url : url Ajax ,
dataType : "text" ,
timeout : 30000
} )
@ -455,18 +466,23 @@ function filledString (ch, ct) { //6/4/14 by DW
return ( s ) ;
}
function encodeXml ( s ) { //7/15/14 by DW
var charMap = {
'<' : '<' ,
'>' : '>' ,
'&' : '&' ,
'"' : '&' + 'quot;'
} ;
s = s . toString ( ) ;
s = s . replace ( /\u00A0/g , " " ) ;
var escaped = s . replace ( /[<>&"]/g , function ( ch ) {
return charMap [ ch ] ;
} ) ;
return escaped ;
if ( s === undefined ) {
return ( "" ) ;
}
else {
var charMap = {
'<' : '<' ,
'>' : '>' ,
'&' : '&' ,
'"' : '&' + 'quot;'
} ;
s = s . toString ( ) ;
s = s . replace ( /\u00A0/g , " " ) ;
var escaped = s . replace ( /[<>&"]/g , function ( ch ) {
return charMap [ ch ] ;
} ) ;
return escaped ;
}
}
function decodeXml ( s ) { //11/7/14 by DW
return ( s . replace ( /</g , '<' ) . replace ( />/g , '>' ) . replace ( /&/g , '&' ) ) ;
@ -596,7 +612,6 @@ function getRandomSnarkySlogan () { //8/15/14 by DW
"All baking done on premises." ,
"Still diggin!" ,
"It's even worse than it appears." ,
"Ask not what the Internet can do for you..." ,
"You should never argue with a crazy man." ,
"Welcome back my friends to the show that never ends." ,
"Greetings, citizen of Planet Earth. We are your overlords. :-)" ,
@ -611,7 +626,12 @@ function getRandomSnarkySlogan () { //8/15/14 by DW
"Shut up and eat your vegetables." ,
"Don't slam the door on the way out." ,
"Yeah well, that's just, you know, like, your opinion, man." ,
"So, it has come to this."
"So, it has come to this." ,
"We now return to our regularly scheduled program." ,
"That rug really tied the room together." ,
"It's a good time for a backup." ,
"Takes a lickin, keeps on tickin." ,
"People return to places that send them away."
]
return ( snarkySlogans [ random ( 0 , snarkySlogans . length - 1 ) ] ) ;
}
@ -755,7 +775,13 @@ function copyScalars (source, dest) { //8/31/14 by DW
}
}
function linkToDomainFromUrl ( url , flshort , maxlength ) { //10/10/14 by DW
var splitUrl = urlSplitter ( url ) , host = splitUrl . host . toLowerCase ( ) ;
var splitUrl = urlSplitter ( url ) , host ;
if ( splitUrl . host === undefined ) { //1/21/16 by DW
host = "" ;
}
else {
host = splitUrl . host . toLowerCase ( ) ;
}
if ( flshort === undefined ) {
flshort = false ;
}
@ -966,6 +992,23 @@ function getFileModDate (f, callback) { //8/26/15 by DW
}
} ) ;
}
function getFileCreationDate ( f , callback ) { //12/15/15 by DW
fs . exists ( f , function ( flExists ) {
if ( flExists ) {
fs . stat ( f , function ( err , stats ) {
if ( err ) {
callback ( undefined ) ;
}
else {
callback ( new Date ( stats . birthtime ) . toString ( ) ) ;
}
} ) ;
}
else {
callback ( undefined ) ;
}
} ) ;
}
function getAppUrl ( ) { //11/13/15 by DW
var url = stringNthField ( window . location . href , "?" , 1 ) ;
url = stringNthField ( url , "#" , 1 ) ;
@ -1024,4 +1067,18 @@ function upperCaseFirstChar (s) { //11/15/15 by DW
s = stringUpper ( s [ 0 ] ) + stringDelete ( s , 1 , 1 ) ;
return ( s ) ;
}
function cacheConfuse ( url ) { //3/1/16 by DW
return ( url + "?x=" + random ( 0 , 10000000 ) ) ;
}
function equalStrings ( s1 , s2 , flUnicase ) { //4/7/16 by DW
if ( flUnicase === undefined ) {
flUnicase = true ;
}
if ( flUnicase ) {
return ( s1 . toLowerCase ( ) == s2 . toLowerCase ( ) ) ;
}
else {
return ( s1 == s2 ) ;
}
}