<commit_before>/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
*/

/*global Windows:true */

var cordova = require('cordova');

var isAlertShowing = false;
var alertStack = [];
var activityDialog = null;
var progressDialog = null;

// CB-8928: When toStaticHTML is undefined, prompt fails to run
function _cleanHtml(html) { return html; }
if (typeof toStaticHTML !== 'undefined') {
    _cleanHtml = toStaticHTML;
}

// Windows does not provide native UI for promp dialog so we use some
// simple html-based implementation until it is available
function createPromptDialog(title, message, buttons, defaultText, callback) {

    var isPhone = cordova.platformId == "windows" && WinJS.Utilities.isPhone;;

    var dlgWrap = document.createElement("div");
    dlgWrap.style.position = "absolute";
    dlgWrap.style.width = "100%";
    dlgWrap.style.height = "100%";
    dlgWrap.style.backgroundColor = "rgba(0,0,0,0.25)";
    dlgWrap.style.zIndex = "100000";
    dlgWrap.className = "dlgWrap";

    var dlg = document.createElement("div");
    dlg.style.width = "100%";
    dlg.style.minHeight = "180px";
    dlg.style.height = "auto";
    dlg.style.overflow = "auto";
    dlg.style.backgroundColor = "white";
    dlg.style.position = "relative";
    dlg.style.lineHeight = "2";

    if (isPhone) {
        dlg.style.padding = "0px 5%";
    } else {
        dlg.style.top = "50%"; // center vertically
        dlg.style.transform = "translateY(-50%)";
        dlg.style.padding = "0px 30%";
    }

    // dialog layout template
    dlg.innerHTML = _cleanHtml("<span id='lbl-title' style='font-size: 24pt'></span><br/>" // title
        + "<span id='lbl-message'></span><br/>" // message
        + "<input id='prompt-input' style='width: 100%'/><br/>"); // input fields

    dlg.querySelector('#lbl-title').appendChild(document.createTextNode(title));
    dlg.querySelector('#lbl-message').appendChild(document.createTextNode(message));
    dlg.querySelector('#prompt-input').setAttribute('placeholder', defaultText);

    function makeButtonCallback(idx) {
        return function () {
            var value = promptInput = dlg.querySelector('#prompt-input').value;
            dlgWrap.parentNode.removeChild(dlgWrap);

            if (callback) {
                callback({ input1: value, buttonIndex: idx });
            }
        }
    }

    function addButton(idx, label) {
        var button = document.createElement('button');
        button.style.margin = "8px 0 8px 16px";
        button.style.float = "right";
        button.style.fontSize = "12pt";
        button.tabIndex = idx;
        button.onclick = makeButtonCallback(idx + 1);
        if (idx == 0) {
            button.style.color = "white";
            button.style.backgroundColor = "#464646";
        } else {
            button.style.backgroundColor = "#cccccc";
        }
        button.style.border = "none";
        button.appendChild(document.createTextNode(label));
        dlg.appendChild(button);
    }

    // reverse order is used since we align buttons to the right
    for (var idx = buttons.length - 1; idx >= 0; idx--) {
        addButton(idx, buttons[idx]);
    }

    dlgWrap.appendChild(dlg);
    document.body.appendChild(dlgWrap);

    // make sure input field is under focus
    dlg.querySelector('#prompt-input').focus();

    return dlgWrap;
}

