Skip to content

Commit b06996b

Browse files
committed
add modal to log progress, fix path with spaces
1 parent 3cc029a commit b06996b

File tree

4 files changed

+85
-23
lines changed

4 files changed

+85
-23
lines changed

assets/custom.css

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.fs12{font-size:12px}.fs14{font-size:14px}.fs16{font-size:16px}.fs18{font-size:18px}.fs20{font-size:20px}.fs22{font-size:22px}.fs24{font-size:24px}.fs26{font-size:26px}.fs28{font-size:28px}.fs30{font-size:30px}.fs32{font-size:32px}.fs34{font-size:34px}.fs36{font-size:36px}.fs38{font-size:38px}.fs40{font-size:40px}
21
.mb0{margin-bottom:0px}.mt0{margin-top:0px}
32
.mb10{margin-bottom:10px}.mt10{margin-top:10px}.ml10{margin-left:10px}.mr10{margin-right:10px}
43
.mb15{margin-bottom:15px}.mt15{margin-top:15px}.ml15{margin-left:15px}.mr15{margin-right:15px}
@@ -8,4 +7,43 @@
87
.pb10{padding-bottom:10px}.pt10{padding-top:10px}.pl10{padding-left:10px}.pr10{padding-right:10px}
98
.pb20{padding-bottom:20px}.pt20{padding-top:20px}.pl20{padding-left:20px}.pr20{padding-right:20px}
109
.pb30{padding-bottom:30px}.pt30{padding-top:30px}.pl30{padding-left:30px}.pr30{padding-right:30px}
11-
.navbar-brand>img{width:32px}
10+
11+
.navbar-brand > img {
12+
width: 32px;
13+
}
14+
15+
#modal {
16+
display: none;
17+
position: fixed;
18+
z-index: 10;
19+
padding-top: 55px;
20+
left: 0;
21+
top: 0;
22+
width: 100%;
23+
height: 100%;
24+
overflow: auto;
25+
background-color: rgba(0,0,0,0.3);
26+
}
27+
28+
#modal-content {
29+
background-color: #fefefe;
30+
margin: auto;
31+
padding: 15px;
32+
border: 1px solid #888;
33+
width: 90%;
34+
}
35+
36+
#modal-content p {
37+
font-weight: 600;
38+
font-size: 16px;
39+
}
40+
41+
#modal-content p span{
42+
font-weight: 400;
43+
font-size: 14px;
44+
word-break: break-all;
45+
}
46+
47+
#modal-btns{
48+
display: none;
49+
}

assets/process.js

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var fso = new ActiveXObject('Scripting.FileSystemObject')
22
var wsh = new ActiveXObject('WScript.Shell')
3-
var sa = new ActiveXObject('Shell.Application')
43
var stream = new ActiveXObject("ADODB.Stream")
54

