WME OH Scripts

Recommended scripts for editing in Ohio

Version vom 06.10.2016. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         WME OH Scripts
// @namespace    https://greasyfork.org/users/30701-justins83-waze
// @version      0.1.1
// @description  Recommended scripts for editing in Ohio
// @include      https://www.waze.com/editor/*
// @include      https://www.waze.com/*/editor/*
// @include      https://beta.waze.com/*
// @author       JustinS83
// @grant        none
// @require      https://greasyfork.org/scripts/9794-wlib/code/wLib.js?version=106259
// @require      https://greasyfork.org/scripts/23614-wlibext/code/wLibExt.js?version=150020
// @license      GPLv3
// ==/UserScript==

/* global W */
/* global wLib */

(function() {
    'use strict';

    // Your code here...
    function bootstrap(tries) {
        tries = tries || 1;

        if (window.W &&
            window.W.map &&
            window.W.model) {
            init();
        } else if (tries < 1000) {
            setTimeout(function () {bootstrap(tries++);}, 200);
        }
    }

    bootstrap();

    function init(){
        var section = document.createElement('div');
        section.style.padding = "8px 16px";
        section.id = "OHScriptsSettings";
        section.innerHTML  = '<div title="OHScriptTitle">Toggling options requires a hard refresh.</div>'
            + '<p><div title="OHValidatorLocalization" class="controls-container"><input type="checkbox" id="_cbOHValidatorLocalizationEnable" /><label for="_cbOHValidatorLocalizationEnable">OH Validator Localization</label></div>'
            +  '<div title="OH Counties 2014" class="controls-container"><input type="checkbox" id="_cbOHCounties2014Enable" /><label for ="_cbOHCounties2014Enable"> OH Counties 2014</label></div>'
            +  '<div title="OH Cities 2014-1" class="controls-container"><input type="checkbox" id="_cbOHCities20141Enable" /><label for ="_cbOHCities20141Enable"> OH Cities 2014-1</label></div>'
            +  '<div title="OH Cities 2014-2" class="controls-container"><input type="checkbox" id="_cbOHCities20142Enable" /><label for ="_cbOHCities20142Enable"> OH Cities 2014-2</label></div>'
            +'</p>';

        new wLib.Interface.Tab('OH Scripts', section.innerHTML);

        if(localStorage.OHScripts){
            console.log("OH Scripts exists!");
            var options = JSON.parse(localStorage.OHScripts);
            alert(options[1]);
            $('#_cbOHValidatorLocalizationEnable').attr('checked', options[1]);
            $('#_cbOHCounties2014Enable').attr('checked', options[2]);
            $('#_cbOHCities20141Enable').attr('checked', options[3]);
            $('#_cbOHCities20142Enable').attr('checked', options[4]);
        }
        else{
            $('#_cbOHValidatorLocalizationEnable').attr('checked', true);
            $('#_cbOHCounties2014Enable').attr('checked', true);
            $('#_cbOHCities20141Enable').attr('checked', false);
            $('#_cbOHCities20142Enable').attr('checked', false);
        }

        /*
        $('#_cbOHValidatorLocalizationEnable').attr('checked', myOptions.get('OHValidatorLocalization'));
        $('#_cbOHCounties2014Enable').attr('checked', myOptions.get('OHCounties'));
        $('#_cbOHCities20141Enable').attr('checked', myOptions.get('OHCities1'));
        $('#_cbOHCities20142Enable').attr('checked', myOptions.get('OHCities2'));*/

        $('#_cbOHValidatorLocalizationEnable').change(function(){
            SaveSettings();
        });
        $('#_cbOHCounties2014Enable').change(function(){
            SaveSettings();
        });
        $('#_cbOHCities20141Enable').change(function(){
            SaveSettings();
        });
        $('#_cbOHCities20142Enable').change(function(){
            SaveSettings();
        });

        if($('#_cbOHValidatorLocalizationEnable').is(':checked'))
            $.getScript("https://greasyfork.org/scripts/11240-wme-counties-ohio-census-2014/code/WME%20Counties%20Ohio%20Census%202014.user.js");

        if($('#_cbOHCounties2014Enable').is(':checked'))
            $.getScript("https://greasyfork.org/scripts/8746-wme-validator-localization-for-ohio/code/WME%20Validator%20Localization%20for%20Ohio.user.js");

        if($('#_cbOHCities20141Enable').is(':checked'))
            $.getScript("https://greasyfork.org/scripts/17391-wme-ohio-cities-census-2014-1/code/WME%20Ohio%20Cities%20Census%202014%20-%201.user.js");

        if($('#_cbOHCities20142Enable').is(':checked'))
            $.getScript("https://greasyfork.org/scripts/17392-wme-ohio-cities-census-2014-2/code/WME%20Ohio%20Cities%20Census%202014%20-%202.user.js");

    }

    function SaveSettings(){
        if (localStorage) {
			var options = [];
			// preserve previous options which may get lost after logout
			if (localStorage.OHScripts) { options = JSON.parse(localStorage.OHScripts); }
			options[1] = $('#_cbOHValidatorLocalizationEnable').is(':checked');
			options[2] = $('#_cbOHCounties2014Enable').is(':checked');
			options[3] = $('#_cbOHCities20141Enable').is(':checked');
			options[4] = $('#_cbOHCities20142Enable').is(':checked');
			localStorage.OHScripts = JSON.stringify(options);
		}
    }
})();