Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' fair warning, this was written in power basic, and sort of just slapped together on the fly
- #PBFORMS CREATED V1.51
- '------------------------------------------------------------------------------
- ' The first line in this file is a PB/Forms metastatement.
- ' It should ALWAYS be the first line of the file. Other
- ' PB/Forms metastatements are placed at the beginning and
- ' end of "Named Blocks" of code that should be edited
- ' with PBForms only. Do not manually edit or delete these
- ' metastatements or PB/Forms will not be able to reread
- ' the file correctly. See the PB/Forms documentation for
- ' more information.
- ' Named blocks begin like this: #PBFORMS BEGIN ...
- ' Named blocks end like this: #PBFORMS END ...
- ' Other PB/Forms metastatements such as:
- ' #PBFORMS DECLARATIONS
- ' are used by PB/Forms to insert additional code.
- ' Feel free to make changes anywhere else in the file.
- '------------------------------------------------------------------------------
- #COMPILE EXE
- #DIM ALL
- '------------------------------------------------------------------------------
- ' ** Includes **
- '------------------------------------------------------------------------------
- #PBFORMS BEGIN INCLUDES
- %USEMACROS = 1
- #IF NOT %DEF(%WINAPI)
- #INCLUDE "WIN32API.INC"
- #ENDIF
- #IF NOT %DEF(%COMMCTRL_INC)
- #INCLUDE "COMMCTRL.INC"
- #ENDIF
- #INCLUDE "PBForms.INC"
- #PBFORMS END INCLUDES
- '------------------------------------------------------------------------------
- '------------------------------------------------------------------------------
- ' ** Constants **
- '------------------------------------------------------------------------------
- #PBFORMS BEGIN CONSTANTS
- %IDD_CONVERTJSON = 101
- %IDR_ACCELERATOR1 = 102
- %IDR_MENU1 = 103
- %IDSB_STATUS = 1201
- %IDLB_CARDS = 1202
- %IDM_FILE_CONVERTJSON = 1001
- %IDM_FILE_RECENTACTS = 1002
- %IDM_FILE_CARDLIST = 1004
- %IDM_FILE_CUSTOM = 1005
- %IDM_FILE_ANALYZE = 1006
- %IDM_FILE_EXIT = 1007
- %IDBT_CANCEL = 5001
- %IDBT_GENERATELIST = 5002
- %IDOPT_LISTORDER1 = 5010
- %IDOPT_LISTORDER2 = 5011
- %IDCK_LISTS = 6000
- %IDCK_LABELS = 7000
- #PBFORMS END CONSTANTS
- '------------------------------------------------------------------------------
- '------------------------------------------------------------------------------
- ' ** Declarations **
- '------------------------------------------------------------------------------
- UNION QUADTODOUBLE
- iParts AS FILETIME
- iQuad AS QUAD
- END UNION
- %UNIXTOWINTIME = 11644473600 ' 11,644,473,600
- %UNIXMULTIPLY = 10000000 '
- GLOBAL hCustom AS DWORD
- '------------------------------------------------------------------------------
- '------------------------------------------------------------------------------
- ' ** Main Application Entry Point **
- '------------------------------------------------------------------------------
- FUNCTION PBMAIN()
- PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR _
- %ICC_INTERNET_CLASSES)
- LOCAL Work AS STRING, uQuad AS QUAD
- uQuad = GetUtcOffset(0)
- Work = FORMAT$(uQuad, "0,0")
- #DEBUG PRINT Work
- ShowConverJson %HWND_DESKTOP
- END FUNCTION
- '------------------------------------------------------------------------------
- '------------------------------------------------------------------------------
- ' ** CallBacks **
- '------------------------------------------------------------------------------
- CALLBACK FUNCTION ShowConverJsonProc()
- STATIC FileName, FileFilter AS STRING
- LOCAL Work AS STRING
- LOCAL FileInfo AS DIRDATA
- LOCAL FileDate AS FILETIME
- LOCAL SysTime AS SYSTEMTIME
- LOCAL jFile, tFile AS QUAD
- SELECT CASE AS LONG CB.MSG
- CASE %WM_INITDIALOG
- ' Initialization handler
- CASE %WM_SIZE
- ' Dialog has been resized
- LOCAL DX, DY, SX, SY AS LONG
- CONTROL SEND CB.HNDL, %IDSB_STATUS, CB.MSG, CB.WPARAM, CB.LPARAM
- DIALOG GET CLIENT CB.HNDL TO DX, DY
- CONTROL GET SIZE CB.HNDL, %IDSB_STATUS TO SX, SY
- DY = DY - SY
- CONTROL SET LOC CB.HNDL, %IDLB_CARDS, 0, 0
- CONTROL SET SIZE CB.HNDL, %IDLB_CARDS, DX, DY
- CASE %WM_NCACTIVATE
- STATIC hWndSaveFocus AS DWORD
- IF ISFALSE CB.WPARAM THEN
- ' Save control focus
- hWndSaveFocus = GetFocus()
- ELSEIF hWndSaveFocus THEN
- ' Restore control focus
- SetFocus(hWndSaveFocus)
- hWndSaveFocus = 0
- END IF
- CASE %WM_COMMAND
- ' Process control notifications
- SELECT CASE AS LONG CB.CTL
- CASE %IDM_FILE_CONVERTJSON, %IDM_FILE_RECENTACTS, %IDM_FILE_CARDLIST, %IDM_FILE_CUSTOM
- FileFilter = CHR$("JSON Files", 0, "*.json", 0)
- DISPLAY OPENFILE CB.HNDL, , , "Select JSON File", EXE.PATH$, _
- FileFilter, "", "", _
- %OFN_ENABLESIZING OR %OFN_FILEMUSTEXIST _
- TO FileName
- IF (LEN(FileName) > 0) THEN
- Work = DIR$(FileName, TO FileInfo)
- jFile = FileInfo.LastWriteTime
- DIR$ CLOSE
- REPLACE ".json" WITH ".txt" IN Work
- Work = DIR$(Work, TO FileInfo)
- IF (LEN(Work) = 0) THEN
- tFile = jFile
- ELSE
- tFile = FileInfo.LastWriteTime
- END IF
- DIR$ CLOSE
- IF (tFile <= jFile) THEN
- ConvertJson CB.HNDL, FileName
- SplitJson CB.HNDL, FileName
- END IF
- SELECT CASE AS LONG CB.CTL
- CASE %IDM_FILE_CONVERTJSON
- CreateCards CB.HNDL, FileName, "actions.mbox", %TRUE
- CreateCards CB.HNDL, FileName, "cards.mbox", %FALSE
- END SELECT
- SELECT CASE AS LONG CB.CTL
- CASE %IDM_FILE_CONVERTJSON, %IDM_FILE_RECENTACTs
- ExtractRecentActions CB.HNDL, FileName
- CASE %IDM_FILE_CARDLIST
- CreateCardList CB.HNDL, FileName
- CASE %IDM_FILE_CUSTOM
- hCustom = ShowCustomDialog(CB.HNDL, FileName)
- DIALOG SHOW MODELESS hCustom, CALL ShowConverJsonProc
- END SELECT
- LISTBOX ADD CB.HNDL, %IDLB_CARDS, "Done"
- END IF
- CASE %IDM_FILE_ANALYZE
- FileFilter = CHR$("JSON Files", 0, "*.json", 0)
- DISPLAY OPENFILE CB.HNDL, , , "Select JSON File", EXE.PATH$, _
- FileFilter, "", "", _
- %OFN_ENABLESIZING OR %OFN_FILEMUSTEXIST _
- TO FileName
- IF (LEN(FileName) > 0) THEN
- Work = DIR$(FileName, TO FileInfo)
- jFile = FileInfo.LastWriteTime
- DIR$ CLOSE
- REPLACE ".json" WITH ".txt" IN Work
- Work = DIR$(Work, TO FileInfo)
- IF (LEN(Work) = 0) THEN
- tFile = jFile
- ELSE
- tFile = FileInfo.LastWriteTime
- END IF
- DIR$ CLOSE
- IF (tFile < jFile) THEN
- ConvertJson CB.HNDL, FileName
- SplitJson CB.HNDL, FileName
- END IF
- AnalyzeActions CB.HNDL, FileName
- LISTBOX ADD CB.HNDL, %IDLB_CARDS, "Done"
- END IF
- CASE %IDBT_CANCEL ' can only come from the child dialog
- IF (hCustom <> 0) THEN
- DIALOG END hCustom
- hCustom = 0
- END IF
- CASE %IDBT_GENERATELIST
- CreateCardList CB.HNDL, FileName
- LISTBOX ADD CB.HNDL, %IDLB_CARDS, "Done"
- CASE %IDM_FILE_EXIT
- DIALOG END CB.HNDL
- END SELECT
- END SELECT
- END FUNCTION
- '------------------------------------------------------------------------------
- '------------------------------------------------------------------------------
- ' ** Dialogs **
- '------------------------------------------------------------------------------
- FUNCTION ShowConverJson(BYVAL hParent AS DWORD) AS LONG
- LOCAL lRslt AS LONG
- #PBFORMS BEGIN DIALOG %IDD_CONVERTJSON->%IDR_MENU1->%IDR_ACCELERATOR1
- LOCAL hDlg AS DWORD
- DIALOG NEW PIXELS, hParent, "Convert Json", 598, 310, 376, 343, %WS_POPUP _
- OR %WS_BORDER OR %WS_THICKFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _
- %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_CLIPSIBLINGS OR _
- %WS_CLIPCHILDREN OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
- %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
- OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
- CONTROL ADD STATUSBAR, hDlg, %IDSB_STATUS, "Status", 0, 306, _
- 376, 19, %WS_CHILD OR %WS_VISIBLE, %WS_EX_TRANSPARENT OR %WS_EX_LEFT _
- OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
- CONTROL ADD LISTBOX, hDlg, %IDLB_CARDS, , 38, 89, 277, 147, %WS_CHILD OR _
- %WS_VISIBLE OR %WS_TABSTOP OR %WS_VSCROLL, %WS_EX_CLIENTEDGE OR _
- %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
- AttachMENU1 hDlg
- AttachACCELERATOR1 hDlg
- #PBFORMS END DIALOG
- DIALOG SHOW MODAL hDlg, CALL ShowConverJsonProc TO lRslt
- #PBFORMS BEGIN CLEANUP %IDD_CONVERTJSON
- #PBFORMS END CLEANUP
- FUNCTION = lRslt
- END FUNCTION
- '------------------------------------------------------------------------------
- '------------------------------------------------------------------------------
- FUNCTION ShowCustomDialog(hParent AS DWORD, JsonFile AS STRING) AS DWORD
- LOCAL hChild AS DWORD
- LOCAL Lists(), Labels() AS STRING
- LOCAL DataBlock() AS STRING
- LOCAL SectionPath, Work AS STRING
- LOCAL FileIn, DataIndex AS LONG
- LOCAL CiDx AS LONG
- LOCAL Caption, SizeY AS LONG
- DataIndex = 0
- REDIM DataBlock(0)
- FetchDataSet hParent, JsonFile, "\lists.mbox", DataBlock()
- FOR CiDx = 0 TO UBOUND(DataBlock)
- Work = Simple(ExtractItemValue("name", DataBlock(CiDx)))
- IF (LEN(Work) > 0) THEN
- REDIM PRESERVE Lists(DataIndex)
- Lists(DataIndex) = Work
- INCR DataIndex
- END IF
- NEXT CiDx
- SectionPath = PATHNAME$(PATH, JsonFile) & PATHNAME$(NAME, JsonFile)
- FileIn = FREEFILE
- OPEN SectionPath &"\globals.mbox" FOR INPUT AS FileIn
- LINE INPUT #FileIn, Work
- DataIndex = 0
- REDIM Labels(DataIndex)
- ' find "labelNames" in globals
- DO
- LINE INPUT #FileIn, Work
- IF (INSTR(Work, "labelNames") > 0) THEN EXIT DO
- LOOP
- LINE INPUT #FileIn, Work
- DO
- LINE INPUT #FileIn, Work
- IF (VAL(Work) = 2) THEN EXIT DO
- REDIM PRESERVE Labels(DataIndex)
- Labels(DataIndex) = PARSE$(Work, ":", 2)
- REPLACE "," WITH "" IN Labels(DataIndex)
- REPLACE CHR$(34) WITH "" IN Labels(DataIndex)
- INCR DataIndex
- LOOP
- CLOSE FileIn
- Caption = GetSystemMetrics(%SM_CYCAPTION) + (GetSystemMetrics(%SM_CYFIXEDFRAME) * 2)
- SizeY = Caption + (UBOUND(Labels) * 16) + (UBOUND(Lists) * 16) + 112
- DIALOG NEW PIXELS, hParent, "Custom Lists", , , 256, SizeY, %WS_POPUP _
- OR %WS_BORDER OR %WS_CAPTION OR %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN _
- OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE _
- OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _
- %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hChild
- CONTROL ADD BUTTON, hChild, %IDBT_GENERATELIST, "Generate List", 0, 0, 120, 24
- CONTROL ADD BUTTON, hChild, %IDBT_CANCEL, "Cancel", 136, 0, 120, 24
- CONTROL ADD OPTION, hChild, %IDOPT_LISTORDER1, "Find In Lists First", 10, 26, 120, 16
- CONTROL ADD OPTION, hChild, %IDOPT_LISTORDER2, "Find In Labels First", 10, 42, 120, 16
- CONTROL SET OPTION hChild, %IDOPT_LISTORDER1, %IDOPT_LISTORDER1, %IDOPT_LISTORDER2
- CONTROL ADD LABEL, hChild, 0, "Select List (none = all)", 10, 60, 240, 16
- CiDx = 78
- FOR DataIndex = 0 TO UBOUND(Lists)
- CONTROL ADD CHECKBOX, hChild, %IDCK_LISTS + DataIndex, Lists(DataIndex), 10, _
- (CiDx + (DataIndex * 16)), 240, 16
- NEXT DataIndex
- DIALOG SET USER hChild, 1, UBOUND(Lists)
- CiDx = (CiDx + (DataIndex * 16)) + 4
- CONTROL ADD LABEL, hChild, 0, "Select Labels (none = all)", 10, CiDx, 240, 16
- CiDx = CiDx + 16
- FOR DataIndex = 0 TO UBOUND(Labels)
- CONTROL ADD CHECKBOX, hChild, %IDCK_LABELS + DataIndex, Labels(DataIndex), 10, _
- (CiDx + (DataIndex * 16)), 240, 16
- NEXT DataIndex
- DIALOG SET USER hChild, 2, UBOUND(Labels)
- ShowCustomDialog = hChild
- END FUNCTION
- '------------------------------------------------------------------------------
- '------------------------------------------------------------------------------
- ' ** Menus **
- '------------------------------------------------------------------------------
- FUNCTION AttachMENU1(BYVAL hDlg AS DWORD) AS DWORD
- #PBFORMS BEGIN MENU %IDR_MENU1->%IDD_CONVERTJSON
- LOCAL hMenu AS DWORD
- LOCAL hPopUp1 AS DWORD
- MENU NEW BAR TO hMenu
- MENU NEW POPUP TO hPopUp1
- MENU ADD POPUP, hMenu, "File", hPopUp1, %MF_ENABLED
- MENU ADD STRING, hPopUp1, "Convert Json", %IDM_FILE_CONVERTJSON, %MF_ENABLED
- MENU ADD STRING, hPopUp1, "Extract Recent", %IDM_FILE_RECENTACTS, %MF_ENABLED
- MENU ADD STRING, hPopUp1, "Create Card List", %IDM_FILE_CARDLIST, %MF_ENABLED
- MENU ADD STRING, hPopUp1, "Create Custom List", %IDM_FILE_CUSTOM, %MF_ENABLED
- MENU ADD STRING, hPopUp1, "Analyze Actions", %IDM_FILE_ANALYZE, %MF_ENABLED
- MENU ADD STRING, hPopUp1, "-", 0, 0
- MENU ADD STRING, hPopUp1, "Exit" + $TAB + "Alt+F4", %IDM_FILE_EXIT, %MF_ENABLED
- MENU ATTACH hMenu, hDlg
- #PBFORMS END MENU
- FUNCTION = hMenu
- END FUNCTION
- '------------------------------------------------------------------------------
- '------------------------------------------------------------------------------
- ' ** Accelerators **
- '------------------------------------------------------------------------------
- #PBFORMS BEGIN ASSIGNACCEL
- FUNCTION ASSIGNACCEL(tAccel AS ACCELAPI, BYVAL wKey AS WORD, BYVAL wCmd AS _
- WORD, BYVAL byFVirt AS BYTE) AS LONG
- tAccel.fVirt = byFVirt
- tAccel.key = wKey
- tAccel.cmd = wCmd
- END FUNCTION
- #PBFORMS END ASSIGNACCEL
- '------------------------------------------------------------------------------
- '------------------------------------------------------------------------------
- FUNCTION AttachACCELERATOR1(BYVAL hDlg AS DWORD) AS DWORD
- #PBFORMS BEGIN ACCEL %IDR_ACCELERATOR1->%IDD_CONVERTJSON
- LOCAL hAccel AS DWORD
- LOCAL tAccel() AS ACCELAPI
- DIM tAccel(1 TO 1) AS ACCELAPI
- ASSIGNACCEL tAccel(1), %VK_F4, %IDM_FILE_EXIT, %FVIRTKEY OR %FALT OR %FNOINVERT
- ACCEL ATTACH hDlg, tAccel() TO hAccel
- #PBFORMS END ACCEL
- FUNCTION = hAccel
- END FUNCTION
- '------------------------------------------------------------------------------
- SUB ConvertJson(hDlg AS LONG, JsonFile AS STRING)
- LOCAL Chunk, Buffer, Work, FileName, Char, StatusText AS STRING
- LOCAL FileIn, FileOut, InQuote, Depth, CiDx, Level AS LONG
- FileName = JsonFile
- FileIn = FREEFILE
- OPEN FileName FOR BINARY AS FileIn
- REPLACE ".json" WITH ".txt" IN FileName
- FileOut = FREEFILE
- OPEN FileName FOR OUTPUT AS FileOut
- Level = 1
- Buffer = ""
- InQuote = %FALSE
- CiDx = 1
- StatusText = "Loading "& PATHNAME$(NAMEX, JsonFile)
- LISTBOX ADD hDlg, %IDLB_CARDS, StatusText
- DIALOG DOEVENTS
- DO
- IF (CiDx > LEN(Buffer)) THEN
- Depth = SEEK(FileIn)
- IF (Depth > LOF(FileIn)) THEN EXIT DO
- StatusText = "Converting Block "& FORMAT$(Depth) &" of "& FORMAT$(LOF(FileIn))
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, StatusText
- DIALOG DOEVENTS
- ' If (Depth > 32000) Then Exit Do
- Chunk = STRING$(4096, $TAB)
- GET #FileIn, , Chunk
- Buffer = Buffer & Chunk
- REPLACE $TAB WITH "" IN Buffer
- CiDx = 1
- END IF
- Char = MID$(Buffer, CiDx, 1)
- MID$(Buffer, CiDx, 1) = $TAB
- IF (Char <> $TAB) THEN
- IF (InQuote) THEN
- Work = Work & Char
- IF (Char = "\") THEN
- IF (CiDx = LEN(Buffer)) THEN
- ' fetch one more
- Chunk = " "
- GET #FileIn, , Chunk
- Buffer = Buffer & Chunk
- END IF
- Work = Work & MID$(Buffer, CiDx + 1, 1)
- MID$(Buffer, CiDx + 1, 1) = $TAB
- Char = $TAB
- END IF
- IF (Char = CHR$(34)) THEN
- InQuote = %FALSE
- END IF
- ELSE
- IF (Char = "{") THEN
- IF (CiDx = LEN(Buffer)) THEN
- ' fetch one more
- Chunk = " "
- GET #FileIn, , Chunk
- Buffer = Buffer & Chunk
- END IF
- IF (MID$(Buffer, CiDx + 1, 1) = "}") THEN
- Work = Work &"{}"
- MID$(Buffer, CiDx + 1, 1) = $TAB
- ELSE
- IF (LEN(Work) > 0) THEN
- DumpOutput FileOut, Level, Work
- Work = ""
- END IF
- DumpOutput FileOut, Level, "{"
- Level = Level + 1
- END IF
- ELSEIF (Char = "}") THEN
- IF (CiDx = LEN(Buffer)) THEN
- ' fetch one more
- Chunk = " "
- GET #FileIn, , Chunk
- Buffer = Buffer & Chunk
- END IF
- IF (LEN(Work) > 0) THEN
- DumpOutput FileOut, Level, Work
- Work = ""
- END IF
- Level = Level - 1
- IF (MID$(Buffer, CiDx + 1, 1) = ",") THEN
- DumpOutput FileOut, Level, "},"
- MID$(Buffer, CiDx + 1, 1) = $TAB
- ELSE
- DumpOutput FileOut, Level, "}"
- END IF
- ELSEIF (Char = ",") THEN
- Work = Work & Char
- IF (LEN(Work) > 0) THEN
- DumpOutput FileOut, Level, Work
- Work = ""
- END IF
- ELSE
- Work = Work & Char
- IF (Char = CHR$(34)) THEN
- InQuote = %TRUE
- END IF
- IF (Char = "[") THEN
- Level = Level + 1
- END IF
- IF (Char = "]") THEN
- Level = Level - 1
- END IF
- END IF ' big chain
- END IF ' InQuote
- END IF ' Char <> $TAB
- CiDx = CiDx + 1
- LOOP
- CLOSE
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, "Done"
- END SUB
- SUB DumpOutput(FileOut AS LONG, Level AS LONG, Work AS STRING)
- ' this is easier to do than over testing in the above subroutine
- IF (RIGHT$(Work, 1) = "[") THEN
- PRINT #FileOut, FORMAT$(Level - 1) & STRING$((Level - 1) * 2, 32) & Work
- ELSE
- PRINT #FileOut, FORMAT$(Level) & STRING$(Level * 2, 32) & Work
- END IF
- END SUB
- SUB SplitJson(hDlg AS LONG, JsonFile AS STRING)
- LOCAL FileIn, FileOut, Depth AS LONG
- LOCAL LineCount AS LONG
- LOCAL Work, FileName AS STRING
- LOCAL SectionPath, SectionName AS STRING
- LOCAL StatusText AS STRING
- LOCAL Exported AS LONG ' boolean value
- SectionPath = PATHNAME$(PATH, JsonFile) & PATHNAME$(NAME, JsonFile)
- IF (ISTRUE ISFOLDER(SectionPath)) THEN
- IF (DIR$(SectionPath &"\*.mbox") <> "") THEN
- KILL SectionPath &"\*.mbox"
- END IF
- DIR$ CLOSE
- ELSE
- MKDIR SectionPath
- END IF
- FileIn = FREEFILE
- FileName = PATHNAME$(PATH, JsonFile) & PATHNAME$(NAME, JsonFile) &".txt"
- OPEN FileName FOR INPUT AS FileIn
- ' global text comes first, dispose of first line and open global
- LINE INPUT #FileIn, Work
- FileOut = FREEFILE
- OPEN SectionPath &"\globals.mbox" FOR APPEND AS FileOut
- SectionName = "globals"
- LineCount = 0
- StatusText = "Converting "& PATHNAME$(NAMEX, JsonFile)
- LISTBOX ADD hDlg, %IDLB_CARDS, StatusText
- DIALOG DOEVENTS
- DO
- LINE INPUT #FileIn, Work
- Depth = VAL(Work)
- IF (Depth = 1) THEN EXIT DO
- IF (Depth = 3) THEN
- INCR LineCount
- StatusText = "Extracting "& SectionName &" "& FORMAT$(LineCount)
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, StatusText
- DIALOG DOEVENTS
- END IF
- Exported = %FALSE
- IF ((Depth = 2) AND (INSTR(Work, "[") > 0)) THEN
- ' new section, close current, open new based on section name
- CLOSE FileOut
- SectionName = PARSE$(TRIM$(MID$(Work, 2)), ":", 1)
- REPLACE CHR$(34) WITH "" IN SectionName
- FileOut = FREEFILE
- OPEN SectionPath &"\"& SectionName &".mbox" FOR APPEND AS FileOut
- PRINT #FileOut, Work
- Exported = %TRUE
- LineCount = 0
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, SectionName
- DIALOG DOEVENTS
- END IF
- IF ((Depth = 2) AND (INSTR(Work, "]") > 0)) THEN
- ' close current and reopen global
- IF (ISFALSE Exported) THEN
- PRINT #FileOut, Work
- END IF
- CLOSE FileOut
- FileOut = FREEFILE
- OPEN SectionPath &"\globals.mbox" FOR APPEND AS FileOut
- Exported = %TRUE
- END IF
- IF (ISFALSE Exported) THEN
- PRINT #FileOut, Work
- END IF
- LOOP
- CLOSE FileIn
- CLOSE FileOut
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, "Done"
- END SUB
- SUB CreateCards(hDlg AS LONG, JsonFile AS STRING, SectionName AS STRING, kJson AS LONG)
- LOCAL FileIn, FileOut, Depth AS LONG
- LOCAL LineCount, wIndex AS LONG
- LOCAL idShort AS LONG
- LOCAL Work, FileName AS STRING
- LOCAL rFix, nFix AS STRING
- LOCAL SectionPath, CardName AS STRING
- LOCAL Char, Opener, Prefix AS STRING
- LOCAL StatusText, Card AS STRING
- LOCAL Exported AS LONG ' boolean value
- SectionPath = PATHNAME$(PATH, JsonFile) & PATHNAME$(NAME, JsonFile)
- IF (ISTRUE kJson) THEN
- IF (DIR$(SectionPath &"\*.json") <> "") THEN
- KILL SectionPath &"\*.json"
- END IF
- DIR$ CLOSE
- END IF
- FileIn = FREEFILE
- OPEN SectionPath &"\"& SectionName FOR INPUT AS FileIn
- ' dispose of first item, do until depth=2
- LINE INPUT #FileIn, Work
- StatusText = "Creating Cards"
- LISTBOX ADD hDlg, %IDLB_CARDS, StatusText
- DIALOG DOEVENTS
- DO
- LINE INPUT #FileIn, Work
- Depth = VAL(Work)
- IF (Depth = 2) THEN EXIT DO
- Work = TRIM$(MID$(Work, 2))
- REPLACE CHR$(34) WITH "|" IN Work
- nFix = PARSE$(Work, "|", 2)
- REPLACE "|"& nFix WITH "|"& Prefix & nFix IN Work
- Char = RIGHT$(Work, 1)
- IF ((Char = ":") OR (Char = "[")) THEN
- Prefix = Prefix & nFix &"."
- Opener = Opener & Char
- END IF
- Char = LEFT$(Work, 1)
- IF ((Char = "]") AND (RIGHT$(Opener, 1) = "[") AND (Depth > 3)) THEN
- IF (LEN(Prefix) > 0) THEN
- wIndex = PARSECOUNT(Prefix, ".")
- Char = PARSE$(Prefix, ".", wIndex - 1) &"."
- REPLACE Char WITH "" IN Prefix
- Opener = LEFT$(Opener, LEN(Opener) - 1)
- END IF
- END IF
- IF ((Char = "}") AND (RIGHT$(Opener, 1) = ":") AND (Depth > 3)) THEN
- IF (LEN(Prefix) > 0) THEN
- wIndex = PARSECOUNT(Prefix, ".")
- Char = PARSE$(Prefix, ".", wIndex - 1) &"."
- REPLACE Char WITH "" IN Prefix
- Opener = LEFT$(Opener, LEN(Opener) - 1)
- END IF
- END IF
- Card = Card & $TAB & FORMAT$(Depth) & Work
- IF ((Depth = 3) AND (INSTR(Work, "}") > 0)) THEN
- ' we are only interested in closing brackets
- IF (ISTRUE kJson) THEN
- idShort = VAL(ExtractItemValue("data.card.idShort", Card))
- ELSE
- idShort = VAL(ExtractItemValue("idShort", Card))
- END IF
- StatusText = "Updating Card "& FORMAT$(idShort)
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, StatusText
- DIALOG DOEVENTS
- FileName = SectionPath &"\card-"& FORMAT$(idShort, "000") &".json"
- FileOut = FREEFILE
- OPEN FileName FOR APPEND AS FileOut
- FOR wIndex = 3 TO 9
- REPLACE ($TAB & FORMAT$(wIndex)) WITH ($CRLF & STRING$(wIndex, $TAB)) IN Card
- NEXT wIndex
- PRINT #FileOut, Card
- CLOSE FileOut
- Card = ""
- END IF
- LOOP
- CLOSE FileIn
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, "Done"
- END SUB
- FUNCTION ExtractItemValue(Hunter AS STRING, CardItem AS STRING) AS STRING
- LOCAL TiDx AS LONG
- LOCAL Results AS STRING
- Results = CardItem
- TiDx = INSTR(Results, "|"& Hunter &"|")
- IF (TiDx = 0) THEN
- ExtractItemValue = ""
- EXIT FUNCTION
- END IF
- Results = MID$(Results, TiDx)
- Results = PARSE$(Results, $TAB, 1)
- TiDx = INSTR(Results, ":")
- Results = MID$(Results, TiDx + 1)
- IF (RIGHT$(Results, 1) = ",") THEN
- Results = LEFT$(Results, LEN(Results) - 1)
- END IF
- ExtractItemValue = Results
- END FUNCTION
- FUNCTION ExtractDataBlock(Hunter AS STRING, CardItem AS STRING) AS STRING
- LOCAL TiDx AS LONG
- LOCAL Results AS STRING
- Results = CardItem
- TiDx = INSTR(Results, "|"& Hunter &"|")
- IF (TiDx = 0) THEN
- ExtractDataBlock = ""
- EXIT FUNCTION
- END IF
- Results = MID$(Results, TiDx)
- TiDx = INSTR(Results, "]")
- IF (TiDx = 0) THEN
- ExtractDataBlock = ""
- EXIT FUNCTION
- END IF
- Results = LEFT$(Results, TiDx)
- ExtractDataBlock = Results
- END FUNCTION
- FUNCTION ExtractSubDataBlock(Hunter AS STRING, CardItem AS STRING) AS STRING
- LOCAL TiDx AS LONG
- LOCAL Results AS STRING
- Results = CardItem
- TiDx = INSTR(Results, "|"& Hunter &"|")
- IF (TiDx = 0) THEN
- ExtractSubDataBlock = ""
- EXIT FUNCTION
- END IF
- Results = MID$(Results, TiDx)
- TiDx = INSTR(Results, "}")
- IF (TiDx = 0) THEN
- ExtractSubDataBlock = ""
- EXIT FUNCTION
- END IF
- Results = LEFT$(Results, TiDx)
- ExtractSubDataBlock = Results
- END FUNCTION
- SUB CreateCardList(hDlg AS DWORD, JsonFile AS STRING)
- LOCAL Cards(), Lists() AS STRING
- LOCAL CardIndex, idShort AS LONG
- LOCAL Work, FileName AS STRING
- LOCAL Details, cIndex AS LONG
- LOCAL SimpleList AS LONG
- LOCAL ThisId, StatusText AS STRING
- LOCAL shortUrl, idList AS STRING
- LOCAL CardName, CardDesc, CardDate AS STRING
- LOCAL UrlCardName AS STRING
- LOCAL DataBlock, CardLabels AS STRING
- LOCAL CardColor, CardList AS STRING
- LOCAL ListLabel, DoExtract AS LONG
- LOCAL WantList(), WantLabel() AS STRING
- LOCAL iCount, iCheck, iBump AS LONG
- LOCAL HasAttachment AS STRING
- REDIM WantList(0)
- REDIM WantLabel(0)
- IF (hCustom = 0) THEN
- StatusText = "Creating Card List"
- LISTBOX ADD hDlg, %IDLB_CARDS, StatusText
- ELSE
- WINDOW GET PARENT hCustom TO hDlg
- StatusText = "Creating Custom List"
- LISTBOX ADD hDlg, %IDLB_CARDS, StatusText
- ' if 1 then List first, Label second, else the other way
- CONTROL GET CHECK hCustom, %IDOPT_LISTORDER1 TO ListLabel
- DIALOG GET USER hCustom, 1 TO iCount
- iBump = 0
- FOR cIndex = 0 TO iCount
- CONTROL GET CHECK hCustom, %IDCK_LISTS + cIndex TO iCheck
- IF (iCheck <> 0) THEN
- CONTROL GET TEXT hCustom, %IDCK_LISTS + cIndex TO Work
- REDIM PRESERVE WantList(iBump)
- WantList(iBump) = Work
- INCR iBump
- END IF
- NEXT cIndex
- DIALOG GET USER hCustom, 2 TO iCount
- iBump = 0
- FOR cIndex = 0 TO iCount
- CONTROL GET CHECK hCustom, %IDCK_LABELS + cIndex TO iCheck
- IF (iCheck <> 0) THEN
- CONTROL GET TEXT hCustom, %IDCK_LABELS + cIndex TO Work
- REDIM PRESERVE WantLabel(iBump)
- WantLabel(iBump) = Work
- INCR iBump
- END IF
- NEXT cIndex
- DIALOG END hCustom
- hCustom = 0
- END IF
- CardIndex = 0
- REDIM Cards(CardIndex)
- StatusText = "Loading Cards"
- LISTBOX ADD hDlg, %IDLB_CARDS, StatusText
- DIALOG DOEVENTS
- FetchDataSet hDlg, JsonFile, "\cards.mbox", Cards()
- IF (UBOUND(Cards) = 0) THEN
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, "Failed Card Extraction"
- EXIT SUB
- END IF
- FOR CardIndex = 0 TO UBOUND(Cards)
- idShort = VAL(ExtractItemValue("idShort", Cards(CardIndex)))
- Cards(CardIndex) = FORMAT$(idShort, "000") & Cards(CardIndex)
- NEXT CardIndex
- ARRAY SORT Cards(), ASCEND
- REDIM Lists(0)
- StatusText = "Loading Lists"
- LISTBOX ADD hDlg, %IDLB_CARDS, StatusText
- DIALOG DOEVENTS
- FetchDataSet hDlg, JsonFile, "\lists.mbox", Lists()
- Details = FREEFILE
- FileName = JsonFile
- REPLACE ".json" WITH "-cardlist.htm" IN FileName
- OPEN FileName FOR OUTPUT AS Details
- PRINT #Details, "<head>"
- PRINT #Details, "<title>List of Trello Cards Ordered By ID</title>"
- PRINT #Details, "<style>"
- PRINT #Details, "<!--"
- PRINT #Details, ".green-label { background-color: #34B27D; width: 100% }"
- PRINT #Details, ".yellow-label { background-color: #DBDB57; width: 100% }"
- PRINT #Details, ".orange-label { background-color: #E09952; width: 100% }"
- PRINT #Details, ".red-label { background-color: #CB4D4D; width: 100% }"
- PRINT #Details, ".purple-label { background-color: #9933CC; width: 100% }"
- PRINT #Details, ".blue-label { background-color: #4D77CB; width: 100% }"
- PRINT #Details, "-->"
- PRINT #Details, "</style>"
- PRINT #Details, "</head>"
- PRINT #Details, "<body>"
- ' PRINT #Details, FormatHtml("<table border=|1| width=|100%|>")
- FOR CardIndex = 0 TO UBOUND(Cards)
- IF (LEN(Cards(CardIndex)) > 0) THEN
- ThisId = ExtractItemValue("idShort", Cards(CardIndex))
- StatusText = "Printing Card "& ThisID
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, StatusText
- DIALOG DOEVENTS
- CardLabels = "<br />"
- IF (ExtractItemValue("labels", Cards(CardIndex)) = "[") THEN
- DataBlock = ExtractDataBlock("labels", Cards(CardIndex))
- cIndex = 1 ' we break on the closing curly bracket
- DO
- Work = PARSE$(DataBlock, "}", cIndex)
- CardColor = Simple(ExtractItemValue("labels.color", Work))
- IF (LEN(CardColor) = 0) THEN EXIT DO
- CardLabels = CardLabels _
- &"<div class=|"& CardColor &"-label|>" _
- & Simple(ExtractItemValue("labels.name", Work)) &"</div>"
- INCR cIndex
- LOOP
- END IF
- idList = Simple(ExtractItemValue("idList", Cards(CardIndex)))
- CardList = "<br>List not found"
- FOR cIndex = 0 TO UBOUND(Lists)
- IF (idList = Simple(ExtractItemValue("id", Lists(cIndex)))) THEN
- CardList = "<br>"& Simple(ExtractItemValue("name", Lists(cIndex)))
- END IF
- NEXT cIndex
- IF ((LEN(WantList(0)) = 0) AND (LEN(WantLabel(0)) = 0)) THEN
- DoExtract = %TRUE
- ELSE
- DoExtract = %FALSE
- IF ((LEN(WantList(0)) = 0) OR (LEN(WantLabel(0)) = 0)) THEN
- ' order checking don't matter, it's either one or the other
- IF (LEN(WantList(0)) = 0) THEN
- ' it's the Labels we're checking
- FOR cIndex = 0 TO UBOUND(WantLabel)
- IF (INSTR(CardLabels, WantLabel(cIndex)) > 0) THEN
- DoExtract = %TRUE
- EXIT FOR
- END IF
- NEXT cIndex
- ELSE
- ' it's the List that we're checking
- FOR cIndex = 0 TO UBOUND(WantList)
- IF (INSTR(CardList, WantList(cIndex)) > 0) THEN
- DoExtract = %TRUE
- EXIT FOR
- END IF
- NEXT cIndex
- END IF
- ELSE
- ' order checking matters, if not found in the first desired, exit false
- IF (ListLabel = 0) THEN ' labels then lists
- FOR cIndex = 0 TO UBOUND(WantLabel)
- IF (INSTR(CardLabels, WantLabel(cIndex)) > 0) THEN
- EXIT FOR
- END IF
- NEXT cIndex
- IF (cIndex <= UBOUND(WantLabel)) THEN
- FOR cIndex = 0 TO UBOUND(WantList)
- IF (INSTR(CardList, WantList(cIndex)) > 0) THEN
- DoExtract = %TRUE
- EXIT FOR
- END IF
- NEXT cIndex
- END IF
- ELSE ' lists then labels
- FOR cIndex = 0 TO UBOUND(WantList)
- IF (INSTR(CardList, WantList(cIndex)) > 0) THEN
- EXIT FOR
- END IF
- NEXT cIndex
- IF (cIndex <= UBOUND(WantList)) THEN
- FOR cIndex = 0 TO UBOUND(WantLabel)
- IF (INSTR(CardLabels, WantLabel(cIndex)) > 0) THEN
- DoExtract = %TRUE
- EXIT FOR
- END IF
- NEXT cIndex
- END IF
- END IF
- END IF
- END IF
- IF (ISTRUE DoExtract) THEN
- shortUrl = Simple(ExtractItemValue("shortUrl", Cards(CardIndex)))
- CardName = PrintPretty(Simple(ExtractItemValue("name", Cards(CardIndex))))
- CardDesc = PrintPretty(ExtractItemValue("desc", Cards(CardIndex)))
- CardDate = WindowsTime(Simple(ExtractItemValue("dateLastActivity", Cards(CardIndex))))
- UrlCardName = "<a href=|"& shortUrl &"| target=|trello|>"& CardName &"</a>"
- HasAttachment = Simple(ExtractItemValue("idAttachmentCover", Cards(CardIndex)))
- IF (LEN(HasAttachment) > 0) THEN
- IF (HasAttachment <> "null")THEN
- HasAttachment = "<br />[IMG]"
- ELSE
- HasAttachment = ""
- END IF
- END IF
- ' IF ((UCASE$(Simple(ExtractItemValue("closed", Cards(CardIndex)))) = "TRUE") AND (LEN(HasAttachment) > 0)) THEN
- PRINT #Details, "<hr />"
- PRINT #Details, FormatHtml("<table border=|1| width=|100%|>")
- PRINT #Details, "<tr>"
- PRINT #Details, FormatHtml("<td width=|10%| valign=|top|>Card: "& ThisId & CardLabels & CardList & HasAttachment &"</td>")
- IF (UCASE$(Simple(ExtractItemValue("closed", Cards(CardIndex)))) = "TRUE") THEN
- PRINT #Details, FormatHtml("<td width=|90%| valign=|top| bgcolor=|#C790BA|>ARCHIVED "& CardDate &" - "& UrlCardName &"<br>")
- ELSE
- PRINT #Details, FormatHtml("<td width=|90%| valign=|top|>"& CardDate &" - "& UrlCardName &"<br>")
- END IF
- IF (LEN(CardDesc) > 0) THEN
- PRINT #Details, FormatHtml("Desc: "& CardDesc &"</td>")
- PRINT #Details, "</tr>"
- ELSE
- PRINT #Details, "</td>"
- PRINT #Details, "</tr>"
- END IF
- PRINT #Details, "</table>"
- ' PRINT #SimpleList, FormatHtml("<table border=|1| width=|100%|>")
- ' PRINT #SimpleList, "<tr>"
- ' PRINT #SimpleList, FormatHtml("<td width=|10%| valign=|top|>Bug #"& ThisId & CardList &"</td>")
- ' PRINT #SimpleList, FormatHtml("<td width=|90%| valign=|top|>"& CardDate &" - "& CardName &"</td></tr>")
- ' PRINT #SimpleList, "</table>"
- ' PRINT #SimpleList, "<hr />"
- ' END IF
- END IF
- END IF
- NEXT CardIndex
- PRINT #Details, "</body>"
- CLOSE Details
- FetchDataSet hDlg, JsonFile, "\cards.mbox", Cards()
- ARRAY SORT Cards(), ASCEND
- SimpleList = FREEFILE
- FileName = JsonFile
- REPLACE ".json" WITH "-simplelist.htm" IN FileName
- OPEN FileName FOR OUTPUT AS SimpleList
- PRINT #SimpleList, "<head>"
- PRINT #SimpleList, "<title>Simple Bug List</title>"
- PRINT #SimpleList, "</head>"
- PRINT #SimpleList, "<body>"
- FOR cIndex = 0 TO UBOUND(Lists)
- FOR CardIndex = 0 TO UBOUND(Cards)
- IF (LEN(Cards(CardIndex)) > 0) THEN
- ThisId = ExtractItemValue("idShort", Cards(CardIndex))
- idList = Simple(ExtractItemValue("idList", Cards(CardIndex)))
- IF (idList = Simple(ExtractItemValue("id", Lists(cIndex)))) THEN
- StatusText = "Printing Card "& ThisID
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, StatusText
- DIALOG DOEVENTS
- CardList = "<br>"& Simple(ExtractItemValue("name", Lists(cIndex)))
- CardDate = WindowsTime(Simple(ExtractItemValue("dateLastActivity", Cards(CardIndex))))
- CardName = PrintPretty(Simple(ExtractItemValue("name", Cards(CardIndex))))
- PRINT #SimpleList, FormatHtml("Bug #"& ThisId & CardList &"<br />")
- PRINT #SimpleList, FormatHtml(CardDate &" - "& CardName &"<br />")
- PRINT #SimpleList, "<br />"
- Cards(CardIndex) = ""
- END IF
- END IF
- NEXT CardIndex
- NEXT cIndex
- PRINT #SimpleList, "</body>"
- CLOSE SimpleList
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, "Done"
- END SUB
- SUB ExtractRecentActions(hDlg AS LONG, JsonFile AS STRING)
- LOCAL FileIn, FileOut, Depth AS LONG
- LOCAL LineCount, cIndex, cCount AS LONG
- LOCAL ActionIndex, CardIndex AS LONG
- LOCAL ActionCount, CheckIndex AS LONG
- LOCAL idShort, exOut, upDone AS LONG
- LOCAL CardID, ThisID, idList AS STRING
- LOCAL Cards(), Actions() AS STRING
- LOCAL CheckLists(), Lists() AS STRING
- LOCAL Work, FileName AS STRING
- LOCAL rFix, nFix, shortUrl AS STRING
- LOCAL SectionPath AS STRING
- LOCAL Char, Opener, Prefix AS STRING
- LOCAL StatusText, Card AS STRING
- LOCAL Extraction AS LONG ' boolean value
- LOCAL CardType, CardText, CardUser AS STRING
- LOCAL CardDate, ListBefore, ListAfter AS STRING
- LOCAL CardDesc, CardName, CardData AS STRING
- LOCAL CardAttachment, CardAttachmentURL AS STRING
- LOCAL CardChecklist, CardCheckID AS STRING
- LOCAL CardCheckState, CardList AS STRING
- LOCAL CardLabels, DataBlock, CardColor AS STRING
- LOCAL HasAttachment, CardStat1, CardStat2 AS STRING
- SectionPath = PATHNAME$(PATH, JsonFile) & PATHNAME$(NAME, JsonFile)
- ActionIndex = 0
- REDIM Actions(ActionIndex)
- FetchDataSet hDlg, JsonFile, "\actions.mbox", Actions()
- IF (UBOUND(Actions) = 0) THEN
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, "Failed Action Extraction"
- EXIT SUB
- END IF
- FOR ActionIndex = 0 TO UBOUND(Actions)
- Actions(ActionIndex) = ExtractItemValue("date", Actions(ActionIndex)) & Actions(ActionIndex)
- NEXT ActionIndex
- ARRAY SORT Actions(), DESCEND
- CardIndex = 0
- REDIM Cards(CardIndex)
- FetchDataSet hDlg, JsonFile, "\cards.mbox", Cards()
- IF (UBOUND(Cards) = 0) THEN
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, "Failed Card Extraction"
- EXIT SUB
- END IF
- FOR CardIndex = 0 TO UBOUND(Cards)
- idShort = VAL(ExtractItemValue("idShort", Cards(CardIndex)))
- Cards(CardIndex) = FORMAT$(idShort, "000") & Cards(CardIndex)
- NEXT CardIndex
- ARRAY SORT Cards(), ASCEND
- REDIM CheckLists(0)
- FetchDataSet hDlg, JsonFile, "\checklists.mbox", CheckLists()
- REDIM Lists(0)
- FetchDataSet hDlg, JsonFile, "\lists.mbox", Lists()
- FileOut = FREEFILE
- FileName = PATHNAME$(PATH, JsonFile) &"actions.txt"
- OPEN FileName FOR OUTPUT AS FileOut
- PRINT #FileOut, Actions()
- CLOSE FileOut
- FileOut = FREEFILE
- FileName = PATHNAME$(PATH, JsonFile) &"cards.txt"
- OPEN FileName FOR OUTPUT AS FileOut
- PRINT #FileOut, Cards()
- CLOSE FileOut
- FileOut = FREEFILE
- FileName = PATHNAME$(PATH, JsonFile) &"checklists.txt"
- OPEN FileName FOR OUTPUT AS FileOut
- PRINT #FileOut, CheckLists()
- CLOSE FileOut
- StatusText = "Creating Recent"
- LISTBOX ADD hDlg, %IDLB_CARDS, StatusText
- DIALOG DOEVENTS
- ActionCount = 0
- FileOut = FREEFILE
- FileName = JsonFile
- REPLACE ".json" WITH ".htm" IN FileName
- OPEN FileName FOR OUTPUT AS FileOut
- exOut = FREEFILE
- FileName = PATHNAME$(PATH, JsonFile) &"actions-used.txt"
- OPEN FileName FOR OUTPUT AS exOut
- PRINT #FileOut, "<head>"
- PRINT #FileOut, "<title>Recent Activity</title>"
- PRINT #FileOut, "<style>"
- PRINT #FileOut, "<!--"
- PRINT #FileOut, ".green-label { background-color: #34B27D; width: 100% }"
- PRINT #FileOut, ".yellow-label { background-color: #DBDB57; width: 100% }"
- PRINT #FileOut, ".orange-label { background-color: #E09952; width: 100% }"
- PRINT #FileOut, ".red-label { background-color: #CB4D4D; width: 100% }"
- PRINT #FileOut, ".purple-label { background-color: #9933CC; width: 100% }"
- PRINT #FileOut, ".blue-label { background-color: #4D77CB; width: 100% }"
- PRINT #FileOut, "-->"
- PRINT #FileOut, "</style>"
- PRINT #FileOut, "</head>"
- PRINT #FileOut, "<body>"
- PRINT #FileOut, FormatHtml("<table border=|1| width=|100%|>")
- DO
- Extraction = %TRUE
- ThisID = ""
- FOR ActionIndex = 0 TO UBOUND(Actions)
- IF (LEN(Actions(ActionIndex)) > 0) THEN
- CardType = ExtractItemValue("type", Actions(ActionIndex))
- idShort = VAL(ExtractItemValue("data.card.idShort", Actions(ActionIndex)))
- CardID = ExtractItemValue("data.card.id", Actions(ActionIndex))
- IF (idShort = 425) THEN
- idShort = idShort
- END IF
- IF ((ThisID = "") OR (ThisID = CardID)) THEN
- Work = Actions(ActionIndex)
- REPLACE $TAB WITH $CRLF & $TAB IN Work
- PRINT #exOut, Work
- IF (ThisId = "") THEN
- PRINT #FileOut, "</table>"
- PRINT #FileOut, "<hr />"
- PRINT #FileOut, FormatHtml("<table border=|1| width=|100%|>")
- FOR CardIndex = 0 TO UBOUND(Cards)
- ThisId = ExtractItemValue("id", Cards(CardIndex))
- IF (ThisID = CardID) THEN
- shortUrl = Simple(ExtractItemValue("shortUrl", Cards(CardIndex)))
- ' don't strip this, cannot use simple
- ' CardName = PrintPretty(Simple(ExtractItemValue("name", Cards(CardIndex))))
- CardName = PrintPretty(ExtractItemValue("name", Cards(CardIndex)))
- CardDesc = PrintPretty(ExtractItemValue("desc", Cards(CardIndex)))
- CardDate = WindowsTime(Simple(ExtractItemValue("dateLastActivity", Cards(CardIndex))))
- CardName = "<a href=|"& shortUrl &"| target=|trello|>"& CardName &"</a>"
- CardLabels = ""
- IF (ExtractItemValue("labels", Cards(CardIndex)) = "[") THEN
- DataBlock = ExtractDataBlock("labels", Cards(CardIndex))
- CardLabels = "<br />"
- cIndex = 1 ' we break on the closing curly bracket
- DO
- Work = PARSE$(DataBlock, "}", cIndex)
- CardColor = Simple(ExtractItemValue("labels.color", Work))
- IF (LEN(CardColor) = 0) THEN EXIT DO
- CardLabels = CardLabels _
- &"<div class=|"& CardColor &"-label|>" _
- & Simple(ExtractItemValue("labels.name", Work)) &"</div>"
- INCR cIndex
- LOOP
- END IF
- idList = Simple(ExtractItemValue("idList", Cards(CardIndex)))
- CardList = "<br>List not found"
- FOR cIndex = 0 TO UBOUND(Lists)
- IF (idList = Simple(ExtractItemValue("id", Lists(cIndex)))) THEN
- CardList = "<br>"& Simple(ExtractItemValue("name", Lists(cIndex)))
- END IF
- NEXT cIndex
- HasAttachment = Simple(ExtractItemValue("idAttachmentCover", Cards(CardIndex)))
- IF (LEN(HasAttachment) > 0) THEN
- IF (HasAttachment <> "null")THEN
- HasAttachment = "<br />[IMG]"
- ELSE
- HasAttachment = ""
- END IF
- END IF
- PRINT #FileOut, "<tr>"
- IF (UCASE$(Simple(ExtractItemValue("closed", Cards(CardIndex)))) = "TRUE") THEN
- CardStat1 = "<td width=|10%| valign=|top| bgcolor=|#C790BA|>ARCHIVED: "
- CardStat2 = "<td width=|90%| valign=|top| bgcolor=|#C790BA|>"
- ELSE
- CardStat1 = "<td width=|10%| valign=|top|>Card: "
- CardStat2 = "<td width=|90%| valign=|top|>"
- END IF
- PRINT #FileOut, FormatHtml(CardStat1 & FORMAT$(idShort) & CardLabels & CardList & HasAttachment &"</td>")
- PRINT #FileOut, FormatHtml(CardStat2 & CardDate &" - "& CardName &"<br>")
- IF (LEN(CardDesc) > 0) THEN
- PRINT #FileOut, FormatHtml("Desc: "& CardDesc &"</td>")
- PRINT #FileOut, "</tr>"
- ELSE
- PRINT #FileOut, "</td>"
- PRINT #FileOut, "</tr>"
- END IF
- Cards(CardIndex) = ""
- ActionCount = 0
- EXIT FOR
- END IF
- NEXT CardIndex
- END IF
- INCR ActionCount
- StatusText = "Printing Card "& FORMAT$(idShort) &"."& FORMAT$(ActionCount)
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, StatusText
- DIALOG DOEVENTS
- ThisID = CardID
- Extraction = %FALSE
- CardType = ExtractItemValue("type", Actions(ActionIndex))
- CardUser = Simple(ExtractItemValue("memberCreator.fullName", Actions(ActionIndex)))
- CardName = PrintPretty(Simple(ExtractItemValue("data.card.name", Actions(ActionIndex))))
- CardDate = WindowsTime(Simple(ExtractItemValue("date", Actions(ActionIndex))))
- SELECT CASE CardType
- CASE "|addAttachmentToCard|"
- CardAttachmentUrl = Simple(ExtractItemValue("data.attachment.url", Actions(ActionIndex)))
- CardAttachment = Simple(ExtractItemValue("data.attachment.name", Actions(ActionIndex)))
- Work = "<a href=|"& CardAttachmentUrl &"| target=|trello|>"& CardAttachment &"</a>"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- IF (LEN(CardAttachmentUrl) > 0) THEN
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" attached "& Work &"</td>")
- ELSE
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" attached <strike>"& CardAttachment &"</strike></td>")
- END IF
- PRINT #FileOut, "</tr>"
- CASE "|addChecklistToCard|"
- CardData = ExtractItemValue("data.checklist.name", Actions(ActionIndex))
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- PRINT #FileOut, FormatHtml("<br>"& CardUser &" Added Checklist "& CardData)
- CardCheckID = ExtractItemValue("data.checklist.id", Actions(ActionIndex))
- FOR CheckIndex = 0 TO UBOUND(CheckLists)
- IF (ExtractItemValue("id", CheckLists(CheckIndex)) = CardCheckID) THEN
- PRINT #FileOut, "<ul>"
- cCount = PARSECOUNT(CheckLists(CheckIndex), $TAB)
- FOR cIndex = 1 TO cCount
- CardCheckList = PARSE$(CheckLists(CheckIndex), $TAB, cIndex)
- Work = Simple(ExtractItemValue("checkItems.state", CardCheckList))
- IF (LEN(Work) > 0) THEN
- CardCheckState = Work
- END IF
- Work = PrintPretty(ExtractItemValue("checkItems.name", CardCheckList))
- IF (LEN(Work) > 0) THEN
- IF (CardCheckState = "complete") THEN
- PRINT #FileOut, FormatHtml("<li type=|square|>"& Work)
- ELSE
- PRINT #FileOut, FormatHtml("<li type=|circle|>"& Work)
- END IF
- END IF
- NEXT cIndex
- PRINT #FileOut, "</ul>"
- EXIT FOR
- END IF
- NEXT CheckIndex
- IF (CheckIndex > UBOUND(CheckLists)) THEN
- PRINT #FileOut, "<ul>"
- PRINT #FileOut, "<li>Check List NOT Found"
- PRINT #FileOut, "</ul>"
- END IF
- PRINT #FileOut, "</td>"
- PRINT #FileOut, "</tr>"
- CASE "|addMemberToBoard|"
- ' this should not be found
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Added Member To Board</td>")
- CASE "|addMemberToCard|"
- CardUser = Simple(ExtractItemValue("memberCreator.fullName", Actions(ActionIndex)))
- CardData = Simple(ExtractItemValue("member.fullName", Actions(ActionIndex)))
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- IF (CardUser = CardData) THEN
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Joined Card</td>")
- ELSE
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" added "& CardData &"</td>")
- END IF
- PRINT #FileOut, "</tr>"
- CASE "|commentCard|"
- CardText = PrintPretty(ExtractItemValue("data.text", Actions(ActionIndex)))
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName &"<br>")
- PRINT #FileOut, FormatHtml("Comment: "& CardUser)
- PRINT #FileOut, FormatHtml("<p>"& CardText &"</p>")
- PRINT #FileOut, "</td>"
- PRINT #FileOut, "</tr>"
- CASE "|copyCard|"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- CardAttachment = "From: "& _
- Simple(ExtractItemValue("data.cardSource.idShort", Actions(ActionIndex))) _
- &" To "& _
- Simple(ExtractItemValue("data.card.idShort", Actions(ActionIndex)))
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Copied Comment "& CardAttachment &"</td>")
- PRINT #FileOut, "</tr>"
- CASE "|copyCommentCard|"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Copied Card</td>")
- PRINT #FileOut, "</tr>"
- CASE "|createCard|"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Created Card</td>")
- PRINT #FileOut, "</tr>"
- CASE "|deleteAttachmentFromCard|"
- CardAttachment = Simple(ExtractItemValue("data.attachment.name", Actions(ActionIndex)))
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" deleted "& CardAttachment &"</td>")
- PRINT #FileOut, "</tr>"
- CASE "|disablePowerUp|"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- CardAttachment = Simple(ExtractItemValue("data.value", Actions(ActionIndex)))
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Disabled Powerup "& CardAttachment &"</td>")
- PRINT #FileOut, "</tr>"
- CASE "|moveCardFromBoard|"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- CardAttachment = Simple(ExtractItemValue("data.boardTarget.name", Actions(ActionIndex)))
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Moved Card To Board "& CardAttachment &"</td>")
- PRINT #FileOut, "</tr>"
- CASE "|moveCardToBoard|"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- CardAttachment = Simple(ExtractItemValue("data.boardSource.name", Actions(ActionIndex)))
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Moved Card From Board "& CardAttachment &"</td>")
- PRINT #FileOut, "</tr>"
- CASE "|removeChecklistFromCard|"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- CardData = ExtractItemValue("data.checklist.name", Actions(ActionIndex))
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Checklist "& CardData &"</td>")
- PRINT #FileOut, "</tr>"
- CASE "|removeMemberFromCard|"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- CardAttachment = Simple(ExtractItemValue("member.fullName", Actions(ActionIndex)))
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Removed Member From Card: "& CardAttachment &"</td>")
- PRINT #FileOut, "</tr>"
- CASE "|updateBoard|"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- CardAttachment = "From: "& _
- Simple(ExtractItemValue("data.old.prefs.cardAging", Actions(ActionIndex))) _
- &" To "& _
- Simple(ExtractItemValue("data.board.prefs.cardAging", Actions(ActionIndex)))
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Updated Board "& CardAttachment &"</td>")
- PRINT #FileOut, "</tr>"
- CASE "|updateCard|"
- upDone = %TRUE
- ListAfter = Simple(ExtractItemValue("data.listAfter.name", Actions(ActionIndex)))
- IF (LEN(ListAfter) > 0) THEN
- ListBefore = Simple(ExtractItemValue("data.listBefore.name", Actions(ActionIndex)))
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Moved Card To "& ListAfter &"</td>")
- PRINT #FileOut, "</tr>"
- upDone = %FALSE
- END IF
- ListAfter = Simple(ExtractItemValue("data.old.name", Actions(ActionIndex)))
- IF (LEN(ListAfter) > 0) THEN
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Edited the Card Name</td>")
- PRINT #FileOut, "</tr>"
- upDone = %FALSE
- END IF
- ListAfter = Simple(ExtractItemValue("data.old.desc", Actions(ActionIndex)))
- IF (INSTR(Actions(ActionIndex), "|data.old.desc|") > 0) THEN
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Edited the Card Description</td>")
- PRINT #FileOut, "</tr>"
- upDone = %FALSE
- END IF
- ListAfter = Simple(ExtractItemValue("data.old.pos", Actions(ActionIndex)))
- IF (LEN(ListAfter) > 0) THEN
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Edited the Card Position</td>")
- PRINT #FileOut, "</tr>"
- upDone = %FALSE
- END IF
- ListAfter = Simple(ExtractItemValue("data.old.closed", Actions(ActionIndex)))
- IF (LEN(ListAfter) > 0) THEN
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- ListAfter = Simple(ExtractItemValue("data.card.closed", Actions(ActionIndex)))
- IF (UCASE$(ListAfter) = "TRUE") THEN
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Closed This Card</td>")
- ELSE
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Reopened This Card</td>")
- END IF
- PRINT #FileOut, "</tr>"
- upDone = %FALSE
- END IF
- IF (ISTRUE upDone) THEN
- CardData = Simple(ExtractItemValue("id", Actions(ActionIndex)))
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" updated something "& CardData &"</td>")
- PRINT #FileOut, "</tr>"
- END IF
- ' Work = Simple(ExtractItemValue("data.card.closed", Actions(ActionIndex)))
- ' IF (Work = "true") THEN
- ' PRINT #FileOut, "<tr>"
- ' PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- ' PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- ' PRINT #FileOut, FormatHtml(" --- "& CardUser &" Closed this card.</td>")
- ' PRINT #FileOut, "</tr>"
- ' END IF
- CASE "|updateCheckItemStateOnCard|"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- CardData = Simple(ExtractItemValue("data.card.name", Actions(ActionIndex)))
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Updated Check Item State "& CardData &"</td>")
- PRINT #FileOut, "</tr>"
- CASE "|updateChecklist|"
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- CardData = Simple(ExtractItemValue("data.card.name", Actions(ActionIndex)))
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Updated Checklist "& CardData &"</td>")
- PRINT #FileOut, "</tr>"
- CASE "|updateList|"
- CardData = ExtractItemValue("data.checklist.name", Actions(ActionIndex))
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& FORMAT$(idShort) &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate) ' &" - "& CardName)
- PRINT #FileOut, FormatHtml(" --- "& CardUser &" Updated Checklist "& CardData &"</td>")
- PRINT #FileOut, "</tr>"
- END SELECT
- Actions(ActionIndex) = ""
- END IF
- END IF
- NEXT ActionIndex
- IF (ISTRUE Extraction) THEN EXIT DO
- LOOP
- PRINT #FileOut, "</table>"
- ' extract cards that have no recent actions
- FOR CardIndex = 0 TO UBOUND(Cards)
- IF (LEN(Cards(CardIndex)) > 0) THEN
- PRINT #FileOut, "<hr />"
- PRINT #FileOut, FormatHtml("<table border=|1| width=|100%|>")
- ThisId = ExtractItemValue("idShort", Cards(CardIndex))
- StatusText = "Printing Card "& ThisID &".0"
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, StatusText
- shortUrl = Simple(ExtractItemValue("shortUrl", Cards(CardIndex)))
- CardName = PrintPretty(Simple(ExtractItemValue("name", Cards(CardIndex))))
- CardDesc = PrintPretty(ExtractItemValue("desc", Cards(CardIndex)))
- CardDate = WindowsTime(Simple(ExtractItemValue("dateLastActivity", Cards(CardIndex))))
- CardName = "<a href=|"& shortUrl &"| target=|trello|>"& CardName &"</a>"
- IF (ExtractItemValue("labels", Cards(CardIndex)) = "[") THEN
- DataBlock = ExtractDataBlock("labels", Cards(CardIndex))
- CardLabels = "<br />"
- cIndex = 1 ' we break on the closing curly bracket
- DO
- Work = PARSE$(DataBlock, "}", cIndex)
- CardColor = Simple(ExtractItemValue("labels.color", Work))
- IF (LEN(CardColor) = 0) THEN EXIT DO
- CardLabels = CardLabels _
- &"<div class=|"& CardColor &"-label|>" _
- & Simple(ExtractItemValue("labels.name", Work)) &"</div>"
- INCR cIndex
- LOOP
- END IF
- PRINT #FileOut, "<tr>"
- PRINT #FileOut, FormatHtml("<td width=|10%| valign=|top|>Card: "& ThisId & CardLabels &"</td>")
- PRINT #FileOut, FormatHtml("<td width=|90%| valign=|top|>"& CardDate &" - "& CardName &"<br>")
- IF (LEN(CardDesc) > 0) THEN
- PRINT #FileOut, FormatHtml("Desc: "& CardDesc &"</td>")
- PRINT #FileOut, "</tr>"
- ELSE
- PRINT #FileOut, "</td>"
- PRINT #FileOut, "</tr>"
- END IF
- Cards(CardIndex) = ""
- PRINT #FileOut, "</table>"
- END IF
- NEXT CardIndex
- PRINT #FileOut, "</body>"
- CLOSE FileOut
- CLOSE exOut
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, "Done"
- END SUB
- FUNCTION FormatHtml(Work AS STRING) AS STRING
- DIM Results AS STRING
- Results = Work
- REPLACE CHR$(34) WITH """ IN Results
- REPLACE "|" WITH CHR$(34) IN Results
- REPLACE $CRLF WITH "<br />"& $CRLF IN Results
- REPLACE "<p></p>" WITH ""& $CRLF IN Results
- FormatHtml = Results
- END FUNCTION
- FUNCTION Simple(CardItem AS STRING) AS STRING
- LOCAL Results AS STRING
- Results = CardItem
- REPLACE "<" WITH "<" IN Results
- REPLACE ">" WITH ">" IN Results
- REPLACE "|" WITH "" IN Results
- Simple = Results
- END FUNCTION
- FUNCTION PrintPretty(CardItem AS STRING) AS STRING
- ' this is where all the parsing and making pretty happen for those cards that need it
- LOCAL Results AS STRING
- ' strip trailing comma
- Results = CardItem
- IF (RIGHT$(Results, 1) = ",") THEN
- Results = LEFT$(Results, LEN(Results) - 1)
- END IF
- ' convert escaped elements
- IF (INSTR(Results, "\") > 0) THEN
- REPLACE "\n" WITH $CRLF IN Results
- REPLACE "\|" WITH """ IN Results
- REPLACE "\\`" WITH "`" IN Results
- REPLACE "\\@" WITH "@" IN Results
- REPLACE "\\#" WITH "#" IN Results
- REPLACE "\\*" WITH "*" IN Results
- REPLACE "\\" WITH "\" IN Results
- END IF
- PrintPretty = Simple(Results)
- END FUNCTION
- FUNCTION EnumerateItemNames(Hunter AS STRING, CardItem AS STRING, PriorHunter AS STRING) AS STRING
- LOCAL Work AS STRING
- LOCAL TiDx AS LONG
- Work = CardItem
- IF (LEN(PriorHunter) > 0) THEN
- TiDx = INSTR(Work, PriorHunter)
- Work = MID$(Work, TiDx + LEN(PriorHunter))
- END IF
- TiDx = INSTR(Work, "|"& Hunter)
- IF (TiDx = 0) THEN
- EnumerateItemNames = ""
- EXIT FUNCTION
- END IF
- Work = MID$(Work, TiDx)
- Work = PARSE$(Work, $TAB, 1)
- TiDx = INSTR(Work, ":")
- Work = LEFT$(Work, TiDx - 1)
- EnumerateItemNames = Work
- END FUNCTION
- SUB AnalyzeActions(hDlg AS LONG, JsonFile AS STRING)
- LOCAL FileOut AS LONG
- LOCAL ActionIndex AS LONG
- LOCAL ActionNames() AS STRING
- LOCAL ActionsSorted() AS STRING
- LOCAL Work, FileName AS STRING
- LOCAL ActionTypes, Samples AS STRING
- LOCAL StatusText AS STRING
- LOCAL CardType, Hunter, PriorHunter AS STRING
- ActionIndex = 0
- REDIM ActionNames(ActionIndex)
- FetchDataSet hDlg, JsonFile, "\actions.mbox", ActionNames()
- IF (UBOUND(ActionNames) = 0) THEN
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, "Failed Action Extraction"
- END IF
- FOR ActionIndex = 0 TO UBOUND(ActionNames)
- StatusText = "Analyzing Action "& FORMAT$(ActionIndex)
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, StatusText
- DIALOG DOEVENTS
- CardType = ExtractItemValue("type", ActionNames(ActionIndex))
- IF (INSTR(ActionTypes, CardType) = 0) THEN
- ActionTypes = ActionTypes & CardType
- END IF
- IF (CardType = "|updateCard|") THEN
- Hunter = "data"
- PriorHunter = ""
- DO
- Work = EnumerateItemNames(Hunter, ActionNames(ActionIndex), PriorHunter)
- IF (LEN(Work) = 0) THEN EXIT DO
- PriorHunter = Work
- IF (INSTR(Samples, Work) = 0) THEN
- Samples = Samples & Work &":"& ExtractItemValue(Simple(Work), ActionNames(ActionIndex)) & $TAB
- END IF
- LOOP
- END IF
- NEXT ActionIndex
- FileOut = FREEFILE
- FileName = PATHNAME$(PATH, JsonFile) &"analyze.txt"
- OPEN FileName FOR OUTPUT AS FileOut
- REPLACE "||" WITH "|"& $TAB &"|" IN ActionTypes
- ActionIndex = PARSECOUNT(ActionTypes, $TAB)
- REDIM ActionsSorted(ActionIndex - 1)
- PARSE ActionTypes, ActionsSorted(), $TAB
- ARRAY SORT ActionsSorted()
- FOR ActionIndex = 0 TO UBOUND(ActionsSorted)
- Work = ActionsSorted(ActionIndex)
- IF (LEN(Work) > 0) THEN
- PRINT #FileOut, Work
- END IF
- NEXT ActionIndex
- ActionIndex = 1
- DO
- Work = PARSE$(Samples, $TAB, ActionIndex)
- IF (LEN(Work) = 0) THEN EXIT DO
- PRINT #FileOut, Work
- INCR ActionIndex
- LOOP
- CLOSE FileOut
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, "Done"
- END SUB
- SUB FetchDataSet(hDlg AS DWORD, JsonFile AS STRING, BoxName AS STRING, BYREF DataItems() AS STRING)
- LOCAL FileIn, DataIndex, Depth AS LONG
- LOCAL wIndex, idShort AS LONG
- LOCAL StatusText AS STRING
- LOCAL SectionPath, Work, Card AS STRING
- LOCAL nFix, Prefix, Char, Opener AS STRING
- SectionPath = PATHNAME$(PATH, JsonFile) & PATHNAME$(NAME, JsonFile)
- FileIn = FREEFILE
- OPEN SectionPath & BoxName FOR INPUT AS FileIn
- ' dispose of first item, do until depth=2
- LINE INPUT #FileIn, Work
- StatusText = "Reading "& BoxName
- LISTBOX ADD hDlg, %IDLB_CARDS, StatusText
- DIALOG DOEVENTS
- DataIndex = 0
- REDIM DataItems(DataIndex)
- DO
- LINE INPUT #FileIn, Work
- Depth = VAL(Work)
- IF (Depth = 2) THEN EXIT DO
- Work = TRIM$(MID$(Work, 2))
- REPLACE CHR$(34) WITH "|" IN Work
- nFix = PARSE$(Work, "|", 2)
- REPLACE "|"& nFix WITH "|"& Prefix & nFix IN Work
- Char = RIGHT$(Work, 1)
- IF ((Char = ":") OR (Char = "[")) THEN
- Prefix = Prefix & nFix &"."
- Opener = Opener & Char
- END IF
- Char = LEFT$(Work, 1)
- IF ((Char = "]") AND (RIGHT$(Opener, 1) = "[") AND (Depth > 3)) THEN
- IF (LEN(Prefix) > 0) THEN
- wIndex = PARSECOUNT(Prefix, ".")
- Char = PARSE$(Prefix, ".", wIndex - 1) &"."
- REPLACE Char WITH "" IN Prefix
- Opener = LEFT$(Opener, LEN(Opener) - 1)
- END IF
- END IF
- IF ((Char = "}") AND (RIGHT$(Opener, 1) = ":") AND (Depth > 3)) THEN
- IF (LEN(Prefix) > 0) THEN
- wIndex = PARSECOUNT(Prefix, ".")
- Char = PARSE$(Prefix, ".", wIndex - 1) &"."
- REPLACE Char WITH "" IN Prefix
- Opener = LEFT$(Opener, LEN(Opener) - 1)
- END IF
- END IF
- Card = Card & $TAB & Work
- IF ((Depth = 3) AND (INSTR(Work, "}") > 0)) THEN
- ' we are only interested in closing brackets
- StatusText = "Reading "& BoxName &": "& FORMAT$(DataIndex)
- STATUSBAR SET TEXT hDlg, %IDSB_STATUS, 1, 0, StatusText
- DIALOG DOEVENTS
- REDIM PRESERVE DataItems(DataIndex)
- DataItems(DataIndex) = Card
- INCR DataIndex
- Card = ""
- END IF
- LOOP
- CLOSE FileIn
- END SUB
- FUNCTION GetUtcOffSet(Adjust AS LONG) AS QUAD
- LOCAL tzTime AS TIME_ZONE_INFORMATION
- LOCAL iResult AS LONG
- LOCAL oTime, kTime AS QUADTODOUBLE
- LOCAL sTime AS SYSTEMTIME
- LOCAL Work AS STRING
- iResult = GetTimeZoneInformation(tzTime)
- GetLocalTime sTime
- sTime.wHour = Adjust
- iResult = SystemTimeToFileTime(sTime, kTime.iParts)
- Work = "Offset From UTC: "& FORMAT$(tzTime.Bias)
- sTime.wHour = (tzTime.Bias / 60)
- iResult = SystemTimeToFileTime(sTime, oTime.iParts)
- GetUtcOffSet = oTime.iQuad - kTime.iQuad
- END FUNCTION
- FUNCTION MakeReadableTime(uTime AS QUAD) AS STRING
- LOCAL sTime AS SYSTEMTIME
- LOCAL hTime AS QUADTODOUBLE
- LOCAL iResult AS LONG
- LOCAL Work AS STRING
- hTime.iQuad = uTime
- iResult = FileTimeToSystemTime(hTime.iParts, sTime)
- Work = FORMAT$(sTime.wMonth)
- Work = Work &"/"& FORMAT$(sTime.wDay)
- Work = Work &"/"& FORMAT$(sTime.wYear)
- Work = Work &" "& FORMAT$(sTime.wHour, "00")
- Work = Work &":"& FORMAT$(sTime.wMinute, "00")
- Work = Work &":"& FORMAT$(sTime.wSecond, "00")
- MakeReadableTime = Work
- END FUNCTION
- FUNCTION WindowsTime(UtcTime AS STRING) AS STRING
- ' 2013-11-16T04:34:44.891Z
- LOCAL sTime AS SYSTEMTIME
- LOCAL hTime AS QUADTODOUBLE
- LOCAL iResult AS LONG
- LOCAL Work AS STRING
- sTime.wYear = VAL(PARSE$(PARSE$(UtcTime, "T", 1), "-", 1))
- sTime.wMonth = VAL(PARSE$(PARSE$(UtcTime, "T", 1), "-", 2))
- sTime.wDay = VAL(PARSE$(PARSE$(UtcTime, "T", 1), "-", 3))
- sTime.wHour = VAL(PARSE$(PARSE$(UtcTime, "T", 2), ":", 1))
- sTime.wMinute = VAL(PARSE$(PARSE$(UtcTime, "T", 2), ":", 2))
- sTime.wSecond = VAL(PARSE$(PARSE$(UtcTime, "T", 2), ":", 3))
- iResult = SystemTimeToFileTime(sTime, hTime.iParts)
- hTime.iQuad = hTime.iQuad - GetUtcOffSet(0)
- WindowsTime = MakeReadableTime(hTime.iQuad)
- END FUNCTION
Advertisement
Add Comment
Please, Sign In to add comment