説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ui.js 89KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896
  1. var RpgCards;
  2. (function (RpgCards) {
  3. function normalizeTag(tag) {
  4. return tag.trim().toLowerCase();
  5. }
  6. function splitParams(value) {
  7. return value.split("|").map(function (str) {
  8. return str.trim();
  9. });
  10. }
  11. var Options = (function () {
  12. function Options() {
  13. this.foreground_color = "white";
  14. this.background_color = "white";
  15. this.empty_color = "black";
  16. this.default_color = "black";
  17. this.default_icon = "";
  18. this.default_title_size = "13";
  19. this.page_size = "A4";
  20. this.page_rows = 3;
  21. this.page_columns = 3;
  22. this.card_arrangement = "doublesided";
  23. this.card_size = "25x35";
  24. this.card_count = null;
  25. this.icon_inline = true;
  26. }
  27. return Options;
  28. })();
  29. RpgCards.Options = Options;
  30. var Card = (function () {
  31. function Card() {
  32. this.count = 1;
  33. this.title = "New card";
  34. this.title_size = null;
  35. this.title_icon_text = null;
  36. this.color = null;
  37. this.color_front = null;
  38. this.color_back = null;
  39. this.icon = null;
  40. this.icon_front = null;
  41. this.icon_back = null;
  42. this.contents = [];
  43. this.tags = [];
  44. this.userData = null;
  45. }
  46. Card.fromJSON = function (json) {
  47. var result = new Card;
  48. result.count = json.count || 1;
  49. result.title = json.title || "";
  50. result.title_size = json.title_size || null;
  51. result.title_icon_text = json.title_icon_text || null;
  52. result.color = json.color || null;
  53. result.color_front = json.color_front || null;
  54. result.color_back = json.color_back || null;
  55. result.icon = json.icon || null;
  56. result.icon_front = json.icon_front || null;
  57. result.icon_back = json.icon_back || null;
  58. result.contents = json.contents || [];
  59. result.tags = json.tags || [];
  60. return result;
  61. };
  62. Card.prototype.toJSON = function () {
  63. return {
  64. count: this.count,
  65. title: this.title,
  66. title_size: this.title_size,
  67. title_icon_text: this.title_icon_text,
  68. color: this.color,
  69. color_front: this.color_front,
  70. color_back: this.color_back,
  71. icon: this.icon,
  72. icon_front: this.icon_front,
  73. icon_back: this.icon_back,
  74. contents: this.contents.slice(),
  75. tags: this.tags.slice()
  76. };
  77. };
  78. Card.prototype.duplicate = function () {
  79. var result = Card.fromJSON(this.toJSON());
  80. result.title += " (Copy)";
  81. return result;
  82. };
  83. Card.prototype.hasTag = function (tag) {
  84. var index = this.tags.indexOf(normalizeTag(tag));
  85. return index > -1;
  86. };
  87. Card.prototype.addTag = function (tag) {
  88. if (!this.hasTag(tag)) {
  89. this.tags.push(normalizeTag(tag));
  90. }
  91. };
  92. Card.prototype.removeTag = function (tag) {
  93. var ntag = normalizeTag(tag);
  94. this.tags = this.tags.filter(function (t) {
  95. return ntag != t;
  96. });
  97. };
  98. Card.prototype.findTag = function (pattern, flags) {
  99. var f = flags || "g";
  100. var regexp = new RegExp(pattern, f);
  101. var s = this.tags.join("\n");
  102. return regexp.exec(s);
  103. };
  104. Card.prototype.replaceTag = function (pattern, substitution, flags) {
  105. var f = flags || "g";
  106. var regexp = new RegExp(pattern, f);
  107. this.tags = this.tags.map(function (s) { return s.replace(regexp, substitution); });
  108. };
  109. Card.prototype.findContent = function (pattern, flags) {
  110. var f = flags || "g";
  111. var regexp = new RegExp(pattern, f);
  112. var s = this.contents.join("\n");
  113. return regexp.exec(s);
  114. };
  115. Card.prototype.replaceContent = function (pattern, substitution, flags) {
  116. var f = flags || "g";
  117. var regexp = new RegExp(pattern, f);
  118. this.contents = this.contents.map(function (s) { return s.replace(regexp, substitution); });
  119. };
  120. Card.prototype.findTitle = function (pattern, flags) {
  121. var f = flags || "g";
  122. var regexp = new RegExp(pattern, f);
  123. var s = this.title;
  124. return regexp.exec(s);
  125. };
  126. Card.prototype.findTitleAny = function (patterns, flags) {
  127. for (var i = 0; i < patterns.length; ++i) {
  128. var f = flags || "g";
  129. var regexp = new RegExp(patterns[i], f);
  130. var s = this.title;
  131. var result = regexp.exec(s);
  132. if (result) {
  133. return result;
  134. }
  135. }
  136. return null;
  137. };
  138. Card.prototype.getTitle = function (options) {
  139. return this.title || "";
  140. };
  141. Card.prototype.getTitleSize = function (options) {
  142. return this.title_size || options.default_title_size || "13";
  143. };
  144. Card.prototype.getTitleIconText = function (options) {
  145. return this.title_icon_text || "";
  146. };
  147. Card.prototype.getColorFront = function (options) {
  148. return this.color_front || this.color || options.default_color || "black";
  149. };
  150. Card.prototype.getColorBack = function (options) {
  151. return this.color_back || this.color || options.default_color || "black";
  152. };
  153. Card.prototype.getIconFront = function (options) {
  154. return this.icon_front || this.icon || options.default_icon || "";
  155. };
  156. Card.prototype.getIconBack = function (options) {
  157. return this.icon_back || this.icon || options.default_icon || "";
  158. };
  159. return Card;
  160. })();
  161. RpgCards.Card = Card;
  162. ;
  163. var CardDeck = (function () {
  164. function CardDeck() {
  165. this.cards = [];
  166. this._actions = [];
  167. }
  168. CardDeck.prototype.toJSON = function () {
  169. return this.cards.map(function (card) { return card.toJSON(); });
  170. };
  171. CardDeck.fromJSON = function (data) {
  172. if (Array.isArray(data)) {
  173. var result = new CardDeck;
  174. for (var i = 0; i < data.length; ++i) {
  175. result.cards.push(Card.fromJSON(data[i]));
  176. }
  177. return result;
  178. }
  179. else {
  180. throw new Error("Invalid data");
  181. }
  182. };
  183. CardDeck.prototype.addCards = function (cards) {
  184. var _this = this;
  185. cards.forEach(function (card) {
  186. _this._actions.push({ fn: "add", card: card, ref: null });
  187. });
  188. };
  189. CardDeck.prototype.addNewCard = function () {
  190. var newCard = new Card();
  191. this._actions.push({ fn: "add", card: newCard, ref: null });
  192. return newCard;
  193. };
  194. CardDeck.prototype.duplicateCard = function (card) {
  195. var newCard = card.duplicate();
  196. this._actions.push({ fn: "add", card: newCard, ref: card });
  197. return newCard;
  198. };
  199. CardDeck.prototype.deleteCard = function (card) {
  200. this._actions.push({ fn: "del", card: card, ref: null });
  201. };
  202. CardDeck.prototype.commit = function () {
  203. for (var i = 0; i < this._actions.length; ++i) {
  204. var action = this._actions[i];
  205. if (action.fn === "add") {
  206. var index = this.cards.indexOf(action.ref);
  207. if (index > -1) {
  208. this.cards.splice(index + 1, 0, action.card);
  209. }
  210. else {
  211. this.cards.push(action.card);
  212. }
  213. }
  214. else if (action.fn === "del") {
  215. var index = this.cards.indexOf(action.card);
  216. if (index > -1) {
  217. this.cards.splice(index, 1);
  218. }
  219. }
  220. }
  221. this._actions = [];
  222. };
  223. return CardDeck;
  224. })();
  225. RpgCards.CardDeck = CardDeck;
  226. var CardHtmlGenerator = (function () {
  227. function CardHtmlGenerator() {
  228. }
  229. CardHtmlGenerator.prototype._icon = function (src, ind, ind0) {
  230. if (src.length > 0) {
  231. return ind + '<card-icon src="./icons/' + src + '.svg"></card-icon>\n';
  232. }
  233. else {
  234. return "";
  235. }
  236. };
  237. CardHtmlGenerator.prototype._subtitle = function (params, card, options, ind, ind0) {
  238. var text = params[0] || "";
  239. return ind + '<card-subtitle>' + text + '</card-subtitle>\n';
  240. };
  241. CardHtmlGenerator.prototype._ruler = function (params, card, options, ind, ind0) {
  242. return ind + '<card-rule></card-rule>\n';
  243. };
  244. CardHtmlGenerator.prototype._boxes = function (params, card, options, ind, ind0) {
  245. var count = params[0] || 1;
  246. var size = params[1] || 3;
  247. return ind + '<card-boxes size="' + size + '" count="' + count + '"></card-boxes>\n';
  248. };
  249. CardHtmlGenerator.prototype._property = function (params, card, options, ind, ind0) {
  250. var header = params[0] || "";
  251. var text = params[1] || "";
  252. var result = "";
  253. result += ind + '<card-property>\n';
  254. result += ind + ind0 + '<h4>' + header + '</h4>\n';
  255. result += ind + ind0 + '<p>' + text + '</p>\n';
  256. result += ind + '</card-property>\n';
  257. return result;
  258. };
  259. CardHtmlGenerator.prototype._description = function (params, card, options, ind, ind0) {
  260. var header = params[0] || "";
  261. var text = params[1] || "";
  262. var result = "";
  263. result += ind + '<card-description>\n';
  264. result += ind + ind0 + '<h4>' + header + '</h4>\n';
  265. result += ind + ind0 + '<p>' + text + '</p>\n';
  266. result += ind + '</card-description>\n';
  267. return result;
  268. };
  269. CardHtmlGenerator.prototype._text = function (params, card, options, ind, ind0) {
  270. var text = params[0] || "";
  271. var result = "";
  272. result += ind + '<card-description>\n';
  273. result += ind + ind0 + '<p>' + text + '</p>\n';
  274. result += ind + '</card-description>\n';
  275. return result;
  276. };
  277. CardHtmlGenerator.prototype._dndstats = function (params, card, options, ind, ind0) {
  278. var stats = ["str", "dex", "con", "int", "wis", "cha"];
  279. var result = "";
  280. result += ind + '<card-dndstats';
  281. for (var i = 0; i < stats.length; ++i) {
  282. var value = params[i] || "";
  283. var stat = stats[i];
  284. result += ' ' + stat + '="' + value + '"';
  285. }
  286. result += '></card-dndstats>\n';
  287. return result;
  288. };
  289. CardHtmlGenerator.prototype._bullet = function (params, card, options, ind, ind0) {
  290. var text = params[0] || "";
  291. return ind + '<card-bullet>' + text + '</card-bullet>\n';
  292. };
  293. CardHtmlGenerator.prototype._section = function (params, card, options, ind, ind0) {
  294. var text = params[0] || "";
  295. return ind + '<card-section>' + text + '</card-section>\n';
  296. };
  297. CardHtmlGenerator.prototype._fill = function (params, card, options, ind, ind0) {
  298. var size = params[0] || "1";
  299. return ind + '<card-fill size="' + size + '"></card-fill>\n';
  300. };
  301. CardHtmlGenerator.prototype._vspace = function (params, card, options, ind, ind0) {
  302. var size = params[0] || "1em";
  303. return ind + '<card-vspace size="' + size + '"></card-vspace>\n';
  304. };
  305. CardHtmlGenerator.prototype._unknown = function (params, card, options, ind, ind0) {
  306. var text = params.join(' | ');
  307. return ind + '<card-description><p>' + text + '</p></card-description>\n';
  308. };
  309. CardHtmlGenerator.prototype._empty = function (params, card, options, ind, ind0) {
  310. return '';
  311. };
  312. CardHtmlGenerator.prototype._contents = function (contents, card, options, ind, ind0) {
  313. var _this = this;
  314. var result = "";
  315. result += ind + '<card-contents>\n';
  316. result += contents.map(function (value) {
  317. var parts = splitParams(value);
  318. var name = parts[0];
  319. var params = parts.splice(1);
  320. var generator = null;
  321. switch (name) {
  322. case "subtitle":
  323. generator = _this._subtitle;
  324. break;
  325. case "property":
  326. generator = _this._property;
  327. break;
  328. case "rule":
  329. generator = _this._ruler;
  330. break;
  331. case "ruler":
  332. generator = _this._ruler;
  333. break;
  334. case "boxes":
  335. generator = _this._boxes;
  336. break;
  337. case "description":
  338. generator = _this._description;
  339. break;
  340. case "dndstats":
  341. generator = _this._dndstats;
  342. break;
  343. case "text":
  344. generator = _this._text;
  345. break;
  346. case "bullet":
  347. generator = _this._bullet;
  348. break;
  349. case "fill":
  350. generator = _this._fill;
  351. break;
  352. case "vspace":
  353. generator = _this._vspace;
  354. break;
  355. case "section":
  356. generator = _this._section;
  357. break;
  358. case "disabled":
  359. generator = _this._empty;
  360. break;
  361. case "":
  362. generator = _this._empty;
  363. break;
  364. default: return _this._unknown(parts, card, options, ind, ind0);
  365. }
  366. return generator(params, card, options, ind + ind0, ind);
  367. }).join("\n");
  368. result += ind + '</card-contents>\n';
  369. return result;
  370. };
  371. CardHtmlGenerator.prototype._title = function (card, options, ind, ind0) {
  372. var title = card.getTitle(options);
  373. var title_size = card.getTitleSize(options);
  374. var title_icon_text = card.getTitleIconText(options);
  375. var icon = card.getIconFront(options);
  376. var result = "";
  377. result += ind + '<card-title size="' + title_size + '">\n';
  378. result += ind + ind0 + '<h1>' + title + '</h1>\n';
  379. result += ind + ind0 + '<h2>' + title_icon_text + '</h2>\n';
  380. result += this._icon(icon, ind + ind0, ind0);
  381. result += ind + '</card-title>\n';
  382. return result;
  383. };
  384. CardHtmlGenerator.prototype._card_front = function (card, options, ind, ind0) {
  385. var result = "";
  386. result += this._title(card, options, ind + ind0, ind0);
  387. result += this._contents(card.contents, card, options, ind + ind0, ind0);
  388. return result;
  389. };
  390. CardHtmlGenerator.prototype._card_back = function (card, options, ind, ind0) {
  391. var icon = card.getIconBack(options);
  392. var result = "";
  393. result += ind + '<card-back>\n';
  394. result += this._icon(icon, ind + ind0, ind);
  395. result += ind + '</card-back>\n';
  396. return result;
  397. };
  398. CardHtmlGenerator.prototype._card_empty = function (options, ind, ind0) {
  399. var result = "";
  400. result += ind + '<card-contents>\n';
  401. result += ind + '</card-contents>\n';
  402. return result;
  403. };
  404. CardHtmlGenerator.prototype._card = function (options, ind, ind0, content, color) {
  405. var size = options.card_size || "25x35";
  406. var result = "";
  407. result += ind + '<rpg-card color="' + color + '" size="' + size + '">\n';
  408. result += content;
  409. result += ind + '</rpg-card>\n';
  410. return result;
  411. };
  412. /** Generates HTML for the front side of the given card */
  413. CardHtmlGenerator.prototype.card_front = function (card, options, indent) {
  414. var content = this._card_front(card, options, "", indent);
  415. return this._card(options, "", indent, content, card.getColorFront(options));
  416. };
  417. /** Generates HTML for the back side of the given card */
  418. CardHtmlGenerator.prototype.card_back = function (card, options, indent) {
  419. var content = this._card_back(card, options, "", indent);
  420. return this._card(options, "", indent, content, card.getColorBack(options));
  421. };
  422. /** Generates HTML for an empty given card */
  423. CardHtmlGenerator.prototype.card_empty = function (options, indent) {
  424. var content = this._card_empty(options, "", indent);
  425. return this._card(options, "", indent, content, options.empty_color);
  426. };
  427. return CardHtmlGenerator;
  428. })();
  429. RpgCards.CardHtmlGenerator = CardHtmlGenerator;
  430. var CardPage = (function () {
  431. function CardPage(rows, cols) {
  432. this.rows = rows;
  433. this.cols = cols;
  434. this.cards = [];
  435. }
  436. /** Returns an empty page with the same dimensions */
  437. CardPage.prototype.newPage = function () {
  438. return new CardPage(this.rows, this.cols);
  439. };
  440. CardPage.prototype._posToIndex = function (row, col) {
  441. return row * this.cols + col;
  442. };
  443. /** Adds one card to the page */
  444. CardPage.prototype.addCard = function (card) {
  445. if (this.capacity() === 0) {
  446. throw new Error("This page is full.");
  447. }
  448. this.cards.push(card);
  449. };
  450. /**
  451. Adds several copies of a card to the page.
  452. Returns the number of copies that did not fit on the page.
  453. */
  454. CardPage.prototype.addCards = function (card, count) {
  455. while (this.capacity() > 0 && count > 0) {
  456. this.addCard(card);
  457. --count;
  458. }
  459. return count;
  460. };
  461. /** Fills all remaining slots on the current row with the given card */
  462. CardPage.prototype.fillRow = function (card) {
  463. while (this.capacityRow() > 0) {
  464. this.addCard(card);
  465. }
  466. };
  467. /** Fills all remaining slots on the page with empty cards */
  468. CardPage.prototype.fillPage = function (card) {
  469. while (this.capacity() > 0) {
  470. this.addCard(card);
  471. }
  472. };
  473. /** Empty slots on the page */
  474. CardPage.prototype.capacity = function () {
  475. return this.rows * this.cols - this.cards.length;
  476. };
  477. /** Empty slots on the current line */
  478. CardPage.prototype.capacityRow = function () {
  479. return this.capacity() % this.cols;
  480. };
  481. /** Flip card slots horizontally */
  482. CardPage.prototype.flipH = function () {
  483. if (this.capacity() > 0) {
  484. throw new Error("Cannot perform this operation while the page is not full");
  485. }
  486. for (var r = 0; r < this.rows; ++r) {
  487. for (var c = 0; c < Math.floor(this.cols / 2); ++c) {
  488. var indexL = this._posToIndex(r, c);
  489. var indexR = this._posToIndex(r, this.cols - c - 1);
  490. var cardL = this.cards[indexL];
  491. var cardR = this.cards[indexR];
  492. this.cards[indexL] = cardR;
  493. this.cards[indexR] = cardL;
  494. }
  495. }
  496. };
  497. return CardPage;
  498. })();
  499. var CardPageSet = (function () {
  500. function CardPageSet(rows, cols) {
  501. this.rows = rows;
  502. this.cols = cols;
  503. this.pages = [];
  504. }
  505. CardPageSet.prototype.lastPage = function () {
  506. if (this.pages.length === 0) {
  507. return null;
  508. }
  509. else {
  510. return this.pages[this.pages.length - 1];
  511. }
  512. };
  513. CardPageSet.prototype.addPage = function () {
  514. var newPage = new CardPage(this.rows, this.cols);
  515. this.pages.push(newPage);
  516. return newPage;
  517. };
  518. /**
  519. Adds one card to the last page.
  520. Adds a new pages if necessary.
  521. */
  522. CardPageSet.prototype.addCard = function (card) {
  523. var page = this.lastPage();
  524. if (page === null || page.capacity() === 0) {
  525. page = this.addPage();
  526. }
  527. page.addCard(card);
  528. };
  529. /**
  530. Adds several copies of a card to the last page.
  531. Adds new pages if necessary.
  532. */
  533. CardPageSet.prototype.addCards = function (card, count) {
  534. for (var i = 0; i < count; ++i) {
  535. this.addCard(card);
  536. }
  537. };
  538. CardPageSet.prototype.forEach = function (fn) {
  539. this.pages.forEach(fn);
  540. };
  541. CardPageSet.prototype.merge = function (other) {
  542. if (this.pages.length !== other.pages.length) {
  543. throw new Error("This function is only for merging two equally sized page sets");
  544. }
  545. var result = new CardPageSet(this.rows, this.cols);
  546. for (var i = 0; i < this.pages.length; ++i) {
  547. result.pages.push(this.pages[i]);
  548. result.pages.push(other.pages[i]);
  549. }
  550. return result;
  551. };
  552. return CardPageSet;
  553. })();
  554. var BoxSize = (function () {
  555. function BoxSize(p, w, h, wpx, hpx) {
  556. this.page = p;
  557. this.width = w;
  558. this.height = h;
  559. this.width_px = Math.floor(wpx);
  560. this.height_px = Math.floor(hpx);
  561. }
  562. return BoxSize;
  563. })();
  564. var boxSizes = {};
  565. boxSizes["auto"] = new BoxSize("auto", "auto", "auto", Infinity, Infinity);
  566. boxSizes["A2"] = new BoxSize("A2 portrait", "420mm", "594mm", 1587.401575, 2245.03937);
  567. boxSizes["A3"] = new BoxSize("A3 portrait", "297mm", "420mm", 1118.740158, 1587.401575);
  568. boxSizes["A4"] = new BoxSize("A4 portrait", "210mm", "297mm", 793.700787, 1118.740158);
  569. boxSizes["A5"] = new BoxSize("A5 portrait", "148mm", "210mm", 559.370079, 793.700787);
  570. boxSizes["Letter"] = new BoxSize("Letter portrait", "8.5in", "11in", 816, 1056);
  571. boxSizes["225x35"] = new BoxSize("2.25in 3.5in", "2.25in", "3.5in", 216, 336);
  572. boxSizes["25x35"] = new BoxSize("2.5in 3.5in", "2.5in", "3.5in", 240, 336);
  573. boxSizes["35x50"] = new BoxSize("3.5in 5.0in", "3.5in", "5.0in", 336, 480);
  574. boxSizes["50x70"] = new BoxSize("5.0in 7.0in", "5.0in", "7.0in", 480, 672);
  575. var PageHtmlGenerator = (function () {
  576. function PageHtmlGenerator() {
  577. this.indent = " ";
  578. }
  579. PageHtmlGenerator.prototype._pageColor = function (page, options) {
  580. if ((options.card_arrangement == "doublesided") && (page % 2 == 1)) {
  581. return options.background_color;
  582. }
  583. else {
  584. return options.foreground_color;
  585. }
  586. };
  587. PageHtmlGenerator.prototype._wrap = function (pageSet, options) {
  588. var result = "";
  589. for (var i = 0; i < pageSet.pages.length; ++i) {
  590. var page = pageSet.pages[i];
  591. var style = ' style="background-color:' + this._pageColor(i, options) + '"';
  592. result += '<card-page' + style + '>\n';
  593. result += page.cards.join("");
  594. result += '</card-page>\n';
  595. }
  596. return result;
  597. };
  598. PageHtmlGenerator.prototype._generatePagesDoublesided = function (cards, options, rows, cols, generator) {
  599. var front_pages = new CardPageSet(rows, cols);
  600. var back_pages = new CardPageSet(rows, cols);
  601. var empty = generator.card_empty(options, this.indent);
  602. for (var i = 0; i < cards.length; ++i) {
  603. var card = cards[i];
  604. var front = generator.card_front(card, options, this.indent);
  605. var back = generator.card_back(card, options, this.indent);
  606. front_pages.addCards(front, card.count);
  607. back_pages.addCards(back, card.count);
  608. }
  609. // Fill empty slots
  610. front_pages.forEach(function (page) { return page.fillPage(empty); });
  611. back_pages.forEach(function (page) { return page.fillPage(empty); });
  612. // Shuffle back cards so that they line up with their corresponding front cards
  613. back_pages.forEach(function (page) { return page.flipH(); });
  614. // Interleave front and back pages so that we can print double-sided
  615. return front_pages.merge(back_pages);
  616. };
  617. PageHtmlGenerator.prototype._generatePagesFrontOnly = function (cards, options, rows, cols, generator) {
  618. var pages = new CardPageSet(rows, cols);
  619. var empty = generator.card_empty(options, this.indent);
  620. for (var i = 0; i < cards.length; ++i) {
  621. var card = cards[i];
  622. var front = generator.card_front(card, options, this.indent);
  623. pages.addCards(front, card.count);
  624. }
  625. // Fill empty slots
  626. pages.forEach(function (page) { return page.fillPage(empty); });
  627. return pages;
  628. };
  629. PageHtmlGenerator.prototype._generatePagesSideBySide = function (cards, options, rows, cols, generator) {
  630. if (cols < 2) {
  631. throw new Error("Need at least two columns for side-by-side");
  632. }
  633. var pages = new CardPageSet(rows, cols);
  634. var empty = generator.card_empty(options, this.indent);
  635. for (var i = 0; i < cards.length; ++i) {
  636. var card = cards[i];
  637. var front = generator.card_front(card, options, this.indent);
  638. var back = generator.card_back(card, options, this.indent);
  639. for (var j = 0; j < card.count; ++j) {
  640. if (pages.pages.length > 0 && pages.lastPage().capacityRow() < 2) {
  641. pages.lastPage().fillRow(empty);
  642. }
  643. pages.addCard(front);
  644. pages.addCard(back);
  645. }
  646. }
  647. // Fill empty slots
  648. pages.forEach(function (page) { return page.fillPage(empty); });
  649. return pages;
  650. };
  651. PageHtmlGenerator.prototype._generatePages = function (cards, options, rows, cols, generator) {
  652. switch (options.card_arrangement) {
  653. case "doublesided": return this._generatePagesDoublesided(cards, options, rows, cols, generator);
  654. case "front_only": return this._generatePagesFrontOnly(cards, options, rows, cols, generator);
  655. case "side_by_side": return this._generatePagesSideBySide(cards, options, rows, cols, generator);
  656. default: throw new Error("Unknown card arrangement");
  657. }
  658. };
  659. PageHtmlGenerator.prototype._generateStyle = function (options) {
  660. var page_box = boxSizes[options.page_size] || boxSizes["auto"];
  661. var result = '';
  662. result += '<style type="text/css">\n';
  663. result += 'body {\n';
  664. result += ' display: block;\n';
  665. result += ' background: rgb(204, 204, 204);\n';
  666. result += '}\n';
  667. result += 'card-page {\n';
  668. result += ' width: ' + (page_box.width_px) + 'px;\n';
  669. result += ' height: ' + (page_box.height_px) + 'px;\n';
  670. result += '}\n';
  671. result += '@media print {\n';
  672. result += ' html, body {\n';
  673. result += ' width: ' + page_box.width_px + 'px;\n';
  674. result += ' }\n';
  675. result += ' body {\n';
  676. result += ' margin: 0;\n';
  677. result += ' padding: 0;\n';
  678. result += ' border: 0;\n';
  679. result += ' }\n';
  680. result += '}\n';
  681. result += '@page {\n';
  682. result += ' margin: 0;\n';
  683. result += ' size:' + page_box.width_px + 'px ' + page_box.height_px + 'px;\n';
  684. result += ' -webkit-print-color-adjust: exact;\n';
  685. result += '}\n';
  686. result += '</style>\n';
  687. return result;
  688. };
  689. PageHtmlGenerator.prototype.generateHtml = function (cards, options) {
  690. options = options || new Options();
  691. var rows = options.page_rows || 3;
  692. var cols = options.page_columns || 3;
  693. // Generate the HTML for each card
  694. var generator = new CardHtmlGenerator();
  695. var pages = this._generatePages(cards, options, rows, cols, generator);
  696. // Wrap all pages in a <page> element
  697. var document = this._wrap(pages, options);
  698. // Generate the HTML for the page layout
  699. var style = this._generateStyle(options);
  700. // Wrap all pages in a <page> element and add CSS for the page size
  701. var result = "";
  702. result += style;
  703. result += document;
  704. return result;
  705. };
  706. PageHtmlGenerator.prototype.insertInto = function (cards, options, container) {
  707. while (container.hasChildNodes()) {
  708. container.removeChild(container.lastChild);
  709. }
  710. // Insert the HTML
  711. var html = this.generateHtml(cards, options);
  712. container.innerHTML = html;
  713. };
  714. return PageHtmlGenerator;
  715. })();
  716. RpgCards.PageHtmlGenerator = PageHtmlGenerator;
  717. })(RpgCards || (RpgCards = {}));
  718. var RpgCardsUI;
  719. (function (RpgCardsUI) {
  720. RpgCardsUI.css_color_names = [
  721. "Black",
  722. "Navy",
  723. "DarkBlue",
  724. "MediumBlue",
  725. "Blue",
  726. "DarkGreen",
  727. "Green",
  728. "Teal",
  729. "DarkCyan",
  730. "DeepSkyBlue",
  731. "DarkTurquoise",
  732. "MediumSpringGreen",
  733. "Lime",
  734. "SpringGreen",
  735. "Aqua",
  736. "Cyan",
  737. "MidnightBlue",
  738. "DodgerBlue",
  739. "LightSeaGreen",
  740. "ForestGreen",
  741. "SeaGreen",
  742. "DarkSlateGray",
  743. "LimeGreen",
  744. "MediumSeaGreen",
  745. "Turquoise",
  746. "RoyalBlue",
  747. "SteelBlue",
  748. "DarkSlateBlue",
  749. "MediumTurquoise",
  750. "Indigo",
  751. "DarkOliveGreen",
  752. "CadetBlue",
  753. "CornflowerBlue",
  754. "MediumAquaMarine",
  755. "DimGray",
  756. "SlateBlue",
  757. "OliveDrab",
  758. "SlateGray",
  759. "LightSlateGray",
  760. "MediumSlateBlue",
  761. "LawnGreen",
  762. "Chartreuse",
  763. "Aquamarine",
  764. "Maroon",
  765. "Purple",
  766. "Olive",
  767. "Gray",
  768. "SkyBlue",
  769. "LightSkyBlue",
  770. "BlueViolet",
  771. "DarkRed",
  772. "DarkMagenta",
  773. "SaddleBrown",
  774. "DarkSeaGreen",
  775. "LightGreen",
  776. "MediumPurple",
  777. "DarkViolet",
  778. "PaleGreen",
  779. "DarkOrchid",
  780. "YellowGreen",
  781. "Sienna",
  782. "Brown",
  783. "DarkGray",
  784. "LightBlue",
  785. "GreenYellow",
  786. "PaleTurquoise",
  787. "LightSteelBlue",
  788. "PowderBlue",
  789. "FireBrick",
  790. "DarkGoldenRod",
  791. "MediumOrchid",
  792. "RosyBrown",
  793. "DarkKhaki",
  794. "Silver",
  795. "MediumVioletRed",
  796. "IndianRed",
  797. "Peru",
  798. "Chocolate",
  799. "Tan",
  800. "LightGray",
  801. "Thistle",
  802. "Orchid",
  803. "GoldenRod",
  804. "PaleVioletRed",
  805. "Crimson",
  806. "Gainsboro",
  807. "Plum",
  808. "BurlyWood",
  809. "LightCyan",
  810. "Lavender",
  811. "DarkSalmon",
  812. "Violet",
  813. "PaleGoldenRod",
  814. "LightCoral",
  815. "Khaki",
  816. "AliceBlue",
  817. "HoneyDew",
  818. "Azure",
  819. "SandyBrown",
  820. "Wheat",
  821. "Beige",
  822. "WhiteSmoke",
  823. "MintCream",
  824. "GhostWhite",
  825. "Salmon",
  826. "AntiqueWhite",
  827. "Linen",
  828. "LightGoldenRodYellow",
  829. "OldLace",
  830. "Red",
  831. "Fuchsia",
  832. "Magenta",
  833. "DeepPink",
  834. "OrangeRed",
  835. "Tomato",
  836. "HotPink",
  837. "Coral",
  838. "DarkOrange",
  839. "LightSalmon",
  840. "Orange",
  841. "LightPink",
  842. "Pink",
  843. "Gold",
  844. "PeachPuff",
  845. "NavajoWhite",
  846. "Moccasin",
  847. "Bisque",
  848. "MistyRose",
  849. "BlanchedAlmond",
  850. "PapayaWhip",
  851. "LavenderBlush",
  852. "SeaShell",
  853. "Cornsilk",
  854. "LemonChiffon",
  855. "FloralWhite",
  856. "Snow",
  857. "Yellow",
  858. "LightYellow",
  859. "Ivory",
  860. "White"
  861. ];
  862. RpgCardsUI.card_colors = {
  863. "": "",
  864. "dimgray": "dimgray",
  865. "black": "black",
  866. "darkgoldenrod": "darkgoldenrod",
  867. "saddlebrown": "saddlebrown",
  868. "indianred": "indianred",
  869. "maroon": "maroon",
  870. "indigo": "indigo",
  871. "darkblue": "darkblue",
  872. "royalblue": "royalblue",
  873. "darkgreen": "darkgreen",
  874. "#666633": "#666633",
  875. "rgb(140, 83, 133)": "rgb(140, 83, 133)",
  876. "rgb(255, 173, 70)": "rgb(255, 173, 70)",
  877. "rgb(96, 184, 93)": "rgb(96, 184, 93)",
  878. "rgb(59, 175, 177)": "rgb(59, 175, 177)",
  879. "rgb(128, 0, 0)": "rgb(128, 0, 0)",
  880. "rgb(133, 112, 86)": "rgb(133, 112, 86)",
  881. "rgb(248, 58, 34)": "rgb(248, 58, 34)"
  882. };
  883. })(RpgCardsUI || (RpgCardsUI = {}));
  884. var RpgCardsUI;
  885. (function (RpgCardsUI) {
  886. RpgCardsUI.icon_names = [
  887. "ace",
  888. "acid-blob",
  889. "acid-tube",
  890. "acid",
  891. "acorn",
  892. "aerial-signal",
  893. "aerosol",
  894. "afterburn",
  895. "alien-skull",
  896. "alien-stare",
  897. "all-for-one",
  898. "alligator-clip",
  899. "ammo-box",
  900. "ammonite-fossil",
  901. "ammonite",
  902. "amphora",
  903. "anatomy",
  904. "anchor",
  905. "andromeda-chain",
  906. "angel-outfit",
  907. "angel-wings",
  908. "angler-fish",
  909. "angular-spider",
  910. "animal-hide",
  911. "animal-skull",
  912. "ankh",
  913. "anthem",
  914. "anvil-impact",
  915. "anvil",
  916. "apple-maggot",
  917. "apple-seeds",
  918. "aquarius",
  919. "archery-target",
  920. "architect-mask",
  921. "arcing-bolt",
  922. "arena",
  923. "aries",
  924. "armadillo-tail",
  925. "armoured-shell",
  926. "arrow-cluster",
  927. "arrow-flights",
  928. "arrowed",
  929. "arrowhead",
  930. "arrows-shield",
  931. "arson",
  932. "artificial-hive",
  933. "at-sea",
  934. "atomic-slashes",
  935. "aubergine",
  936. "aura",
  937. "auto-repair",
  938. "autogun",
  939. "awareness",
  940. "axe-in-stump",
  941. "axe-swing",
  942. "back-forth",
  943. "back-pain",
  944. "backstab",
  945. "backup",
  946. "balloons",
  947. "bandage-roll",
  948. "bandaged",
  949. "barbed-arrow",
  950. "barbed-spear",
  951. "barbed-wire",
  952. "barbute",
  953. "barefoot",
  954. "bat-blade",
  955. "bat-wing",
  956. "battered-axe",
  957. "batteries",
  958. "battery-0",
  959. "battery-100",
  960. "battery-25",
  961. "battery-50",
  962. "battery-75",
  963. "battery-minus",
  964. "battery-pack-alt",
  965. "battery-pack",
  966. "battery-plus",
  967. "battle-axe",
  968. "battle-gear",
  969. "batwing-emblem",
  970. "beam-wake",
  971. "beams-aura",
  972. "beanstalk",
  973. "beard",
  974. "beast-eye",
  975. "bee",
  976. "beech",
  977. "beer-stein",
  978. "beetle-shell",
  979. "behold",
  980. "belt-buckles",
  981. "bestial-fangs",
  982. "beveled-star",
  983. "big-egg",
  984. "big-wave",
  985. "biohazard",
  986. "bird-claw",
  987. "bird-limb",
  988. "bird-mask",
  989. "bird-twitter",
  990. "black-bar",
  991. "black-book",
  992. "black-cat",
  993. "black-flag",
  994. "black-hole-bolas",
  995. "blackball",
  996. "blackcurrant",
  997. "blade-bite",
  998. "blade-fall",
  999. "blast",
  1000. "blaster",
  1001. "bleeding-eye",
  1002. "bleeding-heart",
  1003. "bloody-stash",
  1004. "blunderbuss",
  1005. "boar-tusks",
  1006. "boiling-bubbles",
  1007. "bolas",
  1008. "bolt-shield",
  1009. "bolter-gun",
  1010. "bombing-run",
  1011. "bone-gnawer",
  1012. "bone-knife",
  1013. "book-aura",
  1014. "book-cover",
  1015. "book-storm",
  1016. "bookmark",
  1017. "bookmarklet",
  1018. "boomerang",
  1019. "boot-prints",
  1020. "boot-stomp",
  1021. "boots",
  1022. "bordered-shield",
  1023. "bottle-vapors",
  1024. "bottled-bolt",
  1025. "bottom-right-3d-arrow",
  1026. "bowie-knife",
  1027. "bowl-spiral",
  1028. "bowling-pin",
  1029. "bowling-propulsion",
  1030. "bowman",
  1031. "boxing-glove-surprise",
  1032. "boxing-glove",
  1033. "brain-freeze",
  1034. "brain-stem",
  1035. "brain",
  1036. "brainstorm",
  1037. "branch-arrow",
  1038. "brandy-bottle",
  1039. "brass-eye",
  1040. "breastplate",
  1041. "brick-pile",
  1042. "bridge",
  1043. "broadhead-arrow",
  1044. "broadsword",
  1045. "broken-bone",
  1046. "broken-bottle",
  1047. "broken-heart",
  1048. "broken-shield",
  1049. "broken-skull",
  1050. "broken-tablet",
  1051. "brutal-helm",
  1052. "bubble-field",
  1053. "bubbling-flask",
  1054. "bud",
  1055. "bugle-call",
  1056. "bulb",
  1057. "bull-horns",
  1058. "bull",
  1059. "bullets",
  1060. "burn",
  1061. "burning-book",
  1062. "burning-dot",
  1063. "burning-embers",
  1064. "burning-eye",
  1065. "burning-meteor",
  1066. "burning-passion",
  1067. "burning-round-shot",
  1068. "burning-tree",
  1069. "burst-blob",
  1070. "butterfly-warning",
  1071. "butterfly",
  1072. "caged-ball",
  1073. "cake-slice",
  1074. "caldera",
  1075. "campfire",
  1076. "cancel",
  1077. "cancer",
  1078. "candle-flame",
  1079. "candle-holder",
  1080. "candle-light",
  1081. "candle-skull",
  1082. "candlebright",
  1083. "cannister",
  1084. "cannon-ball",
  1085. "cannon-shot",
  1086. "cannon",
  1087. "capitol",
  1088. "capricorn",
  1089. "cargo-crane",
  1090. "carillon",
  1091. "carrion",
  1092. "carrot",
  1093. "cartwheel",
  1094. "cash",
  1095. "castle",
  1096. "cauldron",
  1097. "cctv-camera",
  1098. "centipede",
  1099. "chain-lightning",
  1100. "chain-mail",
  1101. "chained-heart",
  1102. "chaingun",
  1103. "chalice-drops",
  1104. "charm",
  1105. "checkbox-tree",
  1106. "checked-shield",
  1107. "cheerful",
  1108. "cheese-wedge",
  1109. "chemical-arrow",
  1110. "chemical-bolt",
  1111. "chemical-drop",
  1112. "chemical-tank",
  1113. "chicken-leg",
  1114. "circuitry",
  1115. "circular-saw",
  1116. "circular-sawblade",
  1117. "claw-hammer",
  1118. "claw",
  1119. "cloak-dagger",
  1120. "clockwork",
  1121. "clout",
  1122. "clover-spiked",
  1123. "clover",
  1124. "cluster-bomb",
  1125. "cobweb",
  1126. "coffee-mug",
  1127. "coffin",
  1128. "cog-lock",
  1129. "cog",
  1130. "cogsplosion",
  1131. "coiling-curl",
  1132. "cold-heart",
  1133. "coma",
  1134. "comb",
  1135. "compass",
  1136. "concentration-orb",
  1137. "condor-emblem",
  1138. "condylura-skull",
  1139. "conversation",
  1140. "cool-spices",
  1141. "corked-tube",
  1142. "cowled",
  1143. "crab-claw",
  1144. "crab",
  1145. "cracked-ball-dunk",
  1146. "cracked-disc",
  1147. "cracked-glass",
  1148. "cracked-helm",
  1149. "cracked-mask",
  1150. "cracked-saber",
  1151. "cracked-shield",
  1152. "crags",
  1153. "crenulated-shield",
  1154. "crescent-blade",
  1155. "crested-helmet",
  1156. "croc-jaws",
  1157. "croc-sword",
  1158. "crossbow",
  1159. "crossed-air-flows",
  1160. "crossed-axes",
  1161. "crossed-bones",
  1162. "crossed-chains",
  1163. "crossed-claws",
  1164. "crossed-pistols",
  1165. "crossed-sabres",
  1166. "crossed-slashes",
  1167. "crossed-swords",
  1168. "crow-dive",
  1169. "crown-coin",
  1170. "crown-of-thorns",
  1171. "crown",
  1172. "crowned-explosion",
  1173. "crowned-heart",
  1174. "crowned-skull",
  1175. "crush",
  1176. "crystal-ball",
  1177. "crystal-bars",
  1178. "crystal-cluster",
  1179. "crystal-eye",
  1180. "crystal-growth",
  1181. "crystal-shine",
  1182. "crystal-wand",
  1183. "crystalize",
  1184. "cubeforce",
  1185. "cubes",
  1186. "cupidon-arrow",
  1187. "curled-leaf",
  1188. "curled-tentacle",
  1189. "curling-vines",
  1190. "curly-wing",
  1191. "curvy-knife",
  1192. "cut-diamond",
  1193. "cut-palm",
  1194. "cycle",
  1195. "cyclops",
  1196. "daggers",
  1197. "daisy",
  1198. "dark-squad",
  1199. "dead-eye",
  1200. "dead-wood",
  1201. "death-note",
  1202. "death-skull",
  1203. "death-zone",
  1204. "deathcab",
  1205. "decapitation",
  1206. "defibrilate",
  1207. "demolish",
  1208. "dervish-swords",
  1209. "desert-skull",
  1210. "desk-lamp",
  1211. "despair",
  1212. "diablo-skull",
  1213. "diamond-hard",
  1214. "dice-six-faces-five",
  1215. "dice-six-faces-four",
  1216. "dice-six-faces-one",
  1217. "dice-six-faces-six",
  1218. "dice-six-faces-three",
  1219. "dice-six-faces-two",
  1220. "dig-dug",
  1221. "dinosaur-bones",
  1222. "dinosaur-egg",
  1223. "dinosaur-rex",
  1224. "disintegrate",
  1225. "distraction",
  1226. "divergence",
  1227. "divert",
  1228. "diving-dagger",
  1229. "dna1",
  1230. "dna2",
  1231. "doctor-face",
  1232. "dodge",
  1233. "dodging",
  1234. "domino-mask",
  1235. "double-dragon",
  1236. "double-quaver",
  1237. "double-shot",
  1238. "doubled",
  1239. "dove",
  1240. "dozen",
  1241. "dragon-balls",
  1242. "dragon-breath",
  1243. "dragon-head",
  1244. "dragon-spiral",
  1245. "dragonfly",
  1246. "drama-masks",
  1247. "drill",
  1248. "drink-me",
  1249. "dripping-blade",
  1250. "dripping-goo",
  1251. "dripping-honey",
  1252. "dripping-knife",
  1253. "dripping-stone",
  1254. "dripping-sword",
  1255. "drop",
  1256. "droplet-splash",
  1257. "droplets",
  1258. "drowning",
  1259. "duality",
  1260. "duel",
  1261. "eagle-emblem",
  1262. "earth-crack",
  1263. "earth-spit",
  1264. "eclipse",
  1265. "edge-crack",
  1266. "edged-shield",
  1267. "egg-clutch",
  1268. "egg-pod",
  1269. "egyptian-pyramids",
  1270. "elderberry",
  1271. "electric-whip",
  1272. "electric",
  1273. "elf-ear",
  1274. "ember-shot",
  1275. "embrassed-energy",
  1276. "embryo",
  1277. "emerald",
  1278. "empty-chessboard",
  1279. "empty-hourglass",
  1280. "energise",
  1281. "energy-arrow",
  1282. "energy-shield",
  1283. "energy-sword",
  1284. "engagement-ring",
  1285. "ent-mouth",
  1286. "envelope",
  1287. "erlenmeyer",
  1288. "eruption",
  1289. "eskimo",
  1290. "evil-book",
  1291. "evil-fork",
  1292. "evil-moon",
  1293. "evil-tree",
  1294. "evil-wings",
  1295. "expander",
  1296. "explosive-materials",
  1297. "extra-lucid",
  1298. "eye-shield",
  1299. "eyeball",
  1300. "eyedropper",
  1301. "eyestalk",
  1302. "fairy-wand",
  1303. "fairy",
  1304. "fall-down",
  1305. "falling-eye",
  1306. "falling-leaf",
  1307. "falling-ovoid",
  1308. "falling",
  1309. "fanged-skull",
  1310. "feather",
  1311. "feathered-wing",
  1312. "fedora",
  1313. "female",
  1314. "fez",
  1315. "field",
  1316. "fire-ace",
  1317. "fire-axe",
  1318. "fire-bomb",
  1319. "fire-bottle",
  1320. "fire-bowl",
  1321. "fire-breath",
  1322. "fire-punch",
  1323. "fire-ring",
  1324. "fire-shield",
  1325. "fire-wave",
  1326. "fire",
  1327. "fireball",
  1328. "fireflake",
  1329. "firework-rocket",
  1330. "fish-corpse",
  1331. "fishbone",
  1332. "fishing-hook",
  1333. "fishing-net",
  1334. "fist",
  1335. "fizzing-flask",
  1336. "flake",
  1337. "flame-spin",
  1338. "flame-tunnel",
  1339. "flame",
  1340. "flamer",
  1341. "flaming-arrow",
  1342. "flaming-claw",
  1343. "flaming-trident",
  1344. "flash-grenade",
  1345. "flat-hammer",
  1346. "fleshy-mass",
  1347. "flexible-star",
  1348. "floating-crystal",
  1349. "flower-pot",
  1350. "flowers",
  1351. "fluffy-cloud",
  1352. "fluffy-swirl",
  1353. "fluffy-wing",
  1354. "flying-dagger",
  1355. "flying-flag",
  1356. "foam",
  1357. "focused-lightning",
  1358. "folded-paper",
  1359. "food-chain",
  1360. "foot-trip",
  1361. "footprint",
  1362. "forward-field",
  1363. "fossil",
  1364. "fountain-pen",
  1365. "fountain",
  1366. "fox-head",
  1367. "fragrance",
  1368. "frankenstein-creature",
  1369. "freedom-dove",
  1370. "frog",
  1371. "front-teeth",
  1372. "frontal-lobe",
  1373. "frostfire",
  1374. "frozen-arrow",
  1375. "frozen-block",
  1376. "frozen-orb",
  1377. "fruiting",
  1378. "fulguro-punch",
  1379. "galleon",
  1380. "gamepad-cross",
  1381. "gas-mask",
  1382. "gavel",
  1383. "gaze",
  1384. "gear-hammer",
  1385. "gears",
  1386. "gecko",
  1387. "gem-chain",
  1388. "gem-necklace",
  1389. "gem-pendant",
  1390. "gemini",
  1391. "gems",
  1392. "ghost",
  1393. "gibbet",
  1394. "gift-of-knowledge",
  1395. "gift-trap",
  1396. "glass-heart",
  1397. "glass-shot",
  1398. "globe",
  1399. "gloop",
  1400. "glowing-hands",
  1401. "gluttonous-smile",
  1402. "gluttony",
  1403. "gold-bar",
  1404. "gold-scarab",
  1405. "goo-explosion",
  1406. "goo-skull",
  1407. "goo-spurt",
  1408. "gooey-daemon",
  1409. "gooey-eyed-sun",
  1410. "gooey-impact",
  1411. "gooey-sword",
  1412. "grab",
  1413. "grapes",
  1414. "grasping-claws",
  1415. "grass",
  1416. "grease-trap",
  1417. "grenade",
  1418. "grim-reaper",
  1419. "groundbreaker",
  1420. "guarded-tower",
  1421. "guillotine",
  1422. "guitar",
  1423. "gunshot",
  1424. "halberd-shuriken",
  1425. "halberd",
  1426. "half-heart",
  1427. "hammer-drop",
  1428. "hammer-nails",
  1429. "hand-of-god",
  1430. "hand-saw",
  1431. "hand",
  1432. "handcuffs",
  1433. "hanging-spider",
  1434. "harpoon-chain",
  1435. "harpoon-trident",
  1436. "harpy",
  1437. "hatchets",
  1438. "haunting",
  1439. "hazard-sign",
  1440. "head-shot",
  1441. "headshot",
  1442. "health-decrease",
  1443. "health-increase",
  1444. "health-normal",
  1445. "heart-bottle",
  1446. "heart-drop",
  1447. "heart-inside",
  1448. "heart-organ",
  1449. "heart-tower",
  1450. "heartburn",
  1451. "heat-haze",
  1452. "heavy-arrow",
  1453. "heavy-helm",
  1454. "heavy-rain",
  1455. "helmet",
  1456. "help",
  1457. "hidden",
  1458. "high-grass",
  1459. "high-shot",
  1460. "hive",
  1461. "hole-ladder",
  1462. "holy-grail",
  1463. "holy-symbol",
  1464. "honeycomb",
  1465. "honeypot",
  1466. "hood",
  1467. "hoof",
  1468. "horn-internal",
  1469. "horned-helm",
  1470. "horned-skull",
  1471. "horse-head",
  1472. "horseshoe",
  1473. "hospital-cross",
  1474. "hot-spices",
  1475. "hot-surface",
  1476. "hound",
  1477. "hourglass",
  1478. "human-ear",
  1479. "hunting-horn",
  1480. "hydra-shot",
  1481. "hydra",
  1482. "hypersonic-bolt",
  1483. "hypodermic-test",
  1484. "ice-bolt",
  1485. "ice-bomb",
  1486. "ice-cube",
  1487. "ice-shield",
  1488. "ice-spear",
  1489. "icebergs",
  1490. "ifrit",
  1491. "imbricated-arrows",
  1492. "imp-laugh",
  1493. "imp",
  1494. "impact-point",
  1495. "implosion",
  1496. "imprisoned",
  1497. "incense",
  1498. "incisors",
  1499. "infested-mass",
  1500. "ink-swirl",
  1501. "inner-self",
  1502. "insect-jaws",
  1503. "interdiction",
  1504. "internal-injury",
  1505. "internal-organ",
  1506. "interstellar-path",
  1507. "invisible-face",
  1508. "invisible",
  1509. "iron-mask",
  1510. "james-bond-aperture",
  1511. "jawbone",
  1512. "jellyfish",
  1513. "jet-pack",
  1514. "jetpack",
  1515. "jeweled-chalice",
  1516. "jigsaw-box",
  1517. "jigsaw-piece",
  1518. "journey",
  1519. "juggler",
  1520. "justice-star",
  1521. "kaleidoscope-pearls",
  1522. "kevlar",
  1523. "key",
  1524. "kindle",
  1525. "king",
  1526. "kitchen-knives",
  1527. "knapsack",
  1528. "knife-fork",
  1529. "knife-thrust",
  1530. "lamellar",
  1531. "lamprey-mouth",
  1532. "land-mine",
  1533. "lantern-flame",
  1534. "lantern",
  1535. "laser-blast",
  1536. "laser-gun",
  1537. "laser-sparks",
  1538. "laser-warning",
  1539. "laserburn",
  1540. "lasso",
  1541. "laurel-crown",
  1542. "laurels",
  1543. "lava",
  1544. "law-star",
  1545. "layered-armor",
  1546. "leaf-skeleton",
  1547. "leaf-swirl",
  1548. "leaky-skull",
  1549. "leather-boot",
  1550. "leather-vest",
  1551. "leeching-worm",
  1552. "leo",
  1553. "letter-bomb",
  1554. "level-four-advanced",
  1555. "level-four",
  1556. "level-three-advanced",
  1557. "level-three",
  1558. "level-two-advanced",
  1559. "level-two",
  1560. "lever",
  1561. "libra",
  1562. "life-in-the-balance",
  1563. "life-support",
  1564. "life-tap",
  1565. "lift",
  1566. "light-bulb",
  1567. "lightning-arc",
  1568. "lightning-bow",
  1569. "lightning-branches",
  1570. "lightning-frequency",
  1571. "lightning-helix",
  1572. "lightning-shield",
  1573. "lightning-shout",
  1574. "lightning-storm",
  1575. "lightning-tear",
  1576. "linked-rings",
  1577. "lion",
  1578. "lips",
  1579. "lit-candelabra",
  1580. "lizard-tongue",
  1581. "lizardman",
  1582. "lob-arrow",
  1583. "locked-chest",
  1584. "locked-fortress",
  1585. "lotus-flower",
  1586. "lotus",
  1587. "love-howl",
  1588. "love-song",
  1589. "lucifer-cannon",
  1590. "lyre",
  1591. "mace-head",
  1592. "machete",
  1593. "mad-scientist",
  1594. "maggot",
  1595. "magic-gate",
  1596. "magic-lamp",
  1597. "magic-palm",
  1598. "magic-portal",
  1599. "magic-shield",
  1600. "magic-swirl",
  1601. "magnet-blast",
  1602. "magnet",
  1603. "magnifying-glass",
  1604. "mail-shirt",
  1605. "mailed-fist",
  1606. "male",
  1607. "manacles",
  1608. "mantrap",
  1609. "maple-leaf",
  1610. "marrow-drain",
  1611. "martini",
  1612. "masked-spider",
  1613. "mass-driver",
  1614. "match-head",
  1615. "materials-science",
  1616. "maze",
  1617. "meat-cleaver",
  1618. "meat-hook",
  1619. "meat",
  1620. "mechanical-arm",
  1621. "medal-skull",
  1622. "medal",
  1623. "medical-pack-alt",
  1624. "medical-pack",
  1625. "meditation",
  1626. "mesh-ball",
  1627. "metal-bar",
  1628. "metal-disc",
  1629. "metal-hand",
  1630. "meteor-impact",
  1631. "microchip",
  1632. "microscope-lens",
  1633. "mighty-boosh",
  1634. "mine-wagon",
  1635. "mineral-heart",
  1636. "minigun",
  1637. "mining",
  1638. "minions",
  1639. "minotaur",
  1640. "miracle-medecine",
  1641. "mirror-mirror",
  1642. "missile-mech",
  1643. "missile-pod",
  1644. "missile-swarm",
  1645. "mite-alt",
  1646. "mite",
  1647. "mixed-swords",
  1648. "moebius-star",
  1649. "moebius-triangle",
  1650. "molecule",
  1651. "molotov",
  1652. "monkey",
  1653. "moon",
  1654. "morbid-humour",
  1655. "mountain-cave",
  1656. "mountains",
  1657. "mountaintop",
  1658. "mouse",
  1659. "mouth-watering",
  1660. "movement-sensor",
  1661. "mucous-pillar",
  1662. "muscle-fat",
  1663. "muscle-up",
  1664. "mushroom-cloud",
  1665. "mushroom-gills",
  1666. "mushroom",
  1667. "nailed-foot",
  1668. "nailed-head",
  1669. "nails",
  1670. "needle-drill",
  1671. "needle-jaws",
  1672. "night-sky",
  1673. "ninja-mask",
  1674. "nodular",
  1675. "nothing-to-say",
  1676. "nuclear",
  1677. "oak",
  1678. "ocarina",
  1679. "octopus",
  1680. "omega",
  1681. "on-target",
  1682. "one-eyed",
  1683. "open-book",
  1684. "open-wound",
  1685. "ophiuchus",
  1686. "oppression",
  1687. "orb-direction",
  1688. "orb-wand",
  1689. "orbital",
  1690. "ouroboros",
  1691. "over-infinity",
  1692. "overdose",
  1693. "overdrive",
  1694. "overhead",
  1695. "overkill",
  1696. "overmind",
  1697. "owl",
  1698. "padlock",
  1699. "palm-tree",
  1700. "palm",
  1701. "paper-bomb",
  1702. "paper-lantern",
  1703. "paper",
  1704. "papers",
  1705. "parachute",
  1706. "paranoia",
  1707. "parmecia",
  1708. "parrot-head",
  1709. "paw-front",
  1710. "paw-heart",
  1711. "paw",
  1712. "pawn",
  1713. "pawprint",
  1714. "perfume-bottle",
  1715. "perspective-dice-six-faces-five",
  1716. "perspective-dice-six-faces-four",
  1717. "perspective-dice-six-faces-one",
  1718. "perspective-dice-six-faces-random",
  1719. "perspective-dice-six-faces-six",
  1720. "perspective-dice-six-faces-three",
  1721. "perspective-dice-six-faces-two",
  1722. "pie-slice",
  1723. "pierced-body",
  1724. "pierced-heart",
  1725. "pill-drop",
  1726. "pill",
  1727. "pincers",
  1728. "pine-tree",
  1729. "ping-pong-bat",
  1730. "pirate-grave",
  1731. "pirate-skull",
  1732. "pisces",
  1733. "pistol-gun",
  1734. "pizza-cutter",
  1735. "plain-dagger",
  1736. "planks",
  1737. "plasma-bolt",
  1738. "plastron",
  1739. "pocket-bow",
  1740. "podium",
  1741. "pointing",
  1742. "pointy-hat",
  1743. "poison-bottle",
  1744. "poison-cloud",
  1745. "poison-gas",
  1746. "poison",
  1747. "poker-hand",
  1748. "pollen-dust",
  1749. "portculis",
  1750. "potion-ball",
  1751. "pounce",
  1752. "pouring-chalice",
  1753. "powder",
  1754. "prayer",
  1755. "pretty-fangs",
  1756. "profit",
  1757. "psychic-waves",
  1758. "pulse",
  1759. "pummeled",
  1760. "pumpkin-lantern",
  1761. "pumpkin-mask",
  1762. "punch",
  1763. "puppet",
  1764. "pyromaniac",
  1765. "quake-stomp",
  1766. "queen-crown",
  1767. "quick-slash",
  1768. "quicksand",
  1769. "quill-ink",
  1770. "quill",
  1771. "rabbit",
  1772. "radar-dish",
  1773. "radar-sweep",
  1774. "radial-balance",
  1775. "radioactive",
  1776. "ragged-wound",
  1777. "rainbow-star",
  1778. "raining",
  1779. "rally-the-troops",
  1780. "ram",
  1781. "rapidshare-arrow",
  1782. "raven",
  1783. "ray-gun",
  1784. "razor-blade",
  1785. "reactor",
  1786. "reaper-scythe",
  1787. "recycle",
  1788. "regeneration",
  1789. "relic-blade",
  1790. "reticule",
  1791. "revolt",
  1792. "ribbon",
  1793. "ribcage",
  1794. "rifle",
  1795. "ringed-planet",
  1796. "ringing-bell",
  1797. "riot-shield",
  1798. "roast-chicken",
  1799. "robe",
  1800. "robot-golem",
  1801. "rock",
  1802. "rocket-flight",
  1803. "rocket",
  1804. "rogue",
  1805. "rolling-bomb",
  1806. "rose",
  1807. "round-bottom-flask",
  1808. "round-shield",
  1809. "rss",
  1810. "run",
  1811. "rune-stone",
  1812. "rune-sword",
  1813. "saber-slash",
  1814. "saber-tooth",
  1815. "sacrificial-dagger",
  1816. "sad-crab",
  1817. "sagittarius",
  1818. "salamander",
  1819. "salt-shaker",
  1820. "sands-of-time",
  1821. "saphir",
  1822. "sattelite",
  1823. "saw-claw",
  1824. "scale-mail",
  1825. "scales",
  1826. "scallop",
  1827. "scalpel-strike",
  1828. "scalpel",
  1829. "scarab-beetle",
  1830. "scarecrow",
  1831. "scissors",
  1832. "scorpio",
  1833. "scorpion-tail",
  1834. "scorpion",
  1835. "screaming",
  1836. "screwdriver",
  1837. "scroll-unfurled",
  1838. "scythe",
  1839. "sea-dragon",
  1840. "sea-serpent",
  1841. "seated-mouse",
  1842. "select",
  1843. "semi-closed-eye",
  1844. "sentry-gun",
  1845. "serrated-slash",
  1846. "sewing-needle",
  1847. "shard-sword",
  1848. "shark-jaws",
  1849. "sharp-crown",
  1850. "sharp-smile",
  1851. "shatter",
  1852. "shattered-glass",
  1853. "shattered-sword",
  1854. "sheikah-eye",
  1855. "shield-echoes",
  1856. "shield-reflect",
  1857. "shield",
  1858. "shieldcomb",
  1859. "shining-claw",
  1860. "shining-heart",
  1861. "shining-sword",
  1862. "shiny-apple",
  1863. "shiny-iris",
  1864. "shiny-purse",
  1865. "shotgun",
  1866. "shoulder-scales",
  1867. "shouting",
  1868. "shuriken",
  1869. "sickle",
  1870. "sideswipe",
  1871. "silence",
  1872. "sing",
  1873. "six-eyes",
  1874. "skeleton-inside",
  1875. "skeleton-key",
  1876. "skid-mark",
  1877. "skull-bolt",
  1878. "skull-crack",
  1879. "skull-crossed-bones",
  1880. "skull-in-jar",
  1881. "skull-mask",
  1882. "skull-ring",
  1883. "skull-shield",
  1884. "skull-signet",
  1885. "slap",
  1886. "slashed-shield",
  1887. "slavery-whip",
  1888. "sleepy",
  1889. "sliced-bread",
  1890. "slow-blob",
  1891. "sly",
  1892. "small-fire",
  1893. "smitten",
  1894. "smoking-finger",
  1895. "snail",
  1896. "snake-bite",
  1897. "snake-totem",
  1898. "snake",
  1899. "snatch",
  1900. "snorkel",
  1901. "snow-bottle",
  1902. "snowflake-1",
  1903. "snowflake-2",
  1904. "snowing",
  1905. "snowman",
  1906. "soccer-ball",
  1907. "sonic-boom",
  1908. "sonic-screech",
  1909. "sonic-shout",
  1910. "space-suit",
  1911. "spade-skull",
  1912. "spade",
  1913. "spanner",
  1914. "sparkling-sabre",
  1915. "sparky-bomb",
  1916. "sparrow",
  1917. "spartan",
  1918. "spatter",
  1919. "spawn-node",
  1920. "spears",
  1921. "spectacle-lenses",
  1922. "spectacles",
  1923. "spectre",
  1924. "spider-alt",
  1925. "spider-face",
  1926. "spikeball",
  1927. "spiked-armor",
  1928. "spiked-collar",
  1929. "spiked-fence",
  1930. "spiked-mace",
  1931. "spiked-shell",
  1932. "spiked-snail",
  1933. "spiked-tentacle",
  1934. "spikes-full",
  1935. "spikes-half",
  1936. "spikes-init",
  1937. "spikes",
  1938. "spill",
  1939. "spinal-coil",
  1940. "spine-arrow",
  1941. "spinning-blades",
  1942. "spinning-sword",
  1943. "spiral-arrow",
  1944. "spiral-bloom",
  1945. "spiral-bottle",
  1946. "spiral-shell",
  1947. "spiral-thrust",
  1948. "splash",
  1949. "split-body",
  1950. "split-cross",
  1951. "splurt",
  1952. "spoon",
  1953. "spoted-flower",
  1954. "spotted-mushroom",
  1955. "spotted-wound",
  1956. "spoutnik",
  1957. "spray",
  1958. "sprint",
  1959. "sprout-disc",
  1960. "sprout",
  1961. "spyglass",
  1962. "square-bottle",
  1963. "squid-head",
  1964. "squid",
  1965. "stag-head",
  1966. "stalagtite",
  1967. "star-prominences",
  1968. "star-pupil",
  1969. "star-sattelites",
  1970. "star-swirl",
  1971. "staryu",
  1972. "static",
  1973. "steel-claws",
  1974. "steeltoe-boots",
  1975. "steelwing-emblem",
  1976. "stick-splitting",
  1977. "sticking-plaster",
  1978. "stigmata",
  1979. "stiletto",
  1980. "stitched-wound",
  1981. "stomp",
  1982. "stone-axe",
  1983. "stone-block",
  1984. "stone-crafting",
  1985. "stone-pile",
  1986. "stone-spear",
  1987. "stone-sphere",
  1988. "stone-tablet",
  1989. "stone-throne",
  1990. "stone-tower",
  1991. "stopwatch",
  1992. "strafe",
  1993. "striking-balls",
  1994. "striking-diamonds",
  1995. "strong",
  1996. "suckered-tentacle",
  1997. "suicide",
  1998. "suits",
  1999. "sun",
  2000. "sunbeams",
  2001. "sundial",
  2002. "sunken-eye",
  2003. "sunrise",
  2004. "super-mushroom",
  2005. "supersonic-arrow",
  2006. "supersonic-bullet",
  2007. "surprised-skull",
  2008. "surprised",
  2009. "suspicious",
  2010. "swallow",
  2011. "swamp",
  2012. "swan",
  2013. "swap-bag",
  2014. "sword-array",
  2015. "sword-break",
  2016. "sword-clash",
  2017. "sword-hilt",
  2018. "sword-in-stone",
  2019. "sword-slice",
  2020. "sword-smithing",
  2021. "sword-spade",
  2022. "sword-spin",
  2023. "syringe",
  2024. "tank",
  2025. "target-arrows",
  2026. "target-dummy",
  2027. "target-laser",
  2028. "target-shot",
  2029. "targeted",
  2030. "targeting",
  2031. "tattered-banner",
  2032. "taurus",
  2033. "teapot",
  2034. "tear-tracks",
  2035. "techno-heart",
  2036. "telefrag",
  2037. "telepathy",
  2038. "teleport",
  2039. "templar-heart",
  2040. "temptation",
  2041. "tennis-ball",
  2042. "tentacle-strike",
  2043. "tentacurl",
  2044. "terror",
  2045. "tesla-coil",
  2046. "tesla-turret",
  2047. "tesla",
  2048. "test-tubes",
  2049. "thermometer-scale",
  2050. "third-eye",
  2051. "thor-fist",
  2052. "thorn-helix",
  2053. "thorned-arrow",
  2054. "thorny-vine",
  2055. "three-keys",
  2056. "three-leaves",
  2057. "thrown-charcoal",
  2058. "thrown-daggers",
  2059. "thrown-knife",
  2060. "thrown-spear",
  2061. "thrust",
  2062. "thunder-skull",
  2063. "thunder-struck",
  2064. "thunderball",
  2065. "tic-tac-toe",
  2066. "tick",
  2067. "tied-scroll",
  2068. "time-bomb",
  2069. "time-trap",
  2070. "tinker",
  2071. "toad-teeth",
  2072. "tombstone",
  2073. "tooth",
  2074. "top-hat",
  2075. "top-paw",
  2076. "torch",
  2077. "tornado",
  2078. "totem-head",
  2079. "tower-fall",
  2080. "trade",
  2081. "trample",
  2082. "transfuse",
  2083. "transportation-rings",
  2084. "tread",
  2085. "treasure-map",
  2086. "tree-branch",
  2087. "trefoil-lily",
  2088. "trefoil-shuriken",
  2089. "tribal-mask",
  2090. "trident",
  2091. "trigger-hurt",
  2092. "trilobite",
  2093. "triorb",
  2094. "triple-claws",
  2095. "triple-corn",
  2096. "triple-lock",
  2097. "triple-needle",
  2098. "triple-skulls",
  2099. "tripwire",
  2100. "tron-arrow",
  2101. "trophy",
  2102. "trousers",
  2103. "tune-pitch",
  2104. "turd",
  2105. "turret",
  2106. "turtle-shell",
  2107. "turtle",
  2108. "twirly-flower",
  2109. "twister",
  2110. "two-feathers",
  2111. "two-shadows",
  2112. "tyre",
  2113. "ubisoft-sun",
  2114. "udder",
  2115. "ultrasound",
  2116. "umbrella",
  2117. "uncertainty",
  2118. "underhand",
  2119. "unfriendly-fire",
  2120. "unlit-bomb",
  2121. "unlit-candelabra",
  2122. "unplugged",
  2123. "unstable-projectile",
  2124. "usable",
  2125. "valley",
  2126. "vanilla-flower",
  2127. "vial",
  2128. "vile-fluid",
  2129. "vine-flower",
  2130. "vine-leaf",
  2131. "vine-whip",
  2132. "vintage-robot",
  2133. "viola",
  2134. "virgo",
  2135. "virus",
  2136. "visored-helm",
  2137. "volcano",
  2138. "vomiting",
  2139. "voodoo-doll",
  2140. "vortex",
  2141. "vulture",
  2142. "walking-boot",
  2143. "wasp-sting",
  2144. "water-bolt",
  2145. "water-drop",
  2146. "water-splash",
  2147. "wave-crest",
  2148. "wave-strike",
  2149. "wavy-chains",
  2150. "wavy-itinerary",
  2151. "wax-seal",
  2152. "web-spit",
  2153. "weight-crush",
  2154. "wheat",
  2155. "whip",
  2156. "whiplash",
  2157. "whirlwind",
  2158. "white-book",
  2159. "white-cat",
  2160. "white-tower",
  2161. "wildfires",
  2162. "william-tell",
  2163. "windmill",
  2164. "wine-glass",
  2165. "wing-cloak",
  2166. "winged-arrow",
  2167. "winged-emblem",
  2168. "winged-shield",
  2169. "winged-sword",
  2170. "wingfoot",
  2171. "witch-flight",
  2172. "wizard-staff",
  2173. "wolf-head",
  2174. "wolf-howl",
  2175. "wolf-trap",
  2176. "wolverine-claws",
  2177. "wood-axe",
  2178. "wood-pile",
  2179. "wooden-door",
  2180. "wooden-sign",
  2181. "world",
  2182. "worm-mouth",
  2183. "worried-eyes",
  2184. "wrapped-heart",
  2185. "wrapped-sweet",
  2186. "wrecking-ball",
  2187. "wrench",
  2188. "wyvern",
  2189. "zebra-shield",
  2190. "zeus-sword",
  2191. "zigzag-leaf",
  2192. "zigzag-tune"
  2193. ];
  2194. var class_icon_names = [
  2195. "dnd5eclass-barbarian",
  2196. "dnd5eclass-bard",
  2197. "dnd5eclass-cleric",
  2198. "dnd5eclass-druid",
  2199. "dnd5eclass-fighter",
  2200. "dnd5eclass-monk",
  2201. "dnd5eclass-paladin",
  2202. "dnd5eclass-ranger",
  2203. "dnd5eclass-rogue",
  2204. "dnd5eclass-sorcerer",
  2205. "dnd5eclass-warlock",
  2206. "dnd5eclass-wizard"
  2207. ];
  2208. RpgCardsUI.icon_names = RpgCardsUI.icon_names.concat(class_icon_names);
  2209. })(RpgCardsUI || (RpgCardsUI = {}));
  2210. var RpgCardsUI;
  2211. (function (RpgCardsUI) {
  2212. RpgCardsUI.card_data_example = [
  2213. {
  2214. "count": 1,
  2215. "color": "maroon",
  2216. "title": "Burning Hands",
  2217. "icon": "book-cover",
  2218. "icon_back": "robe",
  2219. "contents": [
  2220. "subtitle | 1st level evocation",
  2221. "rule",
  2222. "property | Casting time | 1 action",
  2223. "property | Range | Self (15ft cone)",
  2224. "property | Components | V,S",
  2225. "rule",
  2226. "fill | 2",
  2227. "text | Each creature in a 15-foot cone must make a Dexterity saving throw. A creature takes <b>3d6 fire damage</b> on a failed save, or half as much damage on a successful one.",
  2228. "text | The fire ignites any flammable objects in the area that aren't being worn or carried.",
  2229. "fill | 3",
  2230. "section | At higher levels",
  2231. "text | +1d6 damage for each slot above 1st"
  2232. ],
  2233. "tags": ["spell", "mage"]
  2234. },
  2235. {
  2236. "count": 1,
  2237. "color": "indigo",
  2238. "title": "Cunning Action",
  2239. "icon": "white-book",
  2240. "icon_back": "cloak-dagger",
  2241. "contents": [
  2242. "subtitle | Rogue feature",
  2243. "rule",
  2244. "fill | 2",
  2245. "text | You can take a <b>bonus action on each of your turns</b> in combat. This action can be used only to take the <b>Dash, Disengage, or Hide</b> action.",
  2246. "fill | 2",
  2247. "section | Fast hands (Thief 3rd)",
  2248. "text | You can also use the bonus action to make a Dexterity (<b>Sleight of Hand</b>) check, use your thieves' tools to <b>disarm a trap</b> or <b>open a lock</b>, or take the <b>Use an Object</b> action."
  2249. ],
  2250. "tags": ["feature", "rogue"]
  2251. },
  2252. {
  2253. "count": 1,
  2254. "color": "dimgray",
  2255. "title": "Full Plate",
  2256. "icon": "breastplate",
  2257. "contents": [
  2258. "subtitle | Heavy armor (1500gp)",
  2259. "rule",
  2260. "property | AC | 18",
  2261. "property | Strength required | 15",
  2262. "property | Stealth | Disadvantage",
  2263. "rule",
  2264. "fill | 2",
  2265. "description | Heavy | Unless you have the required strength, your speed is reduced by 10 feet.",
  2266. "description | Stealth | You have disadvantage on Dexterity (Stealth) checks.",
  2267. "fill | 3"
  2268. ],
  2269. "tags": ["item", "armor"]
  2270. },
  2271. {
  2272. "count": 1,
  2273. "color": "dimgray",
  2274. "title": "Dagger",
  2275. "icon": "mixed-swords",
  2276. "contents": [
  2277. "subtitle | Simple melee weapon (2gp)",
  2278. "rule",
  2279. "property | Damage | 1d4 piercing",
  2280. "property | Modifier | Strength or Dexterity",
  2281. "property | Properties | Light, Finesse, Thrown (20/60)",
  2282. "rule",
  2283. "fill | 2",
  2284. "description | Finesse | Use your choice of Strength or Dexterity modifier for attack and damage.",
  2285. "description | Light | When you attack while dual wielding light weapons, you may use a bonus action to attack with your off hand.",
  2286. "description | Thrown | You can throw the weapon to make a ranged attack with the given range.",
  2287. "fill | 3"
  2288. ],
  2289. "tags": ["item", "weapon"]
  2290. },
  2291. {
  2292. "count": 1,
  2293. "color": "dimgray",
  2294. "title": "Shortsword of Very Long Names",
  2295. "title_size": "10",
  2296. "icon": "crossed-swords",
  2297. "contents": [
  2298. "subtitle | Simple melee weapon (10gp)",
  2299. "rule",
  2300. "property | Damage | 1d6 piercing",
  2301. "property | Modifier | Strength or Dexterity",
  2302. "property | Properties | Light, Finesse",
  2303. "rule",
  2304. "fill | 2",
  2305. "description | Finesse | Use your choice of Strength or Dexterity modifier for attack and damage.",
  2306. "description | Light | When you attack while dual wielding light weapons, you may use a bonus action to attack with your off hand.",
  2307. "fill | 3"
  2308. ],
  2309. "tags": ["item", "weapon", "magic"]
  2310. },
  2311. {
  2312. "count": 1,
  2313. "color": "dimgray",
  2314. "title": "Wand of Magic Missiles",
  2315. "icon": "crystal-wand",
  2316. "contents": [
  2317. "subtitle | Wondrous item",
  2318. "rule",
  2319. "property | Maximum charges | 7",
  2320. "property | Recharge | 1d6+1 each day",
  2321. "property | Depletion | If you expend the last charge, roll a d20. On a 1, the item is destroyed.",
  2322. "rule",
  2323. "fill | 2",
  2324. "description | Spells | You can use your action to cast the following spells:",
  2325. "bullet | magic missile, 1st level (1 charge)",
  2326. "bullet | magic missile, 2nd level (2 charges)",
  2327. "bullet | magic missile, 3rd level (3 charges)",
  2328. "fill | 3",
  2329. "boxes | 7 | 2.5"
  2330. ],
  2331. "tags": ["item", "wondrous-item", "magic"]
  2332. },
  2333. {
  2334. "count": 2,
  2335. "color": "dimgray",
  2336. "title": "Potion of Healing",
  2337. "icon": "drink-me",
  2338. "contents": [
  2339. "subtitle | Potion (50gp)",
  2340. "rule",
  2341. "property | Use time | 1 action",
  2342. "property | Hit points restored | 2d4+2",
  2343. "rule",
  2344. "fill | 2",
  2345. "text | When you drink this potion, you regain 2d4+2 hitpoints.",
  2346. "text | Drinking or administering a potion takes 1 action.",
  2347. "fill | 3"
  2348. ],
  2349. "tags": ["item", "consumable"]
  2350. },
  2351. {
  2352. "count": 1,
  2353. "color": "black",
  2354. "title": "Goblin",
  2355. "icon": "imp-laugh",
  2356. "contents": [
  2357. "subtitle | Small humanoid (goblinoid)",
  2358. "rule",
  2359. "property | Armor class | 15 (leather armor, shield)",
  2360. "property | Hit points | 7 (2d6)",
  2361. "rule",
  2362. "dndstats | 8 | 14 | 10 | 10 | 8 | 8",
  2363. "rule",
  2364. "property | Skills | Stealth +6",
  2365. "property | Challenge | 1/4 (50 XP)",
  2366. "rule",
  2367. "description | Nimble escape | Disengage or Hide as bonus action",
  2368. "fill | 2",
  2369. "section | Actions",
  2370. "description | Scimitar | Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) slashing damage"
  2371. ],
  2372. "tags": ["creature", "humanoid"]
  2373. }
  2374. ];
  2375. })(RpgCardsUI || (RpgCardsUI = {}));
  2376. /// <reference path="./card.ts" />
  2377. /// <reference path="./colors.ts" />
  2378. /// <reference path="./icons.ts" />
  2379. /// <reference path="./example_data.ts" />
  2380. /// <reference path="./jquery.d.ts" />
  2381. /// <reference path="./ace.d.ts" />
  2382. /// <reference path="./shortcut.d.ts" />
  2383. var RpgCardsUI;
  2384. (function (RpgCardsUI) {
  2385. var deck = null;
  2386. var options = null;
  2387. var cardGenerator = null;
  2388. var pageGenerator = null;
  2389. var editor;
  2390. var editorFilter;
  2391. var editorSort;
  2392. var update_in_progress = false;
  2393. // ============================================================================
  2394. // Seleted card
  2395. // ============================================================================
  2396. function selected_card_index() {
  2397. return parseInt($("#selected-card").val(), 10);
  2398. }
  2399. function selected_card() {
  2400. var index = selected_card_index();
  2401. if (deck.cards.length > index) {
  2402. return deck.cards[index];
  2403. }
  2404. else {
  2405. return null;
  2406. }
  2407. }
  2408. function select_card_by_index(index) {
  2409. var size = deck.cards.length;
  2410. if (size === 0) {
  2411. $("#selected-card").val("");
  2412. update_selected_card();
  2413. }
  2414. else {
  2415. index = Math.min(size - 1, index);
  2416. index = Math.max(0, index);
  2417. if (index != selected_card_index()) {
  2418. $("#selected-card").val("" + index);
  2419. update_selected_card();
  2420. }
  2421. }
  2422. }
  2423. function select_first_card() {
  2424. select_card_by_index(0);
  2425. }
  2426. function select_last_card() {
  2427. select_card_by_index(deck.cards.length - 1);
  2428. }
  2429. function select_next_card() {
  2430. select_card_by_index(selected_card_index() + 1);
  2431. }
  2432. function select_prev_card() {
  2433. select_card_by_index(selected_card_index() - 1);
  2434. }
  2435. function select_card_by_card(card) {
  2436. var index = deck.cards.indexOf(card);
  2437. select_card_by_index(index);
  2438. }
  2439. // ============================================================================
  2440. // Rendering
  2441. // ============================================================================
  2442. function render_selected_card() {
  2443. if (update_in_progress) {
  2444. return;
  2445. }
  2446. var card = selected_card();
  2447. $('#preview-container').empty();
  2448. if (card) {
  2449. var front = cardGenerator.card_front(card, options, " ");
  2450. var back = cardGenerator.card_back(card, options, " ");
  2451. $('#preview-container').html(front + "\n" + back);
  2452. }
  2453. }
  2454. function update_selected_card() {
  2455. update_in_progress = true;
  2456. var card = selected_card();
  2457. if (card) {
  2458. $("#card-title").val(card.title);
  2459. $("#card-title-size").val(card.title_size);
  2460. $("#card-title-icon-text").val(card.title_icon_text);
  2461. $("#card-count").val("" + card.count);
  2462. $("#card-icon").val(card.icon);
  2463. $("#card-icon-back").val(card.icon_back);
  2464. //$("#card-contents").val(card.contents.join("\n"));
  2465. editor.setValue(card.contents.join("\n"), -1);
  2466. $("#card-tags").val(card.tags.join(", "));
  2467. $("#card-color").val(card.color).change();
  2468. }
  2469. else {
  2470. $("#card-title").val("");
  2471. $("#card-title-size").val("");
  2472. $("#card-title-icon-text").val("");
  2473. $("#card-count").val("1");
  2474. $("#card-icon").val("");
  2475. $("#card-icon-back").val("");
  2476. //$("#card-contents").val("");
  2477. editor.setValue("");
  2478. $("#card-tags").val("");
  2479. $("#card-color").val("").change();
  2480. }
  2481. update_in_progress = false;
  2482. render_selected_card();
  2483. }
  2484. function update_card_list() {
  2485. deck.commit();
  2486. $("#total_card_count").text("This deck contains " + deck.cards.length + " unique cards.");
  2487. $('#selected-card').empty();
  2488. for (var i = 0; i < deck.cards.length; ++i) {
  2489. var card = deck.cards[i];
  2490. $('#selected-card').append($("<option></option>").attr("value", i).text(card.title));
  2491. }
  2492. update_selected_card();
  2493. }
  2494. // ============================================================================
  2495. // Color picker
  2496. // ============================================================================
  2497. function setup_color_selector() {
  2498. // Insert colors
  2499. $.each(RpgCardsUI.card_colors, function (name, val) {
  2500. $(".colorselector-data").append($("<option></option>").attr("value", name).attr("data-color", val).text(name));
  2501. });
  2502. // Callbacks for when the user picks a color
  2503. $('#default_color_selector').colorselector({
  2504. callback: function (value, color, title) {
  2505. $("#default-color").val(title);
  2506. set_default_color(title);
  2507. }
  2508. });
  2509. $('#card_color_selector').colorselector({
  2510. callback: function (value, color, title) {
  2511. $("#card-color").val(title);
  2512. set_card_color(value);
  2513. }
  2514. });
  2515. $('#foreground_color_selector').colorselector({
  2516. callback: function (value, color, title) {
  2517. $("#foreground-color").val(title);
  2518. set_foreground_color(value);
  2519. }
  2520. });
  2521. $('#background_color_selector').colorselector({
  2522. callback: function (value, color, title) {
  2523. $("#background-color").val(title);
  2524. set_background_color(value);
  2525. }
  2526. });
  2527. // Styling
  2528. $(".dropdown-colorselector").addClass("input-group-addon color-input-addon");
  2529. }
  2530. function set_card_color(value) {
  2531. var card = selected_card();
  2532. if (card) {
  2533. card.color = value;
  2534. render_selected_card();
  2535. }
  2536. }
  2537. function set_default_color(color) {
  2538. options.default_color = color;
  2539. render_selected_card();
  2540. }
  2541. function set_foreground_color(color) {
  2542. options.foreground_color = color;
  2543. }
  2544. function set_background_color(color) {
  2545. options.background_color = color;
  2546. }
  2547. function update_card_color_selector(color, input, selector) {
  2548. if ($(selector + " option[value='" + color + "']").length > 0) {
  2549. // Update the color selector to the entered value
  2550. $(selector).colorselector("setValue", color);
  2551. }
  2552. else {
  2553. // Unknown color - select a neutral color and reset the text value
  2554. $(selector).colorselector("setValue", "");
  2555. input.val(color);
  2556. }
  2557. }
  2558. // ============================================================================
  2559. // Card values
  2560. // ============================================================================
  2561. function on_change_card_title() {
  2562. var title = $("#card-title").val();
  2563. var card = selected_card();
  2564. if (card) {
  2565. card.title = title;
  2566. $("#selected-card option:selected").text(title);
  2567. render_selected_card();
  2568. }
  2569. }
  2570. function on_change_card_color() {
  2571. var input = $(this);
  2572. var color = input.val();
  2573. update_card_color_selector(color, input, "#card_color_selector");
  2574. set_card_color(color);
  2575. }
  2576. function on_change_card_property() {
  2577. var property = $(this).attr("data-property");
  2578. var value = $(this).val();
  2579. var card = selected_card();
  2580. if (card) {
  2581. card[property] = value;
  2582. render_selected_card();
  2583. }
  2584. }
  2585. function on_change_card_contents() {
  2586. var value = editor.getValue();
  2587. var card = selected_card();
  2588. if (card) {
  2589. card.contents = value.split("\n");
  2590. render_selected_card();
  2591. }
  2592. }
  2593. function on_change_card_tags() {
  2594. var value = $(this).val();
  2595. var card = selected_card();
  2596. if (card) {
  2597. if (value.trim().length == 0) {
  2598. card.tags = [];
  2599. }
  2600. else {
  2601. card.tags = value.split(",").map(function (val) {
  2602. return val.trim().toLowerCase();
  2603. });
  2604. }
  2605. render_selected_card();
  2606. }
  2607. }
  2608. // ============================================================================
  2609. // Global default values
  2610. // ============================================================================
  2611. function on_change_option() {
  2612. var property = $(this).attr("data-option");
  2613. var value = $(this).val();
  2614. options[property] = value;
  2615. render_selected_card();
  2616. }
  2617. function on_change_default_color() {
  2618. var input = $(this);
  2619. var color = input.val();
  2620. update_card_color_selector(color, input, "#default_color_selector");
  2621. set_default_color(color);
  2622. }
  2623. function on_change_default_icon() {
  2624. var value = $(this).val();
  2625. options.default_icon = value;
  2626. render_selected_card();
  2627. }
  2628. function on_change_default_title_size() {
  2629. options.default_title_size = $(this).val();
  2630. render_selected_card();
  2631. }
  2632. function on_change_default_icon_size() {
  2633. options.icon_inline = $(this).is(':checked');
  2634. render_selected_card();
  2635. }
  2636. // ============================================================================
  2637. // Map/Filter
  2638. // ============================================================================
  2639. function apply_default_color() {
  2640. deck.cards.forEach(function (card) {
  2641. card.color = options.default_color;
  2642. });
  2643. render_selected_card();
  2644. }
  2645. function apply_default_icon() {
  2646. deck.cards.forEach(function (card) {
  2647. card.icon = options.default_icon;
  2648. });
  2649. render_selected_card();
  2650. }
  2651. function apply_default_icon_back() {
  2652. deck.cards.forEach(function (card) {
  2653. card.icon_back = options.default_icon;
  2654. });
  2655. render_selected_card();
  2656. }
  2657. function sort() {
  2658. showModal("#sort-modal");
  2659. }
  2660. function sort_execute() {
  2661. hideModal("#sort-modal");
  2662. var fn_code = editorSort.getValue();
  2663. var fn = new Function("card_a", "card_b", fn_code);
  2664. deck.cards = deck.cards.sort(function (card_a, card_b) {
  2665. var result = fn(card_a, card_b);
  2666. return result;
  2667. });
  2668. update_card_list();
  2669. }
  2670. function filter() {
  2671. showModal("#filter-modal");
  2672. }
  2673. function filter_execute() {
  2674. hideModal("#filter-modal");
  2675. var fn_code = editorFilter.getValue();
  2676. var fn = new Function("card", "deck", fn_code);
  2677. deck.cards.forEach(function (card) {
  2678. fn(card, deck);
  2679. });
  2680. deck.commit();
  2681. update_card_list();
  2682. }
  2683. // ============================================================================
  2684. // Modals
  2685. // ============================================================================
  2686. function showModal(id) {
  2687. $(id).modal('show');
  2688. }
  2689. function hideModal(id) {
  2690. $(id).modal('hide');
  2691. }
  2692. // ============================================================================
  2693. // I/O
  2694. // ============================================================================
  2695. function save_file() {
  2696. var str = JSON.stringify(deck.toJSON(), null, " ");
  2697. var parts = [str];
  2698. var blob = new Blob(parts, { type: 'application/json' });
  2699. var url = URL.createObjectURL(blob);
  2700. var a = $("#file-save-link")[0];
  2701. a.href = url;
  2702. a.download = "rpg_cards.json";
  2703. a.click();
  2704. setTimeout(function () {
  2705. URL.revokeObjectURL(url);
  2706. }, 1000);
  2707. }
  2708. function load_sample() {
  2709. deck = RpgCards.CardDeck.fromJSON(RpgCardsUI.card_data_example);
  2710. update_card_list();
  2711. }
  2712. function clear_all() {
  2713. deck = new RpgCards.CardDeck();
  2714. update_card_list();
  2715. }
  2716. function ui_load_files(evt) {
  2717. // ui_clear_all();
  2718. var files = evt.target.files;
  2719. for (var i = 0, f; f = files[i]; i++) {
  2720. var reader = new FileReader();
  2721. reader.onload = function (reader) {
  2722. var data = JSON.parse(this.result);
  2723. var deck = RpgCards.CardDeck.fromJSON(data);
  2724. add_cards(deck.cards);
  2725. };
  2726. reader.readAsText(f);
  2727. }
  2728. // Reset file input
  2729. $("#file-load-form")[0].reset();
  2730. }
  2731. function add_cards(cards) {
  2732. deck.addCards(cards);
  2733. update_card_list();
  2734. }
  2735. function add_new_card() {
  2736. deck.addNewCard();
  2737. update_card_list();
  2738. select_card_by_index(deck.cards.length - 1);
  2739. }
  2740. function duplicate_card() {
  2741. var newCard = null;
  2742. if (deck.cards.length > 0) {
  2743. var old_card = selected_card();
  2744. newCard = deck.duplicateCard(old_card);
  2745. }
  2746. else {
  2747. newCard = deck.addNewCard();
  2748. }
  2749. update_card_list();
  2750. select_card_by_card(newCard);
  2751. }
  2752. function delete_card() {
  2753. var index = selected_card_index();
  2754. var card = selected_card();
  2755. deck.deleteCard(card);
  2756. update_card_list();
  2757. select_card_by_index(Math.min(index, deck.cards.length - 1));
  2758. }
  2759. // ============================================================================
  2760. // Menu
  2761. // ============================================================================
  2762. function open_help() {
  2763. showModal("#help-modal");
  2764. }
  2765. function select_icon() {
  2766. window.open("http://game-icons.net/", "_blank");
  2767. }
  2768. var generate_modal_shown = false;
  2769. function generate() {
  2770. if (deck.cards.length === 0) {
  2771. alert("Your deck is empty. Please define some cards first, or load the sample deck.");
  2772. return;
  2773. }
  2774. // Generate output HTML
  2775. var card_html = pageGenerator.generateHtml(deck.cards, options);
  2776. // Open a new window for the output
  2777. // Use a separate window to avoid CSS conflicts
  2778. var tab = window.open("output.html", 'rpg-cards-output');
  2779. if (generate_modal_shown == false) {
  2780. showModal("#print-modal");
  2781. generate_modal_shown = true;
  2782. }
  2783. // Send the generated HTML to the new window
  2784. // Use a delay to give the new window time to set up a message listener
  2785. setTimeout(function () {
  2786. tab.postMessage(card_html, '*');
  2787. }, 500);
  2788. }
  2789. function collapse_menu() {
  2790. $("#menu-column").hide();
  2791. $("#card-column").removeClass("col-lg-5");
  2792. $("#card-column").addClass("col-lg-8");
  2793. editor.resize();
  2794. }
  2795. function uncollapse_menu() {
  2796. $("#menu-column").show();
  2797. $("#card-column").removeClass("col-lg-8");
  2798. $("#card-column").addClass("col-lg-5");
  2799. editor.resize();
  2800. }
  2801. function toggle_menu() {
  2802. if ($("#menu-column").is(":visible")) {
  2803. collapse_menu();
  2804. }
  2805. else {
  2806. uncollapse_menu();
  2807. }
  2808. }
  2809. RpgCardsUI.toggle_menu = toggle_menu;
  2810. // ============================================================================
  2811. // Initialization
  2812. // ============================================================================
  2813. function init() {
  2814. deck = new RpgCards.CardDeck();
  2815. options = new RpgCards.Options();
  2816. cardGenerator = new RpgCards.CardHtmlGenerator;
  2817. pageGenerator = new RpgCards.PageHtmlGenerator;
  2818. editor = ace.edit("card-contents");
  2819. editor.setShowInvisibles(true);
  2820. editor.renderer.setShowGutter(false);
  2821. editor.setOption("wrap", "free");
  2822. editor.setTheme("ace/theme/chrome");
  2823. editor.getSession().setMode("ace/mode/rpgcard");
  2824. editor.$blockScrolling = Infinity;
  2825. editorFilter = ace.edit("filter-function");
  2826. editorFilter.setShowInvisibles(true);
  2827. editorFilter.setTheme("ace/theme/chrome");
  2828. editorFilter.getSession().setMode("ace/mode/javascript");
  2829. editorSort = ace.edit("sort-function");
  2830. editorSort.setShowInvisibles(true);
  2831. editorSort.setTheme("ace/theme/chrome");
  2832. editorSort.getSession().setMode("ace/mode/javascript");
  2833. setup_color_selector();
  2834. $('.icon-list').typeahead({ source: RpgCardsUI.icon_names });
  2835. // Menu
  2836. $("#sort-execute").click(sort_execute);
  2837. $("#filter-execute").click(filter_execute);
  2838. $("#button-generate").click(generate);
  2839. $("#button-load").click(function () {
  2840. $("#file-load").click();
  2841. });
  2842. $("#file-load").change(ui_load_files);
  2843. $("#button-clear").click(clear_all);
  2844. $("#button-load-sample").click(load_sample);
  2845. $("#button-save").click(save_file);
  2846. $("#button-sort").click(sort);
  2847. $("#button-filter").click(filter);
  2848. $("#button-add-card").click(add_new_card);
  2849. $("#button-duplicate-card").click(duplicate_card);
  2850. $("#button-delete-card").click(delete_card);
  2851. $("#button-help").click(open_help);
  2852. $("#button-apply-color").click(apply_default_color);
  2853. $("#button-apply-icon").click(apply_default_icon);
  2854. $("#button-apply-icon-back").click(apply_default_icon_back);
  2855. $("#selected-card").change(update_selected_card);
  2856. $("#card-title").change(on_change_card_title);
  2857. $("#card-title-size").change(on_change_card_property);
  2858. $("#card-title-icon-text").change(on_change_card_property);
  2859. $("#card-icon").change(on_change_card_property);
  2860. $("#card-count").change(on_change_card_property);
  2861. $("#card-icon-back").change(on_change_card_property);
  2862. $("#card-color").change(on_change_card_color);
  2863. editor.getSession().on('change', on_change_card_contents);
  2864. //$("#card-contents").change(on_change_card_contents);
  2865. $("#card-tags").change(on_change_card_tags);
  2866. // Global options
  2867. $("#page-size").change(on_change_option);
  2868. $("#page-rows").change(on_change_option);
  2869. $("#page-columns").change(on_change_option);
  2870. $("#card-arrangement").change(on_change_option);
  2871. $("#card-size").change(on_change_option);
  2872. $("#background-color").change(on_change_option);
  2873. $("#default-color").change(on_change_default_color);
  2874. $("#default-icon").change(on_change_default_icon);
  2875. $("#default-title-size").change(on_change_default_title_size);
  2876. $("#small-icons").change(on_change_default_icon_size);
  2877. $(".icon-select-button").click(select_icon);
  2878. // Shortcuts
  2879. var shortcut_options = { disable_in_input: true };
  2880. shortcut.add("ctrl+m", toggle_menu, shortcut_options);
  2881. shortcut.add("ctrl+n", add_new_card, shortcut_options);
  2882. shortcut.add("ctrl+d", duplicate_card, shortcut_options);
  2883. shortcut.add("delete", delete_card, shortcut_options);
  2884. shortcut.add("down", select_next_card, shortcut_options);
  2885. shortcut.add("page_down", select_next_card, shortcut_options);
  2886. shortcut.add("up", select_prev_card, shortcut_options);
  2887. shortcut.add("page_up", select_prev_card, shortcut_options);
  2888. shortcut.add("home", select_first_card, shortcut_options);
  2889. shortcut.add("end", select_last_card, shortcut_options);
  2890. update_card_list();
  2891. }
  2892. $(document).ready(function () {
  2893. init();
  2894. });
  2895. })(RpgCardsUI || (RpgCardsUI = {}));
  2896. //# sourceMappingURL=ui.js.map