// ==UserScript== // @name TW-Collections // @namespace https://greasyfork.org/users/2196 // @description TW-Collections - see history // @include https://*.the-west.*/game.php* // @exclude https://classic.the-west.net* // @author Dun (updated by Tom Robert) // @version 1.4.6.9 // @history 1.4.6.9 bankfees removed, old updater removed, item sets selectbox improved, bugfixes, TW v2.241 // @history 1.4.6.8 greasyfork fix // @history 1.4.6.5 bugfix, TW v2.97 // @history 1.4.6.4 bugfixes by Tom Robert, TW v2.80 // @history 1.4.6.3 rev. TW 2.29 // @history 1.4.6.2 rev. TW 2.26 // @history 1.4.6.1 rev. TW 2.24 // @history 1.4.6 add Ro translation // @history 1.4.5 correcting a bug on current market bid // @history 1.4.4 Correct bugs & update 2.23 & add upgradeables search in inventory // @history 1.4.3 Correct refresh bug // @history 1.4.2 update for TW 2.21 // @history 1.4.1 correct bugs and add include for beta // @history 1.4.0.2 remove personnal frienset from sets list // @history 1.4.0 add Set Window and crafting items icons // @history 1.3.9 correct for es translation // @history 1.3.8 miscelaneous changes - update link to pastebin (thanks to Tom Robert ) // @history 1.3.7 correct bug for double item wearing - reactivate update // @history 1.3.6 correct translations links // @history 1.3.5 correct bugs save & trader icons // @history 1.3.4 correct bugs save settings // @history 1.3.3.9 correct bugs for 2.1, deactivate update since userscript is dead // @history 1.3.3.8 update TW version 2.1 // @history 1.3.3.7 maj for 2.09 // @history 1.3.3.6 correcting tips in mobile trader // @history 1.3.3.5 add vertical scrollbar in set & collection selectboxs // @history 1.3.3.4 maj 2.08 & optimisation chargement items de collections // @history 1.3.3.3 Fix ended bids // @history 1.3.3.2 correct End bids on collector list, add setting for deactivate menu mouse hover // @history 1.3.3 Mod. listcolector: recherche dans le marché add direct link to market / mobile trader, add filters // @history 1.3.2.1 Fix inventory bug // @history 1.3.2 fix for the the mobile trader link, add the new TW items of the achieved collections, add pictures on collections list // @history 1.3.1.3 fix for the shop display // @history 1.3.1.2 corrections // @history 1.3.1.1 corrections // @history 1.3.1 correction pour le nouveau marchand ambulant + patch TWDB new // @history 1.3.0 correction trad en + ajout lien forum // @history 1.2.9 correction trad en et logout sans confirmation + ajout trad Slovak // @history 1.2.7 correction trad en et logout sans confirmation // @history 1.2.7 ajout filtres inventaires, correction // @history 1.2.7 modification du systeme de langue et de l'updater, simplification suppression rapport, etc... // @history 1.2.6.1 correction affichage TW api // @history 1.2.6 correction lang et changement de nom // @history 1.2.5 corrections ... or not :) // @history 1.2.4 Création d'une barre d'outils dans l'inventaire (recettes, sets, consommables,doublons) // @history 1.2.3 ajout d'un bouton doublon dans l'inventaire et correction bug lang // @history 1.2.2 passage 2.0.6 // @history 1.2.1 passage 2.0.5 // @history 1.2.0 correction bugs maj + Traduction italienne (grazie tw81) // @history 1.1.9 correction attente TWDB.... // @nocompat Chrome // @grant none // @downloadURL none // ==/UserScript== (function (e) { var t = document.createElement("script"); t.type = "application/javascript"; t.textContent = "(" + e + ")();"; document.body.appendChild(t); t.parentNode.removeChild(t); }) (function () { TWT = { DEBUG: false, LANG: {}, info: { name: 'TW-Collections', lang: 'en', version: '1.4.6.9', min_gameversion: '2.0', max_gameversion: Game.version.toString(), idscript: '1670', website: 'https://greasyfork.org/scripts/7258' }, languages: [{ short_name: 'fr', name: 'Francais', translator: 'Dun', version: '1.4.0' }, { short_name: 'en', name: 'English', translator: 'Dun', version: '1.4.0' } ], images: { cup: "images/icons/achv_points.png", logout: "data:image/jpg;base64,/9j/4AAQSkZJRgABAgIAJQAlAAD/wAARCAAZADIDAREAAhEBAxEB/9sAhAAGBAUGBQQGBgUGBwcGCAoRCwoJCQoVDxAMERkWGhoYFhgXGx8oIRsdJR4XGCIvIyUpKiwtLBshMTQwKzQoKywrAQcHBwoJChQLCxQrHBgcHCsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKyv/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXG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Jhd7NFEQ0qSwLJP4lVPcPCrop5Kle3aRf7AN0AZxg9uMvXHN0qy03ZJqWakeOZZJPGfNG0aq0kRZgU6NCyOAOP4jyew45MUxHJtsIb/kWZbwPlEF9t1PLRQxUJhWCKPvKKmY9zxKxk95OVAABJYk64jk3O7nMg3RJtFOktDgugWxG3jzty5p9yeVmEgOmKfcvsvzVfCJ/lGbOfUfie5O3tBmFROszVSc+V06s3Hx7KRyrA8gr+CCNNTz9PuN33IcBlym3xVTU94vVdcKX7qDxyeGadpI2dQB1ZkZXK8AgvwfkHTT+HsyxRcmSpUWeqdIY9/vSAGDqOb9/PrXoO82DYxJFBf5rYGqFk7xOsjRtFIVA7o6FXRuPUlWHK/B5HxrB2/aDF83ySltuZVtzutGKtpoqGuuLyQRuSf8AM+sgHYhVkDhQfUDTTRnZwu5hLpLTjhK1XeqbiUT19P8ATz+/zzqobJYLVZLelut1KEiT9Ofkk/kk/knTTTV4gxF0urFo8Gv/2Q==" }, menu_callback: { goHome: "TaskQueue.add(new TaskWalk(Character.homeTown.town_id,'town'))", goToDaily1: 'GameMap.center(1920, 2176);', goToDaily2: 'GameMap.center(28288,16768);', ownSaloon: 'SaloonWindow.open(Character.homeTown.town_id);', openMarket: 'MarketWindow.open(Character.homeTown.town_id);', mobileTrader: "west.window.shop.open().showCategory('trader');", forum: "ForumWindow.open();", listNeeded: 'TWT.WindowCollection.open();', openOptions: "TWT.Options.open('setting')" }, css: { style: "position:relative;top:0px;left:0px;width:12px;height:12px;padding:0px;border:0px;margin:0px;", styleT: "position:absolute;top:4px;left:3px;width:15px;height:15px;padding:0px;border:0px;margin:0px;", styleN: "position:absolute;top:120px;left:25px;padding:0px;border:0px;margin:0px;", styleDB: "position:absolute;top:0px;left:0px;padding:0px;border:0px;margin:0px;" }, langPatchs: { cs: { link: "7260", texte: "Czech - čeština", author: "Dr.Keeper" }, es: { link: "7313", texte: "Spanish - Español", author: "pepe100" }, de: { link: "1672", texte: "German - Deutsch", author: "Hanya & Tom Robert" }, it: { link: "1675", texte: "Italian - Italiano", author: "tw81" }, hu: { link: "7261", texte: "Hungarian - Magyar", author: "Zoltan80" }, sl: { link: "7259", texte: "Slovak - Slovenčina", author: "Surge" }, pl: { link: "1674", texte: "Polish - Polski", author: "Dun from Darius II mod" }, pt: { link: "7312", texte: "Portuguese - Português", author: "VSaantiago" }, ru: { link: "7271", texte: "Russian - Pу́сский", author: "Anch665" }, ro: { link: "9037", texte: "Romanian - Română", author: "Peta" } }, langs: { fr: { description: "

