@ -47,8 +47,7 @@ define([
'cp-settings-displayname' ,
'cp-settings-displayname' ,
'cp-settings-language-selector' ,
'cp-settings-language-selector' ,
'cp-settings-logout-everywhere' ,
'cp-settings-logout-everywhere' ,
'cp-settings-resettips' ,
'cp-settings-autostore' ,
'cp-settings-thumbnails' ,
'cp-settings-userfeedback' ,
'cp-settings-userfeedback' ,
'cp-settings-change-password' ,
'cp-settings-change-password' ,
'cp-settings-delete'
'cp-settings-delete'
@ -60,6 +59,8 @@ define([
'cp-settings-creation-template'
'cp-settings-creation-template'
] ,
] ,
'drive' : [
'drive' : [
'cp-settings-resettips' ,
'cp-settings-thumbnails' ,
'cp-settings-drive-backup' ,
'cp-settings-drive-backup' ,
'cp-settings-drive-import-local' ,
'cp-settings-drive-import-local' ,
'cp-settings-drive-reset'
'cp-settings-drive-reset'
@ -208,71 +209,56 @@ define([
return $div ;
return $div ;
} ;
} ;
create [ 'resettips' ] = function ( ) {
create [ 'autostore' ] = function ( ) {
var $div = $ ( '<div>' , { 'class' : 'cp-settings-resettips cp-sidebarlayout-element' } ) ;
var $div = $ ( '<div>' , { 'class' : 'cp-settings-autostore cp-sidebarlayout-element' } ) ;
$ ( '<label>' ) . text ( Messages . settings _resetTips ) . appendTo ( $div ) ;
$ ( '<span>' , { 'class' : 'cp-sidebarlayout-description' } )
. text ( Messages . settings _resetTipsButton ) . appendTo ( $div ) ;
var $button = $ ( '<button>' , { 'id' : 'cp-settings-resettips' , 'class' : 'btn btn-primary' } )
. text ( Messages . settings _resetTipsAction ) . appendTo ( $div ) ;
var localStore = window . cryptpadStore ;
$ ( '<span>' , { 'class' : 'label' } ) . text ( Messages . settings _autostoreTitle ) . appendTo ( $div ) ;
$button . click ( function ( ) {
Object . keys ( localStore ) . forEach ( function ( k ) {
if ( k . slice ( 0 , 9 ) === "hide-info" ) {
localStore . put ( k , undefined ) ;
}
} ) ;
UI . alert ( Messages . settings _resetTipsDone ) ;
} ) ;
return $div ;
} ;
create [ 'thumbnails' ] = function ( ) {
var $div = $ ( '<div>' , { 'class' : 'cp-settings-thumbnails cp-sidebarlayout-element' } ) ;
$ ( '<label>' ) . text ( Messages . settings _thumbnails ) . appendTo ( $div ) ;
// Disable
$ ( '<span>' , { 'class' : 'cp-sidebarlayout-description' } )
$ ( '<span>' , { 'class' : 'cp-sidebarlayout-description' } )
. text( Messages . settings _disableThumbnailsDescription ) . appendTo ( $div ) ;
. append ( Messages . settings _autostoreHint ) . appendTo ( $div ) ;
var $ok = $ ( '<span>' , { 'class' : 'fa fa-check' , title : Messages . saved } ) ;
var $ok = $ ( '<span>' , { 'class' : 'fa fa-check' , title : Messages . saved } ) ;
var $spinner = $ ( '<span>' , { 'class' : 'fa fa-spinner fa-pulse' } ) ;
var $spinner = $ ( '<span>' , { 'class' : 'fa fa-spinner fa-pulse' } ) ;
var $cbox = $ ( UI . createCheckbox ( 'disableThumbnails' ,
var opt1 = UI . createRadio ( 'cp-settings-autostore' , 'cp-settings-autostore-no' ,
Messages . settings _disableThumbnailsAction ,
Messages . settings _autostoreNo , false , {
false , { label : { class : 'noTitle' } } ) ) ;
input : { value : - 1 } ,
var $checkbox = $cbox . find ( 'input' ) . on ( 'change' , function ( ) {
label : { class : 'noTitle' }
} ) ;
var opt2 = UI . createRadio ( 'cp-settings-autostore' , 'cp-settings-autostore-maybe' ,
Messages . settings _autostoreMaybe , true , {
input : { value : 0 } ,
label : { class : 'noTitle' }
} ) ;
var opt3 = UI . createRadio ( 'cp-settings-autostore' , 'cp-settings-autostore-yes' ,
Messages . settings _autostoreYes , false , {
input : { value : 1 } ,
label : { class : 'noTitle' }
} ) ;
var $div2 = $ ( h ( 'div.cp-settings-autostore-radio' , [
opt1 ,
opt2 ,
opt3
] ) ) . appendTo ( $div ) ;
$div . find ( 'input[type="radio"]' ) . on ( 'change' , function ( ) {
$spinner . show ( ) ;
$spinner . show ( ) ;
$ok . hide ( ) ;
$ok . hide ( ) ;
var val = $checkbox . is ( ':checked' ) || false ;
var val = $ ( 'input:radio[name="cp-settings-autostore"]:checked' ) . val ( ) ;
common . setAttribute ( [ 'general' , 'disableThumbnails' ] , val , function ( ) {
val = Number ( val ) || 0 ;
common . setAttribute ( [ 'general' , 'autostore' ] , val , function ( ) {
$spinner . hide ( ) ;
$spinner . hide ( ) ;
$ok . show ( ) ;
$ok . show ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
$cbox . appendTo ( $div ) ;
$ok . hide ( ) . appendTo ( $div2 ) ;
$spinner . hide ( ) . appendTo ( $div2 ) ;
$ok . hide ( ) . appendTo ( $cbox ) ;
$spinner . hide ( ) . appendTo ( $cbox ) ;
common . getAttribute ( [ 'general' , 'disableThumbnails' ] , function ( e , val ) {
$checkbox [ 0 ] . checked = typeof ( val ) === "undefined" || val ;
} ) ;
// Reset
$ ( '<span>' , { 'class' : 'cp-sidebarlayout-description' } )
. text ( Messages . settings _resetThumbnailsDescription ) . appendTo ( $div ) ;
var $button = $ ( '<button>' , { 'id' : 'resetThumbnails' , 'class' : 'btn btn-primary' } )
. text ( Messages . settings _resetThumbnailsAction ) . appendTo ( $div ) ;
$button . click ( function ( ) {
common . getAttribute ( [ 'general' , 'autostore' ] , function ( err , val ) {
sframeChan . query ( "Q_THUMBNAIL_CLEAR" , null , function ( err ) {
if ( val === 1 ) { return void $ ( '#cp-settings-autostore-yes' ) . prop ( 'checked' , true ) ; }
if ( err ) { return void console . error ( "Cannot clear localForage" ) ; }
if ( val === - 1 ) { return void $ ( '#cp-settings-autostore-no' ) . prop ( 'checked' , true ) ; }
UI . alert ( Messages . settings _resetThumbnailsDone ) ;
$ ( '#cp-settings-autostore-maybe' ) . prop ( 'checked' , true ) ;
} ) ;
} ) ;
} ) ;
return $div ;
return $div ;
@ -759,6 +745,76 @@ define([
// Drive settings
// Drive settings
create [ 'resettips' ] = function ( ) {
var $div = $ ( '<div>' , { 'class' : 'cp-settings-resettips cp-sidebarlayout-element' } ) ;
$ ( '<label>' ) . text ( Messages . settings _resetTips ) . appendTo ( $div ) ;
$ ( '<span>' , { 'class' : 'cp-sidebarlayout-description' } )
. text ( Messages . settings _resetTipsButton ) . appendTo ( $div ) ;
var $button = $ ( '<button>' , { 'id' : 'cp-settings-resettips' , 'class' : 'btn btn-primary' } )
. text ( Messages . settings _resetTipsAction ) . appendTo ( $div ) ;
var localStore = window . cryptpadStore ;
$button . click ( function ( ) {
Object . keys ( localStore ) . forEach ( function ( k ) {
if ( k . slice ( 0 , 9 ) === "hide-info" ) {
localStore . put ( k , undefined ) ;
}
} ) ;
UI . alert ( Messages . settings _resetTipsDone ) ;
} ) ;
return $div ;
} ;
create [ 'thumbnails' ] = function ( ) {
var $div = $ ( '<div>' , { 'class' : 'cp-settings-thumbnails cp-sidebarlayout-element' } ) ;
$ ( '<label>' ) . text ( Messages . settings _thumbnails ) . appendTo ( $div ) ;
// Disable
$ ( '<span>' , { 'class' : 'cp-sidebarlayout-description' } )
. text ( Messages . settings _disableThumbnailsDescription ) . appendTo ( $div ) ;
var $ok = $ ( '<span>' , { 'class' : 'fa fa-check' , title : Messages . saved } ) ;
var $spinner = $ ( '<span>' , { 'class' : 'fa fa-spinner fa-pulse' } ) ;
var $cbox = $ ( UI . createCheckbox ( 'disableThumbnails' ,
Messages . settings _disableThumbnailsAction ,
false , { label : { class : 'noTitle' } } ) ) ;
var $checkbox = $cbox . find ( 'input' ) . on ( 'change' , function ( ) {
$spinner . show ( ) ;
$ok . hide ( ) ;
var val = $checkbox . is ( ':checked' ) || false ;
common . setAttribute ( [ 'general' , 'disableThumbnails' ] , val , function ( ) {
$spinner . hide ( ) ;
$ok . show ( ) ;
} ) ;
} ) ;
$cbox . appendTo ( $div ) ;
$ok . hide ( ) . appendTo ( $cbox ) ;
$spinner . hide ( ) . appendTo ( $cbox ) ;
common . getAttribute ( [ 'general' , 'disableThumbnails' ] , function ( e , val ) {
$checkbox [ 0 ] . checked = typeof ( val ) === "undefined" || val ;
} ) ;
// Reset
$ ( '<span>' , { 'class' : 'cp-sidebarlayout-description' } )
. text ( Messages . settings _resetThumbnailsDescription ) . appendTo ( $div ) ;
var $button = $ ( '<button>' , { 'id' : 'resetThumbnails' , 'class' : 'btn btn-primary' } )
. text ( Messages . settings _resetThumbnailsAction ) . appendTo ( $div ) ;
$button . click ( function ( ) {
sframeChan . query ( "Q_THUMBNAIL_CLEAR" , null , function ( err ) {
if ( err ) { return void console . error ( "Cannot clear localForage" ) ; }
UI . alert ( Messages . settings _resetThumbnailsDone ) ;
} ) ;
} ) ;
return $div ;
} ;
create [ 'drive-backup' ] = function ( ) {
create [ 'drive-backup' ] = function ( ) {
var $div = $ ( '<div>' , { 'class' : 'cp-settings-drive-backup cp-sidebarlayout-element' } ) ;
var $div = $ ( '<div>' , { 'class' : 'cp-settings-drive-backup cp-sidebarlayout-element' } ) ;
@ -1052,9 +1108,19 @@ define([
// Content
// Content
var $rightside = APP . $rightside ;
var $rightside = APP . $rightside ;
for ( var f in create ) {
/ * f o r ( v a r f i n c r e a t e ) {
if ( typeof create [ f ] !== "function" ) { continue ; }
if ( typeof create [ f ] !== "function" ) { continue ; }
$rightside . append ( create [ f ] ( ) ) ;
$rightside . append ( create [ f ] ( ) ) ;
} * /
var addItem = function ( cssClass ) {
var item = cssClass . slice ( 12 ) ; // remove 'cp-settings-'
if ( typeof ( create [ item ] ) === "function" ) {
$rightside . append ( create [ item ] ( ) ) ;
}
} ;
for ( var cat in categories ) {
if ( ! Array . isArray ( categories [ cat ] ) ) { continue ; }
categories [ cat ] . forEach ( addItem ) ;
}
}
// TODO RPC
// TODO RPC