Add geoButton, getGmina, messages, and translate handler files with initial implementations
This commit is contained in:
9
js/handlers/geoButton.js
Normal file
9
js/handlers/geoButton.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
const currentUrl = document.location.href;
|
||||||
|
|
||||||
|
if (currentUrl.startsWith('https://mapy.geoportal.gov.pl/')) {
|
||||||
|
// Execute code specific to the example.com website
|
||||||
|
console.log('This is the example.com website.');
|
||||||
|
} else {
|
||||||
|
// Execute default code
|
||||||
|
console.log('This is a different website.');
|
||||||
|
}
|
||||||
0
js/handlers/getChelmiec.js
Normal file
0
js/handlers/getChelmiec.js
Normal file
22
js/handlers/getGmina.js
Normal file
22
js/handlers/getGmina.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
function getGmina(width, height, XMIN, YMIN, XMAX, YMAX) {
|
||||||
|
const URL = `https://integracja.gugik.gov.pl/cgi-bin/KrajowaIntegracjaEwidencjiGruntow?VERSION=1.1.1&SERVICE=WMS&REQUEST=GetFeatureInfo&LAYERS=dzialki,numery_dzialek,budynki&QUERY_LAYERS=dzialki,numery_dzialek,budynki&SRS=EPSG:2180&WIDTH=${width}&HEIGHT=${height}&TRANSPARENT=TRUE&FORMAT=image/png&BBOX=${XMIN},${YMIN},${XMAX},${YMAX}`;
|
||||||
|
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
fetch(URL, {
|
||||||
|
method: "GET",
|
||||||
|
})
|
||||||
|
.then((response) => response.text())
|
||||||
|
.then((str) => new window.DOMParser().parseFromString(str, "text/xml"))
|
||||||
|
.then((data) => {
|
||||||
|
console.log(data);
|
||||||
|
for (let attr of data.getElementsByTagName("Attribute")) {
|
||||||
|
if (attr.getAttribute("Name") == "Gmina") {
|
||||||
|
console.log(attr.innerHTML);
|
||||||
|
let dooda = attr.innerHTML;
|
||||||
|
resolve(dooda);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolve(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
268
js/handlers/messages.js
Normal file
268
js/handlers/messages.js
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
function handleMessage(msg) {
|
||||||
|
console.log(msg)
|
||||||
|
if (msg.command == "STARTED") {
|
||||||
|
MapData = JSON.parse(msg.data);
|
||||||
|
console.log(MapData);
|
||||||
|
console.log("MapData loaded");
|
||||||
|
|
||||||
|
if (MapOn == false) {
|
||||||
|
MapOn = true;
|
||||||
|
// ico
|
||||||
|
// height: 26px;
|
||||||
|
// width: 26px;
|
||||||
|
// #343a40
|
||||||
|
// let navBarEl = document.getElementsByClassName("navbar-collapse")[1];
|
||||||
|
const titleDiv = document.getElementById("title");
|
||||||
|
let nextElement = titleDiv.nextElementSibling;
|
||||||
|
let navBarEl = nextElement.nextElementSibling;
|
||||||
|
|
||||||
|
let geoIcon = document.createElement("img");
|
||||||
|
geoIcon.src = chrome.runtime.getURL("icons/geoportal.png");
|
||||||
|
geoIcon.width = "26";
|
||||||
|
geoIcon.height = "26";
|
||||||
|
geoButton.style.border = "none";
|
||||||
|
geoButton.style.background = "none";
|
||||||
|
geoButton.appendChild(geoIcon);
|
||||||
|
navBarEl.insertBefore(geoButton, navBarEl.children[0]);
|
||||||
|
geoButton.onclick = geoportalButtonClick;
|
||||||
|
|
||||||
|
let googleIcon = document.createElement("img");
|
||||||
|
googleIcon.src = chrome.runtime.getURL("icons/google.png");
|
||||||
|
googleIcon.width = "26";
|
||||||
|
googleIcon.height = "26";
|
||||||
|
googleButton.style.border = "none";
|
||||||
|
googleButton.style.background = "none";
|
||||||
|
googleButton.appendChild(googleIcon);
|
||||||
|
navBarEl.insertBefore(googleButton, navBarEl.children[0]);
|
||||||
|
googleButton.onclick = googleButtonClick;
|
||||||
|
|
||||||
|
let isokIcon = document.createElement("img");
|
||||||
|
isokIcon.src = chrome.runtime.getURL("icons/isok.png");
|
||||||
|
isokIcon.width = "26";
|
||||||
|
isokIcon.height = "26";
|
||||||
|
isokButton.style.border = "none";
|
||||||
|
isokButton.style.background = "none";
|
||||||
|
isokButton.appendChild(isokIcon);
|
||||||
|
navBarEl.insertBefore(isokButton, navBarEl.children[0]);
|
||||||
|
isokButton.onclick = isokButtonClick;
|
||||||
|
|
||||||
|
let sopoIcon = document.createElement("img");
|
||||||
|
sopoIcon.src = chrome.runtime.getURL("icons/sopo.png");
|
||||||
|
sopoIcon.width = "26";
|
||||||
|
sopoIcon.height = "26";
|
||||||
|
sopoButton.style.border = "none";
|
||||||
|
sopoButton.style.background = "none";
|
||||||
|
sopoButton.appendChild(sopoIcon);
|
||||||
|
navBarEl.insertBefore(sopoButton, navBarEl.children[0]);
|
||||||
|
sopoButton.onclick = sopoButtonClick;
|
||||||
|
|
||||||
|
let gdosIcon = document.createElement("img");
|
||||||
|
gdosIcon.src = chrome.runtime.getURL("icons/gdos.png");
|
||||||
|
gdosIcon.width = "26";
|
||||||
|
gdosIcon.height = "26";
|
||||||
|
gdosButton.style.border = "none";
|
||||||
|
gdosButton.style.background = "none";
|
||||||
|
gdosButton.appendChild(gdosIcon);
|
||||||
|
navBarEl.insertBefore(gdosButton, navBarEl.children[0]);
|
||||||
|
gdosButton.onclick = gdosButtonClick;
|
||||||
|
|
||||||
|
let drogiIcon = document.createElement("img");
|
||||||
|
drogiIcon.src = chrome.runtime.getURL("icons/lpp.png");
|
||||||
|
drogiIcon.width = "26";
|
||||||
|
drogiIcon.height = "26";
|
||||||
|
drogiButton.style.border = "none";
|
||||||
|
drogiButton.style.background = "none";
|
||||||
|
drogiButton.appendChild(drogiIcon);
|
||||||
|
navBarEl.insertBefore(drogiButton, navBarEl.children[0]);
|
||||||
|
drogiButton.onclick = drogiButtonClick;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// dzialkiIcon.src = chrome.runtime.getURL("icons/dzialki1.png");
|
||||||
|
// dzialkiIcon.width = "26";
|
||||||
|
// dzialkiIcon.height = "26";
|
||||||
|
// dzialkiButton.style.border = "none";
|
||||||
|
// dzialkiButton.style.background = "none";
|
||||||
|
// dzialkiButton.appendChild(dzialkiIcon);
|
||||||
|
// navBarEl.insertBefore(dzialkiButton, navBarEl.children[0]);
|
||||||
|
// dzialkiButton.onclick = dzialkiButtonClick;
|
||||||
|
|
||||||
|
|
||||||
|
// dzialki2Icon.src = chrome.runtime.getURL("icons/dzialki2.png");
|
||||||
|
// dzialki2Icon.width = "26";
|
||||||
|
// dzialki2Icon.height = "26";
|
||||||
|
// dzialki2Button.style.border = "none";
|
||||||
|
// dzialki2Button.style.background = "none";
|
||||||
|
// dzialki2Button.appendChild(dzialki2Icon);
|
||||||
|
// navBarEl.insertBefore(dzialki2Button, navBarEl.children[0]);
|
||||||
|
// dzialki2Button.onclick = dzialki2ButtonClick;
|
||||||
|
|
||||||
|
// mpzpIcon.src = chrome.runtime.getURL("icons/mpzp.png");
|
||||||
|
// mpzpIcon.width = "26";
|
||||||
|
// mpzpIcon.height = "26";
|
||||||
|
// mpzpButton.style.border = "none";
|
||||||
|
// mpzpButton.style.background = "none";
|
||||||
|
// mpzpButton.appendChild(mpzpIcon);
|
||||||
|
|
||||||
|
// navBarEl.insertBefore(mpzpButton, navBarEl.children[0]);
|
||||||
|
// mpzpButton.onclick = mpzpButtonClick;
|
||||||
|
|
||||||
|
// osuwiskaButton.appendChild(document.createTextNode("SOPO"));
|
||||||
|
// navBarEl.insertBefore(osuwiskaButton, navBarEl.children[0]);
|
||||||
|
// osuwiskaButton.onclick = osuwiskaButtonClick;
|
||||||
|
|
||||||
|
// navBarEl.insertBefore(
|
||||||
|
// document.createElement("DIV"),
|
||||||
|
// navBarEl.children[0]
|
||||||
|
// );
|
||||||
|
// navBarEl.firstChild.style.height = "2rem";
|
||||||
|
// navBarEl.firstChild.style.background = "gray";
|
||||||
|
// navBarEl.firstChild.style.padding = "1px";
|
||||||
|
// navBarEl.firstChild.style.margin = "6px";
|
||||||
|
|
||||||
|
// fetch(chrome.extension.getURL("page.html"))
|
||||||
|
// .then((response) => response.text())
|
||||||
|
// .then((text) => {
|
||||||
|
// dropdownButton.innerHTML = text;
|
||||||
|
// navBarEl.insertBefore(dropdownButton, navBarEl.children[0]);
|
||||||
|
// let button = document.getElementById("dropdown-button");
|
||||||
|
// let buttonIcon = document.createElement("img");
|
||||||
|
// buttonIcon.src = chrome.runtime.getURL("icons/slice.png");
|
||||||
|
// buttonIcon.width = "26";
|
||||||
|
// buttonIcon.height = "26";
|
||||||
|
// button.style.border = "none";
|
||||||
|
// button.style.background = "none";
|
||||||
|
// button.appendChild(buttonIcon);
|
||||||
|
|
||||||
|
// let content = document.getElementById("dropdown-content");
|
||||||
|
|
||||||
|
// let sectionDownloadIcon = document.createElement("img");
|
||||||
|
// sectionDownloadIcon.src = chrome.runtime.getURL("icons/save.png");
|
||||||
|
// sectionDownloadIcon.width = "26";
|
||||||
|
// sectionDownloadIcon.height = "26";
|
||||||
|
// sectionDownload.style.border = "none";
|
||||||
|
// sectionDownload.style.background = "none";
|
||||||
|
// sectionDownload.appendChild(sectionDownloadIcon);
|
||||||
|
// content.insertBefore(sectionDownload, content.children[0]);
|
||||||
|
// sectionDownload.onclick = sectionDownloadClick;
|
||||||
|
|
||||||
|
|
||||||
|
// let sectionIcon = document.createElement("img");
|
||||||
|
// sectionIcon.src = chrome.runtime.getURL("icons/pen.png");
|
||||||
|
// sectionIcon.width = "26";
|
||||||
|
// sectionIcon.height = "26";
|
||||||
|
// sectionDraw.style.border = "none";
|
||||||
|
// sectionDraw.style.background = "none";
|
||||||
|
// sectionDraw.appendChild(sectionIcon);
|
||||||
|
// content.insertBefore(sectionDraw, content.children[0]);
|
||||||
|
// sectionDraw.onclick = sectionDrawClick;
|
||||||
|
|
||||||
|
|
||||||
|
// button.onclick = abc;
|
||||||
|
|
||||||
|
// function abc(){
|
||||||
|
// if(dropdownState == 0) {
|
||||||
|
// content.style.display = "flex"
|
||||||
|
// dropdownState = 1;
|
||||||
|
// }else{
|
||||||
|
// content.style.display = "none"
|
||||||
|
// dropdownState = 0;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // sectionDraw.appendChild(document.createTextNode("Prz"));
|
||||||
|
// // navBarEl.insertBefore(sectionDraw, navBarEl.children[0]);
|
||||||
|
// // sectionDraw.onclick = sectionDrawClick;
|
||||||
|
|
||||||
|
// // sectionDownload.appendChild(document.createTextNode("Pb"));
|
||||||
|
// // navBarEl.insertBefore(sectionDownload, navBarEl.children[0]);
|
||||||
|
// // sectionDownload.onclick = sectionDownloadClick;
|
||||||
|
|
||||||
|
// posIcon.src = chrome.runtime.getURL("icons/position.png");
|
||||||
|
// posIcon.width = "26";
|
||||||
|
// posIcon.height = "26";
|
||||||
|
// posButton.style.border = "none";
|
||||||
|
// posButton.style.background = "none";
|
||||||
|
// posButton.appendChild(posIcon);
|
||||||
|
|
||||||
|
// navBarEl.insertBefore(posButton, navBarEl.children[0]);
|
||||||
|
// posButton.onclick = getPos;
|
||||||
|
|
||||||
|
// lineButton.appendChild(document.createTextNode("Linia"));
|
||||||
|
// navBarEl.insertBefore(lineButton, navBarEl.children[0]);
|
||||||
|
// lineButton.onclick = getLines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if (msg.command == "linesResult") {
|
||||||
|
// drawLines(msg.result);
|
||||||
|
// }
|
||||||
|
// if (msg.command == "gotLine") {
|
||||||
|
// let attr = document.getElementById("attribute");
|
||||||
|
// if (attr == null) {
|
||||||
|
// setTimeout(function () {
|
||||||
|
// purgeLineTable(attr);
|
||||||
|
// drawCalcButton(attr);
|
||||||
|
// }, 500);
|
||||||
|
// } else {
|
||||||
|
// purgeLineTable(attr);
|
||||||
|
// drawCalcButton(attr);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// cell1.innerHTML = txt1;
|
||||||
|
// cell2.innerHTML = txt2;
|
||||||
|
// }
|
||||||
|
if (msg.command == "gotStacja") {
|
||||||
|
if (stacjaReq != 1) {
|
||||||
|
let attr = document.getElementById("attribute");
|
||||||
|
if (attr == null) {
|
||||||
|
setTimeout(function () {
|
||||||
|
attr = document.getElementById("attribute");
|
||||||
|
purgeTable(attr);
|
||||||
|
drawButton(attr);
|
||||||
|
}, 500);
|
||||||
|
} else {
|
||||||
|
purgeTable(attr);
|
||||||
|
drawButton(attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (msg.command == "stacjaResult") {
|
||||||
|
stacjaReq = 0;
|
||||||
|
data = msg.result;
|
||||||
|
|
||||||
|
let attr = document.getElementById("attribute");
|
||||||
|
|
||||||
|
const dataNames = [
|
||||||
|
"Rok budowy",
|
||||||
|
"Rok modernizacji",
|
||||||
|
"Moc stacji",
|
||||||
|
"Typ żerdz.",
|
||||||
|
"Czy niebezp.",
|
||||||
|
"Data oględzin",
|
||||||
|
"Zamk. rozdz. sn (?)",
|
||||||
|
"Zasila oświetlenie",
|
||||||
|
];
|
||||||
|
let d = data[0];
|
||||||
|
const dataData = [
|
||||||
|
d["ROK_BUD"],
|
||||||
|
d["ROK_MODERN"],
|
||||||
|
d["MAX_MOC_STAC"],
|
||||||
|
d["TYP_ZERDZ"],
|
||||||
|
d["CZY_NIEBEZP"],
|
||||||
|
d["DATA_OGLEDZ"],
|
||||||
|
d["ZAMK_ROZDZ_SN"],
|
||||||
|
d["CZY_ZAS_OSW"],
|
||||||
|
];
|
||||||
|
|
||||||
|
insertRows(attr, dataNames, dataData);
|
||||||
|
}
|
||||||
|
if (msg.command == "getToken") {
|
||||||
|
data = sessionStorage.getItem("PDSEtoken");
|
||||||
|
port.postMessage({ response: data });
|
||||||
|
}
|
||||||
|
if (msg.command == "gminaResult") {
|
||||||
|
const URL = msg.result;
|
||||||
|
window.open(URL, "_blank");
|
||||||
|
}
|
||||||
|
}
|
||||||
33
js/handlers/translate.js
Normal file
33
js/handlers/translate.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
function translate(data) {
|
||||||
|
let newData = [];
|
||||||
|
const canvas = document.getElementsByClassName("ol-unselectable")[0];
|
||||||
|
const bound = canvas.getBoundingClientRect();
|
||||||
|
|
||||||
|
// szerokość 90%
|
||||||
|
// wysokość 109%
|
||||||
|
|
||||||
|
// SZEROKOŚĆ 137
|
||||||
|
// WYSOKOŚĆ 132
|
||||||
|
const XMIN = MapData.X_MIN;
|
||||||
|
const YMIN = MapData.Y_MIN;
|
||||||
|
const XMAX = MapData.X_MAX;
|
||||||
|
const YMAX = MapData.Y_MAX;
|
||||||
|
|
||||||
|
const xratio = ((XMAX - XMIN) * 1) / bound.width;
|
||||||
|
const yratio = ((YMAX - YMIN) * 1) / bound.height;
|
||||||
|
|
||||||
|
console.log(bound.width/bound.height)
|
||||||
|
console.log((XMAX-XMIN)/(YMAX-YMIN))
|
||||||
|
|
||||||
|
// return ((val - src[0]) / (src[1]-src[0])) * (dst[1]-dst[0]) + dst[0]
|
||||||
|
|
||||||
|
for (let point of data) {
|
||||||
|
let tempx = ((point[0] - XMIN) / (XMAX-XMIN)) * (bound.width)
|
||||||
|
let tempy = ((YMAX - point[1]) / (YMAX-YMIN)) * (bound.height) ;
|
||||||
|
// let tempx = (point[0] - XMIN) / xratio;
|
||||||
|
// let tempy = (YMAX - point[1]) / yratio;
|
||||||
|
newData.push([tempx, tempy]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newData;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user