// Windows does not provide native UI for progress dialog and progress bar sowe use some
// simple html-based implementation until it is available
function createActivityDialog(initialMessage, initialProgressValue) {

    var dlgWrap = document.createElement("div");
    dlgWrap.style.position = "absolute";
    dlgWrap.style.width = "100%";
    dlgWrap.style.height = "100%";
    dlgWrap.style.backgroundColor = "rgba(0,0,0,0.25)";
    dlgWrap.style.zIndex = "100000";
    dlgWrap.className = "dlgWrap";

    var dlg = dlgWrap.appendChild(document.createElement("div"));
    dlg.style.position = "relative";
    dlg.style.top = "50%";
    dlg.style.transform = "translateY(-50%)";
    dlg.style.margin = "auto";
    dlg.style.padding = "1em";
    dlg.style.width = "60%";
    dlg.style.textAlign = "center";
    dlg.style.fontSize = "initial";
    dlg.style.color = "black";
    dlg.style.backgroundColor = "white";
    dlg.style.filter = "drop-shadow(0px 0px 0.3em black)";
    dlg.style.msUserSelect = "none";
    dlg.style.cursor = "default";
    dlg.className = "win-type-medium";

    var p = dlg.appendChild(document.createElement("p"));
    p.textContent = initialMessage;
<commit_msg>Make custom HTML dialogs/indicator appear of splashscreen<commit_after>/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
*/

/*global Windows:true */

var cordova = require('cordova');

var isAlertShowing = false;
var alertStack = [];
var activityDialog = null;
var progressDialog = null;

// CB-8928: When toStaticHTML is undefined, prompt fails to run
function _cleanHtml(html) { return html; }
if (typeof toStaticHTML !== 'undefined') {
    _cleanHtml = toStaticHTML;
}

// Windows does not provide native UI for promp dialog so we use some
// simple html-based implementation until it is available
function createPromptDialog(title, message, buttons, defaultText, callback) {

    var isPhone = cordova.platformId == "windows" && WinJS.Utilities.isPhone;;

    var dlgWrap = document.createElement("div");
    dlgWrap.style.position = "absolute";
    dlgWrap.style.width = "100%";
    dlgWrap.style.height = "100%";
    dlgWrap.style.backgroundColor = "rgba(0,0,0,0.25)";
    dlgWrap.style.zIndex = "2147483647";
    dlgWrap.className = "dlgWrap";

    var dlg = document.createElement("div");
    dlg.style.width = "100%";
    dlg.style.minHeight = "180px";
    dlg.style.height = "auto";
    dlg.style.overflow = "auto";
    dlg.style.backgroundColor = "white";
    dlg.style.position = "relative";
    dlg.style.lineHeight = "2";

    if (isPhone) {
        dlg.style.padding = "0px 5%";
    } else {
        dlg.style.top = "50%"; // center vertically
        dlg.style.transform = "translateY(-50%)";
        dlg.style.padding = "0px 30%";
    }

    // dialog layout template
    dlg.innerHTML = _cleanHtml("<span id='lbl-title' style='font-size: 24pt'></span><br/>" // title
        + "<span id='lbl-message'></span><br/>" // message
        + "<input id='prompt-input' style='width: 100%'/><br/>"); // input fields

    dlg.querySelector('#lbl-title').appendChild(document.createTextNode(title));
    dlg.querySelector('#lbl-message').appendChild(document.createTextNode(message));
    dlg.querySelector('#prompt-input').setAttribute('placeholder', defaultText);

    function makeButtonCallback(idx) {
        return function () {
            var value = promptInput = dlg.querySelector('#prompt-input').value;
            dlgWrap.parentNode.removeChild(dlgWrap);

            if (callback) {
                callback({ input1: value, buttonIndex: idx });
            }
        }
    }

    function addButton(idx, label) {
        var button = document.createElement('button');
        button.style.margin = "8px 0 8px 16px";
        button.style.float = "right";
        button.style.fontSize = "12pt";
        button.tabIndex = idx;
        button.onclick = makeButtonCallback(idx + 1);
        if (idx == 0) {
            button.style.color = "white";
            button.style.backgroundColor = "#464646";
        } else {
            button.style.backgroundColor = "#cccccc";
        }
        button.style.border = "none";
        button.appendChild(document.createTextNode(label));
        dlg.appendChild(button);
    }

    // reverse order is used since we align buttons to the right
    for (var idx = buttons.length - 1; idx >= 0; idx--) {
        addButton(idx, buttons[idx]);
    }

    dlgWrap.appendChild(dlg);
    document.body.appendChild(dlgWrap);

    // make sure input field is under focus
    dlg.querySelector('#prompt-input').focus();

    return dlgWrap;
}

// Windows does not provide native UI for progress dialog and progress bar sowe use some
// simple html-based implementation until it is available
function createActivityDialog(initialMessage, initialProgressValue) {

    var dlgWrap = document.createElement("div");
    dlgWrap.style.position = "absolute";
    dlgWrap.style.width = "100%";
    dlgWrap.style.height = "100%";
    dlgWrap.style.backgroundColor = "rgba(0,0,0,0.25)";
    dlgWrap.style.zIndex = "2147483647";
    dlgWrap.className = "dlgWrap";

    var dlg = dlgWrap.appendChild(document.createElement("div"));
    dlg.style.position = "relative";
    dlg.style.top = "50%";
    dlg.style.transform = "translateY(-50%)";
    dlg.style.margin = "auto";
    dlg.style.padding = "1em";
    dlg.style.width = "60%";
    dlg.style.textAlign = "center";
    dlg.style.fontSize = "initial";
    dlg.style.color = "black";
    dlg.style.backgroundColor = "white";
    dlg.style.filter = "drop-shadow(0px 0px 0.3em black)";
    dlg.style.msUserSelect = "none";
    dlg.style.cursor = "default";
    dlg.className = "win-type-medium";

    var p = dlg.appendChild(document.createElement("p"));
    p.textContent = initialMessage;

{'fraction_non_alphanumeric': 0.13308878856282919, 'fraction_numerical': 0.018434913468773514, 'mean_word_length': 3.099074787972244, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4870565', 'n_tokens_mistral': 3291, 'n_tokens_neox': 3159, 'n_words': 826}