Greasy Fork is available in English.

The West - westernblumis Toolkit

Some useful improvements for The West

// ==UserScript==
// @name        The West - westernblumis Toolkit
// @namespace   westernblumi
// @include 	https://*.the-west.*/game.php*
// @author 	westernblumi (updated by Tom Robert)
// @version     1.09
// @grant       none
// @description Some useful improvements for The West
// ==/UserScript==
(function (fn) {
  var script = document.createElement('script');
  script.setAttribute('type', 'application/javascript');
  script.textContent = '(' + fn.toString() + ')();';
  document.body.appendChild(script);
  document.body.removeChild(script);
}) (function () {

	WTKstart = {
      langs: {
        en: {
			language: 'English',
			features: 'Features',
			FeatRemoveTownBlinkEvent: 'Removes flashing from the forum menu item',
			FeatNewStatistics: 'Adds adventure statistics ',
			FeatOpenTrader: 'Opens the mobil traider, when new items are available',
			FeatDailyItemHelper: 'Adds a new button in the side menu for daily quest items',
			FeatAdventureBlockPlayer: 'Enables ignoring other players in adventure',
			save: 'Save',
			saveMessage: 'Settings saved',
			settings: 'Settings',
			ghostTown: 'Ghost town',
			indianVillage: 'Indian village',
			monday: 'Monday',
			tuesday: 'Tuesday',
			wednesday: 'Wednesday',
			thursday: 'Thursday',
			friday: 'Friday',
			saturday: 'Saturday',
			sunday: 'Sunday',
			saloon: 'Saloon',
			shortName: 'WTK',
			dailyItems: 'Products for daily quests',
			showDailyItems: 'Show products for daily quests',
			adventuresPlayed: 'Adventures played',
			adventuresKnockouts: 'Enemys knocked out',
			adventuresMiss: 'Missed shots',
			adventuresDodges: 'Dodged shots',
			adventures: 'Adventures',
			getData: 'Show data',
			updateMessage: 'A new version of the script is available',
			ignore: 'Ignore',
			dontIgnore: 'Don\'t ignore anymore',
			reportOffense: 'Report offense',
			willBeIgnored: 'will be ignored',
			willNotBeIgnored: 'will not be ignored anymore',
			churchLevels: 'Levels',
			FeatChurchLevels: 'Shows how many additional church levels you can build in your town',
			deleteMarkedItems: 'Delete marked items',
			youHaveFound: 'You have found following item:',
			itemFinder: 'Item Finder',
			FeatWindowPin: 'Opens nearly all windows at a defined position',
			setPosition: 'Set position',
			progress: 'Progress',
			progressTooltip: 'The progress shows how far your town is with the building of the current building stage',
			FeatFormattedRankings: 'Formats ranking data and shows the different to better players',
			FeatShowFort: 'Links the report of a fortbattle declaration to a certain fort instead of the fortbattle overview window',
			FeatBuildingProgress: 'Show the construction progress in a building window',
			FeatImprovedBuildCityhall: 'Show only buildings that have not been fully built',
			searchItem: 'Search Item',
			search: 'Search',
			whatItemsWouldYouLikeToSearchFor: 'What items would you like to search for?',
			howManyOfThemWouldYouLikeToCollect: 'How many of these do you want to collect?',
			nameOfTheItem: 'Name of the item:',
			numberOfItems: 'Number of items:',
			searchResult: 'Search result',
			itemAmountMustBeHigherThan0: 'The number of items must be greater than 0!',
			nameCannotBeEmpty: 'The name must not be empty!',
			emptySearchResult: 'Sorry, your search does not return any results. Please check your input. Maybe the item is already on your list!',
			thereAreMoreItems: 'The search yielded more results.',
			restrictYourSearch: 'Narrow the search to get more precise results.',
			help: 'Help',
			back: 'Go back',
			itemFinderHelpContent: '<b>Add:</b><ol style="padding-inline-start: 40px;"><li>Click on <b>Search Item</b>. This will open the search dialog<br></li><li>Enter the name of the item you want to search for.<br>Please enter how many of them you want to search. Click on <b>Search</b></li><li>A dialog with the search results opens</li><li>Click on the item you want to add to your list</li></ol><br><b>Delete:</b><ol style="padding-inline-start: 40px;"><li>Click on an item. The item will then become transparent</li><li>Click on <b>Delete marked items</b> to delete the selected items</li></ol><br><b>Enable alarm:</b><ol style="padding-inline-start: 40px;"><li>Click on the lower area with the number of items you are looking for</li><li>The area gets a yellow frame, the alarm is activated<br>and you will be notified as soon as the item you are looking for is found</li><li>Click on the area again and the frame and the alarm will be removed again</li></ol>',
			FeatExtendedBBCodes: 'Show correct BB-codes for color, size and images also in profiles, telegrams and notes. This will work only for people who have the script installed. All other player will still see these "wrong" codes'
        },
		de: {
			language: 'German (Deutsch)',
			features: 'Features',
			FeatRemoveTownBlinkEvent: 'Entfernt das Blinken des Stadtforums im Menü',
			FeatNewStatistics: 'Fügt Abenteuer Statistiken hinzu',
			FeatOpenTrader: 'Öffnet den fahrenden Händler, wenn neue Items verfügbar sind',
			FeatDailyItemHelper: 'Fügt im Seitenmenü einen Button für tägliche Questprodukte hinzu',
			FeatAdventureBlockPlayer: 'Erlaubt das Ignorieren von anderen Spielern im Abenteuer',
			save: 'Speichern',
			saveMessage: 'Erfolgreich gespeichert',
			settings: 'Einstellungen',
			ghostTown: 'Geisterstadt',
			indianVillage: 'Indianerdorf',
			monday: 'Montag',
			tuesday: 'Dienstag',
			wednesday: 'Mittwoch',
			thursday: 'Donnerstag',
			friday: 'Freitag',
			saturday: 'Samstag',
			sunday: 'Sonntag',
			saloon: 'Saloon',
			shortName: 'WTK',
			dailyItems: 'Produkte für tägliche Quests',
			showDailyItems: 'Zeige Produkte für tägliche Quests',
			adventuresPlayed: 'Abenteuer absolviert',
			adventuresKnockouts: 'Im Abenteuer KO geschossen',
			adventuresMiss: 'Fehlschüsse',
			adventuresDodges: 'Ausweicher',
			adventures: 'Abenteuer',
			getData: 'Daten anzeigen',
			updateMessage: 'Eine neue Version des Skriptes ist jetzt verfügbar',
			ignore: 'Ignorieren',
			dontIgnore: 'Nicht mehr ignorieren',
			reportOffense: 'Verstoß melden',
			willBeIgnored: 'wird jetzt ignoriert',
			willNotBeIgnored: 'wird jetzt nicht mehr ignoriert',
			churchLevels: 'Stufen',
			FeatChurchLevels: 'Zeigt an, wie viele Kirchenstufen man noch bauen kann',
			deleteMarkedItems: 'Markierte Items löschen',
			youHaveFound: 'Du hast folgenden Gegenstand gefunden:',
			itemFinder: 'Item Finder',
			FeatWindowPin: 'Öffnet die Fenster immer an einer bestimmten Stelle',
			setPosition: 'Position setzen',
			progress: 'Fortschritt',
			progressTooltip: 'Der Fortschritt gibt an, wie weit die Stufe des Gebäudes schon ausgebaut ist.',
			FeatFormattedRankings: 'Formatiert die Daten in der Rangliste und zeigt als Tooltip die Differenz zum besser plazierten Spieler',
			FeatShowFort: 'Verlinke im Bericht einer Fortmapfankündigung das konkrete Fort anstatt nur die Fortkampf Übersicht',
			FeatBuildingProgress: 'Zeige im Ausbaufenster auch den Baufortschritt',
			FeatImprovedBuildCityhall: 'Zeige nur Gebäude die noch ausgebaut werden können',
			searchItem: 'Item suchen',
			search: 'Suchen',
			whatItemsWouldYouLikeToSearchFor: 'Nach welchen Gegenständen möchtest du suchen?',
			howManyOfThemWouldYouLikeToCollect: 'Wie viele davon möchtest du sammeln?',
			nameOfTheItem: 'Name des Gegenstandes:',
			numberOfItems: 'Anzahl der Gegenstände:',
			searchResult: 'Suchergebnis',
			itemAmountMustBeHigherThan0: 'Die Anzahl der Gegenstände muss größer als 0 sein!',
			nameCannotBeEmpty: 'Der Name darf nicht leer sein!',
			emptySearchResult: 'Deine Suche liefert leider keine Ergebnisse. Überprüfe bitte deine Eingabe. Vielleicht ist der Gegenstand auch schon auf deiner Liste!',
			thereAreMoreItems: 'Die Suche lieferte mehr Ergebnisse.',
			restrictYourSearch: 'Schränke die Suche ein, um genauere Ergebnisse zu erhalten.',
			help: 'Hilfe',
			back: 'Zurück',
			itemFinderHelpContent: '<b>Hinzufügen:</b><ol style="padding-inline-start: 40px;"><li>Klick auf <b>Item suchen</b>. Daraufhin öffnet sich der Such-Dialog</li><li>Gib den Namen des Items an, das du suchen möchtest.<br>Trage ein, wie viele davon du suchen möchtest. Klick auf <b>Suchen</b></li><li>Ein Dialog mit den Suchergebnissen öffnet sich</li><li>Klick auf das Item, das du deiner Liste hinzufügen möchtest</li></ol><br><b>Löschen:</b><ol style="padding-inline-start: 40px;"><li>Klick auf ein Item. Das Item wird daraufhin transparent</li><li>Klick auf <b>Markierte Items löschen</b>, um die markierten Elemente zu löschen</li></ol><br><b>Alarm einschalten:</b><ol style="padding-inline-start: 40px;"><li>Klick auf den unteren Bereich mit der Anzahl der gesuchten Items</li><li>Der Bereich erhält einen gelben Rahmen, der Alarm ist somit aktiviert<br>und du wirst benachrichtigt, sobald das gesuchte Item gefunden wurde</li><li>Klickst du nochmal auf den Bereich wird der Rahmen und der Alarm wieder entfernt</li></ol>',
			FeatExtendedBBCodes: 'Zeige BB-Codes für Farbe, Größe und Bilder auch in Profilen, Telegrammen und Notizen richtig an. Das ganze funktioniert nur für Spieler, die das Skript auch installiert haben. Alle anderen sehen weiterhin die "falschen" Codes'
		},
		pl: {
			language: 'Polish',
			features: 'Funkcje',
			FeatRemoveTownBlinkEvent: 'Usuń migające okna z menu',
			FeatNewStatistics: 'Dodaj Przygody do statystyk',
			FeatOpenTrader: ' Otwórz wędrownego handlarza, gdy są dostępne nowe przedmioty',
			FeatDailyItemHelper: 'Doda dodatkowy przycisk w menu, odpowiedzialny za dzienne zadania',
			FeatAdventureBlockPlayer: 'Enables ignoring other players in adventure',
			save: 'Zapisz',
			saveMessage: 'Zapisano',
			settings: 'Opcje',
			ghostTown: 'Miasto Widmo',
			indianVillage: 'Wioska Indiańska Waupee',
			monday: 'Poniedziałek',
			tuesday: 'Wtorek',
			wednesday: 'Środa',
			thursday: 'Czwartek',
			friday: 'Piątek',
			saturday: 'Sobota',
			sunday: 'Niedziela',
			saloon: 'Saloon',
			shortName: 'WTK',
			dailyItems: 'Produkty do dziennych zadań',
			showDailyItems: 'Pokaż produkty do dziennych zadań',
			adventuresPlayed: 'Rozegrane przygody',
			adventuresKnockouts: 'Omdleni przeciwnicy',
			adventuresMiss: 'Nietrafione strzały',
			adventuresDodges: 'Trafione strzały',
			adventures: 'Przygody',
			getData: 'Pokaż dane',
			updateMessage: 'Nowa wersja skryptu jest dostępna',
			ignore: 'Ignore',
			dontIgnore: 'Don\'t ignore anymore',
			reportOffense: 'Report offense',
			willBeIgnored: 'will be ignored',
			willNotBeIgnored: 'will not be ignored anymore',
			churchLevels: 'Levels',
			FeatChurchLevels: 'Shows how many additional church levels you can build in your town',
			deleteMarkedItems: 'Delete marked items',
			youHaveFound: 'You have found following item:',
			itemFinder: 'Item Finder',
			FeatWindowPin: 'Opens nearly all windows at a defined position',
			setPosition: 'Set position',
			progress: 'Progress',
			progressTooltip: 'The progress shows how far your town is with the building of the current building stage',
			FeatFormattedRankings: 'Formats ranking data and shows the different to better players',
			FeatShowFort: 'Links the report of a fortbattle declaration to a certain fort instead of the fortbattle overview window',
			FeatBuildingProgress: 'Show the construction progress in a building window',
			FeatImprovedBuildCityhall: 'Show only buildings that have not been fully built',
			searchItem: 'Search Item',
			search: 'Search',
			whatItemsWouldYouLikeToSearchFor: 'What items would you like to search for?',
			howManyOfThemWouldYouLikeToCollect: 'How many of these do you want to collect?',
			nameOfTheItem: 'Name of the item:',
			numberOfItems: 'Number of items:',
			searchResult: 'Search result',
			itemAmountMustBeHigherThan0: 'The number of items must be greater than 0!',
			nameCannotBeEmpty: 'The name must not be empty!',
			emptySearchResult: 'Sorry, your search does not return any results. Please check your input. Maybe the item is already on your list!',
			thereAreMoreItems: 'The search yielded more results.',
			restrictYourSearch: 'Narrow the search to get more precise results.',
			help: 'Help',
			back: 'Go back',
			itemFinderHelpContent: '<b>Add:</b><ol style="padding-inline-start: 40px;"><li>Click on <b>Search Item</b>. This will open the search dialog<br></li><li>Enter the name of the item you want to search for.<br>Please enter how many of them you want to search. Click on <b>Search</b></li><li>A dialog with the search results opens</li><li>Click on the item you want to add to your list</li></ol><br><b>Delete:</b><ol style="padding-inline-start: 40px;"><li>Click on an item. The item will then become transparent</li><li>Click on <b>Delete marked items</b> to delete the selected items</li></ol><br><b>Enable alarm:</b><ol style="padding-inline-start: 40px;"><li>Click on the lower area with the number of items you are looking for</li><li>The area gets a yellow frame, the alarm is activated<br>and you will be notified as soon as the item you are looking for is found</li><li>Click on the area again and the frame and the alarm will be removed again</li></ol>',
			FeatExtendedBBCodes: 'Show correct BB-codes for color, size and images also in profiles, telegrams and notes. This will work only for people who have the script installed. All other player will still see these "wrong" codes'
        },
		es: {
			language: 'Spanish',
			features: 'Funciones',
			FeatRemoveTownBlinkEvent: 'Elimina parpadeo del elemento del menú del foro',
			FeatNewStatistics: 'Agrega estadísticas de aventuras',
			FeatOpenTrader: 'Abre el vendedor ambulante, cuando hay nuevos artículos disponibles',
			FeatDailyItemHelper: 'Agrega un nuevo botón en el menú lateral para los artículos de búsqeudas diarias',
			FeatAdventureBlockPlayer: 'Permite ignorar a otros jugadores en la aventura',
			save: 'Guardar',
			saveMessage: 'Ajustes guardados',
			settings: 'Ajustes',
			ghostTown: 'Ciudad fantasma',
			indianVillage: 'Pueblo indio',
			monday: 'Lunes',
			tuesday: 'Martes',
			wednesday: 'Miércoles',
			thursday: 'Jueves',
			friday: 'Viernes',
			saturday: 'Sábado',
			sunday: 'Domingo',
			saloon: 'Salón',
			shortName: 'WTK',
			dailyItems: 'Productos para búsquedas diarias',
			showDailyItems: 'Mostrar productos para búsquedas diarias',
			adventuresPlayed: 'Aventuras jugadas',
			adventuresKnockouts: 'Enemigos desmayados',
			adventuresMiss: 'Tiros fallados',
			adventuresDodges: 'Tiros eludidos',
			adventures: 'Adventuras',
			getData: 'Mostrar datos',
			updateMessage: 'Una nueva versión del script está disponible',
			ignore: 'Ignorar',
			dontIgnore: 'No ignorar más',
			reportOffense: 'Informar insulto',
			willBeIgnored: 'será ignorado',
			willNotBeIgnored: 'ya no será ignorado',
			churchLevels: 'Niveles',
			FeatChurchLevels: 'Muestra cuántos niveles adicionales de la Iglesia puede construir en su ciudad',
			deleteMarkedItems: 'Borrar artículos marcados',
			youHaveFound: 'Has encontrado el siguiente artículo:',
			itemFinder: 'Buscador artículos',
			FeatWindowPin: 'Abrir casi todas las ventanas en una posición definida',
			setPosition: 'Fijar posición',
			progress: 'Progreso',
			progressTooltip: 'El progreso muestra en qué punto está la construcción de su ciudad con respecto al actual estado de la construcción',
			FeatFormattedRankings: 'Formatea los datos de clasificación y muestra las diferencias de los mejores jugadores ',
			FeatShowFort: 'Enlaza al informe de una declaración de batalla de un determinado fuerte en lugar de a la ventana resumen ',
			FeatBuildingProgress: 'Muestra el progreso de construcción en la ventana del edificio',
			FeatImprovedBuildCityhall: 'Muestra solo los edificios que no están completamente construidos',
			searchItem: 'Search Item',
			search: 'Search',
			whatItemsWouldYouLikeToSearchFor: 'What items would you like to search for?',
			howManyOfThemWouldYouLikeToCollect: 'How many of these do you want to collect?',
			nameOfTheItem: 'Name of the item:',
			numberOfItems: 'Number of items:',
			searchResult: 'Search result',
			itemAmountMustBeHigherThan0: 'The number of items must be greater than 0!',
			nameCannotBeEmpty: 'The name must not be empty!',
			emptySearchResult: 'Sorry, your search does not return any results. Please check your input. Maybe the item is already on your list!',
			thereAreMoreItems: 'The search yielded more results.',
			restrictYourSearch: 'Narrow the search to get more precise results.',
			help: 'Help',
			back: 'Go back',
			itemFinderHelpContent: '<b>Add:</b><ol style="padding-inline-start: 40px;"><li>Click on <b>Search Item</b>. This will open the search dialog<br></li><li>Enter the name of the item you want to search for.<br>Please enter how many of them you want to search. Click on <b>Search</b></li><li>A dialog with the search results opens</li><li>Click on the item you want to add to your list</li></ol><br><b>Delete:</b><ol style="padding-inline-start: 40px;"><li>Click on an item. The item will then become transparent</li><li>Click on <b>Delete marked items</b> to delete the selected items</li></ol><br><b>Enable alarm:</b><ol style="padding-inline-start: 40px;"><li>Click on the lower area with the number of items you are looking for</li><li>The area gets a yellow frame, the alarm is activated<br>and you will be notified as soon as the item you are looking for is found</li><li>Click on the area again and the frame and the alarm will be removed again</li></ol>',
			FeatExtendedBBCodes: 'Show correct BB-codes for color, size and images also in profiles, telegrams and notes. This will work only for people who have the script installed. All other player will still see these "wrong" codes'
        },
      }
    };

	WTK = {
		version: '1.09',
		name: 'The West - westernblumis Toolkit',
        author: 'westernblumi',
		website: 'https://greasyfork.org/de/scripts/29596-the-west-westernblumis-toolkit',
        Data: {},
        loaded: [],
		Features: {
			RemoveTownBlinkEvent: false,
			NewStatistics: true,
			OpenTrader: false,
			DailyItemHelper: true,
			AdventureBlockPlayer: true,
			ChurchLevels: true,
			FormattedRankings: true,
			WindowPin: false,
			ShowFort: true,
			BuildingProgress: true,
			ImprovedBuildCityhall: true,
			ExtendedBBCodes: true,
        },
		Images: {
			menudailyitems: 'data:image/j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slZH/9k=',
		},
		updateLang: function () {
			var languages = WTKstart.langs;
			WTK.lang = languages[Game.locale.substr(0, 2)] ? Game.locale.substr(0, 2)  : 'en';
			WTKlang = languages[WTK.lang];
        },
	};
	WTK.updateLang();
    WTK.Skript = {
        init: function () {
			var menuContainer = $('<div class="menulink" onclick="WTK.GUI.openMenu();" title="' + WTK.name + '" />').css('background-image', 'url(' + WTK.Images.menu + ')').css('background-position', '0px 0px').on('mouseenter', function () {
				$(this).css('background-position', '-25px 0px');
			}).on('mouseleave', function () {
				$(this).css('background-position', '0px 0px');
			});
			$('#ui_menubar').append($('<div id="WTK_menubutton" class="ui_menucontainer" />').append(menuContainer).append('<div class="menucontainer_bottom" />'));

			var styling = $('<style></style>').text(
				'.WTK_find_notifcation {position: absolute;width: 51px;color: #fff;min-width: 23px;line-height: 12px;font-size: 10px;bottom: 3px;left: 2px;text-align: center;background: rgba(127, 111, 85, 0.7);border-radius: 0 2px 0 2px;box-shadow: 0px -1px 2px #000000;font-weight: bold;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;padding: 0 2px;opacity: 1;}' +
				'.WTK_find_notifcation_highlight {border: 2px;border-color: yellow;border-style: solid;width: 48px;}' +
				'.WTK_item_border {border: transparent;border-style: solid;border-width: 2px;border-radius: 5px;}' +
				'.WTK_item_border_green {border: green;border-style: solid;border-width: 2px;border-radius: 5px;}'
			);
			$('head').append(styling);

			WTK.Skript.updateFeat();
        },
        updateFeat: function () {
			var saved = localStorage.getItem('WTKFeaturestest');
			WTK.Data = saved && saved.indexOf('{') === 0 && JSON.parse(saved) || {};
			for (var k in WTK.Features) {
				if (WTK.Skript.getFeature(k) && !WTK.loaded.includes(k)) {
				  try {
					WTK.loaded.push(k);
					WTK[k].init();
				  } catch (e) {}
				}
			}
			WTK.ExtendedItemFinder.init();
        },
        getFeature: function (name) {
          return (WTK.Data[name] !== undefined) ? WTK.Data[name] : WTK.Features[name];
        },
    };

	WTK.GUI = {
		openMenu: function () {
			WTK.GUI.open();
			WTK.GUI.openSettings();
        },
		window: {},
        checkbox: {},
		open: function () {
			WTK.GUI.window = wman.open('WTKMenuWindow', WTK.name, 'noreload').setMiniTitle(WTKlang.shortName).setMaxSize(1268, 838);
			WTK.GUI.window.addTab(WTKlang.settings, 'WTKSettingsTab', WTK.GUI.openSettings);
			WTK.GUI.window.addTab(WTKlang.dailyItems, 'WTKDailyItemsTab', WTK.DailyItemHelper.showDailyItems);
			WTK.GUI.window.addTab(WTKlang.itemFinder, 'WTKExtendedItemFinder', WTK.ExtendedItemFinder.showExtendedItemFinder);
        },
        getDefault: function (tab) {
			WTK.GUI.window.setResizeable(false).setSize(748, 471).clearContentPane().removeClass('nocloseall').setTitle(WTK.name);
			WTK.GUI.window.dontCloseAll = false;
			$(WTK.GUI.window.getContentPane()).css('margin-top', '10px');
			var wnd = WTK.GUI.window.getMainDiv();
			$('.textart_title', wnd).css('display', '');
			WTK.GUI.window.activateTab(tab);
        },
		openSettings: function () {
			WTK.GUI.getDefault('WTKSettingsTab');

			var featScroll = new west.gui.Scrollpane();

			featScroll.appendContent('<h2>' + WTKlang.features + '</h2>');
			for (var k in WTK.Features) {
				WTK.GUI.checkbox[k] = new west.gui.Checkbox().setLabel(WTKlang['Feat' + k]).setSelected(WTK.Skript.getFeature(k)).appendTo(featScroll.getContentPane());
				if(k == 'WindowPin'){
					var button1 = new west.gui.Button(WTKlang.setPosition, function () {
						WTK.WindowPin.getNewPinPosition();
					});
					featScroll.appendContent(button1.getMainDiv());
				}
				featScroll.appendContent('<br><div style="height:5px;" />');
			}
			featScroll.appendContent('<br>');
			$(featScroll.getMainDiv()).css({
				'height': '310px',
				'margin-bottom': '10px',
			});
			var button2 = new west.gui.Button(WTKlang.save, function () {
				for (var k in WTK.GUI.checkbox) {
					WTK.Data[k] = WTK.GUI.checkbox[k].isSelected();
				}
				localStorage.setItem('WTKFeaturestest', JSON.stringify(WTK.Data));
				WTK.Skript.updateFeat();
				new UserMessage(WTKlang.saveMessage, 'success').show();
            });
			$(WTK.GUI.window.getContentPane()).append(featScroll.getMainDiv()).append(button2.getMainDiv());
        },
	};

	WTK.RemoveTownBlinkEvent = {
        init: function () {
			setTimeout((function () {
				$('div.city > div.city').removeClass('dock-highlight');
            }), 1000);
			//The West Menu
			setTimeout((function () {
				$('#TWM_bottombar div.city > div.Stadt').removeClass('TWM_highlight');
            }), 1000);
        },
    };

	WTK.NewStatistics = {
        init: function () {
			AchievementStatistic.backup_init = AchievementStatistic.init;
			AchievementStatistic.init = function(){
				if(this.playerid == Character.playerId){
					var that=this;
					Ajax.remoteCall('achievement','get_statistic',{
						playerid:this.playerid
					},function(json){
						var table=new west.gui.Table().addColumn('desc').addColumn('value').appendToCell('head','desc').appendToCell('head','value');
						var i=0;
						$.each(json.stats,function(k,v){
							if(i!=0)
								table.appendRow();
							table.appendRow($('<h2>'+k+'</h2>'));
							$.each(v,function(kk,vv){
								table.appendRow().appendToCell(-1,'desc',kk).appendToCell(-1,'value',format_number(vv));
							});
							i++;
						});
						var button3 = new west.gui.Button(WTKlang.getData, WTK.NewStatistics.getDataAdventuresDodges);
						table.appendRow().appendToCell(-1,'desc',WTKlang.adventuresDodges).appendToCell(-1,'value',button3.getMainDiv());
						var button4 = new west.gui.Button(WTKlang.getData, WTK.NewStatistics.getDataAdventuresMiss);
						table.appendRow().appendToCell(-1,'desc',WTKlang.adventuresMiss).appendToCell(-1,'value',button4.getMainDiv());

						that.window.$('div.achievement-statistic',AchievementWindow.DOM).empty();
						table.appendTo(that.window.$('div.achievement-statistic',AchievementWindow.DOM));
					},this);
				} else {
					AchievementStatistic.backup_init.call(this);
				}
				return this;
			};
        },

		getDataAdventuresMiss: function () {
			Ajax.remoteCall('achievement','track',{achvid: 60031}, function(json)
			{
				if(!json.error){
					MessageSuccess(WTKlang.adventuresMiss + ': ' + json.current).show();
				}
				Ajax.remoteCall('achievement','untrack',{}, function(json){});
			});


		},

		getDataAdventuresDodges: function () {
			Ajax.remoteCall('achievement','track',{achvid: 60028}, function(json)
			{
				if(!json.error){
					MessageSuccess(WTKlang.adventuresDodges + ': ' + json.current).show();
				}
				Ajax.remoteCall('achievement','untrack',{}, function(json){});
			});


		},
    };

	WTK.OpenTrader = {
        init: function () {
			setTimeout((function () {
				setInterval(WTK.OpenTrader.checkTrader, 10000);
            }), 10000);

        },
		checkTrader: function(){
			if(WTK.OpenTrader.TraderTime == undefined){
				Ajax.remoteCallMode('shop_trader', 'index', {}, function (response) {
					WTK.OpenTrader.TraderTime = response.traderTime;
					if((WTK.OpenTrader.TraderTime -(new Date()).getTime() / 1000) > 86385) {
						west.window.shop.open('wear_window').showCategory('trader');
						Character.setToRead('trader', false);
					}
				});
			}
			if(Math.round((new Date()).getTime() / 1000) > WTK.OpenTrader.TraderTime){
				Ajax.remoteCallMode('shop_trader', 'index', {}, function (response) {
					WTK.OpenTrader.TraderTime = response.traderTime;
				});
				west.window.shop.open('wear_window').showCategory('trader');
				Character.setToRead('trader', false);
			}
		},
    };

	WTK.DailyItemHelper = {

		ghostTown: [
      {minLevel:21,maxLevel:50,amount:1,itemID: 715},
      {minLevel:27,maxLevel:60,amount:1,itemID: 760},
      {minLevel:28,maxLevel:60,amount:1,itemID: 759},
      {minLevel:37,maxLevel:70,amount:1,itemID: 792},
      {minLevel:62,maxLevel:100,amount:1,itemID: 794},
      {minLevel:73,amount:1,itemID:1817},
      {minLevel:80,amount:1,itemID:1819},
      {minLevel:120,amount:4,itemID:2442},
      {minLevel:151,amount:1,itemID:52967},
      {minLevel:151,amount:2,itemID:52957},
      {minLevel:151,amount:1,itemID:52944},
      {minLevel:151,amount:4,itemID:52968},
      {minLevel:151,amount:3,itemID:52954},
      {minLevel:151,amount:5,itemID:52946},
      {minLevel:151,amount:2,itemID:52964},
      {minLevel:151,amount:1,itemID:52932},
		],
		indianVillage: [
      {minLevel:13,maxLevel:40,amount:1,itemID:714},
      {minLevel:34,maxLevel:60,amount:1,itemID:718},
      {minLevel:41,maxLevel:70,amount:1,itemID:724},
      {minLevel:50,maxLevel:80,amount:1,itemID:1812},
      {minLevel:56,maxLevel:80,amount:1,itemID:1813},
      {minLevel:63,maxLevel:100,amount:1,itemID:1708},
      {minLevel:71,amount:1,itemID:780},
      {minLevel:90,amount:1,itemID:1821},
      {minLevel:100,amount:1,itemID:1826},
      {minLevel:120,amount:1,itemID:2441},
      {minLevel:151,amount:4,itemID:52965},
      {minLevel:151,amount:1,itemID:52935},
      {minLevel:151,amount:1,itemID:52952},
      {minLevel:151,amount:2,itemID:52945},
      {minLevel:151,amount:1,itemID:52938},
      {minLevel:151,amount:5,itemID:52951},
      {minLevel:151,amount:1,itemID:52933},
      {minLevel:151,amount:3,itemID:52963},
		],
		daily: {
			sunday: [
        {minLevel:13,maxLevel:47,amount:1,itemID:716},
        {minLevel:15,maxLevel:43,amount:1,itemID:742},
        {minLevel:17,maxLevel:51,amount:1,itemID:720},
        {minLevel:37,maxLevel:80,amount:1,itemID:792},
        {minLevel:48,maxLevel:80,amount:1,itemID:719},
        {minLevel:52,maxLevel:69,amount:1,itemID:768},
        {minLevel:81,amount:1,itemID:1708},
        {minLevel:81,amount:1,itemID:751},
        {minLevel:120,amount:5,itemID:2447},
        {minLevel:120,amount:1,itemID:2430},
        {minLevel:151,maxLevel:199,amount:5,itemID:52949},
        {minLevel:151,maxLevel:199,amount:1,itemID:52937},
        {minLevel:200,amount:1,itemID:52960},
        {minLevel:200,amount:2,itemID:52970},
			],
			monday: [
        {minLevel:3,maxLevel:46,amount:1,itemID:702},
        {minLevel:26,maxLevel:40,amount:1,itemID:761},
        {minLevel:27,maxLevel:36,amount:1,itemID:760},
        {minLevel:38,maxLevel:64,amount:1,itemID:792},
        {minLevel:65,amount:1,itemID:1814},
        {minLevel:71,amount:1,itemID:780},
        {minLevel:120,amount:1,itemID:2444},
        {minLevel:151,maxLevel:199,amount:2,itemID:52942},
        {minLevel:151,maxLevel:199,amount:2,itemID:52936},
        {minLevel:200,amount:1,itemID:52969},
        {minLevel:200,amount:2,itemID:52972},
			],
			tuesday: [
        {minLevel:11,maxLevel:57,amount:1,itemID:766},
        {minLevel:45,maxLevel:80,amount:1,itemID:778},
        {minLevel:81,amount:1,itemID:1818},
        {minLevel:81,amount:1,itemID:756},
        {minLevel:120,amount:5,itemID:2456},
        {minLevel:120,amount:2,itemID:2450},
        {minLevel:151,maxLevel:199,amount:2,itemID:52947},
        {minLevel:151,maxLevel:199,amount:1,itemID:52941},
        {minLevel:200,amount:6,itemID:52962},
        {minLevel:200,amount:1,itemID:52956},
			],
			wednesday: [
        {minLevel:4,maxLevel:67,amount:1,itemID:700},
        {minLevel:15,maxLevel:49,amount:1,itemID:791},
        {minLevel:18,maxLevel:49,amount:1,itemID:767},
        {minLevel:48,maxLevel:79,amount:1,itemID:1812},
        {minLevel:120,amount:1,itemID:2434},
        {minLevel:120,amount:1,itemID:2449},
        {minLevel:151,maxLevel:199,amount:1,itemID:52939},
        {minLevel:151,maxLevel:199,amount:3,itemID:52950},
        {minLevel:200,amount:2,itemID:52971},
        {minLevel:200,amount:7,itemID:52975},
			],
			thursday: [
        {minLevel:8,maxLevel:56,amount:1,itemID:708},
        {minLevel:28,maxLevel:58,amount:1,itemID:759},
        {minLevel:59,maxLevel:74,amount:1,itemID:752},
        {minLevel:63,maxLevel:87,amount:1,itemID:1708},
        {minLevel:75,amount:1,itemID:730},
        {minLevel:120,amount:3,itemID:2433},
        {minLevel:151,maxLevel:199,amount:5,itemID:52953},
        {minLevel:151,maxLevel:199,amount:1,itemID:52943},
        {minLevel:200,amount:3,itemID:52966},
        {minLevel:200,amount:1,itemID:52961},
			],
			friday: [
        {minLevel:3,maxLevel:61,amount:1,itemID:705},
        {minLevel:21,maxLevel:42,amount:1,itemID:715},
        {minLevel:42,maxLevel:75,amount:1,itemID:1811},
        {minLevel:62,maxLevel:88,amount:1,itemID:794},
        {minLevel:89,amount:1,itemID:1824},
        {minLevel:120,amount:1,itemID:2451},
        {minLevel:120,amount:2,itemID:2453},
        {minLevel:151,maxLevel:199,amount:2,itemID:52940},
        {minLevel:151,maxLevel:199,amount:2,itemID:52955},
        {minLevel:200,amount:1,itemID:52973},
        {minLevel:200,amount:10,itemID:52959},
			],
			saturday: [
        {minLevel:5,maxLevel:41,amount:1,itemID:707},
        {minLevel:5,maxLevel:51,amount:1,itemID:1807},
        {minLevel:35,maxLevel:53,amount:1,itemID:737},
        {minLevel:42,maxLevel:75,amount:1,itemID:725},
        {minLevel:52,maxLevel:77,amount:1,itemID:768},
        {minLevel:76,amount:1,itemID:1756},
        {minLevel:78,amount:1,itemID:1819},
        {minLevel:79,amount:1,itemID:764},
        {minLevel:81,amount:1,itemID:794},
        {minLevel:120,amount:5,itemID:2435},
        {minLevel:151,maxLevel:199,amount:1,itemID:52948},
        {minLevel:151,maxLevel:199,amount:1,itemID:52934},
        {minLevel:200,amount:3,itemID:52974},
        {minLevel:200,amount:10,itemID:52958},
			],
		},
		others: [
			{minLevel: 10, amount: 15, itemID: 2160},
			{minLevel: 10, amount: 15, itemID: 2161},
			{minLevel: 10, amount: 15, itemID: 2162},
			{minLevel: 10, amount: 15, itemID: 2163},

			{minLevel: 20, amount: 1, profession: 1, itemID: 1940},
			{minLevel: 20, amount: 1, profession: 1, itemID: 1871},
			{minLevel: 20, amount: 1, profession: 1, itemID: 1879},

			{minLevel: 20, amount: 1, profession: 2, itemID: 1939},
			{minLevel: 20, amount: 1, profession: 2, itemID: 1890},
			{minLevel: 20, amount: 1, profession: 2, itemID: 1898},

			{minLevel: 20, amount: 1, profession: 3, itemID: 1938},
			{minLevel: 20, amount: 1, profession: 3, itemID: 1910},
			{minLevel: 20, amount: 1, profession: 3, itemID: 1916},

			{minLevel: 20, amount: 1, profession: 4, itemID: 1937},
			{minLevel: 20, amount: 1, profession: 4, itemID: 1928},
			{minLevel: 20, amount: 1, profession: 4, itemID: 1934},
		],
    init: function () {
			var menuContainer = $('<div class="menulink" onclick="WTK.DailyItemHelper.showDailyItems();" title="' + WTKlang.showDailyItems + '" />').css('background-image', 'url(' + WTK.Images.menudailyitems + ')').css('background-position', '0px 0px').on('mouseenter', function () {
				$(this).css('background-position', '-25px 0px');
			}).on('mouseleave', function () {
				$(this).css('background-position', '0px 0px');
			});
			$('#ui_menubar').append($('<div id="WTK_menubutton_DailyItemHelper" class="ui_menucontainer" />').append(menuContainer).append('<div class="menucontainer_bottom" />'));
    },
    baseIdDone: 0,
		getQuestsFromArray: function(questArray) {
			var text = '';
			for (var quest of questArray) {
        if (!this.baseIdDone)
          quest.itemID *= 1000;
				if(!quest.profession || quest.profession == Character.professionId) {
					if(quest.minLevel <= Character.level && (!quest.maxLevel || Character.level <= quest.maxLevel)){
						var color = 'black';
						if(Bag.getItemCount(quest.itemID) < quest.amount){
							color = 'red';
						}
						text += '<span style="color: ' + color + '";>' + ItemManager.get(quest.itemID).name + ' ' +Bag.getItemCount(quest.itemID) + '/' + quest.amount + '</span><br>';
					}
				}
			}
			return text;
		},

		showDailyItems: function() {
			WTK.GUI.open();
			WTK.GUI.getDefault('WTKDailyItemsTab');
      
			var scrollPane = new west.gui.Scrollpane();
			scrollPane.appendContent('<div style="float: left; padding: 10px 30px 5px 5px;"><b>'+WTKlang.saloon + ':</b><br>'+WTK.DailyItemHelper.getQuestsFromArray(WTK.DailyItemHelper.others)+'</div>');
			scrollPane.appendContent('<div style="float: left; padding: 10px 30px 5px 5px;"><b>'+WTKlang.indianVillage + ':</b><br>'+WTK.DailyItemHelper.getQuestsFromArray(WTK.DailyItemHelper.indianVillage)+'</div>');
			scrollPane.appendContent('<div style="float: left; padding: 10px 30px 5px 5px;"><b>'+WTKlang.ghostTown + ':</b><br>'+WTK.DailyItemHelper.getQuestsFromArray(WTK.DailyItemHelper.ghostTown)+'</div>');
			scrollPane.appendContent('<div style="clear:both"></div>');
			scrollPane.appendContent('<div style="float: left; padding: 10px 30px 5px 5px;"><b>'+WTKlang.monday + ':</b><br>'+WTK.DailyItemHelper.getQuestsFromArray(WTK.DailyItemHelper.daily.monday)+'</div>');
			scrollPane.appendContent('<div style="float: left; padding: 10px 30px 5px 5px;"><b>'+WTKlang.tuesday + ':</b><br>'+WTK.DailyItemHelper.getQuestsFromArray(WTK.DailyItemHelper.daily.tuesday)+'</div>');
			scrollPane.appendContent('<div style="float: left; padding: 10px 30px 5px 5px;"><b>'+WTKlang.wednesday + ':</b><br>'+WTK.DailyItemHelper.getQuestsFromArray(WTK.DailyItemHelper.daily.wednesday)+'</div>');
			scrollPane.appendContent('<div style="float: left; padding: 10px 30px 5px 5px;"><b>'+WTKlang.thursday + ':</b><br>'+WTK.DailyItemHelper.getQuestsFromArray(WTK.DailyItemHelper.daily.thursday)+'</div>');
			scrollPane.appendContent('<div style="float: left; padding: 10px 30px 5px 5px;"><b>'+WTKlang.friday + ':</b><br>'+WTK.DailyItemHelper.getQuestsFromArray(WTK.DailyItemHelper.daily.friday)+'</div>');
			scrollPane.appendContent('<div style="float: left; padding: 10px 30px 5px 5px;"><b>'+WTKlang.saturday + ':</b><br>'+WTK.DailyItemHelper.getQuestsFromArray(WTK.DailyItemHelper.daily.saturday)+'</div>');
			scrollPane.appendContent('<div style="float: left; padding: 10px 30px 5px 5px;"><b>'+WTKlang.sunday + ':</b><br>'+WTK.DailyItemHelper.getQuestsFromArray(WTK.DailyItemHelper.daily.sunday)+'</div>');
			scrollPane.appendContent('<div style="clear:both"></div>');
			$(WTK.GUI.window.getContentPane()).append(scrollPane.getMainDiv());
      
      WTK.DailyItemHelper.baseIdDone = 1;
		},
  };

	WTK.AdventureBlockPlayer = {
		blockedUsers: [],

		init: function () {
			Chat.Formatter.backup_formatMessage = Chat.Formatter.formatMessage;
			Chat.Formatter.formatMessage = function (msg, from, time, highlight, classNames) {
				classNames = classNames || '';
				var newDiv = $('<div></div>');
				newDiv.html(from);
				var short_name = $('.client_name', newDiv).text();
				if(WTK.AdventureBlockPlayer.blockedUsers.includes(short_name)){
					return;
				} else {
					return["<table cellpadding='0' cellspacing='0' class='" + classNames + "'>", "<tr>", "<td style='white-space: nowrap;' class='chat_info'>", "<span class='chat_time'>[" + Chat.Formatter.formatTime(time) + "]</span>", "<span class='chat_from'>" + from + "</span>", "&nbsp;", "</td>", "<td class='chat_text " + (highlight ? "chat_highlight" : "") + "'>", msg, "</td>", "</tr>", "</table>"].join("");
				}
			};

			ChatWindow.Client.backup_onClick = ChatWindow.Client.onClick;
			ChatWindow.Client.onClick = function (args, id) {

				var client = Chat.Resource.Manager.getClient(id), isOnline;
				if (!client || client.myself)return;
				isOnline = Chat.Resource.Client.STATUS_OFFLINE != client.statusId;
				if (client.mpi) {
					var onAction = function (id) {
						switch (id) {
							case 0:
								Suggestion.showPopup('mpi', client.pname, client.id);
								break;
							case 1:
								if (WTK.AdventureBlockPlayer.blockedUsers.includes(client.pname)) {

									WTK.AdventureBlockPlayer.blockedUsers = jQuery.grep(WTK.AdventureBlockPlayer.blockedUsers, function(value) {
										return value != client.pname;
									});
									MessageSuccess(client.pname + ' ' + WTKlang.willNotBeIgnored).show();
								}
								else {
									WTK.AdventureBlockPlayer.blockedUsers.push(client.pname);
									localStorage.setItem('WTKAdventureBlockedPlayers', JSON.stringify(WTK.AdventureBlockPlayer.blockedUsers));
									MessageSuccess(client.pname + ' ' + WTKlang.willBeIgnored).show();
								}
								break;
						}
					};
					var selectbox = new west.gui.Selectbox().setHeader(client.pname).addItem(0, WTKlang.reportOffense).addItem(1, WTK.AdventureBlockPlayer.blockedUsers.includes(client.pname) ? WTKlang.dontIgnore : WTKlang.ignore).addListener(onAction).show(args[0]);
				}
				else {
					ChatWindow.Client.backup_onClick.call(this, args, id);
				}

			};

			var savedBlockedUsers = JSON.parse(localStorage.getItem('WTKAdventureBlockedPlayers'));
			if(savedBlockedUsers != null){
				WTK.AdventureBlockPlayer.blockedUsers = savedBlockedUsers;
			}
		},


	};

	WTK.ChurchLevels = {
		init: function () {
			BuildWindow.updateLaborPoints_backup = BuildWindow.updateLaborPoints;
			BuildWindow.updateLaborPoints = function (points) {
				BuildWindow.updateLaborPoints_backup.call(this, points);
				if(this.building == 'church' && points > 0) {
					var stageCount = Math.floor(this.window.$("div.build_progress_nfo > span.text_bold").text()/15);
					this.window.$("div.build_progress_nfo").append(' (' + (stageCount >= 0 ? '+' : '') + stageCount + ' ' + WTKlang.churchLevels + ')');
				}
			};
		},
	};

	WTK.FormattedRankings = {
		init: function () {
			RankingWindow.Cities.updateTable_backup = RankingWindow.Cities.updateTable;
			RankingWindow.Cities.updateTable = function (be_data) {
				RankingWindow.Cities.updateTable_backup.call(this, be_data);
				var elementsLength = $('.town_points_sum:not(div.cell.cell_2)').length;
				for(var i = 0; i < elementsLength; i++){
					$('.town_points_sum:not(div.cell.cell_2)')[i].innerText = format_number($('.town_points_sum:not(div.cell.cell_2)')[i].innerText);
					if(i != 0){
						$('.town_points_sum:not(div.cell.cell_2)')[i].title = format_number(deformat_number($('.town_points_sum:not(div.cell.cell_2)')[i].innerText)-deformat_number($('.town_points_sum:not(div.cell.cell_2)')[i-1].innerText));
					}
					$('.town_points:not(div.cell.cell_3)')[i].innerText = format_number($('.town_points:not(div.cell.cell_3)')[i].innerText);
					if(i != 0){
						$('.town_points:not(div.cell.cell_3)')[i].title = format_number(deformat_number($('.town_points:not(div.cell.cell_3)')[i].innerText)-deformat_number($('.town_points:not(div.cell.cell_3)')[i-1].innerText));
					}
					$('.town_fort_points:not(div.cell.cell_4)')[i].innerText = format_number($('.town_fort_points:not(div.cell.cell_4)')[i].innerText);
					$('.town_member_points:not(div.cell.cell_5)')[i].innerText = format_number($('.town_member_points:not(div.cell.cell_5)')[i].innerText);
					$('.town_duel_points:not(div.cell.cell_6)')[i].innerText = format_number($('.town_duel_points:not(div.cell.cell_6)')[i].innerText);
				}
			};

			RankingWindow.Duels.updateTable_backup = RankingWindow.Duels.updateTable;
			RankingWindow.Duels.updateTable = function (be_data) {
				RankingWindow.Duels.updateTable_backup.call(this, be_data);
				var elementsLength = $('.duel_exp:not(div.cell.cell_2)').length;
				for(var i = 0; i < elementsLength; i++){
					$('.duel_exp:not(div.cell.cell_2)')[i].innerText = format_number($('.duel_exp:not(div.cell.cell_2)')[i].innerText);
					if(i != 0){
						$('.duel_exp:not(div.cell.cell_2)')[i].title = format_number(deformat_number($('.duel_exp:not(div.cell.cell_2)')[i].innerText)-deformat_number($('.duel_exp:not(div.cell.cell_2)')[i-1].innerText));
					}
					$('.duel_win:not(div.cell.cell_3)')[i].innerText = format_number($('.duel_win:not(div.cell.cell_3)')[i].innerText);
					$('.duel_loss:not(div.cell.cell_4)')[i].innerText = format_number($('.duel_loss:not(div.cell.cell_4)')[i].innerText);
					$('.duel_diff:not(div.cell.cell_5)')[i].innerText = format_number($('.duel_diff:not(div.cell.cell_5)')[i].innerText);
				}
			};

			RankingWindow.Experience.updateTable_backup = RankingWindow.Experience.updateTable;
			RankingWindow.Experience.updateTable = function (be_data) {
				RankingWindow.Experience.updateTable_backup.call(this, be_data);
				var elementsLength = $('.exp_exp:not(div.cell.cell_3)').length;
				for(var i = 0; i < elementsLength; i++){
					$('.exp_exp:not(div.cell.cell_3)')[i].innerText = format_number($('.exp_exp:not(div.cell.cell_3)')[i].innerText);
					if(i != 0){
						$('.exp_exp:not(div.cell.cell_3)')[i].title = format_number(deformat_number($('.exp_exp:not(div.cell.cell_3)')[i].innerText)-deformat_number($('.exp_exp:not(div.cell.cell_3)')[i-1].innerText));
					}
				}
			};

			RankingWindow.FortBattles.updateTable_backup = RankingWindow.FortBattles.updateTable;
			RankingWindow.FortBattles.updateTable = function (be_data) {
				RankingWindow.FortBattles.updateTable_backup.call(this, be_data);
				var elementsLength = $('.forts_score:not(div.cell.cell_2)').length;
				for(var i = 0; i < elementsLength; i++){
					$('.forts_score:not(div.cell.cell_2)')[i].innerText = format_number($('.forts_score:not(div.cell.cell_2)')[i].innerText);
					if(i != 0){
						$('.forts_score:not(div.cell.cell_2)')[i].title = format_number(deformat_number($('.forts_score:not(div.cell.cell_2)')[i].innerText)-deformat_number($('.forts_score:not(div.cell.cell_2)')[i-1].innerText));
					}
					$('.forts_damage_dealt:not(div.cell.cell_3)')[i].innerText = format_number($('.forts_damage_dealt:not(div.cell.cell_3)')[i].innerText);
					$('.forts_hits_taken:not(div.cell.cell_4)')[i].innerText = format_number($('.forts_hits_taken:not(div.cell.cell_4)')[i].innerText);
					$('.forts_dodges:not(div.cell.cell_5)')[i].innerText = format_number($('.forts_dodges:not(div.cell.cell_5)')[i].innerText);
				}
			};

			RankingWindow.Crafting.updateTable_backup = RankingWindow.Crafting.updateTable;
			RankingWindow.Crafting.updateTable = function (be_data) {
				RankingWindow.Crafting.updateTable_backup.call(this, be_data);
				var elementsLength = $('.craft_score:not(div.cell.cell_2)').length;
				for(var i = 0; i < elementsLength; i++){
					$('.craft_score:not(div.cell.cell_2)')[i].innerText = format_number($('.craft_score:not(div.cell.cell_2)')[i].innerText);
					$('.craft_items_created:not(div.cell.cell_3)')[i].innerText = format_number($('.craft_items_created:not(div.cell.cell_3)')[i].innerText);
				}
			};
		},
	};

	WTK.WindowPin = {
		newPos: {left: -1, top: -1,},
		saveMousPos: function (event) {
			WTK.WindowPin.newPos = {left:  event.clientX, top: event.clientY,};
			localStorage.setItem('WTKPinPosition', JSON.stringify(WTK.WindowPin.newPos));
			document.removeEventListener("click", WTK.WindowPin.saveMousPos);
			$('body').removeClass('WTK_overlay');
		},
		getNewPinPosition: function () {
			var styling = $('<style></style>').text('.WTK_overlay { background-image: none; opacity:0.2; background-color:#000; position:fixed; width:100%; height:100%; top:0px; left:0px; z-index:1000;}');
			$('head').append(styling);
			$('body').addClass('WTK_overlay');
			setTimeout((function () {
				document.addEventListener("click", WTK.WindowPin.saveMousPos);
            }), 100);

		},
		init: function () {
			var tempPos = JSON.parse(localStorage.getItem('WTKPinPosition'));
			if(tempPos != null && tempPos.left >= 0 && tempPos.top >= 0){
				WTK.WindowPin.newPos = tempPos;

				Inventory.dock = function (dockedWindow) {
					Inventory.window.center = function () {
						var max_window_size_difference = 100;
						var $inventory = $('#windows .inventory'),
						$docklet = $(dockedWindow.divMain),
						offset_left,
						offset_top,
						inventory_position = {},
						docklet_position = {};
						offset_left = ($(document).outerWidth() - $inventory.outerWidth() - $docklet.outerWidth()) >> 1;
						if (offset_left < 0) {
							inventory_position.left = $(document).outerWidth() - $inventory.outerWidth() + 7;
							docklet_position.left = 0;
						} else {
							inventory_position.left = WTK.WindowPin.newPos.left + $docklet.outerWidth() - 13;
							docklet_position.left = WTK.WindowPin.newPos.left;
						}
						inventory_position.top = ($(document).outerHeight() - $inventory.outerHeight()) >> 1;
						if ($docklet.outerHeight() < ($inventory.outerHeight() + max_window_size_difference)) {
							offset_top = Math.min(($(document).outerHeight() - $docklet.outerHeight()) >> 1, ($(document).outerHeight() - $inventory.outerHeight()) >> 1);
							inventory_position.top = docklet_position.top = WTK.WindowPin.newPos.top;
						} else {
							docklet_position.top = ($(document).outerHeight() - $docklet.outerHeight()) >> 1;
						}
						$docklet.css({
							left: docklet_position.left + 'px',
							top: docklet_position.top + 'px'
						});
						$inventory.css({
							left: inventory_position.left + 'px',
							top: inventory_position.top + 'px'
						});
					};
					if (Inventory.dockedWindow) {
						Inventory.undock();
					}
					Inventory.dockedWindow = dockedWindow;
					Inventory.window.addClass('docked_' + dockedWindow.id);
					Inventory.window.addClass('focused_' + dockedWindow.id);
					EventHandler.listen("window_closed_" + dockedWindow.id, Inventory.undock, Inventory);
					Inventory.window.center();
				};

				$.fn.center = function (x, y, relative) {
					var p = this.position();
					if (!relative)
						relative = $(window);
					if (x !== false) {
						var w = this.outerWidth();
						var sw = relative.outerWidth();
						this.first().css('left', (WTK.WindowPin.newPos.left-20) + "px");
					}
					if (y !== false) {
						var h = this.outerHeight();
						var sh = relative.outerHeight();
						this.first().css('top', (WTK.WindowPin.newPos.top-20) + "px");
					}
					return this;
				};
			}
		},
		setNewPos: function(){

		},
	};

	WTK.ShowFort = {
		init: function () {
			ReportWindow.init_content_backup = ReportWindow.init_content;
			ReportWindow.init_content = function (data){
				ReportWindow.init_content_backup.call(this, data);
				if(data.reportType == 'fortbattle' && data.reportInfo.subtype == 'declare'){
					WTK.ShowFort.getFortID(data.reportInfo.fortname, data.report_id);
				}
			};
		},

		getFortID: function (fortName, report_id) {
			Ajax.remoteCall('fort_overview', 'search_fort', {
				fortNames: fortName
			}, function (json) {
				if (!json.error) {
					if (json["0"]) {
						for (var fo in json) {
							if(json[fo].name == fortName){
								$('#rp_report-'+report_id+' .fort_muster a:first-child').replaceWith('<a href="javascript:void(FortWindow.open('+json[fo].fort_id+', '+json[fo].fort_x+', '+json[fo].fort_y+'));">'+json[fo].name+'</a>');
							}
						}
					}
				}
			});
		},
	};

	WTK.BuildingProgress = {
		init: function () {
			BuildWindow.initInfo_backup = BuildWindow.initInfo;
			BuildWindow.initInfo = function (data) {
				BuildWindow.initInfo_backup.call(this, data);
				var tmp = $('<div class="rp_row_jobdata row_build_' + 'hammer' + '" title="' + WTKlang.progress.escapeHTML() + ':&nbsp;' + WTKlang.progressTooltip + '">' + '<span class="rp_jobdata_label_icon"><img src="https://westde.innogamescdn.com/images/icons/' + 'hammer' + '.png" alt="" /></span>' + '<span class="rp_jobdata_label text_bold">' + WTKlang.progress + '</span>' + '<span class="rp_jobdata_text text_bold"></span>' + '</div>');
				$('span.rp_jobdata_text', tmp).append(new west.gui.Progressbar(data.build_point, data.build_point_limit).getMainDiv());
				$('.build-'+data.x+'-'+data.y+'-'+ data.build_key +' div.build_info').append(tmp);
			};
		},
	};

	WTK.ImprovedBuildCityhall = {
		init: function () {
			CityhallWindow.Build.fillContent_backup = CityhallWindow.Build.fillContent;
			CityhallWindow.Build.fillContent = function (data) {
				this.table.clearBody();
				for (var i = 0; i < data.length; i++) {
					var r = data[i];
					var buildtext;
					if (!this.main.ownTown){
						this.table.appendRow();
						buildtext = r.name;
						this.table.appendToCell(-1, "building_foreign", buildtext).appendToCell(-1, "stage", r.stage + " / " + (r.infinite ? "<img src='https://westde.innogamescdn.com/images/xp_inf_000.png' style='padding-bottom: 4px;'/>" : r.maxStage));
					} else if (r.stage == r.maxStage && !r.infinite) {

					} else {
						this.table.appendRow();
						buildtext = '<a href="#" onClick="javascript:void(BuildWindow.open(' + Character.homeTown.town_id + ', ' + Character.homeTown.x + ', ' + Character.homeTown.y + ', \'' + r.key + '\', false));">' + r.name + '</a></span>';
						this.table.appendToCell(-1, "building", buildtext).appendToCell(-1, "stage", r.stage + " / " + (r.infinite ? "<img src='https://westde.innogamescdn.com/images/xp_inf_000.png' style='padding-bottom: 4px;'/>" : r.maxStage)).appendToCell(-1, "progress", new west.gui.Progressbar(r.buildPoints, r.nextStagePoints).getMainDiv());
					}
				}
			};
		},
	};

	WTK.ExtendedItemFinder = {
		itemsToFind: [],
		searchResultDialog: null,
		searchDialog: null,

		init: function () {
			var savedItemsToFindOriginal = JSON.parse(localStorage.getItem('WTKItemFinderItems'));
			if(savedItemsToFindOriginal != null){
				for (var i = 0; i < savedItemsToFindOriginal.length; i++) {
					var item = {id: savedItemsToFindOriginal[i], targetAmount: 1, showNotification: true};
					WTK.ExtendedItemFinder.itemsToFind.push(item);
				}
				localStorage.removeItem('WTKItemFinderItems');
				localStorage.setItem('WTKExtendedItemFinderItems', JSON.stringify(WTK.ExtendedItemFinder.itemsToFind));
			} else {
				var savedItemsToFind = JSON.parse(localStorage.getItem('WTKExtendedItemFinderItems'));
				if(savedItemsToFind != null){
					WTK.ExtendedItemFinder.itemsToFind = savedItemsToFind;
				}
			}
			WTK.ExtendedItemFinder.initFindNotification();
		},

		showExtendedItemFinder: function() {
			WTK.GUI.open();
			WTK.GUI.getDefault('WTKExtendedItemFinder');
			var scrollPane = new west.gui.Scrollpane();

			var itemSearchButton = new west.gui.Button(WTKlang.searchItem, function() {
				WTK.ExtendedItemFinder.showSearchDialog();
            });

			var deleteButton = new west.gui.Button(WTKlang.deleteMarkedItems, function() {
				WTK.ExtendedItemFinder.deleteSelectedItems();
            }).addClass('inactive');

			var helpButton = new west.gui.Button(WTKlang.help, function() {
					WTK.ExtendedItemFinder.helpDialog = new west.gui.Dialog(WTKlang.help, $('<div>').append(WTKlang.itemFinderHelpContent)).addButton(WTKlang.back);
					WTK.ExtendedItemFinder.helpDialog.show();
            });
			
			scrollPane.appendContent(itemSearchButton.getMainDiv());
            scrollPane.appendContent(deleteButton.getMainDiv());
            scrollPane.appendContent(helpButton.getMainDiv());

			var itemsToFind = WTK.ExtendedItemFinder.itemsToFind;
			var targetAmount = 1;
			for (var i = 0; i < itemsToFind.length; i++) {
				var itemId = itemsToFind[i].id;
				var item = ItemManager.get(itemId);
				var popup = new ItemPopup(item,{}).popup;
				var div;
				var classToSet = '';
				if(itemsToFind[i].showNotification == true)
					classToSet = 'WTK_find_notifcation_highlight';
				if(Bag.getItemCount(itemId) >= itemsToFind[i].targetAmount){
					div = $('<div>').append('<div class="item item_inventory hasMousePopup WTK_item_border_green" title="' + popup.getXHTML().escapeHTML() + '"><img class="tw_item item_inventory_img dnd_draggable" src="' + item.image + '" alt='+itemId+'>'+'<div class="' + classToSet + ' WTK_find_notifcation">'+ Bag.getItemCount(itemId) + ' / ' + itemsToFind[i].targetAmount +'</div>'+'<span class="count-required"><p/></span></div>');
				} else {
					div = $('<div>').append('<div class="item item_inventory hasMousePopup WTK_item_border" title="' + popup.getXHTML().escapeHTML() + '"><img class="tw_item item_inventory_img dnd_draggable" src="' + item.image + '" alt='+itemId+'>'+'<div class="' + classToSet + ' WTK_find_notifcation">' + Bag.getItemCount(itemId) + ' / ' + itemsToFind[i].targetAmount +'</div>'+'<span class="count-required"><p/></span></div>');
				}
				div.children("div").children("div").off("click").click(function () {
					$(this).toggleClass("WTK_find_notifcation_highlight");
					WTK.ExtendedItemFinder.toogleNotification($(this).parent().find("img").attr("alt"));
				});
				div.find("img").off("click").click(function () {
					$(this).parent().parent().toggleClass("opacity05");
					if($('.active_tab_id_WTKExtendedItemFinder').find('.opacity05').length == 0){
						$('.WTKMenuWindow').find($('.tw2gui_button')).last().prev().addClass('inactive');
					} else {
						$('.WTKMenuWindow').find($('.tw2gui_button')).last().prev().removeClass('inactive');
					}
				});
				scrollPane.appendContent(div);
			}
			var placeHolder = '';
//			for (var i = 0; i <= (itemsToFind.length - itemsToFind.length  % 10) / 10; i++) {
//				placeHolder += '<div style="height: 64px;" ondrop="WTK.ExtendedItemFinder.dropItem(event)" ondragover="WTK.ExtendedItemFinder.allowDrop(event)"/>';
//			}
			placeHolder = '<div style="height: ' + 66 * Math.ceil(itemsToFind.length / 10) + 'px;" />';

			scrollPane.appendContent(placeHolder);
			$(WTK.GUI.window.getContentPane()).append(scrollPane.getMainDiv());
            $('.WTKMenuWindow').find($('.tw2gui_button')).first().css('margin-bottom', '5px');
		},
		
		

		deleteSelectedItems: function(){
			var selectedItems = $('.active_tab_id_WTKExtendedItemFinder').find('.opacity05');
			for (var i = 0; i < selectedItems.length; i++) {
				var id = selectedItems[i].childNodes[0].childNodes[0].alt;
				WTK.ExtendedItemFinder.itemsToFind = jQuery.grep(WTK.ExtendedItemFinder.itemsToFind, function(value) {
					return value.id != id;
				});
			}
			localStorage.setItem('WTKExtendedItemFinderItems', JSON.stringify(WTK.ExtendedItemFinder.itemsToFind));
			WTK.ExtendedItemFinder.showExtendedItemFinder();
		},

		toogleNotification: function(item_id){
			WTK.ExtendedItemFinder.itemsToFind
			for (var i = 0; i < WTK.ExtendedItemFinder.itemsToFind.length; i++) {
				var entry = WTK.ExtendedItemFinder.itemsToFind[i];
				if (entry.id == item_id) {
					entry.showNotification = ! entry.showNotification;
					WTK.ExtendedItemFinder.itemsToFind[i] = entry;
					localStorage.setItem('WTKExtendedItemFinderItems', JSON.stringify(WTK.ExtendedItemFinder.itemsToFind));
				}
			}
		},

		searchForItems: function(){
			var name = $('#WTKExtendedItemFinder_searchDialog_name').val();
			var amount = parseInt($('#WTKExtendedItemFinder_searchDialog_targetAmount').val());
			var searchResult = [];
			var searchMaximum = Math.floor(($( window ).height() - 230) / 16);
			for(var oldItemId = 1; oldItemId < 253801 && searchResult.length < searchMaximum; oldItemId++){
				var newItemId = oldItemId * 1000;
				if(ItemManager.get(newItemId) != undefined && ItemManager.get(newItemId).name.toLowerCase().indexOf(name.toLowerCase()) >= 0 && WTK.ExtendedItemFinder.isAlreadyOnTheList(newItemId) == false){
					searchResult.push(newItemId);
				}
			}
			if(searchResult.length > 0){
				var contentDiv = "";
				for (var i = 0; i < searchResult.length; i++) {
					var item_id = searchResult[i];
					var item = ItemManager.get(item_id);
					var popup = new ItemPopup(item,{}).popup;
					contentDiv += '<a class="hasMousePopup" title="' + popup.getXHTML().escapeHTML() + '" href="javascript:void(WTK.ExtendedItemFinder.addItemToItemsToSearch(' + item_id + ',' + amount + '))">' + item.name + '</a> ' + WTK.ExtendedItemFinder.getColoredString(Bag.getItemCount(item.item_id), amount) + '<br>';
				}
				if(searchResult.length == searchMaximum){
					contentDiv += '<br><b>' + WTKlang.thereAreMoreItems + '<br>' + WTKlang.restrictYourSearch + '</b>';
				}
				new west.gui.Dialog(WTKlang.searchResult, $(contentDiv)).addButton(WTKlang.back, function(){
					WTK.ExtendedItemFinder.showSearchDialog(name, amount);
				}).addButton('cancel').show();
			} else {
				MessageHint(WTKlang.emptySearchResult).show();
			}
		},

		inputIsValid: function(){
			var targetAmount = parseInt($('#WTKExtendedItemFinder_searchDialog_targetAmount').val());
			var name = $('#WTKExtendedItemFinder_searchDialog_name').val();
			if (name == undefined || name.length <= 0){
				MessageError(WTKlang.nameCannotBeEmpty).show();
				return false;
			} else if (targetAmount == undefined || Number.isNaN(targetAmount) || targetAmount <= 0) {
				MessageError(WTKlang.itemAmountMustBeHigherThan0).show();
				return false;
			}
			return true;
		},

		addItemToItemsToSearch: function(item_id, targetAmountValue) {
			if(WTK.ExtendedItemFinder.isAlreadyOnTheList(item_id) == false){
				var item = {id: item_id, targetAmount: targetAmountValue, showNotification: false};
				WTK.ExtendedItemFinder.itemsToFind.push(item);
				localStorage.setItem('WTKExtendedItemFinderItems', JSON.stringify(WTK.ExtendedItemFinder.itemsToFind));
				WTK.ExtendedItemFinder.showExtendedItemFinder();
			}
		},

		showSearchDialog: function(nameInputValue, targetAmoundInputValue) {
			var contentDiv = $('<div style="text-align: center;">');
			contentDiv.append(WTKlang.whatItemsWouldYouLikeToSearchFor + '<br><b>' + WTKlang.nameOfTheItem + '<b>');
			var nameInput = new west.gui.Textfield('WTKExtendedItemFinder_searchDialog_name').setSize(10).setClass4Input('input_layout');
			nameInput.setValue(nameInputValue)
			contentDiv.append(nameInput.getMainDiv());
			contentDiv.append('<br>' + WTKlang.howManyOfThemWouldYouLikeToCollect + '<br><b>' + WTKlang.numberOfItems + '<b>');
			var targetAmoundInput = new west.gui.Textfield('WTKExtendedItemFinder_searchDialog_targetAmount').onlyNumeric().setSize(10).setClass4Input('input_layout');
			targetAmoundInput.setValue(targetAmoundInputValue);
			contentDiv.append(targetAmoundInput.getMainDiv());
			WTK.ExtendedItemFinder.searchDialog = new west.gui.Dialog(WTKlang.searchItem, $(contentDiv)).addButton(WTKlang.search, function () {
				if(WTK.ExtendedItemFinder.inputIsValid()){
					WTK.ExtendedItemFinder.searchForItems();
				} else {
					WTK.ExtendedItemFinder.showSearchDialog($('#WTKExtendedItemFinder_searchDialog_name').val(), $('#WTKExtendedItemFinder_searchDialog_targetAmount').val());
				}
			}).addButton('cancel');
			WTK.ExtendedItemFinder.searchDialog.show();
			$('#WTKExtendedItemFinder_searchDialog_name').focus()
			$('#WTKExtendedItemFinder_searchDialog_targetAmount').val(1);
		},

		isAlreadyOnTheList: function(item_id) {
			for(var i = 0; i < WTK.ExtendedItemFinder.itemsToFind.length; i++){
				if(WTK.ExtendedItemFinder.itemsToFind[i].id == item_id){
					return true;
				}
			}
			return false;
		},

		getColoredString: function(currentAmount, targetAmount) {
			var color = targetAmount > currentAmount ? 'red' : 'green';
			return '<span class="text_' + color + ' bold">' + currentAmount + '/' + targetAmount + '</span>';
		},
		
		initFindNotification: function() {
			Bag.handleChanges_backup = Bag.handleChanges;
			Bag.handleChanges = function (changes, from) {
				var i = 0, l = changes.length, item;
				for (i; i < l; i++) {
					if (changes[i].count > 0 && WTK.ExtendedItemFinder.isAlreadyOnTheList(changes[i].item_id) && from != 'wear') {
						var item2 = ItemManager.get(changes[i].item_id);
						var popup = new ItemPopup(item2,{}).popup;
						new west.gui.Dialog(WTKlang.itemFinder, '<div class="item item_inventory hasMousePopup" title="' + popup.getXHTML().escapeHTML() + '"><img class="tw_item item_inventory_img dnd_draggable" src="' + item2.image + '"></div>' + WTKlang.youHaveFound + '<br><br><div style="text-align: center;"><b>' + item2.name +'</b></div><br>').addButton('ok').setModal(true, false, {
							bg : "https://westde.innogamescdn.com/images/curtain_bg.png", opacity : 0.7
						}).setHeight('40px').show();
					}
				}
				Bag.handleChanges_backup.call(this, changes, from);
			}
		},
		
		isItemOnNotificationList: function(item_id) {
			for(var i = 0; i < WTK.ExtendedItemFinder.itemsToFind.length; i++){
				if(WTK.ExtendedItemFinder.itemsToFind[i].id == item_id && WTK.ExtendedItemFinder.itemsToFind[i].showNotification == true){
					return true;
				}
			}
			return false;
		}
	};

	WTK.ExtendedBBCodes = {
		init: function () {
			Game.TextHandler.parse_backup = Game.TextHandler.parse;
			Game.TextHandler.parse = function (text) {
				text = WTK.ExtendedBBCodes.replaceColor(text);
				text = WTK.ExtendedBBCodes.replaceSize(text);
				text = WTK.ExtendedBBCodes.replaceImage(text);
				return Game.TextHandler.parse_backup.call(this, text);
			}
		},
		
		replaceColor: function (text) {
			var resultArray = text.match(/\[color=[a-z]*\]/g);
			if (resultArray != null) {
				for (var i = 0; i <resultArray.length; i++) {
					var color = resultArray[i].replace('[color=','').replace(']','');
					text = text.replace(/\[color=[a-z]*\]/,'<span style="color:' + color + '">').replace(/\[\/color\]/,'</span>');
				}
			}
			return text;
		},
		
		replaceSize: function (text) {
			var resultArray = text.match(/\[size=[0-9]*\]/g);
			if (resultArray != null) {
				for (var i = 0; i <resultArray.length; i++) {
					var size = resultArray[i].replace('[size=','').replace(']','');
					text = text.replace(/\[size=[0-9]*\]/,'<span style="font-size:' + size + 'px">').replace(/\[\/size\]/,'</span>');
				}
			}
			return text;
		},
		
		replaceImage: function (text) {
			return text.replace(/\[img\]/g,'<img src="').replace(/\[\/img\]/g,'"/>');
		},
	};

	WTK.Skript.init();
});