tpl: moved changePwd() to lib.js

This commit is contained in:
Massimo Melina 2020-06-13 17:07:22 +02:00
parent 7cc712a245
commit 70947f179c

View File

@ -28,7 +28,14 @@ def 3.0
<link rel="shortcut icon" href="/favicon.ico"> <link rel="shortcut icon" href="/favicon.ico">
<link rel="stylesheet" href="/~style.css" type="text/css"> <link rel="stylesheet" href="/~style.css" type="text/css">
<script type="text/javascript" src="/?mode=jquery"></script> <script type="text/javascript" src="/?mode=jquery"></script>
<script>var HFS = { user:'{.js encode|%user%.}', folder:'{.js encode|%folder%.}', sid:"{.cookie|HFS_SID_.}" }</script> <script>
var HFS = {
user: '{.js encode|%user%.}',
folder: '{.js encode|%folder%.}',
sid: '{.cookie|HFS_SID_.}',
canChangePwd: '{.can change pwd.}',
}
</script>
<script type="text/javascript" src="/~lib.js"></script> <script type="text/javascript" src="/~lib.js"></script>
[] []
@ -67,19 +74,6 @@ def 3.0
if ($('#menu-panel').css('position').indexOf('sticky') < 0) // sticky is not supported if ($('#menu-panel').css('position').indexOf('sticky') < 0) // sticky is not supported
setInterval(function(){ $('#wrapper').css('margin-top', $('#menu-panel').height()+5) }, 300); // leave space for the fixed panel setInterval(function(){ $('#wrapper').css('margin-top', $('#menu-panel').height()+5) }, 300); // leave space for the fixed panel
}); });
function changePwd() {
{.if|{.can change pwd.}
| ask('{.!Warning: the password will be sent unencrypted to the server. For better security change the password from HFS window..}<hr><i class="fa fa-key"></i> {.!Enter new password.}', 'password', function(s){
s && ajax('changepwd', {'new':s}, getStdAjaxCB(function(){
showLoading(false)
showMsg("{.!Password changed.}")
}))
})
| showError("{.!Sorry, you lack permissions for this action.}")
.}
}//changePwd
</script> </script>
<div id='menu-panel'> <div id='menu-panel'>
@ -605,7 +599,7 @@ can mkdir=and|{.get|can upload.}|{.!option.newfolder.}
can comment=and|{.get|can upload.}|{.!option.comment.} can comment=and|{.get|can upload.}|{.!option.comment.}
can rename=and|{.get|can delete.}|{.!option.rename.} can rename=and|{.get|can delete.}|{.!option.rename.}
can delete=get|can delete can delete=get|can delete
can change pwd=member of|can change password can change pwd={.{.member of|can change password.} >.}
can move=and|{.get|can delete.}|{.!option.move.} can move=and|{.get|can delete.}|{.!option.move.}
escape attr=replace|"|&quot;|$1 escape attr=replace|"|&quot;|$1
commentNL=if|{.pos|<br|$1.}|$1|{.replace|{.chr|10.}|<br />|$1.} commentNL=if|{.pos|<br|$1.}|$1|{.replace|{.chr|10.}|<br />|$1.}
@ -631,6 +625,21 @@ function ajax(method, data, cb) {
}, ajaxError); }, ajaxError);
}//ajax }//ajax
function changePwd() {
if (!HFS.canChangePwd)
return showError("{.!Sorry, you lack permissions for this action.}")
ask(`{.!Warning: the password will be sent unencrypted to the server. For better security change the password from HFS window..}
<hr><i class="fa fa-key"></i> {.!Enter new password.}`,
'password',
s=>
s && ajax('changepwd', {'new':s}, getStdAjaxCB(function(){
showLoading(false)
showMsg("{.!Password changed.}")
}))
)
}//changePwd
function outsideV(e, additionalMargin) { function outsideV(e, additionalMargin) {
outsideV.w || (outsideV.w = $(window)); outsideV.w || (outsideV.w = $(window));
if (!(e instanceof $)) if (!(e instanceof $))