providers-utility-controllet.html
2.62 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<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();
}
};
//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) {
console.log("we");
var selectedIndices = [];
for (var i = 0; i < selectedFileds.length; i++)
if($.inArray(selectedFileds[i], fields) > -1)
selectedIndices.push(fields.indexOf(selectedFileds[i]));
return selectedIndices;
};
// utility_getResourceUrl = function(url) {
// //CKAN
// var strDatasetPos = url.indexOf('/dataset/');
// var strResourcePos = url.indexOf('/resource/');
// if (strDatasetPos >= 0 && strResourcePos > strDatasetPos) {
// var urlSegment1 = url.substring(0, strDatasetPos);
// var urlResourceEnd = url.indexOf('/', strResourcePos + 10);
// var resourceId = url.substring(strResourcePos + 10, urlResourceEnd);
// return urlSegment1 + "/api/action/datastore_search?resource_id=" + resourceId;
// }
// //OPENDATASOFT
// var strExploreDatasetPos = url.indexOf('/explore/dataset/');
// if (strExploreDatasetPos >= 0) {
// var urlSegment1 = url.substring(0, strExploreDatasetPos);
// var datasetEnd = url.indexOf(strExploreDatasetPos + 17, '/');
// var datasetId = url.substring(strExploreDatasetPos + 17, datasetEnd >= 0 ? datasetEnd : url.length);
// return urlSegment1 + '/api/records/1.0/search?dataset=' + datasetId;
// }
// return "";
// };
</script>
<dom-module id="providers-utility-controllet">
<template></template>
<script>
Polymer({
is : 'providers-utility-controllet',
});
</script>
</dom-module>