providers-utility-controllet.html
1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<link rel="import" href="../../bower_components/polymer/polymer.html" />
<script src="ckan.js"></script>
<script src="openDataSoft.js"></script>
<script src="generic.js"></script>
<script>
var providerFactory = {
getProvider: function(dataUrl) {
if (dataUrl.indexOf("datastore_search?resource_id") > -1)
return new ckan_Provider();
else if (dataUrl.indexOf("search?dataset") > -1)
return new openDataSoft_Provider();
else
return new generic_Provider();
}
};
//utility non legato al provider, aggiungere copy e creare un altro js!!!
//jsdatachecker
utility_getFields = function(types) {
return Object.keys(types).map(function(key) { return key; });
};
utility_getSelectedFields = function(fields, indices) {
var selectedFileds = [];
for (var i = 0; i < indices.length; i++)
selectedFileds.push(fields[indices[i]]);
return selectedFileds;
};
utility_getSelectedIndices = function(fields, selectedFileds) {
var selectedIndices = [];
for (var i = 0; i < selectedFileds.length; i++)
if($.inArray(selectedFileds[i], fields) > -1)
selectedIndices.push(fields.indexOf(selectedFileds[i]));
return selectedIndices;
};
</script>
<dom-module id="providers-utility-controllet">
<template></template>
<script>
Polymer({
is : 'providers-utility-controllet',
});
</script>
</dom-module>