<commit_before>/**
 * WMS function handlers
 */

function addLayerToMap(wmsUrl, layers) {
    wmsLayers = new ol.layer.Tile({
        source: new ol.source.TileWMS({
            url: wmsUrl,
            serverType: 'mapserver',
            params: {
                LAYERS: layers,
                TRANSPARENT: true
            }
        })
    });
    // wmsLayer.push(layer);
}

function getWMSCapabilities(url, server) {
    loadingStart();
    var capabilitiesRequestUrl = url + '&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities';
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            app.info.detail = this.responseText;
            loadingEnd();
            return this.response;
        } else {
            // loadingEnd();
            app.info.detail = "Not Found";
        }
    }
    xhr.open('GET', capabilitiesRequestUrl);
    xhr.send();
}

function getLayerList(server) {
    loadingStart();
    var url = server.url;
    var capabilitiesRequestUrl = url + '&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities';
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            var result = (new DOMParser()).parseFromString(this.responseText, "application/xml");
            var layers = result.querySelectorAll('Layer[queryable]');
            var layerList = [];
            layers.forEach(function(item, index){
                layerList.push({
                    name: item.querySelector('Name').innerHTML,
                    title: item.querySelector('Title').innerHTML,
                    legendUrl: item.querySelector('Style LegendURL OnlineResource').getAttribute('xlink:href')
                });
            });
            server.layers = layerList;
            log(layerList);
            app.info.detail = this.responseText;
            getSummaryInfo(result);
            loadingEnd();
            setTimeout(function(){
                // Prism.highlightAll();
            }, 10);
            return this.response;
        } else {
            loadingEnd();
            app.info.detail = "Not Found";
        }
    }
    xhr.open('GET', capabilitiesRequestUrl);
    xhr.send();
}

function getSummaryInfo(xml) {
    var summary = {};
    var elService = xml.querySelector('Service');
    var elCapabilities = xml.querySelector('Capability');
    log(elCapabilities);
    summary = {
        service: {
            name: elService.querySelector('Name').innerHTML,
            title: elService.querySelector('Title').innerHTML
        },
        capabilities: {
            requests: [
                elCapabilities.querySelector('Request').children
            ]
        }
    };
    summary = xmlToJson(xml);
    app.info.summary = summary;
    return summary;
}
<commit_msg>get format request capabilities as part of summary<commit_after>/**
 * WMS function handlers
 */

function addLayerToMap(wmsUrl, layers) {
    wmsLayers = new ol.layer.Tile({
        source: new ol.source.TileWMS({
            url: wmsUrl,
            serverType: 'mapserver',
            params: {
                LAYERS: layers,
                TRANSPARENT: true
            }
        })
    });
    // wmsLayer.push(layer);
}

function getWMSCapabilities(url, server) {
    loadingStart();
    var capabilitiesRequestUrl = url + '&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities';
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            app.info.detail = this.responseText;
            loadingEnd();
            return this.response;
        } else {
            // loadingEnd();
            app.info.detail = "Not Found";
        }
    }
    xhr.open('GET', capabilitiesRequestUrl);
    xhr.send();
}

function getLayerList(server) {
    loadingStart();
    var url = server.url;
    var capabilitiesRequestUrl = url + '&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities';
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            var result = (new DOMParser()).parseFromString(this.responseText, "application/xml");
            var layers = result.querySelectorAll('Layer[queryable]');
            var layerList = [];
            layers.forEach(function(item, index){
                layerList.push({
                    name: item.querySelector('Name').innerHTML,
                    title: item.querySelector('Title').innerHTML,
                    legendUrl: item.querySelector('Style LegendURL OnlineResource').getAttribute('xlink:href')
                });
            });
            server.layers = layerList;
            app.info.detail = this.responseText;
            getSummaryInfo(result);
            loadingEnd();
            setTimeout(function(){
                // Prism.highlightAll();
            }, 10);
            return this.response;
        } else {
            loadingEnd();
            app.info.detail = "Not Found";
        }
    }
    xhr.open('GET', capabilitiesRequestUrl);
    xhr.send();
}

function getSummaryInfo(xml) {
    var summary = {};
    var elService = xml.querySelector('Service');
    var elCapabilities = xml.querySelector('Capability');
    summary = {
        service: {
            name: elService.querySelector('Name').innerHTML,
            title: elService.querySelector('Title').innerHTML,
            onlineResouce: elService.querySelector('OnlineResource').getAttribute('xlink:href')
        },
        capabilities: {
            requests: {
                getCapabilities: {
                    format: parseFormat(elCapabilities.querySelectorAll('GetCapabilities Format'))
                },
                getMap: {
                    format: parseFormat(elCapabilities.querySelectorAll('GetMap Format'))
                },
                getFeatureInfo: {
                    format: parseFormat(elCapabilities.querySelectorAll('GetFeatureInfo Format'))
                }
            }
        }
    };
    app.info.summary = summary;
    return summary;
}

function parseFormat(element) {
    var result = [];
    element.forEach(function(item, index) {
        result.push(item.innerHTML);
    });
    return result;
}

{'fraction_non_alphanumeric': 0.12276013832128262, 'fraction_numerical': 0.005029864822382898, 'mean_word_length': 1.9431082331174838, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '1494016', 'n_tokens_mistral': 1721, 'n_tokens_neox': 1683, 'n_words': 311}