65
function doIt() {
@@ -11,6 +10,9 @@ function doIt() {
1110
var completion = form.elements['completion'].checked
1211
var distname = form.elements['distname'].value
1312
var icon = form.elements['icon'].value || 'assets\\default_icon.ico'
13+
var modal = document.getElementById('modal')
14+
var modalContent = document.getElementById('modal-content')
15+
var modalBtns = document.getElementById('modal-btns')
1416

1517
if (isRequired(srcfile) && hasExtension(srcfile, ['bat', 'hta'], true) && isRequired(distname) && isWinFilename(distname)) {
1618
var src = splitPath(srcfile)
@@ -25,27 +27,35 @@ function doIt() {
2527
if (!hasExtension(icon, ['ico'], true)) return false
2628
if (!overwrite(distname + '.exe', src.folder)) return false
2729

30+
modal.style.display = 'block'
31+
log('Processing...', modalContent, modalBtns)
32+
2833
// HTA completion feedback and copy to temp directory
2934
stream.CharSet = 'utf-8'
3035
stream.Open()
3136
stream.LoadFromFile(srcfile)
3237
if (completion) {
33-
var content = stream.ReadText()
34-
content += '\nstart "" mshta.exe javascript:alert("'+ distname +' complete");close()'
35-
stream.Flush()
36-
stream.WriteText(content)
38+
log('Adding completion line...', modalContent, modalBtns)
39+
var srcContent = stream.ReadText()
40+
stream.Close()
41+
stream.Open()
42+
srcContent += '\nstart "" mshta.exe javascript:alert("'+ distname +' complete");close()'
43+
stream.WriteText(srcContent)
3744
}
3845
stream.saveToFile(tempfile, 2)
3946
stream.Close()
40-
47+
4148
// Compress
4249
if (include) {
43-
wsh.Run('bin\\7za.exe a -t7z -mx1 -y ' + archive + ' ' + tempfile + ' ' + src.folder + '\\* -x!' + srcfile, 0, true)
50+
log('Compressing all files...', modalContent, modalBtns)
51+
wsh.Run('bin\\7za.exe a -t7z -mx1 -y "' + archive + '" "' + tempfile + '" "' + src.folder + '\\*" -x!"' + srcfile +'"', 0, true)
4452
} else {
45-
wsh.Run('bin\\7za.exe a -t7z -mx1 -y ' + archive + ' ' + tempfile, 0, true)
53+
log('Compressing...', modalContent, modalBtns)
54+
wsh.Run('bin\\7za.exe a -t7z -mx1 -y "' + archive + '" "' + tempfile +'"', 0, true)
4655
}
4756

4857
// Create Config File for SFX
58+
log('Converting to executable...', modalContent, modalBtns)
4959
var sfxfile = tempdir + '\\' + 'thebatchman_' + distname + '_sfx.txt'
5060
var sfxconfig = ';!@Install@!UTF-8!'
5161
if (hidcon) sfxconfig += '\nRunProgram="hidcon:'+ src.file +'"'
@@ -64,29 +74,24 @@ function doIt() {
6474
binaryCopy(['bin\\7zsd_LZMA2.sfx', sfxfile, archive], disttemp)
6575

6676
// Add Icon and Finalize
77+
log('Adding icon...', modalContent, modalBtns)
6778
binaryCopy([disttemp], disticx)
6879
wsh.Run('bin\\resourcer.exe -op:add -src:"'+ disticx +'" -type:icon -name:name -lang:1033 -file:"'+ icon +'"', 0, true)
6980
binaryCopy([disticx, disttemp], distexe)
7081

82+
// Clean
83+
log('Cleaning...', modalContent, modalBtns)
7184
fso.DeleteFile(tempfile)
7285
fso.DeleteFile(disticx)
7386
fso.DeleteFile(disttemp)
7487
fso.DeleteFile(archive)
7588
fso.DeleteFile(sfxfile)
76-
alert('Done !')
77-
// window.close()
89+
log('Done !', modalContent, modalBtns)
90+
log('<span>'+ distexe +'</span>', modalContent, modalBtns)
91+
modalBtns.style.display = 'block'
7892
} else {
7993
location.reload()
8094
}
81-
82-
// var exe = wsh.exec(cmd)
83-
// var out = ''
84-
// while (!exe.stdOut.atEndOfStream) {
85-
// var s = exe.stdOut.readLine()
86-
// s = s.replace( /\r/gm, '' )
87-
// out += s + '\n'
88-
// }
89-
// document.getElementById("output").value = out
9095

9196
}
9297

@@ -214,3 +219,13 @@ function forEachEl(selector, fn) {
214219
function removeClass(el, classToRemove) {
215220
el.className = el.className.replace(new RegExp('(^|\\b)' + classToRemove.split(' ').join('|') + '(\\b|$)', 'gi'), ' ')
216221
}
222+
223+
function log(message, parent, before) {
224+
var p = document.createElement('p')
225+
p.innerHTML = message
226+
if (before) {
227+
parent.insertBefore(p, before)
228+
} else {
229+
parent.appendChild(p)
230+
}
231+
}

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ So think of adding `goto completion` in your script instead of `goto:eof` if you
3636
Tested on Windows 10 x64, but should work on every Windows up to XP SP2 (x86 or x64), as long as you have Internet Explorer 8 or more recent.
3737

3838
## Included dependencies and licensing
39-
+ [7-zip command-line](http://www.7-zip.org/) 15.12 (under GNU LGPL)
39+
+ [7-zip command-line](http://www.7-zip.org/) 16.02 (under GNU LGPL)
4040
+ [7-zip modified SFX modules](http://7zsfx.info/en/) 1.6 (under GNU LGPL)
4141
+ [Anolis Resourcer](http://anolis.codeplex.com/) 0.9 (under GNU GPLv2)
4242
+ [Bootstrap](http://getbootstrap.com/) 3.3.5 (under MIT)

thebatchman.hta

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta http-equiv="x-ua-compatible" content="ie=9">
55
<script language="javascript">
66
(function () {
7-
var appSize = { width: 350, height: 520 }
7+
var appSize = { width: 350, height: 510 }
88
window.resizeTo(appSize.width, appSize.height)
99
window.moveTo((screen.width - appSize.width) / 2, (screen.availHeight - appSize.height) / 2)
1010
})()
@@ -82,5 +82,14 @@
8282
</div>
8383
</div>
8484
</div>
85+
86+
<div id="modal">
87+
<div id="modal-content">
88+
<div id="modal-btns" class="text-center mt20">
89+
<a class="btn btn-info" onclick="location.reload()">New file</a>
90+
<a class="btn btn-default" onclick="window.close()">Exit</a>
91+
</div>
92+
</div>
93+
</div>
8594
</body>
8695
</html>

0 commit comments

Comments
 (0)