1
1
' Description: Backend script for ABBUsage Rainmeter skin by Big Kahuna
2
2
' Author: Protogen at whirlpool (skin by Big Kahuna)
3
- ' Version: 3.3.1
4
- ' Date: 18 July 2019
3
+ ' Version: 3.5.0
4
+ ' Date: 5 Aug 2019
5
5
6
6
'-------------------------------------------------------------------------------
7
7
' Environment, constants, global variables
@@ -37,7 +37,7 @@ If WScript.Arguments.Count = 2 Or WScript.Arguments.Count = 3 Then
37
37
objDebugLog.Logname = Replace(objDebugLog.Logname, ".ini" , "" )
38
38
objDebugLog.Logname = Replace(objDebugLog.Logname, "\" , "-" )
39
39
40
- appTitle = appTitle & " [" & WScript.Arguments.Item( 0 ) & "]"
40
+ appTitle = appTitle & " [" & WScript.Arguments.Item( 0 ) & "\" & WScript.Arguments.Item( 1 ) & " ]"
41
41
42
42
' Delete old files and update the usage
43
43
If WScript.Arguments.Count = 2 Then
@@ -756,7 +756,7 @@ Class HTTPRequest
756
756
If Username <> "" And Password <> "" Then
757
757
MsgBox "Failed to obtain an authentication cookie from the " & rspName & " portal." & vbCRLF & _
758
758
"Possible network error - please check your connection and try again." & vbCRLF & vbCRLF & _
759
- "(If the problem persist enable debug mode )" , 16 , appTitle
759
+ "(If the problem persists, post the issue on whirlpool )" , 16 , appTitle
760
760
End If
761
761
WScript.Quit
762
762
End If
@@ -771,7 +771,7 @@ Class HTTPRequest
771
771
If Username <> "" And Password <> "" Then
772
772
MsgBox "Failed to obtain an authentication cookie from the " & rspName & " portal." & vbCRLF & _
773
773
"Please check your username and password and try again." & vbCRLF & vbCRLF & _
774
- "(If the problem persist enable debug mode )" , 16 , appTitle
774
+ "(If the problem persists, post the issue on whirlpool )" , 16 , appTitle
775
775
End If
776
776
WScript.Quit
777
777
End If
@@ -789,10 +789,10 @@ Class HTTPRequest
789
789
Private Function PercentEncode(strPlain)
790
790
If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Entering Function PercentEncode"
791
791
792
- Dim strEncoded, pos , currentChar, ansiVal
792
+ Dim strEncoded, index , currentChar, ansiVal
793
793
794
- For pos = 1 to Len(strPlain)
795
- currentChar = Mid(strPlain, pos , 1 )
794
+ For index = 1 to Len(strPlain)
795
+ currentChar = Mid(strPlain, index , 1 )
796
796
ansiVal = Asc(currentChar)
797
797
798
798
' Do not encode numbers, uppercase and lowercase letters
@@ -1003,6 +1003,79 @@ Class Auth
1003
1003
1004
1004
End Class
1005
1005
1006
+ '-------------------------------------------------------------------------------
1007
+ ' Class - UserSelection
1008
+ '-------------------------------------------------------------------------------
1009
+
1010
+ Class UserSelection
1011
+
1012
+ Private p_desc
1013
+ Private p_dict
1014
+
1015
+ '-------------------------------------------------------------------------------
1016
+ ' Property - Desc
1017
+ '-------------------------------------------------------------------------------
1018
+
1019
+ Public Property Let Desc(strDesc)
1020
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Entering Let Desc"
1021
+
1022
+ p_desc = strDesc
1023
+ End Property
1024
+
1025
+ Public Property Get Desc()
1026
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Entering Get Desc"
1027
+
1028
+ Desc = p_desc
1029
+ End Property
1030
+
1031
+ '-------------------------------------------------------------------------------
1032
+ ' Property - Dict
1033
+ '-------------------------------------------------------------------------------
1034
+
1035
+ Public Property Let Dict(objDict)
1036
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Entering Let Dict"
1037
+
1038
+ Set p_dict = objDict
1039
+ End Property
1040
+
1041
+ Public Property Get Dict()
1042
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Entering Get Dict"
1043
+
1044
+ Set Dict = p_dict
1045
+ End Property
1046
+
1047
+ '-------------------------------------------------------------------------------
1048
+ ' Function - GetUserSelection
1049
+ '-------------------------------------------------------------------------------
1050
+
1051
+ Public Function GetUserSelection()
1052
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Entering Function GetUserSelection"
1053
+
1054
+ Dim arrDictKeys, strMessage, index, userResponse
1055
+
1056
+ arrDictKeys = Me .Dict.Keys
1057
+ strMessage = "Please select the " & Me .Desc & " for this skin" & vbCRLF & vbCRLF
1058
+ For index = 1 to Me .Dict.Count
1059
+ strMessage = strMessage & CStr (index) & " - " & arrDictKeys(index - 1 ) & vbCRLF
1060
+ Next
1061
+ strMessage = strMessage & vbCRLF & "Selection (1 - " & Me .Dict.Count & ")?"
1062
+
1063
+ Do Until 1 <= userResponse And userResponse <= Me .Dict.Count
1064
+ userResponse = InputBox(strMessage, appTitle)
1065
+ If IsNumeric(userResponse) Then
1066
+ userResponse = CInt (userResponse)
1067
+ Else
1068
+ userResponse = 0
1069
+ End If
1070
+ Loop
1071
+
1072
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "User response = '" & userResponse & "'"
1073
+
1074
+ GetUserSelection = arrDictKeys(userResponse - 1 )
1075
+ End Function
1076
+
1077
+ End Class
1078
+
1006
1079
'-------------------------------------------------------------------------------
1007
1080
' Class - Options
1008
1081
'-------------------------------------------------------------------------------
@@ -1083,19 +1156,22 @@ Class Options
1083
1156
Private Function GetBarStyleSize()
1084
1157
If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Entering Function GetBarStyleSize"
1085
1158
1086
- Dim objBarStyleSize, userSelection
1087
- Set objBarStyleSize = CreateObject( "Scripting.Dictionary" )
1159
+ Dim objDict, objUserSelection, userSelection
1160
+ Set objDict = CreateObject( "Scripting.Dictionary" )
1161
+ Set objUserSelection = New UserSelection
1088
1162
1089
- objBarStyleSize .Add "Dashed 5px" , "image5px"
1090
- objBarStyleSize .Add "Dashed 8px" , "image8px"
1091
- objBarStyleSize .Add "Solid 5px" , "solid5px"
1092
- objBarStyleSize .Add "Solid 8px" , "solid8px"
1163
+ objDict .Add "Dashed 5px" , "image5px"
1164
+ objDict .Add "Dashed 8px" , "image8px"
1165
+ objDict .Add "Solid 5px" , "solid5px"
1166
+ objDict .Add "Solid 8px" , "solid8px"
1093
1167
1094
- userSelection = GetUserSelection(objBarStyleSize, "bar style and size" )
1168
+ objUserSelection.Desc = "bar style and size"
1169
+ objUserSelection.Dict = objDict
1170
+ userSelection = objUserSelection.GetUserSelection()
1095
1171
1096
- If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "User selection = '" & objBarStyleSize (userSelection) & "'"
1172
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "User selection = '" & objDict (userSelection) & "'"
1097
1173
1098
- GetBarStyleSize = objBarStyleSize (userSelection)
1174
+ GetBarStyleSize = objDict (userSelection)
1099
1175
End Function
1100
1176
1101
1177
'-------------------------------------------------------------------------------
@@ -1105,48 +1181,21 @@ Class Options
1105
1181
Private Function GetFontSize()
1106
1182
If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Entering Function GetFontSize"
1107
1183
1108
- Dim objFontSize, userSelection
1109
- Set objFontSize = CreateObject( "Scripting.Dictionary" )
1110
-
1111
- objFontSize.Add "Small (8px)" , "small"
1112
- objFontSize.Add "Medium (12px)" , "medium"
1113
- objFontSize.Add "Large (16px)" , "large"
1114
-
1115
- userSelection = GetUserSelection(objFontSize, "font size" )
1116
-
1117
- If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "User selection = '" & objFontSize(userSelection) & "'"
1118
-
1119
- GetFontSize = objFontSize(userSelection)
1120
- End Function
1121
-
1122
- '-------------------------------------------------------------------------------
1123
- ' Function - GetUserSelection
1124
- '-------------------------------------------------------------------------------
1125
-
1126
- Public Function GetUserSelection(objDict, strSelectionName)
1127
- If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Entering Function GetUserSelection"
1128
-
1129
- Dim arrDictKeys, strMessage, pos, userResponse
1184
+ Dim objDict, objUserSelection, userSelection
1185
+ Set objDict = CreateObject( "Scripting.Dictionary" )
1186
+ Set objUserSelection = New UserSelection
1130
1187
1131
- arrDictKeys = objDict.Keys
1132
- strMessage = "Please select the " & strSelectionName & " for this skin" & vbCRLF & vbCRLF
1133
- For pos = 1 to objDict.Count
1134
- strMessage = strMessage & CStr (pos) & " - " & arrDictKeys(pos - 1 ) & vbCRLF
1135
- Next
1136
- strMessage = strMessage & vbCRLF & "Selection (1 - " & objDict.Count & ")?"
1188
+ objDict.Add "Small (8px)" , "small"
1189
+ objDict.Add "Medium (12px)" , "medium"
1190
+ objDict.Add "Large (16px)" , "large"
1137
1191
1138
- Do Until 1 <= userResponse And userResponse <= objDict.Count
1139
- userResponse = InputBox(strMessage, appTitle)
1140
- If IsNumeric(userResponse) Then
1141
- userResponse = CInt (userResponse)
1142
- Else
1143
- userResponse = 0
1144
- End If
1145
- Loop
1192
+ objUserSelection.Desc = "font size"
1193
+ objUserSelection.Dict = objDict
1194
+ userSelection = objUserSelection.GetUserSelection()
1146
1195
1147
- If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "User response = '" & userResponse & "'"
1196
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "User selection = '" & objDict(userSelection) & "'"
1148
1197
1149
- GetUserSelection = arrDictKeys(userResponse - 1 )
1198
+ GetFontSize = objDict(userSelection )
1150
1199
End Function
1151
1200
1152
1201
'-------------------------------------------------------------------------------
@@ -1282,9 +1331,9 @@ Class Service
1282
1331
End If
1283
1332
1284
1333
objAuth.GetAuth()
1285
- objOptions.EnsureOptionsExist()
1286
1334
1287
1335
If Not objServiceFile.FileExists() Then CreateService()
1336
+ objOptions.EnsureOptionsExist()
1288
1337
LoadService()
1289
1338
End Sub
1290
1339
@@ -1308,15 +1357,15 @@ Class Service
1308
1357
1309
1358
objJSON.JSONText = objHTTPRequest.ResponseText
1310
1359
1311
- Me .ServiceID = objJSON.JSONStruct.services.NBN. [ 0 ] .service_id
1360
+ Me .ServiceID = GetServiceID( objJSON)
1312
1361
1313
1362
If IsEmpty( Me .ServiceID) Or Me .ServiceID = "" Then
1314
1363
If debugMode Then objDebugLog.Message "error" , TypeName( Me ), "ServiceID is undefined or blank"
1315
1364
WScript.Quit
1316
1365
End If
1317
1366
1318
1367
maxLen = 16 - Len( Me .ServiceID)
1319
- strMessage = "Your " & rspName & " NBN Service ID is " & Me .ServiceID & vbCRLF & vbCRLF & _
1368
+ strMessage = "Your NBN Service ID for this skin is " & Me .ServiceID & vbCRLF & vbCRLF & _
1320
1369
"Please enter a name for this service" & vbCRLF & _
1321
1370
"(e.g. 'Home', 'Home2', 'Work', 'Primary')" & vbCRLF & vbCRLF & _
1322
1371
"Service Name (alphanumeric only; max " & maxLen & " chars)?"
@@ -1342,6 +1391,48 @@ Class Service
1342
1391
objServiceFile.Contents = serviceFileContents
1343
1392
End Sub
1344
1393
1394
+ '-------------------------------------------------------------------------------
1395
+ ' Function - GetServiceID
1396
+ '-------------------------------------------------------------------------------
1397
+
1398
+ Private Function GetServiceID(objJSON)
1399
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Entering Function GetServiceID"
1400
+
1401
+ Dim serviceCount
1402
+ serviceCount = objJSON.JSONStruct.services.NBN.Length
1403
+
1404
+ If serviceCount <= 0 Then
1405
+ If debugMode Then objDebugLog.Message "error" , TypeName( Me ), "NBN array (customer JSON) is empty or missing"
1406
+ MsgBox "Failed to obtain an NBN Service ID from the " & rspName & " portal." & vbCRLF & _
1407
+ "Possible " & rspName & " portal change - please try again." & vbCRLF & vbCRLF & _
1408
+ "(If the problem persists, post the issue on whirlpool)" , 16 , appTitle
1409
+ WScript.Quit
1410
+ ElseIf serviceCount = 1 Then
1411
+ GetServiceID = objJSON.JSONStruct.services.NBN. [0 ].service_id
1412
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Single NBN Service ID found = '" & GetServiceID & "'"
1413
+ Exit Function
1414
+ End If
1415
+
1416
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "Multiple NBN Service IDs found"
1417
+
1418
+ Dim objDict, index, serviceID, objUserSelection, userSelection
1419
+ Set objDict = CreateObject( "Scripting.Dictionary" )
1420
+ Set objUserSelection = New UserSelection
1421
+
1422
+ For index = 0 to (serviceCount - 1 )
1423
+ serviceID = Eval( "objJSON.JSONStruct.services.NBN.[" & index & "].service_id" )
1424
+ objDict.Add serviceID, serviceID
1425
+ Next
1426
+
1427
+ objUserSelection.Desc = "NBN Service ID"
1428
+ objUserSelection.Dict = objDict
1429
+ userSelection = objUserSelection.GetUserSelection()
1430
+
1431
+ If debugMode Then objDebugLog.Message "info" , TypeName( Me ), "User selection = '" & objDict(userSelection) & "'"
1432
+
1433
+ GetServiceID = objDict(userSelection)
1434
+ End Function
1435
+
1345
1436
'-------------------------------------------------------------------------------
1346
1437
' Sub - LoadService
1347
1438
'-------------------------------------------------------------------------------
0 commit comments