User:ScitDei/GeoCoordTool.js
Appearance
Coordinates: Coordinates: Unable to parse latitude as a number:" +lat+ "
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:ScitDei/GeoCoordTool. |
javascript:
var uri=window.location.href;
var uricoordset=uri.substring(uri.indexOf("@"));
var coordset=uricoordset.substring(0,uricoordset.indexOf("z"));
var lat=coordset.substring(1,uricoordset.indexOf(","));
var longtext=coordset.substring(uricoordset.indexOf(","));
var long=longtext.substring(1,uricoordset.indexOf(","));
prompt("Please copy the following code and replace the '{{coord missing}}' tag", "{{coord|" +lat+ "|" +long+ "|display=title}}");
///*
//
//var txt=document.editform.wpTextbox1;
//txt.value = geocordify(txt.value);
//function geocordify(str) { //MAIN FUNCTION describes list of fixes
//// Task 1: Replace named html entities with unicode
//// Most common replacements
//var strtpos = str.find('coord missing|')-2;
//var endpos = str.substring(startpos).indexOf('}');
//
//function geocordEditSummary() {
// var txt = document.forms.editform.wpSummary;
// var tag;
//
// if( typeof geocordTag === 'undefined' ) {
// tag = 'Cordinates added using [[WP:User:ScitDei/GeoCordTool.js|GeoCordTool]]';
// } else {
// tag = geocordTag;
// }
//
// // Is the tag blank?
// if( tag.match(/[^\s]/) ) {
// // Has it already been tagged?
// if( txt.value.indexOf(tag) == -1 ) {
// // Append a pipe if necessary
// if( txt.value.match(/[^\*\/\s][^\/\s]?\s*$/) ) {
// txt.value += ' | ';
// }
// // Append our tag
// txt.value += tag;
// }
// }
//
//***/
// This example adds a search box to a map, using the Google Place Autocomplete
// feature. People can enter geographical searches. The search box will return a
// pick list containing a mix of places and predicted search terms.
// This example requires the Places library. Include the libraries=places
// parameter when you first load the API. For example:
// <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">
/*
// Get the modal
var modal = document.createElement("div");
modal.style.display = "none";
modal.style.position = "fixed";
modal.style.zIndex = "1";
modal.style.paddingTop = "100px";
modal.style.left = "0";
modal.style.top = "0";
modal.style.width = "100%";
modal.style.height = "100%";
modal.style.overflow = "auto";
modal.style.backgroundColor = "rgb(0,0,0)";
modal.style.backgroundColor = "rgba(0,0,0,0.4)";
var modaldiv = document.createElement("div");
modaldiv.style.backgroundColor = "#fefefe";
modaldiv.style.margin = "auto";
modaldiv.style.padding = "20px";
modaldiv.style.border = "1px solid #888";
modaldiv.style.width = "80%";
var spn = document.createElement("span");
var tspn = document.createTextNode("x");
spn.appendChild(tspn);
spn.style.color = "#aaaaaa";
spn.style.float = "right";
spn.style.fontSize = "28px";
spn.style.fontWeight = "bold";
var para = document.createElement("P");
var t = document.createTextNode("Some text in the Modal.");
para.appendChild(t);
var newframe = document.createElement("iframe");
newframe.setAttribute("src","https://www.google.com/maps/embed/v1/search?q=" + mw.config.get('wgPageName') + "&key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI");
newframe.style.border = "none";
para.appendChild(newframe);
modaldiv.appendChild(spn);
modaldiv.appendChild(para);
modal.appendChild(modaldiv);
document.body.appendChild(modal);
modal.style.display = "block";
// When the user clicks on <span> (x), close the modal
spn.onclick = function() {
modal.style.display = "none";
};
spn.onmouseover = function() {
spn.style.color = "#000";
spn.style.textDecoration = "none";
spn.style.cursor = "pointer";
};
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
};
*/
/*
var newItem = document.createElement("input");
newItem.setAttribute("id","pac-input");
newItem.style.backgroundColor = "#fff";
newItem.style.fontFamily = "Roboto";
newItem.style.fontSize= "15px";
newItem.style.fontWeight="300";
newItem.style.marginLeft= "12px";
newItem.style.padding="0 11px 0 13px";
newItem.style.textOverflow="ellipsis";
newItem.style.width="400px";
newItem.setAttribute("height","10px");
newItem.setAttribute("type","text");
newItem.setAttribute("placeholder","Search Box");
modal.appendChild(newItem);
var newItem2 = document.createElement("div");
newItem2.setAttribute("id","map");
newItem2.setAttribute("value","map1");
modal.appendChild(newItem2);
var newItem3 = document.createElement("script");
newItem3.setAttribute("src","https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk&libraries=places&callback=initAutocomplete");
//newItem3.setAttribute("value","map1");
modal.appendChild(newItem3);
function initAutocomplete() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -33.8688, lng: 151.2195},
zoom: 13,
mapTypeId: 'roadmap'
});
// Create the search box and link it to the UI element.
var input = document.getElementById('pac-input');
var searchBox = new google.maps.places.SearchBox(input);
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
// Bias the SearchBox results towards current map's viewport.
map.addListener('bounds_changed', function() {
searchBox.setBounds(map.getBounds());
});
var markers = [];
// Listen for the event fired when the user selects a prediction and retrieve
// more details for that place.
searchBox.addListener('places_changed', function() {
var places = searchBox.getPlaces();
if (places.length == 0) {
return;
}
// Clear out the old markers.
markers.forEach(function(marker) {
marker.setMap(null);
});
markers = [];
// For each place, get the icon, name and location.
var bounds = new google.maps.LatLngBounds();
places.forEach(function(place) {
if (!place.geometry) {
console.log("Returned place contains no geometry");
return;
}
var icon = {
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(25, 25)
};
// Create a marker for each place.
markers.push(new google.maps.Marker({
map: map,
icon: icon,
title: place.name,
position: place.geometry.location
}));
if (place.geometry.viewport) {
// Only geocodes have viewport.
bounds.union(place.geometry.viewport);
} else {
bounds.extend(place.geometry.location);
}
});
map.fitBounds(bounds);
});
}
*/