Skip to content

Commit 15412f9

Browse files
authored
Independent jQuery UI loading
1 parent a7bf5e6 commit 15412f9

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

BeenThere.js

+27-20
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
// @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
99
// @require https://greasyfork.org/scripts/27023-jscolor/code/JSColor.js
1010
// @require https://greasyfork.org/scripts/27254-clipboard-js/code/clipboardjs.js
11-
// @version 0.5.3
12-
// @grant none
11+
// @require https://greasyfork.org/scripts/28687-jquery-ui-1-11-4-custom-min-js/code/jquery-ui-1114customminjs.js
12+
// @resource jqUI_CSS https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css
13+
// @version 2017.11.14.01
14+
// @grant GM_addStyle
15+
// @grant GM_getResourceText
1316
// ==/UserScript==
1417
//---------------------------------------------------------------------------------------
1518

@@ -31,16 +34,19 @@
3134
var currColor;
3235

3336
(function() {
37+
var jqUI_CssSrc = GM_getResourceText("jqUI_CSS");
38+
GM_addStyle(jqUI_CssSrc);
39+
3440
function bootstrap(tries) {
3541
tries = tries || 1;
3642

37-
if (window.W &&
38-
window.W.map &&
39-
window.W.model &&
40-
window.W.loginManager.user &&
43+
if (W &&
44+
W.map &&
45+
W.model &&
46+
W.loginManager.user &&
4147
$ &&
42-
window.jscolor &&
43-
WazeWrap.Interface) {
48+
jscolor &&
49+
unsafeWindow.WazeWrap.Interface) {
4450
InitMapRaidOverlay();
4551
} else if (tries < 1000) {
4652
setTimeout(function () {bootstrap(tries++);}, 200);
@@ -213,7 +219,7 @@
213219
else{
214220
var point2 = getMousePos900913();
215221
var points = [new OL.Geometry.Point(userCircleCenter.lon, userCircleCenter.lat), new OL.Geometry.Point(point2.lon, point2.lat)];
216-
var radius = WazeWrap.Geometry.calculateDistance(points);
222+
var radius = unsafeWindow.WazeWrap.Geometry.calculateDistance(points);
217223
var circleData = {
218224
centerPoint : new OL.Geometry.Point(userCircleCenter.lon, userCircleCenter.lat),
219225
radius : radius,
@@ -275,7 +281,7 @@
275281
drawPointer(currMousePos, true);
276282
if(userCircleCenter){
277283
var points = [new OL.Geometry.Point(userCircleCenter.lon, userCircleCenter.lat), new OL.Geometry.Point(currMousePos.lon, currMousePos.lat)];
278-
var radius = WazeWrap.Geometry.calculateDistance(points);
284+
var radius = unsafeWindow.WazeWrap.Geometry.calculateDistance(points);
279285
drawCircle(userCircleCenter, radius);
280286
}
281287
}
@@ -362,7 +368,7 @@
362368

363369
function getMousePos900913(){
364370
var mousePosition = $('.WazeControlMousePosition').text().split(" ");
365-
return WazeWrap.Geometry.ConvertTo900913(mousePosition[0], mousePosition[1]);
371+
return unsafeWindow.WazeWrap.Geometry.ConvertTo900913(mousePosition[0], mousePosition[1]);
366372
}
367373

368374
function keyUpHandler(e){
@@ -452,7 +458,7 @@
452458

453459
LoadSettingsObj();
454460

455-
WazeWrap.Interface.AddLayerCheckbox("display", "Been There", true, LayerToggled);
461+
unsafeWindow.WazeWrap.Interface.AddLayerCheckbox("display", "Been There", true, LayerToggled);
456462

457463
//append our css to the head
458464
var g = '.beenThereButtons {font-size:26px; color:#59899e; cursor:pointer;} .flex-container {display: -webkit-flex; display: flex; background-color:black;}';
@@ -501,17 +507,18 @@
501507
setChecked('chkBTShapeFill',beenTheresettings.FillShape);
502508
$('#BeenThereSettings').css({'visibility':'visible'});
503509
});
504-
new WazeWrap.Interface.Shortcut('NewBoxShortcut', 'Draw a box around the visible area', 'wmebt', 'Been There', beenTheresettings.NewBoxShortcut, NewBox, null).add();
505-
new WazeWrap.Interface.Shortcut('NewUserRectShortcut', 'Draw a rectangle', 'wmebt', 'Been There', beenTheresettings.NewUserRectShortcut, NewUserRect, null).add();
506-
new WazeWrap.Interface.Shortcut('NewUserCircleShortcut', 'Draw a circle', 'wmebt', 'Been There', beenTheresettings.NewUserCircleShortcut, NewUserCircle, null).add();
507-
new WazeWrap.Interface.Shortcut('RemoveLastShapeShortcut', 'Remove last shape', 'wmebt', 'Been There', beenTheresettings.RemoveLastShapeShortcut, RemoveLastBox, null).add();
508-
new WazeWrap.Interface.Shortcut('RedoLastShapeShortcut', 'Redo last shape', 'wmebt', 'Been There', beenTheresettings.RedoLastShapeShortcut, RedoLastBox, null).add();
509-
new WazeWrap.Interface.Shortcut('RemoveAllShapesShortcut', 'Remove all shapes', 'wmebt', 'Been There', beenTheresettings.RemoveAllShapesShortcut, RemoveAllBoxes, null).add();
510+
new unsafeWindow.WazeWrap.Interface.Shortcut('NewBoxShortcut', 'Draw a box around the visible area', 'wmebt', 'Been There', beenTheresettings.NewBoxShortcut, NewBox, null).add();
511+
new unsafeWindow.WazeWrap.Interface.Shortcut('NewUserRectShortcut', 'Draw a rectangle', 'wmebt', 'Been There', beenTheresettings.NewUserRectShortcut, NewUserRect, null).add();
512+
new unsafeWindow.WazeWrap.Interface.Shortcut('NewUserCircleShortcut', 'Draw a circle', 'wmebt', 'Been There', beenTheresettings.NewUserCircleShortcut, NewUserCircle, null).add();
513+
new unsafeWindow.WazeWrap.Interface.Shortcut('RemoveLastShapeShortcut', 'Remove last shape', 'wmebt', 'Been There', beenTheresettings.RemoveLastShapeShortcut, RemoveLastBox, null).add();
514+
new unsafeWindow.WazeWrap.Interface.Shortcut('RedoLastShapeShortcut', 'Redo last shape', 'wmebt', 'Been There', beenTheresettings.RedoLastShapeShortcut, RedoLastBox, null).add();
515+
new unsafeWindow.WazeWrap.Interface.Shortcut('RemoveAllShapesShortcut', 'Remove all shapes', 'wmebt', 'Been There', beenTheresettings.RemoveAllShapesShortcut, RemoveAllBoxes, null).add();
510516

511517
//necessary to catch changes to the keyboard shortcuts
512-
window.addEventListener("beforeunload", function() {
518+
unsafeWindow.onbeforeunload = function() {
519+
alert("Working!");
513520
saveSettings();
514-
}, false);
521+
};
515522

516523
$('[name="currColor"]').change(function() {
517524
currColor = '#' + $('#' + this.value)[0].jscolor.toString();

0 commit comments

Comments
 (0)