Skip to content

Commit

Permalink
Automatically disable non-mapkit-compatible mods
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsumiki-Chan committed Mar 28, 2019
1 parent a9e0aa6 commit 34ad446
Show file tree
Hide file tree
Showing 7 changed files with 687 additions and 689 deletions.
61 changes: 40 additions & 21 deletions lss-manager-v3/lss-manager-v3.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ lssm.Module = {
},
source: '/modules/lss-FMS5InMap/FMS5InMap.user.js',
develop: false,
collisions: ['Layout03', 'WachenplanungOnMap']
collisions: ['Layout03', 'WachenplanungOnMap'],
nomapkit: true,
},
Clock: {
name: {
Expand All @@ -492,7 +493,8 @@ lssm.Module = {
nl: 'Toont een kleine klok op de kaart.'
},
source: '/modules/lss-clock/clock.user.js',
develop: false
develop: false,
nomapkit: true,
},
WachenplanungOnMap: {
name: {
Expand All @@ -511,7 +513,8 @@ lssm.Module = {
},
source: '/modules/lss-WachenplanungOnMap/WachenplanungOnMap.user.js',
develop: false,
collisions: ['Layout03', 'FMS5InMap', 'heatmap']
collisions: ['Layout03', 'FMS5InMap', 'heatmap'],
nomapkit: true,
},
tagMissions: {
name: {
Expand Down Expand Up @@ -587,7 +590,8 @@ lssm.Module = {
nl: 'Toont de status van voertuigen van een gebouw als je je muis boven het gebouw houdt.'
},
source: '/modules/lss-WachenHoverStati/WachenHoverStati.user.js',
develop: false
develop: false,
nomapkit: true,
},
RenameFZ: {
name: {
Expand Down Expand Up @@ -701,7 +705,8 @@ lssm.Module = {
noapp: false, // Nicht im App-Store auflisten
inframe: false,
develop: false,
collisions: ['Layout03', 'WachenplanungOnMap']
collisions: ['Layout03', 'WachenplanungOnMap'],
nomapkit: true,
},
centermap: {
name: {
Expand All @@ -718,7 +723,8 @@ lssm.Module = {
source: '/modules/lss-centermap/Centermap.user.js',
noapp: false, // Nicht im App-Store auflisten
inframe: false,
develop: false
develop: false,
nomapkit: true,
},
missionHelper: {
name: {
Expand Down Expand Up @@ -959,7 +965,8 @@ lssm.Module = {
source: "/modules/lss-overview/overview.js",
noapp: false,
inframe: true,
develop: false
develop: false,
nomapkit: true,
}
};

Expand Down Expand Up @@ -1020,24 +1027,31 @@ lssm.appstore = {
if ('noapp' in mod && mod.noapp === true || !isSupportedLocale) {
continue;
}
let panel = $('<div style="margin-top:10px;" class="lssm_module' +
let nomapkit = (typeof mapkit !== undefined && 'nomapkit' in module && module.nomapkit === true);
let dom = '<div style="margin-top:10px;" class="lssm_module' +
(mod.develop ? ' lssm_module_develop' : '') + '">' +
'<div class="panel panel-default" style="display: inline-block;width:100%;">' +
'<div class="panel-body">' +
'<span class="pull-right">' +
'<div class="onoffswitch">' +
'<input class="onoffswitch-checkbox" id="lssm.modules_' + mods[i] + '" ' +
(mod.active ? 'checked="true"' : '') + ' value="' + mods[i] +
'"name="onoffswitch" type="checkbox">' +
'<label class="onoffswitch-label" for="lssm.modules_' + mods[i] + '"></label>' +
'</div>' +
'</span>' +
'<h4>' + I18n.t('lssm.apps.' + mods[i] + '.name') + '</h4>' +
'<small style="display:none">' + I18n.t('lssm.apps.' + mods[i] + '.description') +
'</small>' +
'<span class="pull-right">';
if(!nomapkit)
dom += '<div class="onoffswitch">' +
'<input class="onoffswitch-checkbox" id="lssm.modules_' + mods[i] + '" ' +
(mod.active ? 'checked="true"' : '') + ' value="' + mods[i] +
'" name="onoffswitch" type="checkbox">' +
'<label class="onoffswitch-label" for="lssm.modules_' + mods[i] + '"></label>' +
'</div>';
dom += '</span>' +
'<h4>' + I18n.t('lssm.apps.' + mods[i] + '.name') + '</h4>';
if(!nomapkit)
dom += '<small style="display:none">' + I18n.t('lssm.apps.' + mods[i] + '.description');
else
dom += '<small>' +I18n.t('lssm.mapkit');

dom += '</small>' +
'</div>' +
'</div>' +
'</div>');
'</div>';
let panel = $(dom);
panels.find("#apps_col_" + col).append(panel);
col++;
if (col > 2) {
Expand Down Expand Up @@ -1351,7 +1365,7 @@ lssm.modules = {
uid = "?uid=" + game + user_id;
this.addLocales(module);
if (lssm.Module[module].active && lssm.Module.status !== 'develop' &&
lssm.appstore.canActivate(lssm.Module[module])) {
lssm.appstore.canActivate(lssm.Module[module]) && !nomapkit) {
if (path <= 2 || ("inframe" in lssm.Module[module] && lssm.Module[module].inframe ===
true)) {
if (lssm.Module[module].source) {
Expand Down Expand Up @@ -1495,6 +1509,11 @@ lssm.modal = {
let modules = lssm.settings.get('Modules') || {};
for (let i in modules) {
let modname = i.toString();
let nomapkit = (typeof mapkit !== undefined && 'nomapkit' in module && module.nomapkit === true);
if (nomapkit) {
console.log(modname + " is not compatible with mapkit.");
lssm.Module[i].active = false;
}
if ((modname in lssm.Module) === false) {
console.log(modname + " is not a valid app. Skipping.");
continue;
Expand Down
5 changes: 1 addition & 4 deletions modules/lss-FMS5InMap/FMS5InMap.user.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
(function ($, I18n) {
let radio_message_important = $("#radio_messages_important");
let id = "fm5InMap";
if ("undefined" != typeof mapkit) {
alert("[" + lssm.Module.fms5inmap.name[I18n.locale] + "]\n\n" + I18n.t('lssm.mapkit'));
} else {
lssm.newDragableDivOnMap(id,"",lssm.settings.get(lssm.config.prefix + "_"+id+"Position",{x:0,y:0})).append(radio_message_important);
radio_message_important.css({
"z-index": "999",
Expand All @@ -17,4 +14,4 @@
"margin": "0 !important",
"padding": "10px"
});
}})($, I18n);
})($, I18n);
69 changes: 33 additions & 36 deletions modules/lss-WachenHoverStati/WachenHoverStati.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,39 @@
* Created by Northdegree on 05.06.2017.
*/
(function ($, I18n) {
if ("undefined" != typeof mapkit) {
alert("[" + lssm.Module.WachenHoverStati.name[I18n.locale] + "]\n\n" + I18n.t('lssm.mapkit'));
} else {
$(document).bind(lssm.hook.postname("building_maps_draw"),function(event,e){
"use strict";
$(document).bind(lssm.hook.postname("building_maps_draw"),function(event,e){
"use strict";
redraw_Labels();
});
$(document).bind(lssm.hook.postname("radioMessage"),function(event,t){
"use strict";
if(!t.fms_text.startsWith("[Verband]"))
redraw_Labels();
});
function redraw_Labels() {
$.each(building_markers, function (key, marker) {
// Is the tooltip currently open?
let reopen = false;
if (marker.isTooltipOpen()) {
reopen = true;
// Close the tooltip
marker.closeTooltip();
}
// Unbind the tooltip and edit the content
marker.unbindTooltip();
c_labels = lssm.car_list(marker.building_id);
data = marker.options.title;
if (c_labels.length > 0) {
data += '&nbsp;<i class="fa fa-car"></i>' + c_labels.length;
data += lssm.car_list_printable(c_labels);
}
// Re-Bind the content
marker.bindTooltip(data, {direction: "top", offset: L.point(0,-marker.options.icon.options.iconSize[1]),zIndex: 999});
// Open the new tooltip (if needed)
if (reopen)
marker.openTooltip();
});
$(document).bind(lssm.hook.postname("radioMessage"),function(event,t){
"use strict";
if(!t.fms_text.startsWith("[Verband]"))
redraw_Labels();
});
function redraw_Labels() {
$.each(building_markers, function (key, marker) {
// Is the tooltip currently open?
let reopen = false;
if (marker.isTooltipOpen()) {
reopen = true;
// Close the tooltip
marker.closeTooltip();
}
// Unbind the tooltip and edit the content
marker.unbindTooltip();
c_labels = lssm.car_list(marker.building_id);
data = marker.options.title;
if (c_labels.length > 0) {
data += '&nbsp;<i class="fa fa-car"></i>' + c_labels.length;
data += lssm.car_list_printable(c_labels);
}
// Re-Bind the content
marker.bindTooltip(data, {direction: "top", offset: L.point(0,-marker.options.icon.options.iconSize[1]),zIndex: 999});
// Open the new tooltip (if needed)
if (reopen)
marker.openTooltip();
});
}
redraw_Labels();
}
})($, I18n);
redraw_Labels();
}
)($, I18n);
Loading

0 comments on commit 34ad446

Please sign in to comment.