<commit_before>(function(cobalt){
    var plugin={
        name:"location",
        onError:undefined,

        init:function(options){
            cobalt.log('initing location plugin with options', options)

            //create shortcuts
            cobalt.getLocation=this.getLocation;

            if (options && typeof options.onError == "function"){
                this.onError=options.onError;
            }

        },
        getLocation:function(callback){
            cobalt.log('sending getLocation call')
            cobalt.send({ type : "plugin", name:"location", action : "getLocation"}, callback)

        },
        handleEvent:function(json){
            cobalt.log('received native location plugin call', json)
            if (json && json.data && json.data.error){
                if (this.onError){
                    this.onError(json.data.code, json.data.text)
                }else{
                    cobalt.log('location plugin error', json.data.code, json.data.text)
                }
            }
        }
    };
    cobalt.plugins.register(plugin);

})(cobalt || {});
<commit_msg>Web side update for location plugin<commit_after>(function(cobalt){
    var plugin={
        name:"location",
        onError:undefined,
        onSuccess:undefined,

        init:function(options){
            cobalt.log('initing location plugin with options', options)

            //create shortcuts
            cobalt.getLocation=this.getLocation;

            if (options && typeof options.onError == "function"){
                this.onError=options.onError;
            }

        },
        getLocation:function(callback){
            if (typeof callback== "function"){
                cobalt.plugins.enabledPlugins["location"].onSuccess = callback;
            }
            cobalt.log('sending getLocation call', this.onSuccess)
            cobalt.send({ type : "plugin", name:"location", action : "getLocation"})

        },
        handleEvent:function(json){
            cobalt.log('received native location plugin event', json)
            if (json && json.data){
                if (json.data.error){
                    if (this.onError){
                        this.onError(json.data.code, json.data.text)
                    }else{
                        cobalt.log('location plugin error', json.data.code, json.data.text)
                    }
                }else{
                    if (cobalt.plugins.enabledPlugins["location"].onSuccess){
                        cobalt.plugins.enabledPlugins["location"].onSuccess(json.data.value)
                    }else{
                        cobalt.log('location plugin success. but no callback defined. ', json.data.value, this)
                    }
                }
            }
        }
    };
    cobalt.plugins.register(plugin);

})(cobalt || {});

{'fraction_non_alphanumeric': 0.11940824233885171, 'fraction_numerical': 0.0, 'mean_word_length': 1.6320667284522705, 'pattern_counts': {'":': 0, '<': 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': '5308445', 'n_tokens_mistral': 763, 'n_tokens_neox': 721, 'n_words': 137}