<commit_before>
/* jshint undef: true, unused: true */
/* globals console:false, CloudOS:false  */
/* globals console, setTimeout, CloudOS, Fuse */

(function($)
{
    window['Fuse'] = {

        // development settings.
        VERSION: 0.1,

        defaults: {
            logging: false,  // false to turn off logging
	    production: false
        },

	get_rid : function(name) {

	    var rids = {
		"owner": {"prod": "b16x16",
			  "dev":  "b16x16"
			 },
		"fleet": {"prod": "b16x17",
			  "dev":  "b16x17"
			 },
		"vehicle": {"prod": "b16x9",
			    "dev":  "b16x9"
			   },
		"trips": {"prod": "b16x18",
			  "dev":  "b16x18"
			 },
		"fuel":  {"prod": "b16x20",
			  "dev":  "b16x20"
			 },
		"carvoyant":  {"prod": "b16x11",
			       "dev":  "b16x11"
			 }
	    };

	    return this.defaults.production ? rids[name].prod :  rids[name].dev;
	},

	// we'll retrieve the fleet and vehicle ECIs later and put them here...
	fleet_eci: "", 
	vehicles: [],
	vehicle_status: "",
	vehicle_summary: "",

        init: function(cb)
        {
	    cb = cb || function(){};
	    Fuse.log("Initializing...");
	    $.when(
		Fuse.get_profile(),
		Fuse.fleetChannel()
	    ).done(function(profile, eci){
		Fuse.log("Stored fleet channel", eci[0]);
		Fuse.log("Retrieved user profile", profile[0]);
		cb(profile[0], eci[0]);
		Fuse.log("Done initializing...");
	    }).fail(function(res){
		Fuse.log("Initialization failed...", res);
	    });
        },

        detect_type: function(o)
        {
            if (typeof o !== "object") return typeof o;

            if (o === null) return "null";

            var internal_class = Object.prototype.toString.call(o).match(/\[object\s(\w+)\]/)[1];
            return internal_class.toLowerCase();
        },

        log: function()
        {
            if (this.defaults.logging && console && console.log) {
		[].unshift.call(arguments, "Fuse:"); // arguments is Array-like, it's not an Array 
                console.log.apply(console, arguments);
            }
        },

	// ---------- profile ----------

	// need to redefine since we're often interested in the profile of another cloud
        get_profile: function(channel, cb, options)
        {
	    cb = cb || function(){};
	    options = options || {};
            Fuse.log("Retrieving profile for user");

	    return CloudOS.skyCloud("a169x676", "get_all_me", {}, function(res) {
		CloudOS.clean(res);
		if(typeof cb !== "undefined"){
		    cb(res);
		}
	    },
	    {"eci": channel});
        },

        save_profile: function(channel, json, cb)
        {
            var eventParameters = { "element": "profileUpdate.post" };
            return CloudOS.raiseEvent('web', 'submit', json, eventParameters, cb, {"eci": channel});
        },

	// ---------- account ----------
	initAccount: function(attrs, cb, options)
        {
	    cb = cb || function(){};
	    options = options || {};
	    attrs = attrs || {};
            Fuse.log("Initializing account for user with attributes ", attrs);

            return CloudOS.raiseEvent("fuse", "bootstrap", {}, attrs, function(response)
            {
		// note that because the channel is create asynchronously, processing callback does
		// NOT mean the channel exists. 
                Fuse.log("account initialized");<commit_msg>Camel case function names<commit_after>
/* jshint undef: true, unused: true */
/* globals console:false, CloudOS:false  */
/* globals console, setTimeout, CloudOS, Fuse */

(function($)
{
    window['Fuse'] = {

        // development settings.
        VERSION: 0.1,

        defaults: {
            logging: false,  // false to turn off logging
	    production: false
        },

	get_rid : function(name) {

	    var rids = {
		"owner": {"prod": "b16x16",
			  "dev":  "b16x16"
			 },
		"fleet": {"prod": "b16x17",
			  "dev":  "b16x17"
			 },
		"vehicle": {"prod": "b16x9",
			    "dev":  "b16x9"
			   },
		"trips": {"prod": "b16x18",
			  "dev":  "b16x18"
			 },
		"fuel":  {"prod": "b16x20",
			  "dev":  "b16x20"
			 },
		"carvoyant":  {"prod": "b16x11",
			       "dev":  "b16x11"
			 }
	    };

	    return this.defaults.production ? rids[name].prod :  rids[name].dev;
	},

	// we'll retrieve the fleet and vehicle ECIs later and put them here...
	fleet_eci: "", 
	vehicles: [],
	vehicle_status: "",
	vehicle_summary: "",

        init: function(cb)
        {
	    cb = cb || function(){};
	    Fuse.log("Initializing...");
	    $.when(
		Fuse.get_profile(),
		Fuse.fleetChannel()
	    ).done(function(profile, eci){
		Fuse.log("Stored fleet channel", eci[0]);
		Fuse.log("Retrieved user profile", profile[0]);
		cb(profile[0], eci[0]);
		Fuse.log("Done initializing...");
	    }).fail(function(res){
		Fuse.log("Initialization failed...", res);
	    });
        },

        detect_type: function(o)
        {
            if (typeof o !== "object") return typeof o;

            if (o === null) return "null";

            var internal_class = Object.prototype.toString.call(o).match(/\[object\s(\w+)\]/)[1];
            return internal_class.toLowerCase();
        },

        log: function()
        {
            if (this.defaults.logging && console && console.log) {
		[].unshift.call(arguments, "Fuse:"); // arguments is Array-like, it's not an Array 
                console.log.apply(console, arguments);
            }
        },

	// ---------- profile ----------

	// need to redefine since we're often interested in the profile of another cloud
        getProfile: function(channel, cb, options)
        {
	    cb = cb || function(){};
	    options = options || {};
            Fuse.log("Retrieving profile for user");

	    return CloudOS.skyCloud("a169x676", "get_all_me", {}, function(res) {
		CloudOS.clean(res);
		if(typeof cb !== "undefined"){
		    cb(res);
		}
	    },
	    {"eci": channel});
        },

        saveProfile: function(channel, json, cb)
        {
            var eventParameters = { "element": "profileUpdate.post" };
            return CloudOS.raiseEvent('web', 'submit', json, eventParameters, cb, {"eci": channel});
        },

	// ---------- account ----------
	initAccount: function(attrs, cb, options)
        {
	    cb = cb || function(){};
	    options = options || {};
	    attrs = attrs || {};
            Fuse.log("Initializing account for user with attributes ", attrs);

            return CloudOS.raiseEvent("fuse", "bootstrap", {}, attrs, function(response)
            {
		// note that because the channel is create asynchronously, processing callback does
		// NOT mean the channel exists. 
                Fuse.log("account initialized");
{'fraction_non_alphanumeric': 0.17814871016691958, 'fraction_numerical': 0.017905918057663128, 'mean_word_length': 2.159635666347076, 'pattern_counts': {'":': 42, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1722715', 'n_tokens_mistral': 2303, 'n_tokens_neox': 2034, 'n_words': 488}