{"size": 1581, "ext": "js", "max_stars_repo_path": "clients/chrome-ext/libs/osp-service.js", "max_stars_repo_name": "fdibernardo/PlusPrivacy", "max_stars_repo_stars_event_min_datetime": "2017-07-25T15:03:02.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-16T12:55:20.000Z", "max_issues_repo_path": "clients/chrome-ext/libs/osp-service.js", "max_issues_repo_name": "fdibernardo/PlusPrivacy", "max_issues_repo_issues_event_min_datetime": "2017-08-16T08:41:16.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-27T13:39:29.000Z", "max_forks_repo_path": "clients/chrome-ext/libs/osp-service.js", "max_forks_repo_name": "fdibernardo/PlusPrivacy", "max_forks_repo_forks_event_min_datetime": "2017-06-16T08:14:40.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-10T13:32:59.000Z"}
{"max_stars_count": 27, "max_issues_count": 11, "max_forks_count": 6, "avg_line_length": 32.9375, "max_line_length": 191, "alphanum_fraction": 0.6293485136}
/*
 * Copyright (c) 2016 ROMSOFT.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the The MIT License (MIT).
 * which accompanies this distribution, and is available at
 * http://opensource.org/licenses/MIT
 *
 * Contributors:
 *    RAFAEL MASTALERU (ROMSOFT)
 * Initially developed in the context of OPERANDO EU project www.operando.eu
 */

var desiredOrder = ["google", "facebook","linkedin","twitter"];

var bus = require("bus-service").bus;

var ospService = exports.ospService = {
    getOSPSettings: function (success_callback) {

        function requestListener(){

            if(this.responseText){
                var ospSettings = JSON.parse(this.responseText);
                var orderedOspSettings = {};
                desiredOrder.forEach(function(ospName){
                    if(ospSettings[ospName]){
                        orderedOspSettings[ospName] = ospSettings[ospName];
                    }
                });
                success_callback(orderedOspSettings);
            }
            else{
                console.error("Failed retrieving privacy settings!");
            }
        }

        var xhrReq = new XMLHttpRequest();
        xhrReq.addEventListener("load",requestListener);
        var resourceURI = ExtensionConfig.SERVER_HOST_PROTOCOL+"://"+ExtensionConfig.OPERANDO_SERVER_HOST + ":" + ExtensionConfig.OPERANDO_SERVER_PORT+"/social-networks/privacy-settings/all";
        xhrReq.open("GET",resourceURI);
        xhrReq.send();

    }
};

bus.registerService(ospService);

