<commit_before>$(function() {
    function NetconnectdViewModel(parameters) {
        var self = this;

        self.loginState = parameters[0];
        self.settingsViewModel = parameters[1];
        
        self.allViewModels = undefined;

        self.isWizardActive = false;

        self.pollingEnabled = false;
        self.pollingTimeoutId = undefined;

        self.reconnectInProgress = false;
        self.reconnectTimeout = undefined;

        self.enableQualitySorting = ko.observable(false);
        
        self.hostname = ko.observable(undefined);
        self.forwardUrl = ko.observable(undefined);
        
        self.status = {
            link: ko.observable(),
            connections: {
                ap: ko.observable(),
                wifi: ko.observable(),
                wired: ko.observable()
            },
            wifi: {
                current_ssid: ko.observable(),
                current_address: ko.observable(),
                present: ko.observable()
            },
            ip_addresses: {
				eth0: ko.observable(),
				wlan0: ko.observable(),
			}
        };
        self.statusCurrentWifi = ko.observable();

        self.editorWifi = undefined;
        self.editorWifiSsid = ko.observable();
        self.editorWifiPassphrase1 = ko.observable();
        self.editorWifiPassphrase2 = ko.observable();
        self.editorWifiPassphraseMismatch = ko.computed(function() {
            return self.editorWifiPassphrase1() != self.editorWifiPassphrase2();
        });
        self.editorWifiPassphraseNotEmpty = ko.computed(function() {
            
            return self.editorWifiPassphrase1() != self.editorWifiPassphrase2();
        });

        self.working = ko.observable(false);
        self.error = ko.observable(false);

        self.connectionStateText = ko.computed(function() {
            var text;

            if (self.error()) {
                text = gettext("Error while talking to netconnectd, is the service running?");
            } else if (self.status.connections.ap()) {
                text = gettext("Acting as access point");
            } else if (self.status.link()) {
                if (self.status.connections.wired()) {
                    text = gettext("Connected via wire");
                } else if (self.status.connections.wifi()) {
                    if (self.status.wifi.current_ssid()) {
                        text = _.sprintf(gettext("Connected via wifi (SSID \"%(ssid)s\")"), {ssid: self.status.wifi.current_ssid()});
                    } else {
                        text = gettext("Connected via wifi (unknown SSID)")
                    }
                } else {
                    text = gettext("Connected (unknown connection)");
                }
            } else {
                text = gettext("Not connected to network");
            }

            if (!self.status.wifi.present()) {
                text += ", " + gettext("no wifi interface present")
            }

            return text;
        });

        self.connectionStateTextEthernet = ko.computed(function() {
            if (self.status.connections.wired()) {
                return _.sprintf(gettext("Connected (IP: %(ip)s)"), {ip: self.status.ip_addresses.eth0()});
            } else {
                return gettext("Not connected");
            }
        });

        self.connectionStateTextWifi = ko.computed(function() {
            if (self.status.connections.ap()) {
                return _.sprintf(gettext("Access point (IP: %(ip)s)"), {ip: self.status.ip_addresses.wlan0()});
            } else if (self.status.connections.wifi() && self.status.wifi.current_ssid()) {
                return _.sprintf(gettext("Connected to \"%(ssid)s\" (IP: %(ip)s)"), {ssid: self.status.wifi.current_ssid(), ip: self.status.ip_addresses.wlan0()});
            } else if (self.status.connections.wifi()) {
                return _.sprintf(gettext("Connected to unknown wifi (IP: %(ip)s)"), {ssid: self.status.wifi.current_ssid(), ip: self.status.ip_addresses.wlan0()});
            } else {
                return gettext("Access point down, not connected");
            }
        });

        self.onAllBound = function(allViewModels) {
            self.allViewModels = allViewModels;
        }
        
        self.onWizardDetails = function(response){
            console.log("ANDYETST onWizardDetails() setting self.isWizardActive = true");
            self.isWizardActive = true;
            
            // and load data
            self.requestData();
        };
        
        self.onWizardFinish = function(response){
            console.log("ANDYETST onWizardFinish() setting self.isWizardActive = false");
            self.isWizardActive = false;
        };
        
        self.canRun = function(){
            return (self.isWizardActive || self.loginState.isAdmin());
        };

        self.daemonOnline = ko.computed(function() {
            return (!(self.error()));
        });

        self.apRunning = ko.computed(function() {
            return self.status.connections.ap();
        });

        // initialize list helper
        self.listHelper = new ItemListHelper(
            "wifis",
            {
                "ssid": function (a, b) {
                    // sorts ascending
                    if (a["ssid"].toLocaleLowerCase() < b["ssid"].toLocaleLowerCase()) return -1;
                    if (a["ssid"].toLocaleLowerCase() > b["ssid"].toLocaleLowerCase()) return 1;
                    return 0;
                },
                "quality": function (a, b) {
                    // sorts descending
                    if (a["quality"] > b["quality"]) return -1;
                    if (a["quality"] < b["quality"]) return 1;
                    return 0;
                }
            },
            {},
            "quality",
            [],
            [],
            10
        );<commit_msg>Put hidden SSIDs at end of list<commit_after>$(function() {
    function NetconnectdViewModel(parameters) {
        var self = this;

        self.loginState = parameters[0];
        self.settingsViewModel = parameters[1];
        
        self.allViewModels = undefined;

        self.isWizardActive = false;

        self.pollingEnabled = false;
        self.pollingTimeoutId = undefined;

        self.reconnectInProgress = false;
        self.reconnectTimeout = undefined;

        self.enableQualitySorting = ko.observable(false);
        
        self.hostname = ko.observable(undefined);
        self.forwardUrl = ko.observable(undefined);
        
        self.status = {
            link: ko.observable(),
            connections: {
                ap: ko.observable(),
                wifi: ko.observable(),
                wired: ko.observable()
            },
            wifi: {
                current_ssid: ko.observable(),
                current_address: ko.observable(),
                present: ko.observable()
            },
            ip_addresses: {
				eth0: ko.observable(),
				wlan0: ko.observable(),
			}
        };
        self.statusCurrentWifi = ko.observable();

        self.editorWifi = undefined;
        self.editorWifiSsid = ko.observable();
        self.editorWifiPassphrase1 = ko.observable();
        self.editorWifiPassphrase2 = ko.observable();
        self.editorWifiPassphraseMismatch = ko.computed(function() {
            return self.editorWifiPassphrase1() != self.editorWifiPassphrase2();
        });
        self.editorWifiPassphraseNotEmpty = ko.computed(function() {
            
            return self.editorWifiPassphrase1() != self.editorWifiPassphrase2();
        });

        self.working = ko.observable(false);
        self.error = ko.observable(false);

        self.connectionStateText = ko.computed(function() {
            var text;

            if (self.error()) {
                text = gettext("Error while talking to netconnectd, is the service running?");
            } else if (self.status.connections.ap()) {
                text = gettext("Acting as access point");
            } else if (self.status.link()) {
                if (self.status.connections.wired()) {
                    text = gettext("Connected via wire");
                } else if (self.status.connections.wifi()) {
                    if (self.status.wifi.current_ssid()) {
                        text = _.sprintf(gettext("Connected via wifi (SSID \"%(ssid)s\")"), {ssid: self.status.wifi.current_ssid()});
                    } else {
                        text = gettext("Connected via wifi (unknown SSID)")
                    }
                } else {
                    text = gettext("Connected (unknown connection)");
                }
            } else {
                text = gettext("Not connected to network");
            }

            if (!self.status.wifi.present()) {
                text += ", " + gettext("no wifi interface present")
            }

            return text;
        });

        self.connectionStateTextEthernet = ko.computed(function() {
            if (self.status.connections.wired()) {
                return _.sprintf(gettext("Connected (IP: %(ip)s)"), {ip: self.status.ip_addresses.eth0()});
            } else {
                return gettext("Not connected");
            }
        });

        self.connectionStateTextWifi = ko.computed(function() {
            if (self.status.connections.ap()) {
                return _.sprintf(gettext("Access point (IP: %(ip)s)"), {ip: self.status.ip_addresses.wlan0()});
            } else if (self.status.connections.wifi() && self.status.wifi.current_ssid()) {
                return _.sprintf(gettext("Connected to \"%(ssid)s\" (IP: %(ip)s)"), {ssid: self.status.wifi.current_ssid(), ip: self.status.ip_addresses.wlan0()});
            } else if (self.status.connections.wifi()) {
                return _.sprintf(gettext("Connected to unknown wifi (IP: %(ip)s)"), {ssid: self.status.wifi.current_ssid(), ip: self.status.ip_addresses.wlan0()});
            } else {
                return gettext("Access point down, not connected");
            }
        });

        self.onAllBound = function(allViewModels) {
            self.allViewModels = allViewModels;
        }
        
        self.onWizardDetails = function(response){
            console.log("ANDYETST onWizardDetails() setting self.isWizardActive = true");
            self.isWizardActive = true;
            
            // and load data
            self.requestData();
        };
        
        self.onWizardFinish = function(response){
            console.log("ANDYETST onWizardFinish() setting self.isWizardActive = false");
            self.isWizardActive = false;
        };
        
        self.canRun = function(){
            return (self.isWizardActive || self.loginState.isAdmin());
        };

        self.daemonOnline = ko.computed(function() {
            return (!(self.error()));
        });

        self.apRunning = ko.computed(function() {
            return self.status.connections.ap();
        });

        // initialize list helper
        self.listHelper = new ItemListHelper(
            "wifis",
            {
                "ssid": function (a, b) {
		    // hidden SSIDs always go at the end, sorted by MAC
		    if (!a["ssid"] && b["ssid"]) return 1;
		    if (!b["ssid"] && a["ssid"]) return -1;
		    if (!a["ssid"] && !b["ssid"]) {
			if (a["address"] < b["address"]) return -1;
			if (a["address"] > b["address"]) return 1;
		    }
                    // sorts ascending
                    if (a["ssid"].toLocaleLowerCase() < b["ssid"].toLocaleLowerCase()) return -1;
                    if (a["ssid"].toLocaleLowerCase() > b["ssid"].toLocaleLowerCase()) return 1;
                    return 0;
                },
                "quality": function (a, b) {
                    // sorts descending
                    if (a["quality"] > b["quality"]) return -1;
                    if (a["quality"] < b["quality"]) return 1;
                    return 0;
                }
            },
            {},
            "quality",
            [],
            [],
            10
        );
{'fraction_non_alphanumeric': 0.1312623599208965, 'fraction_numerical': 0.003955174686882004, 'mean_word_length': 1.6327548806941432, 'pattern_counts': {'":': 4, '<': 8, '<?xml version=': 0, '>': 8, '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': '3622993', 'n_tokens_mistral': 3427, 'n_tokens_neox': 3254, 'n_words': 621}