providers-utility-controllet.html 1.67 KB
<link rel="import" href="../../bower_components/polymer/polymer.html" />

<script type="text/javascript" src="../../bower_components/jsdatachecker/jsdatachecker.min.js"></script>

<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 || 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>