@ -1,5 +1,5 @@
define ( [
define ( [
'/api/config ?cb= ' + Math . random ( ) . toString ( 16 ) . slice ( 2 ) ,
'/api/config ',
'/customize/messages.js?app=' + window . location . pathname . split ( '/' ) . filter ( function ( x ) { return x ; } ) . join ( '.' ) ,
'/customize/messages.js?app=' + window . location . pathname . split ( '/' ) . filter ( function ( x ) { return x ; } ) . join ( '.' ) ,
'/customize/fsStore.js' ,
'/customize/fsStore.js' ,
'/bower_components/chainpad-crypto/crypto.js?v=0.1.5' ,
'/bower_components/chainpad-crypto/crypto.js?v=0.1.5' ,
@ -163,10 +163,14 @@ define([
// var isArray = function (o) { return Object.prototype.toString.call(o) === '[object Array]'; };
// var isArray = function (o) { return Object.prototype.toString.call(o) === '[object Array]'; };
var isArray = common . isArray = $ . isArray ;
var isArray = common . isArray = $ . isArray ;
var fixHTML = common . fixHTML = function ( html ) {
var fixHTML = common . fixHTML = function ( str ) {
return html . replace ( /</g , '<' ) ;
if ( ! str ) { return '' ; }
return str . replace ( /[<>&"']/g , function ( x ) {
return ( { "<" : "<" , ">" : ">" , "&" : "&" , '"' : """ , "'" : "'" } ) [ x ] ;
} ) ;
} ;
} ;
var truncate = common . truncate = function ( text , len ) {
var truncate = common . truncate = function ( text , len ) {
if ( typeof ( text ) === 'string' && text . length > len ) {
if ( typeof ( text ) === 'string' && text . length > len ) {
return text . slice ( 0 , len ) + '…' ;
return text . slice ( 0 , len ) + '…' ;
@ -851,7 +855,7 @@ define([
if ( ! $ ( '#' + LOADING ) . is ( ':visible' ) ) { common . addLoadingScreen ( ) ; }
if ( ! $ ( '#' + LOADING ) . is ( ':visible' ) ) { common . addLoadingScreen ( ) ; }
$ ( '.spinnerContainer' ) . hide ( ) ;
$ ( '.spinnerContainer' ) . hide ( ) ;
if ( transparent ) { $ ( '#' + LOADING ) . css ( 'opacity' , 0.8 ) ; }
if ( transparent ) { $ ( '#' + LOADING ) . css ( 'opacity' , 0.8 ) ; }
$ ( '#' + LOADING ) . find ( 'p' ) . html ( error || Messages . error ) ;
$ ( '#' + LOADING ) . find ( 'p' ) . text ( error || Messages . error ) ;
} ;
} ;
/ *
/ *
@ -924,7 +928,7 @@ define([
switch ( type ) {
switch ( type ) {
case 'export' :
case 'export' :
button = $ ( '<button>' , {
button = $ ( '<button>' , {
title : Messages . exportButton + '\n' + Messages . exportButton Title,
title : Messages . exportButton Title,
} ) . append ( $ ( '<span>' , { 'class' : 'fa fa-download' , style : 'font:' + size + ' FontAwesome' } ) ) ;
} ) . append ( $ ( '<span>' , { 'class' : 'fa fa-download' , style : 'font:' + size + ' FontAwesome' } ) ) ;
if ( callback ) {
if ( callback ) {
button . click ( callback ) ;
button . click ( callback ) ;
@ -932,7 +936,7 @@ define([
break ;
break ;
case 'import' :
case 'import' :
button = $ ( '<button>' , {
button = $ ( '<button>' , {
title : Messages . importButton + '\n' + Messages . importButton Title,
title : Messages . importButton Title,
} ) . append ( $ ( '<span>' , { 'class' : 'fa fa-upload' , style : 'font:' + size + ' FontAwesome' } ) ) ;
} ) . append ( $ ( '<span>' , { 'class' : 'fa fa-upload' , style : 'font:' + size + ' FontAwesome' } ) ) ;
if ( callback ) {
if ( callback ) {
button . click ( common . importContent ( 'text/plain' , function ( content , file ) {
button . click ( common . importContent ( 'text/plain' , function ( content , file ) {
@ -943,7 +947,7 @@ define([
case 'forget' :
case 'forget' :
button = $ ( '<button>' , {
button = $ ( '<button>' , {
id : 'cryptpad-forget' ,
id : 'cryptpad-forget' ,
title : Messages . forgetButton + '\n' + Messages . forgetButton Title,
title : Messages . forgetButton Title,
'class' : "fa fa-trash cryptpad-forget" ,
'class' : "fa fa-trash cryptpad-forget" ,
style : 'font:' + size + ' FontAwesome'
style : 'font:' + size + ' FontAwesome'
} ) ;
} ) ;
@ -974,7 +978,7 @@ define([
} else {
} else {
callback ( ) ;
callback ( ) ;
}
}
common . alert ( Messages . movedToTrash );
common . alert ( Messages . movedToTrash , undefined , true );
return ;
return ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -1032,14 +1036,14 @@ define([
break ;
break ;
case 'present' :
case 'present' :
button = $ ( '<button>' , {
button = $ ( '<button>' , {
title : Messages . presentButton + '\n' + Messages . presentButton Title,
title : Messages . presentButton Title,
'class' : "fa fa-play-circle cryptpad-present-button" , // class used in slide.js
'class' : "fa fa-play-circle cryptpad-present-button" , // class used in slide.js
style : 'font:' + size + ' FontAwesome'
style : 'font:' + size + ' FontAwesome'
} ) ;
} ) ;
break ;
break ;
case 'source' :
case 'source' :
button = $ ( '<button>' , {
button = $ ( '<button>' , {
title : Messages . sourceButton + '\n' + Messages . sourceButton Title,
title : Messages . sourceButton Title,
'class' : "fa fa-stop-circle cryptpad-source-button" , // class used in slide.js
'class' : "fa fa-stop-circle cryptpad-source-button" , // class used in slide.js
style : 'font:' + size + ' FontAwesome'
style : 'font:' + size + ' FontAwesome'
} ) ;
} ) ;
@ -1158,22 +1162,22 @@ define([
var $displayedName = $ ( '<span>' , { 'class' : config . displayNameCls || 'displayName' } ) ;
var $displayedName = $ ( '<span>' , { 'class' : config . displayNameCls || 'displayName' } ) ;
var accountName = localStorage [ common . userNameKey ] ;
var accountName = localStorage [ common . userNameKey ] ;
var account = isLoggedIn ( ) ;
var account = isLoggedIn ( ) ;
var $userAdminContent = $ ( '<p>' ) ;
if ( account ) {
var $userAccount = $ ( '<span>' , { 'class' : 'userAccount' } ) . append ( Messages . user _accountName + ': ' + accountName ) ;
$userAdminContent . append ( $userAccount ) ;
$userAdminContent . append ( $ ( '<br>' ) ) ;
}
var $userName = $ ( '<span>' , { 'class' : 'userDisplayName' } ) ;
var $userName = $ ( '<span>' , { 'class' : 'userDisplayName' } ) ;
if ( config . displayName ) {
// Hide "Display name:" in read only mode
$userName . append ( Messages . user _displayName + ': ' ) ;
$userName . append ( $displayedName . clone ( ) ) ;
}
//$userName.append($displayedName.clone()); TODO remove ?
$userAdminContent . append ( $userName ) ;
var options = [ ] ;
var options = [ ] ;
if ( config . displayNameCls ) {
if ( config . displayNameCls ) {
var $userAdminContent = $ ( '<p>' ) ;
if ( account ) {
var $userAccount = $ ( '<span>' , { 'class' : 'userAccount' } ) . append ( Messages . user _accountName + ': ' + fixHTML ( accountName ) ) ;
$userAdminContent . append ( $userAccount ) ;
$userAdminContent . append ( $ ( '<br>' ) ) ;
}
if ( config . displayName ) {
// Hide "Display name:" in read only mode
$userName . append ( Messages . user _displayName + ': ' ) ;
$userName . append ( $displayedName . clone ( ) ) ;
}
//$userName.append($displayedName.clone()); TODO remove ?
$userAdminContent . append ( $userName ) ;
options . push ( {
options . push ( {
tag : 'p' ,
tag : 'p' ,
attributes : { 'class' : 'accountData' } ,
attributes : { 'class' : 'accountData' } ,
@ -1305,8 +1309,9 @@ define([
$ ( window ) . off ( 'keyup' , handler ) ;
$ ( window ) . off ( 'keyup' , handler ) ;
} ;
} ;
common . alert = function ( msg , cb ) {
common . alert = function ( msg , cb , force ) {
cb = cb || function ( ) { } ;
cb = cb || function ( ) { } ;
if ( force !== true ) { msg = fixHTML ( msg ) ; }
var keyHandler = listenForKeys ( function ( e ) { // yes
var keyHandler = listenForKeys ( function ( e ) { // yes
findOKButton ( ) . click ( ) ;
findOKButton ( ) . click ( ) ;
} ) ;
} ) ;
@ -1319,9 +1324,10 @@ define([
} ) ;
} ) ;
} ;
} ;
common . prompt = function ( msg , def , cb , opt ) {
common . prompt = function ( msg , def , cb , opt , force ) {
opt = opt || { } ;
opt = opt || { } ;
cb = cb || function ( ) { } ;
cb = cb || function ( ) { } ;
if ( force !== true ) { msg = fixHTML ( msg ) ; }
var keyHandler = listenForKeys ( function ( e ) { // yes
var keyHandler = listenForKeys ( function ( e ) { // yes
findOKButton ( ) . click ( ) ;
findOKButton ( ) . click ( ) ;
@ -1342,9 +1348,11 @@ define([
} ) ;
} ) ;
} ;
} ;
common . confirm = function ( msg , cb , opt ) {
common . confirm = function ( msg , cb , opt , force ) {
opt = opt || { } ;
opt = opt || { } ;
cb = cb || function ( ) { } ;
cb = cb || function ( ) { } ;
if ( force !== true ) { msg = fixHTML ( msg ) ; }
var keyHandler = listenForKeys ( function ( e ) {
var keyHandler = listenForKeys ( function ( e ) {
findOKButton ( ) . click ( ) ;
findOKButton ( ) . click ( ) ;
} , function ( e ) {
} , function ( e ) {
@ -1364,11 +1372,11 @@ define([
} ;
} ;
common . log = function ( msg ) {
common . log = function ( msg ) {
Alertify . success ( msg) ;
Alertify . success ( fixHTML( msg) ) ;
} ;
} ;
common . warn = function ( msg ) {
common . warn = function ( msg ) {
Alertify . error ( msg) ;
Alertify . error ( fixHTML( msg) ) ;
} ;
} ;
/ *
/ *