WME OH Scripts

Recommended scripts for editing in Ohio

2016-10-07 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         WME OH Scripts
// @namespace    https://greasyfork.org/users/30701-justins83-waze
// @version      0.1.5
// @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, initializeSettings);

    }
    
    function initializeSettings(){
        if(localStorage.OHScripts){
            var options = JSON.parse(localStorage.OHScripts);
            $('#_cbOHValidatorLocalizationEnable').prop('checked', options[1]);
            $('#_cbOHCounties2014Enable').prop('checked', options[2]);
            $('#_cbOHCities20141Enable').prop('checked', options[3]);
            $('#_cbOHCities20142Enable').prop('checked', options[4]);
            console.log("Done loading settings");
        }
        else{
            $('#_cbOHValidatorLocalizationEnable').prop('checked', true);
            $('#_cbOHCounties2014Enable').prop('checked', true);
            $('#_cbOHCities20141Enable').prop('checked', false);
            $('#_cbOHCities20142Enable').prop('checked', false);
            SaveSettings();
        }


        $('#_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);
		}
    }
})();