Project

General

Profile

1
function common_init($scope, $http) {
2
	initSpinner();
3
	showSpinner();
4
	$scope.show = '';
5

    
6
	//load export metadata formats
7
	$http.get('getExportMDFs.do')
8
		.success(
9
			function (data) {
10
				$scope.exportFormats = data;
11
			}
12
		)
13
		.error(
14
			function () {
15
				show_notification('error', 'Cannot load info about export metadata formats ');
16
			}
17
		);
18

    
19
	//load source metadata formats (MetadataReference instances)
20
	$http.get('getSourceMDFs.do')
21
		.success(
22
			function (data) {
23
				$scope.srcFormats = data;
24
			}
25
		)
26
		.error(
27
			function () {
28
				show_notification('error', 'Cannot load info about source metadata formats ');
29
			}
30
		);
31

    
32
	//load OAI set names
33
	$http.get('getSetSpecs.do')
34
		.success(
35
			function (data) {
36
				$scope.setSpecs = data;
37
			}
38
		)
39
		.error(
40
			function () {
41
				show_notification('error', 'Cannot load info about OAI sets ');
42
			}
43
		);
44
	hideSpinner();
45
}
46

    
47
function removeFromList(list, object) {
48
	var index = list.indexOf(object);
49
	list.splice(index, 1);
50
}
51

    
52
function contains(list, object) {
53
	return !!~list.indexOf(object);
54
}
55

    
56
function upsertExportFormat(list, format, formatPrefix) {
57
	for (var i = 0; i < list.length; i++) {
58
		if (list[i].prefix == formatPrefix) {
59
			list[i] = format;
60
			return i;
61
		}
62
	}
63
	//if I haven't found it, then let's add it
64
	list[i] = format;
65
	return -1;
66
}
(4-4/4)