<commit_before>"use strict";
// Setup general variables
var defaultListenPort = 8080;

var core, transport;
var pairStatus = 0;
var zoneStatus = [];
var zoneList = [];

// Read command line options
var commandLineArgs = require('command-line-args');
var getUsage = require('command-line-usage');

var optionDefinitions = [
    { name: 'help', alias: 'h', description: 'Display this usage guide.', type: Boolean },
    { name: 'port', alias: 'p', description: 'Specify the port the server listens on.', type: Number }
];

var options = commandLineArgs(optionDefinitions, { partial: true });

var usage = getUsage([
{
    header: 'Roon Web Controller',
    content: 'A web based controller for the Roon Music Player.\n\nUsage: [bold]{node app.js <options>}'
},
{
    header: 'Options',
    optionList: optionDefinitions
},
{
    content: 'Project home: [underline]{https://github.com/pluggemi/roon-web-controller}'
}
]);

if (options.help) {
    console.log(usage);
    process.exit();
}

// Read config file
var config = require('config');

var configPort = config.get('server.port');

// Determine listen port
if (options.port) {
    var listenPort = options.port;
} else if (configPort){
    var listenPort = configPort;
} else {
    var listenPort = defaultListenPort;
}

// Setup Express
var express = require('express');
var http = require('http');
var bodyParser = require('body-parser');

var app = express();
app.use(express.static('public'));
app.use(bodyParser.json());

app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
});

// Setup Socket IO
var server = http.createServer(app);
var io = require('socket.io').listen(server);

server.listen(listenPort, function() {
    console.log('Listening on port ' + listenPort);
});

// Setup Roon
var RoonApi          = require("node-roon-api");
var RoonApiImage     = require("node-roon-api-image");
var RoonApiStatus    = require("node-roon-api-status");
var RoonApiTransport = require("node-roon-api-transport");
var RoonApiBrowse    = require("node-roon-api-browse");

var roon = new RoonApi({
    extension_id:        'com.pluggemi.web.controller',
    display_name:        "Web Controller",
    display_version:     "1.2.0",
    publisher:           '<NAME>',
    email:               'masked',
    website:             'https://github.com/pluggemi/roon-web-controller',

    core_paired: function(core_) {
        core = core_;

        pairStatus = true;
        io.emit("pairStatus", JSON.parse('{"pairEnabled": ' + pairStatus + '}'));

        transport = core_.services.RoonApiTransport;

        transport.subscribe_zones(function(response, data){
            var i, x, y, zone_id, display_name;
            if (response == "Subscribed") {
                for ( x in data.zones ) {
                    zone_id = data.zones[x].zone_id;
                    display_name = data.zones[x].display_name;
                    var item = {};
                    item.zone_id = zone_id;
                    item.display_name = display_name;

                    zoneList.push(item);
                    zoneStatus.push(data.zones[x]);
                }

                removeDuplicateList(zoneList, 'zone_id');<commit_msg>created dev branch<commit_after>"use strict";
// Setup general variables
var defaultListenPort = 8080;

var core, transport;
var pairStatus = 0;
var zoneStatus = [];
var zoneList = [];

// Read command line options
var commandLineArgs = require('command-line-args');
var getUsage = require('command-line-usage');

var optionDefinitions = [
    { name: 'help', alias: 'h', description: 'Display this usage guide.', type: Boolean },
    { name: 'port', alias: 'p', description: 'Specify the port the server listens on.', type: Number }
];

var options = commandLineArgs(optionDefinitions, { partial: true });

var usage = getUsage([
{
    header: 'Roon Web Controller',
    content: 'A web based controller for the Roon Music Player.\n\nUsage: [bold]{node app.js <options>}'
},
{
    header: 'Options',
    optionList: optionDefinitions
},
{
    content: 'Project home: [underline]{https://github.com/pluggemi/roon-web-controller}'
}
]);

if (options.help) {
    console.log(usage);
    process.exit();
}

// Read config file
var config = require('config');

var configPort = config.get('server.port');

// Determine listen port
if (options.port) {
    var listenPort = options.port;
} else if (configPort){
    var listenPort = configPort;
} else {
    var listenPort = defaultListenPort;
}

// Setup Express
var express = require('express');
var http = require('http');
var bodyParser = require('body-parser');

var app = express();
app.use(express.static('public'));
app.use(bodyParser.json());

app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
});

// Setup Socket IO
var server = http.createServer(app);
var io = require('socket.io').listen(server);

server.listen(listenPort, function() {
    console.log('Listening on port ' + listenPort);
});

// Setup Roon
var RoonApi          = require("node-roon-api");
var RoonApiImage     = require("node-roon-api-image");
var RoonApiStatus    = require("node-roon-api-status");
var RoonApiTransport = require("node-roon-api-transport");
var RoonApiBrowse    = require("node-roon-api-browse");

var roon = new RoonApi({
    extension_id:        'com.pluggemi.web.controller',
    display_name:        "Web Controller",
    display_version:     "dev",
    publisher:           '<NAME>',
    email:               'masked',
    website:             'https://github.com/pluggemi/roon-web-controller',

    core_paired: function(core_) {
        core = core_;

        pairStatus = true;
        io.emit("pairStatus", JSON.parse('{"pairEnabled": ' + pairStatus + '}'));

        transport = core_.services.RoonApiTransport;

        transport.subscribe_zones(function(response, data){
            var i, x, y, zone_id, display_name;
            if (response == "Subscribed") {
                for ( x in data.zones ) {
                    zone_id = data.zones[x].zone_id;
                    display_name = data.zones[x].display_name;
                    var item = {};
                    item.zone_id = zone_id;
                    item.display_name = display_name;

                    zoneList.push(item);
                    zoneStatus.push(data.zones[x]);
                }

                removeDuplicateList(zoneList, 'zone_id');
{'fraction_non_alphanumeric': 0.14648819371334035, 'fraction_numerical': 0.0019551812302601897, 'mean_word_length': 2.877551020408163, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, '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': '2377694', 'n_tokens_mistral': 2023, 'n_tokens_neox': 1976, 'n_words': 469}