@@ -25,28 +25,36 @@ var adapter = {
25
25
loadTheme : function ( style ) {
26
26
//var chat = chat;
27
27
var loader = window . srvLoader ;
28
+ var baseDir = "" ;
28
29
loader . toCache ( "variant" , style ) ;
29
30
//chat.console("DEBUG: loading " );
30
31
loader . setCaseInsensitiveFS ( true ) ;
31
32
loader . setPrepareSessionHtml ( true ) ;
32
- loader . setHttpResourcePath ( "/Contents/Resources" ) ;
33
- //chat.console("DEBUG: loading " + loader.themeId);
34
- var resources = [ "FileTransferRequest.html" ,
35
- "Footer.html" , "Header.html" , "Status.html" , "Topic.html" , "Content.html" ,
36
- "Incoming/Content.html" , "Incoming/NextContent.html" ,
37
- "Incoming/Context.html" , "Incoming/NextContext.html" ,
38
- "Outgoing/Content.html" , "Outgoing/NextContent.html" ,
39
- "Outgoing/Context.html" , "Outgoing/NextContext.html" ] ;
40
-
41
- var toCache = { } ;
42
- for ( var i = 0 ; i < resources . length ; i ++ ) {
43
- toCache [ resources [ i ] ] = "Contents/Resources/" + resources [ i ] ;
44
- }
45
- loader . saveFilesToCache ( toCache ) ;
46
33
47
34
function gotFilesList ( filesList ) {
48
- chat . console ( filesList . join ( "," ) ) ;
49
- chat . util . loadXML ( "Contents/Info.plist" , plistLoaded ) ;
35
+ filesList = filesList . filter ( ( path ) => ! ( path . startsWith ( "__MACOSX" ) || path . startsWith ( "." ) || path . endsWith ( "DS_Store" ) ) ) ;
36
+ const value = filesList . find ( ( path ) => path . split ( "/" ) [ 0 ] . toLowerCase ( ) . endsWith ( "adiummessagestyle" ) ) ;
37
+ if ( value ) {
38
+ baseDir = value . split ( "/" ) [ 0 ] + "/" ;
39
+ }
40
+ loader . setHttpResourcePath ( "/" + baseDir + "Contents/Resources" ) ;
41
+
42
+ //chat.console("DEBUG: loading " + loader.themeId);
43
+ var resources = [ "FileTransferRequest.html" ,
44
+ "Footer.html" , "Header.html" , "Status.html" , "Topic.html" , "Content.html" ,
45
+ "Incoming/Content.html" , "Incoming/NextContent.html" ,
46
+ "Incoming/Context.html" , "Incoming/NextContext.html" ,
47
+ "Outgoing/Content.html" , "Outgoing/NextContent.html" ,
48
+ "Outgoing/Context.html" , "Outgoing/NextContext.html" ] ;
49
+
50
+ var toCache = { } ;
51
+ for ( var i = 0 ; i < resources . length ; i ++ ) {
52
+ toCache [ resources [ i ] ] = baseDir + "Contents/Resources/" + resources [ i ] ;
53
+ }
54
+ loader . saveFilesToCache ( toCache ) ;
55
+
56
+ chat . console ( "Found base dir: " + value ) ;
57
+ chat . util . loadXML ( baseDir + "Contents/Info.plist" , plistLoaded ) ;
50
58
}
51
59
52
60
function plistLoaded ( ipDoc )
@@ -98,11 +106,16 @@ var adapter = {
98
106
loader . setTransparent ( ) ;
99
107
}
100
108
101
- var resources = [ "Incoming/buddy_icon.png" , "Outgoing/buddy_icon.png" , "incoming_icon.png" , "outgoing_icon.png" ] ;
109
+ var resources = [
110
+ "Incoming/buddy_icon.png" ,
111
+ "Outgoing/buddy_icon.png" ,
112
+ "incoming_icon.png" ,
113
+ "outgoing_icon.png"
114
+ ] ;
102
115
if ( chat . async ) {
103
- loader . checkFilesExist ( resources , "Contents/Resources" , resourcesListReady ) ;
116
+ loader . checkFilesExist ( resources , baseDir + "Contents/Resources" , resourcesListReady ) ;
104
117
} else {
105
- resourcesListReady ( loader . checkFilesExist ( resources , "Contents/Resources" ) ) ;
118
+ resourcesListReady ( loader . checkFilesExist ( resources , baseDir + "Contents/Resources" ) ) ;
106
119
}
107
120
}
108
121
@@ -115,9 +128,9 @@ var adapter = {
115
128
avatars . outgoingImage = rlist [ "outgoing_icon.png" ] ? "outgoing_icon.png" : chat . server . psiDefaultAvatarUrl ;
116
129
loader . toCache ( "avatars" , avatars )
117
130
if ( chat . async ) {
118
- loader . getFileContents ( "Contents/Resources/Template.html" , baseHtmlLoaded ) ;
131
+ loader . getFileContents ( baseDir + "Contents/Resources/Template.html" , baseHtmlLoaded ) ;
119
132
} else {
120
- baseHtmlLoaded ( loader . getFileContents ( "Contents/Resources/Template.html" ) ) ;
133
+ baseHtmlLoaded ( loader . getFileContents ( baseDir + "Contents/Resources/Template.html" ) ) ;
121
134
}
122
135
}
123
136
0 commit comments