0000: 28 66 75 6e 63 74 69 6f 6e 28 46 2f 2a 74 68 65 (function(F/*the
0010: 20 66 6f 73 73 69 6c 20 6f 62 6a 65 63 74 2a 2f fossil object*/
0020: 29 7b 0a 20 20 22 75 73 65 20 73 74 72 69 63 74 ){. "use strict
0030: 22 3b 0a 20 20 2f 2a 2a 0a 20 20 20 20 20 43 6f ";. /**. Co
0040: 64 65 20 66 6f 72 20 74 68 65 20 2f 66 69 6c 65 de for the /file
0050: 70 61 67 65 20 61 70 70 2e 20 52 65 71 75 69 72 page app. Requir
0060: 65 73 20 74 68 61 74 20 74 68 65 20 66 6f 73 73 es that the foss
0070: 69 6c 20 4a 53 0a 20 20 20 20 20 62 6f 6f 74 73 il JS. boots
0080: 74 72 61 70 70 69 6e 67 20 69 73 20 63 6f 6d 70 trapping is comp
0090: 6c 65 74 65 20 61 6e 64 20 66 6f 73 73 69 6c 2e lete and fossil.
00a0: 66 65 74 63 68 28 29 20 68 61 73 20 62 65 65 6e fetch() has been
00b0: 20 69 6e 73 74 61 6c 6c 65 64 2e 0a 0a 20 20 20 installed...
00c0: 20 20 43 75 73 74 6f 6d 20 65 76 65 6e 74 73 2c Custom events,
00d0: 20 68 61 6e 64 6c 65 64 20 76 69 61 20 66 6f 73 handled via fos
00e0: 73 69 6c 2e 70 61 67 65 2e 61 64 64 45 76 65 6e sil.page.addEven
00f0: 74 4c 69 73 74 65 6e 65 72 28 29 3a 0a 0a 20 20 tListener():..
0100: 20 20 20 2d 20 45 76 65 6e 74 20 27 66 69 6c 65 - Event 'file
0110: 65 64 69 74 2d 66 69 6c 65 2d 6c 6f 61 64 65 64 edit-file-loaded
0120: 27 3a 20 70 61 73 73 65 73 20 6f 6e 20 69 6e 66 ': passes on inf
0130: 6f 72 6d 61 74 69 6f 6e 20 77 68 65 6e 20 69 74 ormation when it
0140: 0a 20 20 20 20 20 6c 6f 61 64 73 20 61 20 66 69 . loads a fi
0150: 6c 65 2c 20 69 6e 20 74 68 65 20 66 6f 72 6d 20 le, in the form
0160: 6f 66 20 61 6e 20 6f 62 6a 65 63 74 3a 0a 0a 20 of an object:..
0170: 20 20 20 20 7b 0a 20 20 20 20 20 66 69 6c 65 6e {. filen
0180: 61 6d 65 3a 20 73 74 72 69 6e 67 2c 0a 20 20 20 ame: string,.
0190: 20 20 63 68 65 63 6b 69 6e 3a 20 55 55 49 44 20 checkin: UUID
01a0: 73 74 72 69 6e 67 2c 0a 20 20 20 20 20 69 73 45 string,. isE
01b0: 78 65 3a 20 62 6f 6f 6c 2c 0a 20 20 20 20 20 6d xe: bool,. m
01c0: 69 6d 65 74 79 70 65 3a 20 6d 69 6d 65 74 79 70 imetype: mimetyp
01d0: 65 20 73 74 72 69 6e 67 2c 20 61 73 20 64 65 74 e string, as det
01e0: 65 72 6d 69 6e 65 64 20 62 79 20 74 68 65 20 66 ermined by the f
01f0: 6f 73 73 69 6c 20 73 65 72 76 65 72 2e 0a 20 20 ossil server..
0200: 20 20 20 7d 0a 0a 20 20 20 20 20 54 68 65 20 66 }.. The f
0210: 6f 73 73 69 6c 2e 70 61 67 65 2e 66 69 6c 65 43 ossil.page.fileC
0220: 6f 6e 74 65 6e 74 28 29 20 6d 65 74 68 6f 64 20 ontent() method
0230: 67 65 74 73 20 6f 72 20 73 65 74 73 20 74 68 65 gets or sets the
0240: 20 63 75 72 72 65 6e 74 20 66 69 6c 65 0a 20 20 current file.
0250: 20 20 20 63 6f 6e 74 65 6e 74 20 66 6f 72 20 74 content for t
0260: 68 65 20 70 61 67 65 2e 0a 0a 20 20 20 20 20 2d he page... -
0270: 20 45 76 65 6e 74 20 27 66 69 6c 65 65 64 69 74 Event 'fileedit
0280: 2d 63 6f 6e 74 65 6e 74 2d 72 65 70 6c 61 63 65 -content-replace
0290: 64 27 3a 20 77 68 65 6e 20 74 68 65 20 65 64 69 d': when the edi
02a0: 74 6f 72 27 73 20 63 6f 6e 74 65 6e 74 20 69 73 tor's content is
02b0: 0a 20 20 20 20 20 72 65 70 6c 61 63 65 64 2c 20 . replaced,
02c0: 61 73 20 6f 70 70 6f 73 65 64 20 74 6f 20 69 74 as opposed to it
02d0: 20 62 65 69 6e 67 20 65 64 69 74 65 64 20 76 69 being edited vi
02e0: 61 20 75 73 65 72 0a 20 20 20 20 20 69 6e 74 65 a user. inte
02f0: 72 61 63 74 69 6f 6e 2e 20 54 68 69 73 20 6e 6f raction. This no
0300: 72 6d 61 6c 6c 79 20 68 61 70 70 65 6e 73 20 76 rmally happens v
0310: 69 61 20 73 65 6c 65 63 74 69 6e 67 20 61 20 66 ia selecting a f
0320: 69 6c 65 20 74 6f 0a 20 20 20 20 20 6c 6f 61 64 ile to. load
0330: 2e 20 54 68 65 20 65 76 65 6e 74 20 64 65 74 61 . The event deta
0340: 69 6c 20 69 73 20 74 68 65 20 66 6f 73 73 69 6c il is the fossil
0350: 2e 70 61 67 65 20 6f 62 6a 65 63 74 2c 20 6e 6f .page object, no
0360: 74 20 74 68 65 20 63 75 72 72 65 6e 74 0a 20 20 t the current.
0370: 20 20 20 66 69 6c 65 20 63 6f 6e 74 65 6e 74 2e file content.
0380: 0a 0a 20 20 20 20 20 2d 20 45 76 65 6e 74 20 27 .. - Event '
0390: 66 69 6c 65 65 64 69 74 2d 70 72 65 76 69 65 77 fileedit-preview
03a0: 2d 75 70 64 61 74 65 64 27 3a 20 77 68 65 6e 20 -updated': when
03b0: 74 68 65 20 70 72 65 76 69 65 77 20 69 73 20 72 the preview is r
03c0: 65 66 72 65 73 68 65 64 0a 20 20 20 20 20 66 72 efreshed. fr
03d0: 6f 6d 20 74 68 65 20 73 65 72 76 65 72 2c 20 74 om the server, t
03e0: 68 69 73 20 65 76 65 6e 74 20 70 61 73 73 65 73 his event passes
03f0: 20 6f 6e 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 on information
0400: 61 62 6f 75 74 20 74 68 65 20 70 72 65 76 69 65 about the previe
0410: 77 0a 20 20 20 20 20 63 68 61 6e 67 65 20 69 6e w. change in
0420: 20 74 68 65 20 66 6f 72 6d 20 6f 66 20 61 6e 20 the form of an
0430: 6f 62 6a 65 63 74 3a 0a 0a 20 20 20 20 20 7b 0a object:.. {.
0440: 20 20 20 20 20 65 6c 65 6d 65 6e 74 3a 20 74 68 element: th
0450: 65 20 44 4f 4d 20 65 6c 65 6d 65 6e 74 20 77 68 e DOM element wh
0460: 69 63 68 20 63 6f 6e 74 61 69 6e 73 20 74 68 65 ich contains the
0470: 20 63 6f 6e 74 65 6e 74 20 70 72 65 76 69 65 77 content preview
0480: 2e 0a 0a 20 20 20 20 20 6d 69 6d 65 74 79 70 65 ... mimetype
0490: 3a 20 74 68 65 20 66 6f 73 73 69 6c 2d 72 65 70 : the fossil-rep
04a0: 6f 72 74 65 64 20 63 6f 6e 74 65 6e 74 20 6d 69 orted content mi
04b0: 6d 65 74 79 70 65 2e 0a 0a 20 20 20 20 20 70 72 metype... pr
04c0: 65 76 69 65 77 4d 6f 64 65 3a 20 61 20 73 74 72 eviewMode: a str
04d0: 69 6e 67 20 64 65 73 63 72 69 62 69 6e 67 20 74 ing describing t
04e0: 68 65 20 70 72 65 76 69 65 77 20 6d 6f 64 65 3a he preview mode:
04f0: 20 73 65 65 0a 20 20 20 20 20 20 20 74 68 65 20 see. the
0500: 66 6f 73 73 69 6c 2e 70 61 67 65 2e 70 72 65 76 fossil.page.prev
0510: 69 65 77 4d 6f 64 65 73 20 6d 61 70 20 66 6f 72 iewModes map for
0520: 20 74 68 65 20 76 61 6c 75 65 73 2e 20 54 68 69 the values. Thi
0530: 73 20 63 61 6e 0a 20 20 20 20 20 20 20 62 65 20 s can. be
0540: 75 73 65 64 20 74 6f 20 64 65 74 65 72 6d 69 6e used to determin
0550: 65 20 77 68 65 74 68 65 72 2c 20 65 2e 67 2e 2c e whether, e.g.,
0560: 20 74 68 65 20 63 6f 6e 74 65 6e 74 20 69 73 20 the content is
0570: 73 75 69 74 61 62 6c 65 0a 20 20 20 20 20 20 20 suitable.
0580: 66 6f 72 20 61 70 70 6c 79 69 6e 67 20 61 20 33 for applying a 3
0590: 72 64 2d 70 61 72 74 79 20 63 6f 64 65 20 68 69 rd-party code hi
05a0: 67 68 6c 69 67 68 74 69 6e 67 20 41 50 49 20 74 ghlighting API t
05b0: 6f 2e 0a 20 20 20 20 20 7d 0a 0a 20 20 20 20 20 o.. }..
05c0: 48 65 72 65 27 73 20 61 6e 20 65 78 61 6d 70 6c Here's an exampl
05d0: 65 20 77 68 69 63 68 20 63 61 6e 20 62 65 20 75 e which can be u
05e0: 73 65 64 20 77 69 74 68 20 74 68 65 20 68 69 67 sed with the hig
05f0: 68 6c 69 67 68 74 6a 73 20 63 6f 64 65 0a 20 20 hlightjs code.
0600: 20 20 20 68 69 67 68 6c 69 67 68 74 65 72 20 74 highlighter t
0610: 6f 20 75 70 64 61 74 65 20 74 68 65 20 68 69 67 o update the hig
0620: 68 6c 69 67 68 74 69 6e 67 20 77 68 65 6e 20 74 hlighting when t
0630: 68 65 20 70 72 65 76 69 65 77 20 69 73 0a 20 20 he preview is.
0640: 20 20 20 72 65 66 72 65 73 68 65 64 20 69 6e 20 refreshed in
0650: 22 77 69 6b 69 22 20 6d 6f 64 65 20 28 77 68 69 "wiki" mode (whi
0660: 63 68 20 69 6e 63 6c 75 64 65 73 20 66 6f 73 73 ch includes foss
0670: 69 6c 2d 6e 61 74 69 76 65 20 77 69 6b 69 20 61 il-native wiki a
0680: 6e 64 0a 20 20 20 20 20 6d 61 72 6b 64 6f 77 6e nd. markdown
0690: 29 3a 0a 0a 20 20 20 20 20 66 6f 73 73 69 6c 2e ):.. fossil.
06a0: 70 61 67 65 2e 61 64 64 45 76 65 6e 74 4c 69 73 page.addEventLis
06b0: 74 65 6e 65 72 28 0a 20 20 20 20 20 20 20 27 66 tener(. 'f
06c0: 69 6c 65 65 64 69 74 2d 70 72 65 76 69 65 77 2d ileedit-preview-
06d0: 75 70 64 61 74 65 64 27 2c 0a 20 20 20 20 20 20 updated',.
06e0: 20 28 65 76 29 3d 3e 7b 0a 20 20 20 20 20 20 20 (ev)=>{.
06f0: 20 20 69 66 28 65 76 2e 64 65 74 61 69 6c 2e 70 if(ev.detail.p
0700: 72 65 76 69 65 77 4d 6f 64 65 3d 3d 3d 27 77 69 reviewMode==='wi
0710: 6b 69 27 29 7b 0a 20 20 20 20 20 20 20 20 20 20 ki'){.
0720: 20 65 76 2e 64 65 74 61 69 6c 2e 65 6c 65 6d 65 ev.detail.eleme
0730: 6e 74 2e 71 75 65 72 79 53 65 6c 65 63 74 6f 72 nt.querySelector
0740: 41 6c 6c 28 0a 20 20 20 20 20 20 20 20 20 20 20 All(.
0750: 20 20 27 63 6f 64 65 5b 63 6c 61 73 73 5e 3d 6c 'code[class^=l
0760: 61 6e 67 75 61 67 65 2d 5d 27 0a 20 20 20 20 20 anguage-]'.
0770: 20 20 20 20 20 20 29 2e 66 6f 72 45 61 63 68 28 ).forEach(
0780: 28 65 29 3d 3e 68 6c 6a 73 2e 68 69 67 68 6c 69 (e)=>hljs.highli
0790: 67 68 74 42 6c 6f 63 6b 28 65 29 29 3b 0a 20 20 ghtBlock(e));.
07a0: 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 }.
07b0: 7d 0a 20 20 20 20 20 29 3b 0a 20 20 2a 2f 0a 20 }. );. */.
07c0: 20 63 6f 6e 73 74 20 45 20 3d 20 28 73 29 3d 3e const E = (s)=>
07d0: 64 6f 63 75 6d 65 6e 74 2e 71 75 65 72 79 53 65 document.querySe
07e0: 6c 65 63 74 6f 72 28 73 29 2c 0a 20 20 20 20 20 lector(s),.
07f0: 20 20 20 44 20 3d 20 46 2e 64 6f 6d 2c 0a 20 20 D = F.dom,.
0800: 20 20 20 20 20 20 50 20 3d 20 46 2e 70 61 67 65 P = F.page
0810: 3b 0a 0a 20 20 2f 2a 2a 0a 20 20 20 20 20 57 69 ;.. /**. Wi
0820: 64 67 65 74 20 66 6f 72 20 74 68 65 20 63 68 65 dget for the che
0830: 63 6b 69 6e 2f 66 69 6c 65 20 73 65 6c 65 63 74 ckin/file select
0840: 69 6f 6e 20 6c 69 73 74 2e 0a 20 20 2a 2f 0a 20 ion list.. */.
0850: 20 50 2e 66 69 6c 65 53 65 6c 65 63 74 6f 72 20 P.fileSelector
0860: 3d 20 7b 0a 20 20 20 20 65 3a 7b 0a 20 20 20 20 = {. e:{.
0870: 20 20 63 6f 6e 74 61 69 6e 65 72 3a 20 45 28 27 container: E('
0880: 23 66 69 6c 65 65 64 69 74 2d 66 69 6c 65 2d 73 #fileedit-file-s
0890: 65 6c 65 63 74 6f 72 27 29 0a 20 20 20 20 7d 2c elector'). },
08a0: 0a 20 20 20 20 66 69 6e 66 6f 3a 20 7b 7d 2c 0a . finfo: {},.
08b0: 20 20 20 20 63 61 63 68 65 3a 20 7b 0a 20 20 20 cache: {.
08c0: 20 20 20 63 68 65 63 6b 69 6e 73 3a 20 75 6e 64 checkins: und
08d0: 65 66 69 6e 65 64 2c 0a 20 20 20 20 20 20 66 69 efined,. fi
08e0: 6c 65 73 3a 7b 7d 0a 20 20 20 20 7d 2c 0a 20 20 les:{}. },.
08f0: 20 20 2f 2a 2a 0a 20 20 20 20 20 20 20 46 65 74 /**. Fet
0900: 63 68 65 73 20 74 68 65 20 6c 69 73 74 20 6f 66 ches the list of
0910: 20 6c 65 61 66 20 63 68 65 63 6b 69 6e 73 20 66 leaf checkins f
0920: 72 6f 6d 20 74 68 65 20 73 65 72 76 65 72 20 61 rom the server a
0930: 6e 64 20 75 70 64 61 74 65 73 0a 20 20 20 20 20 nd updates.
0940: 20 20 74 68 65 20 55 49 20 77 69 74 68 20 74 68 the UI with th
0950: 61 74 20 6c 69 73 74 2e 0a 20 20 20 20 2a 2f 0a at list.. */.
0960: 20 20 20 20 6c 6f 61 64 4c 65 61 76 65 73 3a 20 loadLeaves:
0970: 66 75 6e 63 74 69 6f 6e 28 29 7b 0a 20 20 20 20 function(){.
0980: 20 20 44 2e 61 70 70 65 6e 64 28 44 2e 63 6c 65 D.append(D.cle
0990: 61 72 45 6c 65 6d 65 6e 74 28 0a 20 20 20 20 20 arElement(.
09a0: 20 20 20 74 68 69 73 2e 65 2e 63 69 4c 69 73 74 this.e.ciList
09b0: 4c 61 62 65 6c 2c 0a 20 20 20 20 20 20 20 20 74 Label,. t
09c0: 68 69 73 2e 65 2e 73 65 6c 65 63 74 43 69 2c 0a his.e.selectCi,.
09d0: 20 20 20 20 20 20 20 20 74 68 69 73 2e 65 2e 73 this.e.s
09e0: 65 6c 65 63 74 46 69 6c 65 73 0a 20 20 20 20 20 electFiles.
09f0: 20 29 2c 22 4c 6f 61 64 69 6e 67 20 6c 65 61 76 ),"Loading leav
0a00: 65 73 2e 2e 2e 22 29 3b 0a 20 20 20 20 20 20 44 es...");. D
0a10: 2e 64 69 73 61 62 6c 65 28 74 68 69 73 2e 65 2e .disable(this.e.
0a20: 62 74 6e 4c 6f 61 64 46 69 6c 65 2c 20 74 68 69 btnLoadFile, thi
0a30: 73 2e 65 2e 73 65 6c 65 63 74 46 69 6c 65 73 2c s.e.selectFiles,
0a40: 20 74 68 69 73 2e 65 2e 73 65 6c 65 63 74 43 69 this.e.selectCi
0a50: 29 3b 20 0a 20 20 20 20 20 20 63 6f 6e 73 74 20 ); . const
0a60: 73 65 6c 66 20 3d 20 74 68 69 73 3b 0a 20 20 20 self = this;.
0a70: 20 20 20 46 2e 66 65 74 63 68 28 27 66 69 6c 65 F.fetch('file
0a80: 65 64 69 74 27 2c 7b 0a 20 20 20 20 20 20 20 20 edit',{.
0a90: 75 72 6c 50 61 72 61 6d 73 3a 27 61 6a 61 78 3d urlParams:'ajax=
0aa0: 66 69 6c 65 6c 69 73 74 26 6c 65 61 76 65 73 27 filelist&leaves'
0ab0: 2c 0a 20 20 20 20 20 20 20 20 72 65 73 70 6f 6e ,. respon
0ac0: 73 65 54 79 70 65 3a 20 27 6a 73 6f 6e 27 2c 0a seType: 'json',.
0ad0: 20 20 20 20 20 20 20 20 6f 6e 6c 6f 61 64 3a 20 onload:
0ae0: 66 75 6e 63 74 69 6f 6e 28 6c 69 73 74 29 7b 0a function(list){.
0af0: 20 20 20 20 20 20 20 20 20 20 44 2e 61 70 70 65 D.appe
0b00: 6e 64 28 44 2e 63 6c 65 61 72 45 6c 65 6d 65 6e nd(D.clearElemen
0b10: 74 28 73 65 6c 66 2e 65 2e 63 69 4c 69 73 74 4c t(self.e.ciListL
0b20: 61 62 65 6c 29 2c 0a 20 20 20 20 20 20 20 20 20 abel),.
0b30: 20 20 20 20 20 20 20 20 20 20 22 4f 70 65 6e 20 "Open
0b40: 6c 65 61 76 65 73 20 28 6e 65 77 65 73 74 20 66 leaves (newest f
0b50: 69 72 73 74 29 3a 22 29 3b 0a 20 20 20 20 20 20 irst):");.
0b60: 20 20 20 20 73 65 6c 66 2e 63 61 63 68 65 2e 63 self.cache.c
0b70: 68 65 63 6b 69 6e 73 20 3d 20 6c 69 73 74 3b 0a heckins = list;.
0b80: 20 20 20 20 20 20 20 20 20 20 44 2e 63 6c 65 61 D.clea
0b90: 72 45 6c 65 6d 65 6e 74 28 44 2e 65 6e 61 62 6c rElement(D.enabl
0ba0: 65 28 73 65 6c 66 2e 65 2e 73 65 6c 65 63 74 43 e(self.e.selectC
0bb0: 69 29 29 3b 0a 20 20 20 20 20 20 20 20 20 20 6c i));. l
0bc0: 65 74 20 6c 6f 61 64 54 68 69 73 4f 6e 65 3b 0a et loadThisOne;.
0bd0: 20 20 20 20 20 20 20 20 20 20 6c 69 73 74 2e 66 list.f
0be0: 6f 72 45 61 63 68 28 66 75 6e 63 74 69 6f 6e 28 orEach(function(
0bf0: 6f 2c 6e 29 7b 0a 20 20 20 20 20 20 20 20 20 20 o,n){.
0c00: 20 20 69 66 28 21 6e 29 20 6c 6f 61 64 54 68 69 if(!n) loadThi
0c10: 73 4f 6e 65 20 3d 20 6f 3b 0a 20 20 20 20 20 20 sOne = o;.
0c20: 20 20 20 20 20 20 44 2e 6f 70 74 69 6f 6e 28 73 D.option(s
0c30: 65 6c 66 2e 65 2e 73 65 6c 65 63 74 43 69 2c 20 elf.e.selectCi,
0c40: 6f 2e 63 68 65 63 6b 69 6e 2c 0a 20 20 20 20 20 o.checkin,.
0c50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0c60: 6f 2e 74 69 6d 65 73 74 61 6d 70 2b 27 20 5b 27 o.timestamp+' ['
0c70: 2b 6f 2e 62 72 61 6e 63 68 2b 27 5d 3a 20 27 0a +o.branch+']: '.
0c80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0c90: 20 20 20 20 20 2b 46 2e 68 61 73 68 44 69 67 69 +F.hashDigi
0ca0: 74 73 28 6f 2e 63 68 65 63 6b 69 6e 29 29 3b 0a ts(o.checkin));.
0cb0: 20 20 20 20 20 20 20 20 20 20 7d 29 3b 0a 20 20 });.
0cc0: 20 20 20 20 20 20 20 20 73 65 6c 66 2e 6c 6f 61 self.loa
0cd0: 64 46 69 6c 65 73 28 6c 6f 61 64 54 68 69 73 4f dFiles(loadThisO
0ce0: 6e 65 20 3f 20 6c 6f 61 64 54 68 69 73 4f 6e 65 ne ? loadThisOne
0cf0: 2e 63 68 65 63 6b 69 6e 20 3a 20 66 61 6c 73 65 .checkin : false
0d00: 29 3b 0a 20 20 20 20 20 20 20 20 7d 0a 20 20 20 );. }.
0d10: 20 20 20 7d 29 3b 0a 20 20 20 20 7d 2c 0a 20 20 });. },.
0d20: 20 20 2f 2a 2a 0a 20 20 20 20 20 20 20 4c 6f 61 /**. Loa
0d30: 64 73 20 74 68 65 20 66 69 6c 65 20 6c 69 73 74 ds the file list
0d40: 20 66 6f 72 20 74 68 65 20 67 69 76 65 6e 20 63 for the given c
0d50: 68 65 63 6b 69 6e 20 55 55 49 44 2e 20 49 74 20 heckin UUID. It
0d60: 75 73 65 73 20 61 0a 20 20 20 20 20 20 20 63 61 uses a. ca
0d70: 63 68 65 64 20 63 6f 70 79 20 6f 6e 20 73 75 62 ched copy on sub
0d80: 73 65 71 75 65 6e 74 20 63 61 6c 6c 73 20 66 6f sequent calls fo
0d90: 72 20 74 68 65 20 73 61 6d 65 20 55 55 49 44 2e r the same UUID.
0da0: 20 49 66 20 70 61 73 73 65 64 20 61 0a 20 20 20 If passed a.
0db0: 20 20 20 20 66 61 6c 73 79 20 76 61 6c 75 65 2c falsy value,
0dc0: 20 69 74 20 69 6e 73 74 65 61 64 20 63 6c 65 61 it instead clea
0dd0: 72 73 20 61 6e 64 20 64 69 73 61 62 6c 65 73 20 rs and disables
0de0: 74 68 65 20 66 69 6c 65 20 73 65 6c 65 63 74 69 the file selecti
0df0: 6f 6e 0a 20 20 20 20 20 20 20 6c 69 73 74 2e 0a on. list..
0e00: 20 20 20 20 2a 2f 0a 20 20 20 20 6c 6f 61 64 46 */. loadF
0e10: 69 6c 65 73 3a 20 66 75 6e 63 74 69 6f 6e 28 63 iles: function(c
0e20: 69 55 75 69 64 29 7b 0a 20 20 20 20 20 20 64 65 iUuid){. de
0e30: 6c 65 74 65 20 74 68 69 73 2e 66 69 6e 66 6f 2e lete this.finfo.
0e40: 66 69 6c 65 6e 61 6d 65 3b 0a 20 20 20 20 20 20 filename;.
0e50: 74 68 69 73 2e 66 69 6e 66 6f 2e 63 68 65 63 6b this.finfo.check
0e60: 69 6e 20 3d 20 63 69 55 75 69 64 3b 0a 20 20 20 in = ciUuid;.
0e70: 20 20 20 63 6f 6e 73 74 20 73 65 6c 46 69 6c 65 const selFile
0e80: 73 20 3d 20 74 68 69 73 2e 65 2e 73 65 6c 65 63 s = this.e.selec
0e90: 74 46 69 6c 65 73 3b 0a 20 20 20 20 20 20 69 66 tFiles;. if
0ea0: 28 21 63 69 55 75 69 64 29 7b 0a 20 20 20 20 20 (!ciUuid){.
0eb0: 20 20 20 44 2e 63 6c 65 61 72 45 6c 65 6d 65 6e D.clearElemen
0ec0: 74 28 44 2e 64 69 73 61 62 6c 65 28 73 65 6c 46 t(D.disable(selF
0ed0: 69 6c 65 73 2c 20 74 68 69 73 2e 65 2e 62 74 6e iles, this.e.btn
0ee0: 4c 6f 61 64 46 69 6c 65 29 29 3b 0a 20 20 20 20 LoadFile));.
0ef0: 20 20 20 20 72 65 74 75 72 6e 20 74 68 69 73 3b return this;
0f00: 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 63 . }. c
0f10: 6f 6e 73 74 20 6f 6e 6c 6f 61 64 20 3d 20 28 72 onst onload = (r
0f20: 65 73 70 6f 6e 73 65 29 3d 3e 7b 0a 20 20 20 20 esponse)=>{.
0f30: 20 20 20 20 44 2e 63 6c 65 61 72 45 6c 65 6d 65 D.clearEleme
0f40: 6e 74 28 73 65 6c 46 69 6c 65 73 29 3b 0a 20 20 nt(selFiles);.
0f50: 20 20 20 20 20 20 44 2e 61 70 70 65 6e 64 28 0a D.append(.
0f60: 20 20 20 20 20 20 20 20 20 20 44 2e 63 6c 65 61 D.clea
0f70: 72 45 6c 65 6d 65 6e 74 28 74 68 69 73 2e 65 2e rElement(this.e.
0f80: 66 69 6c 65 4c 69 73 74 4c 61 62 65 6c 29 2c 0a fileListLabel),.
0f90: 20 20 20 20 20 20 20 20 20 20 22 45 64 69 74 61 "Edita
0fa0: 62 6c 65 20 66 69 6c 65 73 20 66 6f 72 20 22 2c ble files for ",
0fb0: 0a 20 20 20 20 20 20 20 20 20 20 44 2e 61 70 70 . D.app
0fc0: 65 6e 64 28 0a 20 20 20 20 20 20 20 20 20 20 20 end(.
0fd0: 20 44 2e 63 6f 64 65 28 29 2c 20 22 5b 22 2c 0a D.code(), "[",.
0fe0: 20 20 20 20 20 20 20 20 20 20 20 20 44 2e 61 28 D.a(
0ff0: 46 2e 72 65 70 6f 55 72 6c 28 27 74 69 6d 65 6c F.repoUrl('timel
1000: 69 6e 65 27 2c 7b 0a 20 20 20 20 20 20 20 20 20 ine',{.
1010: 20 20 20 20 20 63 3a 20 63 69 55 75 69 64 0a 20 c: ciUuid.
1020: 20 20 20 20 20 20 20 20 20 20 20 7d 29 2c 20 46 }), F
1030: 2e 68 61 73 68 44 69 67 69 74 73 28 63 69 55 75 .hashDigits(ciUu
1040: 69 64 29 29 2c 22 5d 22 0a 20 20 20 20 20 20 20 id)),"]".
1050: 20 20 20 29 2c 20 22 3a 22 0a 20 20 20 20 20 20 ), ":".
1060: 20 20 29 3b 0a 20 20 20 20 20 20 20 20 74 68 69 );. thi
1070: 73 2e 63 61 63 68 65 2e 66 69 6c 65 73 5b 72 65 s.cache.files[re
1080: 73 70 6f 6e 73 65 2e 63 68 65 63 6b 69 6e 5d 20 sponse.checkin]
1090: 3d 20 72 65 73 70 6f 6e 73 65 3b 0a 20 20 20 20 = response;.
10a0: 20 20 20 20 72 65 73 70 6f 6e 73 65 2e 65 64 69 response.edi
10b0: 74 61 62 6c 65 46 69 6c 65 73 2e 66 6f 72 45 61 tableFiles.forEa
10c0: 63 68 28 66 75 6e 63 74 69 6f 6e 28 66 6e 2c 6e ch(function(fn,n
10d0: 29 7b 0a 20 20 20 20 20 20 20 20 20 20 44 2e 6f ){. D.o
10e0: 70 74 69 6f 6e 28 73 65 6c 46 69 6c 65 73 2c 20 ption(selFiles,
10f0: 66 6e 29 3b 0a 20 20 20 20 20 20 20 20 7d 29 3b fn);. });
1100: 0a 20 20 20 20 20 20 20 20 69 66 28 73 65 6c 46 . if(selF
1110: 69 6c 65 73 2e 6f 70 74 69 6f 6e 73 2e 6c 65 6e iles.options.len
1120: 67 74 68 29 7b 0a 20 20 20 20 20 20 20 20 20 20 gth){.
1130: 44 2e 65 6e 61 62 6c 65 28 73 65 6c 46 69 6c 65 D.enable(selFile
1140: 73 2c 20 74 68 69 73 2e 65 2e 62 74 6e 4c 6f 61 s, this.e.btnLoa
1150: 64 46 69 6c 65 29 3b 0a 20 20 20 20 20 20 20 20 dFile);.
1160: 7d 0a 20 20 20 20 20 20 7d 3b 0a 20 20 20 20 20 }. };.
1170: 20 63 6f 6e 73 74 20 67 6f 74 20 3d 20 74 68 69 const got = thi
1180: 73 2e 63 61 63 68 65 2e 66 69 6c 65 73 5b 63 69 s.cache.files[ci
1190: 55 75 69 64 5d 3b 0a 20 20 20 20 20 20 69 66 28 Uuid];. if(
11a0: 67 6f 74 29 7b 0a 20 20 20 20 20 20 20 20 6f 6e got){. on
11b0: 6c 6f 61 64 28 67 6f 74 29 3b 0a 20 20 20 20 20 load(got);.
11c0: 20 20 20 72 65 74 75 72 6e 20 74 68 69 73 3b 0a return this;.
11d0: 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 44 2e }. D.
11e0: 64 69 73 61 62 6c 65 28 73 65 6c 46 69 6c 65 73 disable(selFiles
11f0: 2c 74 68 69 73 2e 65 2e 62 74 6e 4c 6f 61 64 46 ,this.e.btnLoadF
1200: 69 6c 65 29 3b 0a 20 20 20 20 20 20 44 2e 63 6c ile);. D.cl
1210: 65 61 72 45 6c 65 6d 65 6e 74 28 73 65 6c 46 69 earElement(selFi
1220: 6c 65 73 29 3b 0a 20 20 20 20 20 20 44 2e 61 70 les);. D.ap
1230: 70 65 6e 64 28 44 2e 63 6c 65 61 72 45 6c 65 6d pend(D.clearElem
1240: 65 6e 74 28 74 68 69 73 2e 65 2e 66 69 6c 65 4c ent(this.e.fileL
1250: 69 73 74 4c 61 62 65 6c 29 2c 0a 20 20 20 20 20 istLabel),.
1260: 20 20 20 20 20 20 20 20 20 20 22 4c 6f 61 64 69 "Loadi
1270: 6e 67 20 66 69 6c 65 73 20 66 6f 72 20 22 2b 46 ng files for "+F
1280: 2e 68 61 73 68 44 69 67 69 74 73 28 63 69 55 75 .hashDigits(ciUu
1290: 69 64 29 2b 22 2e 2e 2e 22 29 3b 0a 20 20 20 20 id)+"...");.
12a0: 20 20 46 2e 66 65 74 63 68 28 27 66 69 6c 65 65 F.fetch('filee
12b0: 64 69 74 27 2c 7b 0a 20 20 20 20 20 20 20 20 75 dit',{. u
12c0: 72 6c 50 61 72 61 6d 73 3a 7b 61 6a 61 78 3a 27 rlParams:{ajax:'
12d0: 66 69 6c 65 6c 69 73 74 27 2c 20 63 68 65 63 6b filelist', check
12e0: 69 6e 3a 20 63 69 55 75 69 64 7d 2c 0a 20 20 20 in: ciUuid},.
12f0: 20 20 20 20 20 72 65 73 70 6f 6e 73 65 54 79 70 responseTyp
1300: 65 3a 20 27 6a 73 6f 6e 27 2c 0a 20 20 20 20 20 e: 'json',.
1310: 20 20 20 6f 6e 6c 6f 61 64 0a 20 20 20 20 20 20 onload.
1320: 7d 29 3b 0a 20 20 20 20 20 20 72 65 74 75 72 6e });. return
1330: 20 74 68 69 73 3b 0a 20 20 20 20 7d 2c 0a 20 20 this;. },.
1340: 20 20 2f 2a 2a 0a 20 20 20 20 20 20 20 49 6e 69 /**. Ini
1350: 74 69 61 6c 69 7a 65 73 20 74 68 65 20 63 68 65 tializes the che
1360: 63 6b 69 6e 2f 66 69 6c 65 20 73 65 6c 65 63 74 ckin/file select
1370: 6f 72 20 77 69 64 67 65 74 2e 20 4d 75 73 74 20 or widget. Must
1380: 6f 6e 6c 79 20 62 65 0a 20 20 20 20 20 20 20 63 only be. c
1390: 61 6c 6c 65 64 20 6f 6e 63 65 2e 0a 20 20 20 20 alled once..
13a0: 2a 2f 0a 20 20 20 20 69 6e 69 74 3a 20 66 75 6e */. init: fun
13b0: 63 74 69 6f 6e 28 29 7b 0a 20 20 20 20 20 20 63 ction(){. c
13c0: 6f 6e 73 74 20 73 65 6c 43 69 20 3d 20 74 68 69 onst selCi = thi
13d0: 73 2e 65 2e 73 65 6c 65 63 74 43 69 20 3d 20 44 s.e.selectCi = D
13e0: 2e 73 65 6c 65 63 74 28 29 2c 0a 20 20 20 20 20 .select(),.
13f0: 20 20 20 20 20 20 20 73 65 6c 46 69 6c 65 73 20 selFiles
1400: 3d 20 74 68 69 73 2e 65 2e 73 65 6c 65 63 74 46 = this.e.selectF
1410: 69 6c 65 73 0a 20 20 20 20 20 20 20 20 20 20 20 iles.
1420: 20 3d 20 44 2e 61 64 64 43 6c 61 73 73 28 44 2e = D.addClass(D.
1430: 73 65 6c 65 63 74 28 29 2c 20 27 66 69 6c 65 2d select(), 'file-
1440: 6c 69 73 74 27 29 2c 0a 20 20 20 20 20 20 20 20 list'),.
1450: 20 20 20 20 62 74 6e 4c 6f 61 64 20 3d 20 74 68 btnLoad = th
1460: 69 73 2e 65 2e 62 74 6e 4c 6f 61 64 46 69 6c 65 is.e.btnLoadFile
1470: 20 3d 0a 20 20 20 20 20 20 20 20 20 20 20 20 44 =. D
1480: 2e 61 64 64 43 6c 61 73 73 28 44 2e 62 75 74 74 .addClass(D.butt
1490: 6f 6e 28 22 4c 6f 61 64 20 66 69 6c 65 22 29 2c on("Load file"),
14a0: 20 22 66 6c 65 78 2d 73 68 72 69 6e 6b 22 29 2c "flex-shrink"),
14b0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 69 6c . fil
14c0: 65 73 4c 61 62 65 6c 20 3d 20 74 68 69 73 2e 65 esLabel = this.e
14d0: 2e 66 69 6c 65 4c 69 73 74 4c 61 62 65 6c 20 3d .fileListLabel =
14e0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 44 2e 61 . D.a
14f0: 64 64 43 6c 61 73 73 28 44 2e 64 69 76 28 29 2c ddClass(D.div(),
1500: 27 66 6c 65 78 2d 73 68 72 69 6e 6b 27 2c 27 66 'flex-shrink','f
1510: 69 6c 65 2d 6c 69 73 74 2d 6c 61 62 65 6c 27 29 ile-list-label')
1520: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 69 ,. ci
1530: 4c 61 62 65 6c 57 72 61 70 70 65 72 20 3d 20 44 LabelWrapper = D
1540: 2e 61 64 64 43 6c 61 73 73 28 0a 20 20 20 20 20 .addClass(.
1550: 20 20 20 20 20 20 20 20 20 44 2e 64 69 76 28 29 D.div()
1560: 2c 20 27 66 6c 65 78 2d 63 6f 6e 74 61 69 6e 65 , 'flex-containe
1570: 72 27 2c 27 66 6c 65 78 2d 72 6f 77 27 2c 20 27 r','flex-row', '
1580: 66 6c 65 78 2d 73 68 72 69 6e 6b 27 2c 0a 20 20 flex-shrink',.
1590: 20 20 20 20 20 20 20 20 20 20 20 20 27 73 74 72 'str
15a0: 65 74 63 68 27 0a 20 20 20 20 20 20 20 20 20 20 etch'.
15b0: 20 20 29 2c 0a 20 20 20 20 20 20 20 20 20 20 20 ),.
15c0: 20 62 74 6e 52 65 6c 6f 61 64 20 3d 20 44 2e 61 btnReload = D.a
15d0: 64 64 43 6c 61 73 73 28 0a 20 20 20 20 20 20 20 ddClass(.
15e0: 20 20 20 20 20 20 20 44 2e 62 75 74 74 6f 6e 28 D.button(
15f0: 27 52 65 6c 6f 61 64 27 29 2c 20 27 66 6c 65 78 'Reload'), 'flex
1600: 2d 73 68 72 69 6e 6b 27 0a 20 20 20 20 20 20 20 -shrink'.
1610: 20 20 20 20 20 29 2c 0a 20 20 20 20 20 20 20 20 ),.
1620: 20 20 20 20 63 69 4c 61 62 65 6c 20 3d 20 74 68 ciLabel = th
1630: 69 73 2e 65 2e 63 69 4c 69 73 74 4c 61 62 65 6c is.e.ciListLabel
1640: 20 3d 0a 20 20 20 20 20 20 20 20 20 20 20 20 44 =. D
1650: 2e 61 64 64 43 6c 61 73 73 28 44 2e 73 70 61 6e .addClass(D.span
1660: 28 29 2c 27 66 6c 65 78 2d 73 68 72 69 6e 6b 27 (),'flex-shrink'
1670: 2c 27 63 68 65 63 6b 69 6e 2d 6c 69 73 74 2d 6c ,'checkin-list-l
1680: 61 62 65 6c 27 29 0a 20 20 20 20 20 20 3b 0a 20 abel'). ;.
1690: 20 20 20 20 20 44 2e 61 74 74 72 28 73 65 6c 43 D.attr(selC
16a0: 69 2c 20 27 74 69 74 6c 65 27 2c 22 54 68 65 20 i, 'title',"The
16b0: 6c 69 73 74 20 6f 66 20 6f 70 65 6e 65 64 20 6c list of opened l
16c0: 65 61 76 65 73 2e 22 29 3b 0a 20 20 20 20 20 20 eaves.");.
16d0: 44 2e 61 74 74 72 28 73 65 6c 46 69 6c 65 73 2c D.attr(selFiles,
16e0: 20 27 74 69 74 6c 65 27 2c 0a 20 20 20 20 20 20 'title',.
16f0: 20 20 20 20 20 20 20 22 54 68 65 20 6c 69 73 74 "The list
1700: 20 6f 66 20 65 64 69 74 61 62 6c 65 20 66 69 6c of editable fil
1710: 65 73 20 66 6f 72 20 74 68 65 20 73 65 6c 65 63 es for the selec
1720: 74 65 64 20 63 68 65 63 6b 69 6e 2e 22 29 3b 0a ted checkin.");.
1730: 20 20 20 20 20 20 44 2e 61 74 74 72 28 62 74 6e D.attr(btn
1740: 4c 6f 61 64 2c 20 27 74 69 74 6c 65 27 2c 0a 20 Load, 'title',.
1750: 20 20 20 20 20 20 20 20 20 20 20 20 22 4c 6f 61 "Loa
1760: 64 20 74 68 65 20 73 65 6c 65 63 74 65 64 20 66 d the selected f
1770: 69 6c 65 20 69 6e 74 6f 20 74 68 65 20 65 64 69 ile into the edi
1780: 74 6f 72 2e 22 29 3b 0a 20 20 20 20 20 20 44 2e tor.");. D.
1790: 64 69 73 61 62 6c 65 28 73 65 6c 43 69 2c 20 73 disable(selCi, s
17a0: 65 6c 46 69 6c 65 73 2c 20 62 74 6e 4c 6f 61 64 elFiles, btnLoad
17b0: 29 3b 0a 20 20 20 20 20 20 44 2e 61 74 74 72 28 );. D.attr(
17c0: 73 65 6c 46 69 6c 65 73 2c 20 27 73 69 7a 65 27 selFiles, 'size'
17d0: 2c 20 31 30 29 3b 0a 20 20 20 20 20 20 44 2e 61 , 10);. D.a
17e0: 70 70 65 6e 64 28 0a 20 20 20 20 20 20 20 20 74 ppend(. t
17f0: 68 69 73 2e 65 2e 63 6f 6e 74 61 69 6e 65 72 2c his.e.container,
1800: 0a 20 20 20 20 20 20 20 20 44 2e 61 70 70 65 6e . D.appen
1810: 64 28 63 69 4c 61 62 65 6c 57 72 61 70 70 65 72 d(ciLabelWrapper
1820: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,.
1830: 20 20 20 62 74 6e 52 65 6c 6f 61 64 2c 20 63 69 btnReload, ci
1840: 4c 61 62 65 6c 29 2c 0a 20 20 20 20 20 20 20 20 Label),.
1850: 73 65 6c 43 69 2c 0a 20 20 20 20 20 20 20 20 66 selCi,. f
1860: 69 6c 65 73 4c 61 62 65 6c 2c 0a 20 20 20 20 20 ilesLabel,.
1870: 20 20 20 73 65 6c 46 69 6c 65 73 2c 0a 20 20 20 selFiles,.
1880: 20 20 20 20 20 62 74 6e 4c 6f 61 64 0a 20 20 20 btnLoad.
1890: 20 20 20 29 3b 0a 20 20 20 20 20 20 74 68 69 73 );. this
18a0: 2e 6c 6f 61 64 4c 65 61 76 65 73 28 29 3b 0a 20 .loadLeaves();.
18b0: 20 20 20 20 20 73 65 6c 43 69 2e 61 64 64 45 76 selCi.addEv
18c0: 65 6e 74 4c 69 73 74 65 6e 65 72 28 0a 20 20 20 entListener(.
18d0: 20 20 20 20 20 27 63 68 61 6e 67 65 27 2c 20 28 'change', (
18e0: 65 29 3d 3e 74 68 69 73 2e 6c 6f 61 64 46 69 6c e)=>this.loadFil
18f0: 65 73 28 65 2e 74 61 72 67 65 74 2e 76 61 6c 75 es(e.target.valu
1900: 65 29 2c 20 66 61 6c 73 65 0a 20 20 20 20 20 20 e), false.
1910: 29 3b 0a 20 20 20 20 20 20 62 74 6e 4c 6f 61 64 );. btnLoad
1920: 2e 61 64 64 45 76 65 6e 74 4c 69 73 74 65 6e 65 .addEventListene
1930: 72 28 0a 20 20 20 20 20 20 20 20 27 63 6c 69 63 r(. 'clic
1940: 6b 27 2c 20 28 65 29 3d 3e 7b 0a 20 20 20 20 20 k', (e)=>{.
1950: 20 20 20 20 20 74 68 69 73 2e 66 69 6e 66 6f 2e this.finfo.
1960: 66 69 6c 65 6e 61 6d 65 20 3d 20 73 65 6c 46 69 filename = selFi
1970: 6c 65 73 2e 76 61 6c 75 65 3b 0a 20 20 20 20 20 les.value;.
1980: 20 20 20 20 20 69 66 28 74 68 69 73 2e 66 69 6e if(this.fin
1990: 66 6f 2e 66 69 6c 65 6e 61 6d 65 29 7b 0a 20 20 fo.filename){.
19a0: 20 20 20 20 20 20 20 20 20 20 50 2e 6c 6f 61 64 P.load
19b0: 46 69 6c 65 28 74 68 69 73 2e 66 69 6e 66 6f 2e File(this.finfo.
19c0: 66 69 6c 65 6e 61 6d 65 2c 20 74 68 69 73 2e 66 filename, this.f
19d0: 69 6e 66 6f 2e 63 68 65 63 6b 69 6e 29 3b 0a 20 info.checkin);.
19e0: 20 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 }.
19f0: 20 20 20 7d 2c 20 66 61 6c 73 65 0a 20 20 20 20 }, false.
1a00: 20 20 29 3b 0a 20 20 20 20 20 20 62 74 6e 52 65 );. btnRe
1a10: 6c 6f 61 64 2e 61 64 64 45 76 65 6e 74 4c 69 73 load.addEventLis
1a20: 74 65 6e 65 72 28 0a 20 20 20 20 20 20 20 20 27 tener(. '
1a30: 63 6c 69 63 6b 27 2c 20 28 65 29 3d 3e 74 68 69 click', (e)=>thi
1a40: 73 2e 6c 6f 61 64 4c 65 61 76 65 73 28 29 2c 20 s.loadLeaves(),
1a50: 66 61 6c 73 65 0a 20 20 20 20 20 20 29 3b 0a 20 false. );.
1a60: 20 20 20 20 20 64 65 6c 65 74 65 20 74 68 69 73 delete this
1a70: 2e 69 6e 69 74 3b 0a 20 20 20 20 7d 0a 20 20 7d .init;. }. }
1a80: 2f 2a 50 2e 66 69 6c 65 53 65 6c 65 63 74 6f 72 /*P.fileSelector
1a90: 2a 2f 3b 0a 0a 20 20 0a 20 20 2f 2a 2a 0a 20 20 */;.. . /**.
1aa0: 20 20 20 49 6e 74 65 72 6e 61 6c 20 77 6f 72 6b Internal work
1ab0: 61 72 6f 75 6e 64 20 74 6f 20 73 65 6c 65 63 74 around to select
1ac0: 20 74 68 65 20 63 75 72 72 65 6e 74 20 70 72 65 the current pre
1ad0: 76 69 65 77 20 6d 6f 64 65 0a 20 20 20 20 20 61 view mode. a
1ae0: 6e 64 20 66 69 72 65 20 61 20 63 68 61 6e 67 65 nd fire a change
1af0: 20 65 76 65 6e 74 20 69 66 20 74 68 65 20 76 61 event if the va
1b00: 6c 75 65 20 61 63 74 75 61 6c 6c 79 20 63 68 61 lue actually cha
1b10: 6e 67 65 73 0a 20 20 20 20 20 6f 72 20 69 66 20 nges. or if
1b20: 66 6f 72 63 65 45 76 65 6e 74 20 69 73 20 74 72 forceEvent is tr
1b30: 75 74 68 79 2e 0a 20 20 2a 2f 0a 20 20 50 2e 73 uthy.. */. P.s
1b40: 65 6c 65 63 74 50 72 65 76 69 65 77 4d 6f 64 65 electPreviewMode
1b50: 20 3d 20 66 75 6e 63 74 69 6f 6e 28 6d 6f 64 65 = function(mode
1b60: 56 61 6c 75 65 2c 20 66 6f 72 63 65 45 76 65 6e Value, forceEven
1b70: 74 29 7b 0a 20 20 20 20 63 6f 6e 73 74 20 73 20 t){. const s
1b80: 3d 20 74 68 69 73 2e 65 2e 73 65 6c 65 63 74 50 = this.e.selectP
1b90: 72 65 76 69 65 77 4d 6f 64 65 3b 0a 20 20 20 20 reviewMode;.
1ba0: 69 66 28 21 6d 6f 64 65 56 61 6c 75 65 29 20 6d if(!modeValue) m
1bb0: 6f 64 65 56 61 6c 75 65 20 3d 20 73 2e 76 61 6c odeValue = s.val
1bc0: 75 65 3b 0a 20 20 20 20 65 6c 73 65 20 69 66 28 ue;. else if(
1bd0: 73 2e 76 61 6c 75 65 20 21 3d 20 6d 6f 64 65 56 s.value != modeV
1be0: 61 6c 75 65 29 7b 0a 20 20 20 20 20 20 73 2e 76 alue){. s.v
1bf0: 61 6c 75 65 20 3d 20 6d 6f 64 65 56 61 6c 75 65 alue = modeValue
1c00: 3b 0a 20 20 20 20 20 20 66 6f 72 63 65 45 76 65 ;. forceEve
1c10: 6e 74 20 3d 20 74 72 75 65 3b 0a 20 20 20 20 7d nt = true;. }
1c20: 0a 20 20 20 20 69 66 28 66 6f 72 63 65 45 76 65 . if(forceEve
1c30: 6e 74 29 7b 0a 20 20 20 20 20 20 2f 2f 20 46 6f nt){. // Fo
1c40: 72 63 65 20 55 49 20 75 70 64 61 74 65 0a 20 20 rce UI update.
1c50: 20 20 20 20 73 2e 64 69 73 70 61 74 63 68 45 76 s.dispatchEv
1c60: 65 6e 74 28 6e 65 77 20 45 76 65 6e 74 28 27 63 ent(new Event('c
1c70: 68 61 6e 67 65 27 2c 7b 74 61 72 67 65 74 3a 73 hange',{target:s
1c80: 7d 29 29 3b 0a 20 20 20 20 7d 0a 20 20 7d 3b 0a }));. }. };.
1c90: 0a 20 20 77 69 6e 64 6f 77 2e 61 64 64 45 76 65 . window.addEve
1ca0: 6e 74 4c 69 73 74 65 6e 65 72 28 22 6c 6f 61 64 ntListener("load
1cb0: 22 2c 20 66 75 6e 63 74 69 6f 6e 28 29 20 7b 0a ", function() {.
1cc0: 20 20 20 20 50 2e 62 61 73 65 20 3d 20 7b 74 61 P.base = {ta
1cd0: 67 3a 20 45 28 27 62 61 73 65 27 29 7d 3b 0a 20 g: E('base')};.
1ce0: 20 20 20 50 2e 62 61 73 65 2e 6f 72 69 67 69 6e P.base.origin
1cf0: 61 6c 48 72 65 66 20 3d 20 50 2e 62 61 73 65 2e alHref = P.base.
1d00: 74 61 67 2e 68 72 65 66 3b 0a 20 20 20 20 50 2e tag.href;. P.
1d10: 74 61 62 73 20 3d 20 6e 65 77 20 66 6f 73 73 69 tabs = new fossi
1d20: 6c 2e 54 61 62 4d 61 6e 61 67 65 72 28 27 23 66 l.TabManager('#f
1d30: 69 6c 65 65 64 69 74 2d 74 61 62 73 27 29 3b 0a ileedit-tabs');.
1d40: 20 20 20 20 50 2e 65 20 3d 20 7b 0a 20 20 20 20 P.e = {.
1d50: 20 20 74 61 45 64 69 74 6f 72 3a 20 45 28 27 23 taEditor: E('#
1d60: 66 69 6c 65 65 64 69 74 2d 63 6f 6e 74 65 6e 74 fileedit-content
1d70: 2d 65 64 69 74 6f 72 27 29 2c 0a 20 20 20 20 20 -editor'),.
1d80: 20 74 61 43 6f 6d 6d 65 6e 74 53 6d 61 6c 6c 3a taCommentSmall:
1d90: 20 45 28 27 23 66 69 6c 65 65 64 69 74 2d 63 6f E('#fileedit-co
1da0: 6d 6d 65 6e 74 27 29 2c 0a 20 20 20 20 20 20 74 mment'),. t
1db0: 61 43 6f 6d 6d 65 6e 74 42 69 67 3a 20 45 28 27 aCommentBig: E('
1dc0: 23 66 69 6c 65 65 64 69 74 2d 63 6f 6d 6d 65 6e #fileedit-commen
1dd0: 74 2d 62 69 67 27 29 2c 0a 20 20 20 20 20 20 61 t-big'),. a
1de0: 6a 61 78 43 6f 6e 74 65 6e 74 54 61 72 67 65 74 jaxContentTarget
1df0: 3a 20 45 28 27 23 61 6a 61 78 2d 74 61 72 67 65 : E('#ajax-targe
1e00: 74 27 29 2c 0a 20 20 20 20 20 20 62 74 6e 43 6f t'),. btnCo
1e10: 6d 6d 69 74 3a 20 45 28 22 23 66 69 6c 65 65 64 mmit: E("#fileed
1e20: 69 74 2d 62 74 6e 2d 63 6f 6d 6d 69 74 22 29 2c it-btn-commit"),
1e30: 0a 20 20 20 20 20 20 62 74 6e 52 65 6c 6f 61 64 . btnReload
1e40: 3a 20 45 28 22 23 66 69 6c 65 65 64 69 74 2d 74 : E("#fileedit-t
1e50: 61 62 2d 63 6f 6e 74 65 6e 74 20 3e 20 2e 66 69 ab-content > .fi
1e60: 6c 65 65 64 69 74 2d 6f 70 74 69 6f 6e 73 20 3e leedit-options >
1e70: 20 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ".
1e80: 20 20 20 20 20 20 2b 22 62 75 74 74 6f 6e 2e 66 +"button.f
1e90: 69 6c 65 65 64 69 74 2d 63 6f 6e 74 65 6e 74 2d ileedit-content-
1ea0: 72 65 6c 6f 61 64 22 29 2c 0a 20 20 20 20 20 20 reload"),.
1eb0: 73 65 6c 65 63 74 50 72 65 76 69 65 77 4d 6f 64 selectPreviewMod
1ec0: 65 3a 20 45 28 27 23 73 65 6c 65 63 74 2d 70 72 e: E('#select-pr
1ed0: 65 76 69 65 77 2d 6d 6f 64 65 20 73 65 6c 65 63 eview-mode selec
1ee0: 74 27 29 2c 0a 20 20 20 20 20 20 73 65 6c 65 63 t'),. selec
1ef0: 74 48 74 6d 6c 45 6d 73 57 72 61 70 3a 20 45 28 tHtmlEmsWrap: E(
1f00: 27 23 73 65 6c 65 63 74 2d 70 72 65 76 69 65 77 '#select-preview
1f10: 2d 68 74 6d 6c 2d 65 6d 73 27 29 2c 0a 20 20 20 -html-ems'),.
1f20: 20 20 20 73 65 6c 65 63 74 45 6f 6c 57 72 61 70 selectEolWrap
1f30: 3a 20 20 45 28 27 23 73 65 6c 65 63 74 2d 65 6f : E('#select-eo
1f40: 6c 2d 73 74 79 6c 65 27 29 2c 0a 20 20 20 20 20 l-style'),.
1f50: 20 73 65 6c 65 63 74 45 6f 6c 3a 20 20 45 28 27 selectEol: E('
1f60: 23 73 65 6c 65 63 74 2d 65 6f 6c 2d 73 74 79 6c #select-eol-styl
1f70: 65 20 73 65 6c 65 63 74 5b 6e 61 6d 65 3d 65 6f e select[name=eo
1f80: 6c 5d 27 29 2c 0a 20 20 20 20 20 20 73 65 6c 65 l]'),. sele
1f90: 63 74 46 6f 6e 74 53 69 7a 65 57 72 61 70 3a 20 ctFontSizeWrap:
1fa0: 45 28 27 23 73 65 6c 65 63 74 2d 66 6f 6e 74 2d E('#select-font-
1fb0: 73 69 7a 65 27 29 2c 0a 20 20 20 20 20 20 73 65 size'),. se
1fc0: 6c 65 63 74 44 69 66 66 57 53 3a 20 20 45 28 27 lectDiffWS: E('
1fd0: 73 65 6c 65 63 74 5b 6e 61 6d 65 3d 64 69 66 66 select[name=diff
1fe0: 5f 77 73 5d 27 29 2c 0a 20 20 20 20 20 20 63 62 _ws]'),. cb
1ff0: 4c 69 6e 65 4e 75 6d 62 65 72 73 57 72 61 70 3a LineNumbersWrap:
2000: 20 45 28 27 23 63 62 2d 6c 69 6e 65 2d 6e 75 6d E('#cb-line-num
2010: 62 65 72 73 27 29 2c 0a 20 20 20 20 20 20 63 62 bers'),. cb
2020: 41 75 74 6f 50 72 65 76 69 65 77 3a 20 45 28 27 AutoPreview: E('
2030: 23 63 62 2d 70 72 65 76 69 65 77 2d 61 75 74 6f #cb-preview-auto
2040: 75 70 64 61 74 65 20 3e 20 69 6e 70 75 74 5b 74 update > input[t
2050: 79 70 65 3d 63 68 65 63 6b 62 6f 78 5d 27 29 2c ype=checkbox]'),
2060: 0a 20 20 20 20 20 20 70 72 65 76 69 65 77 54 61 . previewTa
2070: 72 67 65 74 3a 20 45 28 27 23 66 69 6c 65 65 64 rget: E('#fileed
2080: 69 74 2d 74 61 62 2d 70 72 65 76 69 65 77 2d 77 it-tab-preview-w
2090: 72 61 70 70 65 72 27 29 2c 0a 20 20 20 20 20 20 rapper'),.
20a0: 64 69 66 66 54 61 72 67 65 74 3a 20 45 28 27 23 diffTarget: E('#
20b0: 66 69 6c 65 65 64 69 74 2d 74 61 62 2d 64 69 66 fileedit-tab-dif
20c0: 66 2d 77 72 61 70 70 65 72 27 29 2c 0a 20 20 20 f-wrapper'),.
20d0: 20 20 20 63 62 49 73 45 78 65 3a 20 45 28 27 69 cbIsExe: E('i
20e0: 6e 70 75 74 5b 74 79 70 65 3d 63 68 65 63 6b 62 nput[type=checkb
20f0: 6f 78 5d 5b 6e 61 6d 65 3d 65 78 65 63 5f 62 69 ox][name=exec_bi
2100: 74 5d 27 29 2c 0a 20 20 20 20 20 20 66 73 46 69 t]'),. fsFi
2110: 6c 65 56 65 72 73 69 6f 6e 44 65 74 61 69 6c 73 leVersionDetails
2120: 3a 20 45 28 27 23 66 69 6c 65 2d 76 65 72 73 69 : E('#file-versi
2130: 6f 6e 2d 64 65 74 61 69 6c 73 27 29 2c 0a 20 20 on-details'),.
2140: 20 20 20 20 74 61 62 73 3a 7b 0a 20 20 20 20 20 tabs:{.
2150: 20 20 20 63 6f 6e 74 65 6e 74 3a 20 45 28 27 23 content: E('#
2160: 66 69 6c 65 65 64 69 74 2d 74 61 62 2d 63 6f 6e fileedit-tab-con
2170: 74 65 6e 74 27 29 2c 0a 20 20 20 20 20 20 20 20 tent'),.
2180: 70 72 65 76 69 65 77 3a 20 45 28 27 23 66 69 6c preview: E('#fil
2190: 65 65 64 69 74 2d 74 61 62 2d 70 72 65 76 69 65 eedit-tab-previe
21a0: 77 27 29 2c 0a 20 20 20 20 20 20 20 20 64 69 66 w'),. dif
21b0: 66 3a 20 45 28 27 23 66 69 6c 65 65 64 69 74 2d f: E('#fileedit-
21c0: 74 61 62 2d 64 69 66 66 27 29 2c 0a 20 20 20 20 tab-diff'),.
21d0: 20 20 20 20 63 6f 6d 6d 69 74 3a 20 45 28 27 23 commit: E('#
21e0: 66 69 6c 65 65 64 69 74 2d 74 61 62 2d 63 6f 6d fileedit-tab-com
21f0: 6d 69 74 27 29 0a 20 20 20 20 20 20 7d 0a 20 20 mit'). }.
2200: 20 20 7d 3b 0a 20 20 20 20 50 2e 66 69 6c 65 53 };. P.fileS
2210: 65 6c 65 63 74 6f 72 2e 69 6e 69 74 28 29 3b 0a elector.init();.
2220: 20 20 20 20 2f 2a 20 46 69 67 75 72 65 20 6f 75 /* Figure ou
2230: 74 20 77 68 69 63 68 20 63 6f 6d 6d 65 6e 74 20 t which comment
2240: 65 64 69 74 6f 72 20 74 6f 20 73 68 6f 77 20 62 editor to show b
2250: 79 20 64 65 66 61 75 6c 74 20 61 6e 64 0a 20 20 y default and.
2260: 20 20 20 20 20 68 69 64 65 20 74 68 65 20 6f 74 hide the ot
2270: 68 65 72 20 6f 6e 65 2e 20 42 79 20 64 65 66 61 her one. By defa
2280: 75 6c 74 20 77 65 20 74 61 6b 65 20 74 68 65 20 ult we take the
2290: 6f 6e 65 20 77 68 69 63 68 20 64 6f 65 73 0a 20 one which does.
22a0: 20 20 20 20 20 20 6e 6f 74 20 68 61 76 65 20 74 not have t
22b0: 68 65 20 27 68 69 64 64 65 6e 27 20 43 53 53 20 he 'hidden' CSS
22c0: 63 6c 61 73 73 2e 20 49 66 20 6e 65 69 74 68 65 class. If neithe
22d0: 72 20 64 6f 2c 20 77 65 20 64 65 66 61 75 6c 74 r do, we default
22e0: 0a 20 20 20 20 20 20 20 74 6f 20 73 69 6e 67 6c . to singl
22f0: 65 2d 6c 69 6e 65 20 6d 6f 64 65 2e 20 2a 2f 0a e-line mode. */.
2300: 20 20 20 20 69 66 28 44 2e 68 61 73 43 6c 61 73 if(D.hasClas
2310: 73 28 50 2e 65 2e 74 61 43 6f 6d 6d 65 6e 74 53 s(P.e.taCommentS
2320: 6d 61 6c 6c 2c 20 27 68 69 64 64 65 6e 27 29 29 mall, 'hidden'))
2330: 7b 0a 20 20 20 20 20 20 50 2e 65 2e 74 61 43 6f {. P.e.taCo
2340: 6d 6d 65 6e 74 20 3d 20 50 2e 65 2e 74 61 43 6f mment = P.e.taCo
2350: 6d 6d 65 6e 74 42 69 67 3b 0a 20 20 20 20 7d 65 mmentBig;. }e
2360: 6c 73 65 20 69 66 28 44 2e 68 61 73 43 6c 61 73 lse if(D.hasClas
2370: 73 28 50 2e 65 2e 74 61 43 6f 6d 6d 65 6e 74 42 s(P.e.taCommentB
2380: 69 67 2c 27 68 69 64 64 65 6e 27 29 29 7b 0a 20 ig,'hidden')){.
2390: 20 20 20 20 20 50 2e 65 2e 74 61 43 6f 6d 6d 65 P.e.taComme
23a0: 6e 74 20 3d 20 50 2e 65 2e 74 61 43 6f 6d 6d 65 nt = P.e.taComme
23b0: 6e 74 53 6d 61 6c 6c 3b 0a 20 20 20 20 7d 65 6c ntSmall;. }el
23c0: 73 65 7b 0a 20 20 20 20 20 20 50 2e 65 2e 74 61 se{. P.e.ta
23d0: 43 6f 6d 6d 65 6e 74 20 3d 20 50 2e 65 2e 74 61 Comment = P.e.ta
23e0: 43 6f 6d 6d 65 6e 74 53 6d 61 6c 6c 3b 0a 20 20 CommentSmall;.
23f0: 20 20 20 20 44 2e 61 64 64 43 6c 61 73 73 28 50 D.addClass(P
2400: 2e 65 2e 74 61 43 6f 6d 6d 65 6e 74 42 69 67 2c .e.taCommentBig,
2410: 20 27 68 69 64 64 65 6e 27 29 3b 0a 20 20 20 20 'hidden');.
2420: 7d 0a 20 20 20 20 44 2e 72 65 6d 6f 76 65 43 6c }. D.removeCl
2430: 61 73 73 28 50 2e 65 2e 74 61 43 6f 6d 6d 65 6e ass(P.e.taCommen
2440: 74 2c 20 27 68 69 64 64 65 6e 27 29 3b 0a 0a 20 t, 'hidden');..
2450: 20 20 20 50 2e 74 61 62 73 2e 65 2e 63 6f 6e 74 P.tabs.e.cont
2460: 61 69 6e 65 72 2e 69 6e 73 65 72 74 42 65 66 6f ainer.insertBefo
2470: 72 65 28 0a 20 20 20 20 20 20 2f 2a 20 4d 6f 76 re(. /* Mov
2480: 65 20 74 68 65 20 73 74 61 74 75 73 20 62 61 72 e the status bar
2490: 20 62 65 74 77 65 65 6e 20 74 68 65 20 74 61 62 between the tab
24a0: 20 62 75 74 74 6f 6e 73 20 61 6e 64 0a 20 20 20 buttons and.
24b0: 20 20 20 20 20 20 74 61 62 20 70 61 6e 65 6c 73 tab panels
24c0: 2e 20 53 65 65 6d 73 20 74 6f 20 62 65 20 74 68 . Seems to be th
24d0: 65 20 62 65 73 74 20 66 69 74 20 69 6e 20 74 65 e best fit in te
24e0: 72 6d 73 20 6f 66 0a 20 20 20 20 20 20 20 20 20 rms of.
24f0: 66 75 6e 63 74 69 6f 6e 61 6c 69 74 79 20 61 6e functionality an
2500: 64 20 76 69 73 69 62 69 6c 69 74 79 2e 20 2a 2f d visibility. */
2510: 0a 20 20 20 20 20 20 45 28 27 23 66 6f 73 73 69 . E('#fossi
2520: 6c 2d 73 74 61 74 75 73 2d 62 61 72 27 29 2c 20 l-status-bar'),
2530: 50 2e 74 61 62 73 2e 65 2e 74 61 62 73 0a 20 20 P.tabs.e.tabs.
2540: 20 20 29 3b 0a 0a 20 20 20 20 50 2e 74 61 62 73 );.. P.tabs
2550: 2e 61 64 64 45 76 65 6e 74 4c 69 73 74 65 6e 65 .addEventListene
2560: 72 28 0a 20 20 20 20 20 20 2f 2a 20 53 65 74 20 r(. /* Set
2570: 75 70 20 61 75 74 6f 2d 72 65 66 72 65 73 68 20 up auto-refresh
2580: 6f 66 20 74 68 65 20 70 72 65 76 69 65 77 20 74 of the preview t
2590: 61 62 2e 2e 2e 20 2a 2f 0a 20 20 20 20 20 20 27 ab... */. '
25a0: 62 65 66 6f 72 65 2d 73 77 69 74 63 68 2d 74 6f before-switch-to
25b0: 27 2c 20 66 75 6e 63 74 69 6f 6e 28 65 76 29 7b ', function(ev){
25c0: 0a 20 20 20 20 20 20 20 20 69 66 28 65 76 2e 64 . if(ev.d
25d0: 65 74 61 69 6c 3d 3d 3d 50 2e 65 2e 74 61 62 73 etail===P.e.tabs
25e0: 2e 70 72 65 76 69 65 77 29 7b 0a 20 20 20 20 20 .preview){.
25f0: 20 20 20 20 20 50 2e 62 61 73 65 48 72 65 66 46 P.baseHrefF
2600: 6f 72 46 69 6c 65 28 29 3b 0a 20 20 20 20 20 20 orFile();.
2610: 20 20 20 20 69 66 28 50 2e 65 2e 63 62 41 75 74 if(P.e.cbAut
2620: 6f 50 72 65 76 69 65 77 2e 63 68 65 63 6b 65 64 oPreview.checked
2630: 29 20 50 2e 70 72 65 76 69 65 77 28 29 3b 0a 20 ) P.preview();.
2640: 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 7d }. }
2650: 0a 20 20 20 20 29 3b 0a 20 20 20 20 50 2e 74 61 . );. P.ta
2660: 62 73 2e 61 64 64 45 76 65 6e 74 4c 69 73 74 65 bs.addEventListe
2670: 6e 65 72 28 0a 20 20 20 20 20 20 2f 2a 20 53 65 ner(. /* Se
2680: 74 20 75 70 20 61 75 74 6f 2d 72 65 66 72 65 73 t up auto-refres
2690: 68 20 6f 66 20 74 68 65 20 70 72 65 76 69 65 77 h of the preview
26a0: 20 74 61 62 2e 2e 2e 20 2a 2f 0a 20 20 20 20 20 tab... */.
26b0: 20 27 62 65 66 6f 72 65 2d 73 77 69 74 63 68 2d 'before-switch-
26c0: 66 72 6f 6d 27 2c 20 66 75 6e 63 74 69 6f 6e 28 from', function(
26d0: 65 76 29 7b 0a 20 20 20 20 20 20 20 20 69 66 28 ev){. if(
26e0: 65 76 2e 64 65 74 61 69 6c 3d 3d 3d 50 2e 65 2e ev.detail===P.e.
26f0: 74 61 62 73 2e 70 72 65 76 69 65 77 29 7b 0a 20 tabs.preview){.
2700: 20 20 20 20 20 20 20 20 20 50 2e 62 61 73 65 48 P.baseH
2710: 72 65 66 52 65 73 74 6f 72 65 28 29 3b 0a 20 20 refRestore();.
2720: 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 7d 0a }. }.
2730: 20 20 20 20 29 3b 0a 0a 20 20 20 20 46 2e 63 6f );.. F.co
2740: 6e 6e 65 63 74 50 61 67 65 50 72 65 76 69 65 77 nnectPagePreview
2750: 65 72 73 28 0a 20 20 20 20 20 20 50 2e 65 2e 74 ers(. P.e.t
2760: 61 62 73 2e 70 72 65 76 69 65 77 2e 71 75 65 72 abs.preview.quer
2770: 79 53 65 6c 65 63 74 6f 72 28 0a 20 20 20 20 20 ySelector(.
2780: 20 20 20 27 23 62 74 6e 2d 70 72 65 76 69 65 77 '#btn-preview
2790: 2d 72 65 66 72 65 73 68 27 0a 20 20 20 20 20 20 -refresh'.
27a0: 29 0a 20 20 20 20 29 3b 0a 0a 20 20 20 20 63 6f ). );.. co
27b0: 6e 73 74 20 64 69 66 66 42 75 74 74 6f 6e 73 20 nst diffButtons
27c0: 3d 20 45 28 27 23 66 69 6c 65 65 64 69 74 2d 74 = E('#fileedit-t
27d0: 61 62 2d 64 69 66 66 2d 62 75 74 74 6f 6e 73 27 ab-diff-buttons'
27e0: 29 3b 0a 20 20 20 20 64 69 66 66 42 75 74 74 6f );. diffButto
27f0: 6e 73 2e 71 75 65 72 79 53 65 6c 65 63 74 6f 72 ns.querySelector
2800: 28 27 62 75 74 74 6f 6e 2e 73 62 73 27 29 2e 61 ('button.sbs').a
2810: 64 64 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 28 ddEventListener(
2820: 0a 20 20 20 20 20 20 22 63 6c 69 63 6b 22 2c 28 . "click",(
2830: 65 29 3d 3e 50 2e 64 69 66 66 28 74 72 75 65 29 e)=>P.diff(true)
2840: 2c 20 66 61 6c 73 65 0a 20 20 20 20 29 3b 0a 20 , false. );.
2850: 20 20 20 64 69 66 66 42 75 74 74 6f 6e 73 2e 71 diffButtons.q
2860: 75 65 72 79 53 65 6c 65 63 74 6f 72 28 27 62 75 uerySelector('bu
2870: 74 74 6f 6e 2e 75 6e 69 66 69 65 64 27 29 2e 61 tton.unified').a
2880: 64 64 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 28 ddEventListener(
2890: 0a 20 20 20 20 20 20 22 63 6c 69 63 6b 22 2c 28 . "click",(
28a0: 65 29 3d 3e 50 2e 64 69 66 66 28 66 61 6c 73 65 e)=>P.diff(false
28b0: 29 2c 20 66 61 6c 73 65 0a 20 20 20 20 29 3b 0a ), false. );.
28c0: 20 20 20 20 50 2e 65 2e 62 74 6e 43 6f 6d 6d 69 P.e.btnCommi
28d0: 74 2e 61 64 64 45 76 65 6e 74 4c 69 73 74 65 6e t.addEventListen
28e0: 65 72 28 0a 20 20 20 20 20 20 22 63 6c 69 63 6b er(. "click
28f0: 22 2c 28 65 29 3d 3e 50 2e 63 6f 6d 6d 69 74 28 ",(e)=>P.commit(
2900: 29 2c 20 66 61 6c 73 65 0a 20 20 20 20 29 3b 0a ), false. );.
2910: 20 20 20 20 46 2e 63 6f 6e 66 69 72 6d 65 72 28 F.confirmer(
2920: 50 2e 65 2e 62 74 6e 52 65 6c 6f 61 64 2c 20 7b P.e.btnReload, {
2930: 0a 20 20 20 20 20 20 63 6f 6e 66 69 72 6d 54 65 . confirmTe
2940: 78 74 3a 20 22 52 65 61 6c 6c 79 20 72 65 6c 6f xt: "Really relo
2950: 61 64 2c 20 6c 6f 73 69 6e 67 20 65 64 69 74 73 ad, losing edits
2960: 3f 22 2c 0a 20 20 20 20 20 20 6f 6e 63 6f 6e 66 ?",. onconf
2970: 69 72 6d 3a 20 28 65 29 3d 3e 50 2e 75 6e 73 74 irm: (e)=>P.unst
2980: 61 73 68 43 6f 6e 74 65 6e 74 28 29 2e 6c 6f 61 ashContent().loa
2990: 64 46 69 6c 65 28 29 2c 0a 20 20 20 20 20 20 74 dFile(),. t
29a0: 69 63 6b 73 3a 20 33 0a 20 20 20 20 7d 29 3b 0a icks: 3. });.
29b0: 20 20 20 20 45 28 27 23 63 6f 6d 6d 65 6e 74 2d E('#comment-
29c0: 74 6f 67 67 6c 65 27 29 2e 61 64 64 45 76 65 6e toggle').addEven
29d0: 74 4c 69 73 74 65 6e 65 72 28 0a 20 20 20 20 20 tListener(.
29e0: 20 22 63 6c 69 63 6b 22 2c 28 65 29 3d 3e 50 2e "click",(e)=>P.
29f0: 74 6f 67 67 6c 65 43 6f 6d 6d 65 6e 74 4d 6f 64 toggleCommentMod
2a00: 65 28 29 2c 20 66 61 6c 73 65 0a 20 20 20 20 29 e(), false. )
2a10: 3b 0a 0a 20 20 20 20 50 2e 65 2e 74 61 45 64 69 ;.. P.e.taEdi
2a20: 74 6f 72 2e 61 64 64 45 76 65 6e 74 4c 69 73 74 tor.addEventList
2a30: 65 6e 65 72 28 0a 20 20 20 20 20 20 27 63 68 61 ener(. 'cha
2a40: 6e 67 65 27 2c 20 28 29 3d 3e 50 2e 73 74 61 73 nge', ()=>P.stas
2a50: 68 43 6f 6e 74 65 6e 74 43 68 61 6e 67 65 28 29 hContentChange()
2a60: 2c 20 66 61 6c 73 65 0a 20 20 20 20 29 3b 0a 20 , false. );.
2a70: 20 20 20 50 2e 65 2e 63 62 49 73 45 78 65 2e 61 P.e.cbIsExe.a
2a80: 64 64 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 28 ddEventListener(
2a90: 0a 20 20 20 20 20 20 27 63 68 61 6e 67 65 27 2c . 'change',
2aa0: 20 28 29 3d 3e 50 2e 73 74 61 73 68 43 6f 6e 74 ()=>P.stashCont
2ab0: 65 6e 74 43 68 61 6e 67 65 28 74 72 75 65 29 2c entChange(true),
2ac0: 20 66 61 6c 73 65 0a 20 20 20 20 29 3b 0a 20 20 false. );.
2ad0: 20 20 0a 20 20 20 20 2f 2a 2a 0a 20 20 20 20 20 . /**.
2ae0: 20 20 43 6f 73 6d 65 74 69 63 3a 20 6a 75 6d 70 Cosmetic: jump
2af0: 20 74 68 72 6f 75 67 68 20 73 6f 6d 65 20 68 6f through some ho
2b00: 6f 70 73 20 74 6f 20 65 6e 61 62 6c 65 2f 64 69 ops to enable/di
2b10: 73 61 62 6c 65 0a 20 20 20 20 20 20 20 63 65 72 sable. cer
2b20: 74 61 69 6e 20 70 72 65 76 69 65 77 20 6f 70 74 tain preview opt
2b30: 69 6f 6e 73 20 64 65 70 65 6e 64 69 6e 67 20 6f ions depending o
2b40: 6e 20 74 68 65 20 63 75 72 72 65 6e 74 0a 20 20 n the current.
2b50: 20 20 20 20 20 70 72 65 76 69 65 77 20 6d 6f 64 preview mod
2b60: 65 2e 2e 2e 0a 20 20 20 20 2a 2f 0a 20 20 20 20 e.... */.
2b70: 50 2e 65 2e 73 65 6c 65 63 74 50 72 65 76 69 65 P.e.selectPrevie
2b80: 77 4d 6f 64 65 2e 61 64 64 45 76 65 6e 74 4c 69 wMode.addEventLi
2b90: 73 74 65 6e 65 72 28 0a 20 20 20 20 20 20 22 63 stener(. "c
2ba0: 68 61 6e 67 65 22 2c 20 66 75 6e 63 74 69 6f 6e hange", function
2bb0: 28 65 29 7b 0a 20 20 20 20 20 20 20 20 63 6f 6e (e){. con
2bc0: 73 74 20 6d 6f 64 65 20 3d 20 65 2e 74 61 72 67 st mode = e.targ
2bd0: 65 74 2e 76 61 6c 75 65 2c 0a 20 20 20 20 20 20 et.value,.
2be0: 20 20 20 20 20 20 20 20 6e 61 6d 65 20 3d 20 50 name = P
2bf0: 2e 70 72 65 76 69 65 77 4d 6f 64 65 73 5b 6d 6f .previewModes[mo
2c00: 64 65 5d 2c 0a 20 20 20 20 20 20 20 20 20 20 20 de],.
2c10: 20 20 20 68 69 64 65 20 3d 20 5b 5d 2c 20 75 6e hide = [], un
2c20: 68 69 64 65 20 3d 20 5b 5d 3b 0a 20 20 20 20 20 hide = [];.
2c30: 20 20 20 50 2e 70 72 65 76 69 65 77 4d 6f 64 65 P.previewMode
2c40: 73 2e 63 75 72 72 65 6e 74 20 3d 20 6e 61 6d 65 s.current = name
2c50: 3b 0a 20 20 20 20 20 20 20 20 69 66 28 27 67 75 ;. if('gu
2c60: 65 73 73 27 3d 3d 3d 6e 61 6d 65 29 7b 0a 20 20 ess'===name){.
2c70: 20 20 20 20 20 20 20 20 75 6e 68 69 64 65 2e 70 unhide.p
2c80: 75 73 68 28 50 2e 65 2e 63 62 4c 69 6e 65 4e 75 ush(P.e.cbLineNu
2c90: 6d 62 65 72 73 57 72 61 70 2c 0a 20 20 20 20 20 mbersWrap,.
2ca0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2cb0: 20 50 2e 65 2e 73 65 6c 65 63 74 48 74 6d 6c 45 P.e.selectHtmlE
2cc0: 6d 73 57 72 61 70 29 3b 0a 20 20 20 20 20 20 20 msWrap);.
2cd0: 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20 20 20 }else{.
2ce0: 20 20 69 66 28 27 74 65 78 74 27 3d 3d 3d 6e 61 if('text'===na
2cf0: 6d 65 29 20 75 6e 68 69 64 65 2e 70 75 73 68 28 me) unhide.push(
2d00: 50 2e 65 2e 63 62 4c 69 6e 65 4e 75 6d 62 65 72 P.e.cbLineNumber
2d10: 73 57 72 61 70 29 3b 0a 20 20 20 20 20 20 20 20 sWrap);.
2d20: 20 20 65 6c 73 65 20 68 69 64 65 2e 70 75 73 68 else hide.push
2d30: 28 50 2e 65 2e 63 62 4c 69 6e 65 4e 75 6d 62 65 (P.e.cbLineNumbe
2d40: 72 73 57 72 61 70 29 3b 0a 20 20 20 20 20 20 20 rsWrap);.
2d50: 20 20 20 69 66 28 27 68 74 6d 6c 49 66 72 61 6d if('htmlIfram
2d60: 65 27 3d 3d 3d 6e 61 6d 65 29 20 75 6e 68 69 64 e'===name) unhid
2d70: 65 2e 70 75 73 68 28 50 2e 65 2e 73 65 6c 65 63 e.push(P.e.selec
2d80: 74 48 74 6d 6c 45 6d 73 57 72 61 70 29 3b 0a 20 tHtmlEmsWrap);.
2d90: 20 20 20 20 20 20 20 20 20 65 6c 73 65 20 68 69 else hi
2da0: 64 65 2e 70 75 73 68 28 50 2e 65 2e 73 65 6c 65 de.push(P.e.sele
2db0: 63 74 48 74 6d 6c 45 6d 73 57 72 61 70 29 3b 0a ctHtmlEmsWrap);.
2dc0: 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 }.
2dd0: 20 20 68 69 64 65 2e 66 6f 72 45 61 63 68 28 28 hide.forEach((
2de0: 65 29 3d 3e 65 2e 63 6c 61 73 73 4c 69 73 74 2e e)=>e.classList.
2df0: 61 64 64 28 27 68 69 64 64 65 6e 27 29 29 3b 0a add('hidden'));.
2e00: 20 20 20 20 20 20 20 20 75 6e 68 69 64 65 2e 66 unhide.f
2e10: 6f 72 45 61 63 68 28 28 65 29 3d 3e 65 2e 63 6c orEach((e)=>e.cl
2e20: 61 73 73 4c 69 73 74 2e 72 65 6d 6f 76 65 28 27 assList.remove('
2e30: 68 69 64 64 65 6e 27 29 29 3b 0a 20 20 20 20 20 hidden'));.
2e40: 20 7d 2c 20 66 61 6c 73 65 0a 20 20 20 20 29 3b }, false. );
2e50: 0a 20 20 20 20 50 2e 73 65 6c 65 63 74 50 72 65 . P.selectPre
2e60: 76 69 65 77 4d 6f 64 65 28 66 61 6c 73 65 2c 20 viewMode(false,
2e70: 74 72 75 65 29 3b 0a 20 20 20 20 63 6f 6e 73 74 true);. const
2e80: 20 73 65 6c 65 63 74 46 6f 6e 74 53 69 7a 65 20 selectFontSize
2e90: 3d 20 45 28 27 73 65 6c 65 63 74 5b 6e 61 6d 65 = E('select[name
2ea0: 3d 65 64 69 74 6f 72 5f 66 6f 6e 74 5f 73 69 7a =editor_font_siz
2eb0: 65 5d 27 29 3b 0a 20 20 20 20 69 66 28 73 65 6c e]');. if(sel
2ec0: 65 63 74 46 6f 6e 74 53 69 7a 65 29 7b 0a 20 20 ectFontSize){.
2ed0: 20 20 20 20 73 65 6c 65 63 74 46 6f 6e 74 53 69 selectFontSi
2ee0: 7a 65 2e 61 64 64 45 76 65 6e 74 4c 69 73 74 65 ze.addEventListe
2ef0: 6e 65 72 28 0a 20 20 20 20 20 20 20 20 22 63 68 ner(. "ch
2f00: 61 6e 67 65 22 2c 66 75 6e 63 74 69 6f 6e 28 65 ange",function(e
2f10: 29 7b 0a 20 20 20 20 20 20 20 20 20 20 63 6f 6e ){. con
2f20: 73 74 20 65 64 20 3d 20 50 2e 65 2e 74 61 45 64 st ed = P.e.taEd
2f30: 69 74 6f 72 3b 0a 20 20 20 20 20 20 20 20 20 20 itor;.
2f40: 65 64 2e 63 6c 61 73 73 4e 61 6d 65 20 3d 20 65 ed.className = e
2f50: 64 2e 63 6c 61 73 73 4e 61 6d 65 2e 72 65 70 6c d.className.repl
2f60: 61 63 65 28 0a 20 20 20 20 20 20 20 20 20 20 20 ace(.
2f70: 20 20 20 2f 5c 62 66 6f 6e 74 2d 73 69 7a 65 2d /\bfont-size-
2f80: 5c 64 2b 2f 67 2c 20 27 27 20 29 3b 0a 20 20 20 \d+/g, '' );.
2f90: 20 20 20 20 20 20 20 65 64 2e 63 6c 61 73 73 4c ed.classL
2fa0: 69 73 74 2e 61 64 64 28 27 66 6f 6e 74 2d 73 69 ist.add('font-si
2fb0: 7a 65 2d 27 2b 65 2e 74 61 72 67 65 74 2e 76 61 ze-'+e.target.va
2fc0: 6c 75 65 29 3b 0a 20 20 20 20 20 20 20 20 7d 2c lue);. },
2fd0: 20 66 61 6c 73 65 0a 20 20 20 20 20 20 29 3b 0a false. );.
2fe0: 20 20 20 20 20 20 73 65 6c 65 63 74 46 6f 6e 74 selectFont
2ff0: 53 69 7a 65 2e 64 69 73 70 61 74 63 68 45 76 65 Size.dispatchEve
3000: 6e 74 28 0a 20 20 20 20 20 20 20 20 2f 2f 20 46 nt(. // F
3010: 6f 72 63 65 20 55 49 20 75 70 64 61 74 65 0a 20 orce UI update.
3020: 20 20 20 20 20 20 20 6e 65 77 20 45 76 65 6e 74 new Event
3030: 28 27 63 68 61 6e 67 65 27 2c 7b 74 61 72 67 65 ('change',{targe
3040: 74 3a 73 65 6c 65 63 74 46 6f 6e 74 53 69 7a 65 t:selectFontSize
3050: 7d 29 0a 20 20 20 20 20 20 29 3b 0a 20 20 20 20 }). );.
3060: 7d 0a 0a 20 20 20 20 69 66 28 30 29 7b 20 2f 2f }.. if(0){ //
3070: 20 6f 6e 6c 79 20 66 6f 72 20 74 65 73 74 69 6e only for testin
3080: 67 0a 20 20 20 20 20 20 50 2e 61 64 64 45 76 65 g. P.addEve
3090: 6e 74 4c 69 73 74 65 6e 65 72 28 0a 20 20 20 20 ntListener(.
30a0: 20 20 20 20 27 66 69 6c 65 65 64 69 74 2d 66 69 'fileedit-fi
30b0: 6c 65 2d 6c 6f 61 64 65 64 27 2c 0a 20 20 20 20 le-loaded',.
30c0: 20 20 20 20 28 65 29 3d 3e 63 6f 6e 73 6f 6c 65 (e)=>console
30d0: 2e 64 65 62 75 67 28 27 66 69 6c 65 65 64 69 74 .debug('fileedit
30e0: 2d 66 69 6c 65 2d 6c 6f 61 64 65 64 20 3d 3d 3e -file-loaded ==>
30f0: 27 2c 65 29 0a 20 20 20 20 20 20 29 3b 0a 20 20 ',e). );.
3100: 20 20 7d 0a 0a 20 20 20 20 50 2e 61 64 64 45 76 }.. P.addEv
3110: 65 6e 74 4c 69 73 74 65 6e 65 72 28 0a 20 20 20 entListener(.
3120: 20 20 20 2f 2f 20 43 6c 65 61 72 20 64 69 66 66 // Clear diff
3130: 2f 70 72 65 76 69 65 77 20 77 68 65 6e 20 6e 65 /preview when ne
3140: 77 20 63 6f 6e 74 65 6e 74 20 69 73 20 6c 6f 61 w content is loa
3150: 64 65 64 2f 73 65 74 0a 20 20 20 20 20 20 27 66 ded/set. 'f
3160: 69 6c 65 65 64 69 74 2d 63 6f 6e 74 65 6e 74 2d ileedit-content-
3170: 72 65 70 6c 61 63 65 64 27 2c 0a 20 20 20 20 20 replaced',.
3180: 20 28 29 3d 3e 44 2e 63 6c 65 61 72 45 6c 65 6d ()=>D.clearElem
3190: 65 6e 74 28 50 2e 65 2e 64 69 66 66 54 61 72 67 ent(P.e.diffTarg
31a0: 65 74 2c 20 50 2e 65 2e 70 72 65 76 69 65 77 54 et, P.e.previewT
31b0: 61 72 67 65 74 29 0a 20 20 20 20 29 3b 0a 0a 20 arget). );..
31c0: 20 20 20 2f 2a 20 54 65 6c 6c 20 74 68 65 20 75 /* Tell the u
31d0: 73 65 72 20 61 62 6f 75 74 20 77 68 69 63 68 20 ser about which
31e0: 66 6f 73 73 69 6c 2e 73 74 6f 72 61 67 65 20 69 fossil.storage i
31f0: 73 20 62 65 69 6e 67 20 75 73 65 64 2e 2e 2e 20 s being used...
3200: 2a 2f 0a 20 20 20 20 6c 65 74 20 73 74 6f 72 61 */. let stora
3210: 67 65 4d 73 67 20 3d 20 44 2e 61 64 64 43 6c 61 geMsg = D.addCla
3220: 73 73 28 44 2e 64 69 76 28 29 2c 27 66 6c 65 78 ss(D.div(),'flex
3230: 2d 63 6f 6e 74 61 69 6e 65 72 27 2c 27 66 6c 65 -container','fle
3240: 78 2d 72 6f 77 27 2c 0a 20 20 20 20 20 20 20 20 x-row',.
3250: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3260: 20 20 20 20 20 20 20 20 27 66 69 6c 65 65 64 69 'fileedi
3270: 74 2d 68 69 6e 74 27 29 3b 0a 20 20 20 20 69 66 t-hint');. if
3280: 28 46 2e 73 74 6f 72 61 67 65 2e 69 73 54 72 61 (F.storage.isTra
3290: 6e 73 69 65 6e 74 28 29 29 7b 0a 20 20 20 20 20 nsient()){.
32a0: 20 44 2e 61 70 70 65 6e 64 28 0a 20 20 20 20 20 D.append(.
32b0: 20 20 20 44 2e 61 64 64 43 6c 61 73 73 28 73 74 D.addClass(st
32c0: 6f 72 61 67 65 4d 73 67 2c 27 77 61 72 6e 69 6e orageMsg,'warnin
32d0: 67 27 29 2c 0a 20 20 20 20 20 20 20 20 22 57 61 g'),. "Wa
32e0: 72 6e 69 6e 67 3a 20 70 65 72 73 69 73 74 65 6e rning: persisten
32f0: 74 20 73 74 6f 72 61 67 65 20 69 73 20 6e 6f 74 t storage is not
3300: 20 61 76 61 69 62 6c 65 2c 20 22 2b 0a 20 20 20 avaible, "+.
3310: 20 20 20 20 20 20 20 22 73 6f 20 75 6e 73 61 76 "so unsav
3320: 65 64 20 65 64 69 74 73 20 22 2b 0a 20 20 20 20 ed edits "+.
3330: 20 20 20 20 20 20 22 77 69 6c 6c 20 6e 6f 74 20 "will not
3340: 73 75 72 76 69 76 65 20 61 20 70 61 67 65 20 72 survive a page r
3350: 65 6c 6f 61 64 2e 22 0a 20 20 20 20 20 20 29 3b eload.". );
3360: 0a 20 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 . }else{.
3370: 20 20 44 2e 61 70 70 65 6e 64 28 0a 20 20 20 20 D.append(.
3380: 20 20 20 20 73 74 6f 72 61 67 65 4d 73 67 2c 0a storageMsg,.
3390: 20 20 20 20 20 20 20 20 22 43 75 72 72 65 6e 74 "Current
33a0: 20 73 74 6f 72 61 67 65 20 6d 65 63 68 61 6e 69 storage mechani
33b0: 73 6d 20 66 6f 72 20 6c 6f 63 61 6c 20 65 64 69 sm for local edi
33c0: 74 73 3a 20 22 2b 0a 20 20 20 20 20 20 20 20 20 ts: "+.
33d0: 20 46 2e 73 74 6f 72 61 67 65 2e 73 74 6f 72 61 F.storage.stora
33e0: 67 65 49 6d 70 6c 4e 61 6d 65 28 29 0a 20 20 20 geImplName().
33f0: 20 20 20 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 );. }.
3400: 50 2e 65 2e 74 61 62 73 2e 63 6f 6e 74 65 6e 74 P.e.tabs.content
3410: 2e 69 6e 73 65 72 74 42 65 66 6f 72 65 28 73 74 .insertBefore(st
3420: 6f 72 61 67 65 4d 73 67 2c 20 50 2e 65 2e 74 61 orageMsg, P.e.ta
3430: 62 73 2e 63 6f 6e 74 65 6e 74 2e 6c 61 73 74 45 bs.content.lastE
3440: 6c 65 6d 65 6e 74 43 68 69 6c 64 29 3b 0a 20 20 lementChild);.
3450: 7d 2c 20 66 61 6c 73 65 29 2f 2a 6f 6e 6c 6f 61 }, false)/*onloa
3460: 64 20 65 76 65 6e 74 20 68 61 6e 64 6c 65 72 2a d event handler*
3470: 2f 3b 0a 0a 20 20 2f 2a 2a 0a 20 20 20 20 20 47 /;.. /**. G
3480: 65 74 74 65 72 20 28 69 66 20 63 61 6c 6c 65 64 etter (if called
3490: 20 77 69 74 68 20 6e 6f 20 61 72 67 73 29 20 6f with no args) o
34a0: 72 20 73 65 74 74 65 72 20 28 69 66 20 70 61 73 r setter (if pas
34b0: 73 65 64 20 61 6e 20 61 72 67 29 20 66 6f 72 0a sed an arg) for.
34c0: 20 20 20 20 20 74 68 65 20 63 75 72 72 65 6e 74 the current
34d0: 20 66 69 6c 65 20 63 6f 6e 74 65 6e 74 2e 0a 0a file content...
34e0: 20 20 20 20 20 54 68 65 20 73 65 74 74 65 72 20 The setter
34f0: 66 6f 72 6d 20 73 65 74 73 20 74 68 65 20 63 6f form sets the co
3500: 6e 74 65 6e 74 2c 20 64 69 73 70 61 74 63 68 65 ntent, dispatche
3510: 73 20 61 0a 20 20 20 20 20 27 66 69 6c 65 65 64 s a. 'fileed
3520: 69 74 2d 63 6f 6e 74 65 6e 74 2d 72 65 70 6c 61 it-content-repla
3530: 63 65 64 27 20 65 76 65 6e 74 2c 20 61 6e 64 20 ced' event, and
3540: 72 65 74 75 72 6e 73 20 74 68 69 73 20 6f 62 6a returns this obj
3550: 65 63 74 2e 0a 20 20 2a 2f 0a 20 20 50 2e 66 69 ect.. */. P.fi
3560: 6c 65 43 6f 6e 74 65 6e 74 20 3d 20 66 75 6e 63 leContent = func
3570: 74 69 6f 6e 20 66 28 29 7b 0a 20 20 20 20 69 66 tion f(){. if
3580: 28 30 3d 3d 3d 61 72 67 75 6d 65 6e 74 73 2e 6c (0===arguments.l
3590: 65 6e 67 74 68 29 7b 0a 20 20 20 20 20 20 72 65 ength){. re
35a0: 74 75 72 6e 20 66 2e 67 65 74 28 29 3b 0a 20 20 turn f.get();.
35b0: 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20 66 }else{. f
35c0: 2e 73 65 74 28 61 72 67 75 6d 65 6e 74 73 5b 30 .set(arguments[0
35d0: 5d 20 7c 7c 20 27 27 29 3b 0a 20 20 20 20 20 20 ] || '');.
35e0: 74 68 69 73 2e 64 69 73 70 61 74 63 68 45 76 65 this.dispatchEve
35f0: 6e 74 28 27 66 69 6c 65 65 64 69 74 2d 63 6f 6e nt('fileedit-con
3600: 74 65 6e 74 2d 72 65 70 6c 61 63 65 64 27 2c 20 tent-replaced',
3610: 74 68 69 73 29 3b 0a 20 20 20 20 20 20 72 65 74 this);. ret
3620: 75 72 6e 20 74 68 69 73 3b 0a 20 20 20 20 7d 0a urn this;. }.
3630: 20 20 7d 3b 0a 20 20 2f 2a 20 44 65 66 61 75 6c };. /* Defaul
3640: 74 20 67 65 74 2f 73 65 74 20 69 6d 70 6c 73 20 t get/set impls
3650: 66 6f 72 20 66 69 6c 65 20 63 6f 6e 74 65 6e 74 for file content
3660: 20 2a 2f 0a 20 20 50 2e 66 69 6c 65 43 6f 6e 74 */. P.fileCont
3670: 65 6e 74 2e 67 65 74 20 3d 20 66 75 6e 63 74 69 ent.get = functi
3680: 6f 6e 28 29 7b 72 65 74 75 72 6e 20 50 2e 65 2e on(){return P.e.
3690: 74 61 45 64 69 74 6f 72 2e 76 61 6c 75 65 7d 3b taEditor.value};
36a0: 0a 20 20 50 2e 66 69 6c 65 43 6f 6e 74 65 6e 74 . P.fileContent
36b0: 2e 73 65 74 20 3d 20 66 75 6e 63 74 69 6f 6e 28 .set = function(
36c0: 63 6f 6e 74 65 6e 74 29 7b 50 2e 65 2e 74 61 45 content){P.e.taE
36d0: 64 69 74 6f 72 2e 76 61 6c 75 65 20 3d 20 63 6f ditor.value = co
36e0: 6e 74 65 6e 74 7d 3b 0a 0a 20 20 2f 2a 2a 0a 20 ntent};.. /**.
36f0: 20 20 20 20 46 6f 72 20 75 73 65 20 77 68 65 6e For use when
3700: 20 69 6e 73 74 61 6c 6c 69 6e 67 20 61 20 63 75 installing a cu
3710: 73 74 6f 6d 20 65 64 69 74 6f 72 20 77 69 64 67 stom editor widg
3720: 65 74 2e 20 50 61 73 73 20 69 74 20 74 68 65 0a et. Pass it the.
3730: 20 20 20 20 20 67 65 74 74 65 72 20 61 6e 64 20 getter and
3740: 73 65 74 74 65 72 20 63 61 6c 6c 62 61 63 6b 73 setter callbacks
3750: 20 74 6f 20 66 65 74 63 68 20 72 65 73 70 2e 20 to fetch resp.
3760: 73 65 74 20 74 68 65 20 63 6f 6e 74 65 6e 74 20 set the content
3770: 6f 66 20 74 68 65 0a 20 20 20 20 20 63 75 73 74 of the. cust
3780: 6f 6d 20 77 69 64 67 65 74 2e 20 54 68 65 79 20 om widget. They
3790: 77 69 6c 6c 20 62 65 20 74 72 69 67 67 65 72 65 will be triggere
37a0: 64 20 76 69 61 0a 20 20 20 20 20 50 2e 66 69 6c d via. P.fil
37b0: 65 43 6f 6e 74 65 6e 74 28 29 2e 20 52 65 74 75 eContent(). Retu
37c0: 72 6e 73 20 74 68 69 73 20 6f 62 6a 65 63 74 2e rns this object.
37d0: 0a 20 20 2a 2f 0a 20 20 50 2e 73 65 74 46 69 6c . */. P.setFil
37e0: 65 43 6f 6e 74 65 6e 74 4d 65 74 68 6f 64 73 20 eContentMethods
37f0: 3d 20 66 75 6e 63 74 69 6f 6e 28 67 65 74 74 65 = function(gette
3800: 72 2c 20 73 65 74 74 65 72 29 7b 0a 20 20 20 20 r, setter){.
3810: 74 68 69 73 2e 66 69 6c 65 43 6f 6e 74 65 6e 74 this.fileContent
3820: 2e 67 65 74 20 3d 20 67 65 74 74 65 72 3b 0a 20 .get = getter;.
3830: 20 20 20 74 68 69 73 2e 66 69 6c 65 43 6f 6e 74 this.fileCont
3840: 65 6e 74 2e 73 65 74 20 3d 20 73 65 74 74 65 72 ent.set = setter
3850: 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 74 68 69 ;. return thi
3860: 73 3b 0a 20 20 7d 3b 0a 0a 20 20 2f 2a 2a 0a 20 s;. };.. /**.
3870: 20 20 20 20 52 65 6d 6f 76 65 73 20 74 68 65 20 Removes the
3880: 64 65 66 61 75 6c 74 20 65 64 69 74 6f 72 20 77 default editor w
3890: 69 64 67 65 74 20 28 61 6e 64 20 61 6e 79 20 64 idget (and any d
38a0: 65 70 65 6e 64 65 6e 74 20 65 6c 65 6d 65 6e 74 ependent element
38b0: 73 29 0a 20 20 20 20 20 66 72 6f 6d 20 74 68 65 s). from the
38c0: 20 44 4f 4d 2c 20 61 64 64 73 20 74 68 65 20 67 DOM, adds the g
38d0: 69 76 65 6e 20 65 6c 65 6d 65 6e 74 20 69 6e 20 iven element in
38e0: 69 74 73 20 70 6c 61 63 65 2c 20 72 65 6d 6f 76 its place, remov
38f0: 65 73 20 74 68 69 73 0a 20 20 20 20 20 6d 65 74 es this. met
3900: 68 6f 64 20 66 72 6f 6d 20 74 68 69 73 20 6f 62 hod from this ob
3910: 6a 65 63 74 2c 20 61 6e 64 20 72 65 74 75 72 6e ject, and return
3920: 73 20 74 68 69 73 20 6f 62 6a 65 63 74 2e 0a 20 s this object..
3930: 20 2a 2f 0a 20 20 50 2e 72 65 70 6c 61 63 65 45 */. P.replaceE
3940: 64 69 74 6f 72 45 6c 65 6d 65 6e 74 20 3d 20 66 ditorElement = f
3950: 75 6e 63 74 69 6f 6e 28 6e 65 77 45 64 69 74 6f unction(newEdito
3960: 72 29 7b 0a 20 20 20 20 50 2e 65 2e 74 61 45 64 r){. P.e.taEd
3970: 69 74 6f 72 2e 70 61 72 65 6e 74 4e 6f 64 65 2e itor.parentNode.
3980: 69 6e 73 65 72 74 42 65 66 6f 72 65 28 6e 65 77 insertBefore(new
3990: 45 64 69 74 6f 72 2c 20 50 2e 65 2e 74 61 45 64 Editor, P.e.taEd
39a0: 69 74 6f 72 29 3b 0a 20 20 20 20 50 2e 65 2e 74 itor);. P.e.t
39b0: 61 45 64 69 74 6f 72 2e 72 65 6d 6f 76 65 28 29 aEditor.remove()
39c0: 3b 0a 20 20 20 20 50 2e 65 2e 73 65 6c 65 63 74 ;. P.e.select
39d0: 46 6f 6e 74 53 69 7a 65 57 72 61 70 2e 72 65 6d FontSizeWrap.rem
39e0: 6f 76 65 28 29 3b 0a 20 20 20 20 64 65 6c 65 74 ove();. delet
39f0: 65 20 74 68 69 73 2e 72 65 70 6c 61 63 65 45 64 e this.replaceEd
3a00: 69 74 6f 72 45 6c 65 6d 65 6e 74 3b 0a 20 20 20 itorElement;.
3a10: 20 72 65 74 75 72 6e 20 50 3b 0a 20 20 7d 3b 0a return P;. };.
3a20: 0a 20 20 2f 2a 2a 0a 20 20 20 20 20 49 66 20 65 . /**. If e
3a30: 69 74 68 65 72 20 6f 66 2e 2e 2e 0a 0a 20 20 20 ither of.....
3a40: 20 20 2d 20 50 2e 70 72 65 76 69 65 77 4d 6f 64 - P.previewMod
3a50: 65 73 2e 63 75 72 72 65 6e 74 3d 3d 3d 27 77 69 es.current==='wi
3a60: 6b 69 27 0a 0a 20 20 20 20 20 2d 20 50 2e 70 72 ki'.. - P.pr
3a70: 65 76 69 65 77 4d 6f 64 65 73 2e 63 75 72 72 65 eviewModes.curre
3a80: 6e 74 3d 3d 3d 27 67 75 65 73 73 27 20 41 4e 44 nt==='guess' AND
3a90: 20 74 68 65 20 63 75 72 72 65 6e 74 6c 79 2d 6c the currently-l
3aa0: 6f 61 64 65 64 20 66 69 6c 65 0a 20 20 20 20 20 oaded file.
3ab0: 68 61 73 20 61 20 6d 69 6d 65 74 79 70 65 20 6f has a mimetype o
3ac0: 66 20 22 74 65 78 74 2f 78 2d 66 6f 73 73 69 6c f "text/x-fossil
3ad0: 2d 77 69 6b 69 22 20 6f 72 20 22 74 65 78 74 2f -wiki" or "text/
3ae0: 78 2d 6d 61 72 6b 64 6f 77 6e 22 2e 0a 0a 20 20 x-markdown"...
3af0: 20 20 20 2e 2e 2e 20 74 68 65 6e 20 74 68 69 73 ... then this
3b00: 20 66 75 6e 63 74 69 6f 6e 20 75 70 64 61 74 65 function update
3b10: 73 20 74 68 65 20 64 6f 63 75 6d 65 6e 74 27 73 s the document's
3b20: 20 62 61 73 65 2e 68 72 65 66 20 74 6f 20 61 0a base.href to a.
3b30: 20 20 20 20 20 72 65 70 6f 2d 72 65 6c 61 74 69 repo-relati
3b40: 76 65 20 2f 64 6f 63 2f 7b 7b 74 68 69 73 2e 66 ve /doc/{{this.f
3b50: 69 6e 66 6f 2e 63 68 65 63 6b 69 6e 7d 7d 2f 7b info.checkin}}/{
3b60: 7b 64 69 72 65 63 74 6f 72 79 20 70 61 72 74 20 {directory part
3b70: 6f 66 0a 20 20 20 20 20 74 68 69 73 2e 66 69 6e of. this.fin
3b80: 66 6f 2e 66 69 6c 65 6e 61 6d 65 7d 7d 2f 0a 0a fo.filename}}/..
3b90: 20 20 20 20 20 49 66 20 6e 65 69 74 68 65 72 20 If neither
3ba0: 6f 66 20 74 68 6f 73 65 20 63 6f 6e 64 69 74 69 of those conditi
3bb0: 6f 6e 73 20 61 70 70 6c 69 65 73 2c 20 74 68 69 ons applies, thi
3bc0: 73 20 69 73 20 61 20 6e 6f 2d 6f 70 2e 0a 20 20 s is a no-op..
3bd0: 2a 2f 0a 20 20 50 2e 62 61 73 65 48 72 65 66 46 */. P.baseHrefF
3be0: 6f 72 46 69 6c 65 20 3d 20 66 75 6e 63 74 69 6f orFile = functio
3bf0: 6e 20 66 28 29 7b 0a 20 20 20 20 63 6f 6e 73 74 n f(){. const
3c00: 20 66 6e 20 3d 20 74 68 69 73 2e 66 69 6e 66 6f fn = this.finfo
3c10: 20 3f 20 74 68 69 73 2e 66 69 6e 66 6f 2e 66 69 ? this.finfo.fi
3c20: 6c 65 6e 61 6d 65 20 3a 20 75 6e 64 65 66 69 6e lename : undefin
3c30: 65 64 3b 0a 20 20 20 20 69 66 28 21 66 6e 29 20 ed;. if(!fn)
3c40: 72 65 74 75 72 6e 20 74 68 69 73 3b 0a 20 20 20 return this;.
3c50: 20 69 66 28 21 66 2e 77 69 6b 69 4d 69 6d 65 54 if(!f.wikiMimeT
3c60: 79 70 65 73 29 7b 0a 20 20 20 20 20 20 66 2e 77 ypes){. f.w
3c70: 69 6b 69 4d 69 6d 65 54 79 70 65 73 20 3d 20 5b ikiMimeTypes = [
3c80: 22 74 65 78 74 2f 78 2d 66 6f 73 73 69 6c 2d 77 "text/x-fossil-w
3c90: 69 6b 69 22 2c 20 22 74 65 78 74 2f 78 2d 6d 61 iki", "text/x-ma
3ca0: 72 6b 64 6f 77 6e 22 5d 3b 0a 20 20 20 20 7d 0a rkdown"];. }.
3cb0: 20 20 20 20 69 66 28 27 77 69 6b 69 27 3d 3d 3d if('wiki'===
3cc0: 50 2e 70 72 65 76 69 65 77 4d 6f 64 65 73 2e 63 P.previewModes.c
3cd0: 75 72 72 65 6e 74 0a 20 20 20 20 20 20 20 7c 7c urrent. ||
3ce0: 20 28 27 67 75 65 73 73 27 3d 3d 3d 50 2e 70 72 ('guess'===P.pr
3cf0: 65 76 69 65 77 4d 6f 64 65 73 2e 63 75 72 72 65 eviewModes.curre
3d00: 6e 74 0a 20 20 20 20 20 20 20 20 20 20 20 26 26 nt. &&
3d10: 20 66 2e 77 69 6b 69 4d 69 6d 65 54 79 70 65 73 f.wikiMimeTypes
3d20: 2e 69 6e 64 65 78 4f 66 28 74 68 69 73 2e 66 69 .indexOf(this.fi
3d30: 6e 66 6f 2e 6d 69 6d 65 74 79 70 65 29 3e 3d 30 nfo.mimetype)>=0
3d40: 29 29 7b 0a 20 20 20 20 20 20 63 6f 6e 73 74 20 )){. const
3d50: 61 20 3d 20 66 6e 2e 73 70 6c 69 74 28 27 2f 27 a = fn.split('/'
3d60: 29 3b 0a 20 20 20 20 20 20 61 2e 70 6f 70 28 29 );. a.pop()
3d70: 3b 0a 20 20 20 20 20 20 74 68 69 73 2e 62 61 73 ;. this.bas
3d80: 65 2e 74 61 67 2e 68 72 65 66 20 3d 20 46 2e 72 e.tag.href = F.r
3d90: 65 70 6f 55 72 6c 28 0a 20 20 20 20 20 20 20 20 epoUrl(.
3da0: 27 64 6f 63 2f 27 2b 46 2e 68 61 73 68 44 69 67 'doc/'+F.hashDig
3db0: 69 74 73 28 74 68 69 73 2e 66 69 6e 66 6f 2e 63 its(this.finfo.c
3dc0: 68 65 63 6b 69 6e 29 0a 20 20 20 20 20 20 20 20 heckin).
3dd0: 20 20 2b 27 2f 27 2b 28 61 2e 6c 65 6e 67 74 68 +'/'+(a.length
3de0: 20 3f 20 61 2e 6a 6f 69 6e 28 27 2f 27 29 2b 27 ? a.join('/')+'
3df0: 2f 27 20 3a 20 27 27 29 0a 20 20 20 20 20 20 29 /' : ''). )
3e00: 3b 0a 20 20 20 20 7d 0a 20 20 20 20 72 65 74 75 ;. }. retu
3e10: 72 6e 20 74 68 69 73 3b 0a 20 20 7d 3b 0a 0a 20 rn this;. };..
3e20: 20 2f 2a 2a 0a 20 20 20 20 20 53 65 74 73 20 74 /**. Sets t
3e30: 68 65 20 64 6f 63 75 6d 65 6e 74 27 73 20 62 61 he document's ba
3e40: 73 65 2e 68 72 65 66 20 76 61 6c 75 65 20 74 6f se.href value to
3e50: 20 69 74 73 20 70 61 67 65 2d 6c 6f 61 64 2d 74 its page-load-t
3e60: 69 6d 65 0a 20 20 20 20 20 73 65 74 74 69 6e 67 ime. setting
3e70: 2e 0a 20 20 2a 2f 0a 20 20 50 2e 62 61 73 65 48 .. */. P.baseH
3e80: 72 65 66 52 65 73 74 6f 72 65 20 3d 20 66 75 6e refRestore = fun
3e90: 63 74 69 6f 6e 28 29 7b 0a 20 20 20 20 50 2e 62 ction(){. P.b
3ea0: 61 73 65 2e 74 61 67 2e 68 72 65 66 20 3d 20 50 ase.tag.href = P
3eb0: 2e 62 61 73 65 2e 6f 72 69 67 69 6e 61 6c 48 72 .base.originalHr
3ec0: 65 66 3b 0a 20 20 7d 3b 0a 0a 20 20 2f 2a 2a 0a ef;. };.. /**.
3ed0: 20 20 20 20 20 54 6f 67 67 6c 65 73 20 62 65 74 Toggles bet
3ee0: 77 65 65 6e 20 73 69 6e 67 6c 65 2d 20 61 6e 64 ween single- and
3ef0: 20 6d 75 6c 74 69 2d 6c 69 6e 65 20 63 6f 6d 6d multi-line comm
3f00: 65 6e 74 0a 20 20 20 20 20 6d 6f 64 65 2e 0a 20 ent. mode..
3f10: 20 2a 2f 0a 20 20 50 2e 74 6f 67 67 6c 65 43 6f */. P.toggleCo
3f20: 6d 6d 65 6e 74 4d 6f 64 65 20 3d 20 66 75 6e 63 mmentMode = func
3f30: 74 69 6f 6e 28 29 7b 0a 20 20 20 20 76 61 72 20 tion(){. var
3f40: 73 2c 20 68 2c 20 63 20 3d 20 74 68 69 73 2e 65 s, h, c = this.e
3f50: 2e 74 61 43 6f 6d 6d 65 6e 74 2e 76 61 6c 75 65 .taComment.value
3f60: 3b 0a 20 20 20 20 69 66 28 74 68 69 73 2e 65 2e ;. if(this.e.
3f70: 74 61 43 6f 6d 6d 65 6e 74 20 3d 3d 3d 20 74 68 taComment === th
3f80: 69 73 2e 65 2e 74 61 43 6f 6d 6d 65 6e 74 53 6d is.e.taCommentSm
3f90: 61 6c 6c 29 7b 0a 20 20 20 20 20 20 73 20 3d 20 all){. s =
3fa0: 74 68 69 73 2e 65 2e 74 61 43 6f 6d 6d 65 6e 74 this.e.taComment
3fb0: 42 69 67 3b 0a 20 20 20 20 20 20 68 20 3d 20 74 Big;. h = t
3fc0: 68 69 73 2e 65 2e 74 61 43 6f 6d 6d 65 6e 74 53 his.e.taCommentS
3fd0: 6d 61 6c 6c 3b 0a 20 20 20 20 7d 65 6c 73 65 7b mall;. }else{
3fe0: 0a 20 20 20 20 20 20 73 20 3d 20 74 68 69 73 2e . s = this.
3ff0: 65 2e 74 61 43 6f 6d 6d 65 6e 74 53 6d 61 6c 6c e.taCommentSmall
4000: 3b 0a 20 20 20 20 20 20 68 20 3d 20 74 68 69 73 ;. h = this
4010: 2e 65 2e 74 61 43 6f 6d 6d 65 6e 74 42 69 67 3b .e.taCommentBig;
4020: 0a 20 20 20 20 20 20 2f 2a 0a 20 20 20 20 20 20 . /*.
4030: 20 20 44 6f 69 6e 67 20 28 69 6e 70 75 74 5b 74 Doing (input[t
4040: 79 70 65 3d 74 65 78 74 5d 2e 76 61 6c 75 65 20 ype=text].value
4050: 3d 20 74 65 78 74 61 72 65 61 2e 76 61 6c 75 65 = textarea.value
4060: 29 20 75 6e 66 6f 72 74 75 6e 61 74 65 6c 79 0a ) unfortunately.
4070: 20 20 20 20 20 20 20 20 73 74 72 69 70 73 20 61 strips a
4080: 6c 6c 20 6e 65 77 6c 69 6e 65 73 2e 20 54 6f 20 ll newlines. To
4090: 63 6f 6d 70 65 6e 73 61 74 65 20 77 65 27 6c 6c compensate we'll
40a0: 20 72 65 70 6c 61 63 65 20 65 61 63 68 20 45 4f replace each EO
40b0: 4c 20 77 69 74 68 0a 20 20 20 20 20 20 20 20 61 L with. a
40c0: 20 73 70 61 63 65 2e 20 4e 6f 74 20 69 64 65 61 space. Not idea
40d0: 6c 2e 20 49 66 20 77 65 20 77 65 72 65 20 74 6f l. If we were to
40e0: 20 69 6e 73 74 65 61 64 20 65 73 63 61 70 65 20 instead escape
40f0: 74 68 65 6d 20 61 73 20 5c 6e 2c 0a 20 20 20 20 them as \n,.
4100: 20 20 20 20 61 6e 64 20 64 6f 20 74 68 65 20 72 and do the r
4110: 65 76 65 72 73 65 20 77 68 65 6e 20 74 6f 67 67 everse when togg
4120: 6c 69 6e 67 20 61 67 61 69 6e 2c 20 74 68 65 6e ling again, then
4130: 20 74 68 65 79 20 77 6f 75 6c 64 20 67 65 74 0a they would get.
4140: 20 20 20 20 20 20 20 20 63 6f 6d 6d 69 74 74 65 committe
4150: 64 20 61 73 20 65 73 63 61 70 65 64 20 6e 65 77 d as escaped new
4160: 6c 69 6e 65 73 20 69 66 20 74 68 65 20 75 73 65 lines if the use
4170: 72 20 64 69 64 20 6e 6f 74 20 66 69 72 73 74 20 r did not first
4180: 73 77 69 74 63 68 0a 20 20 20 20 20 20 20 20 62 switch. b
4190: 61 63 6b 20 74 6f 20 6d 75 6c 74 69 2d 6c 69 6e ack to multi-lin
41a0: 65 20 6d 6f 64 65 2e 20 57 65 20 63 61 6e 6e 6f e mode. We canno
41b0: 74 20 62 6c 69 6e 64 6c 79 20 75 6e 65 73 63 61 t blindly unesca
41c0: 70 65 20 74 68 65 0a 20 20 20 20 20 20 20 20 6e pe the. n
41d0: 65 77 6c 69 6e 65 73 2c 20 69 6e 20 74 68 65 20 ewlines, in the
41e0: 6f 66 66 20 63 68 61 6e 63 65 20 74 68 61 74 20 off chance that
41f0: 74 68 65 20 75 73 65 72 20 61 63 74 75 61 6c 6c the user actuall
4200: 79 20 65 6e 74 65 72 73 20 5c 6e 0a 20 20 20 20 y enters \n.
4210: 20 20 20 20 69 6e 20 74 68 65 20 63 6f 6d 6d 65 in the comme
4220: 6e 74 2e 0a 20 20 20 20 20 20 2a 2f 0a 20 20 20 nt.. */.
4230: 20 20 20 63 20 3d 20 63 2e 72 65 70 6c 61 63 65 c = c.replace
4240: 28 2f 5c 72 3f 5c 6e 2f 67 2c 27 20 27 29 3b 0a (/\r?\n/g,' ');.
4250: 20 20 20 20 7d 0a 20 20 20 20 73 2e 76 61 6c 75 }. s.valu
4260: 65 20 3d 20 63 3b 0a 20 20 20 20 74 68 69 73 2e e = c;. this.
4270: 65 2e 74 61 43 6f 6d 6d 65 6e 74 20 3d 20 73 3b e.taComment = s;
4280: 0a 20 20 20 20 44 2e 61 64 64 43 6c 61 73 73 28 . D.addClass(
4290: 68 2c 20 27 68 69 64 64 65 6e 27 29 3b 0a 20 20 h, 'hidden');.
42a0: 20 20 44 2e 72 65 6d 6f 76 65 43 6c 61 73 73 28 D.removeClass(
42b0: 73 2c 20 27 68 69 64 64 65 6e 27 29 3b 0a 20 20 s, 'hidden');.
42c0: 7d 3b 0a 0a 20 20 2f 2a 2a 0a 20 20 20 20 20 52 };.. /**. R
42d0: 65 74 75 72 6e 73 20 74 72 75 65 20 69 66 20 66 eturns true if f
42e0: 6f 73 73 69 6c 2e 70 61 67 65 2e 66 69 6e 66 6f ossil.page.finfo
42f0: 20 69 73 20 73 65 74 2c 20 69 6e 64 69 63 61 74 is set, indicat
4300: 69 6e 67 20 74 68 61 74 20 61 20 66 69 6c 65 0a ing that a file.
4310: 20 20 20 20 20 68 61 73 20 62 65 65 6e 20 6c 6f has been lo
4320: 61 64 65 64 2c 20 65 6c 73 65 20 69 74 20 72 65 aded, else it re
4330: 70 6f 72 74 73 20 61 6e 20 65 72 72 6f 72 20 61 ports an error a
4340: 6e 64 20 72 65 74 75 72 6e 73 20 66 61 6c 73 65 nd returns false
4350: 2e 0a 0a 20 20 20 20 20 49 66 20 70 61 73 73 65 ... If passe
4360: 64 20 61 20 74 72 75 74 68 79 20 76 61 6c 75 65 d a truthy value
4370: 20 61 6e 79 20 65 72 72 6f 72 20 6d 65 73 73 61 any error messa
4380: 67 65 20 61 62 6f 75 74 20 6e 6f 74 20 68 61 76 ge about not hav
4390: 69 6e 67 0a 20 20 20 20 20 61 20 66 69 6c 65 20 ing. a file
43a0: 6c 6f 61 64 65 64 20 69 73 20 73 75 70 70 72 65 loaded is suppre
43b0: 73 73 65 64 2e 0a 20 20 2a 2f 0a 20 20 63 6f 6e ssed.. */. con
43c0: 73 74 20 61 66 66 69 72 6d 48 61 73 46 69 6c 65 st affirmHasFile
43d0: 20 3d 20 66 75 6e 63 74 69 6f 6e 28 71 75 69 65 = function(quie
43e0: 74 29 7b 0a 20 20 20 20 69 66 28 21 50 2e 66 69 t){. if(!P.fi
43f0: 6e 66 6f 29 7b 0a 20 20 20 20 20 20 69 66 28 21 nfo){. if(!
4400: 71 75 69 65 74 29 20 46 2e 65 72 72 6f 72 28 22 quiet) F.error("
4410: 4e 6f 20 66 69 6c 65 20 69 73 20 6c 6f 61 64 65 No file is loade
4420: 64 2e 22 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 d.");. }.
4430: 72 65 74 75 72 6e 20 21 21 50 2e 66 69 6e 66 6f return !!P.finfo
4440: 3b 0a 20 20 7d 3b 0a 0a 20 20 2f 2a 2a 0a 20 20 ;. };.. /**.
4450: 20 20 20 75 70 64 61 74 65 56 65 72 73 69 6f 6e updateVersion
4460: 28 29 20 75 70 64 61 74 65 73 20 74 68 65 20 66 () updates the f
4470: 69 6c 65 6e 61 6d 65 20 61 6e 64 20 76 65 72 73 ilename and vers
4480: 69 6f 6e 20 69 6e 20 76 61 72 69 6f 75 73 20 55 ion in various U
4490: 49 0a 20 20 20 20 20 65 6c 65 6d 65 6e 74 73 2e I. elements.
44a0: 2e 2e 0a 0a 20 20 20 20 20 52 65 74 75 72 6e 73 .... Returns
44b0: 20 74 68 69 73 20 6f 62 6a 65 63 74 2e 0a 20 20 this object..
44c0: 2a 2f 0a 20 20 50 2e 75 70 64 61 74 65 56 65 72 */. P.updateVer
44d0: 73 69 6f 6e 20 3d 20 66 75 6e 63 74 69 6f 6e 28 sion = function(
44e0: 66 69 6c 65 2c 72 65 76 29 7b 0a 20 20 20 20 69 file,rev){. i
44f0: 66 28 31 3d 3d 3d 61 72 67 75 6d 65 6e 74 73 2e f(1===arguments.
4500: 6c 65 6e 67 74 68 29 7b 2f 2a 61 73 73 75 6d 65 length){/*assume
4510: 20 6f 62 6a 65 63 74 2a 2f 0a 20 20 20 20 20 20 object*/.
4520: 74 68 69 73 2e 66 69 6e 66 6f 20 3d 20 61 72 67 this.finfo = arg
4530: 75 6d 65 6e 74 73 5b 30 5d 3b 0a 20 20 20 20 20 uments[0];.
4540: 20 66 69 6c 65 20 3d 20 74 68 69 73 2e 66 69 6e file = this.fin
4550: 66 6f 2e 66 69 6c 65 6e 61 6d 65 3b 0a 20 20 20 fo.filename;.
4560: 20 20 20 72 65 76 20 3d 20 74 68 69 73 2e 66 69 rev = this.fi
4570: 6e 66 6f 2e 63 68 65 63 6b 69 6e 3b 0a 20 20 20 nfo.checkin;.
4580: 20 7d 65 6c 73 65 20 69 66 28 30 3d 3d 3d 61 72 }else if(0===ar
4590: 67 75 6d 65 6e 74 73 2e 6c 65 6e 67 74 68 29 7b guments.length){
45a0: 0a 20 20 20 20 20 20 69 66 28 21 61 66 66 69 72 . if(!affir
45b0: 6d 48 61 73 46 69 6c 65 28 29 29 20 72 65 74 75 mHasFile()) retu
45c0: 72 6e 20 74 68 69 73 3b 0a 20 20 20 20 20 20 66 rn this;. f
45d0: 69 6c 65 20 3d 20 74 68 69 73 2e 66 69 6e 66 6f ile = this.finfo
45e0: 2e 66 69 6c 65 6e 61 6d 65 3b 0a 20 20 20 20 20 .filename;.
45f0: 20 72 65 76 20 3d 20 74 68 69 73 2e 66 69 6e 66 rev = this.finf
4600: 6f 2e 63 68 65 63 6b 69 6e 3b 0a 20 20 20 20 7d o.checkin;. }
4610: 65 6c 73 65 7b 0a 20 20 20 20 20 20 74 68 69 73 else{. this
4620: 2e 66 69 6e 66 6f 20 3d 20 7b 66 69 6c 65 6e 61 .finfo = {filena
4630: 6d 65 3a 66 69 6c 65 2c 63 68 65 63 6b 69 6e 3a me:file,checkin:
4640: 72 65 76 7d 3b 0a 20 20 20 20 7d 0a 20 20 20 20 rev};. }.
4650: 63 6f 6e 73 74 20 65 54 67 74 20 3d 20 74 68 69 const eTgt = thi
4660: 73 2e 65 2e 66 73 46 69 6c 65 56 65 72 73 69 6f s.e.fsFileVersio
4670: 6e 44 65 74 61 69 6c 73 2e 71 75 65 72 79 53 65 nDetails.querySe
4680: 6c 65 63 74 6f 72 28 27 64 69 76 27 29 2c 0a 20 lector('div'),.
4690: 20 20 20 20 20 20 20 20 20 72 48 75 6d 61 6e 20 rHuman
46a0: 3d 20 46 2e 68 61 73 68 44 69 67 69 74 73 28 72 = F.hashDigits(r
46b0: 65 76 29 2c 0a 20 20 20 20 20 20 20 20 20 20 72 ev),. r
46c0: 55 72 6c 20 3d 20 46 2e 68 61 73 68 44 69 67 69 Url = F.hashDigi
46d0: 74 73 28 72 65 76 2c 74 72 75 65 29 3b 0a 20 20 ts(rev,true);.
46e0: 20 20 44 2e 63 6c 65 61 72 45 6c 65 6d 65 6e 74 D.clearElement
46f0: 28 65 54 67 74 29 3b 0a 20 20 20 20 44 2e 61 70 (eTgt);. D.ap
4700: 70 65 6e 64 28 0a 20 20 20 20 20 20 65 54 67 74 pend(. eTgt
4710: 2c 20 22 46 69 6c 65 3a 20 22 2c 0a 20 20 20 20 , "File: ",.
4720: 20 20 44 2e 61 70 70 65 6e 64 28 44 2e 63 6f 64 D.append(D.cod
4730: 65 28 29 2c 0a 20 20 20 20 20 20 20 20 20 20 20 e(),.
4740: 20 20 20 20 44 2e 61 28 46 2e 72 65 70 6f 55 72 D.a(F.repoUr
4750: 6c 28 27 66 69 6e 66 6f 27 2c 7b 6e 61 6d 65 3a l('finfo',{name:
4760: 66 69 6c 65 2c 20 6d 3a 72 55 72 6c 7d 29 2c 20 file, m:rUrl}),
4770: 66 69 6c 65 29 29 2c 0a 20 20 20 20 20 20 44 2e file)),. D.
4780: 62 72 28 29 0a 20 20 20 20 29 3b 0a 20 20 20 20 br(). );.
4790: 44 2e 61 70 70 65 6e 64 28 0a 20 20 20 20 20 20 D.append(.
47a0: 65 54 67 74 2c 20 22 43 68 65 63 6b 69 6e 3a 20 eTgt, "Checkin:
47b0: 22 2c 0a 20 20 20 20 20 20 44 2e 61 70 70 65 6e ",. D.appen
47c0: 64 28 44 2e 63 6f 64 65 28 29 2c 20 44 2e 61 28 d(D.code(), D.a(
47d0: 46 2e 72 65 70 6f 55 72 6c 28 27 69 6e 66 6f 2f F.repoUrl('info/
47e0: 27 2b 72 55 72 6c 29 2c 20 72 48 75 6d 61 6e 29 '+rUrl), rHuman)
47f0: 29 2c 0a 20 20 20 20 20 20 22 20 5b 22 2c 44 2e ),. " [",D.
4800: 61 28 46 2e 72 65 70 6f 55 72 6c 28 27 74 69 6d a(F.repoUrl('tim
4810: 65 6c 69 6e 65 27 2c 7b 6d 3a 72 55 72 6c 7d 29 eline',{m:rUrl})
4820: 2c 20 22 74 69 6d 65 6c 69 6e 65 22 29 2c 22 5d , "timeline"),"]
4830: 22 2c 0a 20 20 20 20 20 20 44 2e 62 72 28 29 0a ",. D.br().
4840: 20 20 20 20 29 3b 0a 20 20 20 20 44 2e 61 70 70 );. D.app
4850: 65 6e 64 28 0a 20 20 20 20 20 20 65 54 67 74 2c end(. eTgt,
4860: 20 22 4d 69 6d 65 74 79 70 65 3a 20 22 2c 0a 20 "Mimetype: ",.
4870: 20 20 20 20 20 44 2e 61 70 70 65 6e 64 28 44 2e D.append(D.
4880: 63 6f 64 65 28 29 2c 20 74 68 69 73 2e 66 69 6e code(), this.fin
4890: 66 6f 2e 6d 69 6d 65 74 79 70 65 7c 7c 27 3f 3f fo.mimetype||'??
48a0: 3f 27 29 2c 0a 20 20 20 20 20 20 44 2e 62 72 28 ?'),. D.br(
48b0: 29 0a 20 20 20 20 29 3b 0a 20 20 20 20 44 2e 61 ). );. D.a
48c0: 70 70 65 6e 64 28 0a 20 20 20 20 20 20 65 54 67 ppend(. eTg
48d0: 74 2c 0a 20 20 20 20 20 20 44 2e 61 70 70 65 6e t,. D.appen
48e0: 64 28 44 2e 63 6f 64 65 28 29 2c 20 22 5b 22 2c d(D.code(), "[",
48f0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
4900: 44 2e 61 28 46 2e 72 65 70 6f 55 72 6c 28 27 61 D.a(F.repoUrl('a
4910: 6e 6e 6f 74 61 74 65 27 2c 7b 66 69 6c 65 6e 61 nnotate',{filena
4920: 6d 65 3a 66 69 6c 65 2c 20 63 68 65 63 6b 69 6e me:file, checkin
4930: 3a 72 55 72 6c 7d 29 2c 0a 20 20 20 20 20 20 20 :rUrl}),.
4940: 20 20 20 20 20 20 20 20 20 20 20 20 27 61 6e 6e 'ann
4950: 6f 74 61 74 65 27 29 2c 20 22 5d 22 29 2c 0a 20 otate'), "]"),.
4960: 20 20 20 20 20 44 2e 61 70 70 65 6e 64 28 44 2e D.append(D.
4970: 63 6f 64 65 28 29 2c 20 22 5b 22 2c 0a 20 20 20 code(), "[",.
4980: 20 20 20 20 20 20 20 20 20 20 20 20 44 2e 61 28 D.a(
4990: 46 2e 72 65 70 6f 55 72 6c 28 27 62 6c 61 6d 65 F.repoUrl('blame
49a0: 27 2c 7b 66 69 6c 65 6e 61 6d 65 3a 66 69 6c 65 ',{filename:file
49b0: 2c 20 63 68 65 63 6b 69 6e 3a 72 55 72 6c 7d 29 , checkin:rUrl})
49c0: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,.
49d0: 20 20 20 20 20 27 62 6c 61 6d 65 27 29 2c 20 22 'blame'), "
49e0: 5d 22 29 0a 20 20 20 20 29 3b 0a 20 20 20 20 63 ]"). );. c
49f0: 6f 6e 73 74 20 70 75 72 6c 41 72 67 73 20 3d 20 onst purlArgs =
4a00: 46 2e 65 6e 63 6f 64 65 55 72 6c 41 72 67 73 28 F.encodeUrlArgs(
4a10: 7b 0a 20 20 20 20 20 20 66 69 6c 65 6e 61 6d 65 {. filename
4a20: 3a 20 74 68 69 73 2e 66 69 6e 66 6f 2e 66 69 6c : this.finfo.fil
4a30: 65 6e 61 6d 65 2c 0a 20 20 20 20 20 20 63 68 65 ename,. che
4a40: 63 6b 69 6e 3a 20 72 55 72 6c 0a 20 20 20 20 7d ckin: rUrl. }
4a50: 2c 66 61 6c 73 65 2c 74 72 75 65 29 3b 0a 20 20 ,false,true);.
4a60: 20 20 63 6f 6e 73 74 20 70 75 72 6c 20 3d 20 46 const purl = F
4a70: 2e 72 65 70 6f 55 72 6c 28 27 66 69 6c 65 65 64 .repoUrl('fileed
4a80: 69 74 27 2c 70 75 72 6c 41 72 67 73 29 3b 0a 20 it',purlArgs);.
4a90: 20 20 20 44 2e 61 70 70 65 6e 64 28 0a 20 20 20 D.append(.
4aa0: 20 20 20 65 54 67 74 2c 0a 20 20 20 20 20 20 44 eTgt,. D
4ab0: 2e 61 70 70 65 6e 64 28 44 2e 63 6f 64 65 28 29 .append(D.code()
4ac0: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,.
4ad0: 20 22 5b 22 2c 44 2e 61 28 70 75 72 6c 2c 22 45 "[",D.a(purl,"E
4ae0: 64 69 74 6f 72 20 70 65 72 6d 61 6c 69 6e 6b 22 ditor permalink"
4af0: 29 2c 22 5d 22 29 0a 20 20 20 20 29 3b 0a 20 20 ),"]"). );.
4b00: 20 20 74 68 69 73 2e 73 65 74 50 61 67 65 54 69 this.setPageTi
4b10: 74 6c 65 28 22 45 64 69 74 3a 20 22 2b 74 68 69 tle("Edit: "+thi
4b20: 73 2e 66 69 6e 66 6f 2e 66 69 6c 65 6e 61 6d 65 s.finfo.filename
4b30: 29 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 74 68 );. return th
4b40: 69 73 3b 0a 20 20 7d 3b 0a 0a 20 20 2f 2a 2a 0a is;. };.. /**.
4b50: 20 20 20 20 20 6c 6f 61 64 46 69 6c 65 28 29 20 loadFile()
4b60: 6c 6f 61 64 73 20 28 66 69 6c 65 2c 63 68 65 63 loads (file,chec
4b70: 6b 69 6e 56 65 72 73 69 6f 6e 29 20 61 6e 64 20 kinVersion) and
4b80: 75 70 64 61 74 65 73 20 74 68 65 20 72 65 6c 65 updates the rele
4b90: 76 61 6e 74 0a 20 20 20 20 20 55 49 20 65 6c 65 vant. UI ele
4ba0: 6d 65 6e 74 73 20 74 6f 20 72 65 66 6c 65 63 74 ments to reflect
4bb0: 20 74 68 65 20 6c 6f 61 64 65 64 20 73 74 61 74 the loaded stat
4bc0: 65 2e 20 49 66 20 70 61 73 73 65 64 20 6e 6f 20 e. If passed no
4bd0: 61 72 67 75 6d 65 6e 74 73 0a 20 20 20 20 20 74 arguments. t
4be0: 68 65 6e 20 69 74 20 72 65 2d 75 73 65 73 20 74 hen it re-uses t
4bf0: 68 65 20 76 61 6c 75 65 73 20 66 72 6f 6d 20 74 he values from t
4c00: 68 65 20 63 75 72 72 65 6e 74 6c 79 2d 6c 6f 61 he currently-loa
4c10: 64 65 64 20 66 69 6c 65 2c 20 72 65 6c 6f 61 64 ded file, reload
4c20: 69 6e 67 0a 20 20 20 20 20 69 74 20 28 65 6d 69 ing. it (emi
4c30: 74 74 69 6e 67 20 61 6e 20 65 72 72 6f 72 20 6d tting an error m
4c40: 65 73 73 61 67 65 20 69 66 20 6e 6f 20 66 69 6c essage if no fil
4c50: 65 20 69 73 20 6c 6f 61 64 65 64 29 2e 0a 0a 20 e is loaded)...
4c60: 20 20 20 20 52 65 74 75 72 6e 73 20 74 68 69 73 Returns this
4c70: 20 6f 62 6a 65 63 74 2c 20 6e 6f 74 69 6e 67 20 object, noting
4c80: 74 68 61 74 20 74 68 65 20 6c 6f 61 64 20 69 73 that the load is
4c90: 20 61 73 79 6e 63 2e 20 41 66 74 65 72 20 6c 6f async. After lo
4ca0: 61 64 69 6e 67 0a 20 20 20 20 20 69 74 20 74 72 ading. it tr
4cb0: 69 67 67 65 72 73 20 61 20 27 66 69 6c 65 65 64 iggers a 'fileed
4cc0: 69 74 2d 66 69 6c 65 2d 6c 6f 61 64 65 64 27 20 it-file-loaded'
4cd0: 65 76 65 6e 74 2c 20 70 61 73 73 69 6e 67 20 69 event, passing i
4ce0: 74 0a 20 20 20 20 20 74 68 69 73 2e 66 69 6e 66 t. this.finf
4cf0: 6f 2e 0a 20 20 2a 2f 0a 20 20 50 2e 6c 6f 61 64 o.. */. P.load
4d00: 46 69 6c 65 20 3d 20 66 75 6e 63 74 69 6f 6e 28 File = function(
4d10: 66 69 6c 65 2c 72 65 76 29 7b 0a 20 20 20 20 69 file,rev){. i
4d20: 66 28 30 3d 3d 3d 61 72 67 75 6d 65 6e 74 73 2e f(0===arguments.
4d30: 6c 65 6e 67 74 68 29 7b 0a 20 20 20 20 20 20 69 length){. i
4d40: 66 28 21 61 66 66 69 72 6d 48 61 73 46 69 6c 65 f(!affirmHasFile
4d50: 28 29 29 20 72 65 74 75 72 6e 20 74 68 69 73 3b ()) return this;
4d60: 0a 20 20 20 20 20 20 66 69 6c 65 20 3d 20 74 68 . file = th
4d70: 69 73 2e 66 69 6e 66 6f 2e 66 69 6c 65 6e 61 6d is.finfo.filenam
4d80: 65 3b 0a 20 20 20 20 20 20 72 65 76 20 3d 20 74 e;. rev = t
4d90: 68 69 73 2e 66 69 6e 66 6f 2e 63 68 65 63 6b 69 his.finfo.checki
4da0: 6e 3b 0a 20 20 20 20 7d 0a 20 20 20 20 63 6f 6e n;. }. con
4db0: 73 74 20 73 65 6c 66 20 3d 20 74 68 69 73 3b 0a st self = this;.
4dc0: 20 20 20 20 63 6f 6e 73 74 20 6f 6e 6c 6f 61 64 const onload
4dd0: 20 3d 20 28 72 2c 68 65 61 64 65 72 73 29 3d 3e = (r,headers)=>
4de0: 7b 0a 20 20 20 20 20 20 64 65 6c 65 74 65 20 73 {. delete s
4df0: 65 6c 66 2e 66 69 6e 66 6f 3b 0a 20 20 20 20 20 elf.finfo;.
4e00: 20 73 65 6c 66 2e 75 70 64 61 74 65 56 65 72 73 self.updateVers
4e10: 69 6f 6e 28 7b 0a 20 20 20 20 20 20 20 20 66 69 ion({. fi
4e20: 6c 65 6e 61 6d 65 3a 20 66 69 6c 65 2c 0a 20 20 lename: file,.
4e30: 20 20 20 20 20 20 63 68 65 63 6b 69 6e 3a 20 72 checkin: r
4e40: 65 76 2c 0a 20 20 20 20 20 20 20 20 69 73 45 78 ev,. isEx
4e50: 65 3a 20 28 27 78 27 3d 3d 3d 68 65 61 64 65 72 e: ('x'===header
4e60: 73 5b 27 78 2d 66 69 6c 65 65 64 69 74 2d 66 69 s['x-fileedit-fi
4e70: 6c 65 2d 70 65 72 6d 27 5d 29 2c 0a 20 20 20 20 le-perm']),.
4e80: 20 20 20 20 6d 69 6d 65 74 79 70 65 3a 20 68 65 mimetype: he
4e90: 61 64 65 72 73 5b 27 63 6f 6e 74 65 6e 74 2d 74 aders['content-t
4ea0: 79 70 65 27 5d 2e 73 70 6c 69 74 28 27 3b 27 29 ype'].split(';')
4eb0: 2e 73 68 69 66 74 28 29 0a 20 20 20 20 20 20 7d .shift(). }
4ec0: 29 3b 0a 20 20 20 20 20 20 73 65 6c 66 2e 74 61 );. self.ta
4ed0: 62 73 2e 73 77 69 74 63 68 54 6f 54 61 62 28 73 bs.switchToTab(s
4ee0: 65 6c 66 2e 65 2e 74 61 62 73 2e 63 6f 6e 74 65 elf.e.tabs.conte
4ef0: 6e 74 29 3b 0a 20 20 20 20 20 20 73 65 6c 66 2e nt);. self.
4f00: 65 2e 63 62 49 73 45 78 65 2e 63 68 65 63 6b 65 e.cbIsExe.checke
4f10: 64 20 3d 20 73 65 6c 66 2e 66 69 6e 66 6f 2e 69 d = self.finfo.i
4f20: 73 45 78 65 3b 0a 20 20 20 20 20 20 73 65 6c 66 sExe;. self
4f30: 2e 66 69 6c 65 43 6f 6e 74 65 6e 74 28 72 29 3b .fileContent(r);
4f40: 0a 20 20 20 20 20 20 73 65 6c 66 2e 64 69 73 70 . self.disp
4f50: 61 74 63 68 45 76 65 6e 74 28 27 66 69 6c 65 65 atchEvent('filee
4f60: 64 69 74 2d 66 69 6c 65 2d 6c 6f 61 64 65 64 27 dit-file-loaded'
4f70: 2c 20 73 65 6c 66 2e 66 69 6e 66 6f 29 3b 0a 20 , self.finfo);.
4f80: 20 20 20 7d 3b 0a 20 20 20 20 63 6f 6e 73 74 20 };. const
4f90: 73 65 6d 69 46 69 6e 66 6f 20 3d 20 7b 66 69 6c semiFinfo = {fil
4fa0: 65 6e 61 6d 65 3a 20 66 69 6c 65 2c 20 63 68 65 ename: file, che
4fb0: 63 6b 69 6e 3a 20 72 65 76 7d 3b 0a 20 20 20 20 ckin: rev};.
4fc0: 63 6f 6e 73 74 20 73 74 61 73 68 46 69 6e 66 6f const stashFinfo
4fd0: 20 3d 20 74 68 69 73 2e 67 65 74 53 74 61 73 68 = this.getStash
4fe0: 65 64 46 69 6e 66 6f 28 73 65 6d 69 46 69 6e 66 edFinfo(semiFinf
4ff0: 6f 29 3b 0a 20 20 20 20 69 66 28 73 74 61 73 68 o);. if(stash
5000: 46 69 6e 66 6f 29 7b 20 2f 2f 20 66 61 6b 65 20 Finfo){ // fake
5010: 61 20 72 65 73 70 6f 6e 73 65 20 66 72 6f 6d 20 a response from
5020: 74 68 65 20 73 74 61 73 68 2e 2e 2e 0a 20 20 20 the stash....
5030: 20 20 20 74 68 69 73 2e 66 69 6e 66 6f 20 3d 20 this.finfo =
5040: 73 74 61 73 68 46 69 6e 66 6f 3b 0a 20 20 20 20 stashFinfo;.
5050: 20 20 74 68 69 73 2e 65 2e 63 62 49 73 45 78 65 this.e.cbIsExe
5060: 2e 63 68 65 63 6b 65 64 20 3d 20 21 21 73 74 61 .checked = !!sta
5070: 73 68 46 69 6e 66 6f 2e 69 73 45 78 65 3b 0a 20 shFinfo.isExe;.
5080: 20 20 20 20 20 6f 6e 6c 6f 61 64 28 74 68 69 73 onload(this
5090: 2e 63 6f 6e 74 65 6e 74 46 72 6f 6d 53 74 61 73 .contentFromStas
50a0: 68 28 29 7c 7c 27 27 2c 7b 0a 20 20 20 20 20 20 h()||'',{.
50b0: 20 20 27 78 2d 66 69 6c 65 65 64 69 74 2d 66 69 'x-fileedit-fi
50c0: 6c 65 2d 70 65 72 6d 27 3a 20 73 74 61 73 68 46 le-perm': stashF
50d0: 69 6e 66 6f 2e 69 73 45 78 65 20 3f 20 27 78 27 info.isExe ? 'x'
50e0: 20 3a 20 75 6e 64 65 66 69 6e 65 64 2c 0a 20 20 : undefined,.
50f0: 20 20 20 20 20 20 27 63 6f 6e 74 65 6e 74 2d 74 'content-t
5100: 79 70 65 27 3a 20 73 74 61 73 68 46 69 6e 66 6f ype': stashFinfo
5110: 2e 6d 69 6d 65 74 79 70 65 0a 20 20 20 20 20 20 .mimetype.
5120: 7d 29 3b 0a 20 20 20 20 20 20 46 2e 6d 65 73 73 });. F.mess
5130: 61 67 65 28 22 46 65 74 63 68 65 64 20 66 72 6f age("Fetched fro
5140: 6d 20 74 68 65 20 6c 6f 63 61 6c 2d 65 64 69 74 m the local-edit
5150: 20 73 74 61 73 68 3a 22 2c 0a 20 20 20 20 20 20 stash:",.
5160: 20 20 20 20 20 20 20 20 20 20 46 2e 68 61 73 68 F.hash
5170: 44 69 67 69 74 73 28 73 74 61 73 68 46 69 6e 66 Digits(stashFinf
5180: 6f 2e 63 68 65 63 6b 69 6e 29 2c 0a 20 20 20 20 o.checkin),.
5190: 20 20 20 20 20 20 20 20 20 20 20 20 73 74 61 73 stas
51a0: 68 46 69 6e 66 6f 2e 66 69 6c 65 6e 61 6d 65 29 hFinfo.filename)
51b0: 3b 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 ;. return t
51c0: 68 69 73 3b 0a 20 20 20 20 7d 0a 20 20 20 20 46 his;. }. F
51d0: 2e 6d 65 73 73 61 67 65 28 0a 20 20 20 20 20 20 .message(.
51e0: 22 4c 6f 61 64 69 6e 67 20 63 6f 6e 74 65 6e 74 "Loading content
51f0: 2e 2e 2e 22 0a 20 20 20 20 29 2e 66 65 74 63 68 ...". ).fetch
5200: 28 27 66 69 6c 65 65 64 69 74 27 2c 7b 0a 20 20 ('fileedit',{.
5210: 20 20 20 20 75 72 6c 50 61 72 61 6d 73 3a 20 7b urlParams: {
5220: 0a 20 20 20 20 20 20 20 20 61 6a 61 78 3a 20 27 . ajax: '
5230: 63 6f 6e 74 65 6e 74 27 2c 0a 20 20 20 20 20 20 content',.
5240: 20 20 66 69 6c 65 6e 61 6d 65 3a 66 69 6c 65 2c filename:file,
5250: 0a 20 20 20 20 20 20 20 20 63 68 65 63 6b 69 6e . checkin
5260: 3a 72 65 76 0a 20 20 20 20 20 20 7d 2c 0a 20 20 :rev. },.
5270: 20 20 20 20 72 65 73 70 6f 6e 73 65 48 65 61 64 responseHead
5280: 65 72 73 3a 20 5b 27 78 2d 66 69 6c 65 65 64 69 ers: ['x-fileedi
5290: 74 2d 66 69 6c 65 2d 70 65 72 6d 27 2c 20 27 63 t-file-perm', 'c
52a0: 6f 6e 74 65 6e 74 2d 74 79 70 65 27 5d 2c 0a 20 ontent-type'],.
52b0: 20 20 20 20 20 6f 6e 6c 6f 61 64 3a 28 72 2c 68 onload:(r,h
52c0: 65 61 64 65 72 73 29 3d 3e 7b 0a 20 20 20 20 20 eaders)=>{.
52d0: 20 20 20 6f 6e 6c 6f 61 64 28 72 2c 68 65 61 64 onload(r,head
52e0: 65 72 73 29 3b 0a 20 20 20 20 20 20 20 20 46 2e ers);. F.
52f0: 6d 65 73 73 61 67 65 28 27 4c 6f 61 64 65 64 20 message('Loaded
5300: 63 6f 6e 74 65 6e 74 20 66 6f 72 27 2c 0a 20 20 content for',.
5310: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5320: 46 2e 68 61 73 68 44 69 67 69 74 73 28 73 65 6c F.hashDigits(sel
5330: 66 2e 66 69 6e 66 6f 2e 63 68 65 63 6b 69 6e 29 f.finfo.checkin)
5340: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,.
5350: 20 20 20 20 73 65 6c 66 2e 66 69 6e 66 6f 2e 66 self.finfo.f
5360: 69 6c 65 6e 61 6d 65 29 3b 0a 20 20 20 20 20 20 ilename);.
5370: 7d 0a 20 20 20 20 7d 29 3b 0a 20 20 20 20 72 65 }. });. re
5380: 74 75 72 6e 20 74 68 69 73 3b 0a 20 20 7d 3b 0a turn this;. };.
5390: 0a 20 20 2f 2a 2a 0a 20 20 20 20 20 46 65 74 63 . /**. Fetc
53a0: 68 65 73 20 74 68 65 20 70 61 67 65 20 70 72 65 hes the page pre
53b0: 76 69 65 77 20 62 61 73 65 64 20 6f 6e 20 74 68 view based on th
53c0: 65 20 63 6f 6e 74 65 6e 74 73 20 61 6e 64 20 73 e contents and s
53d0: 65 74 74 69 6e 67 73 20 6f 66 0a 20 20 20 20 20 ettings of.
53e0: 74 68 69 73 20 70 61 67 65 27 73 20 69 6e 70 75 this page's inpu
53f0: 74 20 66 69 65 6c 64 73 2c 20 61 6e 64 20 75 70 t fields, and up
5400: 64 61 74 65 73 20 74 68 65 20 55 49 20 77 69 74 dates the UI wit
5410: 68 20 77 69 74 68 20 74 68 65 0a 20 20 20 20 20 h with the.
5420: 70 72 65 76 69 65 77 2e 0a 0a 20 20 20 20 20 52 preview... R
5430: 65 74 75 72 6e 73 20 74 68 69 73 20 6f 62 6a 65 eturns this obje
5440: 63 74 2c 20 6e 6f 74 69 6e 67 20 74 68 61 74 20 ct, noting that
5450: 74 68 65 20 6f 70 65 72 61 74 69 6f 6e 20 69 73 the operation is
5460: 20 61 73 79 6e 63 2e 0a 20 20 2a 2f 0a 20 20 50 async.. */. P
5470: 2e 70 72 65 76 69 65 77 20 3d 20 66 75 6e 63 74 .preview = funct
5480: 69 6f 6e 20 66 28 73 77 69 74 63 68 54 6f 54 61 ion f(switchToTa
5490: 62 29 7b 0a 20 20 20 20 69 66 28 21 61 66 66 69 b){. if(!affi
54a0: 72 6d 48 61 73 46 69 6c 65 28 29 29 20 72 65 74 rmHasFile()) ret
54b0: 75 72 6e 20 74 68 69 73 3b 0a 20 20 20 20 63 6f urn this;. co
54c0: 6e 73 74 20 74 61 72 67 65 74 20 3d 20 74 68 69 nst target = thi
54d0: 73 2e 65 2e 70 72 65 76 69 65 77 54 61 72 67 65 s.e.previewTarge
54e0: 74 2c 0a 20 20 20 20 20 20 20 20 20 20 73 65 6c t,. sel
54f0: 66 20 3d 20 74 68 69 73 3b 0a 20 20 20 20 63 6f f = this;. co
5500: 6e 73 74 20 75 70 64 61 74 65 56 69 65 77 20 3d nst updateView =
5510: 20 66 75 6e 63 74 69 6f 6e 28 63 29 7b 0a 20 20 function(c){.
5520: 20 20 20 20 44 2e 63 6c 65 61 72 45 6c 65 6d 65 D.clearEleme
5530: 6e 74 28 74 61 72 67 65 74 29 3b 0a 20 20 20 20 nt(target);.
5540: 20 20 69 66 28 27 73 74 72 69 6e 67 27 3d 3d 3d if('string'===
5550: 74 79 70 65 6f 66 20 63 29 20 74 61 72 67 65 74 typeof c) target
5560: 2e 69 6e 6e 65 72 48 54 4d 4c 20 3d 20 63 3b 0a .innerHTML = c;.
5570: 20 20 20 20 20 20 69 66 28 73 77 69 74 63 68 54 if(switchT
5580: 6f 54 61 62 29 20 73 65 6c 66 2e 74 61 62 73 2e oTab) self.tabs.
5590: 73 77 69 74 63 68 54 6f 54 61 62 28 73 65 6c 66 switchToTab(self
55a0: 2e 65 2e 74 61 62 73 2e 70 72 65 76 69 65 77 29 .e.tabs.preview)
55b0: 3b 0a 20 20 20 20 7d 3b 0a 20 20 20 20 72 65 74 ;. };. ret
55c0: 75 72 6e 20 74 68 69 73 2e 5f 70 6f 73 74 50 72 urn this._postPr
55d0: 65 76 69 65 77 28 74 68 69 73 2e 66 69 6c 65 43 eview(this.fileC
55e0: 6f 6e 74 65 6e 74 28 29 2c 20 75 70 64 61 74 65 ontent(), update
55f0: 56 69 65 77 29 3b 0a 20 20 7d 3b 0a 0a 20 20 2f View);. };.. /
5600: 2a 2a 0a 20 20 20 20 20 43 61 6c 6c 62 61 63 6b **. Callback
5610: 20 66 6f 72 20 75 73 65 20 77 69 74 68 20 46 2e for use with F.
5620: 63 6f 6e 6e 65 63 74 50 61 67 65 50 72 65 76 69 connectPagePrevi
5630: 65 77 65 72 73 28 29 0a 20 20 2a 2f 0a 20 20 50 ewers(). */. P
5640: 2e 5f 70 6f 73 74 50 72 65 76 69 65 77 20 3d 20 ._postPreview =
5650: 66 75 6e 63 74 69 6f 6e 28 63 6f 6e 74 65 6e 74 function(content
5660: 2c 63 61 6c 6c 62 61 63 6b 29 7b 0a 20 20 20 20 ,callback){.
5670: 69 66 28 21 61 66 66 69 72 6d 48 61 73 46 69 6c if(!affirmHasFil
5680: 65 28 29 29 20 72 65 74 75 72 6e 20 74 68 69 73 e()) return this
5690: 3b 0a 20 20 20 20 69 66 28 21 63 6f 6e 74 65 6e ;. if(!conten
56a0: 74 29 7b 0a 20 20 20 20 20 20 63 61 6c 6c 62 61 t){. callba
56b0: 63 6b 28 63 6f 6e 74 65 6e 74 29 3b 0a 20 20 20 ck(content);.
56c0: 20 20 20 72 65 74 75 72 6e 20 74 68 69 73 3b 0a return this;.
56d0: 20 20 20 20 7d 0a 20 20 20 20 63 6f 6e 73 74 20 }. const
56e0: 66 64 20 3d 20 6e 65 77 20 46 6f 72 6d 44 61 74 fd = new FormDat
56f0: 61 28 29 3b 0a 20 20 20 20 66 64 2e 61 70 70 65 a();. fd.appe
5700: 6e 64 28 27 72 65 6e 64 65 72 5f 6d 6f 64 65 27 nd('render_mode'
5710: 2c 74 68 69 73 2e 65 2e 73 65 6c 65 63 74 50 72 ,this.e.selectPr
5720: 65 76 69 65 77 4d 6f 64 65 2e 76 61 6c 75 65 29 eviewMode.value)
5730: 3b 0a 20 20 20 20 66 64 2e 61 70 70 65 6e 64 28 ;. fd.append(
5740: 27 66 69 6c 65 6e 61 6d 65 27 2c 74 68 69 73 2e 'filename',this.
5750: 66 69 6e 66 6f 2e 66 69 6c 65 6e 61 6d 65 29 3b finfo.filename);
5760: 0a 20 20 20 20 66 64 2e 61 70 70 65 6e 64 28 27 . fd.append('
5770: 6c 6e 27 2c 45 28 27 5b 6e 61 6d 65 3d 70 72 65 ln',E('[name=pre
5780: 76 69 65 77 5f 6c 6e 5d 27 29 2e 63 68 65 63 6b view_ln]').check
5790: 65 64 20 3f 20 31 20 3a 20 30 29 3b 0a 20 20 20 ed ? 1 : 0);.
57a0: 20 66 64 2e 61 70 70 65 6e 64 28 27 69 66 72 61 fd.append('ifra
57b0: 6d 65 5f 68 65 69 67 68 74 27 2c 20 45 28 27 5b me_height', E('[
57c0: 6e 61 6d 65 3d 70 72 65 76 69 65 77 5f 68 74 6d name=preview_htm
57d0: 6c 5f 65 6d 73 5d 27 29 2e 76 61 6c 75 65 29 3b l_ems]').value);
57e0: 0a 20 20 20 20 66 64 2e 61 70 70 65 6e 64 28 27 . fd.append('
57f0: 63 6f 6e 74 65 6e 74 27 2c 63 6f 6e 74 65 6e 74 content',content
5800: 20 7c 7c 20 27 27 29 3b 0a 20 20 20 20 46 2e 6d || '');. F.m
5810: 65 73 73 61 67 65 28 0a 20 20 20 20 20 20 22 46 essage(. "F
5820: 65 74 63 68 69 6e 67 20 70 72 65 76 69 65 77 2e etching preview.
5830: 2e 2e 22 0a 20 20 20 20 29 2e 66 65 74 63 68 28 ..". ).fetch(
5840: 27 66 69 6c 65 65 64 69 74 27 2c 7b 0a 20 20 20 'fileedit',{.
5850: 20 20 20 75 72 6c 50 61 72 61 6d 73 3a 20 7b 61 urlParams: {a
5860: 6a 61 78 3a 20 27 70 72 65 76 69 65 77 27 7d 2c jax: 'preview'},
5870: 0a 20 20 20 20 20 20 70 61 79 6c 6f 61 64 3a 20 . payload:
5880: 66 64 2c 0a 20 20 20 20 20 20 72 65 73 70 6f 6e fd,. respon
5890: 73 65 48 65 61 64 65 72 73 3a 20 27 78 2d 66 69 seHeaders: 'x-fi
58a0: 6c 65 65 64 69 74 2d 72 65 6e 64 65 72 2d 6d 6f leedit-render-mo
58b0: 64 65 27 2c 0a 20 20 20 20 20 20 6f 6e 6c 6f 61 de',. onloa
58c0: 64 3a 20 28 72 2c 68 65 61 64 65 72 29 3d 3e 7b d: (r,header)=>{
58d0: 0a 20 20 20 20 20 20 20 20 50 2e 73 65 6c 65 63 . P.selec
58e0: 74 50 72 65 76 69 65 77 4d 6f 64 65 28 50 2e 70 tPreviewMode(P.p
58f0: 72 65 76 69 65 77 4d 6f 64 65 73 5b 68 65 61 64 reviewModes[head
5900: 65 72 5d 29 3b 0a 20 20 20 20 20 20 20 20 69 66 er]);. if
5910: 28 27 77 69 6b 69 27 3d 3d 3d 68 65 61 64 65 72 ('wiki'===header
5920: 29 20 50 2e 62 61 73 65 48 72 65 66 46 6f 72 46 ) P.baseHrefForF
5930: 69 6c 65 28 29 3b 0a 20 20 20 20 20 20 20 20 65 ile();. e
5940: 6c 73 65 20 50 2e 62 61 73 65 48 72 65 66 52 65 lse P.baseHrefRe
5950: 73 74 6f 72 65 28 29 3b 0a 20 20 20 20 20 20 20 store();.
5960: 20 63 61 6c 6c 62 61 63 6b 28 72 29 3b 0a 20 20 callback(r);.
5970: 20 20 20 20 20 20 46 2e 6d 65 73 73 61 67 65 28 F.message(
5980: 27 55 70 64 61 74 65 64 20 70 72 65 76 69 65 77 'Updated preview
5990: 2e 27 29 3b 0a 20 20 20 20 20 20 20 20 50 2e 64 .');. P.d
59a0: 69 73 70 61 74 63 68 45 76 65 6e 74 28 27 66 69 ispatchEvent('fi
59b0: 6c 65 65 64 69 74 2d 70 72 65 76 69 65 77 2d 75 leedit-preview-u
59c0: 70 64 61 74 65 64 27 2c 7b 0a 20 20 20 20 20 20 pdated',{.
59d0: 20 20 20 20 70 72 65 76 69 65 77 4d 6f 64 65 3a previewMode:
59e0: 20 50 2e 70 72 65 76 69 65 77 4d 6f 64 65 73 2e P.previewModes.
59f0: 63 75 72 72 65 6e 74 2c 0a 20 20 20 20 20 20 20 current,.
5a00: 20 20 20 6d 69 6d 65 74 79 70 65 3a 20 50 2e 66 mimetype: P.f
5a10: 69 6e 66 6f 2e 6d 69 6d 65 74 79 70 65 2c 0a 20 info.mimetype,.
5a20: 20 20 20 20 20 20 20 20 20 65 6c 65 6d 65 6e 74 element
5a30: 3a 20 50 2e 65 2e 70 72 65 76 69 65 77 54 61 72 : P.e.previewTar
5a40: 67 65 74 0a 20 20 20 20 20 20 20 20 7d 29 3b 0a get. });.
5a50: 20 20 20 20 20 20 7d 2c 0a 20 20 20 20 20 20 6f },. o
5a60: 6e 65 72 72 6f 72 3a 20 28 65 29 3d 3e 7b 0a 20 nerror: (e)=>{.
5a70: 20 20 20 20 20 20 20 66 6f 73 73 69 6c 2e 66 65 fossil.fe
5a80: 74 63 68 2e 6f 6e 65 72 72 6f 72 28 65 29 3b 0a tch.onerror(e);.
5a90: 20 20 20 20 20 20 20 20 63 61 6c 6c 62 61 63 6b callback
5aa0: 28 22 45 72 72 6f 72 20 66 65 74 63 68 69 6e 67 ("Error fetching
5ab0: 20 70 72 65 76 69 65 77 3a 20 22 2b 65 29 3b 0a preview: "+e);.
5ac0: 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 29 3b 0a }. });.
5ad0: 20 20 20 20 72 65 74 75 72 6e 20 74 68 69 73 3b return this;
5ae0: 0a 20 20 7d 3b 0a 0a 20 20 2f 2a 2a 0a 20 20 20 . };.. /**.
5af0: 20 20 46 65 74 63 68 65 73 20 74 68 65 20 63 6f Fetches the co
5b00: 6e 74 65 6e 74 20 64 69 66 66 20 62 61 73 65 64 ntent diff based
5b10: 20 6f 6e 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 on the contents
5b20: 20 61 6e 64 20 73 65 74 74 69 6e 67 73 20 6f 66 and settings of
5b30: 0a 20 20 20 20 20 74 68 69 73 20 70 61 67 65 27 . this page'
5b40: 73 20 69 6e 70 75 74 20 66 69 65 6c 64 73 2c 20 s input fields,
5b50: 61 6e 64 20 75 70 64 61 74 65 73 20 74 68 65 20 and updates the
5b60: 55 49 20 77 69 74 68 20 74 68 65 20 64 69 66 66 UI with the diff
5b70: 20 76 69 65 77 2e 0a 0a 20 20 20 20 20 52 65 74 view... Ret
5b80: 75 72 6e 73 20 74 68 69 73 20 6f 62 6a 65 63 74 urns this object
5b90: 2c 20 6e 6f 74 69 6e 67 20 74 68 61 74 20 74 68 , noting that th
5ba0: 65 20 6f 70 65 72 61 74 69 6f 6e 20 69 73 20 61 e operation is a
5bb0: 73 79 6e 63 2e 0a 20 20 2a 2f 0a 20 20 50 2e 64 sync.. */. P.d
5bc0: 69 66 66 20 3d 20 66 75 6e 63 74 69 6f 6e 20 66 iff = function f
5bd0: 28 73 62 73 29 7b 0a 20 20 20 20 69 66 28 21 61 (sbs){. if(!a
5be0: 66 66 69 72 6d 48 61 73 46 69 6c 65 28 29 29 20 ffirmHasFile())
5bf0: 72 65 74 75 72 6e 20 74 68 69 73 3b 0a 20 20 20 return this;.
5c00: 20 63 6f 6e 73 74 20 63 6f 6e 74 65 6e 74 20 3d const content =
5c10: 20 74 68 69 73 2e 66 69 6c 65 43 6f 6e 74 65 6e this.fileConten
5c20: 74 28 29 2c 0a 20 20 20 20 20 20 20 20 20 20 73 t(),. s
5c30: 65 6c 66 20 3d 20 74 68 69 73 2c 0a 20 20 20 20 elf = this,.
5c40: 20 20 20 20 20 20 74 61 72 67 65 74 20 3d 20 74 target = t
5c50: 68 69 73 2e 65 2e 64 69 66 66 54 61 72 67 65 74 his.e.diffTarget
5c60: 3b 0a 20 20 20 20 63 6f 6e 73 74 20 66 64 20 3d ;. const fd =
5c70: 20 6e 65 77 20 46 6f 72 6d 44 61 74 61 28 29 3b new FormData();
5c80: 0a 20 20 20 20 66 64 2e 61 70 70 65 6e 64 28 27 . fd.append('
5c90: 66 69 6c 65 6e 61 6d 65 27 2c 74 68 69 73 2e 66 filename',this.f
5ca0: 69 6e 66 6f 2e 66 69 6c 65 6e 61 6d 65 29 3b 0a info.filename);.
5cb0: 20 20 20 20 66 64 2e 61 70 70 65 6e 64 28 27 63 fd.append('c
5cc0: 68 65 63 6b 69 6e 27 2c 20 74 68 69 73 2e 66 69 heckin', this.fi
5cd0: 6e 66 6f 2e 63 68 65 63 6b 69 6e 29 3b 0a 20 20 nfo.checkin);.
5ce0: 20 20 66 64 2e 61 70 70 65 6e 64 28 27 73 62 73 fd.append('sbs
5cf0: 27 2c 20 73 62 73 20 3f 20 31 20 3a 20 30 29 3b ', sbs ? 1 : 0);
5d00: 0a 20 20 20 20 66 64 2e 61 70 70 65 6e 64 28 27 . fd.append('
5d10: 63 6f 6e 74 65 6e 74 27 2c 63 6f 6e 74 65 6e 74 content',content
5d20: 29 3b 0a 20 20 20 20 69 66 28 74 68 69 73 2e 65 );. if(this.e
5d30: 2e 73 65 6c 65 63 74 44 69 66 66 57 53 29 20 66 .selectDiffWS) f
5d40: 64 2e 61 70 70 65 6e 64 28 27 77 73 27 2c 74 68 d.append('ws',th
5d50: 69 73 2e 65 2e 73 65 6c 65 63 74 44 69 66 66 57 is.e.selectDiffW
5d60: 53 2e 76 61 6c 75 65 29 3b 0a 20 20 20 20 46 2e S.value);. F.
5d70: 6d 65 73 73 61 67 65 28 0a 20 20 20 20 20 20 22 message(. "
5d80: 46 65 74 63 68 69 6e 67 20 64 69 66 66 2e 2e 2e Fetching diff...
5d90: 22 0a 20 20 20 20 29 2e 66 65 74 63 68 28 27 66 ". ).fetch('f
5da0: 69 6c 65 65 64 69 74 27 2c 7b 0a 20 20 20 20 20 ileedit',{.
5db0: 20 75 72 6c 50 61 72 61 6d 73 3a 20 7b 61 6a 61 urlParams: {aja
5dc0: 78 3a 20 27 64 69 66 66 27 7d 2c 0a 20 20 20 20 x: 'diff'},.
5dd0: 20 20 70 61 79 6c 6f 61 64 3a 20 66 64 2c 0a 20 payload: fd,.
5de0: 20 20 20 20 20 6f 6e 6c 6f 61 64 3a 20 66 75 6e onload: fun
5df0: 63 74 69 6f 6e 28 63 29 7b 0a 20 20 20 20 20 20 ction(c){.
5e00: 20 20 74 61 72 67 65 74 2e 69 6e 6e 65 72 48 54 target.innerHT
5e10: 4d 4c 20 3d 20 5b 0a 20 20 20 20 20 20 20 20 20 ML = [.
5e20: 20 22 3c 64 69 76 3e 44 69 66 66 20 3c 63 6f 64 "<div>Diff <cod
5e30: 65 3e 5b 22 2c 0a 20 20 20 20 20 20 20 20 20 20 e>[",.
5e40: 73 65 6c 66 2e 66 69 6e 66 6f 2e 63 68 65 63 6b self.finfo.check
5e50: 69 6e 2c 0a 20 20 20 20 20 20 20 20 20 20 22 5d in,. "]
5e60: 3c 2f 63 6f 64 65 3e 20 26 72 61 72 72 3b 20 4c </code> → L
5e70: 6f 63 61 6c 20 45 64 69 74 73 3c 2f 64 69 76 3e ocal Edits</div>
5e80: 22 2c 0a 20 20 20 20 20 20 20 20 20 20 63 7c 7c ",. c||
5e90: 27 4e 6f 20 63 68 61 6e 67 65 73 2e 27 0a 20 20 'No changes.'.
5ea0: 20 20 20 20 20 20 5d 2e 6a 6f 69 6e 28 27 27 29 ].join('')
5eb0: 3b 0a 20 20 20 20 20 20 20 20 69 66 28 73 62 73 ;. if(sbs
5ec0: 29 20 50 2e 74 77 65 61 6b 53 62 73 44 69 66 66 ) P.tweakSbsDiff
5ed0: 73 28 29 3b 0a 20 20 20 20 20 20 20 20 46 2e 6d s();. F.m
5ee0: 65 73 73 61 67 65 28 27 55 70 64 61 74 65 64 20 essage('Updated
5ef0: 64 69 66 66 2e 27 29 3b 0a 20 20 20 20 20 20 20 diff.');.
5f00: 20 73 65 6c 66 2e 74 61 62 73 2e 73 77 69 74 63 self.tabs.switc
5f10: 68 54 6f 54 61 62 28 73 65 6c 66 2e 65 2e 74 61 hToTab(self.e.ta
5f20: 62 73 2e 64 69 66 66 29 3b 0a 20 20 20 20 20 20 bs.diff);.
5f30: 7d 0a 20 20 20 20 7d 29 3b 0a 20 20 20 20 72 65 }. });. re
5f40: 74 75 72 6e 20 74 68 69 73 3b 0a 20 20 7d 3b 0a turn this;. };.
5f50: 0a 20 20 2f 2a 2a 0a 20 20 20 20 20 50 65 72 66 . /**. Perf
5f60: 6f 72 6d 73 20 61 6e 20 61 73 79 6e 63 20 63 6f orms an async co
5f70: 6d 6d 69 74 20 62 61 73 65 64 20 6f 6e 20 74 68 mmit based on th
5f80: 65 20 66 6f 72 6d 20 63 6f 6e 74 65 6e 74 73 20 e form contents
5f90: 61 6e 64 20 75 70 64 61 74 65 73 0a 20 20 20 20 and updates.
5fa0: 20 74 68 65 20 55 49 2e 0a 0a 20 20 20 20 20 52 the UI... R
5fb0: 65 74 75 72 6e 73 20 74 68 69 73 20 6f 62 6a 65 eturns this obje
5fc0: 63 74 2e 0a 20 20 2a 2f 0a 20 20 50 2e 63 6f 6d ct.. */. P.com
5fd0: 6d 69 74 20 3d 20 66 75 6e 63 74 69 6f 6e 20 66 mit = function f
5fe0: 28 29 7b 0a 20 20 20 20 69 66 28 21 61 66 66 69 (){. if(!affi
5ff0: 72 6d 48 61 73 46 69 6c 65 28 29 29 20 72 65 74 rmHasFile()) ret
6000: 75 72 6e 20 74 68 69 73 3b 0a 20 20 20 20 63 6f urn this;. co
6010: 6e 73 74 20 73 65 6c 66 20 3d 20 74 68 69 73 3b nst self = this;
6020: 0a 20 20 20 20 63 6f 6e 73 74 20 63 6f 6e 74 65 . const conte
6030: 6e 74 20 3d 20 74 68 69 73 2e 66 69 6c 65 43 6f nt = this.fileCo
6040: 6e 74 65 6e 74 28 29 2c 0a 20 20 20 20 20 20 20 ntent(),.
6050: 20 20 20 74 61 72 67 65 74 20 3d 20 64 6f 63 75 target = docu
6060: 6d 65 6e 74 2e 71 75 65 72 79 53 65 6c 65 63 74 ment.querySelect
6070: 6f 72 28 27 23 66 69 6c 65 65 64 69 74 2d 6d 61 or('#fileedit-ma
6080: 6e 69 66 65 73 74 27 29 2c 0a 20 20 20 20 20 20 nifest'),.
6090: 20 20 20 20 63 62 44 72 79 52 75 6e 20 3d 20 45 cbDryRun = E
60a0: 28 27 5b 6e 61 6d 65 3d 64 72 79 5f 72 75 6e 5d ('[name=dry_run]
60b0: 27 29 2c 0a 20 20 20 20 20 20 20 20 20 20 69 73 '),. is
60c0: 44 72 79 52 75 6e 20 3d 20 63 62 44 72 79 52 75 DryRun = cbDryRu
60d0: 6e 2e 63 68 65 63 6b 65 64 2c 0a 20 20 20 20 20 n.checked,.
60e0: 20 20 20 20 20 66 69 6c 65 6e 61 6d 65 20 3d 20 filename =
60f0: 74 68 69 73 2e 66 69 6e 66 6f 2e 66 69 6c 65 6e this.finfo.filen
6100: 61 6d 65 3b 0a 20 20 20 20 69 66 28 21 66 2e 6f ame;. if(!f.o
6110: 6e 6c 6f 61 64 29 7b 0a 20 20 20 20 20 20 66 2e nload){. f.
6120: 6f 6e 6c 6f 61 64 20 3d 20 66 75 6e 63 74 69 6f onload = functio
6130: 6e 28 63 29 7b 0a 20 20 20 20 20 20 20 20 63 6f n(c){. co
6140: 6e 73 74 20 6f 6c 64 46 69 6e 66 6f 20 3d 20 4a nst oldFinfo = J
6150: 53 4f 4e 2e 70 61 72 73 65 28 4a 53 4f 4e 2e 73 SON.parse(JSON.s
6160: 74 72 69 6e 67 69 66 79 28 73 65 6c 66 2e 66 69 tringify(self.fi
6170: 6e 66 6f 29 29 0a 20 20 20 20 20 20 20 20 74 61 nfo)). ta
6180: 72 67 65 74 2e 69 6e 6e 65 72 48 54 4d 4c 20 3d rget.innerHTML =
6190: 20 5b 0a 20 20 20 20 20 20 20 20 20 20 22 3c 68 [. "<h
61a0: 33 3e 4d 61 6e 69 66 65 73 74 22 2c 0a 20 20 20 3>Manifest",.
61b0: 20 20 20 20 20 20 20 28 63 2e 64 72 79 52 75 6e (c.dryRun
61c0: 3f 22 20 28 64 72 79 20 72 75 6e 29 22 3a 22 22 ?" (dry run)":""
61d0: 29 2c 0a 20 20 20 20 20 20 20 20 20 20 22 3a 20 ),. ":
61e0: 22 2c 20 46 2e 68 61 73 68 44 69 67 69 74 73 28 ", F.hashDigits(
61f0: 63 2e 63 68 65 63 6b 69 6e 29 2c 22 3c 2f 68 33 c.checkin),"</h3
6200: 3e 22 2c 0a 20 20 20 20 20 20 20 20 20 20 22 3c >",. "<
6210: 63 6f 64 65 20 63 6c 61 73 73 3d 27 66 69 6c 65 code class='file
6220: 65 64 69 74 2d 6d 61 6e 69 66 65 73 74 27 3e 22 edit-manifest'>"
6230: 2c 0a 20 20 20 20 20 20 20 20 20 20 63 2e 6d 61 ,. c.ma
6240: 6e 69 66 65 73 74 2c 0a 20 20 20 20 20 20 20 20 nifest,.
6250: 20 20 22 3c 2f 63 6f 64 65 3e 3c 2f 70 72 65 3e "</code></pre>
6260: 22 0a 20 20 20 20 20 20 20 20 5d 2e 6a 6f 69 6e ". ].join
6270: 28 27 27 29 3b 0a 20 20 20 20 20 20 20 20 63 6f ('');. co
6280: 6e 73 74 20 6d 73 67 20 3d 20 5b 0a 20 20 20 20 nst msg = [.
6290: 20 20 20 20 20 20 27 43 6f 6d 6d 69 74 74 65 64 'Committed
62a0: 27 2c 0a 20 20 20 20 20 20 20 20 20 20 63 2e 64 ',. c.d
62b0: 72 79 52 75 6e 20 3f 20 27 28 64 72 79 20 72 75 ryRun ? '(dry ru
62c0: 6e 29 27 20 3a 20 27 27 2c 0a 20 20 20 20 20 20 n)' : '',.
62d0: 20 20 20 20 27 5b 27 2c 20 46 2e 68 61 73 68 44 '[', F.hashD
62e0: 69 67 69 74 73 28 63 2e 63 68 65 63 6b 69 6e 29 igits(c.checkin)
62f0: 20 2c 27 5d 2e 27 0a 20 20 20 20 20 20 20 20 5d ,'].'. ]
6300: 3b 0a 20 20 20 20 20 20 20 20 69 66 28 21 63 2e ;. if(!c.
6310: 64 72 79 52 75 6e 29 7b 0a 20 20 20 20 20 20 20 dryRun){.
6320: 20 20 20 69 66 28 30 29 7b 0a 20 20 20 20 20 20 if(0){.
6330: 20 20 20 20 20 20 6d 73 67 2e 70 75 73 68 28 27 msg.push('
6340: 52 65 2d 61 63 74 69 76 61 74 69 6e 67 20 64 72 Re-activating dr
6350: 79 2d 72 75 6e 20 6d 6f 64 65 2e 27 29 3b 0a 20 y-run mode.');.
6360: 20 20 20 20 20 20 20 20 20 20 20 63 62 44 72 79 cbDry
6370: 52 75 6e 2e 63 68 65 63 6b 65 64 20 3d 20 74 72 Run.checked = tr
6380: 75 65 3b 0a 20 20 20 20 20 20 20 20 20 20 7d 0a ue;. }.
6390: 20 20 20 20 20 20 20 20 20 20 73 65 6c 66 2e 75 self.u
63a0: 6e 73 74 61 73 68 43 6f 6e 74 65 6e 74 28 6f 6c nstashContent(ol
63b0: 64 46 69 6e 66 6f 29 3b 0a 20 20 20 20 20 20 20 dFinfo);.
63c0: 20 20 20 64 65 6c 65 74 65 20 63 2e 6d 61 6e 69 delete c.mani
63d0: 66 65 73 74 3b 0a 20 20 20 20 20 20 20 20 20 20 fest;.
63e0: 73 65 6c 66 2e 66 69 6e 66 6f 20 3d 20 63 3b 0a self.finfo = c;.
63f0: 20 20 20 20 20 20 20 20 20 20 73 65 6c 66 2e 65 self.e
6400: 2e 74 61 43 6f 6d 6d 65 6e 74 2e 76 61 6c 75 65 .taComment.value
6410: 20 3d 20 27 27 3b 0a 20 20 20 20 20 20 20 20 20 = '';.
6420: 20 73 65 6c 66 2e 75 70 64 61 74 65 56 65 72 73 self.updateVers
6430: 69 6f 6e 28 29 3b 0a 20 20 20 20 20 20 20 20 20 ion();.
6440: 20 73 65 6c 66 2e 66 69 6c 65 53 65 6c 65 63 74 self.fileSelect
6450: 6f 72 2e 6c 6f 61 64 4c 65 61 76 65 73 28 29 3b or.loadLeaves();
6460: 0a 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 . }.
6470: 20 20 20 46 2e 6d 65 73 73 61 67 65 2e 61 70 70 F.message.app
6480: 6c 79 28 46 2c 20 6d 73 67 29 3b 0a 20 20 20 20 ly(F, msg);.
6490: 20 20 20 20 73 65 6c 66 2e 74 61 62 73 2e 73 77 self.tabs.sw
64a0: 69 74 63 68 54 6f 54 61 62 28 73 65 6c 66 2e 65 itchToTab(self.e
64b0: 2e 74 61 62 73 2e 63 6f 6d 6d 69 74 29 3b 0a 20 .tabs.commit);.
64c0: 20 20 20 20 20 7d 3b 0a 20 20 20 20 7d 0a 20 20 };. }.
64d0: 20 20 63 6f 6e 73 74 20 66 64 20 3d 20 6e 65 77 const fd = new
64e0: 20 46 6f 72 6d 44 61 74 61 28 29 3b 0a 20 20 20 FormData();.
64f0: 20 66 64 2e 61 70 70 65 6e 64 28 27 66 69 6c 65 fd.append('file
6500: 6e 61 6d 65 27 2c 66 69 6c 65 6e 61 6d 65 29 3b name',filename);
6510: 0a 20 20 20 20 66 64 2e 61 70 70 65 6e 64 28 27 . fd.append('
6520: 63 68 65 63 6b 69 6e 27 2c 20 74 68 69 73 2e 66 checkin', this.f
6530: 69 6e 66 6f 2e 63 68 65 63 6b 69 6e 29 3b 0a 20 info.checkin);.
6540: 20 20 20 66 64 2e 61 70 70 65 6e 64 28 27 63 6f fd.append('co
6550: 6e 74 65 6e 74 27 2c 63 6f 6e 74 65 6e 74 29 3b ntent',content);
6560: 0a 20 20 20 20 66 64 2e 61 70 70 65 6e 64 28 27 . fd.append('
6570: 64 72 79 5f 72 75 6e 27 2c 69 73 44 72 79 52 75 dry_run',isDryRu
6580: 6e 20 3f 20 31 20 3a 20 30 29 3b 0a 20 20 20 20 n ? 1 : 0);.
6590: 66 64 2e 61 70 70 65 6e 64 28 27 65 6f 6c 27 2c fd.append('eol',
65a0: 20 74 68 69 73 2e 65 2e 73 65 6c 65 63 74 45 6f this.e.selectEo
65b0: 6c 2e 76 61 6c 75 65 20 7c 7c 20 30 29 3b 0a 20 l.value || 0);.
65c0: 20 20 20 2f 2a 20 54 65 78 74 20 66 69 65 6c 64 /* Text field
65d0: 73 20 6f 72 20 73 65 6c 65 63 74 20 6c 69 73 74 s or select list
65e0: 73 2e 2e 2e 20 2a 2f 0a 20 20 20 20 66 64 2e 61 s... */. fd.a
65f0: 70 70 65 6e 64 28 27 63 6f 6d 6d 65 6e 74 27 2c ppend('comment',
6600: 20 74 68 69 73 2e 65 2e 74 61 43 6f 6d 6d 65 6e this.e.taCommen
6610: 74 2e 76 61 6c 75 65 29 3b 0a 20 20 20 20 69 66 t.value);. if
6620: 28 30 29 7b 0a 20 20 20 20 20 20 2f 2f 20 43 6f (0){. // Co
6630: 6d 6d 65 6e 74 20 6d 69 6d 65 74 79 70 65 20 69 mment mimetype i
6640: 73 20 63 75 72 72 65 6e 74 6c 79 20 6e 6f 74 20 s currently not
6650: 73 75 70 70 6f 72 74 65 64 20 62 79 20 74 68 65 supported by the
6660: 20 55 49 2e 2e 2e 0a 20 20 20 20 20 20 5b 27 63 UI.... ['c
6670: 6f 6d 6d 65 6e 74 5f 6d 69 6d 65 74 79 70 65 27 omment_mimetype'
6680: 0a 20 20 20 20 20 20 5d 2e 66 6f 72 45 61 63 68 . ].forEach
6690: 28 66 75 6e 63 74 69 6f 6e 28 6e 61 6d 65 29 7b (function(name){
66a0: 0a 20 20 20 20 20 20 20 20 76 61 72 20 65 20 3d . var e =
66b0: 20 45 28 27 5b 6e 61 6d 65 3d 27 2b 6e 61 6d 65 E('[name='+name
66c0: 2b 27 5d 27 29 3b 0a 20 20 20 20 20 20 20 20 69 +']');. i
66d0: 66 28 65 29 20 66 64 2e 61 70 70 65 6e 64 28 6e f(e) fd.append(n
66e0: 61 6d 65 2c 65 2e 76 61 6c 75 65 29 3b 0a 20 20 ame,e.value);.
66f0: 20 20 20 20 7d 29 3b 0a 20 20 20 20 7d 0a 20 20 });. }.
6700: 20 20 2f 2a 20 43 68 65 63 6b 62 6f 78 65 73 3a /* Checkboxes:
6710: 20 2a 2f 0a 20 20 20 20 5b 27 61 6c 6c 6f 77 5f */. ['allow_
6720: 66 6f 72 6b 27 2c 0a 20 20 20 20 20 27 61 6c 6c fork',. 'all
6730: 6f 77 5f 6f 6c 64 65 72 27 2c 0a 20 20 20 20 20 ow_older',.
6740: 27 65 78 65 63 5f 62 69 74 27 2c 0a 20 20 20 20 'exec_bit',.
6750: 20 27 61 6c 6c 6f 77 5f 6d 65 72 67 65 5f 63 6f 'allow_merge_co
6760: 6e 66 6c 69 63 74 27 2c 0a 20 20 20 20 20 27 70 nflict',. 'p
6770: 72 65 66 65 72 5f 64 65 6c 74 61 27 0a 20 20 20 refer_delta'.
6780: 20 5d 2e 66 6f 72 45 61 63 68 28 66 75 6e 63 74 ].forEach(funct
6790: 69 6f 6e 28 6e 61 6d 65 29 7b 0a 20 20 20 20 20 ion(name){.
67a0: 20 76 61 72 20 65 20 3d 20 45 28 27 5b 6e 61 6d var e = E('[nam
67b0: 65 3d 27 2b 6e 61 6d 65 2b 27 5d 27 29 3b 0a 20 e='+name+']');.
67c0: 20 20 20 20 20 69 66 28 65 29 7b 0a 20 20 20 20 if(e){.
67d0: 20 20 20 20 66 64 2e 61 70 70 65 6e 64 28 6e 61 fd.append(na
67e0: 6d 65 2c 20 65 2e 63 68 65 63 6b 65 64 20 3f 20 me, e.checked ?
67f0: 31 20 3a 20 30 29 3b 0a 20 20 20 20 20 20 7d 65 1 : 0);. }e
6800: 6c 73 65 7b 0a 20 20 20 20 20 20 20 20 63 6f 6e lse{. con
6810: 73 6f 6c 65 2e 65 72 72 6f 72 28 22 4d 69 73 73 sole.error("Miss
6820: 69 6e 67 20 63 68 65 63 6b 62 6f 78 3f 20 6e 61 ing checkbox? na
6830: 6d 65 20 3d 22 2c 6e 61 6d 65 29 3b 0a 20 20 20 me =",name);.
6840: 20 20 20 7d 0a 20 20 20 20 7d 29 3b 0a 20 20 20 }. });.
6850: 20 46 2e 6d 65 73 73 61 67 65 28 0a 20 20 20 20 F.message(.
6860: 20 20 22 43 68 65 63 6b 69 6e 67 20 69 6e 2e 2e "Checking in..
6870: 2e 22 0a 20 20 20 20 29 2e 66 65 74 63 68 28 27 .". ).fetch('
6880: 66 69 6c 65 65 64 69 74 27 2c 7b 0a 20 20 20 20 fileedit',{.
6890: 20 20 75 72 6c 50 61 72 61 6d 73 3a 20 7b 61 6a urlParams: {aj
68a0: 61 78 3a 20 27 63 6f 6d 6d 69 74 27 7d 2c 0a 20 ax: 'commit'},.
68b0: 20 20 20 20 20 70 61 79 6c 6f 61 64 3a 20 66 64 payload: fd
68c0: 2c 0a 20 20 20 20 20 20 72 65 73 70 6f 6e 73 65 ,. response
68d0: 54 79 70 65 3a 20 27 6a 73 6f 6e 27 2c 0a 20 20 Type: 'json',.
68e0: 20 20 20 20 6f 6e 6c 6f 61 64 3a 20 66 2e 6f 6e onload: f.on
68f0: 6c 6f 61 64 0a 20 20 20 20 7d 29 3b 0a 20 20 20 load. });.
6900: 20 72 65 74 75 72 6e 20 74 68 69 73 3b 0a 20 20 return this;.
6910: 7d 3b 0a 0a 20 20 2f 2a 2a 0a 20 20 20 20 20 24 };.. /**. $
6920: 73 74 61 73 68 20 69 73 20 61 6e 20 69 6e 74 65 stash is an inte
6930: 72 6e 61 6c 2d 75 73 65 2d 6f 6e 6c 79 20 6f 62 rnal-use-only ob
6940: 6a 65 63 74 20 66 6f 72 20 6d 61 6e 61 67 69 6e ject for managin
6950: 67 20 22 73 74 61 73 68 65 64 22 0a 20 20 20 20 g "stashed".
6960: 20 6c 6f 63 61 6c 20 65 64 69 74 73 2c 20 74 6f local edits, to
6970: 20 68 65 6c 70 20 61 76 6f 69 64 20 74 68 61 74 help avoid that
6980: 20 75 73 65 72 73 20 61 63 63 69 64 65 6e 74 61 users accidenta
6990: 6c 6c 79 20 6c 6f 73 65 20 63 6f 6e 74 65 6e 74 lly lose content
69a0: 0a 20 20 20 20 20 62 79 20 73 77 69 74 63 68 69 . by switchi
69b0: 6e 67 20 74 61 62 73 20 6f 72 20 66 6f 6c 6c 6f ng tabs or follo
69c0: 77 69 6e 67 20 6c 69 6e 6b 73 20 6f 72 20 73 6f wing links or so
69d0: 6d 65 20 73 75 63 68 2e 20 54 68 65 20 62 61 73 me such. The bas
69e0: 69 63 0a 20 20 20 20 20 74 68 65 6f 72 79 20 6f ic. theory o
69f0: 66 20 6f 70 65 72 61 74 69 6f 6e 20 69 73 2e 2e f operation is..
6a00: 2e 0a 0a 20 20 20 20 20 41 6c 6c 20 22 73 74 61 ... All "sta
6a10: 73 68 65 64 22 20 73 74 61 74 65 20 69 73 20 73 shed" state is s
6a20: 74 6f 72 65 64 20 75 73 69 6e 67 20 66 6f 73 73 tored using foss
6a30: 69 6c 2e 73 74 6f 72 61 67 65 2e 0a 0a 20 20 20 il.storage...
6a40: 20 20 2d 20 57 68 65 6e 20 74 68 65 20 63 75 72 - When the cur
6a50: 72 65 6e 74 20 66 69 6c 65 20 63 6f 6e 74 65 6e rent file conten
6a60: 74 20 69 73 20 6d 6f 64 69 66 69 65 64 20 62 79 t is modified by
6a70: 20 74 68 65 20 75 73 65 72 2c 20 74 68 65 0a 20 the user, the.
6a80: 20 20 20 20 20 20 63 75 72 72 65 6e 74 20 73 74 current st
6a90: 61 74 68 65 20 6f 66 20 74 68 65 20 63 75 72 72 athe of the curr
6aa0: 65 6e 74 20 50 2e 66 69 6e 66 6f 20 61 6e 64 20 ent P.finfo and
6ab0: 69 74 73 20 74 68 65 20 63 6f 6e 74 65 6e 74 0a its the content.
6ac0: 20 20 20 20 20 20 20 69 73 20 73 74 61 73 68 65 is stashe
6ad0: 64 2e 20 46 6f 72 20 74 68 65 20 62 75 69 6c 74 d. For the built
6ae0: 2d 69 6e 20 65 64 69 74 6f 72 20 77 69 64 67 65 -in editor widge
6af0: 74 2c 20 22 63 68 61 6e 67 65 73 22 20 69 73 0a t, "changes" is.
6b00: 20 20 20 20 20 20 20 6e 6f 74 69 66 69 65 64 20 notified
6b10: 76 69 61 20 61 20 27 63 68 61 6e 67 65 27 20 65 via a 'change' e
6b20: 76 65 6e 74 2e 20 20 46 6f 72 20 61 20 63 6c 69 vent. For a cli
6b30: 65 6e 74 2d 73 69 64 65 20 63 75 73 74 6f 6d 0a ent-side custom.
6b40: 20 20 20 20 20 20 20 77 69 64 67 65 74 2c 20 74 widget, t
6b50: 68 65 20 63 6c 69 65 6e 74 20 6e 65 65 64 73 20 he client needs
6b60: 74 6f 20 63 61 6c 6c 20 50 2e 73 74 61 73 68 43 to call P.stashC
6b70: 6f 6e 74 65 6e 74 43 68 61 6e 67 65 28 29 20 77 ontentChange() w
6b80: 68 65 6e 0a 20 20 20 20 20 20 20 74 68 65 69 72 hen. their
6b90: 20 77 69 64 67 65 74 20 74 72 69 67 67 65 72 73 widget triggers
6ba0: 20 74 68 65 20 65 71 75 69 76 61 6c 65 6e 74 20 the equivalent
6bb0: 6f 66 20 61 20 27 63 68 61 6e 67 65 27 20 65 76 of a 'change' ev
6bc0: 65 6e 74 2e 0a 0a 20 20 20 20 20 2d 20 46 6f 72 ent... - For
6bd0: 20 63 65 72 74 61 69 6e 20 6e 6f 6e 2d 63 6f 6e certain non-con
6be0: 74 65 6e 74 20 75 70 64 61 74 65 73 20 28 61 73 tent updates (as
6bf0: 20 6f 66 20 74 68 69 73 20 77 72 69 74 69 6e 67 of this writing
6c00: 2c 20 6f 6e 6c 79 20 74 68 65 0a 20 20 20 20 20 , only the.
6c10: 20 20 69 73 2d 65 78 65 63 75 74 61 62 6c 65 20 is-executable
6c20: 63 68 65 63 6b 62 6f 78 29 2c 20 6f 6e 6c 79 20 checkbox), only
6c30: 74 68 65 20 50 2e 66 69 6e 66 6f 20 73 74 61 73 the P.finfo stas
6c40: 68 20 65 6e 74 72 79 20 69 73 0a 20 20 20 20 20 h entry is.
6c50: 20 20 75 70 64 61 74 65 64 2c 20 6e 6f 74 20 74 updated, not t
6c60: 68 65 20 63 6f 6e 74 65 6e 74 20 28 75 6e 6c 65 he content (unle
6c70: 73 73 20 74 68 65 20 63 6f 6e 74 65 6e 74 20 68 ss the content h
6c80: 61 73 20 6e 6f 74 20 79 65 74 20 62 65 65 6e 0a as not yet been.
6c90: 20 20 20 20 20 20 20 73 74 61 73 68 65 64 2c 20 stashed,
6ca0: 69 6e 20 77 68 69 63 68 20 63 61 73 65 20 69 74 in which case it
6cb0: 20 69 73 20 61 6c 73 6f 20 73 74 61 73 68 65 64 is also stashed
6cc0: 20 73 6f 20 74 68 61 74 20 74 68 65 20 73 74 61 so that the sta
6cd0: 73 68 0a 20 20 20 20 20 20 20 61 6c 77 61 79 73 sh. always
6ce0: 20 68 61 73 20 6d 61 74 63 68 69 6e 67 20 70 61 has matching pa
6cf0: 69 72 73 20 6f 66 20 66 69 6e 66 6f 2f 63 6f 6e irs of finfo/con
6d00: 74 65 6e 74 29 2e 0a 0a 20 20 20 20 20 2d 20 57 tent)... - W
6d10: 68 65 6e 20 73 61 76 69 6e 67 2c 20 74 68 65 20 hen saving, the
6d20: 73 74 61 73 68 65 64 20 65 6e 74 72 79 20 66 6f stashed entry fo
6d30: 72 20 74 68 65 20 70 72 65 76 69 6f 75 73 20 76 r the previous v
6d40: 65 72 73 69 6f 6e 20 69 73 20 72 65 6d 6f 76 65 ersion is remove
6d50: 64 0a 20 20 20 20 20 20 20 66 72 6f 6d 20 74 68 d. from th
6d60: 65 20 73 74 61 73 68 2e 0a 0a 20 20 20 20 20 2d e stash... -
6d70: 20 57 68 65 6e 20 22 6c 6f 61 64 69 6e 67 22 2c When "loading",
6d80: 20 77 65 20 75 73 65 20 61 6e 79 20 73 74 61 73 we use any stas
6d90: 68 65 64 20 73 74 61 74 65 20 66 6f 72 20 74 68 hed state for th
6da0: 65 20 67 69 76 65 6e 0a 20 20 20 20 20 20 20 63 e given. c
6db0: 68 65 63 6b 69 6e 2f 66 69 6c 65 20 63 6f 6d 62 heckin/file comb
6dc0: 69 6e 61 74 69 6f 6e 2e 20 57 68 65 6e 20 66 6f ination. When fo
6dd0: 72 63 69 6e 67 20 61 20 72 65 2d 6c 6f 61 64 20 rcing a re-load
6de0: 6f 66 20 63 6f 6e 74 65 6e 74 2c 0a 20 20 20 20 of content,.
6df0: 20 20 20 61 6e 79 20 73 74 61 73 68 65 64 20 65 any stashed e
6e00: 6e 74 72 79 20 66 6f 72 20 74 68 61 74 20 63 6f ntry for that co
6e10: 6d 62 69 6e 61 74 69 6f 6e 20 69 73 20 72 65 6d mbination is rem
6e20: 6f 76 65 64 20 66 72 6f 6d 20 74 68 65 0a 20 20 oved from the.
6e30: 20 20 20 20 20 73 74 61 73 68 2e 0a 0a 20 20 20 stash...
6e40: 20 20 2d 20 45 76 65 72 79 20 74 69 6d 65 20 50 - Every time P
6e50: 2e 73 74 61 73 68 43 6f 6e 74 65 6e 74 43 68 61 .stashContentCha
6e60: 6e 67 65 28 29 20 75 70 64 61 74 65 73 20 74 68 nge() updates th
6e70: 65 20 73 74 61 73 68 2c 20 69 74 20 69 73 0a 20 e stash, it is.
6e80: 20 20 20 20 20 20 70 72 75 6e 65 64 20 74 6f 20 pruned to
6e90: 24 73 74 61 73 68 2e 70 72 75 6e 65 2e 64 65 66 $stash.prune.def
6ea0: 61 75 6c 74 4d 61 78 43 6f 75 6e 74 20 6d 6f 73 aultMaxCount mos
6eb0: 74 2d 72 65 63 65 6e 74 6c 79 2d 75 70 64 61 74 t-recently-updat
6ec0: 65 64 0a 20 20 20 20 20 20 20 65 6e 74 72 69 65 ed. entrie
6ed0: 73 2e 0a 0a 20 20 20 20 20 2d 20 54 68 69 73 20 s... - This
6ee0: 41 50 49 20 6f 66 74 65 6e 20 72 65 66 65 72 73 API often refers
6ef0: 20 74 6f 20 22 66 69 6e 66 6f 20 6f 62 6a 65 63 to "finfo objec
6f00: 74 73 2e 22 20 54 68 6f 73 65 20 61 72 65 20 6f ts." Those are o
6f10: 62 6a 65 63 74 73 0a 20 20 20 20 20 20 20 77 69 bjects. wi
6f20: 74 68 20 61 20 6d 69 6e 69 6d 75 6d 20 6f 66 20 th a minimum of
6f30: 7b 63 68 65 63 6b 69 6e 2c 66 69 6c 65 6e 61 6d {checkin,filenam
6f40: 65 7d 20 70 72 6f 70 65 72 74 69 65 73 20 28 77 e} properties (w
6f50: 68 69 63 68 20 6d 75 73 74 20 62 65 0a 20 20 20 hich must be.
6f60: 20 20 20 20 76 61 6c 69 64 29 2c 20 61 6e 64 20 valid), and
6f70: 61 20 63 6f 6d 62 69 6e 61 74 69 6f 6e 20 6f 66 a combination of
6f80: 20 74 68 6f 73 65 20 74 77 6f 20 70 72 6f 70 65 those two prope
6f90: 72 74 69 65 73 20 69 73 20 75 73 65 64 20 61 73 rties is used as
6fa0: 0a 20 20 20 20 20 20 20 62 61 73 69 73 20 66 6f . basis fo
6fb0: 72 20 74 68 65 20 73 74 61 73 68 20 6b 65 79 73 r the stash keys
6fc0: 20 66 6f 72 20 61 6e 79 20 67 69 76 65 6e 20 63 for any given c
6fd0: 68 65 63 6b 69 6e 2f 66 69 6c 65 6e 61 6d 65 0a heckin/filename.
6fe0: 20 20 20 20 20 20 20 63 6f 6d 62 69 6e 61 74 69 combinati
6ff0: 6f 6e 2e 0a 0a 20 20 20 20 20 54 68 65 20 73 74 on... The st
7000: 72 75 63 74 75 72 65 20 6f 66 20 74 68 65 20 73 ructure of the s
7010: 74 61 73 68 20 69 73 20 61 20 62 69 74 20 63 6f tash is a bit co
7020: 6e 76 6f 6c 75 74 65 64 20 66 6f 72 20 65 66 66 nvoluted for eff
7030: 69 63 69 65 6e 63 79 27 73 0a 20 20 20 20 20 73 iciency's. s
7040: 61 6b 65 3a 20 77 65 20 73 74 6f 72 65 20 61 20 ake: we store a
7050: 6d 61 70 20 6f 66 20 66 69 6c 65 20 69 6e 66 6f map of file info
7060: 20 28 66 69 6e 66 6f 29 20 6f 62 6a 65 63 74 73 (finfo) objects
7070: 20 73 65 70 61 72 61 74 65 6c 79 20 66 72 6f 6d separately from
7080: 0a 20 20 20 20 20 74 68 6f 73 65 20 66 69 6c 65 . those file
7090: 73 27 20 63 6f 6e 74 65 6e 74 73 20 62 65 63 61 s' contents beca
70a0: 75 73 65 20 6f 74 68 65 72 77 69 73 65 20 77 65 use otherwise we
70b0: 20 77 6f 75 6c 64 20 62 65 20 72 65 71 75 69 72 would be requir
70c0: 65 64 20 74 6f 0a 20 20 20 20 20 4a 53 4f 4e 69 ed to. JSONi
70d0: 7a 65 2f 64 65 2d 4a 53 4f 4e 69 7a 65 20 74 68 ze/de-JSONize th
70e0: 65 20 66 69 6c 65 20 63 6f 6e 74 65 6e 74 20 77 e file content w
70f0: 68 65 6e 20 73 74 61 73 68 69 6e 67 2f 72 65 73 hen stashing/res
7100: 74 6f 72 69 6e 67 20 69 74 2c 0a 20 20 20 20 20 toring it,.
7110: 61 6e 64 20 74 68 61 74 20 77 6f 75 6c 64 20 62 and that would b
7120: 65 20 68 6f 72 72 69 62 6c 79 20 69 6e 65 66 66 e horribly ineff
7130: 69 63 69 65 6e 74 20 28 6d 65 61 6e 69 6e 67 20 icient (meaning
7140: 22 62 61 74 74 65 72 79 2d 63 6f 6e 73 75 6d 69 "battery-consumi
7150: 6e 67 22 0a 20 20 20 20 20 6f 6e 20 6d 6f 62 69 ng". on mobi
7160: 6c 65 20 64 65 76 69 63 65 73 29 2e 0a 20 20 2a le devices).. *
7170: 2f 0a 20 20 63 6f 6e 73 74 20 24 73 74 61 73 68 /. const $stash
7180: 20 3d 20 7b 0a 20 20 20 20 6b 65 79 73 3a 20 7b = {. keys: {
7190: 0a 20 20 20 20 20 20 69 6e 64 65 78 3a 20 46 2e . index: F.
71a0: 70 61 67 65 2e 6e 61 6d 65 2b 27 3a 69 6e 64 65 page.name+':inde
71b0: 78 27 0a 20 20 20 20 7d 2c 0a 20 20 20 20 2f 2a x'. },. /*
71c0: 2a 0a 20 20 20 20 20 20 20 69 6e 64 65 78 3a 20 *. index:
71d0: 7b 0a 20 20 20 20 20 20 20 22 43 48 45 43 4b 49 {. "CHECKI
71e0: 4e 5f 48 41 53 48 3a 46 49 4c 45 4e 41 4d 45 22 N_HASH:FILENAME"
71f0: 3a 20 7b 66 69 6c 65 20 69 6e 66 6f 20 77 2f 6f : {file info w/o
7200: 20 63 6f 6e 74 65 6e 74 7d 0a 20 20 20 20 20 20 content}.
7210: 20 2e 2e 2e 0a 20 20 20 20 20 20 20 7d 0a 0a 20 .... }..
7220: 20 20 20 20 20 20 49 6e 20 46 2e 73 74 6f 72 61 In F.stora
7230: 67 65 20 77 65 2e 2e 2e 0a 0a 20 20 20 20 20 20 ge we.....
7240: 20 2d 20 53 74 6f 72 65 20 74 68 69 73 2e 69 6e - Store this.in
7250: 64 65 78 20 75 6e 64 65 72 20 74 68 65 20 6b 65 dex under the ke
7260: 79 20 74 68 69 73 2e 6b 65 79 73 2e 69 6e 64 65 y this.keys.inde
7270: 78 2e 0a 0a 20 20 20 20 20 20 20 2d 20 53 74 6f x... - Sto
7280: 72 65 20 65 61 63 68 20 66 69 6c 65 27 73 20 63 re each file's c
7290: 6f 6e 74 65 6e 74 20 75 6e 64 65 72 20 74 68 65 ontent under the
72a0: 20 6b 65 79 0a 20 20 20 20 20 20 20 28 50 2e 6e key. (P.n
72b0: 61 6d 65 2b 27 2f 43 48 45 43 4b 49 4e 5f 48 41 ame+'/CHECKIN_HA
72c0: 53 48 3a 46 49 4c 45 4e 41 4d 45 27 29 2e 20 54 SH:FILENAME'). T
72d0: 68 65 73 65 20 61 72 65 20 73 74 6f 72 65 64 20 hese are stored
72e0: 73 65 70 61 72 61 74 65 6c 79 0a 20 20 20 20 20 separately.
72f0: 20 20 66 72 6f 6d 20 74 68 65 20 69 6e 64 65 78 from the index
7300: 20 65 6e 74 72 69 65 73 20 74 6f 20 61 76 6f 69 entries to avoi
7310: 64 20 68 61 76 69 6e 67 20 74 6f 20 4a 53 4f 4e d having to JSON
7320: 69 7a 65 2f 64 65 2d 4a 53 4f 4e 69 7a 65 0a 20 ize/de-JSONize.
7330: 20 20 20 20 20 20 74 68 65 20 63 6f 6e 74 65 6e the conten
7340: 74 2e 20 54 68 65 20 61 73 73 75 6d 70 74 69 6f t. The assumptio
7350: 6e 2f 68 6f 70 65 20 69 73 20 74 68 61 74 20 74 n/hope is that t
7360: 68 65 20 62 72 6f 77 73 65 72 20 63 61 6e 20 73 he browser can s
7370: 74 6f 72 65 0a 20 20 20 20 20 20 20 74 68 6f 73 tore. thos
7380: 65 20 72 65 63 6f 72 64 73 20 22 64 69 72 65 63 e records "direc
7390: 74 6c 79 2c 22 20 77 69 74 68 6f 75 74 20 61 6e tly," without an
73a0: 79 20 69 6e 74 65 72 6d 65 64 69 61 72 79 0a 20 y intermediary.
73b0: 20 20 20 20 20 20 65 6e 63 6f 64 69 6e 67 2f 64 encoding/d
73c0: 65 63 6f 64 69 6e 67 20 67 6f 69 6e 67 20 6f 6e ecoding going on
73d0: 2e 0a 20 20 20 20 2a 2f 0a 20 20 20 20 69 6e 64 .. */. ind
73e0: 65 78 4b 65 79 3a 20 66 75 6e 63 74 69 6f 6e 28 exKey: function(
73f0: 66 69 6e 66 6f 29 7b 72 65 74 75 72 6e 20 66 69 finfo){return fi
7400: 6e 66 6f 2e 63 68 65 63 6b 69 6e 2b 27 3a 27 2b nfo.checkin+':'+
7410: 66 69 6e 66 6f 2e 66 69 6c 65 6e 61 6d 65 7d 2c finfo.filename},
7420: 0a 20 20 20 20 2f 2a 2a 20 52 65 74 75 72 6e 73 . /** Returns
7430: 20 74 68 65 20 6b 65 79 20 66 6f 72 20 73 74 6f the key for sto
7440: 72 69 6e 67 20 63 6f 6e 74 65 6e 74 20 66 6f 72 ring content for
7450: 20 74 68 65 20 67 69 76 65 6e 20 6b 65 79 20 73 the given key s
7460: 75 66 66 69 78 2c 0a 20 20 20 20 20 20 20 20 62 uffix,. b
7470: 79 20 70 72 65 70 65 6e 64 69 6e 67 20 50 2e 6e y prepending P.n
7480: 61 6d 65 20 74 6f 20 73 75 66 66 69 78 2e 20 2a ame to suffix. *
7490: 2f 0a 20 20 20 20 63 6f 6e 74 65 6e 74 4b 65 79 /. contentKey
74a0: 3a 20 66 75 6e 63 74 69 6f 6e 28 73 75 66 66 69 : function(suffi
74b0: 78 29 7b 72 65 74 75 72 6e 20 50 2e 6e 61 6d 65 x){return P.name
74c0: 2b 27 2f 27 2b 73 75 66 66 69 78 7d 2c 0a 20 20 +'/'+suffix},.
74d0: 20 20 2f 2a 2a 20 52 65 74 75 72 6e 73 20 74 68 /** Returns th
74e0: 65 20 69 6e 64 65 78 20 6f 62 6a 65 63 74 2c 20 e index object,
74f0: 66 65 74 63 68 69 6e 67 20 69 74 20 66 72 6f 6d fetching it from
7500: 20 74 68 65 20 73 74 61 73 68 20 6f 72 20 63 72 the stash or cr
7510: 65 61 74 69 6e 67 0a 20 20 20 20 20 20 20 20 69 eating. i
7520: 74 20 61 6e 65 77 20 6f 6e 20 74 68 65 20 66 69 t anew on the fi
7530: 72 73 74 20 63 61 6c 6c 2e 20 2a 2f 0a 20 20 20 rst call. */.
7540: 20 67 65 74 49 6e 64 65 78 3a 20 66 75 6e 63 74 getIndex: funct
7550: 69 6f 6e 28 29 7b 0a 20 20 20 20 20 20 69 66 28 ion(){. if(
7560: 21 74 68 69 73 2e 69 6e 64 65 78 29 20 74 68 69 !this.index) thi
7570: 73 2e 69 6e 64 65 78 20 3d 20 46 2e 73 74 6f 72 s.index = F.stor
7580: 61 67 65 2e 67 65 74 4a 53 4f 4e 28 74 68 69 73 age.getJSON(this
7590: 2e 6b 65 79 73 2e 69 6e 64 65 78 2c 7b 7d 29 3b .keys.index,{});
75a0: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 68 . return th
75b0: 69 73 2e 69 6e 64 65 78 3b 0a 20 20 20 20 7d 2c is.index;. },
75c0: 0a 20 20 20 20 2f 2a 2a 0a 20 20 20 20 20 20 20 . /**.
75d0: 52 65 74 75 72 6e 73 20 74 68 65 20 73 74 61 73 Returns the stas
75e0: 68 65 64 20 76 65 72 73 69 6f 6e 2c 20 69 66 20 hed version, if
75f0: 61 6e 79 2c 20 66 6f 72 20 74 68 65 20 67 69 76 any, for the giv
7600: 65 6e 20 66 69 6e 66 6f 20 6f 62 6a 65 63 74 2e en finfo object.
7610: 0a 20 20 20 20 2a 2f 0a 20 20 20 20 67 65 74 46 . */. getF
7620: 69 6e 66 6f 3a 20 66 75 6e 63 74 69 6f 6e 28 66 info: function(f
7630: 69 6e 66 6f 29 7b 0a 20 20 20 20 20 20 63 6f 6e info){. con
7640: 73 74 20 6e 64 78 20 3d 20 74 68 69 73 2e 67 65 st ndx = this.ge
7650: 74 49 6e 64 65 78 28 29 3b 0a 20 20 20 20 20 20 tIndex();.
7660: 72 65 74 75 72 6e 20 6e 64 78 5b 74 68 69 73 2e return ndx[this.
7670: 69 6e 64 65 78 4b 65 79 28 66 69 6e 66 6f 29 5d indexKey(finfo)]
7680: 3b 0a 20 20 20 20 7d 2c 0a 20 20 20 20 2f 2a 2a ;. },. /**
7690: 20 53 65 72 69 61 6c 69 7a 65 73 20 74 68 69 73 Serializes this
76a0: 20 6f 62 6a 65 63 74 27 73 20 69 6e 64 65 78 20 object's index
76b0: 74 6f 20 46 2e 73 74 6f 72 61 67 65 2e 20 52 65 to F.storage. Re
76c0: 74 75 72 6e 73 20 74 68 69 73 2e 20 2a 2f 0a 20 turns this. */.
76d0: 20 20 20 73 74 6f 72 65 49 6e 64 65 78 3a 20 66 storeIndex: f
76e0: 75 6e 63 74 69 6f 6e 28 29 7b 0a 20 20 20 20 20 unction(){.
76f0: 20 69 66 28 74 68 69 73 2e 69 6e 64 65 78 29 20 if(this.index)
7700: 46 2e 73 74 6f 72 61 67 65 2e 73 65 74 4a 53 4f F.storage.setJSO
7710: 4e 28 74 68 69 73 2e 6b 65 79 73 2e 69 6e 64 65 N(this.keys.inde
7720: 78 2c 74 68 69 73 2e 69 6e 64 65 78 29 3b 0a 20 x,this.index);.
7730: 20 20 20 20 20 72 65 74 75 72 6e 20 74 68 69 73 return this
7740: 3b 0a 20 20 20 20 7d 2c 0a 20 20 20 20 2f 2a 2a ;. },. /**
7750: 20 55 70 64 61 74 65 73 20 74 68 65 20 73 74 61 Updates the sta
7760: 73 68 20 72 65 63 6f 72 64 20 66 6f 72 20 74 68 sh record for th
7770: 65 20 67 69 76 65 6e 20 66 69 6e 66 6f 0a 20 20 e given finfo.
7780: 20 20 20 20 20 20 61 6e 64 20 28 6f 70 74 69 6f and (optio
7790: 6e 61 6c 6c 79 29 20 63 6f 6e 74 65 6e 74 2e 20 nally) content.
77a0: 49 66 20 70 61 73 73 65 64 20 31 20 61 72 67 2c If passed 1 arg,
77b0: 20 6f 6e 6c 79 0a 20 20 20 20 20 20 20 20 74 68 only. th
77c0: 65 20 66 69 6e 66 6f 20 73 74 61 73 68 20 69 73 e finfo stash is
77d0: 20 75 70 64 61 74 65 64 2c 20 65 6c 73 65 20 62 updated, else b
77e0: 6f 74 68 20 74 68 65 20 66 69 6e 66 6f 0a 20 20 oth the finfo.
77f0: 20 20 20 20 20 20 61 6e 64 20 69 74 73 20 63 6f and its co
7800: 6e 74 65 6e 74 73 20 61 72 65 20 28 72 65 2d 29 ntents are (re-)
7810: 73 74 61 73 68 65 64 2e 20 52 65 74 75 72 6e 73 stashed. Returns
7820: 20 74 68 69 73 2e 0a 20 20 20 20 2a 2f 0a 20 20 this.. */.
7830: 20 20 75 70 64 61 74 65 46 69 6c 65 3a 20 66 75 updateFile: fu
7840: 6e 63 74 69 6f 6e 28 66 69 6e 66 6f 2c 63 6f 6e nction(finfo,con
7850: 74 65 6e 74 29 7b 0a 20 20 20 20 20 20 63 6f 6e tent){. con
7860: 73 74 20 6e 64 78 20 3d 20 74 68 69 73 2e 67 65 st ndx = this.ge
7870: 74 49 6e 64 65 78 28 29 2c 0a 20 20 20 20 20 20 tIndex(),.
7880: 20 20 20 20 20 20 6b 65 79 20 3d 20 74 68 69 73 key = this
7890: 2e 69 6e 64 65 78 4b 65 79 28 66 69 6e 66 6f 29 .indexKey(finfo)
78a0: 3b 0a 20 20 20 20 20 20 63 6f 6e 73 74 20 72 65 ;. const re
78b0: 63 6f 72 64 20 3d 20 6e 64 78 5b 6b 65 79 5d 20 cord = ndx[key]
78c0: 7c 7c 20 28 6e 64 78 5b 6b 65 79 5d 3d 7b 0a 20 || (ndx[key]={.
78d0: 20 20 20 20 20 20 20 63 68 65 63 6b 69 6e 3a 20 checkin:
78e0: 66 69 6e 66 6f 2e 63 68 65 63 6b 69 6e 2c 0a 20 finfo.checkin,.
78f0: 20 20 20 20 20 20 20 66 69 6c 65 6e 61 6d 65 3a filename:
7900: 20 66 69 6e 66 6f 2e 66 69 6c 65 6e 61 6d 65 2c finfo.filename,
7910: 0a 20 20 20 20 20 20 20 20 6d 69 6d 65 74 79 70 . mimetyp
7920: 65 3a 20 66 69 6e 66 6f 2e 6d 69 6d 65 74 79 70 e: finfo.mimetyp
7930: 65 0a 20 20 20 20 20 20 7d 29 3b 0a 20 20 20 20 e. });.
7940: 20 20 72 65 63 6f 72 64 2e 69 73 45 78 65 20 3d record.isExe =
7950: 20 21 21 66 69 6e 66 6f 2e 69 73 45 78 65 3b 0a !!finfo.isExe;.
7960: 20 20 20 20 20 20 72 65 63 6f 72 64 2e 73 74 61 record.sta
7970: 73 68 54 69 6d 65 20 3d 20 6e 65 77 20 44 61 74 shTime = new Dat
7980: 65 28 29 2e 67 65 74 54 69 6d 65 28 29 3b 0a 20 e().getTime();.
7990: 20 20 20 20 20 74 68 69 73 2e 73 74 6f 72 65 49 this.storeI
79a0: 6e 64 65 78 28 29 3b 0a 20 20 20 20 20 20 69 66 ndex();. if
79b0: 28 61 72 67 75 6d 65 6e 74 73 2e 6c 65 6e 67 74 (arguments.lengt
79c0: 68 3e 31 29 7b 0a 20 20 20 20 20 20 20 20 46 2e h>1){. F.
79d0: 73 74 6f 72 61 67 65 2e 73 65 74 28 74 68 69 73 storage.set(this
79e0: 2e 63 6f 6e 74 65 6e 74 4b 65 79 28 6b 65 79 29 .contentKey(key)
79f0: 2c 20 63 6f 6e 74 65 6e 74 29 3b 0a 20 20 20 20 , content);.
7a00: 20 20 7d 0a 20 20 20 20 20 20 72 65 74 75 72 6e }. return
7a10: 20 74 68 69 73 3b 0a 20 20 20 20 7d 2c 0a 20 20 this;. },.
7a20: 20 20 2f 2a 2a 0a 20 20 20 20 20 20 20 52 65 74 /**. Ret
7a30: 75 72 6e 73 20 74 68 65 20 73 74 61 73 68 65 64 urns the stashed
7a40: 20 63 6f 6e 74 65 6e 74 2c 20 69 66 20 61 6e 79 content, if any
7a50: 2c 20 66 6f 72 20 74 68 65 20 67 69 76 65 6e 20 , for the given
7a60: 66 69 6e 66 6f 0a 20 20 20 20 20 20 20 6f 62 6a finfo. obj
7a70: 65 63 74 2e 0a 20 20 20 20 2a 2f 20 20 20 20 20 ect.. */
7a80: 20 20 0a 20 20 20 20 73 74 61 73 68 65 64 43 6f . stashedCo
7a90: 6e 74 65 6e 74 3a 20 66 75 6e 63 74 69 6f 6e 28 ntent: function(
7aa0: 66 69 6e 66 6f 29 7b 0a 20 20 20 20 20 20 72 65 finfo){. re
7ab0: 74 75 72 6e 20 46 2e 73 74 6f 72 61 67 65 2e 67 turn F.storage.g
7ac0: 65 74 28 74 68 69 73 2e 63 6f 6e 74 65 6e 74 4b et(this.contentK
7ad0: 65 79 28 74 68 69 73 2e 69 6e 64 65 78 4b 65 79 ey(this.indexKey
7ae0: 28 66 69 6e 66 6f 29 29 29 3b 0a 20 20 20 20 7d (finfo)));. }
7af0: 2c 0a 20 20 20 20 2f 2a 2a 20 52 65 74 75 72 6e ,. /** Return
7b00: 73 20 74 72 75 65 20 69 66 20 77 65 20 68 61 76 s true if we hav
7b10: 65 20 73 74 61 73 68 65 64 20 63 6f 6e 74 65 6e e stashed conten
7b20: 74 20 66 6f 72 20 74 68 65 20 67 69 76 65 6e 20 t for the given
7b30: 66 69 6e 66 6f 0a 20 20 20 20 20 20 20 20 72 65 finfo. re
7b40: 63 6f 72 64 2e 20 2a 2f 0a 20 20 20 20 68 61 73 cord. */. has
7b50: 53 74 61 73 68 65 64 43 6f 6e 74 65 6e 74 3a 20 StashedContent:
7b60: 66 75 6e 63 74 69 6f 6e 28 66 69 6e 66 6f 29 7b function(finfo){
7b70: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 46 2e . return F.
7b80: 73 74 6f 72 61 67 65 2e 63 6f 6e 74 61 69 6e 73 storage.contains
7b90: 28 74 68 69 73 2e 63 6f 6e 74 65 6e 74 4b 65 79 (this.contentKey
7ba0: 28 74 68 69 73 2e 69 6e 64 65 78 4b 65 79 28 66 (this.indexKey(f
7bb0: 69 6e 66 6f 29 29 29 3b 0a 20 20 20 20 7d 2c 0a info)));. },.
7bc0: 20 20 20 20 2f 2a 2a 20 55 6e 73 74 61 73 68 65 /** Unstashe
7bd0: 73 20 74 68 65 20 67 69 76 65 6e 20 66 69 6e 66 s the given finf
7be0: 6f 20 72 65 63 6f 72 64 20 61 6e 64 20 69 74 73 o record and its
7bf0: 20 63 6f 6e 74 65 6e 74 2e 0a 20 20 20 20 20 20 content..
7c00: 20 20 52 65 74 75 72 6e 73 20 74 68 69 73 2e 20 Returns this.
7c10: 2a 2f 0a 20 20 20 20 75 6e 73 74 61 73 68 3a 20 */. unstash:
7c20: 66 75 6e 63 74 69 6f 6e 28 66 69 6e 66 6f 29 7b function(finfo){
7c30: 0a 20 20 20 20 20 20 63 6f 6e 73 74 20 6e 64 78 . const ndx
7c40: 20 3d 20 74 68 69 73 2e 67 65 74 49 6e 64 65 78 = this.getIndex
7c50: 28 29 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 (),.
7c60: 6b 65 79 20 3d 20 74 68 69 73 2e 69 6e 64 65 78 key = this.index
7c70: 4b 65 79 28 66 69 6e 66 6f 29 3b 0a 20 20 20 20 Key(finfo);.
7c80: 20 20 64 65 6c 65 74 65 20 66 69 6e 66 6f 2e 73 delete finfo.s
7c90: 74 61 73 68 54 69 6d 65 3b 0a 20 20 20 20 20 20 tashTime;.
7ca0: 64 65 6c 65 74 65 20 6e 64 78 5b 6b 65 79 5d 3b delete ndx[key];
7cb0: 0a 20 20 20 20 20 20 46 2e 73 74 6f 72 61 67 65 . F.storage
7cc0: 2e 72 65 6d 6f 76 65 28 74 68 69 73 2e 63 6f 6e .remove(this.con
7cd0: 74 65 6e 74 4b 65 79 28 6b 65 79 29 29 3b 0a 20 tentKey(key));.
7ce0: 20 20 20 20 20 72 65 74 75 72 6e 20 74 68 69 73 return this
7cf0: 2e 73 74 6f 72 65 49 6e 64 65 78 28 29 3b 0a 20 .storeIndex();.
7d00: 20 20 20 7d 2c 0a 20 20 20 20 2f 2a 2a 0a 20 20 },. /**.
7d10: 20 20 20 20 20 43 6c 65 61 72 73 20 61 6c 6c 20 Clears all
7d20: 24 73 74 61 73 68 20 65 6e 74 72 69 65 73 20 66 $stash entries f
7d30: 72 6f 6d 20 46 2e 73 74 6f 72 61 67 65 2e 20 52 rom F.storage. R
7d40: 65 74 75 72 6e 73 20 74 68 69 73 2e 0a 20 20 20 eturns this..
7d50: 20 20 2a 2f 0a 20 20 20 20 63 6c 65 61 72 3a 20 */. clear:
7d60: 66 75 6e 63 74 69 6f 6e 28 29 7b 0a 20 20 20 20 function(){.
7d70: 20 20 63 6f 6e 73 74 20 6e 64 78 20 3d 20 74 68 const ndx = th
7d80: 69 73 2e 67 65 74 49 6e 64 65 78 28 29 2c 0a 20 is.getIndex(),.
7d90: 20 20 20 20 20 20 20 20 20 20 20 73 65 6c 66 20 self
7da0: 3d 20 74 68 69 73 3b 0a 20 20 20 20 20 20 4f 62 = this;. Ob
7db0: 6a 65 63 74 2e 6b 65 79 73 28 6e 64 78 29 2e 66 ject.keys(ndx).f
7dc0: 6f 72 45 61 63 68 28 66 75 6e 63 74 69 6f 6e 28 orEach(function(
7dd0: 6b 29 7b 0a 20 20 20 20 20 20 20 20 63 6f 6e 73 k){. cons
7de0: 74 20 65 20 3d 20 6e 64 78 5b 6b 5d 3b 0a 20 20 t e = ndx[k];.
7df0: 20 20 20 20 20 20 64 65 6c 65 74 65 20 6e 64 78 delete ndx
7e00: 5b 6b 5d 3b 0a 20 20 20 20 20 20 20 20 46 2e 73 [k];. F.s
7e10: 74 6f 72 61 67 65 2e 72 65 6d 6f 76 65 28 73 65 torage.remove(se
7e20: 6c 66 2e 63 6f 6e 74 65 6e 74 4b 65 79 28 6b 29 lf.contentKey(k)
7e30: 29 3b 0a 20 20 20 20 20 20 7d 29 3b 0a 20 20 20 );. });.
7e40: 20 20 20 46 2e 73 74 6f 72 61 67 65 2e 72 65 6d F.storage.rem
7e50: 6f 76 65 28 74 68 69 73 2e 6b 65 79 73 2e 69 6e ove(this.keys.in
7e60: 64 65 78 29 3b 0a 20 20 20 20 20 20 64 65 6c 65 dex);. dele
7e70: 74 65 20 74 68 69 73 2e 69 6e 64 65 78 3b 0a 20 te this.index;.
7e80: 20 20 20 20 20 72 65 74 75 72 6e 20 74 68 69 73 return this
7e90: 3b 0a 20 20 20 20 7d 2c 0a 20 20 20 20 2f 2a 2a ;. },. /**
7ea0: 0a 20 20 20 20 20 20 20 52 65 6d 6f 76 65 73 20 . Removes
7eb0: 61 6c 6c 20 62 75 74 20 74 68 65 20 6d 61 78 43 all but the maxC
7ec0: 6f 75 6e 74 20 6d 6f 73 74 2d 72 65 63 65 6e 74 ount most-recent
7ed0: 6c 79 2d 75 70 64 61 74 65 64 20 73 74 61 73 68 ly-updated stash
7ee0: 0a 20 20 20 20 20 20 20 65 6e 74 72 69 65 73 2c . entries,
7ef0: 20 77 68 65 72 65 20 6d 61 78 43 6f 75 6e 74 20 where maxCount
7f00: 64 65 66 61 75 6c 74 73 20 74 6f 20 74 68 69 73 defaults to this
7f10: 2e 70 72 75 6e 65 2e 64 65 66 61 75 6c 74 4d 61 .prune.defaultMa
7f20: 78 43 6f 75 6e 74 2e 0a 20 20 20 20 2a 2f 0a 20 xCount.. */.
7f30: 20 20 20 70 72 75 6e 65 3a 20 66 75 6e 63 74 69 prune: functi
7f40: 6f 6e 20 66 28 6d 61 78 43 6f 75 6e 74 29 7b 0a on f(maxCount){.
7f50: 20 20 20 20 20 20 63 6f 6e 73 74 20 6e 64 78 20 const ndx
7f60: 3d 20 74 68 69 73 2e 67 65 74 49 6e 64 65 78 28 = this.getIndex(
7f70: 29 3b 0a 20 20 20 20 20 20 63 6f 6e 73 74 20 6c );. const l
7f80: 69 20 3d 20 5b 5d 3b 0a 20 20 20 20 20 20 69 66 i = [];. if
7f90: 28 21 6d 61 78 43 6f 75 6e 74 20 7c 7c 20 6d 61 (!maxCount || ma
7fa0: 78 43 6f 75 6e 74 3c 30 29 20 6d 61 78 43 6f 75 xCount<0) maxCou
7fb0: 6e 74 20 3d 20 66 2e 64 65 66 61 75 6c 74 4d 61 nt = f.defaultMa
7fc0: 78 43 6f 75 6e 74 3b 0a 20 20 20 20 20 20 4f 62 xCount;. Ob
7fd0: 6a 65 63 74 2e 6b 65 79 73 28 6e 64 78 29 2e 66 ject.keys(ndx).f
7fe0: 6f 72 45 61 63 68 28 28 6b 29 3d 3e 6c 69 2e 70 orEach((k)=>li.p
7ff0: 75 73 68 28 6e 64 78 5b 6b 5d 29 29 3b 0a 20 20 ush(ndx[k]));.
8000: 20 20 20 20 6c 69 2e 73 6f 72 74 28 28 6c 2c 72 li.sort((l,r
8010: 29 3d 3e 6c 2e 73 74 61 73 68 54 69 6d 65 20 2d )=>l.stashTime -
8020: 20 72 2e 73 74 61 73 68 54 69 6d 65 29 3b 0a 20 r.stashTime);.
8030: 20 20 20 20 20 77 68 69 6c 65 28 6c 69 2e 6c 65 while(li.le
8040: 6e 67 74 68 3e 6d 61 78 43 6f 75 6e 74 29 7b 0a ngth>maxCount){.
8050: 20 20 20 20 20 20 20 20 63 6f 6e 73 74 20 65 20 const e
8060: 3d 20 6c 69 2e 73 68 69 66 74 28 29 3b 0a 20 20 = li.shift();.
8070: 20 20 20 20 20 20 74 68 69 73 2e 75 6e 73 74 61 this.unsta
8080: 73 68 28 65 29 3b 0a 20 20 20 20 20 20 20 20 63 sh(e);. c
8090: 6f 6e 73 6f 6c 65 2e 77 61 72 6e 28 22 50 72 75 onsole.warn("Pru
80a0: 6e 65 64 20 6f 6c 64 65 73 74 20 73 74 61 73 68 ned oldest stash
80b0: 20 65 6e 74 72 79 3a 22 2c 65 29 3b 0a 20 20 20 entry:",e);.
80c0: 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20 7d 3b 0a }. }. };.
80d0: 20 20 24 73 74 61 73 68 2e 70 72 75 6e 65 2e 64 $stash.prune.d
80e0: 65 66 61 75 6c 74 4d 61 78 43 6f 75 6e 74 20 3d efaultMaxCount =
80f0: 20 37 3b 0a 0a 20 20 2f 2a 2a 0a 20 20 20 20 20 7;.. /**.
8100: 55 70 64 61 74 65 73 20 50 2e 66 69 6e 66 6f 20 Updates P.finfo
8110: 66 6f 72 20 63 65 72 74 61 69 6e 20 73 74 61 74 for certain stat
8120: 65 20 61 6e 64 20 73 74 61 73 68 65 73 20 50 2e e and stashes P.
8130: 66 69 6e 66 6f 2c 20 77 69 74 68 20 74 68 65 0a finfo, with the.
8140: 20 20 20 20 20 63 75 72 72 65 6e 74 20 63 6f 6e current con
8150: 74 65 6e 74 20 66 65 74 63 68 65 64 20 76 69 61 tent fetched via
8160: 20 50 2e 66 69 6c 65 43 6f 6e 74 65 6e 74 28 29 P.fileContent()
8170: 2e 0a 0a 20 20 20 20 20 49 66 20 70 61 73 73 65 ... If passe
8180: 64 20 74 72 75 74 68 79 20 41 4e 44 20 74 68 65 d truthy AND the
8190: 20 73 74 61 73 68 20 61 6c 72 65 61 64 79 20 68 stash already h
81a0: 61 73 20 73 74 61 73 68 65 64 20 63 6f 6e 74 65 as stashed conte
81b0: 6e 74 20 66 6f 72 0a 20 20 20 20 20 74 68 65 20 nt for. the
81c0: 63 75 72 72 65 6e 74 20 66 69 6c 65 2c 20 6f 6e current file, on
81d0: 6c 79 20 74 68 65 20 73 74 61 73 68 65 64 20 66 ly the stashed f
81e0: 69 6e 66 6f 20 72 65 63 6f 72 64 20 69 73 20 75 info record is u
81f0: 70 64 61 74 65 64 2c 20 65 6c 73 65 0a 20 20 20 pdated, else.
8200: 20 20 62 6f 74 68 20 74 68 65 20 66 69 6e 66 6f both the finfo
8210: 20 61 6e 64 20 63 6f 6e 74 65 6e 74 20 61 72 65 and content are
8220: 20 75 70 64 61 74 65 64 2e 0a 20 20 2a 2f 0a 20 updated.. */.
8230: 20 50 2e 73 74 61 73 68 43 6f 6e 74 65 6e 74 43 P.stashContentC
8240: 68 61 6e 67 65 20 3d 20 66 75 6e 63 74 69 6f 6e hange = function
8250: 28 6f 6e 6c 79 46 69 6e 66 6f 29 7b 0a 20 20 20 (onlyFinfo){.
8260: 20 69 66 28 61 66 66 69 72 6d 48 61 73 46 69 6c if(affirmHasFil
8270: 65 28 74 72 75 65 29 29 7b 0a 20 20 20 20 20 20 e(true)){.
8280: 63 6f 6e 73 74 20 66 69 20 3d 20 74 68 69 73 2e const fi = this.
8290: 66 69 6e 66 6f 3b 0a 20 20 20 20 20 20 66 69 2e finfo;. fi.
82a0: 69 73 45 78 65 20 3d 20 74 68 69 73 2e 65 2e 63 isExe = this.e.c
82b0: 62 49 73 45 78 65 2e 63 68 65 63 6b 65 64 3b 0a bIsExe.checked;.
82c0: 20 20 20 20 20 20 69 66 28 6f 6e 6c 79 46 69 6e if(onlyFin
82d0: 66 6f 20 26 26 20 24 73 74 61 73 68 2e 68 61 73 fo && $stash.has
82e0: 53 74 61 73 68 65 64 43 6f 6e 74 65 6e 74 28 66 StashedContent(f
82f0: 69 29 29 7b 0a 20 20 20 20 20 20 20 20 24 73 74 i)){. $st
8300: 61 73 68 2e 75 70 64 61 74 65 46 69 6c 65 28 66 ash.updateFile(f
8310: 69 29 3b 0a 20 20 20 20 20 20 7d 65 6c 73 65 7b i);. }else{
8320: 0a 20 20 20 20 20 20 20 20 24 73 74 61 73 68 2e . $stash.
8330: 75 70 64 61 74 65 46 69 6c 65 28 66 69 2c 20 50 updateFile(fi, P
8340: 2e 66 69 6c 65 43 6f 6e 74 65 6e 74 28 29 29 3b .fileContent());
8350: 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 46 . }. F
8360: 2e 6d 65 73 73 61 67 65 28 22 53 74 61 73 68 65 .message("Stashe
8370: 64 20 63 68 61 6e 67 65 20 74 6f 22 2c 46 2e 68 d change to",F.h
8380: 61 73 68 44 69 67 69 74 73 28 66 69 2e 63 68 65 ashDigits(fi.che
8390: 63 6b 69 6e 29 2c 66 69 2e 66 69 6c 65 6e 61 6d ckin),fi.filenam
83a0: 65 29 3b 0a 20 20 20 20 20 20 24 73 74 61 73 68 e);. $stash
83b0: 2e 70 72 75 6e 65 28 29 3b 0a 20 20 20 20 7d 0a .prune();. }.
83c0: 20 20 20 20 72 65 74 75 72 6e 20 74 68 69 73 3b return this;
83d0: 0a 20 20 7d 3b 0a 0a 20 20 2f 2a 2a 0a 20 20 20 . };.. /**.
83e0: 20 20 52 65 6d 6f 76 65 73 20 61 6e 79 20 73 74 Removes any st
83f0: 61 73 68 65 64 20 73 74 61 74 65 20 66 6f 72 20 ashed state for
8400: 74 68 65 20 63 75 72 72 65 6e 74 20 50 2e 66 69 the current P.fi
8410: 6e 66 6f 20 28 69 66 20 73 65 74 29 20 66 72 6f nfo (if set) fro
8420: 6d 0a 20 20 20 20 20 46 2e 73 74 6f 72 61 67 65 m. F.storage
8430: 2e 20 52 65 74 75 72 6e 73 20 74 68 69 73 2e 0a . Returns this..
8440: 20 20 2a 2f 0a 20 20 50 2e 75 6e 73 74 61 73 68 */. P.unstash
8450: 43 6f 6e 74 65 6e 74 20 3d 20 66 75 6e 63 74 69 Content = functi
8460: 6f 6e 28 29 7b 0a 20 20 20 20 63 6f 6e 73 74 20 on(){. const
8470: 66 69 6e 66 6f 20 3d 20 61 72 67 75 6d 65 6e 74 finfo = argument
8480: 73 5b 30 5d 20 7c 7c 20 74 68 69 73 2e 66 69 6e s[0] || this.fin
8490: 66 6f 3b 0a 20 20 20 20 69 66 28 66 69 6e 66 6f fo;. if(finfo
84a0: 29 7b 0a 20 20 20 20 20 20 24 73 74 61 73 68 2e ){. $stash.
84b0: 75 6e 73 74 61 73 68 28 66 69 6e 66 6f 29 3b 0a unstash(finfo);.
84c0: 20 20 20 20 20 20 2f 2f 63 6f 6e 73 6f 6c 65 2e //console.
84d0: 64 65 62 75 67 28 22 55 6e 73 74 61 73 68 65 64 debug("Unstashed
84e0: 22 2c 66 69 6e 66 6f 29 3b 0a 20 20 20 20 20 20 ",finfo);.
84f0: 46 2e 6d 65 73 73 61 67 65 28 22 55 6e 73 74 61 F.message("Unsta
8500: 73 68 65 64 22 2c 46 2e 68 61 73 68 44 69 67 69 shed",F.hashDigi
8510: 74 73 28 66 69 6e 66 6f 2e 63 68 65 63 6b 69 6e ts(finfo.checkin
8520: 29 2c 66 69 6e 66 6f 2e 66 69 6c 65 6e 61 6d 65 ),finfo.filename
8530: 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 72 65 74 );. }. ret
8540: 75 72 6e 20 74 68 69 73 3b 0a 20 20 7d 3b 0a 0a urn this;. };..
8550: 20 20 2f 2a 2a 0a 20 20 20 20 20 43 6c 65 61 72 /**. Clear
8560: 73 20 61 6c 6c 20 73 74 61 73 68 65 64 20 66 69 s all stashed fi
8570: 6c 65 20 73 74 61 74 65 20 66 72 6f 6d 20 46 2e le state from F.
8580: 73 74 6f 72 61 67 65 2e 20 52 65 74 75 72 6e 73 storage. Returns
8590: 20 74 68 69 73 2e 0a 20 20 2a 2f 0a 20 20 50 2e this.. */. P.
85a0: 63 6c 65 61 72 53 74 61 73 68 20 3d 20 66 75 6e clearStash = fun
85b0: 63 74 69 6f 6e 28 29 7b 0a 20 20 20 20 24 73 74 ction(){. $st
85c0: 61 73 68 2e 63 6c 65 61 72 28 29 3b 0a 20 20 20 ash.clear();.
85d0: 20 72 65 74 75 72 6e 20 74 68 69 73 3b 0a 20 20 return this;.
85e0: 7d 3b 0a 0a 20 20 2f 2a 2a 0a 20 20 20 20 20 49 };.. /**. I
85f0: 66 20 73 74 61 73 68 65 64 20 63 6f 6e 74 65 6e f stashed conten
8600: 74 20 66 6f 72 20 50 2e 66 69 6e 66 6f 20 65 78 t for P.finfo ex
8610: 69 73 74 73 2c 20 69 74 20 69 73 20 72 65 74 75 ists, it is retu
8620: 72 6e 65 64 2c 20 65 6c 73 65 0a 20 20 20 20 20 rned, else.
8630: 75 6e 64 65 66 69 6e 65 64 20 69 73 20 72 65 74 undefined is ret
8640: 75 72 6e 65 64 2e 0a 20 20 2a 2f 0a 20 20 50 2e urned.. */. P.
8650: 63 6f 6e 74 65 6e 74 46 72 6f 6d 53 74 61 73 68 contentFromStash
8660: 20 3d 20 66 75 6e 63 74 69 6f 6e 28 29 7b 0a 20 = function(){.
8670: 20 20 20 72 65 74 75 72 6e 20 61 66 66 69 72 6d return affirm
8680: 48 61 73 46 69 6c 65 28 74 72 75 65 29 20 3f 20 HasFile(true) ?
8690: 24 73 74 61 73 68 2e 73 74 61 73 68 65 64 43 6f $stash.stashedCo
86a0: 6e 74 65 6e 74 28 74 68 69 73 2e 66 69 6e 66 6f ntent(this.finfo
86b0: 29 20 3a 20 75 6e 64 65 66 69 6e 65 64 3b 0a 20 ) : undefined;.
86c0: 20 7d 3b 0a 0a 20 20 2f 2a 2a 0a 20 20 20 20 20 };.. /**.
86d0: 49 66 20 61 20 73 74 61 73 68 65 64 20 76 65 72 If a stashed ver
86e0: 73 69 6f 6e 20 6f 66 20 74 68 65 20 67 69 76 65 sion of the give
86f0: 6e 20 66 69 6e 66 6f 20 6f 62 6a 65 63 74 20 65 n finfo object e
8700: 78 69 73 74 73 20 28 73 61 6d 65 0a 20 20 20 20 xists (same.
8710: 20 66 69 6c 65 6e 61 6d 65 2f 63 68 65 63 6b 69 filename/checki
8720: 6e 20 76 61 6c 75 65 73 29 2c 20 72 65 74 75 72 n values), retur
8730: 6e 20 69 74 2c 20 65 6c 73 65 20 72 65 74 75 72 n it, else retur
8740: 6e 20 75 6e 64 65 66 69 6e 65 64 2e 0a 20 20 2a n undefined.. *
8750: 2f 0a 20 20 50 2e 67 65 74 53 74 61 73 68 65 64 /. P.getStashed
8760: 46 69 6e 66 6f 20 3d 20 66 75 6e 63 74 69 6f 6e Finfo = function
8770: 28 66 69 6e 66 6f 29 7b 0a 20 20 20 20 72 65 74 (finfo){. ret
8780: 75 72 6e 20 24 73 74 61 73 68 2e 67 65 74 46 69 urn $stash.getFi
8790: 6e 66 6f 28 66 69 6e 66 6f 29 3b 0a 20 20 7d 3b nfo(finfo);. };
87a0: 0a 0a 20 20 50 2e 24 73 74 61 73 68 20 3d 20 24 .. P.$stash = $
87b0: 73 74 61 73 68 20 2f 2a 6f 6e 6c 79 20 66 6f 72 stash /*only for
87c0: 20 74 65 73 74 69 6e 67 2f 64 65 62 75 67 67 69 testing/debuggi
87d0: 6e 67 20 2a 2f 3b 0a 0a 7d 29 28 77 69 6e 64 6f ng */;..})(windo
87e0: 77 2e 66 6f 73 73 69 6c 29 3b 0a w.fossil);.