Completed
Pull Request — master (#6)
by Janis
340:04 queued 336:33
created

js/ocrapp.js   A

Complexity

Total Complexity 9
Complexity/F 1.5

Size

Lines of Code 60
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
dl 0
loc 60
rs 10
c 1
b 0
f 0
cc 0
nc 1
mnd 1
bc 9
fnc 6
bpm 1.5
cpm 1.5
noi 3

3 Functions

Rating   Name   Duplication   Size   Complexity  
A OCA.Ocr.App.initialize 0 14 1
A OCA.Ocr.App.destroy 0 4 1
A $(document).ready 0 13 3
1
/**
2
 * nextCloud - ocr
3
 *
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later. See the COPYING file.
6
 *
7
 * @author Janis Koehr <[email protected]>
8
 * @copyright Janis Koehr 2016
9
 */
10
(function (OC, window, $, undefined) {
0 ignored issues
show
Unused Code introduced by
The parameter undefined is not used and could be removed.

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.

Loading history...
11
	'use strict';
12
	/** global: OCA */
13
	if (!OCA.Ocr) {
14
		/**
15
		 * @namespace
16
		 * global: OCA
17
		 */
18
		OCA.Ocr = {};
19
	}
20
	/**
21
	 * OCA.Ocr.App
22
	 * Integrates all necessary objects to build the app.
23
	 * @type {{initialize: OCA.Ocr.App.initialize}}
24
	 * global: OCA
25
	 */
26
	OCA.Ocr.App = {
27
		/**
28
		 * Initialize function. Gets all things together.
29
		 */
30
		initialize: function () {
31
			var self = this;
32
			//Create the OCR object
33
			/** global: OC, OCA */
34
			this._ocr = new OCA.Ocr.Ocr(OC.generateUrl('/apps/ocr'));
35
			// Create the View Object
36
			/** global: OCA */
37
			this._view = new OCA.Ocr.View(this._ocr);
38
			self._ocr.initialize().done(function(){
39
				self._view.initialize();
40
			}).fail(function (message) {
41
				self._view.notifyError('OCR App could not be initialized: ' + message);
42
			});
43
		},
44
		/**
45
		 * Destroy function. Deregisters everthing and destroys the Ocr app.
46
		 */
47
		destroy: function () {
48
			var self = this;
0 ignored issues
show
Unused Code introduced by
The variable self seems to be never used. Consider removing it.
Loading history...
49
			this._view.destroy();
50
		}
51
	};
52
/**
53
 * Init the App
54
 */
55
$(document).ready(function () {
56
	/**
57
	 *  We have to be in the Files App!
58
	 */
59
	if(!OCA.Files){ // we don't have the files app, so ignore anything
60
		return;
61
	}
62
	if(/(public)\.php/i.exec(window.location.href)!=null){
0 ignored issues
show
Coding Style introduced by
It is recommended to use !== to compare with null.

Generally, it is recommended to use strict comparison whenever possible and not to rely on the weaker type-juggling comparison operator.

Read more about comparison operations.

Loading history...
63
		return; // escape when the requested file is public.php
64
	}
65
	/** global: OCA */
66
	OCA.Ocr.App.initialize();
67
});
68
/** global: OC */
69
})(OC, window, jQuery);