1 | /** |
||
2 | * Nextcloud - Gallery |
||
3 | * |
||
4 | * |
||
5 | * This file is licensed under the Affero General Public License version 3 or |
||
6 | * later. See the COPYING file. |
||
7 | * |
||
8 | * @author Olivier Paroz <[email protected]> |
||
9 | * |
||
10 | * @copyright Olivier Paroz 2017 |
||
11 | */ |
||
12 | /* global OC, OCA, FileList, $, t */ |
||
13 | var GalleryButton = {}; |
||
14 | GalleryButton.isPublic = false; |
||
15 | GalleryButton.button = {}; |
||
16 | GalleryButton.url = null; |
||
17 | |||
18 | /** |
||
19 | * Rebuilds the Gallery URL every time the files list has changed |
||
20 | */ |
||
21 | GalleryButton.onFileListUpdated = function () { |
||
22 | "use strict"; |
||
23 | var fileList; |
||
24 | |||
25 | if (GalleryButton.isPublic) { |
||
26 | fileList = OCA.Sharing.PublicApp.fileList; |
||
27 | } else { |
||
28 | fileList = FileList; |
||
29 | } |
||
30 | |||
31 | GalleryButton.buildGalleryUrl(fileList.getCurrentDirectory().replace(/^\//, '')); |
||
32 | }; |
||
33 | |||
34 | /** |
||
35 | * Builds the URL which will load the exact same folder in Gallery |
||
36 | * |
||
37 | * @param dir |
||
38 | */ |
||
39 | GalleryButton.buildGalleryUrl = function (dir) { |
||
40 | "use strict"; |
||
41 | var params = {}; |
||
42 | var tokenPath = ''; |
||
43 | var sharingTokenElement = $('#sharingToken'); |
||
44 | var token = (sharingTokenElement.val()) ? sharingTokenElement.val() : false; |
||
45 | if (token) { |
||
46 | params.token = token; |
||
47 | tokenPath = 's/{token}'; |
||
48 | } |
||
49 | GalleryButton.url = |
||
50 | OC.generateUrl('apps/gallery/' + tokenPath, params) + '#' + encodeURIComponent(dir); |
||
51 | }; |
||
52 | |||
53 | $(document).ready(function () { |
||
54 | "use strict"; |
||
55 | if ($('#body-login').length > 0) { |
||
56 | return true; //deactivate on login page |
||
57 | } |
||
58 | |||
59 | if ($('html').is('.ie8')) { |
||
60 | return true; //deactivate in IE8 |
||
61 | } |
||
62 | |||
63 | if ($('#isPublic').val()) { |
||
64 | GalleryButton.isPublic = true; |
||
65 | } |
||
66 | |||
67 | if ($('#filesApp').val()) { |
||
0 ignored issues
–
show
|
|||
68 | |||
69 | $('#fileList').on('updated', GalleryButton.onFileListUpdated); |
||
70 | |||
71 | // Button for opening files list as gallery view |
||
72 | GalleryButton.button = |
||
73 | $('<div id="gallery-button" class="button view-switcher">' + |
||
74 | '<div id="button-loading" class="hidden"></div>' + |
||
75 | '<span class="icon-toggle-pictures"></span>' + |
||
76 | '</div>'); |
||
77 | |||
78 | GalleryButton.button.click(function () { |
||
79 | $(this).children('span').addClass('hidden'); |
||
80 | $(this).children('#button-loading').removeClass('hidden').addClass('icon-loading-small'); |
||
81 | window.location.href = GalleryButton.url; |
||
82 | }); |
||
83 | |||
84 | $('#controls').append(GalleryButton.button); |
||
0 ignored issues
–
show
|
|||
85 | } |
||
86 | } |
||
87 | ); |
||
88 |
This check looks for functions where a
return
statement is found in some execution paths, but not in all.Consider this little piece of code
The function
isBig
will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly returnundefined
.This behaviour may not be what you had intended. In any case, you can add a
return undefined
to the other execution path to make the return value explicit.