Skip to content

Commit 2fe4d76

Browse files
committed
add function to check paramets for allowVisibleSource fn
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
1 parent 296b29a commit 2fe4d76

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

public/js/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,13 @@ $(window).on('error', function () {
508508
// setNeedRefresh();
509509
})
510510

511+
//
512+
function checkParametr (isLogin, permission) {
513+
if (typeof isLogin !== 'boolean' || !permission) {
514+
throw new Error('one or more parametr is incorrect')
515+
} else return allowVisibleSource(isLogin, permission)
516+
}
517+
511518
// replace url if user have not rights to veiw source code
512519
function replaceUrl (url) {
513520
const urlHasEditOrBoth = /\?edit|\?both/;
@@ -2159,7 +2166,14 @@ socket.on('refresh', function (data) {
21592166
updateInfo(data)
21602167
updatePermission(data.permission)
21612168
currentPermission = data.permission
2162-
if (ui.toolbar.edit.data('blockSource')) { allowVisibleSource(userIsLogin(personalInfo), currentPermission) }
2169+
// run allowVisebleSource functionality
2170+
if (ui.toolbar.edit.data('blockSource')) {
2171+
try {
2172+
checkParametr(userIsLogin(personalInfo), currentPermission)
2173+
} catch (error) {
2174+
console.log(error)
2175+
}
2176+
}
21632177
if (ui.toolbar.edit.data('blockSource') && blockSourceView) { replaceUrl(window.location.href) }
21642178
if (!window.loaded) {
21652179
// auto change mode if no content detected

0 commit comments

Comments
 (0)