WME OH Scripts

Recommended scripts for editing in Ohio

目前為 2016-10-06 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);
		}
    }
})();