-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRunMe.hta
188 lines (188 loc) · 6.44 KB
/
RunMe.hta
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
<!DOCTYPE HTML>
<html lang="en">
<meta charset="utf-8">
<head>
<title>clusteR: Interactive point clustering built on R -- Version 0.9</title>
<HTA:APPLICATION
APPLICATIONNAME="clusteR: Interactive point clustering built on R -- Version 0.9"
id="clusteR"
version="0.9"
scroll="yes"
singleinstance="yes"
/>
</head>
<script type="text/vbscript" id="LOGRefresh">
' <!--
Sub LOGRefresh()
set oFSO=CreateObject("Scripting.FileSystemObject")
set oFile=oFSO.OpenTextFile("ShinyApp.log",1)
text = oFile.ReadAll
MyDataInfo.InnerText=text
oFile.Close
End Sub
' -->
</script>
<script type="text/vbscript" id="OOLOAD">
' <!--
sub OOLOAD()
window.resizeTo 835,800
Userlat.Value = "Latitude.Decimal"
Userlon.Value = "Longitude.Decimal"
Usercrs.Value = "4326"
Const ForReading = 1
Const ForWriting = 2
FullName = replace(clusteR.commandLine,chr(34),"")
arrFN=split(FullName,"\")
FileName = arrFN(ubound(arrFN))
SourceDir = replace(FullName,FileName,"")
x=Len(SourceDir)
SecondStringLen=x-2
SecondStringBase=Right(SourceDir,SecondStringLen)
SecondStringFull="LastDirectory=" & SecondStringBase & "R-Portable"
NewDrive=Left(SourceDir,2)
NewDriveString="LastDrive=" & NewDrive
AppDirLen=x-18
LPABD="PAL:LastPortableAppsBaseDir=" & Left(SourceDir,AppDirLen)
dim basePathFilename
basePathFilename = SourceDir & "R-Portable\Data\settings\R-PortableSettings.ini"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(basePathFilename, ForReading)
strText = objFile.ReadAll
objFile.Close
strText = Replace(strText, "PAL:LastPortableAppsBaseDir=C:\Users\Cornholio\Desktop", LPABD)
strText = Replace(strText, "LastDirectory=\Users\Cornholio\Desktop\clusteR-master\R-Portable", SecondStringFull)
strText = Replace(strText, "LastDrive=C:", NewDriveString)
Set objFile = objFSO.OpenTextFile(basePathFilename, ForWriting)
objFile.WriteLine strText
objFile.Close
end sub
' -->
</script>
<script type="text/vbscript" id="Shutdown">
' <!--
sub Shutdown()
iTimerID = window.setInterval("LOGRefresh()",1000)
dim sCurPathC
sCurPathC = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
dim RKillPath
RKillPath = sCurPathC & "\shiny\killr.r"
Rexe = "R-Portable\App\R-Portable\bin\Rscript.exe"
Ropts = "--no-save --no-environ --no-init-file --no-restore --no-Rconsole"
RScriptFile = RKillPath
Outfile = "ShinyApp.log"
strCommand = Rexe & " " & Ropts & " " & RScriptFile & " 1> " & Outfile & " 2>&1"
intWindowStyle = 0
bWaitOnReturnT = False
CreateObject("Wscript.Shell").Run strCommand, intWindowStyle, bWaitOnReturnT
Self.Close()
end sub
' -->
</script>
<script type="text/vbscript" id="ExecuteclusteR">
' <!--
Sub ExecuteclusteR()
Const Q = """"
iTimerID = window.setInterval("LOGRefresh()",5000)
Const ForReading = 1
Const ForWriting = 2
dim sCurPath
sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
dim basePathFilename
basePathFilename = sCurPath & "\data\global.txt"
dim shinyPath
shinyPath = sCurPath & "\shiny\"
dim shinyPathFilename
shinyPathFilename = sCurPath & "\shiny\global.txt"
dim shinyRPathFilename
shinyRPathFilename = sCurPath & "\shiny\global.r"
dim BGTXT
Set BGTXT = CreateObject("Scripting.FileSystemObject")
BGTXT.CopyFile basePathFilename, shinyPath, TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(shinyPathFilename, ForReading)
strText = objFile.ReadAll
objFile.Close
strText = Replace(strText, "##USERFILE", Replace(userFile.Value, "\", "/"))
strText = Replace(strText, "##USERLAT", Userlat.Value)
strText = Replace(strText, "##USERLON", Userlon.Value)
strText = Replace(strText, "##USERcrs", Usercrs.Value)
strText = Replace(strText, "##USERNETD", PrintCheck.Value)
For i=0 to RadioButton2.length-1
If RadioButton2.Item(i).Checked Then
val = CStr(RadioButton2.Item(i).Value)
strText = Replace(strText, "##UserRoads", val)
End If
Next
strText = Replace(strText, "##RoadsFile", Replace(userROADFile.Value, "\", "/"))
Set objFile = objFSO.OpenTextFile(shinyPathFilename, ForWriting)
objFile.WriteLine strText
objFile.Close
dim RGTXT
Set RGTXT = CreateObject("Scripting.FileSystemObject")
RGTXT.DeleteFile(shinyRPathFilename)
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
dim shinyPath2
shinyPath2 = sCurPath & "\shiny"
Set colFiles = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='"& shinyPath2 &"'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In colFiles
strExtension = objFile.Extension
strExtension = Replace(strExtension, "txt", "r")
strNewName = objFile.Drive & objFile.Path & objFile.FileName & "." & strExtension
errResult = objFile.Rename(strNewName)
Next
dim shinyRAPPPath
shinyRAPPPath = Q & sCurPath & "\shiny\global.r" & Q
Rexe = "R-Portable\App\R-Portable\bin\Rscript.exe"
Ropts = "--no-save --no-environ --no-init-file --no-restore --no-Rconsole"
RScriptFile = shinyRAPPPath
Outfile = "ShinyApp.log"
strCommand = Rexe & " " & Ropts & " " & RScriptFile & " 1> " & Outfile & " 2>&1"
intWindowStyle = 0
bWaitOnReturnT = True
CreateObject("Wscript.Shell").Run strCommand, intWindowStyle, bWaitOnReturnT
End Sub
' -->
</script>
<body onload="OOLOAD()" onbeforeunload="Shutdown()">
<table>
<tbody>
<tr>
<td style="text-align: center;"> <img src="data/clusteR.png"> </td>
</tr>
<tr>
<td style="text-align: left;">
Welcome to clusteR -- V 0.9<br>
<br>
<fieldset>
<legend>User inputs</legend>
Your file (csv or shp):<input type="file" id="userFile" name="userFile"><br>
<br>
if csv:<br>
Latitude:<input type="text" name="Userlat" size="30"><br>
Longitude:<input type="text" name="Userlon" size="30"><br>
Projection epsg:<input type="text" name="Usercrs" size="30">
</fieldset>
<fieldset>
<legend><input type="checkbox"name="PrintCheck"value="0">Network distance:</legend>
<input type="radio" name="RadioButton2" ID="RadioButton2" value="OSM">OSM<br>
<input type="radio" name="RadioButton2" ID="RadioButton2" value="TIGER">TIGER<br>
<input type="radio" name="RadioButton2" ID="RadioButton2" value="UPRoads">User Provided:<input type="file" id="userROADFile" name="userROADFile">
</fieldset>
<br>
<input type="button" value="Run clusteR" name="run_button" onClick="ExecuteclusteR"><br>
<br>
Log:
</td>
</tr>
<tr>
<td>
<div id = "MyDataInfo" style="line-height:1em;overflow:scroll;padding:1px;"></div>
</td>
</tr>
</tbody>
</table>
</body>
</html>