Total Complexity | 11 |
Complexity/F | 1.83 |
Lines of Code | 58 |
Function Count | 6 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /** |
||
10 | (function (OC, OCA, window, $) { |
||
|
|||
11 | 'use strict'; |
||
12 | /** |
||
13 | * Adds some util functions mainly used by the OCR controller. |
||
14 | * @public |
||
15 | * @class Ocr.Util |
||
16 | */ |
||
17 | var Util = function (config) { |
||
18 | |||
19 | /** Constructor */ |
||
20 | var ocrConfig; |
||
21 | config !== undefined ? ocrConfig = config : console.error('OCR config is not defined.'); |
||
22 | |||
23 | /** TODO: |
||
24 | * Filter file array for files with supported mimetypes and return |
||
25 | * the clean array of all input elements with a proper mimetype. |
||
26 | * @public |
||
27 | * @param {Array<File>} selectedFiles |
||
28 | * @returns {Array<File>} |
||
29 | */ |
||
30 | this.filterFilesWithMimeTypes = function (selectedFiles) { |
||
31 | return selectedFiles.filter(function(file){ |
||
32 | return ocrConfig.ALLOWED_MIMETYPES.indexOf(file.mimetype) == -1 ? false : true; |
||
33 | }); |
||
34 | } |
||
35 | |||
36 | /** Reduce the input array of file elements to only contain the file id. |
||
37 | * @public |
||
38 | * @param {Array<File>} files |
||
39 | * @returns {Array<File>} |
||
40 | */ |
||
41 | this.shrinkData = function(files) { |
||
42 | return files.map(function(file){ |
||
43 | return {id: file.id}; |
||
44 | }); |
||
45 | } |
||
46 | |||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Init OCR Util |
||
51 | */ |
||
52 | /** We have to be in the Files App! */ |
||
53 | if (!OCA.Files) { |
||
54 | return; |
||
55 | } |
||
56 | /** Escape when the requested file is public.php */ |
||
57 | if (/(public)\.php/i.exec(window.location.href) !== null) { |
||
58 | return; |
||
59 | } |
||
60 | /** Create namespace Ocr */ |
||
61 | if (!OCA.Ocr) { |
||
62 | OCA.Ocr = {}; |
||
63 | } |
||
64 | OCA.Ocr.Util = Util; |
||
65 | |||
66 | /** global: OC, OCA */ |
||
67 | })(OC, OCA, window, jQuery); |
||
68 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.