Skip to content

Commit f1104b8

Browse files
committed
v3.0.6
1 parent 470dbfa commit f1104b8

File tree

8 files changed

+108
-5253
lines changed

8 files changed

+108
-5253
lines changed

app/public/scripts/CoSearch.js

Lines changed: 0 additions & 2504 deletions
This file was deleted.

app/public/scripts/CoSearch.ts

Lines changed: 0 additions & 2646 deletions
This file was deleted.

app/public/scripts/appsManager.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -338,23 +338,18 @@ const _appScript = {
338338
return self.showErrorMessageProcess();
339339
}
340340
_view.bodyBlue(false);
341-
let html = data.html;
342-
data.folder.forEach((val, key) => {
343-
const regex = new RegExp(`["]?[']?${key}["]?[']?`, 'g');
344-
const index = html.indexOf(`"${key}"`);
341+
const getData = (filename, _data) => {
342+
const regex = new RegExp(`${filename}`, 'g');
343+
const index = html.indexOf(`${filename}`);
345344
if (index > -1) {
346-
const url = window.URL.createObjectURL(val);
347-
self.urlPool.push(url);
348-
html = html.replace(regex, `"${url}"`);
349-
}
350-
else {
351-
const uuu = 999;
345+
html = html.replace(regex, _data);
352346
}
347+
};
348+
let html = data.html;
349+
data.folder.forEach(n => {
350+
getData(n.filename, n.data);
353351
});
354-
const imgBlob = new Blob([data.img], { type: 'image/png' });
355-
const urlImg = window.URL.createObjectURL(imgBlob);
356-
self.png(urlImg);
357-
self.urlPool.push(urlImg);
352+
self.png(data.img);
358353
const htmlBolb = new Blob([html], { type: 'text/html' });
359354
const url = window.URL.createObjectURL(htmlBolb);
360355
self.urlPool.push(url);
@@ -385,6 +380,21 @@ const _appScript = {
385380
this.showHtmlCodePage(true);
386381
this.showImgPage(false);
387382
}
383+
getimageData(val, mine, CallBack) {
384+
const img = document.createElement('img');
385+
const contentBlob = new Blob([val], { type: mine });
386+
const url = window.URL.createObjectURL(contentBlob);
387+
img.addEventListener('loadend', e => {
388+
window.URL.revokeObjectURL(url);
389+
const uu = $(`${img.id}`);
390+
const ret = uu.attr('src');
391+
uu.remove();
392+
return CallBack(null, ret);
393+
});
394+
img.id = uuid_generate();
395+
img.src = url;
396+
$('#tempDom').append(img);
397+
}
388398
},
389399
info: {
390400
totalResults: ['大约有', '約', 'About', '大約有'],
@@ -895,10 +905,6 @@ const _appScript = {
895905
self.returnSearchResultItemsInit(self.imageItemsArray());
896906
});
897907
/** */
898-
return setTimeout(() => {
899-
self.imageButtonShowLoading(false);
900-
self.imageItemsArray(googleSearchImageClickResult);
901-
}, 2000);
902908
}
903909
self.searchSimilarImagesList(self.imageItemsArray().Result);
904910
self.showMain(false);

