RELEASED: VERSION 0.4.3
What’s New?
Updated to work in Firefox / Greasemonkey.
Awww yeah! It’s working. Thank you! ![]()
Way Cool!!! Thanx. Is there any way to shrink the SL input boxes so both fit on one line? I would then be able to see everything from name down to lock level at once.
You may find my WME Fix UI script useful here. ![]()
found something is missing: direction unknown
Outstanding work, excellent script, thanks so much!!
Would like to second this request. There are some times, when working with RR or doing other advanced editor trickery, that there are reasons to set segments to “Unknown” direction from time to time. Love this script, but have to go disable the road direction feature in order to access the Unknown direction option.
Thanks for the reports. I’ll add unknown direction as soon as possible.
Thank you so much!!
Sent from my C6750 using Tapatalk
thanks, can see the “?”, but does not work yet …
It seems to be working for me. Can you let me know what type of segment(s) you’re editing? Does nothing happen, or do you get an error?
Is working for me on all segment types.
Windows 7 Pro, SP1
Chrome 51.0.2704.103
Thank you!
Hello me again, so when you have free time, I can help you to translate to some languages
I did the same thing about the other script, a little help for brazilian editors. My e-mail is cartajenaa@gmail.com
Here is the code and here is the link:
[code]// ==UserScript==
// @name WME ClickSaver (pt-BR)
// @namespace https://greasyfork.org/users/45389
// @version 0.4.6
// @description Owner is MapOMatic. Translation by me. Várias modificações para facilitar uma edição rápida. Original link: https://greasyfork.org/en/scripts/22059-wme-clicksaver
// @author GabiruDriverX
// @include https://beta.waze.com/*editor/*
// @include https://www.waze.com/*editor/*
// @exclude https://www.waze.com/*user/editor/*
// @license MIT/BSD/X11
// ==/UserScript==
(function() {
‘use strict’;
var _debugLevel = 0;
var _roadTypeDropDownSelector = 'select[name="roadType"]';
var _lockDropDownSelector = 'select[name="lockRank"]';
var _directionDropDownSelector = 'select[name="direction"]';
var _elevationDropDownSelector = 'select[name="level"]';
var _alertUpdate = true;
var _settings = {};
var _settingsStoreName = 'clicksaver_settings';
var _lastScriptVersion;
var _scriptVersion = GM_info.script.version;
var _setPLRAttributes = true;
var _scriptVersionChanges = [
GM_info.script.name + '\nv' + _scriptVersion + '\n\O que há\de novo\n------------------------------',
'\n- Workaround for latest WME beta editor change. This workaround still breaks setting street / city to empty for new PLR segments.',
'\n- Added level 7 lock rank button (only displayed if object is locked to 7).'
].join('');
var _roadTypes = {
R:{val:1, title:'Rua', wmeColor:'#ffffeb', svColor:'#ffffff', category:'streets', visible:true},
RP:{val:2, title:'Rua Primária', wmeColor:'#f0ea58', svColor:'#cba12e', category:'streets', visible:true},
Est:{val:7, title:'Estrada Estadual', wmeColor:'#69bf88', svColor:'#ece589', category:'highways', visible:true},
F:{val:6, title:'Estrada Federal', wmeColor:'#45b8d1', svColor:'#c13040', category:'highways', visible:true},
VE:{val:3, title:'Via Expressa', wmeColor:'#c577d2', svColor:'#387fb8', category:'highways', visible:false},
Rmp:{val:4, title:'Rampa', wmeColor:'#b3bfb3', svColor:'#58c53b', category:'highways', visible:false},
NPav:{val:8, title:'Não Pavimentado', wmeColor:'#867342', svColor:'#82614a', category:'otherDrivable', visible:true},
RE:{val:20, title:'Rua de Estacionamento', wmeColor:'#ababab', svColor:'#2282ab', category:'otherDrivable', visible:true},
Rp:{val:17, title:'Rua Privada', wmeColor:'#beba6c', svColor:'#00ffb3', category:'otherDrivable', visible:true},
Bal:{val:15, title:'Balsa', wmeColor:'#d7d8f8', svColor:'#ff8000', category:'otherDrivable', visible:false},
TP:{val:5, title:'Trilha de Pedestres', wmeColor:'#b0a790', svColor:'#00ff00', category:'nonDrivable', visible:false},
CBV:{val:10, title:'Calçadão/Beco/Viela', wmeColor:'#9a9a9a', svColor:'#0000ff', category:'nonDrivable', visible:false},
Esc:{val:16, title:'Escadaria', wmeColor:'#999999', svColor:'#b700ff', category:'nonDrivable', visible:false},
Fer:{val:18, title:'Ferrovia', wmeColor:'#c62925', svColor:'#ffffff', category:'nonDrivable', visible:false},
Tax:{val:19, title:'Taxiamento', wmeColor:'#ffffff', svColor:'#00ff00', category:'nonDrivable', visible:false}
};
var _directions = {
twoWay:{val:3, text:'Mão dupla', title:'Mão dupla'},
oneWayAB:{val:1, text:'A → B', title:'Mão única (A → B)' },
oneWayBA:{val:2, text:'B → A', title:'Mao única (B → A)' },
};
var UpdateObject,
AddOrGetCity,
AddOrGetStreet,
MultiAction;
if (typeof(require) !== "undefined") {
UpdateObject = require("Waze/Action/UpdateObject");
AddOrGetCity = require("Waze/Action/AddOrGetCity");
AddOrGetStreet = require("Waze/Action/AddOrGetStreet");
MultiAction = require("Waze/Action/MultiAction");
}
function log(message, level) {
if (message && level <= _debugLevel) {
console.log('ClickSaver: ' + message);
}
}
function isChecked(checkboxId) {
return $('#' + checkboxId).is(':checked');
}
function setChecked(checkboxId, checked) {
$('#' + checkboxId).prop('checked', checked);
}
function loadSettingsFromStorage() {
var loadedSettings = $.parseJSON(localStorage.getItem(_settingsStoreName));
var defaultSettings = {
lastVersion: null,
roadButtons: true,
roadTypeButtons: ['R','RP','Est','F','Unp','RE','Rp'],
lockButtons: true,
elevationButtons: true,
directionButtons: true,
inlineRoadTypeCheckboxes: true,
hideAvgSpeedCameras: true,
setNewPLRStreetToNone: true
};
_settings = loadedSettings ? loadedSettings : defaultSettings;
for (var prop in defaultSettings) {
if (!_settings.hasOwnProperty(prop)) {
_settings[prop] = defaultSettings[prop];
}
}
setChecked('csRoadTypeButtonsCheckBox', _settings.roadButtons);
if (_settings.roadTypeButtons) {
for (var roadTypeAbbr1 in _roadTypes) {
setChecked('cs' + roadTypeAbbr1 + 'CheckBox', _settings.roadTypeButtons.indexOf(roadTypeAbbr1) !== -1);
}
}
if (_settings.roadButtons) {
$('.csRoadTypeButtonsCheckBoxContainer').show();
} else {
$('.csRoadTypeButtonsCheckBoxContainer').hide();
}
setChecked('csLockButtonsCheckBox', _settings.lockButtons);
setChecked('csElevationButtonsCheckBox', _settings.elevationButtons);
setChecked('csDirectionButtonsCheckBox', _settings.directionButtons);
setChecked('csInlineRoadTypesCheckBox', _settings.inlineRoadTypeCheckboxes);
setChecked('csHideAvgSpeedCamerasCheckBox', _settings.hideAvgSpeedCameras);
setChecked('csClearNewPLRCheckBox', _settings.setNewPLRStreetToNone);
}
function saveSettingsToStorage() {
if (localStorage) {
var settings = {
lastVersion: _scriptVersion,
roadButtons: _settings.roadButtons,//isChecked('csRoadTypeButtonsCheckBox'),
lockButtons: _settings.lockButtons, //isChecked('csLockButtonsCheckBox'),
elevationButtons: _settings.elevationButtons, //isChecked('csElevationButtonsCheckBox'),
directionButtons: _settings.directionButtons, //isChecked('csDirectionButtonsCheckBox'),
inlineRoadTypeCheckboxes: _settings.inlineRoadTypeCheckboxes, //isChecked('csInlineRoadTypesCheckBox'),
hideAvgSpeedCameras: _settings.hideAvgSpeedCameras, //isChecked('csHideAvgSpeedCamerasCheckBox'),
setNewPLRStreetToNone: _settings.setNewPLRStreetToNone //isChecked('csClearNewPLRCheckBox')
};
settings.roadTypeButtons = [];
for (var roadTypeAbbr in _roadTypes) {
if(_settings.roadTypeButtons.indexOf(roadTypeAbbr) !== -1) { settings.roadTypeButtons.push(roadTypeAbbr); }
}
localStorage.setItem(_settingsStoreName, JSON.stringify(settings));
log('Configurações salvas.', 1);
}
}
function getConnectedSegmentIDs(segmentID) {
var IDs = [];
var segment = Waze.model.segments.get(segmentID);
[Waze.model.nodes.get(segment.attributes.fromNodeID), Waze.model.nodes.get(segment.attributes.toNodeID)].forEach(function(node) {
node.attributes.segIDs.forEach(function(segID) {
if (segID != segmentID) { IDs.push(segID); }
});
});
return IDs;
}
function getFirstConnectedStateID(startSegment) {
var stateID = null;
var nonMatches = [];
var segmentIDsToSearch = [startSegment.attributes.id];
while (stateID === null && segmentIDsToSearch.length > 0) {
var startSegmentID = segmentIDsToSearch.pop();
startSegment = Waze.model.segments.get(startSegmentID);
var connectedSegmentIDs = getConnectedSegmentIDs(startSegmentID);
for (var i=0;i<connectedSegmentIDs.length;i++) {
var streetID = Waze.model.segments.get(connectedSegmentIDs[i]).attributes.primaryStreetID;
if (streetID !== null && typeof(streetID) !== 'undefined') {
var cityID = Waze.model.streets.get(streetID).cityID;
stateID = Waze.model.cities.get(cityID).attributes.stateID;
break;
}
}
if (stateID === null) {
nonMatches.push(startSegmentID);
connectedSegmentIDs.forEach(function(segmentID) {
if (nonMatches.indexOf(segmentID) === -1 && segmentIDsToSearch.indexOf(segmentID) === -1) {
segmentIDsToSearch.push(segmentID);
}
});
} else {
return stateID;
}
}
return null;
}
function getEmptyCity(stateID) {
var emptyCity = null;
W.model.cities.getObjectArray().forEach(function(city) {
if (city.attributes.stateID === stateID && city.attributes.isEmpty) {
emptyCity = city;
}
});
return emptyCity;
}
function clearStreetAndCity () {
var segments = Waze.selectionManager.selectedItems;
if (segments.length === 0 || segments[0].model.type !== 'segment') {
return;
}
segments.forEach(function(segment) {
var segModel = segment.model;
if (segModel.attributes.primaryStreetID === null) {
var stateID = getFirstConnectedStateID(segment.model);
if (stateID) {
var state = W.model.states.get(stateID);
var country = W.model.countries.get(state.countryID);
var m_action = new MultiAction();
m_action.setModel(W.model);
var emptyCity = getEmptyCity(state.id);
if (!emptyCity) {
var addCityAction = new AddOrGetCity(state, country, "", true);
m_action.doSubAction(addCityAction);
emptyCity = getEmptyCity(state.id);
}
var newStreet = {isEmpty:true, cityID:emptyCity.attributes.id};
var emptyStreet = W.model.streets.getByAttributes(newStreet)[0];
if (!emptyStreet) {
var addStreetAction = new AddOrGetStreet("", emptyCity, true);
m_action.doSubAction(addStreetAction);
emptyStreet = W.model.streets.getByAttributes(newStreet)[0];
}
var action3 = new UpdateObject(segModel, {primaryStreetID: emptyStreet.id});
m_action.doSubAction(action3);
W.model.actionManager.add(m_action);
}
}
});
}
function onRoadTypeButtonClick(roadTypeAbbr) {
$(_roadTypeDropDownSelector).val(_roadTypes[roadTypeAbbr].val).change();
if (roadTypeAbbr === 'PLR' && isChecked('csClearNewPLRCheckBox') && typeof(require) !== "undefined") {
clearStreetAndCity();
}
}
function addRoadTypeButtons() {
var $dropDown = $(_roadTypeDropDownSelector);
$('#csRoadTypeButtonsContainer').remove();
var $container = $('<div>',{id:'csRoadTypeButtonsContainer',class:'rth-btn-container'});
var $street = $('<div>', {id:'csStreetButtonContainer',class:'cs-rt-btn-container'});
var $highway = $('<div>', {id:'csHighwayButtonContainer',class:'cs-rt-btn-container'});
var $otherDrivable = $('<div>', {id:'csOtherDrivableButtonContainer',class:'cs-rt-btn-container'});
var $nonDrivable = $('<div>', {id:'csNonDrivableButtonContainer',class:'cs-rt-btn-container'});
var divs = {streets:$street, highways:$highway, otherDrivable:$otherDrivable, nonDrivable:$nonDrivable};
for (var roadTypeAbbr in _roadTypes) {
if (_settings.roadTypeButtons.indexOf(roadTypeAbbr) !== -1) {
var roadType = _roadTypes[roadTypeAbbr];
var $div = divs[roadType.category];
$div.append(
$('<div>', {class:'btn btn-rth btn-rth-' + roadTypeAbbr + ($dropDown.attr('disabled') ? ' disabled' : '') + ' btn-positive',title:roadType.title})
.text(roadTypeAbbr)
.prop('checked', roadType.visible)
.click(function() { onRoadTypeButtonClick(this.innerHTML); })
);
}
}
$container.append($street).append($highway).append($otherDrivable).append($nonDrivable);
$dropDown.before($container);
}
function addDirectionButtons() {
var $dropDown = $(_directionDropDownSelector);
$('#csDirectionButtonsContainer').remove();
var $form = $('<div>', {id:"csDirectionButtonsContainer",style:"height:30px;padding-top:0px"});
for (var prop in _directions) {
if (prop !== 'unknown' || $('select[name="direction"]').has('option[value="0"]')) {
$form.append(
$('<div class="controls-container" style="float: left; margin-right: 12px;margin-left:0px">').append(
$('<input type="radio" name="direction" title="' + _directions[prop].title + '" id="' + prop + '" value="' + _directions[prop].val + '"' + (_directions[prop].val == $dropDown.val() ? ' checked' : '') + '>)')
.click(function() {
$(_directionDropDownSelector).val($(this).attr('value')).change();
hideAvgSpeedCameras();
})).append(
$('<label for="' + prop + '" style="padding-left: 20px;">').text(_directions[prop].text))
);
}
}
$dropDown.before($form);
$dropDown.hide();
}
function addLockButtons() {
var $lockDropDown = $(_lockDropDownSelector);
var selItems = W.selectionManager.selectedItems;
var item = selItems[0];
var isSegments = (item.model.type === "segment");
var attr = item.model.attributes;
var autoRank = attr.rank;
var manualRank = attr.lockRank;
var firstManualRank = manualRank;
var userRank = W.loginManager.getUserRank();
var maxAutoRank = autoRank;
var multiRanks = false;
var isOutranked =( manualRank > userRank || (manualRank === null && autoRank > userRank));
for (var i=1; i<selItems.length; i++) {
item = selItems[i];
attr = item.model.attributes;
autoRank = attr.rank;
manualRank = attr.lockRank;
multiRanks |= (manualRank !== firstManualRank);
isOutranked |= (manualRank > userRank || (manualRank === null && autoRank > userRank));
maxAutoRank = autoRank > maxAutoRank ? autoRank : maxAutoRank;
}
var $div = $('#csLockButtonsContainer');
$div.remove();
$div = $('<div>',{id:'csLockButtonsContainer',style:'margin-bottom:5px;'});
var btnInfos = [];
var disabled = $lockDropDown.attr('disabled') === 'disabled';
if (isSegments) {btnInfos.push({r:maxAutoRank,title:'Auto (' + (maxAutoRank + 1) + ')',val:null});}
for(var iBtn=0;iBtn<=6;iBtn++){btnInfos.push({r:iBtn,val:iBtn});}
btnInfos.forEach(function(btnInfo){
var selected = !multiRanks && (btnInfo.val === manualRank);
if (btnInfo.val !== 6 || (!multiRanks && firstManualRank === 6)) {
$div.append(
$('<div>', {
class:'btn btn-lh' + (selected ? ' btn-lh-selected':'') + (btnInfo.r < 6 & (userRank < btnInfo.r || isOutranked || disabled) ? ' disabled' : '')
})
.text(btnInfo.hasOwnProperty('title') ? btnInfo.title : btnInfo.r + 1)
.data('val',btnInfo.hasOwnProperty('val') ? btnInfo.val : btnInfo.r + 1)
.hover(function() {})
.click(function() {
if(btnInfo.r < 6 || !isOutranked) {
$(_lockDropDownSelector).val($(this).data('val')).change();
addLockButtons($(_lockDropDownSelector));
} else {
var a = new Audio('https://c6.rbxcdn.com/6db610c9a3bf131f1db6c785f465406d');
a.play();
}
})
);
}
});
if (multiRanks) {
$div.append($('<div>').text('Múltiplos bloqueios de níveis selecionado!').css({color:'red',fontSize:'smaller',fontWeight:'bold',marginLeft:'20px'}));
}
$lockDropDown.before($div);
$lockDropDown.hide();
}
function addElevationButtons() {
var id = 'csElevationButtonsContainer';
if ($('#' + id).length===0) {
var $dropDown = $(_elevationDropDownSelector);
var baseClass = 'btn btn-default' + ($dropDown.attr('disabled') ? ' disabled' : '');
var style = 'height: 20px;line-height: 20px;padding-left: 8px;padding-right: 8px;margin-right: 4px;padding-top: 1px;';
var $div = $('<div>', {id:id, style:'margin-bottom: 5px;'}).append(
$('<div>',{class:baseClass, style:style}).text('-').click(function() {
var level = parseInt($(_elevationDropDownSelector).val());
if (level > -5) { $(_elevationDropDownSelector).val(level - 1).change(); }
})
).append(
$('<div>',{class:baseClass, style:style}).text('Ground')
.click(function() {
var level = parseInt($(_elevationDropDownSelector).val());
if (level !== 0) { $(_elevationDropDownSelector).val(0).change(); }
})
).append(
$('<div>',{class:baseClass, style:style}).text('+').click(function() {
var level = parseInt($(_elevationDropDownSelector).val());
if (level < 9) { $(_elevationDropDownSelector).val(level + 1).change(); }
})
);
$dropDown.css({display:'inline-block',width:'120px',marginRight:'10px'});
$dropDown.before($div);
$dropDown.detach();
$div.prepend($dropDown);
}
}
function showScriptInfoAlert() {
/* Check version and alert on update */
if (_alertUpdate && _scriptVersion !== _lastScriptVersion) {
alert(_scriptVersionChanges);
}
}
function shadeColor2(color, percent) {
var f=parseInt(color.slice(1),16),t=percent<0?0:255,p=percent<0?percent*-1:percent,R=f>>16,G=f>>8&0x00FF,B=f&0x0000FF;
return "#"+(0x1000000+(Math.round((t-R)*p)+R)*0x10000+(Math.round((t-G)*p)+G)*0x100+(Math.round((t-B)*p)+B)).toString(16).slice(1);
}
function buildRoadTypeButtonCss() {
var lines = [];
var isStreetVector = typeof(Waze.map.getLayersByName('Street Vector Layer')[0]) !== 'undefined';
for (var roadTypeAbbr in _roadTypes) {
var roadType = _roadTypes[roadTypeAbbr];
var bgColor = isStreetVector ? roadType.svColor : roadType.wmeColor;
var output = '.rth-btn-container .btn-rth-' + roadTypeAbbr + ' {background-color:' + bgColor + ';box-shadow:0 2px ' + shadeColor2(bgColor, -0.5) + ';border-color:' + shadeColor2(bgColor,-0.15) + ';}';
output += ' .rth-btn-container .btn-rth-' + roadTypeAbbr + ':hover {background-color:' + shadeColor2(bgColor,0.2) + '}';
lines.push(output);
}
return lines.join(' ');
}
function injectCss() {
var css = [
// Road type button formatting
'.rth-btn-container {margin-bottom:5px;}',
'.rth-btn-container .btn-rth {font-size:11px;line-height:20px;color:black;padding:0px 4px;height:20px;margin-right:2px;border-style:solid;border-width:1px;}',
buildRoadTypeButtonCss(),
'.btn.btn-rth:active {box-shadow:none;transform:translateY(2px)}',
'div .cs-rt-btn-container {float:left; margin: 0px 5px 5px 0px;}',
'#sidepanel-clicksaver .controls-container {padding:0px;}',
// Lock button formatting
'.btn-lh {cursor:pointer;padding:1px 6px;height:22px;border:solid 1px #c1c1c1;margin-right:3px;}',
'.btn.btn-lh.btn-lh-selected {background-color:#6999ae;color:white}',
'.btn.btn-lh.btn-lh-selected:hover {color:white}',
'.btn.btn-lh.disabled {color:#909090;background-color:#f7f7f7;}',
'.btn.btn-lh.btn-lh-selected.disabled {color:white;background-color:#6999ae;}'
].join(' ');
$('<style type="text/css">' + css + '</style>').appendTo('head');
}
function inlineRoadTypeCheckboxes() {
// TODO - move styling to css.
var $div = $('<div>',{style:'font-size:11px;display:inline-block;'});
['tollRoadCheck','unpavedCheckbox','tunnelCheckbox'].forEach(function(id) {
$('label[for="' + id + '"]').css({paddingLeft:'20px'});
$('#' + id).parent().css({float:'left',marginRight:'4px'}).detach().appendTo($div);
});
$(_roadTypeDropDownSelector).after($div);
}
function hideAvgSpeedCameras() {
$('#fwdSpeedCameraCheckbox').closest('.form-group').hide();
$('#revSpeedCameraCheckbox').closest('.form-group').hide();
}
function onModeChanged(model, modeId, context) {
if(!modeId || modeId === 1) {
initUserPanel();
loadSettingsFromStorage();
}
}
function initUserPanel() {
var $roadTypesDiv = $('<div>', {class:'csRoadTypeButtonsCheckBoxContainer'});
for (var roadTypeAbbr in _roadTypes) {
var roadType = _roadTypes[roadTypeAbbr];
var id = 'cs' + roadTypeAbbr + 'CheckBox';
var $check = $roadTypesDiv.append(
$('<div>',{class:'controls-container',style:'padding-left: 30px'}).append(
$('<input>', {type:'checkbox',class:'csSettingsCheckBox',name:id, id:id, 'data-setting-name':'roadType', 'data-road-type':roadTypeAbbr})).append(
$('<label>', {for:id}).text(roadType.title)
)
);
if (roadTypeAbbr === 'PLR') {
id = 'csClearNewPLRCheckBox';
$roadTypesDiv.append(
$('<div>',{class:'controls-container',style:'padding-left: 40px'}).append(
$('<input>', {type:'checkbox',class:'csSettingsCheckBox',name:id,id:id,'data-setting-name':'setNewPLRStreetToNone'})).append(
$('<label>', {for:id, style:'font-style: italic;',title:'NOTE: Only works if connected directly or indirectly to a segment with State/Country already set.'})
.text('Set Street/City to None (new PLRs)'))
);
}
}
var $tab = $('<li>',{title:'ClickSaver'}).append(
$('<a>', {'data-toggle':'tab', href:'#sidepanel-clicksaver'}).append($('<span>').text('CS'))
);
var $panel = $('<div>', {class:'tab-pane', id:'sidepanel-clicksaver'}).append(
$('<div>', {class:'side-panel-section>'}).append(
$('<div>', {style: 'margin-bottom:8px;'}).append(
$('<div>', {class:'form-group'}).append(
$('<label>', {class:"control-label"}).text('SUPORTE DE EDIÇÃO')
).append(
$('<div>').append(
$('<div>',{class:'controls-container'})
.append($('<input>', {type:'checkbox',class:'csSettingsCheckBox',name: 'csRoadTypeButtonsCheckBox', id:'csRoadTypeButtonsCheckBox', 'data-setting-name':'roadButtons'}))
.append($('<label>', {for:'csRoadTypeButtonsCheckBox'}).text('Adicionar botões de tipo de vias:'))
).append(
$roadTypesDiv
)
).append(
$('<div>',{class:'controls-container'})
.append($('<input>', {type:'checkbox',class:'csSettingsCheckBox',name:'csDirectionButtonsCheckBox',id:'csDirectionButtonsCheckBox', 'data-setting-name':'directionButtons'}))
.append($('<label>', {for:'csDirectionButtonsCheckBox'}).text('Adicionar botões de direção da via.'))
).append(
$('<div>',{class:'controls-container'})
.append($('<input>', {type:'checkbox',class:'csSettingsCheckBox',name:'csElevationButtonsCheckBox',id:'csElevationButtonsCheckBox', 'data-setting-name':'elevationButtons'}))
.append($('<label>', {for:'csElevationButtonsCheckBox'}).text('Adicionar botões de elevação.'))
).append(
$('<div>',{class:'controls-container'})
.append($('<input>', {type:'checkbox',class:'csSettingsCheckBox',name:'csLockButtonsCheckBox',id:'csLockButtonsCheckBox', 'data-setting-name':'lockButtons'}))
.append($('<label>', {for:'csLockButtonsCheckBox'}).text('Adicionar botões de bloqueio.'))
)
).append(
$('<label>', {class:"control-label"}).text('POUPAR ESPAÇO')
).append(
$('<div>', {style:'margin-bottom:20px;'}).append(
$('<div>',{class:'controls-container'})
.append($('<input>', {type:'checkbox',class:'csSettingsCheckBox',name:'csInlineRoadTypesCheckBox',id:'csInlineRoadTypesCheckBox', 'data-setting-name':'inlineRoadTypeCheckboxes'}))
.append($('<label>', {for:'csInlineRoadTypesCheckBox'}).text('Inline road type checkboxes'))
).append(
$('<div>',{class:'controls-container'})
.append($('<input>', {type:'checkbox',class:'csSettingsCheckBox',name:'csHideAvgSpeedCamerasCheckBox',id:'csHideAvgSpeedCamerasCheckBox', 'data-setting-name':'hideAvgSpeedCameras'}))
.append($('<label>', {for:'csHideAvgSpeedCamerasCheckBox'}).text('Esconder "Radar de velocidade média"'))
)
)
)
);
$panel.append(
$('<div>',{style:'margin-top:10px;font-size:10px;color:#999999;'})
.append($('<div>').text('version ' + _scriptVersion))
.append(
$('<div>').append(
$('<a>',{href:'https://www.waze.com/forum/viewtopic.php?f=819&t=199894', target:'__blank'}).text('Discussion Forum')
)
)
);
$('#user-tabs > .nav-tabs').append($tab);
$('#user-info > .flex-parent > .tab-content').append($panel);
// Add change events
$('#csRoadTypeButtonsCheckBox').change(function() {
if(this.checked) {
$('.csRoadTypeButtonsCheckBoxContainer').show();
} else {
$('.csRoadTypeButtonsCheckBoxContainer').hide();
}
saveSettingsToStorage();
});
$('.csSettingsCheckBox').change(function() {
var checked = this.checked;
var settingName = $(this).data('setting-name');
if (settingName === 'roadType') {
var roadType = $(this).data('road-type');
var array = _settings.roadTypeButtons;
var index = array.indexOf(roadType);
if(checked && index === -1) {
array.push(roadType);
} else if (!checked && index !== -1) {
array.splice(index, 1);
}
} else {
_settings[settingName] = checked;
}
saveSettingsToStorage();
});
}
function updateControls() {
if($(_roadTypeDropDownSelector).length>0) {
if(isChecked('csRoadTypeButtonsCheckBox')) addRoadTypeButtons();
if(isChecked('csHideAvgSpeedCamerasCheckBox')) hideAvgSpeedCameras();
if(isChecked('csInlineRoadTypesCheckBox')) inlineRoadTypeCheckboxes();
}
if($(_lockDropDownSelector).length>0) {
if(isChecked('csLockButtonsCheckBox')) addLockButtons();
}
if($(_directionDropDownSelector).length>0) {
if(isChecked('csDirectionButtonsCheckBox')) addDirectionButtons();
}
if ($(_elevationDropDownSelector).length>0) {
if(isChecked('csElevationButtonsCheckBox')) addElevationButtons();
}
}
function init() {
_lastScriptVersion = localStorage.getItem('wmeClickSaver_lastVersion');
localStorage.setItem('wmeClickSaver_lastVersion', _scriptVersion);
showScriptInfoAlert();
// check for changes in the edit-panel
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
// Mutation is a NodeList and doesn't support forEach like an array
for (var i = 0; i < mutation.addedNodes.length; i++) {
var addedNode = mutation.addedNodes[i];
// Only fire up if it's a node
if (addedNode.nodeType === Node.ELEMENT_NODE) {
if(addedNode.querySelector(_roadTypeDropDownSelector)) {
if(isChecked('csRoadTypeButtonsCheckBox')) addRoadTypeButtons();
if(isChecked('csHideAvgSpeedCamerasCheckBox')) hideAvgSpeedCameras();
if(isChecked('csInlineRoadTypesCheckBox')) inlineRoadTypeCheckboxes();
}
if(addedNode.querySelector(_lockDropDownSelector)) {
if(isChecked('csLockButtonsCheckBox')) addLockButtons();
}
if(addedNode.querySelector(_directionDropDownSelector)) {
if(isChecked('csDirectionButtonsCheckBox')) addDirectionButtons();
}
if (addedNode.querySelector(_elevationDropDownSelector)) {
if(isChecked('csElevationButtonsCheckBox')) addElevationButtons();
}
}
}
});
});
observer.observe(document.getElementById('edit-panel'), { childList: true, subtree: true });
injectCss();
initUserPanel();
loadSettingsFromStorage();
unsafeWindow.addEventListener('beforeunload', function saveOnClose() { saveSettingsToStorage(); }, false);
Waze.app.modeController.model.bind('change:mode', onModeChanged);
Waze.prefs.on("change:isImperial", function() {initUserPanel();loadSettingsFromStorage();});
updateControls(); // In case of PL w/ segments selected.
Waze.selectionManager.events.register("selectionchanged", null, updateControls);
}
function bootstrap() {
if (Waze && Waze.loginManager &&
Waze.loginManager.events.register &&
Waze.map && Waze.loginManager.isLoggedIn()) {
log('Inicializando', 0);
init();
} else {
log('Bootstrap falhou. Tente novamente...', 0);
unsafeWindow.setTimeout(function () {
bootstrap();
}, 1000);
}
}
log('Bootstrap...', 0);
bootstrap();
})();
[/code]
Note that I took off this part because is unusefull (but I keep the rest):
unknown:{val:0, text:'?', title:'Unknown'}
This script makes me SO happy! Thank you!!
Another minor request: Can you please add the option to automatically set No City and No Name for Unpaved roads, as is done for PLRs? In my experience, adding any notable amount of unpaved segments is nearly certain to be outside of a city.
Again, thanks so much for this terrific script!
Thanks SeveriorumPatrem. I’ve considered adding more road types for that feature, but have decided not to based on push back from senior editors. It’s a controversial topic (automating anything). I may revisit the idea someday if it makes sense to. BTW, that feature is completely broken in WME beta due to a WME change. If we’re not able to find a workaround, it will be a moot point anyway ![]()
OK, thanks for the reply, appreciated very much.
The update to this script this morning has now killed the ability work URs. URs will not open/populate once you click them. I traced it back to this script after disabling all others one-by-one.
Thank you!
Thanks for the report. I’m checking it out now…
I have ClickSaver enabled but am not having any UR problems… However, I’ve found a load-order conflict with WME Clear Geometry. If ClickSaver loads first, everything seems OK. If Clear Geometry loads first, its hotkey won’t function. I’m guessing they both override something in common?