-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOutputHtml.vb
867 lines (746 loc) · 97.9 KB
/
OutputHtml.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
Option Explicit On
Imports System.Data
Imports System.Text
Imports FolderFileList.FolderFileList
''' <summary>
''' Html出力の機能を提供する
''' </summary>
''' <remarks></remarks>
Public Class OutputHtml
#Region "定数"
''' <summary>階層構造表示用文字列</summary>
''' <remarks>
''' フォルダの階層構造を見た目でわかるようにファイル名
''' の前に全角スペースを2つ付加する
''' </remarks>
Private Const _cHierarchySpace As String = " "
''' <summary>フォルダファイルリストのドキュメントURL</summary>
''' <remarks></remarks>
Public Const cFolderFileListDocumentURL As String = "https://github.com/dodonki1223/FolderFileList/blob/master/docs/README.md"
''' <summary>Selectタグ初期値</summary>
''' <remarks></remarks>
Private Const _cInitialSelectValue As String = "未選択"
#End Region
#Region "列挙体"
''' <summary>リンクタイプ</summary>
''' <remarks></remarks>
Public Enum LinkType
''' <summary>ローカルファイルパス</summary>
Local
''' <summary>URL</summary>
Url
End Enum
#End Region
#Region "変数"
''' <summary>フォルダ・ファイルリスト</summary>
''' <remarks></remarks>
Private _FolderFileList As FolderFileList
''' <summary>フォームの種類</summary>
''' <remarks></remarks>
Private _FormType As CommandLine.FormType
#End Region
#Region "プロパティ"
''' <summary>
''' フォルダファイルリストプロパティ
''' </summary>
''' <remarks></remarks>
Public ReadOnly Property FolderFileList As FolderFileList
Get
Return _FolderFileList
End Get
End Property
''' <summary>
''' フォームタイププロパティ
''' </summary>
''' <remarks></remarks>
Public Property FormType As CommandLine.FormType
Get
Return _FormType
End Get
Set(value As CommandLine.FormType)
_FormType = value
End Set
End Property
''' <summary>
''' Html文書
''' </summary>
''' <remarks>
''' FolderFileListからHtml文書に変換したものを取得
''' </remarks>
Public ReadOnly Property HtmlSentence() As String
Get
Return _ConvertFolderFileListToHtmlSentence(_FolderFileList)
End Get
End Property
#End Region
#Region "コンストラクタ"
''' <summary>
''' コンストラクタ
''' </summary>
''' <remarks>
''' 引数無しは外部に公開しない
''' </remarks>
Private Sub New()
End Sub
''' <summary>
''' コンストラクタ
''' </summary>
''' <param name="pFolderFileList">フォルダファイルリスト</param>
''' <param name="pFormType">フォームタイプ</param>
''' <remarks>
''' 引数付きのコンストラクタのみを公開
''' </remarks>
Public Sub New(ByVal pFolderFileList As FolderFileList, Optional ByVal pFormType As CommandLine.FormType = CommandLine.FormType.Text)
'フォームタイプをセット
_FormType = pFormType
'フォルダファイルリストをセット
_FolderFileList = pFolderFileList
End Sub
#End Region
#Region "メソッド"
''' <summary>
''' フォルダファイルリストをHtml文書に変換
''' </summary>
''' <param name="pFolderFileList">フォルダファイルリスト</param>
''' <returns>フォルダファイルリストをHtml文書に変換した文字列</returns>
''' <remarks></remarks>
Private Function _ConvertFolderFileListToHtmlSentence(ByVal pFolderFileList As FolderFileList) As String
Dim mHtmlSentence As New StringBuilder
With mHtmlSentence
.AppendLine("<!DOCTYPE html> ")
.AppendLine("<html lang=""ja""> ")
.AppendLine(" <head> ")
.AppendLine(" <meta charset=""UTF-8""> ")
'CSS設定
.Append(_GetCssSetting())
.AppendLine(" </head> ")
.AppendLine(" <body> ")
.AppendLine(" <header id=""header""> ")
.AppendLine(" <h1>" & _FolderFileList.TargetPathFolderName & "</h1> ")
.AppendLine(" </header> ")
.AppendLine(" ")
.AppendLine(" <div class=""refineConditions""> ")
.AppendLine(" <fieldset> ")
.AppendLine(" <legend>絞り込み条件</legend> ")
.AppendLine(" <div class=""refineBox""> ")
.AppendLine(" <fieldset> ")
.AppendLine(" <legend>対象ファイル</legend> ")
.AppendLine(" <input type=""radio"" name=""displayTarget"" value=""All"" checked>全て表示</input> ")
.AppendLine(" <input type=""radio"" name=""displayTarget"" value=""Folder"">フォルダのみ表示</input> ")
.AppendLine(" <input type=""radio"" name=""displayTarget"" value=""File"">ファイルのみ表示</input> ")
.AppendLine(" </fieldset> ")
.AppendLine(" </div> ")
.AppendLine(" <div class=""refineBox""> ")
.AppendLine(" <fieldset> ")
.AppendLine(" <legend>拡張子指定</legend> ")
.AppendLine(" <select name=""extensionTarget"" > ")
'拡張子リスト分繰り返す
For Each mExtension As String In _FolderFileList.ExtensionList(_cInitialSelectValue)
.AppendLine(" <option value=""" & mExtension & """" & _GetNotSelectClass(mExtension) & ">" & mExtension & "</option> ")
Next
.AppendLine(" </select> ")
.AppendLine(" </fieldset> ")
.AppendLine(" </div> ")
.AppendLine(" <div class=""refineBox""> ")
.AppendLine(" <fieldset> ")
.AppendLine(" <legend>ファイルサイズ指定</legend> ")
.AppendLine(" <select name=""sizeLevelTarget"" > ")
'ファイルサイズレベル分繰り返す
For Each mLevel As DataRow In FolderFileList.cFileSizeLevel.LevelList(_cInitialSelectValue).Rows
Dim mLevelValue As String = mLevel(cFileSizeLevel.LevelListColum.NAME)
.AppendLine(" <option value=""" & mLevelValue & """" & _GetNotSelectClass(mLevelValue) & ">" & mLevelValue & "</option> ")
Next
.AppendLine(" </select> ")
.AppendLine(" </fieldset> ")
.AppendLine(" </div> ")
.AppendLine(" <div class=""refineBox""> ")
.AppendLine(" <fieldset> ")
.AppendLine(" <legend>名前(LIKE検索)</legend> ")
.AppendLine(" <input type=""text"" name=""fileNameSearch"" placeholder=""検索したい文字列を入力して下さい""></input> ")
.AppendLine(" </fieldset> ")
.AppendLine(" </div> ")
.AppendLine(" <div class=""refineButtonBox""> ")
.AppendLine(" <a class=""refineButton"" href=""javascript:(function() {refineFolderFileList()})();"">絞り込み</a> ")
.AppendLine(" </div> ")
.AppendLine(" </fieldset> ")
.AppendLine(" </div> ")
.AppendLine(" <div> ")
.AppendLine(" <p class=""folderFileCount""></p> ")
.AppendLine(" </div> ")
.AppendLine(" <div> ")
.AppendLine(" <table class=""folderFileList""> ")
.AppendLine(" <thead> ")
.AppendLine(" <tr> ")
.AppendLine(" <th>" & StrConv(FolderFileListJapaneseColumn.ファイル名.ToString, VbStrConv.Wide) & "</th> ")
.AppendLine(" <th>" & FolderFileListJapaneseColumn.更新日時.ToString & "</th> ")
.AppendLine(" <th>" & StrConv(FolderFileListJapaneseColumn.ファイルサイズ.ToString, VbStrConv.Wide) & "</th> ")
.AppendLine(" <th>" & StrConv(FolderFileListJapaneseColumn.ファイルシステムタイプ.ToString, VbStrConv.Wide) & "</th> ")
.AppendLine(" <th>" & FolderFileListJapaneseColumn.拡張子.ToString & "</th> ")
.AppendLine(" <th>" & StrConv(FolderFileListJapaneseColumn.ファイルサイズレベル.ToString, VbStrConv.Wide) & "</th> ")
.AppendLine(" <th>" & StrConv(FolderFileListJapaneseColumn.親フォルダ.ToString, VbStrConv.Wide) & "</th> ")
.AppendLine(" <th>" & StrConv(FolderFileListJapaneseColumn.対象フォルダ以下.ToString, VbStrConv.Wide) & "</th> ")
.AppendLine(" <th>" & StrConv(FolderFileListJapaneseColumn.フルパス.ToString, VbStrConv.Wide) & "</th> ")
.AppendLine(" </tr> ")
.AppendLine(" </thead> ")
.AppendLine(" <tbody> ")
'フォルダファイルリストの行数分繰り返す
For Each mDr As DataRow In _FolderFileList.FolderFileList.Rows
'行IDを作成
Dim mRowID As String = "row" & mDr(FolderFileListColumn.No)
'ファイル名を取得
Dim mFileName As String = _GetFileName(mDr(FolderFileListColumn.Name), mDr(FolderFileListColumn.DirectoryLevel), _FormType)
'ファイルパスのURLを作成
Dim mFilePathUrl As String = _CreateWindowOpenURL(mDr(FolderFileListColumn.FullPath), LinkType.Local)
'親フォルダパスのURLを作成
Dim mParentFolderPathUrl As String = _CreateWindowOpenURL(mDr(FolderFileListColumn.ParentFolderFullPath), LinkType.Local)
.AppendLine(" <tr id=""" & mRowID & """> ")
.AppendLine(" <td class=""fileName""> ")
.AppendLine(" <a href=""" & mFilePathUrl & """>" & mFileName & "</a> ")
.AppendLine(" </td> ")
.AppendLine(" <td>" & mDr(FolderFileListColumn.UpdateDate) & "</td> ")
.AppendLine(" <td>" & mDr(FolderFileListColumn.SizeAndUnit) & "</td> ")
.AppendLine(" <td class=""fileSystemType"">" & mDr(FolderFileListColumn.FileSystemTypeName) & "</td> ")
.AppendLine(" <td class=""extension"">" & mDr(FolderFileListColumn.Extension) & "</td> ")
.AppendLine(" <td class=""sizeLevel"">" & mDr(FolderFileListColumn.SizeLevelName) & "</td> ")
.AppendLine(" <td> ")
.AppendLine(" <a href=""" & mParentFolderPathUrl & """>" & mDr(FolderFileListColumn.ParentFolder) & "</a> ")
.AppendLine(" </td> ")
.AppendLine(" <td> ")
.AppendLine(" <a href=""" & mFilePathUrl & """>" & mDr(FolderFileListColumn.UnderTargetFolder) & "</a> ")
.AppendLine(" </td> ")
.AppendLine(" <td> ")
.AppendLine(" <a href=""" & mFilePathUrl & """>" & mDr(FolderFileListColumn.FullPath) & "</a> ")
.AppendLine(" </td> ")
.AppendLine(" </tr> ")
Next
.AppendLine(" </tbody> ")
.AppendLine(" </table> ")
.AppendLine(" </div> ")
.AppendLine(" <footer id=""footer""> ")
.AppendLine(" <p> ")
'フォルダ・ファイルリストのドキュメントURLを取得
Dim mDocumentUrl As String = _CreateWindowOpenURL(cFolderFileListDocumentURL, LinkType.Url)
.AppendLine(" <a href=""" & mDocumentUrl & """>FolderFileListのドキュメントはこちら</a> ")
.AppendLine(" </p> ")
.AppendLine(" </footer> ")
'JavaScript設定
.Append(_GetJavaScriptSetting())
.AppendLine(" </body> ")
.AppendLine("</html> ")
End With
Return mHtmlSentence.ToString
End Function
''' <summary>
''' ファイル名を取得
''' </summary>
''' <param name="pFileName">ファイル名</param>
''' <param name="pDirectoryLevel">ディレクトリレベル</param>
''' <param name="pFormType">フォームタイプ</param>
''' <returns>
''' フォームタイプに応じてファイル名を返す
''' 出力文字列:ディレクトリレベル分、階層構造用の文字列をファイル名の前に付加して返す
''' リスト表示:ファイル名をそのまま返す
''' </returns>
''' <remarks></remarks>
Private Function _GetFileName(ByVal pFileName As String, ByVal pDirectoryLevel As Integer, ByVal pFormType As CommandLine.FormType) As String
Dim mFileName As String = String.Empty
'フォームタイプごと処理を分岐
Select Case pFormType
Case CommandLine.FormType.Text
mFileName = pFileName
'ディレクトリレベル分繰り返す
For i As Integer = 0 To pDirectoryLevel
'階層構造用の文字列をファイル名の前に追加
mFileName = _cHierarchySpace & mFileName
Next
Case CommandLine.FormType.List
mFileName = pFileName
End Select
Return mFileName
End Function
''' <summary>
''' Html出力時のCSS部分を取得
''' </summary>
''' <returns>Htmlに設定するCSS</returns>
''' <remarks></remarks>
Private Function _GetCssSetting() As String
Dim mCssString As New System.Text.StringBuilder
With mCssString
.AppendLine(" <style type=""text/css""> ")
.AppendLine(" ")
.AppendLine(" /* aタグ設定 */ ")
.AppendLine(" a { ")
.AppendLine(" text-decoration: none; ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /* tableタグ設定 */ ")
.AppendLine(" table { ")
.AppendLine(" *border-collapse: collapse; ")
.AppendLine(" border-spacing: 0; ")
.AppendLine(" width: 100%; ")
.AppendLine(" font-size: 10px; ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /* Selectタグ設定 */ ")
.AppendLine(" select { ")
.AppendLine(" width :120px; ")
.AppendLine(" height:21px; ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /* Selectタグの項目の文字色は黒色 */ ")
.AppendLine(" option { ")
.AppendLine(" color:#333; ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /* TextBox設定 */ ")
.AppendLine(" input[type=""text""] { ")
.AppendLine(" width :300px; ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /* ボタン設定 */ ")
.AppendLine(" .refineButton { ")
.AppendLine(" margin-top:10px; ")
.AppendLine(" position: relative; ")
.AppendLine(" background-color: #1abc9c; ")
.AppendLine(" border-radius: 4px; ")
.AppendLine(" color: #fff; ")
.AppendLine(" line-height: 52px; ")
.AppendLine(" -webkit-transition: none; ")
.AppendLine(" transition: none; ")
.AppendLine(" box-shadow: 0 3px 0 #0e8c73; ")
.AppendLine(" text-shadow: 0 1px 1px rgba(0, 0, 0, .3); ")
.AppendLine(" } ")
.AppendLine(" .refineButton:hover { ")
.AppendLine(" background-color: #31c8aa; ")
.AppendLine(" box-shadow: 0 3px 0 #23a188; ")
.AppendLine(" } ")
.AppendLine(" .refineButton:active { ")
.AppendLine(" top: 3px; ")
.AppendLine(" box-shadow: none; ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /* 絞り込み領域 */ ")
.AppendLine(" .refineConditions { ")
.AppendLine(" width: 1270px; ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /* 絞り込み条件ボックス */ ")
.AppendLine(" .refineBox { ")
.AppendLine(" float: left; ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /* 絞り込み条件ボックス */ ")
.AppendLine(" .refineButtonBox { ")
.AppendLine(" text-align: right; ")
.AppendLine(" float: left; ")
.AppendLine(" width: 135px; ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /* 絞り込みボタン設定 */ ")
.AppendLine(" .refineConditions .refineButton { ")
.AppendLine(" display: inline-block; ")
.AppendLine(" width: 130px; ")
.AppendLine(" height: 50px; ")
.AppendLine(" text-align: center; ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /* フォルダファイルリスト設定 */ ")
.AppendLine(" .folderFileList { ")
.AppendLine(" border: solid #ccc 1px; ")
.AppendLine(" -moz-border-radius: 6px; ")
.AppendLine(" -webkit-border-radius: 6px; ")
.AppendLine(" border-radius: 6px; ")
.AppendLine(" -webkit-box-shadow: 0 1px 1px #ccc; ")
.AppendLine(" -moz-box-shadow: 0 1px 1px #ccc; ")
.AppendLine(" box-shadow: 0 1px 1px #ccc; ")
.AppendLine(" margin-top: 10px; ")
.AppendLine(" } ")
.AppendLine(" .folderFileList tr:hover { ")
.AppendLine(" background: #e8bebe; ")
.AppendLine(" -o-transition: all 0.1s ease-in-out; ")
.AppendLine(" -webkit-transition: all 0.1s ease-in-out; ")
.AppendLine(" -moz-transition: all 0.1s ease-in-out; ")
.AppendLine(" -ms-transition: all 0.1s ease-in-out; ")
.AppendLine(" transition: all 0.1s ease-in-out; ")
.AppendLine(" } ")
.AppendLine(" .folderFileList td, .folderFileList th { ")
.AppendLine(" border-left: 1px solid #ccc; ")
.AppendLine(" border-top: 1px solid #ccc; ")
.AppendLine(" padding: 10px; ")
.AppendLine(" text-align: left; ")
.AppendLine(" white-space: nowrap; ")
.AppendLine(" } ")
.AppendLine(" .folderFileList th { ")
.AppendLine(" background-color: #dce9f9; ")
.AppendLine(" background-image: -webkit-gradient(linear, left top, left bottom, from(#ebf3fc), to(#dce9f9)); ")
.AppendLine(" background-image: -webkit-linear-gradient(top, #ebf3fc, #dce9f9); ")
.AppendLine(" background-image: -moz-linear-gradient(top, #ebf3fc, #dce9f9); ")
.AppendLine(" background-image: -ms-linear-gradient(top, #ebf3fc, #dce9f9); ")
.AppendLine(" background-image: -o-linear-gradient(top, #ebf3fc, #dce9f9); ")
.AppendLine(" background-image: linear-gradient(top, #ebf3fc, #dce9f9); ")
.AppendLine(" -webkit-box-shadow: 0 1px 0 rgba(255,255,255,.8) inset; ")
.AppendLine(" -moz-box-shadow:0 1px 0 rgba(255,255,255,.8) inset; ")
.AppendLine(" box-shadow: 0 1px 0 rgba(255,255,255,.8) inset; ")
.AppendLine(" border-top: none; ")
.AppendLine(" text-shadow: 0 1px 0 rgba(255,255,255,.5); ")
.AppendLine(" } ")
.AppendLine(" .folderFileList td:first-child, .folderFileList th:first-child { ")
.AppendLine(" border-left: none; ")
.AppendLine(" } ")
.AppendLine(" .folderFileList th:first-child { ")
.AppendLine(" -moz-border-radius: 6px 0 0 0; ")
.AppendLine(" -webkit-border-radius: 6px 0 0 0; ")
.AppendLine(" border-radius: 6px 0 0 0; ")
.AppendLine(" } ")
.AppendLine(" .folderFileList th:last-child { ")
.AppendLine(" -moz-border-radius: 0 6px 0 0; ")
.AppendLine(" -webkit-border-radius: 0 6px 0 0; ")
.AppendLine(" border-radius: 0 6px 0 0; ")
.AppendLine(" } ")
.AppendLine(" .folderFileList th:only-child{ ")
.AppendLine(" -moz-border-radius: 6px 6px 0 0; ")
.AppendLine(" -webkit-border-radius: 6px 6px 0 0; ")
.AppendLine(" border-radius: 6px 6px 0 0; ")
.AppendLine(" } ")
.AppendLine(" .folderFileList tr:last-child td:first-child { ")
.AppendLine(" -moz-border-radius: 0 0 0 6px; ")
.AppendLine(" -webkit-border-radius: 0 0 0 6px; ")
.AppendLine(" border-radius: 0 0 0 6px; ")
.AppendLine(" } ")
.AppendLine(" .folderFileList tr:last-child td:last-child { ")
.AppendLine(" -moz-border-radius: 0 0 6px 0; ")
.AppendLine(" -webkit-border-radius: 0 0 6px 0; ")
.AppendLine(" border-radius: 0 0 6px 0; ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" </style> ")
End With
Return mCssString.ToString
End Function
''' <summary>
''' Html出力時のJavaScript部分を取得
''' </summary>
''' <returns>Htmlに設定するJavaScript</returns>
''' <remarks></remarks>
Private Function _GetJavaScriptSetting() As String
Dim mJavaScriptString As New System.Text.StringBuilder
With mJavaScriptString
.AppendLine(" <script src=""https://code.jquery.com/jquery-2.2.0.min.js"" type=""text/javascript""></script> ")
.AppendLine(" <script type=""text/javascript""> ")
.AppendLine(" ")
.AppendLine(" /** ")
.AppendLine(" * フォルダファイルリストの絞り込み ")
.AppendLine(" */ ")
.AppendLine(" function refineFolderFileList(){ ")
.AppendLine(" ")
.AppendLine(" //選択されているラジオボタンを取得し対象ファイルシステムタイプの行を表示 ")
.AppendLine(" var checkedRadioButton = $('input[name=displayTarget]:checked').val(); ")
.AppendLine(" refineByFileSystemType(checkedRadioButton); ")
.AppendLine(" ")
.AppendLine(" //選択されている拡張子を取得し対象拡張子のファイルに一致する行を表示 ")
.AppendLine(" var selectExtension = $('[name=extensionTarget]').val(); ")
.AppendLine(" refineBySelectTag(selectExtension, 'extension'); ")
.AppendLine(" ")
.AppendLine(" //選択されているサイズレベルを取得し対象サイズレベルのファイルに一致する行を表示 ")
.AppendLine(" var selectSizeLevel = $('[name=sizeLevelTarget]').val(); ")
.AppendLine(" refineBySelectTag(selectSizeLevel, 'sizeLevel'); ")
.AppendLine(" ")
.AppendLine(" //入力されている「名前(LIKE検索)」の値を取得し対象文字列にLIKEで一致するファイル名の行を表示 ")
.AppendLine(" var fileNameSearch = $('[name=fileNameSearch]').val(); ")
.AppendLine(" refineByTextBox(fileNameSearch, 'fileName'); ")
.AppendLine(" ")
.AppendLine(" //フォルダファイルリストの件数を画面に表示 ")
.AppendLine(" setFolderFileCount(); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /** ")
.AppendLine(" * 対象のファイルシステムタイプの行を表示 ")
.AppendLine(" * @param {string} target 表示対象のファイルシステムタイプ ")
.AppendLine(" * ※All:すべて表示、Folder:フォルダのみ表示、File:ファイルのみ表示 ")
.AppendLine(" */ ")
.AppendLine(" function refineByFileSystemType(target) { ")
.AppendLine(" ")
.AppendLine(" //全て表示定数 ")
.AppendLine(" const ALL = 'All'; ")
.AppendLine(" ")
.AppendLine(" //Class名に「fileSystemType」と名の付くタグ分繰り返す ")
.AppendLine(" $('.fileSystemType').each(function() { ")
.AppendLine(" ")
.AppendLine(" //表示対象ファイルシステムタイプがALLの時 ")
.AppendLine(" if (target === ALL) { ")
.AppendLine(" ")
.AppendLine(" //親要素を表示し次の繰り返しへ ")
.AppendLine(" $(this).parent().show(); ")
.AppendLine(" return true; ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" //「fileSystemType」と名の付くタグのテキストが「target」と一致したら ")
.AppendLine(" if ($(this).text() === target) { ")
.AppendLine(" ")
.AppendLine(" //「fileSystemType」と名の付くタグの親要素を表示する ")
.AppendLine(" $(this).parent().show(); ")
.AppendLine(" ")
.AppendLine(" } else { ")
.AppendLine(" ")
.AppendLine(" //「fileSystemType」と名の付くタグの親要素を非表示にする ")
.AppendLine(" $(this).parent().hide(); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" }); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /** ")
.AppendLine(" * 選択されているSelectタグの値の行を表示 ")
.AppendLine(" * @param {string} target Selectタグで選択されている値 ")
.AppendLine(" * @param {string} className 対象のtdタグのクラス名 ")
.AppendLine(" */ ")
.AppendLine(" function refineBySelectTag(target, className) { ")
.AppendLine(" ")
.AppendLine(" //対象のSelectタグの選択されている値が未選択の時は処理を終了 ")
.AppendLine(" if (target === '未選択') return; ")
.AppendLine(" ")
.AppendLine(" //Class名に「className」と名の付くタグ分繰り返す ")
.AppendLine(" $('.' + className).each(function() { ")
.AppendLine(" ")
.AppendLine(" //「className」と名の付くタグのテキストと親要素のdisplayの状態を取得 ")
.AppendLine(" var targetTag = $(this).text().toLowerCase() , ")
.AppendLine(" parentDisplayState = $(this).parent().css('display'); ")
.AppendLine(" ")
.AppendLine(" // 「className」と名の付くタグのテキストが「target」と一致 ")
.AppendLine(" // かつ「className」と名の付くタグの親要素のdisplayの状態が「none」でない時 ")
.AppendLine(" if (targetTag === target.toLowerCase() && parentDisplayState != 'none') { ")
.AppendLine(" ")
.AppendLine(" //「className」と名の付くタグの親要素を表示 ")
.AppendLine(" $(this).parent().show(); ")
.AppendLine(" ")
.AppendLine(" } else { ")
.AppendLine(" ")
.AppendLine(" //「className」と名の付くタグの親要素を非表示 ")
.AppendLine(" $(this).parent().hide(); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" }); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /** ")
.AppendLine(" * テキストボックスに入力されている値にLIKE一致する行の表示 ")
.AppendLine(" * @param {string} target input(text)タグで入力されている値 ")
.AppendLine(" * @param {string} className 対象のtdタグのクラス名 ")
.AppendLine(" */ ")
.AppendLine(" function refineByTextBox(target, className) { ")
.AppendLine(" ")
.AppendLine(" //Class名に「className」と名の付くタグ分繰り返す ")
.AppendLine(" $('.' + className).each(function() { ")
.AppendLine(" ")
.AppendLine(" //「className」と名の付くタグのテキスト(小文字変換後)と親要素のdisplayの状態を取得 ")
.AppendLine(" //「 対象文字が含まれているか」変数にFalseをセット(デフォルト) ")
.AppendLine(" var targetString = $(this).text().toLowerCase() , ")
.AppendLine(" parentDisplayState = $(this).parent().css('display') , ")
.AppendLine(" isIncludedString = false; ")
.AppendLine(" ")
.AppendLine(" //「className」と名の付くタグのテキスト(小文字変換後)に対象となる文字列が存在する時は ")
.AppendLine(" //「 対象文字が含まれているか」変数にTrueをセット ")
.AppendLine(" if ( targetString.indexOf(target.toLowerCase()) != -1) isIncludedString = true; ")
.AppendLine(" ")
.AppendLine(" // 「 対象文字が含まれているか」変数がTrueで ")
.AppendLine(" // かつ「className」と名の付くタグの親要素のdisplayの状態が「none」でない時 ")
.AppendLine(" if (isIncludedString && parentDisplayState != 'none') { ")
.AppendLine(" ")
.AppendLine(" //「className」と名の付くタグの親要素を表示 ")
.AppendLine(" $(this).parent().show(); ")
.AppendLine(" ")
.AppendLine(" } else { ")
.AppendLine(" ")
.AppendLine(" //「className」と名の付くタグの親要素を非表示 ")
.AppendLine(" $(this).parent().hide(); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" }); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /** ")
.AppendLine(" * Selectタグで最初に表示する項目の文字色を灰色表示にします ")
.AppendLine(" */ ")
.AppendLine(" function setSelectTagColor() { ")
.AppendLine(" ")
.AppendLine(" //Selectタグ内のOptionタグでSlectedされているタグ分繰り返す ")
.AppendLine(" $('select').find('option:selected').each(function() { ")
.AppendLine(" ")
.AppendLine(" //Slectedされているタグで「not-select」というクラス名を持っていた時 ")
.AppendLine(" if ($(this).hasClass('not-select')) { ")
.AppendLine(" ")
.AppendLine(" // 文字色を灰色に変更 ")
.AppendLine(" $(this).parent().css({'color':'#A9A9A9'}); ")
.AppendLine(" ")
.AppendLine(" } else { ")
.AppendLine(" ")
.AppendLine(" // 文字色を黒色に変更 ")
.AppendLine(" $(this).parent().css({'color':'#333'}); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" }); ")
.AppendLine(" ")
.AppendLine(" //項目が変更された時、条件によって色変更 ")
.AppendLine(" $('select').on('change', function(){ ")
.AppendLine(" ")
.AppendLine(" //Selectタグ内のOptionタグでSlectedされているタグ分繰り返す ")
.AppendLine(" $('select').find('option:selected').each(function() { ")
.AppendLine(" ")
.AppendLine(" //Slectedされているタグで「not-select」というクラス名を持っていた時 ")
.AppendLine(" if ($(this).hasClass('not-select')) { ")
.AppendLine(" ")
.AppendLine(" // 文字色を灰色に変更 ")
.AppendLine(" $(this).parent().css({'color':'#A9A9A9'}); ")
.AppendLine(" ")
.AppendLine(" } else { ")
.AppendLine(" ")
.AppendLine(" // 文字色を黒色に変更 ")
.AppendLine(" $(this).parent().css({'color':'#333'}); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" }); ")
.AppendLine(" ")
.AppendLine(" }); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /** ")
.AppendLine(" * 拡張子使用不可設定 ")
.AppendLine(" * ※対象ファイルのラジオボタンイベントに拡張子使用不可の処理を追加する ")
.AppendLine(" */ ")
.AppendLine(" function setExtensionDisable() { ")
.AppendLine(" ")
.AppendLine(" $('input[name=displayTarget]:radio').change(function() { ")
.AppendLine(" ")
.AppendLine(" //対象ファイルFolder定数 ")
.AppendLine(" const FOLDER = 'Folder'; ")
.AppendLine(" ")
.AppendLine(" //選択されているラジオボタンを取得 ")
.AppendLine(" var checkedRadioButton = $('input[name=displayTarget]:checked').val(); ")
.AppendLine(" ")
.AppendLine(" //選択されているラジオボタンが「Folder」の時 ")
.AppendLine(" if (checkedRadioButton === FOLDER) { ")
.AppendLine(" ")
.AppendLine(" //「extensionTarget」Selectタグの値を「未選択」でセット ")
.AppendLine(" $('select[name=extensionTarget]').val('未選択'); ")
.AppendLine(" ")
.AppendLine(" //「extensionTarget」Selectタグの使用を不可 ")
.AppendLine(" $('select[name=extensionTarget]').attr('disabled', true); ")
.AppendLine(" ")
.AppendLine(" //「extensionTarget」Selectタグの背景色を灰色に変更 ")
.AppendLine(" $('select[name=extensionTarget]').css({'background-color':'#808080'}); ")
.AppendLine(" ")
.AppendLine(" //Selectタグで最初に表示する項目の文字色を灰色表示 ")
.AppendLine(" setSelectTagColor(); ")
.AppendLine(" ")
.AppendLine(" } else { ")
.AppendLine(" ")
.AppendLine(" //「extensionTarget」Selectタグの「disabled」属性を削除 ")
.AppendLine(" $('select[name=extensionTarget]').removeAttr('disabled'); ")
.AppendLine(" ")
.AppendLine(" //「extensionTarget」Selectタグの背景色を白に変更 ")
.AppendLine(" $('select[name=extensionTarget]').css({'background-color':'#ffffff'}); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" }); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /** ")
.AppendLine(" * フォルダファイルリストの件数を取得する ")
.AppendLine(" * @return {number} フォルダファイルリストの表示されている件数 ")
.AppendLine(" */ ")
.AppendLine(" function getFolderFileListRowCount(){ ")
.AppendLine(" ")
.AppendLine(" //行数を数える変数 ")
.AppendLine(" var rowCount = 0; ")
.AppendLine(" ")
.AppendLine(" //クラス名が「fileName」と名の付くタグ分繰り返す ")
.AppendLine(" $('.fileName').each(function() { ")
.AppendLine(" ")
.AppendLine(" //「fileName」と名の付くタグの親要素のdisplayの状態を取得 ")
.AppendLine(" var parentDisplayState = $(this).parent().css('display'); ")
.AppendLine(" ")
.AppendLine(" //親要素のdisplayの状態が「display:none;」で無かった時、行数を+1 ")
.AppendLine(" if (parentDisplayState != 'none') rowCount++; ")
.AppendLine(" ")
.AppendLine(" }); ")
.AppendLine(" ")
.AppendLine(" return rowCount; ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" /** ")
.AppendLine(" * フォルダ・ファイルリストの件数を画面にセット ")
.AppendLine(" */ ")
.AppendLine(" function setFolderFileCount() { ")
.AppendLine(" ")
.AppendLine(" //「folderFileCount」クラスの名の付く要素のテキストに「フォルダ・ファイルリスト件数:○件」形式で表示させる ")
.AppendLine(" $('.folderFileCount').text('フォルダ・ファイルリスト件数:' + getFolderFileListRowCount() + '件'); ")
.AppendLine(" ")
.AppendLine(" } ")
.AppendLine(" ")
.AppendLine(" //Selectタグの最初に表示する項目の文字色を灰色表示に変更 ")
.AppendLine(" setSelectTagColor(); ")
.AppendLine(" ")
.AppendLine(" //対象ファイルのラジオボタンイベントに拡張子使用不可の処理を追加する ")
.AppendLine(" setExtensionDisable(); ")
.AppendLine(" ")
.AppendLine(" //フォルダ・ファイルリストの件数を画面に表示 ")
.AppendLine(" setFolderFileCount(); ")
.AppendLine(" ")
.AppendLine(" </script> ")
End With
Return mJavaScriptString.ToString
End Function
''' <summary>
''' Select句の未選択状態のクラスを取得する
''' </summary>
''' <param name="pValue">Option句に表示する値</param>
''' <returns>not-selectのクラス設定</returns>
''' <remarks></remarks>
Private Function _GetNotSelectClass(ByVal pValue As String) As String
'Option句に表示する値がSelectタグの初期値
If pValue = _cInitialSelectValue Then
'未選択クラス設定を返す
Return " class=""not-select"""
Else
Return String.Empty
End If
End Function
''' <summary>
''' window.openで開く用のURLを作成
''' </summary>
''' <param name="pPath">対象パス</param>
''' <returns>window.openで開く用のURL文字列</returns>
''' <remarks>
''' ※別タブでリンクを開く時のパスは以下のどちらかの形式でなければならない
''' ①\\\\FileServer\\Folder1\\Gorira.txt
''' ②file://FileServer/Folder1/Gorira.txt
''' </remarks>
Private Function _CreateWindowOpenURL(ByVal pPath As String, ByVal pLinkType As LinkType) As String
Dim mLink As String = String.Empty
Select Case pLinkType
Case LinkType.Local
'パス文字列から「\」マークを「\\」に変換し、
'パス文字列の前と後にjavascriptのwindow.open用の文字列を付加して返す
mLink = "javascript:window.open('" & "file:\\\\" & Replace(pPath, "\", "\\") & "');"
Case LinkType.Url
'URLをwindow.open用の文字列を付加して返す
mLink = "javascript:window.open('" & pPath & "');"
End Select
Return mLink
End Function
#End Region
End Class