app/public/scripts/appsManager.ts

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,25 @@ const _appScript = {
353353
this.showHtmlCodePage ( true )
354354
this.showImgPage ( false )
355355
}
356+
357+
private getimageData ( val: any, mine: string, CallBack ) {
358+
const img = document.createElement('img')
359+
const contentBlob = new Blob ([ val ], { type: mine })
360+
const url = window.URL.createObjectURL ( contentBlob )
361+
362+
img.addEventListener ( 'loadend', e => {
363+
window.URL.revokeObjectURL ( url )
364+
const uu = $( `${ img.id }`)
365+
const ret = uu.attr ('src')
366+
uu.remove ()
367+
return CallBack ( null, ret )
368+
})
369+
370+
img.id = uuid_generate ()
371+
img.src = url
372+
$('#tempDom').append ( img )
373+
}
374+
356375
constructor ( public showUrl: string, private zipBase64Stream: string, private zipBase64StreamUuid: string, private exit: ()=> void ) {
357376
const self = this
358377
_view.showIconBar ( false )
@@ -361,38 +380,50 @@ const _appScript = {
361380
if ( err ) {
362381
return self.showErrorMessageProcess ()
363382
}
364-
showHTMLComplete ( zipBase64StreamUuid, data, ( err, data: { img: string, html: string, folder: Map < string, Blob >} ) => {
383+
showHTMLComplete ( zipBase64StreamUuid, data, ( err, data: { img: string, html: string, folder: [ { filename: string, data: string }]} ) => {
365384
if ( err ) {
366385
return self.showErrorMessageProcess ()
367386
}
368387
_view.bodyBlue ( false )
369-
let html = data.html
370-
data.folder.forEach (( val, key ) => {
388+
389+
390+
391+
const getData = ( filename: string, _data: string ) => {
371392

372-
const regex = new RegExp (`["]?[']?${ key }["]?[']?`,'g')
393+
const regex = new RegExp (`${ filename }`,'g')
373394

374-
const index = html.indexOf ( `"${ key }"` )
395+
const index = html.indexOf ( `${ filename }` )
375396

376397
if ( index > -1 ) {
377-
const url = window.URL.createObjectURL ( val )
378-
self.urlPool.push ( url )
379-
html = html.replace ( regex, `"${ url }"` )
380-
} else {
381-
const uuu = 999
398+
399+
html = html.replace ( regex, _data )
400+
382401
}
383402

403+
404+
}
405+
406+
let html = data.html
407+
408+
data.folder.forEach ( n => {
409+
getData ( n.filename, n.data )
384410
})
385-
const imgBlob = new Blob ([ data.img ], { type: 'image/png'})
386-
const urlImg = window.URL.createObjectURL ( imgBlob )
387-
self.png ( urlImg )
388-
self.urlPool.push ( urlImg )
411+
412+
413+
414+
self.png ( data.img )
415+
389416
const htmlBolb = new Blob ([ html ], { type: 'text/html'})
390417
const url = window.URL.createObjectURL ( htmlBolb )
391418
self.urlPool.push ( url )
392419
//_view.showLanguageSelect ( false )
393420
self.showLoading ( false )
394421
self.htmlIframe ( url )
395422

423+
424+
425+
426+
396427
})
397428
})
398429

@@ -1049,11 +1080,6 @@ const _appScript = {
10491080
})
10501081
/** */
10511082

1052-
1053-
return setTimeout (() => {
1054-
self.imageButtonShowLoading ( false )
1055-
self.imageItemsArray ( googleSearchImageClickResult )
1056-
}, 2000 )
10571083
}
10581084

10591085

@@ -1397,7 +1423,6 @@ const _appScript = {
13971423

13981424
}
13991425

1400-
14011426
class appsManager {
14021427
public mainPages = ko.observable( null )
14031428
public mainLoading = ko.observable ( true )
Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
window.URL = window.URL || window.webkitURL;
22
const getFilenameMime = (fileName, CallBack) => {
33
const exc = fileName.split('.');
4+
if (exc.length < 2) {
5+
CallBack();
6+
}
47
const exc1 = exc[exc.length - 1];
58
const ret = $.cookie(`mime.${exc1}`);
69
if (ret && ret.length) {
@@ -22,49 +25,35 @@ const showHTMLComplete = (uuid, zipStream, CallBack) => {
2225
const ret = {
2326
img: null,
2427
html: null,
25-
folder: new Map()
28+
folder: []
2629
};
2730
const allFiles = Object.keys(zip.files);
28-
let currentFileName = '';
29-
const getZipFile = (filename, __CallBack) => {
30-
return getFilenameMime(filename, (err, mime) => {
31-
if (err) {
32-
return __CallBack(err);
33-
}
34-
if (/^text\//.test(mime)) {
35-
return zip.files[filename].async('string').then(__CallBack, errCallBack);
36-
}
37-
return zip.files[filename].async('uint8array').then(__CallBack, errCallBack);
38-
});
39-
};
31+
let currentFileName = allFiles.shift();
4032
const _CallBack = content => {
4133
if (content && content.length) {
4234
const processFile = () => {
43-
return getFilenameMime(currentFileName, (err, mine) => {
44-
if (err) {
45-
return;
35+
switch (currentFileName) {
36+
case `temp/${uuid}.html`: {
37+
return ret.html = content;
38+
}
39+
case `temp/${uuid}.png`: {
40+
return ret.img = content;
4641
}
47-
switch (currentFileName) {
48-
case `temp/${uuid}.html`: {
49-
return ret.html = content;
50-
}
51-
case `temp/${uuid}.png`: {
52-
return ret.img = content;
53-
}
54-
default: {
55-
const contentBlob = new Blob([content], { type: mine });
56-
ret.folder.set(currentFileName.replace('temp/', './'), contentBlob);
57-
}
42+
default: {
43+
return ret.folder.push({ filename: currentFileName.replace('temp/', './'), data: content });
5844
}
59-
});
45+
}
6046
};
6147
processFile();
6248
}
63-
if (allFiles.length) {
64-
return getZipFile(currentFileName = allFiles.shift(), _CallBack);
49+
if (currentFileName = allFiles.shift()) {
50+
return zip.files[currentFileName].async('string').then(_CallBack, errCallBack);
6551
}
6652
return CallBack(null, ret);
6753
};
68-
return getZipFile(currentFileName = allFiles.shift(), _CallBack);
54+
if (currentFileName) {
55+
return zip.files[currentFileName].async('string').then(_CallBack, errCallBack);
56+
}
57+
return CallBack(null, ret);
6958
}, errCallBack);
7059
};

app/public/scripts/showHTMLComplete.ts

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ window.URL = window.URL || window.webkitURL
33
declare const JSZip
44
const getFilenameMime = ( fileName: string, CallBack ) => {
55
const exc = fileName.split ('.')
6+
if ( exc.length < 2 ) {
7+
CallBack ()
8+
}
69
const exc1 = exc[ exc.length - 1 ]
710
const ret = $.cookie (`mime.${ exc1 }`)
811
if ( ret && ret.length ) {
@@ -26,38 +29,16 @@ const showHTMLComplete = ( uuid: string, zipStream: string, CallBack ) => {
2629
const ret = {
2730
img: null,
2831
html: null,
29-
folder: new Map()
32+
folder: []
3033
}
3134
const allFiles = Object.keys ( zip.files )
32-
let currentFileName = ''
33-
34-
const getZipFile = ( filename, __CallBack ) => {
35-
36-
return getFilenameMime ( filename, ( err, mime ) => {
37-
if ( err ) {
38-
return __CallBack ( err )
39-
}
40-
if ( /^text\//.test ( mime )) {
41-
return zip.files [ filename ].async ( 'string' ).then ( __CallBack, errCallBack )
42-
}
43-
return zip.files [ filename ].async ('uint8array').then ( __CallBack, errCallBack )
44-
})
45-
}
46-
35+
let currentFileName = allFiles.shift()
36+
4737
const _CallBack = content => {
48-
49-
50-
5138
if ( content && content.length ) {
5239

5340
const processFile = () => {
54-
return getFilenameMime ( currentFileName, ( err, mine ) => {
55-
if ( err ) {
56-
return
57-
}
58-
59-
60-
switch ( currentFileName ) {
41+
switch ( currentFileName ) {
6142
case `temp/${ uuid }.html`: {
6243
return ret.html = content
6344

@@ -68,27 +49,29 @@ const showHTMLComplete = ( uuid: string, zipStream: string, CallBack ) => {
6849
}
6950

7051
default: {
71-
const contentBlob = new Blob ([ content ], { type: mine })
72-
ret.folder.set ( currentFileName.replace( 'temp/','./' ), contentBlob )
52+
return ret.folder.push ( { filename: currentFileName.replace( 'temp/','./' ), data: content })
7353
}
7454

7555
}
76-
77-
})
7856
}
7957

8058
processFile ()
8159
}
8260

83-
if ( allFiles.length ) {
84-
return getZipFile ( currentFileName = allFiles.shift(), _CallBack )
61+
if ( currentFileName = allFiles.shift() ) {
62+
return zip.files [ currentFileName ].async ( 'string' ).then ( _CallBack, errCallBack )
8563
}
8664

8765
return CallBack ( null, ret )
8866

8967
}
9068

91-
return getZipFile ( currentFileName = allFiles.shift(), _CallBack )
69+
if ( currentFileName ) {
70+
return zip.files [ currentFileName ].async ( 'string' ).then ( _CallBack, errCallBack )
71+
}
72+
return CallBack ( null, ret )
73+
74+
9275

9376

9477
}, errCallBack )

app/views/Shared/appHtml.pug

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,4 +664,6 @@
664664
i.icon.object.group.olive
665665
span( data-bind = "text: webUrl" )
666666
<!-- /ko -->
667+
668+
#tempDom( style = 'width: 0px;height:0px')
667669
<!-- /ko -->

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "conet",
3-
"version": "3.0.5",
3+
"version": "3.0.6",
44
"license": "MIT",
55
"description": "CoNET platform",
66
"scripts": {

0 commit comments

Comments
 (0)