Greasy Fork is available in English.

TW-Collections

TW-Collections - see history

  1. // ==UserScript==
  2. // @name TW-Collections
  3. // @namespace https://greatest.deepsurf.us/users/2196
  4. // @description TW-Collections - see history
  5. // @include https://*.the-west.*/game.php*
  6. // @exclude https://classic.the-west.net*
  7. // @author Dun (updated by Tom Robert)
  8. // @version 1.4.7
  9. // @homepage https://github.com/The-West-Scripts/The-West-Collections
  10. // @supportURL https://github.com/The-West-Scripts/The-West-Collections/issues
  11. // @history 1.4.6.9 bankfees removed, old updater removed, item sets selectbox improved, bugfixes, TW v2.241
  12. // @history 1.4.6.8 greasyfork fix
  13. // @history 1.4.6.5 bugfix, TW v2.97
  14. // @history 1.4.6.4 bugfixes by Tom Robert, TW v2.80
  15. // @history 1.4.6.3 rev. TW 2.29
  16. // @history 1.4.6.2 rev. TW 2.26
  17. // @history 1.4.6.1 rev. TW 2.24
  18. // @history 1.4.6 add Ro translation
  19. // @history 1.4.5 correcting a bug on current market bid
  20. // @history 1.4.4 Correct bugs & update 2.23 & add upgradeables search in inventory
  21. // @history 1.4.3 Correct refresh bug
  22. // @history 1.4.2 update for TW 2.21
  23. // @history 1.4.1 correct bugs and add include for beta
  24. // @history 1.4.0.2 remove personnal frienset from sets list
  25. // @history 1.4.0 add Set Window and crafting items icons
  26. // @history 1.3.9 correct for es translation
  27. // @history 1.3.8 miscelaneous changes - update link to pastebin (thanks to Tom Robert )
  28. // @history 1.3.7 correct bug for double item wearing - reactivate update
  29. // @history 1.3.6 correct translations links
  30. // @history 1.3.5 correct bugs save & trader icons
  31. // @history 1.3.4 correct bugs save settings
  32. // @history 1.3.3.9 correct bugs for 2.1, deactivate update since userscript is dead
  33. // @history 1.3.3.8 update TW version 2.1
  34. // @history 1.3.3.7 maj for 2.09
  35. // @history 1.3.3.6 correcting tips in mobile trader
  36. // @history 1.3.3.5 add vertical scrollbar in set & collection selectboxs
  37. // @history 1.3.3.4 maj 2.08 & optimisation chargement items de collections
  38. // @history 1.3.3.3 Fix ended bids
  39. // @history 1.3.3.2 correct End bids on collector list, add setting for deactivate menu mouse hover
  40. // @history 1.3.3 Mod. listcolector: recherche dans le marché add direct link to market / mobile trader, add filters
  41. // @history 1.3.2.1 Fix inventory bug
  42. // @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
  43. // @history 1.3.1.3 fix for the shop display
  44. // @history 1.3.1.2 corrections
  45. // @history 1.3.1.1 corrections
  46. // @history 1.3.1 correction pour le nouveau marchand ambulant + patch TWDB new
  47. // @history 1.3.0 correction trad en + ajout lien forum
  48. // @history 1.2.9 correction trad en et logout sans confirmation + ajout trad Slovak
  49. // @history 1.2.7 correction trad en et logout sans confirmation
  50. // @history 1.2.7 ajout filtres inventaires, correction
  51. // @history 1.2.7 modification du systeme de langue et de l'updater, simplification suppression rapport, etc...
  52. // @history 1.2.6.1 correction affichage TW api
  53. // @history 1.2.6 correction lang et changement de nom
  54. // @history 1.2.5 corrections ... or not :)
  55. // @history 1.2.4 Création d'une barre d'outils dans l'inventaire (recettes, sets, consommables,doublons)
  56. // @history 1.2.3 ajout d'un bouton doublon dans l'inventaire et correction bug lang
  57. // @history 1.2.2 passage 2.0.6
  58. // @history 1.2.1 passage 2.0.5
  59. // @history 1.2.0 correction bugs maj + Traduction italienne (grazie tw81)
  60. // @history 1.1.9 correction attente TWDB....
  61. // @nocompat Chrome
  62. // @grant none
  63. // ==/UserScript==
  64. (function (e) {
  65. var t = document.createElement("script");
  66. t.type = "application/javascript";
  67. t.textContent = "(" + e + ")();";
  68. document.body.appendChild(t);
  69. t.parentNode.removeChild(t);
  70. })
  71. (function () {
  72. TWT = {
  73. DEBUG: false,
  74. LANG: {},
  75. info: {
  76. name: 'TW-Collections',
  77. lang: 'en',
  78. version: '1.4.7',
  79. min_gameversion: '2.0',
  80. max_gameversion: Game.version.toString(),
  81. idscript: '1670',
  82. website: 'https://the-west-scripts.github.io/The-West-Collections',
  83. },
  84. languages: [{
  85. short_name: 'fr',
  86. name: 'Francais',
  87. translator: 'Dun',
  88. version: '1.4.0'
  89. }, {
  90. short_name: 'en',
  91. name: 'English',
  92. translator: 'Dun',
  93. version: '1.4.0'
  94. }
  95. ],
  96. images: {
  97. cup: "images/icons/achv_points.png",
  98. logout: "data:image/jpg;base64,/9j/4AAQSkZJRgABAgIAJQAlAAD/wAARCAAZADIDAREAAhEBAxEB/9sAhAAGBAUGBQQGBgUGBwcGCAoRCwoJCQoVDxAMERkWGhoYFhgXGx8oIRsdJR4XGCIvIyUpKiwtLBshMTQwKzQoKywrAQcHBwoJChQLCxQrHBgcHCsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKyv/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APDNaa5l1G4Zp5YYoZHiTy3ZSQrHBIz1rhg4pWR2NSb1Poqb4f8Ag7Zf507UG+xwCTd/a0+HJVGwBu45f36Vz+1adl+S/wAjpVFb6/ezhPjB4P0Xw9pWmX2gwTpetOGPnXLzjaN/ykMSC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9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgr/wAARCAAUABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAgGBAf/xAAoEAACAQMEAgEDBQAAAAAAAAABAgMEBQYABxESEyIhCBRBMTIzQkP/xAAXAQEBAQEAAAAAAAAAAAAAAAAFAwQH/8QAJREBAAIBAwQBBQEAAAAAAAAAAQIRAwAEURITITFhIjJBkaGx/9oADAMBAAIRAxEAPwCzsr3ZqcwrZ446eojpYzykVNTuY2JcIZZCrKSo/cQG9V9jyCNZbNZd1dvJhd7NFEQ0qSwLJP4lVPcPCrop5Kle3aRf7AN0AZxg9uMvXHN0qy03ZJqWakeOZZJPGfNG0aq0kRZgU6NCyOAOP4jyew45MUxHJtsIb/kWZbwPlEF9t1PLRQxUJhWCKPvKKmY9zxKxk95OVAABJYk64jk3O7nMg3RJtFOktDgugWxG3jzty5p9yeVmEgOmKfcvsvzVfCJ/lGbOfUfie5O3tBmFROszVSc+V06s3Hx7KRyrA8gr+CCNNTz9PuN33IcBlym3xVTU94vVdcKX7qDxyeGadpI2dQB1ZkZXK8AgvwfkHTT+HsyxRcmSpUWeqdIY9/vSAGDqOb9/PrXoO82DYxJFBf5rYGqFk7xOsjRtFIVA7o6FXRuPUlWHK/B5HxrB2/aDF83ySltuZVtzutGKtpoqGuuLyQRuSf8AM+sgHYhVkDhQfUDTTRnZwu5hLpLTjhK1XeqbiUT19P8ATz+/zzqobJYLVZLelut1KEiT9Ofkk/kk/knTTTV4gxF0urFo8Gv/2Q=="
  101. },
  102. menu_callback: {
  103. goHome: "TaskQueue.add(new TaskWalk(Character.homeTown.town_id,'town'))",
  104. goToDaily1: 'GameMap.center(1920, 2176);',
  105. goToDaily2: 'GameMap.center(28288,16768);',
  106. ownSaloon: 'SaloonWindow.open(Character.homeTown.town_id);',
  107. openMarket: 'MarketWindow.open(Character.homeTown.town_id);',
  108. mobileTrader: "west.window.shop.open().showCategory('trader');",
  109. forum: "ForumWindow.open();",
  110. listNeeded: 'TWT.WindowCollection.open();',
  111. openOptions: "TWT.Options.open('setting')"
  112. },
  113. css: {
  114. style: "position:relative;top:0px;left:0px;width:12px;height:12px;padding:0px;border:0px;margin:0px;",
  115. styleT: "position:absolute;top:4px;left:3px;width:15px;height:15px;padding:0px;border:0px;margin:0px;",
  116. styleN: "position:absolute;top:120px;left:25px;padding:0px;border:0px;margin:0px;",
  117. styleDB: "position:absolute;top:0px;left:0px;padding:0px;border:0px;margin:0px;"
  118. },
  119. langPatchs: {
  120. cs: {
  121. link: "7260",
  122. texte: "Czech - čeština",
  123. author: "Dr.Keeper"
  124. },
  125. es: {
  126. link: "7313",
  127. texte: "Spanish - Español",
  128. author: "pepe100"
  129. },
  130. de: {
  131. link: "1672",
  132. texte: "German - Deutsch",
  133. author: "Hanya & Tom Robert"
  134. },
  135. it: {
  136. link: "1675",
  137. texte: "Italian - Italiano",
  138. author: "tw81"
  139. },
  140. hu: {
  141. link: "7261",
  142. texte: "Hungarian - Magyar",
  143. author: "Zoltan80"
  144. },
  145. sl: {
  146. link: "7259",
  147. texte: "Slovak - Slovenčina",
  148. author: "Surge"
  149. },
  150. pl: {
  151. link: "1674",
  152. texte: "Polish - Polski",
  153. author: "Dun from Darius II mod"
  154. },
  155. pt: {
  156. link: "7312",
  157. texte: "Portuguese - Português",
  158. author: "VSaantiago"
  159. },
  160. ru: {
  161. link: "7271",
  162. texte: "Russian - Pу́сский",
  163. author: "Anch665"
  164. },
  165. ro: {
  166. link: "9037",
  167. texte: "Romanian - Română",
  168. author: "Peta"
  169. }
  170. },
  171. langs: {
  172. fr: {
  173. description: "<center><br><b>TW Collections</b><br>Astuces et signalement des items manquants des collections<br>Liste des items manquants des collections<br>Divers raccourcis et fonctions<br> Suppressions des rapports<br>Doublons dans l'inventaire<br>etc...</center>",
  174. Options: {
  175. tab: {
  176. setting: 'Réglages'
  177. },
  178. checkbox_text: {
  179. box: {
  180. title: 'Raccourcis menus',
  181. options: {
  182. goHome: 'Aller &agrave; sa ville',
  183. goToDaily1: 'Aller &agrave; la ville abandonn&eacute;e',
  184. goToDaily2: 'Aller au village de Waupee',
  185. ownSaloon: 'Ouvrir votre saloon',
  186. openMarket: 'Ouvrir le march&eacute;',
  187. mobileTrader: 'Ouvrir le marchand ambulant',
  188. forum: 'Ouvrir le forum',
  189. listNeeded: 'Items manquants des collections'
  190. }
  191. },
  192. collection: {
  193. title: 'Collections',
  194. options: {
  195. gereNewItems: 'Gérer les nouveaux items des succés déjà obtenus',
  196. patchsell: 'Signalement des items manquants aux collections dans l\'inventaire',
  197. patchtrader: 'Signalement des items n&eacute;cessaires aux collections chez les marchands',
  198. patchmarket: 'Signalement des items n&eacute;cessaires aux collections dans le march&eacute;',
  199. filterMarket: 'Filtre dans le march&eacute; pour n\'afficher que les items manquants des collections',
  200. showmiss: 'Items manquants des collections sur survol'
  201. }
  202. },
  203. inventory: {
  204. title: 'Boutons supplémentaires dans l\'inventaire',
  205. options: {
  206. doublons: 'Bouton de recherche des doublons',
  207. useables: 'Bouton de recherche des consommables',
  208. recipe: 'Bouton de recherche des recettes',
  209. sets: 'Liste de recherche des sets',
  210. sum: "Cumul des prix de vente marchand sur recherche"
  211. }
  212. },
  213. miscellaneous: {
  214. title: 'Divers',
  215. options: {
  216. lang: 'Language',
  217. logout: 'Bouton d&eacute;connexion directe',
  218. deleteAllReports: 'Action pour supprimer tous les rapports',
  219. showFees: 'Frais bancaire en survol',
  220. popupTWT: 'Ouverture du menu du script Collections au survol'
  221. }
  222. },
  223. craft: {
  224. title: 'Artisanat',
  225. options: {
  226. filterMarket: 'Recherche des items de craft dans le marché'
  227. }
  228. },
  229. twdbadds: {
  230. title: 'Add-on Clothcalc',
  231. options: {
  232. filterBuyMarket: 'Filtre dans le march&eacute; pour n\'afficher que les items manquants <a target=\'_blank\' href="//tw-db.info/?strana=userscript">(twdb add)</a>'
  233. }
  234. }
  235. },
  236. message: {
  237. title: 'Information',
  238. message: 'Préférences appliquées',
  239. reloadButton: 'Recharger cette page',
  240. gameButton: 'Aller sur le jeu',
  241. indispo: 'Option indisponible (Collections terminées ou script non diponible)',
  242. more: 'Autres ?',
  243. moreTip: 'Ouvrir la page des traductions'
  244. },
  245. update: {
  246. title: ' Mise à jour',
  247. updok: 'Le script TW Collection est à jour',
  248. updscript: 'Une nouvelle version du script TW Collections est disponible<br>Mettre à jour ?',
  249. updlangmaj: 'Une mise à jour est disponible pour une ou plusieurs langues utilisées avec le script TW Collections.<br>Cliquez sur les liens ci dessous pour mettre à jour ?',
  250. upddaily: 'Journalières',
  251. updweek: 'Hebdomadaire',
  252. updnever: 'Jamais',
  253. checknow: 'Verifier les mises à jour ?',
  254. upderror: 'Impossible de mettre le script TW Collections à jour, vous devez installer le script ou la langue manuellement'
  255. },
  256. saveButton: 'Sauvegarder'
  257. },
  258. Craft: {
  259. titleMarket: 'Rechercher cet item dans les ventes du marché',
  260. },
  261. ToolBox: {
  262. title: 'Fonctionnalit&eacute;s',
  263. list: {
  264. openOptions: 'Param&egrave;tres de l&acute;outil'
  265. }
  266. },
  267. Doublons: {
  268. tip: 'Afficher uniquement les doublons',
  269. current: 'Recherche courante',
  270. upgradeable: 'Ameliorables',
  271. noset: 'Sans items de sets',
  272. sellable: 'Vendables',
  273. auctionable: 'Commercialisables',
  274. tipuse: 'Afficher uniquement les consommables',
  275. tiprecipe: 'Afficher uniquement les recettes',
  276. tipsets: 'Afficher uniquement les items de sets',
  277. sellGain: '$ prix marchand '
  278. },
  279. Logout: {
  280. title: 'D&eacute;connecter'
  281. },
  282. AllReportsDelete: {
  283. button: 'Tout supprimer',
  284. title: 'Supprimer tous les rapports',
  285. work: 'Job',
  286. progress: 'Etat d\'avancement',
  287. userConfirm: 'Confirmation utilisateur',
  288. loadPage: 'Charger la page',
  289. deleteReports: 'Supprimer les rapports',
  290. confirmText: 'Etes-vous sur de vouloir supprimer tous les rapports ?',
  291. deleteYes: 'Oui, supprimer',
  292. deleteNo: 'Non, ne pas supprimer',
  293. status: {
  294. title: 'Statut',
  295. wait: 'Patienter',
  296. successful: 'R&eacute;ussi',
  297. fail: 'Erreur',
  298. error: 'Erreur'
  299. }
  300. },
  301. twdbadds: {
  302. buyFilterTip: 'Montrer seulement les items manquants',
  303. buyFilterLabel: 'Items manquants'
  304. },
  305. collection: {
  306. miss: "Manquants : ",
  307. colTabTitle: "Collections",
  308. setTabTitle: "Sets",
  309. thText: '%1 item%2 manquant%3',
  310. thEncours: 'Vous avez une ench&egrave;re en cours pour cet article',
  311. thFetch: 'Vous pouvez récuperer cet article au marché de %1',
  312. allOpt: 'Tous',
  313. listText: 'Liste des items manquants des collections',
  314. listSetText: 'Liste des items manquants des Sets',
  315. collectionFilterTip: 'Montrer seulement les items de collection',
  316. collectionFilterLabel: 'Collections seules',
  317. select: 'Sélectionner ...',
  318. filters: 'Filtres',
  319. atTrader: 'Vendu par le marchand ambulant',
  320. atBid: 'Enchères en cours',
  321. atCurBid: 'Enchères terminées',
  322. searchMarket: 'Rechercher dans le marché',
  323. atTraderTitle: 'Affichez les items en vente chez le marchand ambulant',
  324. atBidTitle: 'Affichez les items en cours d\'enchère',
  325. atCurBidTitle: 'Affichez les items récupèrables aux enchères',
  326. patchsell: {
  327. title: "Cet item est n&eacute;cessaire pour une collection en cours"
  328. }
  329. }
  330. },
  331. en: {
  332. description: "<center><br><b>TW-Collections</b><br>Tips and reporting missing items collections <br>list of collection needed items<br>Various shortcuts" + "<br>All reports deletion<br>Additional buttons in inventory (duplicates,useables, recipes, sets)<br>etc ...",
  333. Options: {
  334. tab: {
  335. setting: 'Settings'
  336. },
  337. checkbox_text: {
  338. box: {
  339. title: 'Features / Menus',
  340. options: {
  341. goHome: 'Travel to town',
  342. goToDaily1: 'Ghost Town',
  343. goToDaily2: 'Waupee Indian Camp ',
  344. ownSaloon: 'Open saloon',
  345. openMarket: 'Open Market',
  346. mobileTrader: 'Open Mobile Trader',
  347. forum: 'Open forum',
  348. listNeeded: 'Collector\'s items needed'
  349. }
  350. },
  351. collection: {
  352. title: 'Collections',
  353. options: {
  354. gereNewItems: 'Manage the new items added on succeeded achievements',
  355. patchsell: 'Signal missing items in inventory',
  356. patchtrader: 'Signal missing items on Traders',
  357. patchmarket: 'Signal missing items on Market',
  358. showmiss: 'List for missing items on tip',
  359. filterMarket: 'Market filter : show only missing items (collections)'
  360. }
  361. },
  362. inventory: {
  363. title: 'Buttons in inventory',
  364. options: {
  365. doublons: 'Add button for duplicates search',
  366. useables: 'Add button for useables search',
  367. recipe: 'Add button for recipes search',
  368. sets: 'Add button for sets list',
  369. sum: 'Show sell sum on search based on merchant prices'
  370. }
  371. },
  372. miscellaneous: {
  373. title: 'Miscellaneous',
  374. options: {
  375. lang: 'Language',
  376. logout: 'Add Logout button',
  377. deleteAllReports: 'Add suppress all reports action',
  378. showFees: 'Add Bank Fees on Mouseover',
  379. popupTWT: 'Open menu of TW Collections on mouse hover'
  380. }
  381. },
  382. craft: {
  383. title: 'Craft',
  384. options: {
  385. filterMarket: 'Icon for searching craft item in the market'
  386. }
  387. },
  388. twdbadds: {
  389. title: 'Clothcalc Add-on',
  390. options: {
  391. filterBuyMarket: 'Market filter : show only marked missing items <a target=\'_blank\' href="//tw-db.info/?strana=userscript">(twdb add)</a>'
  392. }
  393. }
  394. },
  395. message: {
  396. title: 'Information',
  397. message: 'Preferences have been applied.',
  398. reloadButton: 'Reload this page',
  399. gameButton: 'Return to the game',
  400. indispo: 'Setting unavailable (Collections completed or script not available)',
  401. more: 'More ?',
  402. moreTip: 'Open the translations tips page'
  403. },
  404. update: {
  405. title: 'Update',
  406. upddaily: 'Every day',
  407. updweek: 'Every week',
  408. updnever: 'Never',
  409. checknow: 'Check update now ?',
  410. updok: "The TW Collection's script is up to date",
  411. updlangmaj: 'An update is available for one or more languages of the TW Collections script.<BR>Clic on the links bellow to upgrade.',
  412. updscript: 'An update is available for the script TW Collections<br>Upgrade ?',
  413. upderror: 'Unable to upgrade, you should install the script or language manually'
  414. },
  415. saveButton: 'Save'
  416. },
  417. Craft: {
  418. titleMarket: 'Search this item in the market',
  419. },
  420. ToolBox: {
  421. title: 'Features',
  422. list: {
  423. openOptions: 'Settings'
  424. }
  425. },
  426. Doublons: {
  427. tip: 'Show only duplicates',
  428. current: 'Current search',
  429. upgradeable: 'Upgradeables',
  430. noset: 'Without set items',
  431. sellable: 'Sellables',
  432. auctionable: 'Auctionables',
  433. tipuse: 'Show only useables',
  434. tiprecipe: 'Show only recipes',
  435. tipsets: 'Show only set items',
  436. sellGain: '$ from the merchant'
  437. },
  438. Logout: {
  439. title: 'Logout'
  440. },
  441. AllReportsDelete: {
  442. button: 'Delete all reports',
  443. title: 'Delete all reports',
  444. work: 'Job',
  445. progress: 'Progress',
  446. userConfirm: 'User Confirm',
  447. loadPage: 'Load Page',
  448. deleteReports: 'Delete reports',
  449. confirmText: 'Delete all reports - Are you sure?',
  450. deleteYes: 'Yes, delete',
  451. deleteNo: 'No, don\'t delete',
  452. status: {
  453. title: 'Status',
  454. wait: 'Wait',
  455. successful: 'R&eacute;ussi',
  456. fail: 'Error',
  457. error: 'Error'
  458. }
  459. },
  460. twdbadds: {
  461. buyFilterTip: 'Show only missing items',
  462. buyFilterLabel: 'Missing items'
  463. },
  464. collection: {
  465. miss: "Missing : ",
  466. colTabTitle: "Collections",
  467. setTabTitle: "Sets",
  468. thText: '%1 missing item%2',
  469. thEncours: 'You have a bid for this item',
  470. thFetch: 'You may retrieve this item at the market of %1',
  471. allOpt: 'All',
  472. collectionFilterTip: 'Show only collections items',
  473. collectionFilterLabel: 'Collections only',
  474. select: 'Select ...',
  475. listText: 'Collector\'s items needed',
  476. listSetText: 'Set\'s items needed',
  477. filters: 'Filters',
  478. atTrader: 'Sold by mobile trader',
  479. atBid: 'Current bids',
  480. atCurBid: 'Ended bids',
  481. atTraderTitle: 'Show items on sale at the mobile trader',
  482. atBidTitle: 'Show currents bids',
  483. atCurBidTitle: 'Show items retrievable at market',
  484. searchMarket: 'Search in the market',
  485. patchsell: {
  486. title: "Items needed to complete collections"
  487. }
  488. }
  489. }
  490. },
  491. getLanguage: function () {
  492. var detected_lang;
  493. try {
  494. detected_lang = TWT.scriptStorage.getItem('TWT.Cache.miscellaneous.lang');
  495. if (!isDefined(detected_lang)) {
  496. detected_lang = Game.locale.match(/(\S*)_/)[1];
  497. }
  498. if (!isDefined(detected_lang)) {
  499. detected_lang = TWT.info.lang;
  500. }
  501. } catch (ex) {
  502. detected_lang = TWT.info.lang;
  503. } finally {
  504. var langue = TWT.langs[detected_lang];
  505. if (!isDefined(langue)) {
  506. langue = TWT.langs[TWT.info.lang];
  507. var saved_descr = localStorage.getItem('TWT.Cache.description');
  508. if (isDefined(saved_descr)) {
  509. langue.description = saved_descr;
  510. }
  511. EventHandler.listen('twt_lang_started_' + detected_lang, function () {
  512. TWT.getLanguage();
  513. return EventHandler.ONE_TIME_EVENT;
  514. });
  515. } else {
  516. TWT.info.lang = detected_lang;
  517. }
  518. return langue;
  519. }
  520. },
  521. addMissedTrad: function (enTrObj, langTrObj) {
  522. if (!isDefined(langTrObj)) {
  523. langTrObj = {};
  524. }
  525. $.each(enTrObj, function (ind, item) {
  526. if (jQuery.type(item) == "object") {
  527. langTrObj[ind] = TWT.addMissedTrad(item, langTrObj[ind]);
  528. } else {
  529. if (jQuery.type(langTrObj[ind]) == "undefined") {
  530. langTrObj[ind] = enTrObj[ind];
  531. }
  532. }
  533. });
  534. return langTrObj;
  535. },
  536. isGreasyLang: function (lang) {
  537. var oldIdLangs = ["179395", "179358", "179298", "178773", "180784", "182959", "179302"];
  538. if ($.inArray(lang.idscript, oldIdLangs) > -1) {
  539. var dlg = new west.gui.Dialog("Unmaintained language script for TW Collection", "<div><b>You are using an obsolete version of '" + lang.name + "' language script for TW Collection.</b>" + "<br><br>You should manually uninstall this script and <br><a target='_blank' href='//greatest.deepsurf.us/scripts/" + TWT.langPatchs[lang.short_name].link + "'>" + "Install the correct version of " + lang.name + " script.</a>" + "</div>", west.gui.Dialog.SYS_WARNING).setModal(true, false, {
  540. bg: "images/curtain_bg.png",
  541. opacity: 0.4
  542. }).addButton(west.gui.Dialog.SYS_OK).show();
  543. return false;
  544. } else {
  545. return true;
  546. }
  547. },
  548. addPatchLang: function (lang) {
  549. try {
  550. if (TWT.isGreasyLang(lang)) {
  551. TWT.langs[lang.short_name] = lang.translation;
  552. TWT.languages.push({
  553. 'short_name': lang.short_name,
  554. 'name': lang.name,
  555. 'translator': lang.translator,
  556. 'version': lang.version,
  557. 'script': lang.idscript
  558. });
  559. TWT.langs[lang.short_name] = TWT.addMissedTrad(TWT.langs.en, TWT.langs[lang.short_name]);
  560. EventHandler.signal('twt_lang_started_' + lang.short_name);
  561. }
  562. } catch (e) {
  563. ErrorLog.log(e);
  564. }
  565. },
  566. checkIsValidLang: function () {
  567. var selLang = TWT.langs[TWT.Settings.checked.miscellaneous.lang] || undefined;
  568. if (!isDefined(selLang)) {
  569. TWT.Options.open('translate');
  570. TWT.Settings.checked.miscellaneous.lang = TWT.info.lang;
  571. TWT.scriptStorage.setItem('TWT.Cache.miscellaneous.lang', TWT.info.lang);
  572. }
  573. },
  574. init: function () {
  575. try {
  576. EventHandler.signal("twt.init");
  577. var that = this;
  578. var timeout = 0;
  579. this.interval = setInterval(function () {
  580. var loading = false;
  581. if (isDefined(Character.playerId) && Character.playerId == 0) {
  582. loading = false;
  583. } else if (!isDefined(ItemManager)) {
  584. loading = false;
  585. } else if (isDefined(ItemManager.initialized) && !ItemManager.initialized) {
  586. loading = false;
  587. } else if (isDefined(window.TWDB)) {
  588. /* null != TWDB && 'undefined' != typeof TWDB) {*/
  589. if (!window.TWDB.ClothCalc.ready) {
  590. loading = false;
  591. timeout++;
  592. if (timeout > 20) {
  593. ErrorLog.log('Stop interval, chargement de TWDB non possible ?');
  594. TWT.isTWDBHere = true;
  595. loading = true;
  596. }
  597. } else {
  598. TWT.isTWDBHere = true;
  599. loading = true;
  600. }
  601. } else
  602. loading = true;
  603. if (loading) {
  604. clearInterval(that.interval);
  605. if (TWT.scriptStorage == null) {
  606. TWT.scriptStorage = new Storage("local", "Storage." + TWT.info.idscript);
  607. }
  608. TWT.LANG = TWT.getLanguage();
  609. TWT.Settings.init();
  610. TWT.checkIsValidLang();
  611. if (!TWT.DEBUG) {
  612. TWT.api();
  613. } else {
  614. window.DEBUG = true;
  615. }
  616. TWT.ready = true;
  617. EventHandler.signal('twt.ready');
  618. }
  619. }, 500);
  620. } catch (e) {
  621. ErrorLog.log("Erreur d'initialisation", e);
  622. ErrorLog.showLog();
  623. TWT.ready = false;
  624. }
  625. },
  626. Commons: {
  627. searchMarket: function (id) {
  628. if (!isNaN(id)) {
  629. var objS = ItemManager.get(id);
  630. id = objS.name;
  631. }
  632. MarketWindow.open(Character.homeTown.town_id);
  633. MarketWindow.showTab('buy');
  634. $("div.market-buy .iSearchbox input", MarketWindow.DOM).val(id);
  635. $('span.iconBut_mpb_refresh', MarketWindow.DOM).click();
  636. },
  637. addMarketBuyLink: function (itemId) {
  638. var imgMrket = $('<div class="TWTcraftitem opmarket" id="' + itemId + '" style="background: url(\'images/window/market/market_icons2.png\') -16px 0;cursor:pointer;display:inline-block;position:absolute;top:4px;left:3px;width:16px;height:16px;" ' + 'title="' + TWT.LANG.Craft.titleMarket + '">').click(function (e) {
  639. TWT.Commons.searchMarket(e.target.attributes.id.value);
  640. });
  641. return imgMrket;
  642. },
  643. },
  644. Settings: {
  645. checked: {},
  646. shouldRefresh: {},
  647. init: function () {
  648. if (!isDefined(TWT.scriptStorage.getItem('TWT.Cache.Metacol.finished'))) {
  649. /* TWT.MetaCol.init();*/
  650. } else {
  651. TWT.MetaCol.finished = TWT.scriptStorage.getItem('TWT.Cache.Metacol.finished');
  652. }
  653. $.each(TWT.LANG.Options.checkbox_text, function (ind1, val) {
  654. TWT.Settings.checked[ind1] = [];
  655. $.each(TWT.LANG.Options.checkbox_text[ind1].options, function (ind2, detail) {
  656. if (['showFees'].includes(ind2))
  657. return 1;
  658. var attended = TWT.scriptStorage.getItem('TWT.Cache.' + ind1 + '.' + ind2);
  659. if (!isDefined(attended)) {
  660. if (ind2 == 'lang')
  661. attended = TWT.info.lang;
  662. else if (['logout', 'deleteAllReports'].includes(ind2))
  663. attended = 0;
  664. else
  665. attended = '1';
  666. TWT.scriptStorage.setItem('TWT.Cache.' + ind1 + '.' + ind2, attended);
  667. }
  668. TWT.Settings.checked[ind1][ind2] = attended;
  669. });
  670. });
  671. TWT.Settings.apply();
  672. },
  673. getValue: function (what) {
  674. return eval('TWT.Settings.checked.' + what);
  675. },
  676. isChecked: function (what) {
  677. return TWT.Settings.getValue(what) == "1";
  678. },
  679. refresh: function (tabOpt) {
  680. var refreshed = false;
  681. try {
  682. for (var key in tabOpt) {
  683. if (tabOpt.hasOwnProperty(key)) {
  684. var val = tabOpt[key];
  685. if (val != TWT.Settings.getValue(key)) {
  686. TWT.scriptStorage.setItem('TWT.Cache.' + key, val);
  687. var det = key.split('.');
  688. TWT.Settings.checked[det[0]][det[1]] = val;
  689. EventHandler.signal(key);
  690. refreshed = true;
  691. }
  692. }
  693. }
  694. TWT.LANG = TWT.langs[TWT.Settings.getValue('miscellaneous.lang')] || TWT.langs.en;
  695. EventHandler.signal('collection.bagupdate');
  696. } catch (e) {
  697. ErrorLog.log('Erreur refresh ', e);
  698. }
  699. return refreshed;
  700. },
  701. apply: function () {
  702. TWT.LANG = TWT.langs[TWT.Settings.getValue('miscellaneous.lang')] || TWT.langs[TWT.info.lang];
  703. TWT.MenuBox.initListener();
  704. TWT.MenuBox.create();
  705. TWT.Injecteur.startListen();
  706. TWT.Logout.initListener();
  707. if (TWT.Settings.isChecked('inventory.doublons') || TWT.Settings.isChecked('inventory.useables') || TWT.Settings.isChecked('inventory.recipe') || TWT.Settings.isChecked('inventory.sets')) {
  708. TWT.Inventaire.create();
  709. } else {
  710. TWT.Inventaire.detach();
  711. }
  712. TWT.CraftHandler.initListener();
  713. TWT.AllReportsDelete.initListener();
  714. if (TWT.Settings.isChecked('craft.filterMarket')) {
  715. TWT.CraftHandler.init();
  716. TWT.CraftHandler.inject();
  717. }
  718. if (TWT.Settings.isChecked('miscellaneous.logout'))
  719. TWT.Logout.create();
  720. if ((!TWT.MetaCol.finished) || TWT.isTWDBHere) {
  721. TWT.Market.initListener();
  722. if (TWT.Settings.isChecked("twdbadds.filterBuyMarket") || TWT.Settings.isChecked('collection.filterMarket')) {
  723. TWT.Market.init();
  724. TWT.Market.inject();
  725. }
  726. }
  727. if (!TWT.MetaCol.finished) {
  728. TWT.CollectionsHandler.initListener();
  729. if (TWT.Settings.isChecked('collection.patchsell') || TWT.Settings.isChecked('collection.patchmarket') || TWT.Settings.isChecked('collection.showmiss')) {
  730. /* EventHandler.signal('collection.bagupdate');*/
  731. TWT.CollectionsHandler.init();
  732. TWT.CollectionsHandler.inject();
  733. TWT.CollectionsHandler.attachFilter();
  734. }
  735. }
  736. if (TWT.Settings.isChecked('miscellaneous.deleteAllReports')) {
  737. TWT.AllReportsDelete.addStyle();
  738. TWT.AllReportsDelete.attach();
  739. }
  740. }
  741. },
  742. Options: {
  743. open: function (window) {
  744. 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);
  745. $('<div></div>').attr({
  746. 'id': 'ToolWindowBody'
  747. }).css({
  748. 'margin-left': '20px',
  749. 'margin-right': '20px'
  750. }).appendTo('.TWTToolWindow .tw2gui_window_content_pane');
  751. if (window == 'setting') {
  752. TWT.Options.setting.open();
  753. } else {
  754. TWT.Options.translate.open();
  755. }
  756. },
  757. translate: {
  758. open: function () {
  759. var txtArea = '<div style="width:650px;margin-left:15px;margin-top:20px;height:250px;font-size:16px;text-align:justify;padding-bottom:50px;">' + '<h4 style="margin-bottom:20px;"><center>The translation\'s system of the TW Collections script has changed</center></h4>' + "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<BR><BR>" + "<div style='margin-left:60px;overflow:auto;height:200px;font-size:15px;'>";
  760. var langPatchs = TWT.langPatchs;
  761. $.each(langPatchs, function (lang) {
  762. txtArea += "<a target='_blank' href='//greatest.deepsurf.us/scripts/" + langPatchs[lang].link + "'>" + langPatchs[lang].texte + " by " + langPatchs[lang].author + "</a><br>";
  763. });
  764. txtArea += '</div></div>';
  765. TWT.Options.Windows.activateTab('TabTranslate').$("div.tw2gui_window_content_pane").empty();
  766. TWT.Options.Windows.setTitle("Translations for TW Collections");
  767. TWT.Options.Windows.appendToContentPane(txtArea);
  768. TWT.Options.Windows.appendToContentPane(TWT.getDunMp());
  769. }
  770. },
  771. setting: {
  772. open: function () {
  773. TWT.Options.Windows.activateTab('TabSetting').$("div.tw2gui_window_content_pane").empty();
  774. TWT.Options.Windows.setTitle(TWT.LANG.Options.tab.setting);
  775. var save_button = new west.gui.Button(TWT.LANG.Options.saveButton, TWT.Options.save);
  776. var l0 = TWT.Options.createLanguage();
  777. var l1 = TWT.Options.getContent();
  778. var l2 = $('<div style="text-align:center;">').append(save_button.getMainDiv());
  779. TWT.Options.Windows.appendToContentPane($('<div id="divopts" style="font-weight:bolder;width:683px;left:10px;" class="daily_activity-list">').append(l0, l1, l2));
  780. $("#divopts", TWT.Options.Windows.getMainDiv()).css("width: 674px;");
  781. TWT.Options.Windows.appendToContentPane(TWT.getDunMp());
  782. $(".fancytable div.trows div.tbody").css({
  783. "min-height": "30px"
  784. });
  785. }
  786. },
  787. getContent: function () {
  788. var scrollbar = new west.gui.Scrollpane();
  789. $.each(TWT.LANG.Options.checkbox_text, function (key) {
  790. 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, "<span style='font-size:12pt;padding-left:25px;'>" + TWT.LANG.Options.checkbox_text[key].title + "</span>");
  791. $.each(TWT.LANG.Options.checkbox_text[key].options, function (i) {
  792. if (!['lang', 'showFees'].includes(i)) {
  793. var checkB;
  794. if ((TWT.MetaCol.finished && (key == 'collection' || i == 'listNeeded')) || ((key == 'twdbadds') && !TWT.isTWDBHere)) {
  795. checkB = $("<span title='" + TWT.LANG.Options.message.indispo + "' style='color: #808080;font-style: italic;font-size:11pt;padding-left:10px;'>").append(TWT.LANG.Options.checkbox_text[key].options[i]);
  796. } else {
  797. checkB = new west.gui.Checkbox().setTitle(TWT.LANG.Options.checkbox_text[key].options[i]).setLabel("<span style='font-size:11pt;padding-left:10px;'>" + TWT.LANG.Options.checkbox_text[key].options[i] + "</span>").setSelected(TWT.Settings.isChecked(key + '.' + i)).setId('setting_' + key + '_' + i).getMainDiv();
  798. }
  799. table.appendRow(checkB, '');
  800. }
  801. });
  802. scrollbar.appendContent(table.getMainDiv());
  803. });
  804. $(scrollbar.getMainDiv()).css({
  805. "height": "300px",
  806. "margin-top": "5px;",
  807. "font-weight": "normal"
  808. });
  809. return $(scrollbar.getMainDiv());
  810. },
  811. createLanguage: function () {
  812. TWT.Options.lang_box = new west.gui.Combobox();
  813. for (var i = 0; i < TWT.languages.length; i++) {
  814. TWT.Options.lang_box.addItem(TWT.languages[i].short_name, TWT.languages[i].name);
  815. }
  816. TWT.Options.lang_box.select(TWT.Settings.getValue('miscellaneous.lang'));
  817. var more_button = new west.gui.Button(TWT.LANG.Options.message.more, TWT.Options.translate.open, this, this, TWT.LANG.Options.message.moreTip);
  818. return $("<span>").append(TWT.LANG.Options.checkbox_text.miscellaneous.options.lang + " : ").append(TWT.Options.lang_box.getMainDiv()).append(more_button.getMainDiv());
  819. },
  820. save: function () {
  821. TWT.Options.Windows.showLoader();
  822. var tblSave = [];
  823. $.each(TWT.LANG.Options.checkbox_text, function (key) {
  824. $.each(TWT.LANG.Options.checkbox_text[key].options, function (i) {
  825. if (i != 'lang') {
  826. tblSave[key + '.' + i] = $('#setting_' + key + '_' + i).hasClass("tw2gui_checkbox_checked");
  827. }
  828. });
  829. });
  830. tblSave['miscellaneous.lang'] = TWT.Options.lang_box.getValue();
  831. TWT.Settings.refresh(tblSave);
  832. TWT.Options.Windows.hideLoader();
  833. new UserMessage(TWT.LANG.Options.message.message, UserMessage.TYPE_SUCCESS).show();
  834. }
  835. },
  836. MenuBox: {
  837. selectbox: null,
  838. initListener: function () {
  839. EventHandler.listen('miscellaneous.popupTWT', function () {
  840. $('#TWT_Icon').remove();
  841. TWT.MenuBox.create();
  842. });
  843. },
  844. create: function () {
  845. $('#TWT_Icon').remove();
  846. var a = $('<div></div>').attr({
  847. 'class': 'menulink',
  848. 'title': TWT.LANG.ToolBox.title
  849. }).css({
  850. 'background-position': '0px -100px'
  851. }).on('mouseleave', function () {
  852. $(this).css("background-position", "0px -100px");
  853. }).click(function (e) {
  854. TWT.MenuBox.open(e);
  855. });
  856. if (TWT.Settings.isChecked('miscellaneous.popupTWT')) {
  857. a.on('mouseenter', function (e) {
  858. $(this).css("background-position", "-25px -100px");
  859. TWT.MenuBox.open(e);
  860. });
  861. }
  862. var b = $('<div></div>').attr({
  863. 'class': 'menucontainer_bottom'
  864. });
  865. $('#ui_menubar').append($('<div></div>').attr({
  866. 'class': 'ui_menucontainer',
  867. 'id': 'TWT_Icon'
  868. }).append(a).append(b));
  869. },
  870. open: function (e) {
  871. if (isDefined(this.selectbox)) {
  872. this.selectbox.items = [];
  873. } else {
  874. this.selectbox = new west.gui.Selectbox(true);
  875. this.selectbox.setWidth(250).addListener(function (key) {
  876. if (key == 99) {
  877. eval(TWT.menu_callback.openOptions);
  878. } else {
  879. eval(TWT.menu_callback[key]);
  880. }
  881. });
  882. }
  883. var that = this;
  884. $.each(TWT.LANG.Options.checkbox_text.box.options, function (indexB, keyB) {
  885. if (TWT.Settings.isChecked('box.' + indexB))
  886. that.selectbox.addItem(indexB, keyB);
  887. });
  888. this.selectbox.addItem(99, TWT.LANG.ToolBox.list.openOptions);
  889. this.selectbox.show(e);
  890. this.selectbox.setPosition(e.clientX, e.clientY - 25);
  891. $(this.selectbox.elContent).on('mouseleave', function () {
  892. that.selectbox.hide();
  893. });
  894. }
  895. },
  896. MetaCol: {
  897. group: [],
  898. groupSorted: [],
  899. marketEC: {},
  900. all: {},
  901. inProgress: {},
  902. erreur: false,
  903. ready: false,
  904. dirty: true,
  905. getMarketEC: function () {
  906. $.ajax({
  907. url: 'game.php?window=building_market&action=fetch_bids&h=' + Player.h,
  908. type: 'POST',
  909. data: {},
  910. dataType: 'json',
  911. success: function (json) {
  912. if (json.error)
  913. return new UserMessage(json.msg, UserMessage.TYPE_ERROR).show();
  914. var result = json.msg.search_result;
  915. TWT.MetaCol.marketEC = [];
  916. for (var i = 0; i < result.length; i++) {
  917. var item = ItemManager.get(result[i].item_id);
  918. if (isDefined(item)) {
  919. TWT.MetaCol.marketEC[item.name.trim()] = result[i];
  920. }
  921. }
  922. }
  923. });
  924. },
  925. populateInProgress: function (all) {
  926. try {
  927. var tmpArr = all.achievements.progress;
  928. if (TWT.Settings.isChecked('collection.gereNewItems')) {
  929. $.merge(tmpArr, all.achievements.finished);
  930. }
  931. $.each(tmpArr, function (index, value) {
  932. var itemsImg = [];
  933. var rex = /<span.*?([\s\S]*?)<\/span>/gm;
  934. var match;
  935. while (match = rex.exec(value.meta)) {
  936. var val = match[1];
  937. var srcI = /<img.*?src="(.*?)"/.exec(val)[1];
  938. var ident = value.title.trim();
  939. var strManquant = "";
  940. var name = /<img.*?alt="(.*?)"/.exec(val)[1];
  941. var shoudBuy = (val.indexOf("locked") > -1);
  942. TWT.MetaCol.inProgress[name] = {
  943. shouldBuy: (val.indexOf("locked") > -1),
  944. src: srcI,
  945. img: srcI.match(/\S*.\/(\S*png)/)[1],
  946. group: ident
  947. };
  948. if (shoudBuy) {
  949. if (!isDefined(TWT.MetaCol.group[ident])) {
  950. TWT.MetaCol.group[ident] = [];
  951. }
  952. TWT.MetaCol.group[ident].push(name);
  953. }
  954. }
  955. });
  956. var sortable = [];
  957. for (var group in TWT.MetaCol.group) {
  958. sortable.push([group, TWT.MetaCol.group[group]]);
  959. }
  960. sortable.sort(function (a, b) {
  961. var x = a[0];
  962. var y = b[0];
  963. if (typeof x === 'string' && typeof x === 'string') {
  964. return x.localeCompare(y);
  965. }
  966. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  967. });
  968. TWT.MetaCol.groupSorted = sortable;
  969. /* 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;*/
  970. } catch (e) {
  971. this.erreur = "Initialisation des Collections impossible";
  972. ErrorLog.log(e, this.erreur);
  973. ErrorLog.showLog();
  974. }
  975. },
  976. sort: function (array, key) {
  977. return array.sort(function (a, b) {
  978. a = a[key].trim();
  979. b = b[key].trim();
  980. return a.localeCompare(b);
  981. });
  982. },
  983. init: function () {
  984. if (this.ready == false) {
  985. TWT.MetaCol.setCol = [];
  986. TWT.MetaCol.setsProgress = [];
  987. TWT.MetaCol.groupSet = [];
  988. TWT.MetaCol.all = {};
  989. TWT.MetaCol.group = {};
  990. TWT.MetaCol.inProgress = {};
  991. var that = this;
  992. $.ajax({
  993. url: 'game.php?window=achievement&action=get_list&h=' + Player.h,
  994. type: 'POST',
  995. data: {
  996. 'folder': 'collections',
  997. 'playerid': Character.playerId
  998. },
  999. dataType: 'json',
  1000. success: function (data_return) {
  1001. var all = eval(data_return);
  1002. if (all.achievements.progress.length > 0 || TWT.Settings.isChecked('collection.gereNewItems')) {
  1003. TWT.MetaCol.all = all;
  1004. TWT.MetaCol.getMarketEC();
  1005. TWT.MetaCol.populateInProgress(eval(data_return));
  1006. TWT.MetaCol.ready = true;
  1007. } else {
  1008. EventHandler.signal('collections_finished');
  1009. TWT.MetaCol.finished = true;
  1010. TWT.scriptStorage.setItem('TWT.Cache.Metacol.finished', true);
  1011. }
  1012. }
  1013. });
  1014. /* init des items de sets manquants*/
  1015. $.getScript('//the-west-scripts.github.io/The-West-Essentials/files/newSets.js', function () {
  1016. var sets = west.storage.ItemSetManager._setArray.slice(0);
  1017. sets = TWT.MetaCol.sort(sets, "name");
  1018. for (var jj = 0; jj < sets.length; jj++) {
  1019. var set = sets[jj];
  1020. if (forbid.sets.includes(set.key) || set.key.includes('friendship_set_'))
  1021. continue;
  1022. var items = set.getItems(),
  1023. detSet = [],
  1024. isFriend = 0;
  1025. for (var zz of items) {
  1026. var item = ItemManager.getByBaseId(zz);
  1027. if (!isDefined(item)) {
  1028. ErrorLog.log("Erreur sur " + zz + " " + set.name);
  1029. } else {
  1030. if (item.short.includes('friendset_') || forbid.IDs.includes(zz)) {
  1031. isFriend = 1;
  1032. break;
  1033. } else {
  1034. var weared = Wear.carries(zz),
  1035. bagItem = Bag.getItemsIdsByBaseItemId(zz);
  1036. if (!weared && !bagItem[0]) {
  1037. detSet.push(item.name);
  1038. TWT.MetaCol.setsProgress[item.name] = item.image;
  1039. }
  1040. }
  1041. }
  1042. }
  1043. if (detSet.length > 0 && !isFriend) {
  1044. TWT.MetaCol.setCol.push([set.name, detSet]);
  1045. TWT.MetaCol.groupSet[set.name] = detSet;
  1046. }
  1047. }
  1048. });
  1049. }
  1050. },
  1051. isFinished: function (name) {
  1052. if (TWT.MetaCol.finished)
  1053. return true;
  1054. var item = TWT.MetaCol.inProgress[name.trim()];
  1055. if (!isDefined(item)) {
  1056. return true;
  1057. } else if (isDefined(TWT.MetaCol.group[item.group]) && TWT.MetaCol.group[item.group][0] == true) {
  1058. return true;
  1059. } else if (!isDefined(TWT.MetaCol.group[item.group])) {
  1060. return true;
  1061. } else
  1062. return false;
  1063. },
  1064. shouldBuy: function (name) {
  1065. var item = TWT.MetaCol.inProgress[name.trim()];
  1066. var marketed = TWT.MetaCol.marketEC[name.trim()];
  1067. if (isDefined(item) && !isDefined(marketed)) {
  1068. return item.shouldBuy;
  1069. } else {
  1070. return false;
  1071. }
  1072. },
  1073. getBuyItems: function (name, withbr) {
  1074. try {
  1075. if (TWT.Settings.isChecked('collection.showmiss')) {
  1076. var br = (withbr) ? "<BR>" : " - ";
  1077. var item = TWT.MetaCol.inProgress[name.trim()];
  1078. if (isDefined(item)) {
  1079. var manquants = TWT.MetaCol.group[item.group];
  1080. if (isDefined(manquants) && manquants.length > 0) {
  1081. var strManq = br;
  1082. $.each(manquants, function (inD, val) {
  1083. strManq += "[ " + val + " ]" + br;
  1084. });
  1085. return strManq += " ";
  1086. } else {
  1087. return "";
  1088. }
  1089. }
  1090. }
  1091. } catch (e) {
  1092. this.erreur = "Impossible de recenser les items manquants pour " + name;
  1093. ErrorLog.log(e, this.erreur);
  1094. }
  1095. return "";
  1096. },
  1097. remove: function (arr, name) {
  1098. name = name.trim();
  1099. var x,
  1100. _i,
  1101. _len,
  1102. _results;
  1103. _results = [];
  1104. for (_i = 0, _len = arr.length; _i < _len; _i++) {
  1105. x = arr[_i];
  1106. if (x != name) {
  1107. _results.push(x);
  1108. }
  1109. }
  1110. return _results;
  1111. }
  1112. },
  1113. WindowCollection: {
  1114. scrollbar: null,
  1115. totalGroup: 0,
  1116. cbTrader: null,
  1117. cbBid: null,
  1118. cbCurBid: null,
  1119. getAllAnchors: function (what, group) {
  1120. var that = this;
  1121. if (!isDefined(what)) {
  1122. what = TWT.MetaCol.groupSorted;
  1123. group = TWT.MetaCol.group;
  1124. }
  1125. var textinput = new west.gui.Textfield().maxlength(12).setPlaceholder(TWT.LANG.collection.select).setWidth(165);
  1126. var anchorz = new west.gui.Selectbox();
  1127. anchorz.setWidth(200);
  1128. $(anchorz.elContent).css({
  1129. "max-height": "270px",
  1130. "width": "250px",
  1131. "white-space": 'nowrap'
  1132. });
  1133. anchorz.addItem(TWT.LANG.collection.allOpt, TWT.LANG.collection.allOpt);
  1134. $.each(what, function (ind2, val) {
  1135. anchorz.addItem(val[0], '<div style="overflow:hidden;text-overflow:ellipsis;">' + val[0] + '</div>');
  1136. });
  1137. anchorz.addListener(function (e) {
  1138. var str = "";
  1139. textinput.setValue(e);
  1140. var arrtmp = {};
  1141. if (e == TWT.LANG.collection.allOpt) {
  1142. arrtmp = what;
  1143. } else {
  1144. arrtmp[0] = [e, group[e]];
  1145. }
  1146. that.scrollbar.scrollToTop();
  1147. var opt = that.getDiv(arrtmp);
  1148. $('#showbox').html(opt);
  1149. that.switchOff();
  1150. return true;
  1151. });
  1152. textinput.click(function (e) {
  1153. anchorz.show(e);
  1154. });
  1155. return textinput.getMainDiv();
  1156. },
  1157. initTrader: function () {
  1158. var check = -1;
  1159. var traderInv;
  1160. var model = west.window.shop.model;
  1161. var trader = model.getCategory('trader');
  1162. if (isDefined(trader)) {
  1163. var timeTrader = trader.getRefreshTimeout();
  1164. check = timeTrader - Math.round(new Date() / 1000);
  1165. traderInv = model._data.inventory.trader;
  1166. }
  1167. if (check < 0) {
  1168. $.ajax({
  1169. url: 'game.php?window=shop_trader&mode=index',
  1170. type: 'POST',
  1171. dataType: 'json',
  1172. success: function (resp) {
  1173. model.setInventory(resp.inventory);
  1174. model.getCategories()['trader'] = west.window.shop.getFactory().createCategory({
  1175. 'name': 'trader'
  1176. }, 'trader');
  1177. model.getCategory('trader').setRefreshTimeout(resp.traderTime);
  1178. traderInv = resp.inventory.trader;
  1179. }
  1180. });
  1181. }
  1182. var traderItems = [];
  1183. $.each(traderInv, function (i, item) {
  1184. var obj = item.item_data;
  1185. if (!isDefined(obj)) {
  1186. obj = ItemManager.get(item.item_id);
  1187. }
  1188. traderItems[obj.name.trim()] = item;
  1189. });
  1190. return traderItems;
  1191. },
  1192. getDiv: function (what) {
  1193. /* 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(); };*/
  1194. var traderItems = this.initTrader();
  1195. var that = this;
  1196. var total = 0;
  1197. var divMain = $("<br><table width='100%' cellpading=10 cellspacing=10 style='font-style: bold; -webkit-user-select: text !important; -khtml-user-select: text !important; -moz-user-select: text !important; -ms-user-select: text !important; user-select: text !important;'>");
  1198. $.each(what, function (ind2, valGroup) {
  1199. var imod = 0;
  1200. var bigTR = $('<tr>');
  1201. bigTR.attr('class', 'questlog_entrie');
  1202. bigTR.css({
  1203. 'color': '#113355'
  1204. });
  1205. bigTR.attr('id', valGroup[0].trim());
  1206. bigTR.append($('<td>').append(valGroup[0].trim()));
  1207. divMain.append(bigTR);
  1208. $.each(valGroup[1], function (ind3, val) {
  1209. var tr = $('<tr style="font-weight:bold;font-style:italic;"></tr>');
  1210. var td = $('<td class="achieve_list">');
  1211. var span = $("<span>");
  1212. var img = $("<img class='resizedImage'>");
  1213. if (isDefined(TWT.MetaCol.inProgress[val])) {
  1214. img.attr('src', TWT.MetaCol.inProgress[val].src);
  1215. } else {
  1216. if (isDefined(TWT.MetaCol.setsProgress[val])) {
  1217. img.attr('src', TWT.MetaCol.setsProgress[val]);
  1218. }
  1219. }
  1220. img.attr("title", TWT.LANG.collection.searchMarket);
  1221. img.css("cursor", "pointer");
  1222. img.click(function () {
  1223. TWT.Commons.searchMarket(val);
  1224. });
  1225. span.append(img, "&nbsp;", val);
  1226. if (isDefined(traderItems[val.trim()])) {
  1227. tr.addClass('hasTrader');
  1228. var divTrader = $('<img src="' + TWT.images.traderImg + '" style="cursor: pointer;display: inline-block;" ' + 'title="' + TWT.LANG.collection.atTrader + '">');
  1229. divTrader.click(function () {
  1230. west.window.shop.open().showCategory("trader");
  1231. });
  1232. span.append("&nbsp;&nbsp;&nbsp;", divTrader);
  1233. }
  1234. var item = TWT.MetaCol.marketEC[val.trim()];
  1235. if (isDefined(item)) {
  1236. var imsell = '';
  1237. var sp = '';
  1238. if (item.auction_ends_in < 0) {
  1239. tr.addClass('hasCurrentBid');
  1240. imsell = $('<span title="' + TWT.LANG.collection.thFetch.replace('%1', item.market_town_name) + '" style="background: url(\'images/market/fetch.png\') ' + 'repeat-x scroll 0 0 transparent;cursor: pointer;' + 'height: 12px; display: inline-block;width: 12px;"></span>');
  1241. item.isFinished = true;
  1242. } else {
  1243. tr.addClass('hasBid');
  1244. sp = $('<span title="' + TWT.LANG.collection.thEncours + '" ' + 'style="background: url(\'images/window/market/market_icons2.png\') ' + 'repeat-x scroll 0 0 transparent;cursor: pointer;' + 'height: 16px; background-position: -16px 0;display: inline-block;width: 16px;"> </span>');
  1245. }
  1246. span.append('&nbsp;', sp, '&nbsp;', imsell).click(function () {
  1247. MarketWindow.open(Character.homeTown.town_id, 'offer');
  1248. MarketWindow.showTab('offer');
  1249. });
  1250. }
  1251. td.append(span).appendTo(tr);
  1252. divMain.append(tr);
  1253. divMain.append(tr);
  1254. imod++;
  1255. });
  1256. total += imod;
  1257. });
  1258. var s = (total > 1) ? 's' : '';
  1259. $('#thliste').text(TWT.LANG.collection.thText.replace('%2', s).replace('%3', s).replace('%1', total));
  1260. return divMain;
  1261. },
  1262. switchOff: function () {
  1263. var that = TWT.WindowCollection;
  1264. if (that.cbTrader.isSelected() || that.cbBid.isSelected() || that.cbCurBid.isSelected()) {
  1265. $('tr', $('#rightPane')).css('display', 'none');
  1266. if (that.cbTrader.isSelected()) {
  1267. $('.hasTrader', $('#rightPane')).css('display', '');
  1268. }
  1269. if (that.cbBid.isSelected()) {
  1270. $('.hasBid', $('#rightPane')).css('display', '');
  1271. }
  1272. if (that.cbCurBid.isSelected()) {
  1273. $('.hasCurrentBid', $('#rightPane')).css('display', '');
  1274. }
  1275. } else {
  1276. $('tr', $('#rightPane')).css('display', '');
  1277. }
  1278. },
  1279. getFiltres: function () {
  1280. this.cbTrader = new west.gui.Checkbox(TWT.LANG.collection.atTrader, '', this.switchOff).setTitle(TWT.LANG.collection.atTraderTitle);
  1281. this.cbBid = new west.gui.Checkbox(TWT.LANG.collection.atBid, '', this.switchOff).setTitle(TWT.LANG.collection.atBidTitle);
  1282. this.cbCurBid = new west.gui.Checkbox(TWT.LANG.collection.atCurBid, '', this.switchOff).setTitle(TWT.LANG.collection.atCurBidTitle);
  1283. var cbox = $('<div class="jobs_basisbox"><h3>' + TWT.LANG.collection.filters + '</h3></div>');
  1284. cbox.append(this.cbTrader.getMainDiv(), '<br>', '<div class="jobs_divider_checkbox">');
  1285. cbox.append(this.cbBid.getMainDiv(), '<br>', '<div class="jobs_divider_checkbox">');
  1286. cbox.append(this.cbCurBid.getMainDiv(), '<br>');
  1287. return cbox;
  1288. },
  1289. open: function () {
  1290. if (!TWT.MetaCol.ready) {
  1291. TWT.MetaCol.init();
  1292. this.interval = setInterval(function () {
  1293. if (TWT.MetaCol.ready)
  1294. clearInterval(this.interval);
  1295. }, 200);
  1296. }
  1297. this.Window = wman.open('WindowCollection', TWT.LANG.collection.listText).setMiniTitle(TWT.LANG.collection.listText);
  1298. this.Window.addTab(TWT.LANG.collection.colTabTitle, "TabCols", this.openCols);
  1299. this.Window.addTab(TWT.LANG.collection.setTabTitle, "TabSets", this.openSets);
  1300. if (window == 'sets') {
  1301. this.openSets();
  1302. } else {
  1303. this.openCols();
  1304. }
  1305. },
  1306. openSets: function () {
  1307. TWT.WindowCollection.Window.activateTab('TabSets').$("div.tw2gui_window_content_pane").empty();
  1308. TWT.WindowCollection.Window.setTitle(TWT.LANG.collection.listSetText);
  1309. var rightPane = $('<div id="rightPane">').css({
  1310. 'height': '100%',
  1311. 'left': '199px',
  1312. 'position': 'absolute',
  1313. 'top': '15px',
  1314. 'width': '450px'
  1315. });
  1316. var leftPane = $('<div id="leftPane">').css({
  1317. 'position': 'absolute',
  1318. 'top': '15px',
  1319. 'height': '100%',
  1320. 'width': '190px'
  1321. });
  1322. var divide = $('<div class="jobs_divider">');
  1323. divide.css({
  1324. 'top': '0px',
  1325. 'height': '375px'
  1326. });
  1327. $('<div id="WindowSetsBody">').append(leftPane).append(divide).append(rightPane).appendTo('.WindowCollection .tw2gui_window_content_pane');
  1328. TWT.WindowCollection.Window.showLoader();
  1329. TWT.MetaCol.getMarketEC();
  1330. var showbox = $('<div style="max-height: 370px;"></div>');
  1331. this.scrollbar = new west.gui.Scrollpane();
  1332. this.scrollbar.scrollToTop();
  1333. $(this.scrollbar.getMainDiv()).css({
  1334. 'height': '320px',
  1335. 'top': '5px'
  1336. });
  1337. this.scrollbar.appendContent($('<div id="showbox" align="center"></div>'));
  1338. showbox.append(this.scrollbar.getMainDiv());
  1339. var th = $('<div id="thliste">');
  1340. th.css({
  1341. 'text-align': 'center',
  1342. 'font-weight': 'bolder'
  1343. });
  1344. $('#rightPane').append(th);
  1345. $('#rightPane').append(showbox);
  1346. $('#leftPane').append(TWT.WindowCollection.getAllAnchors(TWT.MetaCol.setCol, TWT.MetaCol.groupSet));
  1347. var divMain = TWT.WindowCollection.getDiv(TWT.MetaCol.setCol);
  1348. $('#showbox').html(divMain);
  1349. TWT.WindowCollection.Window.hideLoader();
  1350. },
  1351. openCols: function () {
  1352. TWT.WindowCollection.Window.activateTab('TabCols').$("div.tw2gui_window_content_pane").empty();
  1353. TWT.WindowCollection.Window.setTitle(TWT.LANG.collection.listText);
  1354. var rightPane = $('<div id="rightPane">').css({
  1355. 'height': '100%',
  1356. 'left': '199px',
  1357. 'position': 'absolute',
  1358. 'top': '15px',
  1359. 'width': '450px'
  1360. });
  1361. var leftPane = $('<div id="leftPane">').css({
  1362. 'position': 'absolute',
  1363. 'top': '15px',
  1364. 'height': '380px',
  1365. 'width': '190px'
  1366. });
  1367. var divide = $('<div class="jobs_divider">');
  1368. divide.css({
  1369. 'top': '0px',
  1370. 'height': '375px'
  1371. });
  1372. $('<div id="WindowCollectionBody">').append(leftPane).append(divide).append(rightPane).appendTo('.WindowCollection .tw2gui_window_content_pane');
  1373. TWT.WindowCollection.Window.showLoader();
  1374. TWT.MetaCol.getMarketEC();
  1375. var showbox = $('<div style="max-height: 370px;"></div>');
  1376. this.scrollbar = new west.gui.Scrollpane();
  1377. this.scrollbar.scrollToTop();
  1378. $(this.scrollbar.getMainDiv()).css({
  1379. 'height': '320px',
  1380. 'top': '5px'
  1381. });
  1382. this.scrollbar.appendContent($('<div id="showbox" align="center"></div>'));
  1383. showbox.append(this.scrollbar.getMainDiv());
  1384. var th = $('<div id="thliste">');
  1385. th.css({
  1386. 'text-align': 'center',
  1387. 'font-weight': 'bolder'
  1388. });
  1389. $('#leftPane').append(TWT.WindowCollection.getAllAnchors());
  1390. $('#leftPane').append(TWT.WindowCollection.getFiltres());
  1391. /* $('<div style="text-align: left;"></div>') .append(this.getAllAnchors())) ;*/
  1392. $('#rightPane').append(th);
  1393. $('#rightPane').append(showbox);
  1394. var divMain = TWT.WindowCollection.getDiv(TWT.MetaCol.groupSorted);
  1395. $('#showbox').html(divMain);
  1396. TWT.WindowCollection.Window.hideLoader();
  1397. }
  1398. },
  1399. Injecteur: {
  1400. methodes: [],
  1401. winTabInjected: [],
  1402. init: function (id, name, callback) {
  1403. if (!isDefined(this.methodes[id])) {
  1404. this.methodes[id] = {
  1405. attached: false,
  1406. id: id,
  1407. name: name,
  1408. callback: callback,
  1409. original: eval(name)
  1410. };
  1411. }
  1412. },
  1413. addWinTabListen: function (who, callback, tab) {
  1414. if (!isDefined(TWT.Injecteur.winTabInjected[who + '_' + tab])) {
  1415. TWT.Injecteur.winTabInjected[who] = {
  1416. who: who,
  1417. tab: tab,
  1418. callback: callback
  1419. };
  1420. }
  1421. },
  1422. startListen: function () {
  1423. EventHandler.listen('WINDOW_OPENED', function (e) {
  1424. if (isDefined(TWT.Injecteur.winTabInjected[e])) {
  1425. var inj = TWT.Injecteur.winTabInjected[e];
  1426. TWT.Injecteur.detecteWin(inj.who, inj.callback, inj.tab);
  1427. }
  1428. });
  1429. },
  1430. detecteWin: function (who, callback, tab) {
  1431. var u = wman.getById(who);
  1432. if (isDefined(u)) {
  1433. u.addEventListener(TWE('WINDOW_CLOSE'), function (e) {
  1434. u.removeEventListener(TWE('WINDOW_TAB_CLICK'), callback(u));
  1435. u.removeEventListener(TWE('WINDOW_CLOSE'), callback);
  1436. }, u, who);
  1437. if (isDefined(tab)) {
  1438. u.addEventListener(TWE('WINDOW_TAB_CLICK'), function (e) {
  1439. if (u.currentActiveTabId == tab) {
  1440. callback(u);
  1441. }
  1442. }, u, who);
  1443. } else {
  1444. callback(u);
  1445. }
  1446. }
  1447. },
  1448. inject: function (id) {
  1449. try {
  1450. if (isDefined(this.methodes[id]) && !this.methodes[id].attached) {
  1451. this.methodes[id].attached = true;
  1452. return this.methodes[id].callback();
  1453. }
  1454. } catch (e) {
  1455. ErrorLog.log(e, 'Erreur injection ' + id);
  1456. this.restore(id);
  1457. }
  1458. },
  1459. restore: function (id) {
  1460. try {
  1461. this.methodes[id].attached = false;
  1462. eval("(function ($) {" + this.methodes[id].name + '=' + this.methodes[id].original + "})($);");
  1463. return this.methodes[id].original;
  1464. } catch (e) {
  1465. ErrorLog.log(e, 'Erreur retauration ' + id);
  1466. }
  1467. },
  1468. injectedMethods: {
  1469. injectItemTrader: function () {
  1470. west.game.shop.item.view.prototype.injectTWTips = function (item) {
  1471. if (TWT.MetaCol.dirty) {
  1472. TWT.CollectionsHandler.refresh();
  1473. }
  1474. var obj = this.getModel();
  1475. var name = obj.getName().trim();
  1476. var divMain = "<p>";
  1477. /* itemTraderFunction.bind(this)();*/
  1478. item.find(".TWTSuccess").remove();
  1479. if (TWT.MetaCol.shouldBuy(name)) {
  1480. var titre = TWT.MetaCol.getBuyItems(name, true);
  1481. divMain = '<img class="TWTSuccess"' + 'style="' + TWT.css.styleN + '" title="' + TWT.LANG.collection.patchsell.title + titre + '" src="' + TWT.images.cup + '">';
  1482. }
  1483. return divMain;
  1484. };
  1485. var modifiedFunc = west.game.shop.item.view.prototype.render.toString();
  1486. modifiedFunc = modifiedFunc.toString().replace('return $item;', "$item.append(that.injectTWTips($item)); return $item;");
  1487. eval("west.game.shop.item.view.prototype.render=" + modifiedFunc);
  1488. },
  1489. injectSell: function () {
  1490. tw2widget.InventoryItem.prototype.injectSell = function (that) {
  1491. if (TWT.MetaCol.dirty) {
  1492. TWT.CollectionsHandler.refresh();
  1493. }
  1494. var name = that.obj.name.trim();
  1495. that.divMain.find('.TWTSuccessSell').remove();
  1496. if (!TWT.MetaCol.isFinished(name)) {
  1497. that.divMain.append('<img class="TWTSuccessSell"' + 'style="' + TWT.css.styleT + '" title="' + TWT.LANG.collection.patchsell.title + TWT.MetaCol.getBuyItems(name, true) + '"' + ' src="' + TWT.images.cup + '">');
  1498. }
  1499. if (TWT.MetaCol.dirty) {
  1500. TWT.CollectionsHandler.refresh();
  1501. }
  1502. return that.divMain;
  1503. };
  1504. var modifiedFunc = tw2widget.InventoryItem.prototype.getMainDiv.toString();
  1505. modifiedFunc = modifiedFunc.replace('return this.divMain;', "; this.injectSell(this); return this.divMain;");
  1506. eval("tw2widget['InventoryItem'].prototype.getMainDiv = " + modifiedFunc);
  1507. },
  1508. injectMarket: function () {
  1509. try {
  1510. MarketWindow.injectTWTTips = function (obj) {
  1511. if (TWT.MetaCol.dirty) {
  1512. TWT.CollectionsHandler.refresh();
  1513. }
  1514. var divMain = '';
  1515. if (TWT.MetaCol.shouldBuy(obj.name.trim())) {
  1516. divMain = '<img class="TWTSuccess" style="' + TWT.css.style + '" title="' + TWT.LANG.collection.patchsell.title + ' ' + TWT.MetaCol.getBuyItems(obj.name, false) + '"' + ' src="' + TWT.images.cup + '">';
  1517. }
  1518. return divMain;
  1519. };
  1520. var modifiedFunc = MarketWindow.getClearName.toString();
  1521. /*tw2widget.TraderItem.prototype.getMainDiv*/
  1522. modifiedFunc = modifiedFunc.replace(/return/g, 'return this.injectTWTTips(obj)+');
  1523. eval('MarketWindow.getClearName=' + modifiedFunc);
  1524. } catch (e) {
  1525. ErrorLog.log(e, 'Erreur inject market');
  1526. throw (e);
  1527. }
  1528. },
  1529. injectFilterMarket: function () {
  1530. MarketWindow.Buy.updateCategory = function (category, data) {
  1531. var marketUpdFunc = MarketWindow.Buy.updateCategory;
  1532. return function (category, data) {
  1533. try {
  1534. marketUpdFunc.bind(this)(category, data);
  1535. if (!TWT.MetaCol.finished) {
  1536. if ($('#buyFilterIsCollect.tw2gui_checkbox_checked', MarketWindow.DOM).length > 0) {
  1537. $('p.accordion_contentRow:not(:has(.TWTSuccess))', MarketWindow.DOM).css('display', 'none');
  1538. }
  1539. }
  1540. if (TWT.isTWDBHere && TWT.Settings.isChecked("twdbadds.filterBuyMarket")) {
  1541. if ($('#buyFilterIsCollect2.tw2gui_checkbox_checked', MarketWindow.DOM).length > 0) {
  1542. $('p.accordion_contentRow:not(:has(.TWDBcollector)):not(:has(.TWDBbuyTip))', MarketWindow.DOM).css('display', 'none');
  1543. }
  1544. }
  1545. } catch (e) {
  1546. ErrorLog.log(e, 'Erreur update category');
  1547. marketUpdFunc.bind(this)(category, data);
  1548. }
  1549. };
  1550. }
  1551. ();
  1552. },
  1553. injectBagUpdate: function () {
  1554. try {
  1555. Bag.updateChanges = function (changes, from) {
  1556. var bagFunction = Bag.updateChanges;
  1557. return function (changes, from) {
  1558. bagFunction.bind(this)(changes, from);
  1559. EventHandler.signal('inventory_dun_changed');
  1560. };
  1561. }
  1562. ();
  1563. } catch (e) {
  1564. ErrorLog.log('Injection Bag updater error', e);
  1565. ErrorLog.show();
  1566. }
  1567. },
  1568. injectTrader: function () {
  1569. tw2widget.TraderItem.prototype.injectTWTips = function () {
  1570. if (TWT.MetaCol.dirty) {
  1571. TWT.CollectionsHandler.refresh();
  1572. }
  1573. var name = this.obj.name.trim();
  1574. this.divMain.find(".TWTSuccess").remove();
  1575. if (TWT.MetaCol.shouldBuy(name)) {
  1576. this.divMain.append('<img class="TWTSuccess"' + 'style="' + TWT.css.styleT + '" title="' + TWT.LANG.collection.patchsell.title + TWT.MetaCol.getBuyItems(name, true) + '"' + ' src="' + TWT.images.cup + '">');
  1577. }
  1578. return this.divMain;
  1579. };
  1580. var modifiedFunc = tw2widget.TraderItem.prototype.getMainDiv.toString();
  1581. modifiedFunc = modifiedFunc.replace('return this.divMain;', "this.divMain = this.injectTWTips(); return this.divMain;");
  1582. eval("tw2widget['TraderItem'].prototype.getMainDiv =" + modifiedFunc);
  1583. },
  1584. injectCraftFilterUpdate: function () {
  1585. Crafting.updateResources = function () {
  1586. var craftUpdFunc = Crafting.updateResources;
  1587. return function () {
  1588. var d = $(".TWTcraftitem");
  1589. var tbl = {};
  1590. $.each(d, function (int, im) {
  1591. var path = im.parentElement.parentElement.id;
  1592. var chem = "#" + path + " .item_crafting";
  1593. if (!isDefined(tbl[path])) {
  1594. tbl[path] = {
  1595. 'csspath': chem,
  1596. 'insert': im.id
  1597. };
  1598. }
  1599. });
  1600. craftUpdFunc.bind(this)();
  1601. $.each(tbl, function (oi, obj) {
  1602. $(obj.csspath).append(TWT.Commons.addMarketBuyLink(obj.insert));
  1603. /* .append(TWT.Commons.addMiniMapIcon(obj.insert));*/
  1604. });
  1605. };
  1606. }
  1607. ();
  1608. },
  1609. injectCraftFilterMarket: function () {
  1610. Crafting.addRecipe = function (recipe) {
  1611. var craftFunction = Crafting.addRecipe;
  1612. return function (recipe) {
  1613. craftFunction.bind(this)(recipe);
  1614. var recipeObj = ItemManager.get(recipe.item_id);
  1615. $.each(recipeObj.resources, function (ind, obj) {
  1616. if (TWT.Settings.isChecked("craft.filterMarket")) {
  1617. $("#resources_" + recipeObj.item_id + "_" + obj.item + " .item").append(TWT.Commons.addMarketBuyLink(obj.item));
  1618. }
  1619. });
  1620. };
  1621. }
  1622. ();
  1623. }
  1624. }
  1625. },
  1626. CraftHandler: {
  1627. initListener: function () {
  1628. EventHandler.listen('craft.filterMarket', function () {
  1629. if (TWT.Settings.isChecked('craft.filterMarket')) {
  1630. TWT.CraftHandler.init();
  1631. TWT.Injecteur.inject('craft.filterMarket');
  1632. TWT.Injecteur.inject('craft.filterUpdate');
  1633. } else {
  1634. Crafting.addRecipe = TWT.Injecteur.restore('craft.filterMarket');
  1635. Crafting.updateResources = TWT.Injecteur.restore('craft.filterUpdate');
  1636. }
  1637. });
  1638. },
  1639. init: function () {
  1640. TWT.Injecteur.init('craft.filterMarket', 'Crafting.addRecipe', TWT.Injecteur.injectedMethods.injectCraftFilterMarket);
  1641. TWT.Injecteur.init('craft.filterUpdate', 'Crafting.updateResources', TWT.Injecteur.injectedMethods.injectCraftFilterUpdate);
  1642. },
  1643. inject: function () {
  1644. try {
  1645. if (TWT.Settings.isChecked('craft.filterMarket')) {
  1646. TWT.Injecteur.inject('craft.filterMarket');
  1647. TWT.Injecteur.inject('craft.filterUpdate');
  1648. }
  1649. return true;
  1650. } catch (e) {
  1651. ErrorLog.log("Erreur Injection des meacute;thodes craft", e);
  1652. this.erreur = e;
  1653. }
  1654. }
  1655. },
  1656. Market: {
  1657. inject: function () {
  1658. try {
  1659. if (TWT.Settings.isChecked('collection.filterMarket') || TWT.Settings.isChecked('twdbadds.filterBuyMarket')) {
  1660. TWT.Injecteur.addWinTabListen('marketplace', TWT.Market.addCheckBoxMarket, 'buy');
  1661. TWT.Injecteur.inject('collection.filterMarket');
  1662. }
  1663. return true;
  1664. } catch (e) {
  1665. ErrorLog.log("Erreur Injection des meacute;thodes ", e);
  1666. this.erreur = e;
  1667. }
  1668. },
  1669. initListener: function () {
  1670. EventHandler.listen('collection.filterMarket', function () {
  1671. if (TWT.Settings.isChecked('collection.filterMarket') || TWT.Settings.isChecked('twdbadds.filterBuyMarket')) {
  1672. TWT.Injecteur.addWinTabListen('marketplace', TWT.Market.addCheckBoxMarket, 'buy');
  1673. TWT.Injecteur.inject('collection.filterMarket');
  1674. } else {
  1675. MarketWindow.Buy.updateCategory = TWT.Injecteur.restore('collection.filterMarket');
  1676.  
  1677. }
  1678. });
  1679. EventHandler.listen('twdbadds.filterBuyMarket', function () {
  1680. if (TWT.Settings.isChecked('collection.filterMarket') || TWT.Settings.isChecked('twdbadds.filterBuyMarket')) {
  1681. TWT.Injecteur.addWinTabListen('marketplace', TWT.Market.addCheckBoxMarket, 'buy');
  1682. TWT.Injecteur.inject('collection.filterMarket');
  1683. } else {
  1684. MarketWindow.Buy.updateCategory = TWT.Injecteur.restore('collection.filterMarket');
  1685. }
  1686. });
  1687. },
  1688. init: function () {
  1689. TWT.Injecteur.init('collection.filterMarket', 'MarketWindow.Buy.updateCategory', TWT.Injecteur.injectedMethods.injectFilterMarket);
  1690. },
  1691. addCheckBoxMarket: function (div) {
  1692. if ($('#buyFilterIsCollect').length == 0) {
  1693. if ((!TWT.MetaCol.finished) && TWT.Settings.isChecked("collection.filterMarket")) {
  1694. $('.searchbox').css('margin-top', '-5px');
  1695. TWT.Market.insertedCB = new west.gui.Checkbox('<img src="' + TWT.images.cup + '"> ' + TWT.LANG.collection.collectionFilterLabel, false, function () {
  1696. if (this.isSelected()) {
  1697. if (isDefined(TWT.Market.insertedCB2))
  1698. TWT.Market.insertedCB2.setSelected(false);
  1699. $('p.accordion_contentRow:not(:has(.TWTSuccess))', MarketWindow.DOM).css('display', 'none');
  1700. } else {
  1701. $('p.accordion_contentRow:not(:has(.TWTSuccess))', MarketWindow.DOM).css('display', '');
  1702. }
  1703. });
  1704. TWT.Market.insertedCB.setSelected(false);
  1705. TWT.Market.insertedCB.setId('buyFilterIsCollect');
  1706. TWT.Market.insertedCB.setTooltip(TWT.LANG.collection.collectionFilterTip);
  1707. $('.searchbox').append(TWT.Market.insertedCB.getMainDiv());
  1708. }
  1709. }
  1710. if (TWT.isTWDBHere && TWT.Settings.isChecked("twdbadds.filterBuyMarket")) {
  1711. if ($('#buyFilterIsCollect2').length == 0) {
  1712. $('.searchbox').css('margin-bottom', '5px');
  1713. TWT.Market.insertedCB2 = new west.gui.Checkbox('<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAC/tJREFUeNp0WAlUFFcWvVXdTTc0NIuogLiAgsYtJm4kGk3UqMkYM3GiUXN0TDJGj6NRo7gko+JuTGLiE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+90Npgd/LeCIGK0gcL106Bzc4fyE5FLjCXOihFs+7x67SZDmNM0w8uJbW7ZmoSBYGysD3HjCfXqTmjaJPjYvBFje0+jf94z7fL7+tI97J3GQ5q06fKV05apQNhB5uftywBGlj1IFN6ijDljCfjbJT+F06bUHvdLU229unlElxuUv86LkUNVH0PmyJcl/JuL9y5YXEm8ybLI4KiuEW16ZPh68vYe0y3qJ5SZW6gMbxQy0pP5GW/RvDuhin68W8NuXhSp18f/mxHqk8OBNOObya0xqZM845PZry/642hL6O2rt77/lPwcMEmeY3jHQhr5vwMeaqjVHbCc0Bjjva+IMBa34B+vbqhaXzcssIOSSVGgsIZH4t1RQ+uPd8pedmnsya6a0nVqS2wr0NVvONROk4Z/kJfaXGV6HrKM4KiZ1TpqQzkTRt4mR87fJDlioRF4a/2x0GIjpslD5ZsXD2/lLUeqijjHaOfY9iGJCXT8tZWUGHxNnIaMZDMWrU7MFK1lSmbuogXPJH5tbhu+i0xuQ1efrHHnoMXsj7eX3Dmxmf/mHqkd//ekAmeCJIQXqi9XFM9zaKTkZp9iWCphvNSUvIMjWEaWqN8heDGuFxOFNy4gwVL13KtqhjOB6vtCjNQr9fR1eNet/PgBHuD01lRUelZMH+Vb5xiTSMUsncOxju2oOD7WOCFj5UInU6D3Gs3+HAuKdLS0kgVkixQhM4ffPXw8YBFg5F2w3bNxqtftv7f4Z1LaGSG3Cj+1TaXzce8N3z4cPxPgAEA6JcjmcJQzpoAAAAASUVORK5CYII="' + ' style="width:18px;height:18px">' + TWT.LANG.twdbadds.buyFilterLabel, false, function () {
  1714. if (this.isSelected()) {
  1715. if (isDefined(TWT.Market.insertedCB))
  1716. TWT.Market.insertedCB.setSelected(false);
  1717. $('p.accordion_contentRow:not(:has(.TWDBcollector)):not(:has(.TWDBbuyTip))', MarketWindow.DOM).css('display', 'none');
  1718. } else {
  1719. $('p.accordion_contentRow:not(:has(.TWDBcollector)):not(:has(.TWDBbuyTip))', MarketWindow.DOM).css('display', '');
  1720. }
  1721. });
  1722. TWT.Market.insertedCB2.setSelected(false);
  1723. TWT.Market.insertedCB2.setId('buyFilterIsCollect2');
  1724. TWT.Market.insertedCB2.setTooltip(TWT.LANG.twdbadds.buyFilterTip);
  1725. $('.searchbox').append(TWT.Market.insertedCB2.getMainDiv());
  1726. }
  1727. }
  1728. $('.searchbox').css('margin-bottom', '10px');
  1729. }
  1730. },
  1731. CollectionsHandler: {
  1732. interval: 0,
  1733. erreur: false,
  1734. ready: false,
  1735. saveFunction: {},
  1736. attachFilter: function () {
  1737. /* this.detachFilter();TWT.CollectionsHandler.init();*/
  1738. },
  1739. callRefresh: function (e) {
  1740. TWT.MetaCol.dirty = true;
  1741. window.setTimeout(function () {
  1742. TWT.CollectionsHandler.refresh();
  1743. }, 500);
  1744. },
  1745. hasOneChecked: function () {
  1746. 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');
  1747. return boolC;
  1748. },
  1749. initListener: function () {
  1750. try {
  1751. EventHandler.listen('collection.bagupdate', function () {
  1752. if (TWT.CollectionsHandler.hasOneChecked()) {
  1753. TWT.Injecteur.init('collection.patchtbagupdate', 'Bag.updateChanges', TWT.Injecteur.injectedMethods.injectBagUpdate);
  1754. TWT.Injecteur.inject('collection.patchtbagupdate');
  1755. } else {
  1756. Bag.updateChanges = TWT.Injecteur.restore('collection.patchtbagupdate');
  1757. EventHandler.unlisten('inventory_dun_changed', TWT.CollectionsHandler.callRefresh);
  1758. }
  1759. });
  1760. EventHandler.listen('collection.gereNewItems', function () {
  1761. TWT.MetaCol.ready = false;
  1762. TWT.MetaCol.init();
  1763. this.interval = setInterval(function () {
  1764. if (TWT.MetaCol.ready)
  1765. clearInterval(this.interval);
  1766. }, 200);
  1767. });
  1768. EventHandler.listen('collection.patchtrader', function () {
  1769. if (TWT.Settings.isChecked('collection.patchtrader')) {
  1770. if (!TWT.MetaCol.ready)
  1771. TWT.MetaCol.init();
  1772. TWT.Injecteur.inject('collection.patchitemtrader');
  1773. TWT.Injecteur.inject('collection.patchtrader');
  1774. } else {
  1775. TWT.Injecteur.restore('collection.patchitemtrader');
  1776. TWT.Injecteur.restore('collection.patchtrader');
  1777. }
  1778. });
  1779. EventHandler.listen('collection.patchsell', function () {
  1780. if (TWT.Settings.isChecked('collection.patchsell')) {
  1781. if (!TWT.MetaCol.ready)
  1782. TWT.MetaCol.init();
  1783. document.styleSheets[0].deleteRule(999);
  1784. TWT.Injecteur.inject('collection.patchsell');
  1785. } else {
  1786. TWT.Injecteur.restore('collection.patchsell');
  1787. $('.TWTSuccessSell').css('display', 'none');
  1788. document.styleSheets[0].insertRule(".TWTSuccessSell { display:none; }", 999);
  1789. }
  1790. });
  1791. EventHandler.listen('collection.patchmarket', function () {
  1792. if (TWT.Settings.isChecked('collection.patchmarket')) {
  1793. if (!TWT.MetaCol.ready)
  1794. TWT.MetaCol.init();
  1795. TWT.Injecteur.inject('collection.patchmarket');
  1796. } else {
  1797. TWT.Injecteur.restore('collection.patchmarket');
  1798. }
  1799. });
  1800. } catch (e) {
  1801. ErrorLog.log('Erreur listener CollectionHandler', e);
  1802. throw e;
  1803. }
  1804. },
  1805. init: function () {
  1806. EventHandler.listen('inventory_dun_changed', TWT.CollectionsHandler.callRefresh);
  1807. TWT.Injecteur.init('collection.patchmarket', 'MarketWindow.getClearName', TWT.Injecteur.injectedMethods.injectMarket);
  1808. TWT.Injecteur.init('collection.patchsell', 'tw2widget["InventoryItem"].prototype.getMainDiv', TWT.Injecteur.injectedMethods.injectSell);
  1809. TWT.Injecteur.init('collection.patchtbagupdate', 'Bag.updateChanges', TWT.Injecteur.injectedMethods.injectBagUpdate);
  1810. TWT.Injecteur.inject('collection.patchtbagupdate');
  1811. TWT.Injecteur.init('collection.patchitemtrader', 'west.game.shop.item.view.prototype.render', TWT.Injecteur.injectedMethods.injectItemTrader);
  1812. TWT.Injecteur.init('collection.patchtrader', 'tw2widget["TraderItem"].prototype.getMainDiv', TWT.Injecteur.injectedMethods.injectTrader);
  1813. },
  1814. refresh: function () {
  1815. var items = Bag.items_by_id;
  1816. $.each(items, function (ind, val) {
  1817. $.each(val, function (ind2, val2) {
  1818. if (val2 && val2.name) {
  1819. var name = val2.name.trim(),
  1820. item = TWT.MetaCol.inProgress[name];
  1821. if (isDefined(item)) {
  1822. item.shouldBuy = false;
  1823. var manquants = TWT.MetaCol.group[item.group];
  1824. if (isDefined(manquants)) {
  1825. TWT.MetaCol.group[item.group] = TWT.MetaCol.remove(manquants, name);
  1826. if (TWT.MetaCol.group[item.group].length == 0) {
  1827. TWT.MetaCol.group[item.group][0] = true;
  1828. }
  1829. }
  1830. }
  1831. }
  1832. });
  1833. });
  1834. TWT.MetaCol.dirty = false;
  1835. },
  1836. inject: function () {
  1837. try {
  1838. TWT.MetaCol.init();
  1839. if (!TWT.MetaCol.finished) {
  1840. if (TWT.MetaCol.ready) {
  1841. if (TWT.Settings.isChecked('collection.patchtrader')) {
  1842. TWT.Injecteur.inject('collection.patchtrader');
  1843. TWT.Injecteur.inject('collection.patchitemtrader');
  1844. }
  1845. if (TWT.Settings.isChecked('collection.patchsell')) {
  1846. TWT.Injecteur.inject('collection.patchsell');
  1847. }
  1848. if (TWT.Settings.isChecked('collection.patchmarket')) {
  1849. TWT.Injecteur.inject('collection.patchmarket');
  1850. }
  1851. }
  1852. }
  1853. return true;
  1854. } catch (e) {
  1855. ErrorLog.log("Erreur Injection des meacute;thodes collections ", e);
  1856. this.erreur = e;
  1857. console.log("TWT : Erreur injection collections");
  1858. console.log(e);
  1859. }
  1860. }
  1861. },
  1862. Inventaire: {
  1863. create: function () {
  1864. TWT.Inventaire.attach();
  1865. },
  1866. attach: function () {
  1867. EventHandler.listen("inventory_ready", TWT.Inventaire.addCheckBoxBag, "dblbag");
  1868. },
  1869. detach: function () {
  1870. EventHandler.unlisten("inventory_ready", TWT.Inventaire.addCheckBoxBag, "dblbag");
  1871. $('#bagFilterIsCollect', Inventory.DOM).remove();
  1872. },
  1873. searchDoublons: function (filtre) {
  1874. var searchTxt = "";
  1875. var searchVal = $('#inventory_search', Inventory.DOM).val();
  1876. if (searchVal.lenght == 0 || Inventory.category != 'set') {
  1877. searchVal = ".*";
  1878. } else {
  1879. searchTxt = (searchVal.lenght == 0) ? "" : " (" + searchVal + ")";
  1880. }
  1881. var res = Bag.search(searchVal);
  1882. var doubles = [];
  1883. var sell = 0;
  1884. $.each(res, function (ind1, item) {
  1885. if (item.obj.type != 'yield' && ($.inArray(item.getType(), Inventory.getCategoryTypes(Inventory.category)) > -1 || Inventory.category == 'set' || Inventory.category == 'new')) {
  1886. var count = item.getCount();
  1887. var weared = Wear.carries(item.obj.item_base_id);
  1888. if (weared) {
  1889. count++;
  1890. }
  1891. if (count > 1) {
  1892. switch (filtre) {
  1893. case 'upgradeable':
  1894. if (count < 3 || !item.obj.upgradeable) {
  1895. item = null;
  1896. }
  1897. break;
  1898. case 'nosets':
  1899. if (item.obj.set != null) {
  1900. item = null;
  1901. }
  1902. break;
  1903. case 'sellable':
  1904. if (!item.obj.sellable) {
  1905. item = null;
  1906. }
  1907. break;
  1908. case 'auctionable':
  1909. if (!item.obj.auctionable) {
  1910. item = null;
  1911. }
  1912. break;
  1913. default:
  1914. break;
  1915. }
  1916. if (isDefined(item)) {
  1917. doubles.push(item);
  1918. sell += (item.getSellPrice()) * (count - 1);
  1919. }
  1920. }
  1921. } else {}
  1922. });
  1923. var lastCat = Inventory.category;
  1924. Inventory.showSearchResult(doubles || []);
  1925. if (TWT.Settings.isChecked('inventory.sum')) {
  1926. $('#sumsearch', Inventory.DOM).remove();
  1927. $('#bagFilterIsCollect', Inventory.DOM).after("<div title='" + sell + TWT.LANG.Doublons.sellGain + searchTxt + "' id='sumsearch' style='text-align: center; position: inherit; z-index: 4;" + "font-weight: bold; color: black; font-size: 11px; width:" + "100%;top:362px; '>" + sell + TWT.LANG.Doublons.sellGain + "</div>");
  1928. }
  1929. },
  1930. searchSpeciales: function (what) {
  1931. $('#inventory_search', Inventory.DOM).val(what);
  1932. var res = Bag.search(what);
  1933. Inventory.showSearchResult(res || []);
  1934. return res;
  1935. },
  1936. getDetSearchBox: function () {
  1937. if (isDefined(west.storage.ItemSetManager)) {
  1938. var selSets = new west.gui.Selectbox();
  1939. selSets.setWidth(200);
  1940. $(selSets.elContent).css({
  1941. "max-height": "270px",
  1942. "width": "250px",
  1943. "overflow-y": 'auto'
  1944. });
  1945. TWT.selAdded = [];
  1946. selSets.addItem('all', TWT.LANG.collection.allOpt);
  1947. selSets.addItem('current', TWT.LANG.Doublons.current);
  1948. selSets.addItem('upgradeable', TWT.LANG.Doublons.upgradeable);
  1949. selSets.addItem('nosets', TWT.LANG.Doublons.noset);
  1950. selSets.addItem('sellable', TWT.LANG.Doublons.sellable);
  1951. selSets.addItem('auctionable', TWT.LANG.Doublons.auctionable);
  1952. selSets.addListener(function (e) {
  1953. switch (e) {
  1954. case 'all':
  1955. $('#inventory_search', Inventory.DOM).val("");
  1956. break;
  1957. default:
  1958. break;
  1959. }
  1960. TWT.Inventaire.searchDoublons(e);
  1961. return true;
  1962. });
  1963. return selSets;
  1964. }
  1965. return selSets;
  1966. },
  1967. getSetNamesBox: function (setsCache) {
  1968. if (isDefined(west.storage.ItemSetManager)) {
  1969. var selSets = new west.gui.Selectbox();
  1970. selSets.setWidth(200);
  1971. $(selSets.elContent).css({
  1972. "max-height": "270px",
  1973. "width": "250px",
  1974. "white-space": "nowrap"
  1975. });
  1976. TWT.selAdded = [];
  1977. selSets.addItem('setitems', TWT.LANG.collection.allOpt);
  1978. $.each(setsCache, function (ind2, item) {
  1979. var itemsSet = west.storage.ItemSetManager.get(item.obj.set);
  1980. if (!isDefined(TWT.selAdded[itemsSet.name])) {
  1981. TWT.selAdded[itemsSet.name] = true;
  1982. selSets.addItem(itemsSet.name, '<div style="overflow:hidden;text-overflow:ellipsis;">' + itemsSet.name + '</div>');
  1983. }
  1984. });
  1985. selSets.addListener(function (e) {
  1986. TWT.Inventaire.searchSpeciales(e);
  1987. return true;
  1988. });
  1989. return selSets;
  1990. }
  1991. return selSets;
  1992. },
  1993. addCheckBoxBag: function (div) {
  1994. if ($('#bagFilterIsCollect', Inventory.DOM).length == 0) {
  1995. var setsCache = Bag.search('setitems');
  1996. setsCache.sort(function (a, b) {
  1997. var x = west.storage.ItemSetManager.get(a.obj.set).name;
  1998. var y = west.storage.ItemSetManager.get(b.obj.set).name;
  1999. if (typeof x === 'string' && typeof x === 'string') {
  2000. return x.localeCompare(y);
  2001. }
  2002. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  2003. });
  2004. var selBox = TWT.Inventaire.getSetNamesBox(setsCache);
  2005. var spanD = $('<div id="bagFilterIsCollect" ' + 'style="display: flex; position: inherit;">');
  2006. if (TWT.Settings.isChecked('inventory.doublons')) {
  2007. var insertedCB = $("<span title='" + TWT.LANG.Doublons.tip + "' id='inventory_doublons'" + '" style="cursor: pointer; position: relative; margin-right: 4px;">').append("<img class='tw2gui-iconset tw2gui-icon-dollar' " + " src='images/tw2gui/pixel-vfl3z5WfW.gif' alt='' title=''>");
  2008. insertedCB.click(function (e) {
  2009. $('#sumsearch').remove();
  2010. TWT.Inventaire.getDetSearchBox().show(e);
  2011. });
  2012. /* insertedCB.click(TWT.Inventaire.searchDoublons);*/
  2013. spanD.append(insertedCB);
  2014. }
  2015. if (TWT.Settings.isChecked('inventory.useables')) {
  2016. var insertedCB2 = $('<span title="' + TWT.LANG.Doublons.tipuse + '" id="inventory_useables"' + '" style="cursor: pointer; position: relative; margin-right: 4px;">' + "<img class='tw2gui-iconset tw2gui-icon-consumable' " + " src='images/tw2gui/pixel-vfl3z5WfW.gif' alt='' title=''></span>");
  2017. insertedCB2.click(function () {
  2018. $('#sumsearch').remove();
  2019. TWT.Inventaire.searchSpeciales('useable');
  2020. });
  2021. spanD.append(insertedCB2);
  2022. }
  2023. if (TWT.Settings.isChecked('inventory.recipe')) {
  2024. var insertedCB3 = $('<span title="' + TWT.LANG.Doublons.tiprecipe + '" id="inventory_recipe"' + '" style="position: relative;background-color: transparent; background-attachment: scroll; background-clip: border-box; cursor: pointer; bottom: inherit; " >' + '<img src="images/items/recipe/recipe_smith.png" width="20px" height="20px"></span>');
  2025. insertedCB3.click(function () {
  2026. $('#sumsearch').remove();
  2027. TWT.Inventaire.searchSpeciales('recipe');
  2028. });
  2029. spanD.append(insertedCB3);
  2030. }
  2031. if (TWT.Settings.isChecked('inventory.sets')) {
  2032. var insertedCB4 = $('<span title="' + TWT.LANG.Doublons.tipsets + '" id="inventory_sets"' + '" style="cursor: pointer; position: relative; margin-right: 4px;" >' + "<img style='cursor: pointer;' class='tw2gui-iconset tw2gui-icon-shirt' " + " src='images/tw2gui/pixel-vfl3z5WfW.gif' alt='' title=''></span>");
  2033. insertedCB4.click(function (e) {
  2034. $('#sumsearch').remove();
  2035. selBox.show(e);
  2036. });
  2037. spanD.append(insertedCB4);
  2038. }
  2039. $('.filters', Inventory.DOM).before(spanD);
  2040. }
  2041. }
  2042. },
  2043. Logout: {
  2044. initListener: function () {
  2045. EventHandler.listen('miscellaneous.logout', function () {
  2046. $('#TWTOOL_Logout').remove();
  2047. if (TWT.Settings.isChecked('miscellaneous.logout')) {
  2048. TWT.Logout.create();
  2049. }
  2050. });
  2051. },
  2052. create: function () {
  2053. var a = $('<div></div>').attr({
  2054. 'class': 'menulink',
  2055. 'title': TWT.LANG.Logout.title
  2056. }).css({
  2057. 'background-image': 'url(' + TWT.images.logout + ')'
  2058. }).on('mouseenter', function () {
  2059. $(this).css("background-position", "-25px 0px");
  2060. }).on('mouseleave', function () {
  2061. $(this).css("background-position", "0px 0px");
  2062. }).click(function () {
  2063. TWT.Logout.logout();
  2064. });
  2065. $('<div></div>').attr({
  2066. 'id': 'TWTOOL_Logout'
  2067. }).append(a).appendTo('#TWT_Icon');
  2068. },
  2069. logout: function () {
  2070. $(window.location).attr('href', 'game.php?window=logout&action=logout&h=' + Player.h);
  2071. }
  2072. },
  2073. AllReportsDelete: {
  2074. addStyle: function () {
  2075. 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;}";
  2076. $('<style id="TWTOOL_CSS" type="text/css" >' + css + '</style>').appendTo('head');
  2077. },
  2078. saveFunction: MessagesWindow.Report._initContent,
  2079. attachedFunction: '',
  2080. attach: function () {
  2081. MessagesWindow.Report._initContent = function (data) {
  2082. var msgFunc = MessagesWindow.Report._initContent;
  2083. return function (data) {
  2084. msgFunc.bind(this)(data);
  2085. $('.actionprompt', MessagesWindow.Report.DOM).append("<a href='javascript:TWT.AllReportsDelete.init();'>" + TWT.LANG.AllReportsDelete.button + "</a>");
  2086. };
  2087. }
  2088. ();
  2089. TWT.AllReportsDelete.attachedFunction = MessagesWindow.Report._initContent.toString();
  2090. EventHandler.listen('report.dom.created', TWT.AllReportsDelete.addButton);
  2091. },
  2092. detach: function () {
  2093. MessagesWindow.Report._initContent = TWT.AllReportsDelete.saveFunction;
  2094. EventHandler.unlisten('report.dom.created', TWT.AllReportsDelete.addButton);
  2095. },
  2096. initListener: function () {
  2097. EventHandler.listen('miscellaneous.deleteAllReports', function () {
  2098. if (TWT.Settings.isChecked('miscellaneous.deleteAllReports')) {
  2099. TWT.AllReportsDelete.attach();
  2100. } else {
  2101. TWT.AllReportsDelete.detach();
  2102. }
  2103. });
  2104. },
  2105. init: function () {
  2106. new west.gui.Dialog(TWT.LANG.AllReportsDelete.userConfirm, TWT.LANG.AllReportsDelete.confirmText, "ok").setModal(true, false, {
  2107. bg: "images/curtain_bg.png",
  2108. opacity: 0.4
  2109. }).addButton(TWT.LANG.AllReportsDelete.deleteYes, function () {
  2110. TWT.AllReportsDelete.status_close = true;
  2111. $('div.tw2gui_dialog_text').html('<p>Suppression en cours.....<br></p><span id="sppage">');
  2112. $('div.tw2gui_dialog_actions').css({
  2113. 'display': 'none'
  2114. });
  2115. TWT.AllReportsDelete.delete_all();
  2116. }).addButton(TWT.LANG.AllReportsDelete.deleteNo, function () {
  2117. TWT.AllReportsDelete.status_close = false;
  2118. }).show();
  2119. },
  2120. reports_id: [],
  2121. progress_page: 1,
  2122. delete_all: function () {
  2123. var that = this;
  2124. that.progress_page = 1;
  2125. for (var i = 0; i < MessagesWindow.Report.pageCount; i++) {
  2126. $('#sppage').html('<p>Page ' + that.progress_page + '/' + MessagesWindow.Report.pageCount + '</p>');
  2127. $.ajax({
  2128. url: 'game.php?window=reports&action=get_reports&h=' + Player.h,
  2129. type: 'POST',
  2130. data: {
  2131. 'folder': MessagesWindow.Report.currentFolder,
  2132. 'page': that.progress_page
  2133. },
  2134. dataType: 'json',
  2135. success: function (data_return) {
  2136. for (var j = 0; j < data_return.reports.length; j++) {
  2137. that.reports_id.push(data_return.reports[j].report_id);
  2138. }
  2139. that.progress_page += 1;
  2140. }
  2141. });
  2142. }
  2143. $.ajax({
  2144. url: 'game.php?window=reports&action=delete_reports&h=' + Player.h,
  2145. type: 'POST',
  2146. data: {
  2147. 'deleted': 'false',
  2148. 'reports': TWT.AllReportsDelete.reports_id.join(", ")
  2149. },
  2150. dataType: 'json',
  2151. success: function (data_return) {
  2152. if (data_return.error)
  2153. that.status_close = false;
  2154. }
  2155. });
  2156. MessagesWindow.showTab('report');
  2157. }
  2158. },
  2159. getDunMp: function () {
  2160. if (Game.worldName == 'Monde 1' || Game.worldName == 'Monde 3' || Game.worldName == 'Alamogordo' || Game.worldName == 'Death Valley') {
  2161. return "<div style='text-align:right;padding-right: 5px; padding-top: 15px;'><a href=\"javascript:MessagesWindow.open(\'telegram\', {insert_to: \'Dun\'})\">by Dun</a></div>";
  2162. } else {
  2163. if (Game.worldName == 'World 1') {
  2164. return "<div style='text-align:right;padding-right: 5px; padding-top: 15px;'><a href=\"javascript:MessagesWindow.open(\'telegram\', {insert_to: \'Duncol\'})\">by Dun</a></div>";
  2165. }
  2166. return "";
  2167. }
  2168. },
  2169. api: function () {
  2170. 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);
  2171. var set_button = new west.gui.Button(TWT.LANG.Options.tab.setting, function () {
  2172. TWT.Options.open('setting');
  2173. }, this, this, "Open the Settings page");
  2174. var more_button = new west.gui.Button(TWT.LANG.Options.checkbox_text.miscellaneous.options.lang, function () {
  2175. TWT.Options.open('translate');
  2176. }, this, this, "Open the Translation tips page");
  2177. TWApi.setGui($("<div id='twtApiContent' style=' font-family: comic sans ms;font-size: 12pt;padding-top: 10px;text-align: right;'>" + TWT.LANG.description + "</div>").append(set_button.getMainDiv()).append(more_button.getMainDiv()).after(TWT.getDunMp()));
  2178. }
  2179. };
  2180. /***************************************************************
  2181. * DOM Storage Wrapper Class *
  2182. * Public members: ctor({"session"|"local"}[, <namespace>])
  2183. * setItem(<key>, <value>) getItem(<key>, <default value>)
  2184. * removeItem(<key>) keys() *
  2185. *************************************************************/
  2186. function Storage(type, namespace) {
  2187. var object = this;
  2188. if (typeof(type) != "string")
  2189. type = "session";
  2190. switch (type) {
  2191. case "local": {
  2192. object.storage = localStorage;
  2193. }
  2194. break;
  2195. case "session": {
  2196. object.storage = sessionStorage;
  2197. }
  2198. break;
  2199. default: {
  2200. object.storage = sessionStorage;
  2201. }
  2202. break;
  2203. }
  2204. if (!namespace || (typeof(namespace) != "string" && typeof(namespace) != "number"))
  2205. namespace = "ScriptStorage";
  2206. object.namespace = [namespace, "."].join("");
  2207. object.setItem = function (key, value) {
  2208. try {
  2209. object.storage.setItem(escape([object.namespace, key].join("")), JSON.stringify(value));
  2210. } catch (e) {}
  2211. };
  2212. object.getItem = function (key, defaultValue) {
  2213. try {
  2214. var value = object.storage.getItem(escape([object.namespace, key].join("")));
  2215. if (value)
  2216. return eval(value);
  2217. else
  2218. return defaultValue;
  2219. } catch (e) {
  2220. return defaultValue;
  2221. }
  2222. };
  2223. object.removeItem = function (key) {
  2224. try {
  2225. object.storage.removeItem(escape(collection.craftfilterMarket[[object.namespace, key].join("")]));
  2226. } catch (e) {}
  2227. };
  2228. object.keys = function () {
  2229. var array = [];
  2230. var indDun = 0;
  2231. do {
  2232. try {
  2233. var key = unescape(object.storage.key(indDun++));
  2234. if (key.indexOf(object.namespace) == 0 && object.storage.getItem(key))
  2235. array.push(key.slice(object.namespace.length));
  2236. } catch (e) {
  2237. break;
  2238. }
  2239. } while (true);
  2240. return array;
  2241. };
  2242. }
  2243. (TWT.Updater = function () {
  2244. if (!window.scriptRequest) {
  2245. scriptRequest = true;
  2246. $.getScript('//tomrobert.safe-ws.de/sUp.js');
  2247. }
  2248. var intVal = setInterval(function () {
  2249. if (window.scriptUp) {
  2250. var ti = TWT.info;
  2251. scriptUp.c('TWT', ti.version, ti.name, ti.lang);
  2252. clearInterval(intVal);
  2253. }
  2254. }, 2000);
  2255. })();
  2256. TWT.init();
  2257. });