WME Copy Venue Attributes

Copy and paste Venue's attributes

目前為 2019-03-07 提交的版本,檢視 最新版本

// ==UserScript==
// @name                WME Copy Venue Attributes
// @namespace           none
// @description         Copy and paste Venue's attributes 
// @include             https://www.waze.com/editor*
// @include             https://www.waze.com/*/editor*
// @include             https://beta.waze.com/editor*
// @include             https://beta.waze.com/*/editor*
// @exclude             https://www.waze.com/*user/editor/*
// @version             0.1
// @grant               none
// ==/UserScript==

(function() {
    'use strict';
    var PoiAttr={}
    function init(){
        console.log("Copy Venue Attributes: INIT");
        var editpanel = $('#edit-panel');
        if (editpanel.length==0) { window.setTimeout(init, 1000); return; }

        $('#edit-panel').bind('DOMSubtreeModified',function(e){
            var editLM = $('.geometry-button-region');
            console.log("Copy Venue Attributes: editLM" , editLM.length);
            if (editLM.length==1) {
                var copyattribDiv = $('#wme-copyattrib-fr');
                if (copyattribDiv.length==0) {
                    copyattribDiv=document.createElement('div');
                    copyattribDiv.id='wme-copyattrib-fr';
                    $(copyattribDiv).css({'float':'right','height':'20px','width':'42px','padding':'5px','border-radius':'5px','background-color':'#fff','box-shadow':'rgba(0, 0, 0, 0.1) 0px 1px 6px 0px'});
                    editLM[0].parentNode.insertBefore(copyattribDiv, editLM[0].nextSibling);

                    var copyBtn=document.createElement('span');
                    copyBtn.innerHTML='<i class="fa fa-copy" data-original-title="" title="Copy attributes"></i>';
                    copyBtn.style.margin='0 3px';
                    copyBtn.onclick=CopyAttrib;
                    copyattribDiv.appendChild(copyBtn);

                    var pasteBtn=document.createElement('span');
                    pasteBtn.innerHTML='<i class="fa fa-paste" data-original-title="" title="Paste attributes"></i>';
                    pasteBtn.style.margin='0 3px';
                    pasteBtn.onclick=PasteAttrib;
                    copyattribDiv.appendChild(pasteBtn);
                }
            }

        })
    }
    function CopyAttrib(){
        $('#wme-copyattrib-fr')[0].style.backgroundColor='#0a0';
        var venue=W.selectionManager.getSelectedFeatures()[0].model.attributes;
        PoiAttr.aliases=venue.aliases;
        PoiAttr.brand=venue.brand;
        PoiAttr.categories=venue.categories;
        PoiAttr.categoryAttributes=venue.categoryAttributes;
        PoiAttr.description=venue.description;
        PoiAttr.name=venue.name;
        PoiAttr.openingHours=venue.openingHours;
        PoiAttr.phone=venue.phone;
        PoiAttr.services=venue.services;
        PoiAttr.url=venue.url
        console.log(PoiAttr);
        setTimeout(function () { $('#wme-copyattrib-fr')[0].style.backgroundColor='#fff'; }, 1000);
    }
    function PasteAttrib(){
        try {
            $('#wme-copyattrib-fr')[0].style.backgroundColor='#26bae8';
            var venue=W.selectionManager.getSelectedFeatures()[0].model;
            W.model.actionManager.add(new (require("Waze/Action/UpdateObject"))(venue, PoiAttr));
            setTimeout(function () { $('#wme-copyattrib-fr')[0].style.backgroundColor='#fff'; }, 1000);
        }
        catch (err) {
            console.log("Copy Venue Attributes : Problem", err);
        }
    }
    setTimeout(init, 200);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址