<commit_before>String.prototype.lPad = function (n,c) {
    var i; 
    var a = this.split(''); 
    for (i = 0; i < n - this.length; i++) {
        a.unshift (c);
    }; 
    return a.join('');
};

function mapStatus(p) {
    if (p == 1) {
        return 'door is open';    
    } else if (p  == 2) {
        return 'door is closed';
    } else {
        return 'unknown';
    }
}

function getTimeString(unixtime) {
    var timeaction = new Date(unixtime * 1000);
    return  [timeaction.getDate().toString().lPad(2,'0'), '.', 
            timeaction.getMonth().toString().lPad(2,'0'), '.', 
            (timeaction.getFullYear() - 2000).toString().lPad(2,'0'), ' ', 
            timeaction.getHours().toString().lPad(2,'0'), ':', 
            timeaction.getMinutes().toString().lPad(2,'0')].join('');
}

function getAPIData() {
    var theUrl = 'https://rickmer.org/pebble/example.json.php';
    var xmlHttp = new XMLHttpRequest();
    try {
        xmlHttp.open('GET', theUrl, false);
        xmlHttp.send(null);
    }
    catch(error) {
        return {'error':1};
    }
    try {
        var json = JSON.parse(xmlHttp.responseText);
    }
    catch(e) {
        return {'error':2};
    }
    return {
        'error':0,
        'timeaction':json['timeaction'], 
        'status':json['status']
    };
}

function sendData2Pebble() {
    var apiData = getAPIData();
    if (apiData['error'] === 0){
        Pebble.sendAppMessage({1:getTimeString(apiData['timeaction']), 2:mapStatus(apiData['status'])});
    } else if (apiData['error'] === 1) {
        Pebble.sendAppMessage({1:'http', 2:'error'});
    } else if (apiData['error'] === 2) {
        Pebble.sendAppMessage({1:'api', 2:'error'});
    }
}

Pebble.addEventListener("ready", function(e) {
        console.log("phone is ready!");
        sendData2Pebble();<commit_msg>now querys space API at ccc hamburg endpoint<commit_after>String.prototype.lPad = function (n,c) {
    var i; 
    var a = this.split(''); 
    for (i = 0; i < n - this.length; i++) {
        a.unshift (c);
    }; 
    return a.join('');
};

function mapStatus(p) {
    if (p) {
        return 'door is open';    
    } else if (!p) {
        return 'door is closed';
    } else {
        return 'unknown';
    }
}

function getTimeString(unixtime) {
    var timeaction = new Date(unixtime * 1000);
    return  [timeaction.getDate().toString().lPad(2,'0'), '.', 
            timeaction.getMonth().toString().lPad(2,'0'), '.', 
            (timeaction.getFullYear() - 2000).toString().lPad(2,'0'), ' ', 
            timeaction.getHours().toString().lPad(2,'0'), ':', 
            timeaction.getMinutes().toString().lPad(2,'0')].join('');
}

function getAPIData() {
    var theUrl = 'http://hamburg.ccc.de/dooris/status.json';
    var xmlHttp = new XMLHttpRequest();
    try {
        xmlHttp.open('GET', theUrl, false);
        xmlHttp.send(null);
    }
    catch(error) {
        return {'error':1};
    }
    try {
        var json = JSON.parse(xmlHttp.responseText);
    }
    catch(e) {
        return {'error':2};
    }
    return {
        'error':0,
        'timeaction':json['state']['lastchange'], 
        'status':json['state']['open']
    };
}

function sendData2Pebble() {
    var apiData = getAPIData();
    if (apiData['error'] === 0){
        Pebble.sendAppMessage({1:getTimeString(apiData['timeaction']), 2:mapStatus(apiData['status'])});
    } else if (apiData['error'] === 1) {
        Pebble.sendAppMessage({1:'http', 2:'error'});
    } else if (apiData['error'] === 2) {
        Pebble.sendAppMessage({1:'api', 2:'error'});
    }
}

Pebble.addEventListener("ready", function(e) {
        console.log("phone is ready!");
        sendData2Pebble();
{'fraction_non_alphanumeric': 0.1955110870740941, 'fraction_numerical': 0.01838831800973499, 'mean_word_length': 2.539712918660287, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '479943', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1254, 'n_words': 222}