TW Collections
Astuces et signalement des items manquants des collections
Liste des items manquants des collections
Divers raccourcis et fonctions
Suppressions des rapports
Doublons dans l'inventaire
etc...
", Options: { tab: { setting: 'Réglages' }, checkbox_text: { box: { title: 'Raccourcis menus', options: { goHome: 'Aller à sa ville', goToDaily1: 'Aller à la ville abandonnée', goToDaily2: 'Aller au village de Waupee', ownSaloon: 'Ouvrir votre saloon', openMarket: 'Ouvrir le marché', mobileTrader: 'Ouvrir le marchand ambulant', forum: 'Ouvrir le forum', listNeeded: 'Items manquants des collections' } }, collection: { title: 'Collections', options: { gereNewItems: 'Gérer les nouveaux items des succés déjà obtenus', patchsell: 'Signalement des items manquants aux collections dans l\'inventaire', patchtrader: 'Signalement des items nécessaires aux collections chez les marchands', patchmarket: 'Signalement des items nécessaires aux collections dans le marché', filterMarket: 'Filtre dans le marché pour n\'afficher que les items manquants des collections', showmiss: 'Items manquants des collections sur survol' } }, inventory: { title: 'Boutons supplémentaires dans l\'inventaire', options: { doublons: 'Bouton de recherche des doublons', useables: 'Bouton de recherche des consommables', recipe: 'Bouton de recherche des recettes', sets: 'Liste de recherche des sets', sum: "Cumul des prix de vente marchand sur recherche" } }, miscellaneous: { title: 'Divers', options: { lang: 'Language', logout: 'Bouton déconnexion directe', deleteAllReports: 'Action pour supprimer tous les rapports', showFees: 'Frais bancaire en survol', popupTWT: 'Ouverture du menu du script Collections au survol' } }, craft: { title: 'Artisanat', options: { filterMarket: 'Recherche des items de craft dans le marché' } }, twdbadds: { title: 'Add-on Clothcalc', options: { filterBuyMarket: 'Filtre dans le marché pour n\'afficher que les items manquants (twdb add)' } } }, message: { title: 'Information', message: 'Préférences appliquées', reloadButton: 'Recharger cette page', gameButton: 'Aller sur le jeu', indispo: 'Option indisponible (Collections terminées ou script non diponible)', more: 'Autres ?', moreTip: 'Ouvrir la page des traductions' }, update: { title: ' Mise à jour', updok: 'Le script TW Collection est à jour', updscript: 'Une nouvelle version du script TW Collections est disponible
Mettre à jour ?', updlangmaj: 'Une mise à jour est disponible pour une ou plusieurs langues utilisées avec le script TW Collections.
Cliquez sur les liens ci dessous pour mettre à jour ?', upddaily: 'Journalières', updweek: 'Hebdomadaire', updnever: 'Jamais', checknow: 'Verifier les mises à jour ?', upderror: 'Impossible de mettre le script TW Collections à jour, vous devez installer le script ou la langue manuellement' }, saveButton: 'Sauvegarder' }, Craft: { titleMarket: 'Rechercher cet item dans les ventes du marché', }, ToolBox: { title: 'Fonctionnalités', list: { openOptions: 'Paramètres de l´outil' } }, Doublons: { tip: 'Afficher uniquement les doublons', current: 'Recherche courante', upgradeable: 'Ameliorables', noset: 'Sans items de sets', sellable: 'Vendables', auctionable: 'Commercialisables', tipuse: 'Afficher uniquement les consommables', tiprecipe: 'Afficher uniquement les recettes', tipsets: 'Afficher uniquement les items de sets', sellGain: '$ prix marchand ' }, Logout: { title: 'Déconnecter' }, AllReportsDelete: { button: 'Tout supprimer', title: 'Supprimer tous les rapports', work: 'Job', progress: 'Etat d\'avancement', userConfirm: 'Confirmation utilisateur', loadPage: 'Charger la page', deleteReports: 'Supprimer les rapports', confirmText: 'Etes-vous sur de vouloir supprimer tous les rapports ?', deleteYes: 'Oui, supprimer', deleteNo: 'Non, ne pas supprimer', status: { title: 'Statut', wait: 'Patienter', successful: 'Réussi', fail: 'Erreur', error: 'Erreur' } }, twdbadds: { buyFilterTip: 'Montrer seulement les items manquants', buyFilterLabel: 'Items manquants' }, collection: { miss: "Manquants : ", colTabTitle: "Collections", setTabTitle: "Sets", thText: '%1 item%2 manquant%3', thEncours: 'Vous avez une enchère en cours pour cet article', thFetch: 'Vous pouvez récuperer cet article au marché de %1', allOpt: 'Tous', listText: 'Liste des items manquants des collections', listSetText: 'Liste des items manquants des Sets', collectionFilterTip: 'Montrer seulement les items de collection', collectionFilterLabel: 'Collections seules', select: 'Sélectionner ...', filters: 'Filtres', atTrader: 'Vendu par le marchand ambulant', atBid: 'Enchères en cours', atCurBid: 'Enchères terminées', searchMarket: 'Rechercher dans le marché', atTraderTitle: 'Affichez les items en vente chez le marchand ambulant', atBidTitle: 'Affichez les items en cours d\'enchère', atCurBidTitle: 'Affichez les items récupèrables aux enchères', patchsell: { title: "Cet item est nécessaire pour une collection en cours" } } }, en: { description: "

TW-Collections
Tips and reporting missing items collections
list of collection needed items
Various shortcuts" + "
All reports deletion
Additional buttons in inventory (duplicates,useables, recipes, sets)
etc ...", Options: { tab: { setting: 'Settings' }, checkbox_text: { box: { title: 'Features / Menus', options: { goHome: 'Travel to town', goToDaily1: 'Ghost Town', goToDaily2: 'Waupee Indian Camp ', ownSaloon: 'Open saloon', openMarket: 'Open Market', mobileTrader: 'Open Mobile Trader', forum: 'Open forum', listNeeded: 'Collector\'s items needed' } }, collection: { title: 'Collections', options: { gereNewItems: 'Manage the new items added on succeeded achievements', patchsell: 'Signal missing items in inventory', patchtrader: 'Signal missing items on Traders', patchmarket: 'Signal missing items on Market', showmiss: 'List for missing items on tip', filterMarket: 'Market filter : show only missing items (collections)' } }, inventory: { title: 'Buttons in inventory', options: { doublons: 'Add button for duplicates search', useables: 'Add button for useables search', recipe: 'Add button for recipes search', sets: 'Add button for sets list', sum: 'Show sell sum on search based on merchant prices' } }, miscellaneous: { title: 'Miscellaneous', options: { lang: 'Language', logout: 'Add Logout button', deleteAllReports: 'Add suppress all reports action', showFees: 'Add Bank Fees on Mouseover', popupTWT: 'Open menu of TW Collections on mouse hover' } }, craft: { title: 'Craft', options: { filterMarket: 'Icon for searching craft item in the market' } }, twdbadds: { title: 'Clothcalc Add-on', options: { filterBuyMarket: 'Market filter : show only marked missing items (twdb add)' } } }, message: { title: 'Information', message: 'Preferences have been applied.', reloadButton: 'Reload this page', gameButton: 'Return to the game', indispo: 'Setting unavailable (Collections completed or script not available)', more: 'More ?', moreTip: 'Open the translations tips page' }, update: { title: 'Update', upddaily: 'Every day', updweek: 'Every week', updnever: 'Never', checknow: 'Check update now ?', updok: "The TW Collection's script is up to date", updlangmaj: 'An update is available for one or more languages ​​of the TW Collections script.
Clic on the links bellow to upgrade.', updscript: 'An update is available for the script TW Collections
Upgrade ?', upderror: 'Unable to upgrade, you should install the script or language manually' }, saveButton: 'Save' }, Craft: { titleMarket: 'Search this item in the market', }, ToolBox: { title: 'Features', list: { openOptions: 'Settings' } }, Doublons: { tip: 'Show only duplicates', current: 'Current search', upgradeable: 'Upgradeables', noset: 'Without set items', sellable: 'Sellables', auctionable: 'Auctionables', tipuse: 'Show only useables', tiprecipe: 'Show only recipes', tipsets: 'Show only set items', sellGain: '$ from the merchant' }, Logout: { title: 'Logout' }, AllReportsDelete: { button: 'Delete all reports', title: 'Delete all reports', work: 'Job', progress: 'Progress', userConfirm: 'User Confirm', loadPage: 'Load Page', deleteReports: 'Delete reports', confirmText: 'Delete all reports - Are you sure?', deleteYes: 'Yes, delete', deleteNo: 'No, don\'t delete', status: { title: 'Status', wait: 'Wait', successful: 'Réussi', fail: 'Error', error: 'Error' } }, twdbadds: { buyFilterTip: 'Show only missing items', buyFilterLabel: 'Missing items' }, collection: { miss: "Missing : ", colTabTitle: "Collections", setTabTitle: "Sets", thText: '%1 missing item%2', thEncours: 'You have a bid for this item', thFetch: 'You may retrieve this item at the market of %1', allOpt: 'All', collectionFilterTip: 'Show only collections items', collectionFilterLabel: 'Collections only', select: 'Select ...', listText: 'Collector\'s items needed', listSetText: 'Set\'s items needed', filters: 'Filters', atTrader: 'Sold by mobile trader', atBid: 'Current bids', atCurBid: 'Ended bids', atTraderTitle: 'Show items on sale at the mobile trader', atBidTitle: 'Show currents bids', atCurBidTitle: 'Show items retrievable at market', searchMarket: 'Search in the market', patchsell: { title: "Items needed to complete collections" } } } }, getLanguage: function () { var detected_lang; try { detected_lang = TWT.scriptStorage.getItem('TWT.Cache.miscellaneous.lang'); if (!isDefined(detected_lang)) { detected_lang = Game.locale.match(/(\S*)_/)[1]; } if (!isDefined(detected_lang)) { detected_lang = TWT.info.lang; } } catch (ex) { detected_lang = TWT.info.lang; } finally { var langue = TWT.langs[detected_lang]; if (!isDefined(langue)) { langue = TWT.langs[TWT.info.lang]; var saved_descr = localStorage.getItem('TWT.Cache.description'); if (isDefined(saved_descr)) { langue.description = saved_descr; } EventHandler.listen('twt_lang_started_' + detected_lang, function () { TWT.getLanguage(); return EventHandler.ONE_TIME_EVENT; }); } else { TWT.info.lang = detected_lang; } return langue; } }, addMissedTrad: function (enTrObj, langTrObj) { if (!isDefined(langTrObj)) { langTrObj = {}; } $.each(enTrObj, function (ind, item) { if (jQuery.type(item) == "object") { langTrObj[ind] = TWT.addMissedTrad(item, langTrObj[ind]); } else { if (jQuery.type(langTrObj[ind]) == "undefined") { langTrObj[ind] = enTrObj[ind]; } } }); return langTrObj; }, isGreasyLang: function (lang) { var oldIdLangs = ["179395", "179358", "179298", "178773", "180784", "182959", "179302"]; if ($.inArray(lang.idscript, oldIdLangs) > -1) { var dlg = new west.gui.Dialog("Unmaintained language script for TW Collection", "
You are using an obsolete version of '" + lang.name + "' language script for TW Collection." + "

You should manually uninstall this script and
" + "Install the correct version of " + lang.name + " script." + "
", west.gui.Dialog.SYS_WARNING).setModal(true, false, { bg: "images/curtain_bg.png", opacity: 0.4 }).addButton(west.gui.Dialog.SYS_OK).show(); return false; } else { return true; } }, addPatchLang: function (lang) { try { if (TWT.isGreasyLang(lang)) { TWT.langs[lang.short_name] = lang.translation; TWT.languages.push({ 'short_name': lang.short_name, 'name': lang.name, 'translator': lang.translator, 'version': lang.version, 'script': lang.idscript }); TWT.langs[lang.short_name] = TWT.addMissedTrad(TWT.langs.en, TWT.langs[lang.short_name]); EventHandler.signal('twt_lang_started_' + lang.short_name); } } catch (e) { ErrorLog.log(e); } }, checkIsValidLang: function () { var selLang = TWT.langs[TWT.Settings.checked.miscellaneous.lang] || undefined; if (!isDefined(selLang)) { TWT.Options.open('translate'); TWT.Settings.checked.miscellaneous.lang = TWT.info.lang; TWT.scriptStorage.setItem('TWT.Cache.miscellaneous.lang', TWT.info.lang); } }, init: function () { try { EventHandler.signal("twt.init"); var that = this; var timeout = 0; this.interval = setInterval(function () { var loading = false; if (isDefined(Character.playerId) && Character.playerId == 0) { loading = false; } else if (!isDefined(ItemManager)) { loading = false; } else if (isDefined(ItemManager.initialized) && !ItemManager.initialized) { loading = false; } else if (isDefined(window.TWDB)) { /* null != TWDB && 'undefined' != typeof TWDB) {*/ if (!window.TWDB.ClothCalc.ready) { loading = false; timeout++; if (timeout > 20) { ErrorLog.log('Stop interval, chargement de TWDB non possible ?'); TWT.isTWDBHere = true; loading = true; } } else { TWT.isTWDBHere = true; loading = true; } } else loading = true; if (loading) { clearInterval(that.interval); if (TWT.scriptStorage == null) { TWT.scriptStorage = new Storage("local", "Storage." + TWT.info.idscript); } TWT.LANG = TWT.getLanguage(); TWT.Settings.init(); TWT.checkIsValidLang(); if (!TWT.DEBUG) { TWT.api(); } else { window.DEBUG = true; } TWT.ready = true; EventHandler.signal('twt.ready'); } }, 500); } catch (e) { ErrorLog.log("Erreur d'initialisation", e); ErrorLog.showLog(); TWT.ready = false; } }, Commons: { searchMarket: function (id) { if (!isNaN(id)) { var objS = ItemManager.get(id); id = objS.name; } MarketWindow.open(Character.homeTown.town_id); MarketWindow.showTab('buy'); $("div.market-buy .iSearchbox input", MarketWindow.DOM).val(id); $('span.iconBut_mpb_refresh', MarketWindow.DOM).click(); }, addMarketBuyLink: function (itemId) { var imgMrket = $('
').click(function (e) { TWT.Commons.searchMarket(e.target.attributes.id.value); }); return imgMrket; }, }, Settings: { checked: {}, shouldRefresh: {}, init: function () { if (!isDefined(TWT.scriptStorage.getItem('TWT.Cache.Metacol.finished'))) { /* TWT.MetaCol.init();*/ } else { TWT.MetaCol.finished = TWT.scriptStorage.getItem('TWT.Cache.Metacol.finished'); } $.each(TWT.LANG.Options.checkbox_text, function (ind1, val) { TWT.Settings.checked[ind1] = []; $.each(TWT.LANG.Options.checkbox_text[ind1].options, function (ind2, detail) { if (['showFees'].includes(ind2)) return 1; var attended = TWT.scriptStorage.getItem('TWT.Cache.' + ind1 + '.' + ind2); if (!isDefined(attended)) { if (ind2 == 'lang') attended = TWT.info.lang; else if (['logout', 'deleteAllReports'].includes(ind2)) attended = 0; else attended = '1'; TWT.scriptStorage.setItem('TWT.Cache.' + ind1 + '.' + ind2, attended); } TWT.Settings.checked[ind1][ind2] = attended; }); }); TWT.Settings.apply(); }, getValue: function (what) { return eval('TWT.Settings.checked.' + what); }, isChecked: function (what) { return TWT.Settings.getValue(what) == "1"; }, refresh: function (tabOpt) { var refreshed = false; try { for (var key in tabOpt) { if (tabOpt.hasOwnProperty(key)) { var val = tabOpt[key]; if (val != TWT.Settings.getValue(key)) { TWT.scriptStorage.setItem('TWT.Cache.' + key, val); var det = key.split('.'); TWT.Settings.checked[det[0]][det[1]] = val; EventHandler.signal(key); refreshed = true; } } } TWT.LANG = TWT.langs[TWT.Settings.getValue('miscellaneous.lang')] || TWT.langs.en; EventHandler.signal('collection.bagupdate'); } catch (e) { ErrorLog.log('Erreur refresh ', e); } return refreshed; }, apply: function () { TWT.LANG = TWT.langs[TWT.Settings.getValue('miscellaneous.lang')] || TWT.langs[TWT.info.lang]; TWT.MenuBox.initListener(); TWT.MenuBox.create(); TWT.Injecteur.startListen(); TWT.Logout.initListener(); if (TWT.Settings.isChecked('inventory.doublons') || TWT.Settings.isChecked('inventory.useables') || TWT.Settings.isChecked('inventory.recipe') || TWT.Settings.isChecked('inventory.sets')) { TWT.Inventaire.create(); } else { TWT.Inventaire.detach(); } TWT.CraftHandler.initListener(); TWT.AllReportsDelete.initListener(); if (TWT.Settings.isChecked('craft.filterMarket')) { TWT.CraftHandler.init(); TWT.CraftHandler.inject(); } if (TWT.Settings.isChecked('miscellaneous.logout')) TWT.Logout.create(); if ((!TWT.MetaCol.finished) || TWT.isTWDBHere) { TWT.Market.initListener(); if (TWT.Settings.isChecked("twdbadds.filterBuyMarket") || TWT.Settings.isChecked('collection.filterMarket')) { TWT.Market.init(); TWT.Market.inject(); } } if (!TWT.MetaCol.finished) { TWT.CollectionsHandler.initListener(); if (TWT.Settings.isChecked('collection.patchsell') || TWT.Settings.isChecked('collection.patchmarket') || TWT.Settings.isChecked('collection.showmiss')) { /* EventHandler.signal('collection.bagupdate');*/ TWT.CollectionsHandler.init(); TWT.CollectionsHandler.inject(); TWT.CollectionsHandler.attachFilter(); } } if (TWT.Settings.isChecked('miscellaneous.deleteAllReports')) { TWT.AllReportsDelete.addStyle(); TWT.AllReportsDelete.attach(); } } }, Options: { open: function (window) { TWT.Options.Windows = wman.open('TWTToolWindow').addClass('noreload').setMiniTitle(TWT.LANG.Options.tab.setting).addTab(TWT.LANG.Options.tab.setting, 'TabSetting', TWT.Options.setting.open).addTab('Translations', 'TabTranslate', TWT.Options.translate.open); $('
').attr({ 'id': 'ToolWindowBody' }).css({ 'margin-left': '20px', 'margin-right': '20px' }).appendTo('.TWTToolWindow .tw2gui_window_content_pane'); if (window == 'setting') { TWT.Options.setting.open(); } else { TWT.Options.translate.open(); } }, translate: { open: function () { var txtArea = '
' + '

The translation\'s system of the TW Collections script has changed

' + "TW Collections script contains just the french and english languages, if you need a different translation you must install one of the script below and reload the TW page

" + "
"; var langPatchs = TWT.langPatchs; $.each(langPatchs, function (lang) { txtArea += "" + langPatchs[lang].texte + " by " + langPatchs[lang].author + "
"; }); txtArea += '

If you want to create your own translation, you can go to the home page of the script for more explanations
'; TWT.Options.Windows.activateTab('TabTranslate').$("div.tw2gui_window_content_pane").empty(); TWT.Options.Windows.setTitle("Translations for TW Collections"); TWT.Options.Windows.appendToContentPane(txtArea); TWT.Options.Windows.appendToContentPane(TWT.getDunMp()); } }, setting: { open: function () { TWT.Options.Windows.activateTab('TabSetting').$("div.tw2gui_window_content_pane").empty(); TWT.Options.Windows.setTitle(TWT.LANG.Options.tab.setting); var save_button = new west.gui.Button(TWT.LANG.Options.saveButton, TWT.Options.save); var l0 = TWT.Options.createLanguage(); var l1 = TWT.Options.getContent(); var l2 = $('
').append(save_button.getMainDiv()); TWT.Options.Windows.appendToContentPane($('
').append(l0, l1, l2)); $("#divopts", TWT.Options.Windows.getMainDiv()).css("width: 674px;"); TWT.Options.Windows.appendToContentPane(TWT.getDunMp()); $(".fancytable div.trows div.tbody").css({ "min-height": "30px" }); } }, getContent: function () { var scrollbar = new west.gui.Scrollpane(); $.each(TWT.LANG.Options.checkbox_text, function (key) { var table = new west.gui.Table(true).setId('paramtwt_table_' + key).createEmptyMessage('! No Parameters !').addColumn("settings_" + key).appendToThCell("head", "settings_" + key, TWT.LANG.Options.checkbox_text[key].title, "" + TWT.LANG.Options.checkbox_text[key].title + ""); $.each(TWT.LANG.Options.checkbox_text[key].options, function (i) { if (!['lang', 'showFees'].includes(i)) { var checkB; if ((TWT.MetaCol.finished && (key == 'collection' || i == 'listNeeded')) || ((key == 'twdbadds') && !TWT.isTWDBHere)) { checkB = $("").append(TWT.LANG.Options.checkbox_text[key].options[i]); } else { checkB = new west.gui.Checkbox().setTitle(TWT.LANG.Options.checkbox_text[key].options[i]).setLabel("" + TWT.LANG.Options.checkbox_text[key].options[i] + "").setSelected(TWT.Settings.isChecked(key + '.' + i)).setId('setting_' + key + '_' + i).getMainDiv(); } table.appendRow(checkB, ''); } }); scrollbar.appendContent(table.getMainDiv()); }); $(scrollbar.getMainDiv()).css({ "height": "300px", "margin-top": "5px;", "font-weight": "normal" }); return $(scrollbar.getMainDiv()); }, createLanguage: function () { TWT.Options.lang_box = new west.gui.Combobox(); for (var i = 0; i < TWT.languages.length; i++) { TWT.Options.lang_box.addItem(TWT.languages[i].short_name, TWT.languages[i].name); } TWT.Options.lang_box.select(TWT.Settings.getValue('miscellaneous.lang')); var more_button = new west.gui.Button(TWT.LANG.Options.message.more, TWT.Options.translate.open, this, this, TWT.LANG.Options.message.moreTip); return $("").append(TWT.LANG.Options.checkbox_text.miscellaneous.options.lang + " : ").append(TWT.Options.lang_box.getMainDiv()).append(more_button.getMainDiv()); }, save: function () { TWT.Options.Windows.showLoader(); var tblSave = []; $.each(TWT.LANG.Options.checkbox_text, function (key) { $.each(TWT.LANG.Options.checkbox_text[key].options, function (i) { if (i != 'lang') { tblSave[key + '.' + i] = $('#setting_' + key + '_' + i).hasClass("tw2gui_checkbox_checked"); } }); }); tblSave['miscellaneous.lang'] = TWT.Options.lang_box.getValue(); TWT.Settings.refresh(tblSave); TWT.Options.Windows.hideLoader(); new UserMessage(TWT.LANG.Options.message.message, UserMessage.TYPE_SUCCESS).show(); } }, MenuBox: { selectbox: null, initListener: function () { EventHandler.listen('miscellaneous.popupTWT', function () { $('#TWT_Icon').remove(); TWT.MenuBox.create(); }); }, create: function () { $('#TWT_Icon').remove(); var a = $('
').attr({ 'class': 'menulink', 'title': TWT.LANG.ToolBox.title }).css({ 'background-position': '0px -100px' }).on('mouseleave', function () { $(this).css("background-position", "0px -100px"); }).click(function (e) { TWT.MenuBox.open(e); }); if (TWT.Settings.isChecked('miscellaneous.popupTWT')) { a.on('mouseenter', function (e) { $(this).css("background-position", "-25px -100px"); TWT.MenuBox.open(e); }); } var b = $('
').attr({ 'class': 'menucontainer_bottom' }); $('#ui_menubar').append($('
').attr({ 'class': 'ui_menucontainer', 'id': 'TWT_Icon' }).append(a).append(b)); }, open: function (e) { if (isDefined(this.selectbox)) { this.selectbox.items = []; } else { this.selectbox = new west.gui.Selectbox(true); this.selectbox.setWidth(250).addListener(function (key) { if (key == 99) { eval(TWT.menu_callback.openOptions); } else { eval(TWT.menu_callback[key]); } }); } var that = this; $.each(TWT.LANG.Options.checkbox_text.box.options, function (indexB, keyB) { if (TWT.Settings.isChecked('box.' + indexB)) that.selectbox.addItem(indexB, keyB); }); this.selectbox.addItem(99, TWT.LANG.ToolBox.list.openOptions); this.selectbox.show(e); this.selectbox.setPosition(e.clientX, e.clientY - 25); $(this.selectbox.elContent).on('mouseleave', function () { that.selectbox.hide(); }); } }, MetaCol: { group: [], groupSorted: [], marketEC: {}, all: {}, inProgress: {}, erreur: false, ready: false, dirty: true, getMarketEC: function () { $.ajax({ url: 'game.php?window=building_market&action=fetch_bids&h=' + Player.h, type: 'POST', data: {}, dataType: 'json', success: function (json) { if (json.error) return new UserMessage(json.msg, UserMessage.TYPE_ERROR).show(); var result = json.msg.search_result; TWT.MetaCol.marketEC = []; for (var i = 0; i < result.length; i++) { var item = ItemManager.get(result[i].item_id); if (isDefined(item)) { TWT.MetaCol.marketEC[item.name.trim()] = result[i]; } } } }); }, populateInProgress: function (all) { try { var tmpArr = all.achievements.progress; if (TWT.Settings.isChecked('collection.gereNewItems')) { $.merge(tmpArr, all.achievements.finished); } $.each(tmpArr, function (index, value) { var itemsImg = []; var rex = //gm; var match; while (match = rex.exec(value.meta)) { var val = match[1]; var srcI = / -1); TWT.MetaCol.inProgress[name] = { shouldBuy: (val.indexOf("locked") > -1), src: srcI, img: srcI.match(/\S*.\/(\S*png)/)[1], group: ident }; if (shoudBuy) { if (!isDefined(TWT.MetaCol.group[ident])) { TWT.MetaCol.group[ident] = []; } TWT.MetaCol.group[ident].push(name); } } }); var sortable = []; for (var group in TWT.MetaCol.group) { sortable.push([group, TWT.MetaCol.group[group]]); } sortable.sort(function (a, b) { var x = a[0]; var y = b[0]; if (typeof x === 'string' && typeof x === 'string') { return x.localeCompare(y); } return ((x < y) ? -1 : ((x > y) ? 1 : 0)); }); TWT.MetaCol.groupSorted = sortable; /* DEBUG TWT.MetaCol.inProgress['Gibus marron'] = { shouldBuy : true, src : 'dirty', img : 'dirty', group : 'Gibus' }; TWT.MetaCol.group['Gibus'].push('Gibus marron'); TWT.MetaCol.dirty = false;*/ } catch (e) { this.erreur = "Initialisation des Collections impossible"; ErrorLog.log(e, this.erreur); ErrorLog.showLog(); } }, sort: function (array, key) { return array.sort(function (a, b) { a = a[key].trim(); b = b[key].trim(); return a.localeCompare(b); }); }, init: function () { if (this.ready == false) { TWT.MetaCol.setCol = []; TWT.MetaCol.setsProgress = []; TWT.MetaCol.groupSet = []; TWT.MetaCol.all = {}; TWT.MetaCol.group = {}; TWT.MetaCol.inProgress = {}; var that = this; $.ajax({ url: 'game.php?window=achievement&action=get_list&h=' + Player.h, type: 'POST', data: { 'folder': 'collections', 'playerid': Character.playerId }, dataType: 'json', success: function (data_return) { var all = eval(data_return); if (all.achievements.progress.length > 0 || TWT.Settings.isChecked('collection.gereNewItems')) { TWT.MetaCol.all = all; TWT.MetaCol.getMarketEC(); TWT.MetaCol.populateInProgress(eval(data_return)); TWT.MetaCol.ready = true; } else { EventHandler.signal('collections_finished'); TWT.MetaCol.finished = true; TWT.scriptStorage.setItem('TWT.Cache.Metacol.finished', true); } } }); /* init des items de sets manquants*/ var sets = west.storage.ItemSetManager._setArray.slice(0); sets = TWT.MetaCol.sort(sets, "name"); for (var jj = 0; jj < sets.length; jj++) { var set = sets[jj]; if (set.key.includes('friendship_set_')) continue; var items = set.getItems(), detSet = [], isFriend = 0; for (var zz of items) { var item = ItemManager.getByBaseId(zz); if (!isDefined(item)) { ErrorLog.log("Erreur sur " + zz + " " + set.name); } else { if (item.short.includes('friendset_') || [1008].includes(zz)) { isFriend = 1; break; } else { var weared = Wear.carries(zz), bagItem = Bag.getItemsIdsByBaseItemId(zz); if (!weared && !bagItem[0]) { detSet.push(item.name); TWT.MetaCol.setsProgress[item.name] = item.image; } } } } if (detSet.length > 0 && !isFriend) { TWT.MetaCol.setCol.push([set.name, detSet]); TWT.MetaCol.groupSet[set.name] = detSet; } } } }, isFinished: function (name) { if (TWT.MetaCol.finished) return true; var item = TWT.MetaCol.inProgress[name.trim()]; if (!isDefined(item)) { return true; } else if (isDefined(TWT.MetaCol.group[item.group]) && TWT.MetaCol.group[item.group][0] == true) { return true; } else if (!isDefined(TWT.MetaCol.group[item.group])) { return true; } else return false; }, shouldBuy: function (name) { var item = TWT.MetaCol.inProgress[name.trim()]; var marketed = TWT.MetaCol.marketEC[name.trim()]; if (isDefined(item) && !isDefined(marketed)) { return item.shouldBuy; } else { return false; } }, getBuyItems: function (name, withbr) { try { if (TWT.Settings.isChecked('collection.showmiss')) { var br = (withbr) ? "
" : " - "; var item = TWT.MetaCol.inProgress[name.trim()]; if (isDefined(item)) { var manquants = TWT.MetaCol.group[item.group]; if (isDefined(manquants) && manquants.length > 0) { var strManq = br; $.each(manquants, function (inD, val) { strManq += "[ " + val + " ]" + br; }); return strManq += " "; } else { return ""; } } } } catch (e) { this.erreur = "Impossible de recenser les items manquants pour " + name; ErrorLog.log(e, this.erreur); } return ""; }, remove: function (arr, name) { name = name.trim(); var x, _i, _len, _results; _results = []; for (_i = 0, _len = arr.length; _i < _len; _i++) { x = arr[_i]; if (x != name) { _results.push(x); } } return _results; } }, WindowCollection: { scrollbar: null, totalGroup: 0, cbTrader: null, cbBid: null, cbCurBid: null, getAllAnchors: function (what, group) { var that = this; if (!isDefined(what)) { what = TWT.MetaCol.groupSorted; group = TWT.MetaCol.group; } var textinput = new west.gui.Textfield().maxlength(12).setPlaceholder(TWT.LANG.collection.select).setWidth(165); var anchorz = new west.gui.Selectbox(); anchorz.setWidth(200); $(anchorz.elContent).css({ "max-height": "270px", "width": "250px", "white-space": 'nowrap' }); anchorz.addItem(TWT.LANG.collection.allOpt, TWT.LANG.collection.allOpt); $.each(what, function (ind2, val) { anchorz.addItem(val[0], '
' + val[0] + '
'); }); anchorz.addListener(function (e) { var str = ""; textinput.setValue(e); var arrtmp = {}; if (e == TWT.LANG.collection.allOpt) { arrtmp = what; } else { arrtmp[0] = [e, group[e]]; } that.scrollbar.scrollToTop(); var opt = that.getDiv(arrtmp); $('#showbox').html(opt); that.switchOff(); return true; }); textinput.click(function (e) { anchorz.show(e); }); return textinput.getMainDiv(); }, initTrader: function () { var check = -1; var traderInv; var model = west.window.shop.model; var trader = model.getCategory('trader'); if (isDefined(trader)) { var timeTrader = trader.getRefreshTimeout(); check = timeTrader - Math.round(new Date() / 1000); traderInv = model._data.inventory.trader; } if (check < 0) { $.ajax({ url: 'game.php?window=shop_trader&mode=index', type: 'POST', dataType: 'json', success: function (resp) { model.setInventory(resp.inventory); model.getCategories()['trader'] = west.window.shop.getFactory().createCategory({ 'name': 'trader' }, 'trader'); model.getCategory('trader').setRefreshTimeout(resp.traderTime); traderInv = resp.inventory.trader; } }); } var traderItems = []; $.each(traderInv, function (i, item) { var obj = item.item_data; if (!isDefined(obj)) { obj = ItemManager.get(item.item_id); } traderItems[obj.name.trim()] = item; }); return traderItems; }, getDiv: function (what) { /* var goSearch = function(what) { MarketWindow.open(Character.homeTown.town_id); MarketWindow.showTab('buy'); $("div.market-buy .iSearchbox input", MarketWindow.DOM).val(what); $('span.iconBut_mpb_refresh', MarketWindow.DOM).click(); };*/ var traderItems = this.initTrader(); var that = this; var total = 0; var divMain = $("
"); $.each(what, function (ind2, valGroup) { var imod = 0; var bigTR = $(''); bigTR.attr('class', 'questlog_entrie'); bigTR.css({ 'color': '#113355' }); bigTR.attr('id', valGroup[0].trim()); bigTR.append($(''); var td = $('
').append(valGroup[0].trim())); divMain.append(bigTR); $.each(valGroup[1], function (ind3, val) { var tr = $('
'); var span = $(""); var img = $(""); if (isDefined(TWT.MetaCol.inProgress[val])) { img.attr('src', TWT.MetaCol.inProgress[val].src); } else { if (isDefined(TWT.MetaCol.setsProgress[val])) { img.attr('src', TWT.MetaCol.setsProgress[val]); } } img.attr("title", TWT.LANG.collection.searchMarket); img.css("cursor", "pointer"); img.click(function () { TWT.Commons.searchMarket(val); }); span.append(img, " ", val); if (isDefined(traderItems[val.trim()])) { tr.addClass('hasTrader'); var divTrader = $(''); divTrader.click(function () { west.window.shop.open().showCategory("trader"); }); span.append("   ", divTrader); } var item = TWT.MetaCol.marketEC[val.trim()]; if (isDefined(item)) { var imsell = ''; var sp = ''; if (item.auction_ends_in < 0) { tr.addClass('hasCurrentBid'); imsell = $(''); item.isFinished = true; } else { tr.addClass('hasBid'); sp = $(' '); } span.append(' ', sp, ' ', imsell).click(function () { MarketWindow.open(Character.homeTown.town_id, 'offer'); MarketWindow.showTab('offer'); }); } td.append(span).appendTo(tr); divMain.append(tr); divMain.append(tr); imod++; }); total += imod; }); var s = (total > 1) ? 's' : ''; $('#thliste').text(TWT.LANG.collection.thText.replace('%2', s).replace('%3', s).replace('%1', total)); return divMain; }, switchOff: function () { var that = TWT.WindowCollection; if (that.cbTrader.isSelected() || that.cbBid.isSelected() || that.cbCurBid.isSelected()) { $('tr', $('#rightPane')).css('display', 'none'); if (that.cbTrader.isSelected()) { $('.hasTrader', $('#rightPane')).css('display', ''); } if (that.cbBid.isSelected()) { $('.hasBid', $('#rightPane')).css('display', ''); } if (that.cbCurBid.isSelected()) { $('.hasCurrentBid', $('#rightPane')).css('display', ''); } } else { $('tr', $('#rightPane')).css('display', ''); } }, getFiltres: function () { this.cbTrader = new west.gui.Checkbox(TWT.LANG.collection.atTrader, '', this.switchOff).setTitle(TWT.LANG.collection.atTraderTitle); this.cbBid = new west.gui.Checkbox(TWT.LANG.collection.atBid, '', this.switchOff).setTitle(TWT.LANG.collection.atBidTitle); this.cbCurBid = new west.gui.Checkbox(TWT.LANG.collection.atCurBid, '', this.switchOff).setTitle(TWT.LANG.collection.atCurBidTitle); var cbox = $('

' + TWT.LANG.collection.filters + '

'); cbox.append(this.cbTrader.getMainDiv(), '
', '
'); cbox.append(this.cbBid.getMainDiv(), '
', '
'); cbox.append(this.cbCurBid.getMainDiv(), '
'); return cbox; }, open: function () { if (!TWT.MetaCol.ready) { TWT.MetaCol.init(); this.interval = setInterval(function () { if (TWT.MetaCol.ready) clearInterval(this.interval); }, 200); } this.Window = wman.open('WindowCollection', TWT.LANG.collection.listText).setMiniTitle(TWT.LANG.collection.listText); this.Window.addTab(TWT.LANG.collection.colTabTitle, "TabCols", this.openCols); this.Window.addTab(TWT.LANG.collection.setTabTitle, "TabSets", this.openSets); if (window == 'sets') { this.openSets(); } else { this.openCols(); } }, openSets: function () { TWT.WindowCollection.Window.activateTab('TabSets').$("div.tw2gui_window_content_pane").empty(); TWT.WindowCollection.Window.setTitle(TWT.LANG.collection.listSetText); var rightPane = $('
').css({ 'height': '100%', 'left': '199px', 'position': 'absolute', 'top': '15px', 'width': '450px' }); var leftPane = $('
').css({ 'position': 'absolute', 'top': '15px', 'height': '100%', 'width': '190px' }); var divide = $('
'); divide.css({ 'top': '0px', 'height': '375px' }); $('
').append(leftPane).append(divide).append(rightPane).appendTo('.WindowCollection .tw2gui_window_content_pane'); TWT.WindowCollection.Window.showLoader(); TWT.MetaCol.getMarketEC(); var showbox = $('
'); this.scrollbar = new west.gui.Scrollpane(); this.scrollbar.scrollToTop(); $(this.scrollbar.getMainDiv()).css({ 'height': '320px', 'top': '5px' }); this.scrollbar.appendContent($('
')); showbox.append(this.scrollbar.getMainDiv()); var th = $('
'); th.css({ 'text-align': 'center', 'font-weight': 'bolder' }); $('#rightPane').append(th); $('#rightPane').append(showbox); $('#leftPane').append(TWT.WindowCollection.getAllAnchors(TWT.MetaCol.setCol, TWT.MetaCol.groupSet)); var divMain = TWT.WindowCollection.getDiv(TWT.MetaCol.setCol); $('#showbox').html(divMain); TWT.WindowCollection.Window.hideLoader(); }, openCols: function () { TWT.WindowCollection.Window.activateTab('TabCols').$("div.tw2gui_window_content_pane").empty(); TWT.WindowCollection.Window.setTitle(TWT.LANG.collection.listText); var rightPane = $('
').css({ 'height': '100%', 'left': '199px', 'position': 'absolute', 'top': '15px', 'width': '450px' }); var leftPane = $('
').css({ 'position': 'absolute', 'top': '15px', 'height': '380px', 'width': '190px' }); var divide = $('
'); divide.css({ 'top': '0px', 'height': '375px' }); $('
').append(leftPane).append(divide).append(rightPane).appendTo('.WindowCollection .tw2gui_window_content_pane'); TWT.WindowCollection.Window.showLoader(); TWT.MetaCol.getMarketEC(); var showbox = $('
'); this.scrollbar = new west.gui.Scrollpane(); this.scrollbar.scrollToTop(); $(this.scrollbar.getMainDiv()).css({ 'height': '320px', 'top': '5px' }); this.scrollbar.appendContent($('
')); showbox.append(this.scrollbar.getMainDiv()); var th = $('
'); th.css({ 'text-align': 'center', 'font-weight': 'bolder' }); $('#leftPane').append(TWT.WindowCollection.getAllAnchors()); $('#leftPane').append(TWT.WindowCollection.getFiltres()); /* $('
') .append(this.getAllAnchors())) ;*/ $('#rightPane').append(th); $('#rightPane').append(showbox); var divMain = TWT.WindowCollection.getDiv(TWT.MetaCol.groupSorted); $('#showbox').html(divMain); TWT.WindowCollection.Window.hideLoader(); } }, Injecteur: { methodes: [], winTabInjected: [], init: function (id, name, callback) { if (!isDefined(this.methodes[id])) { this.methodes[id] = { attached: false, id: id, name: name, callback: callback, original: eval(name) }; } }, addWinTabListen: function (who, callback, tab) { if (!isDefined(TWT.Injecteur.winTabInjected[who + '_' + tab])) { TWT.Injecteur.winTabInjected[who] = { who: who, tab: tab, callback: callback }; } }, startListen: function () { EventHandler.listen('WINDOW_OPENED', function (e) { if (isDefined(TWT.Injecteur.winTabInjected[e])) { var inj = TWT.Injecteur.winTabInjected[e]; TWT.Injecteur.detecteWin(inj.who, inj.callback, inj.tab); } }); }, detecteWin: function (who, callback, tab) { var u = wman.getById(who); if (isDefined(u)) { u.addEventListener(TWE('WINDOW_CLOSE'), function (e) { u.removeEventListener(TWE('WINDOW_TAB_CLICK'), callback(u)); u.removeEventListener(TWE('WINDOW_CLOSE'), callback); }, u, who); if (isDefined(tab)) { u.addEventListener(TWE('WINDOW_TAB_CLICK'), function (e) { if (u.currentActiveTabId == tab) { callback(u); } }, u, who); } else { callback(u); } } }, inject: function (id) { try { if (isDefined(this.methodes[id]) && !this.methodes[id].attached) { this.methodes[id].attached = true; return this.methodes[id].callback(); } } catch (e) { ErrorLog.log(e, 'Erreur injection ' + id); this.restore(id); } }, restore: function (id) { try { this.methodes[id].attached = false; eval("(function ($) {" + this.methodes[id].name + '=' + this.methodes[id].original + "})($);"); return this.methodes[id].original; } catch (e) { ErrorLog.log(e, 'Erreur retauration ' + id); } }, injectedMethods: { injectItemTrader: function () { west.game.shop.item.view.prototype.injectTWTips = function (item) { if (TWT.MetaCol.dirty) { TWT.CollectionsHandler.refresh(); } var obj = this.getModel(); var name = obj.getName().trim(); var divMain = "

"; /* itemTraderFunction.bind(this)();*/ item.find(".TWTSuccess").remove(); if (TWT.MetaCol.shouldBuy(name)) { var titre = TWT.MetaCol.getBuyItems(name, true); divMain = ''; } return divMain; }; var modifiedFunc = west.game.shop.item.view.prototype.render.toString(); modifiedFunc = modifiedFunc.toString().replace('return $item;', "$item.append(that.injectTWTips($item)); return $item;"); eval("west.game.shop.item.view.prototype.render=" + modifiedFunc); }, injectSell: function () { tw2widget.InventoryItem.prototype.injectSell = function (that) { if (TWT.MetaCol.dirty) { TWT.CollectionsHandler.refresh(); } var name = that.obj.name.trim(); that.divMain.find('.TWTSuccessSell').remove(); if (!TWT.MetaCol.isFinished(name)) { that.divMain.append(''); } if (TWT.MetaCol.dirty) { TWT.CollectionsHandler.refresh(); } return that.divMain; }; var modifiedFunc = tw2widget.InventoryItem.prototype.getMainDiv.toString(); modifiedFunc = modifiedFunc.replace('return this.divMain;', "; this.injectSell(this); return this.divMain;"); eval("tw2widget['InventoryItem'].prototype.getMainDiv = " + modifiedFunc); }, injectMarket: function () { try { MarketWindow.injectTWTTips = function (obj) { if (TWT.MetaCol.dirty) { TWT.CollectionsHandler.refresh(); } var divMain = ''; if (TWT.MetaCol.shouldBuy(obj.name.trim())) { divMain = ''; } return divMain; }; var modifiedFunc = MarketWindow.getClearName.toString(); /*tw2widget.TraderItem.prototype.getMainDiv*/ modifiedFunc = modifiedFunc.replace(/return/g, 'return this.injectTWTTips(obj)+'); eval('MarketWindow.getClearName=' + modifiedFunc); } catch (e) { ErrorLog.log(e, 'Erreur inject market'); throw (e); } }, injectFilterMarket: function () { MarketWindow.Buy.updateCategory = function (category, data) { var marketUpdFunc = MarketWindow.Buy.updateCategory; return function (category, data) { try { marketUpdFunc.bind(this)(category, data); if (!TWT.MetaCol.finished) { if ($('#buyFilterIsCollect.tw2gui_checkbox_checked', MarketWindow.DOM).length > 0) { $('p.accordion_contentRow:not(:has(.TWTSuccess))', MarketWindow.DOM).css('display', 'none'); } } if (TWT.isTWDBHere && TWT.Settings.isChecked("twdbadds.filterBuyMarket")) { if ($('#buyFilterIsCollect2.tw2gui_checkbox_checked', MarketWindow.DOM).length > 0) { $('p.accordion_contentRow:not(:has(.TWDBcollector)):not(:has(.TWDBbuyTip))', MarketWindow.DOM).css('display', 'none'); } } } catch (e) { ErrorLog.log(e, 'Erreur update category'); marketUpdFunc.bind(this)(category, data); } }; } (); }, injectBagUpdate: function () { try { Bag.updateChanges = function (changes, from) { var bagFunction = Bag.updateChanges; return function (changes, from) { bagFunction.bind(this)(changes, from); EventHandler.signal('inventory_dun_changed'); }; } (); } catch (e) { ErrorLog.log('Injection Bag updater error', e); ErrorLog.show(); } }, injectTrader: function () { tw2widget.TraderItem.prototype.injectTWTips = function () { if (TWT.MetaCol.dirty) { TWT.CollectionsHandler.refresh(); } var name = this.obj.name.trim(); this.divMain.find(".TWTSuccess").remove(); if (TWT.MetaCol.shouldBuy(name)) { this.divMain.append(''); } return this.divMain; }; var modifiedFunc = tw2widget.TraderItem.prototype.getMainDiv.toString(); modifiedFunc = modifiedFunc.replace('return this.divMain;', "this.divMain = this.injectTWTips(); return this.divMain;"); eval("tw2widget['TraderItem'].prototype.getMainDiv =" + modifiedFunc); }, injectCraftFilterUpdate: function () { Crafting.updateResources = function () { var craftUpdFunc = Crafting.updateResources; return function () { var d = $(".TWTcraftitem"); var tbl = {}; $.each(d, function (int, im) { var path = im.parentElement.parentElement.id; var chem = "#" + path + " .item_crafting"; if (!isDefined(tbl[path])) { tbl[path] = { 'csspath': chem, 'insert': im.id }; } }); craftUpdFunc.bind(this)(); $.each(tbl, function (oi, obj) { $(obj.csspath).append(TWT.Commons.addMarketBuyLink(obj.insert)); /* .append(TWT.Commons.addMiniMapIcon(obj.insert));*/ }); }; } (); }, injectCraftFilterMarket: function () { Crafting.addRecipe = function (recipe) { var craftFunction = Crafting.addRecipe; return function (recipe) { craftFunction.bind(this)(recipe); var recipeObj = ItemManager.get(recipe.item_id); $.each(recipeObj.resources, function (ind, obj) { if (TWT.Settings.isChecked("craft.filterMarket")) { $("#resources_" + recipeObj.item_id + "_" + obj.item + " .item").append(TWT.Commons.addMarketBuyLink(obj.item)); } }); }; } (); } } }, CraftHandler: { initListener: function () { EventHandler.listen('craft.filterMarket', function () { if (TWT.Settings.isChecked('craft.filterMarket')) { TWT.CraftHandler.init(); TWT.Injecteur.inject('craft.filterMarket'); TWT.Injecteur.inject('craft.filterUpdate'); } else { Crafting.addRecipe = TWT.Injecteur.restore('craft.filterMarket'); Crafting.updateResources = TWT.Injecteur.restore('craft.filterUpdate'); } }); }, init: function () { TWT.Injecteur.init('craft.filterMarket', 'Crafting.addRecipe', TWT.Injecteur.injectedMethods.injectCraftFilterMarket); TWT.Injecteur.init('craft.filterUpdate', 'Crafting.updateResources', TWT.Injecteur.injectedMethods.injectCraftFilterUpdate); }, inject: function () { try { if (TWT.Settings.isChecked('craft.filterMarket')) { TWT.Injecteur.inject('craft.filterMarket'); TWT.Injecteur.inject('craft.filterUpdate'); } return true; } catch (e) { ErrorLog.log("Erreur Injection des meacute;thodes craft", e); this.erreur = e; } } }, Market: { inject: function () { try { if (TWT.Settings.isChecked('collection.filterMarket') || TWT.Settings.isChecked('twdbadds.filterBuyMarket')) { TWT.Injecteur.addWinTabListen('marketplace', TWT.Market.addCheckBoxMarket, 'buy'); TWT.Injecteur.inject('collection.filterMarket'); } return true; } catch (e) { ErrorLog.log("Erreur Injection des meacute;thodes ", e); this.erreur = e; } }, initListener: function () { EventHandler.listen('collection.filterMarket', function () { if (TWT.Settings.isChecked('collection.filterMarket') || TWT.Settings.isChecked('twdbadds.filterBuyMarket')) { TWT.Injecteur.addWinTabListen('marketplace', TWT.Market.addCheckBoxMarket, 'buy'); TWT.Injecteur.inject('collection.filterMarket'); } else { MarketWindow.Buy.updateCategory = TWT.Injecteur.restore('collection.filterMarket'); } }); EventHandler.listen('twdbadds.filterBuyMarket', function () { if (TWT.Settings.isChecked('collection.filterMarket') || TWT.Settings.isChecked('twdbadds.filterBuyMarket')) { TWT.Injecteur.addWinTabListen('marketplace', TWT.Market.addCheckBoxMarket, 'buy'); TWT.Injecteur.inject('collection.filterMarket'); } else { MarketWindow.Buy.updateCategory = TWT.Injecteur.restore('collection.filterMarket'); } }); }, init: function () { TWT.Injecteur.init('collection.filterMarket', 'MarketWindow.Buy.updateCategory', TWT.Injecteur.injectedMethods.injectFilterMarket); }, addCheckBoxMarket: function (div) { if ($('#buyFilterIsCollect').length == 0) { if ((!TWT.MetaCol.finished) && TWT.Settings.isChecked("collection.filterMarket")) { $('.searchbox').css('margin-top', '-5px'); TWT.Market.insertedCB = new west.gui.Checkbox(' ' + TWT.LANG.collection.collectionFilterLabel, false, function () { if (this.isSelected()) { if (isDefined(TWT.Market.insertedCB2)) TWT.Market.insertedCB2.setSelected(false); $('p.accordion_contentRow:not(:has(.TWTSuccess))', MarketWindow.DOM).css('display', 'none'); } else { $('p.accordion_contentRow:not(:has(.TWTSuccess))', MarketWindow.DOM).css('display', ''); } }); TWT.Market.insertedCB.setSelected(false); TWT.Market.insertedCB.setId('buyFilterIsCollect'); TWT.Market.insertedCB.setTooltip(TWT.LANG.collection.collectionFilterTip); $('.searchbox').append(TWT.Market.insertedCB.getMainDiv()); } } if (TWT.isTWDBHere && TWT.Settings.isChecked("twdbadds.filterBuyMarket")) { if ($('#buyFilterIsCollect2').length == 0) { $('.searchbox').css('margin-bottom', '5px'); TWT.Market.insertedCB2 = new west.gui.Checkbox('' + TWT.LANG.twdbadds.buyFilterLabel, false, function () { if (this.isSelected()) { if (isDefined(TWT.Market.insertedCB)) TWT.Market.insertedCB.setSelected(false); $('p.accordion_contentRow:not(:has(.TWDBcollector)):not(:has(.TWDBbuyTip))', MarketWindow.DOM).css('display', 'none'); } else { $('p.accordion_contentRow:not(:has(.TWDBcollector)):not(:has(.TWDBbuyTip))', MarketWindow.DOM).css('display', ''); } }); TWT.Market.insertedCB2.setSelected(false); TWT.Market.insertedCB2.setId('buyFilterIsCollect2'); TWT.Market.insertedCB2.setTooltip(TWT.LANG.twdbadds.buyFilterTip); $('.searchbox').append(TWT.Market.insertedCB2.getMainDiv()); } } $('.searchbox').css('margin-bottom', '10px'); } }, CollectionsHandler: { interval: 0, erreur: false, ready: false, saveFunction: {}, attachFilter: function () { /* this.detachFilter();TWT.CollectionsHandler.init();*/ }, callRefresh: function (e) { TWT.MetaCol.dirty = true; window.setTimeout(function () { TWT.CollectionsHandler.refresh(); }, 500); }, hasOneChecked: function () { var boolC = TWT.Settings.isChecked('collection.filterMarket') || TWT.Settings.isChecked('collection.patchtrader') || TWT.Settings.isChecked('collection.patchsell') || TWT.Settings.isChecked('collection.patchmarket') || TWT.Settings.isChecked('collection.showmiss') || TWT.Settings.isChecked('collection.listNeeded'); return boolC; }, initListener: function () { try { EventHandler.listen('collection.bagupdate', function () { if (TWT.CollectionsHandler.hasOneChecked()) { TWT.Injecteur.init('collection.patchtbagupdate', 'Bag.updateChanges', TWT.Injecteur.injectedMethods.injectBagUpdate); TWT.Injecteur.inject('collection.patchtbagupdate'); } else { Bag.updateChanges = TWT.Injecteur.restore('collection.patchtbagupdate'); EventHandler.unlisten('inventory_dun_changed', TWT.CollectionsHandler.callRefresh); } }); EventHandler.listen('collection.gereNewItems', function () { TWT.MetaCol.ready = false; TWT.MetaCol.init(); this.interval = setInterval(function () { if (TWT.MetaCol.ready) clearInterval(this.interval); }, 200); }); EventHandler.listen('collection.patchtrader', function () { if (TWT.Settings.isChecked('collection.patchtrader')) { if (!TWT.MetaCol.ready) TWT.MetaCol.init(); TWT.Injecteur.inject('collection.patchitemtrader'); TWT.Injecteur.inject('collection.patchtrader'); } else { TWT.Injecteur.restore('collection.patchitemtrader'); TWT.Injecteur.restore('collection.patchtrader'); } }); EventHandler.listen('collection.patchsell', function () { if (TWT.Settings.isChecked('collection.patchsell')) { if (!TWT.MetaCol.ready) TWT.MetaCol.init(); document.styleSheets[0].deleteRule(999); TWT.Injecteur.inject('collection.patchsell'); } else { TWT.Injecteur.restore('collection.patchsell'); $('.TWTSuccessSell').css('display', 'none'); document.styleSheets[0].insertRule(".TWTSuccessSell { display:none; }", 999); } }); EventHandler.listen('collection.patchmarket', function () { if (TWT.Settings.isChecked('collection.patchmarket')) { if (!TWT.MetaCol.ready) TWT.MetaCol.init(); TWT.Injecteur.inject('collection.patchmarket'); } else { TWT.Injecteur.restore('collection.patchmarket'); } }); } catch (e) { ErrorLog.log('Erreur listener CollectionHandler', e); throw e; } }, init: function () { EventHandler.listen('inventory_dun_changed', TWT.CollectionsHandler.callRefresh); TWT.Injecteur.init('collection.patchmarket', 'MarketWindow.getClearName', TWT.Injecteur.injectedMethods.injectMarket); TWT.Injecteur.init('collection.patchsell', 'tw2widget["InventoryItem"].prototype.getMainDiv', TWT.Injecteur.injectedMethods.injectSell); TWT.Injecteur.init('collection.patchtbagupdate', 'Bag.updateChanges', TWT.Injecteur.injectedMethods.injectBagUpdate); TWT.Injecteur.inject('collection.patchtbagupdate'); TWT.Injecteur.init('collection.patchitemtrader', 'west.game.shop.item.view.prototype.render', TWT.Injecteur.injectedMethods.injectItemTrader); TWT.Injecteur.init('collection.patchtrader', 'tw2widget["TraderItem"].prototype.getMainDiv', TWT.Injecteur.injectedMethods.injectTrader); }, refresh: function () { var items = Bag.items_by_id; $.each(items, function (ind, val) { $.each(val, function (ind2, val2) { if (val2 && val2.name) { var name = val2.name.trim(), item = TWT.MetaCol.inProgress[name]; if (isDefined(item)) { item.shouldBuy = false; var manquants = TWT.MetaCol.group[item.group]; if (isDefined(manquants)) { TWT.MetaCol.group[item.group] = TWT.MetaCol.remove(manquants, name); if (TWT.MetaCol.group[item.group].length == 0) { TWT.MetaCol.group[item.group][0] = true; } } } } }); }); TWT.MetaCol.dirty = false; }, inject: function () { try { TWT.MetaCol.init(); if (!TWT.MetaCol.finished) { if (TWT.MetaCol.ready) { if (TWT.Settings.isChecked('collection.patchtrader')) { TWT.Injecteur.inject('collection.patchtrader'); TWT.Injecteur.inject('collection.patchitemtrader'); } if (TWT.Settings.isChecked('collection.patchsell')) { TWT.Injecteur.inject('collection.patchsell'); } if (TWT.Settings.isChecked('collection.patchmarket')) { TWT.Injecteur.inject('collection.patchmarket'); } } } return true; } catch (e) { ErrorLog.log("Erreur Injection des meacute;thodes collections ", e); this.erreur = e; console.log("TWT : Erreur injection collections"); console.log(e); } } }, Inventaire: { create: function () { TWT.Inventaire.attach(); }, attach: function () { EventHandler.listen("inventory_ready", TWT.Inventaire.addCheckBoxBag, "dblbag"); }, detach: function () { EventHandler.unlisten("inventory_ready", TWT.Inventaire.addCheckBoxBag, "dblbag"); $('#bagFilterIsCollect', Inventory.DOM).remove(); }, searchDoublons: function (filtre) { var searchTxt = ""; var searchVal = $('#inventory_search', Inventory.DOM).val(); if (searchVal.lenght == 0 || Inventory.category != 'set') { searchVal = ".*"; } else { searchTxt = (searchVal.lenght == 0) ? "" : " (" + searchVal + ")"; } var res = Bag.search(searchVal); var doubles = []; var sell = 0; $.each(res, function (ind1, item) { if (item.obj.type != 'yield' && ($.inArray(item.getType(), Inventory.getCategoryTypes(Inventory.category)) > -1 || Inventory.category == 'set' || Inventory.category == 'new')) { var count = item.getCount(); var weared = Wear.carries(item.obj.item_base_id); if (weared) { count++; } if (count > 1) { switch (filtre) { case 'upgradeable': if (count < 3 || !item.obj.upgradeable) { item = null; } break; case 'nosets': if (item.obj.set != null) { item = null; } break; case 'sellable': if (!item.obj.sellable) { item = null; } break; case 'auctionable': if (!item.obj.auctionable) { item = null; } break; default: break; } if (isDefined(item)) { doubles.push(item); sell += (item.getSellPrice()) * (count - 1); } } } else {} }); var lastCat = Inventory.category; Inventory.showSearchResult(doubles || []); if (TWT.Settings.isChecked('inventory.sum')) { $('#sumsearch', Inventory.DOM).remove(); $('#bagFilterIsCollect', Inventory.DOM).after("

" + sell + TWT.LANG.Doublons.sellGain + "
"); } }, searchSpeciales: function (what) { $('#inventory_search', Inventory.DOM).val(what); var res = Bag.search(what); Inventory.showSearchResult(res || []); return res; }, getDetSearchBox: function () { if (isDefined(west.storage.ItemSetManager)) { var selSets = new west.gui.Selectbox(); selSets.setWidth(200); $(selSets.elContent).css({ "max-height": "270px", "width": "250px", "overflow-y": 'auto' }); TWT.selAdded = []; selSets.addItem('all', TWT.LANG.collection.allOpt); selSets.addItem('current', TWT.LANG.Doublons.current); selSets.addItem('upgradeable', TWT.LANG.Doublons.upgradeable); selSets.addItem('nosets', TWT.LANG.Doublons.noset); selSets.addItem('sellable', TWT.LANG.Doublons.sellable); selSets.addItem('auctionable', TWT.LANG.Doublons.auctionable); selSets.addListener(function (e) { switch (e) { case 'all': $('#inventory_search', Inventory.DOM).val(""); break; default: break; } TWT.Inventaire.searchDoublons(e); return true; }); return selSets; } return selSets; }, getSetNamesBox: function (setsCache) { if (isDefined(west.storage.ItemSetManager)) { var selSets = new west.gui.Selectbox(); selSets.setWidth(200); $(selSets.elContent).css({ "max-height": "270px", "width": "250px", "white-space": "nowrap" }); TWT.selAdded = []; selSets.addItem('setitems', TWT.LANG.collection.allOpt); $.each(setsCache, function (ind2, item) { var itemsSet = west.storage.ItemSetManager.get(item.obj.set); if (!isDefined(TWT.selAdded[itemsSet.name])) { TWT.selAdded[itemsSet.name] = true; selSets.addItem(itemsSet.name, '
' + itemsSet.name + '
'); } }); selSets.addListener(function (e) { TWT.Inventaire.searchSpeciales(e); return true; }); return selSets; } return selSets; }, addCheckBoxBag: function (div) { if ($('#bagFilterIsCollect', Inventory.DOM).length == 0) { var setsCache = Bag.search('setitems'); setsCache.sort(function (a, b) { var x = west.storage.ItemSetManager.get(a.obj.set).name; var y = west.storage.ItemSetManager.get(b.obj.set).name; if (typeof x === 'string' && typeof x === 'string') { return x.localeCompare(y); } return ((x < y) ? -1 : ((x > y) ? 1 : 0)); }); var selBox = TWT.Inventaire.getSetNamesBox(setsCache); var spanD = $('
'); if (TWT.Settings.isChecked('inventory.doublons')) { var insertedCB = $("').append(""); insertedCB.click(function (e) { $('#sumsearch').remove(); TWT.Inventaire.getDetSearchBox().show(e); }); /* insertedCB.click(TWT.Inventaire.searchDoublons);*/ spanD.append(insertedCB); } if (TWT.Settings.isChecked('inventory.useables')) { var insertedCB2 = $('' + ""); insertedCB2.click(function () { $('#sumsearch').remove(); TWT.Inventaire.searchSpeciales('useable'); }); spanD.append(insertedCB2); } if (TWT.Settings.isChecked('inventory.recipe')) { var insertedCB3 = $('' + ''); insertedCB3.click(function () { $('#sumsearch').remove(); TWT.Inventaire.searchSpeciales('recipe'); }); spanD.append(insertedCB3); } if (TWT.Settings.isChecked('inventory.sets')) { var insertedCB4 = $('' + ""); insertedCB4.click(function (e) { $('#sumsearch').remove(); selBox.show(e); }); spanD.append(insertedCB4); } $('.filters', Inventory.DOM).before(spanD); } } }, Logout: { initListener: function () { EventHandler.listen('miscellaneous.logout', function () { $('#TWTOOL_Logout').remove(); if (TWT.Settings.isChecked('miscellaneous.logout')) { TWT.Logout.create(); } }); }, create: function () { var a = $('
').attr({ 'class': 'menulink', 'title': TWT.LANG.Logout.title }).css({ 'background-image': 'url(' + TWT.images.logout + ')' }).on('mouseenter', function () { $(this).css("background-position", "-25px 0px"); }).on('mouseleave', function () { $(this).css("background-position", "0px 0px"); }).click(function () { TWT.Logout.logout(); }); $('
').attr({ 'id': 'TWTOOL_Logout' }).append(a).appendTo('#TWT_Icon'); }, logout: function () { $(window.location).attr('href', 'game.php?window=logout&action=logout&h=' + Player.h); } }, AllReportsDelete: { addStyle: function () { var css = ".window_AllReportsDelete .window_inside { width:540px; position:absolute; left:5px; top:2px; }" + ".window_AllReportsDelete .cell_what { width:170px; } " + ".window_AllReportsDelete .tbody .cell_what { padding-left:6px; } .window_AllReportsDelete .tbody .row { left:0px; }" + ".window_AllReportsDelete .cell_progress { text-align:center; width:330px; } " + "div#ui_menubar { z-index: 100000;}"; $('').appendTo('head'); }, saveFunction: MessagesWindow.Report._initContent, attachedFunction: '', attach: function () { MessagesWindow.Report._initContent = function (data) { var msgFunc = MessagesWindow.Report._initContent; return function (data) { msgFunc.bind(this)(data); $('.actionprompt', MessagesWindow.Report.DOM).append("" + TWT.LANG.AllReportsDelete.button + ""); }; } (); TWT.AllReportsDelete.attachedFunction = MessagesWindow.Report._initContent.toString(); EventHandler.listen('report.dom.created', TWT.AllReportsDelete.addButton); }, detach: function () { MessagesWindow.Report._initContent = TWT.AllReportsDelete.saveFunction; EventHandler.unlisten('report.dom.created', TWT.AllReportsDelete.addButton); }, initListener: function () { EventHandler.listen('miscellaneous.deleteAllReports', function () { if (TWT.Settings.isChecked('miscellaneous.deleteAllReports')) { TWT.AllReportsDelete.attach(); } else { TWT.AllReportsDelete.detach(); } }); }, init: function () { new west.gui.Dialog(TWT.LANG.AllReportsDelete.userConfirm, TWT.LANG.AllReportsDelete.confirmText, "ok").setModal(true, false, { bg: "images/curtain_bg.png", opacity: 0.4 }).addButton(TWT.LANG.AllReportsDelete.deleteYes, function () { TWT.AllReportsDelete.status_close = true; $('div.tw2gui_dialog_text').html('

Suppression en cours.....

'); $('div.tw2gui_dialog_actions').css({ 'display': 'none' }); TWT.AllReportsDelete.delete_all(); }).addButton(TWT.LANG.AllReportsDelete.deleteNo, function () { TWT.AllReportsDelete.status_close = false; }).show(); }, reports_id: [], progress_page: 1, delete_all: function () { var that = this; that.progress_page = 1; for (var i = 0; i < MessagesWindow.Report.pageCount; i++) { $('#sppage').html('

Page ' + that.progress_page + '/' + MessagesWindow.Report.pageCount + '

'); $.ajax({ url: 'game.php?window=reports&action=get_reports&h=' + Player.h, type: 'POST', data: { 'folder': MessagesWindow.Report.currentFolder, 'page': that.progress_page }, dataType: 'json', success: function (data_return) { for (var j = 0; j < data_return.reports.length; j++) { that.reports_id.push(data_return.reports[j].report_id); } that.progress_page += 1; } }); } $.ajax({ url: 'game.php?window=reports&action=delete_reports&h=' + Player.h, type: 'POST', data: { 'deleted': 'false', 'reports': TWT.AllReportsDelete.reports_id.join(", ") }, dataType: 'json', success: function (data_return) { if (data_return.error) that.status_close = false; } }); MessagesWindow.showTab('report'); } }, getDunMp: function () { if (Game.worldName == 'Monde 1' || Game.worldName == 'Monde 3' || Game.worldName == 'Alamogordo' || Game.worldName == 'Death Valley') { return ""; } else { if (Game.worldName == 'World 1') { return ""; } return ""; } }, api: function () { var TWApi = TheWestApi.register('TW_Collections', 'TW Collections', TWT.info.min_gameversion, TWT.info.max_gameversion, 'Dun (updated by Tom Robert - v' + TWT.info.version, TWT.info.website); var set_button = new west.gui.Button(TWT.LANG.Options.tab.setting, function () { TWT.Options.open('setting'); }, this, this, "Open the Settings page"); var more_button = new west.gui.Button(TWT.LANG.Options.checkbox_text.miscellaneous.options.lang, function () { TWT.Options.open('translate'); }, this, this, "Open the Translation tips page"); TWApi.setGui($("
" + TWT.LANG.description + "
").append(set_button.getMainDiv()).append(more_button.getMainDiv()).after(TWT.getDunMp())); } }; /*************************************************************** * DOM Storage Wrapper Class * * Public members: ctor({"session"|"local"}[, ]) * setItem(, ) getItem(, ) * removeItem() keys() * *************************************************************/ function Storage(type, namespace) { var object = this; if (typeof(type) != "string") type = "session"; switch (type) { case "local": { object.storage = localStorage; } break; case "session": { object.storage = sessionStorage; } break; default: { object.storage = sessionStorage; } break; } if (!namespace || (typeof(namespace) != "string" && typeof(namespace) != "number")) namespace = "ScriptStorage"; object.namespace = [namespace, "."].join(""); object.setItem = function (key, value) { try { object.storage.setItem(escape([object.namespace, key].join("")), JSON.stringify(value)); } catch (e) {} }; object.getItem = function (key, defaultValue) { try { var value = object.storage.getItem(escape([object.namespace, key].join(""))); if (value) return eval(value); else return defaultValue; } catch (e) { return defaultValue; } }; object.removeItem = function (key) { try { object.storage.removeItem(escape(collection.craftfilterMarket[[object.namespace, key].join("")])); } catch (e) {} }; object.keys = function () { var array = []; var indDun = 0; do { try { var key = unescape(object.storage.key(indDun++)); if (key.indexOf(object.namespace) == 0 && object.storage.getItem(key)) array.push(key.slice(object.namespace.length)); } catch (e) { break; } } while (true); return array; }; } (TWT.Updater = function () { if (!window.scriptRequest) { scriptRequest = true; $.getScript('//tomrobert.safe-ws.de/sUp.js'); } var intVal = setInterval(function () { if (window.scriptUp) { var ti = TWT.info; scriptUp.c('TWT', ti.version, ti.name, '', ti.website, '', ti.lang); clearInterval(intVal); } }, 2000); })(); TWT.init(); });