11
2-
32const testHtml = '<div id="mainMenu" data-bind="with: mainScript " style="margin-top: 2em;"><div class="ui divider"></div><div class="ui header AppListHeader" style="color: cornsilk;"><div class="content"><span data-bind=" text: infoDefine[ $root.languageIndex() ].appsManager.nodeName"></span><span data-bind=" text: nodeName [$root.languageIndex() ]" style="color: lightcyan;"></span><div class="sub header" style="color: cornsilk;"><span data-bind=" text: infoDefine[ $root.languageIndex() ].appsManager.connectAddress "></span><span data-bind=" text: nodeAddress " style="color: lightcyan;"></span></div></div></div><div class="ui header AppListHeader" style=" color: white;"><div class="content"><h2 data-bind=" text: infoDefine[ $root.languageIndex() ].appsManager.serviceList"></h2></div></div><div class="ui divider"></div><div class="ui items divided" data-bind=" foreach: mainMenuItem"><a class="item AppListHeader"><img class="ui medium image" data-bind=" attr: { src: imgSrc }"><div class="content"><div class="header" data-bind=" text: headerText[ $root.languageIndex()], style: { color: headerTextColor }"></div><div class="meta"><span data-bind=" text: meta[ $root.languageIndex() ], style: { color: textColor }"></span></div><div class="description"><p data-bind="text: description[ $root.languageIndex() ], style: { color: textColor } "></p></div><div class="extra" data-bind=" html: extra [ $root.languageIndex() ], style: { color: textColor } "></div></div></a></div></div>'
43
54const _mainMenuObj = {
@@ -416,24 +415,6 @@ const _appScript = {
416415 this . showImgPage ( false )
417416 }
418417
419- private getimageData ( val : any , mine : string , CallBack ) {
420- const img = document . createElement ( 'img' )
421- const contentBlob = new Blob ( [ val ] , { type : mine } )
422- const url = window . URL . createObjectURL ( contentBlob )
423-
424- img . addEventListener ( 'loadend' , e => {
425- window . URL . revokeObjectURL ( url )
426- const uu = $ ( `${ img . id } ` )
427- const ret = uu . attr ( 'src' )
428- uu . remove ( )
429- return CallBack ( null , ret )
430- } )
431-
432- img . id = uuid_generate ( )
433- img . src = url
434- $ ( '#tempDom' ) . append ( img )
435- }
436-
437418 constructor ( public showUrl : string , private zipBase64Stream : string , private zipBase64StreamUuid : string , private exit : ( ) => void ) {
438419 const self = this
439420 _view . showIconBar ( false )
@@ -559,6 +540,9 @@ const _appScript = {
559540 imageLoadingGetResponse : ko . observable ( false ) ,
560541 imageConetResponse : ko . observable ( false ) ,
561542 imageItemsArray : ko . observable ( ) ,
543+ searchSimilarImagesList : ko . observableArray ( [ ] ) ,
544+ showSearchSimilarImagesResult : ko . observable ( false ) ,
545+ imageSearchItemArray : ko . observable ( ) ,
562546
563547 videoButtonShowLoading : ko . observable ( false ) ,
564548 videoItemsArray : ko . observable ( ) ,
@@ -571,12 +555,8 @@ const _appScript = {
571555 nextButtonConetResponse : ko . observable ( false ) ,
572556 nextButtonLoadingGetResponse : ko . observable ( false ) ,
573557
574- searchSimilarImagesList : ko . observableArray ( [ ] ) ,
575- showSearchSimilarImagesResult : ko . observable ( false ) ,
576558
577559 // ['originImage']
578- similarImagesLoading : ko . observable ( false ) ,
579- showSimilarImagesError : ko . observable ( false ) ,
580560
581561 initSearchData : ( self ) => {
582562 self . searchItem ( null )
@@ -586,20 +566,8 @@ const _appScript = {
586566 self . newsItemsArray ( null )
587567 self . imageItemsArray ( null )
588568 self . showSearchesRelated ( null )
589- self . searchSimilarImagesList ( [ ] )
590569 self . videoItemsArray ( null )
591- } ,
592-
593- similarImagesReadyClick : ( self , event ) => {
594-
595- } ,
596-
597- requestSimilarImagesClick : ( self , e ) => {
598-
599- } ,
600-
601- SimilarImagesErrorClick : ( self , e ) => {
602-
570+ self . imageSearchItemArray ( null )
603571 } ,
604572
605573 showResultItems : ( self , items ) => {
@@ -1009,6 +977,7 @@ const _appScript = {
1009977 } ,
1010978
1011979 imageButtonClick : ( self , event ) => {
980+
1012981 if ( self . imageButtonShowLoading ( ) ) {
1013982 return
1014983 }
@@ -1027,10 +996,10 @@ const _appScript = {
1027996 }
1028997
1029998 if ( ! self . imageItemsArray ( ) ) {
1030-
999+ const imageLink = self . searchItemsArray ( ) && self . searchItemsArray ( ) . action && self . searchItemsArray ( ) . action . image ? self . searchItemsArray ( ) . action . image : self . imageSearchItemArray ( ) . searchesRelated [ 1 ]
10311000 const com : QTGateAPIRequestCommand = {
10321001 command : 'CoSearch' ,
1033- Args : [ 'google' , self . searchItemsArray ( ) . action . image ] ,
1002+ Args : [ 'google' , imageLink ] ,
10341003 error : null ,
10351004 subCom : 'imageNext'
10361005 }
@@ -1311,34 +1280,48 @@ const _appScript = {
13111280
13121281 } ,
13131282
1283+
1284+
13141285 imageSearch : ( ee ) => {
13151286
1287+
1288+ const self = _view . appsManager ( ) . appScript ( )
1289+
1290+ const errorProcess = ( err ) => {
1291+ self . showInputLoading ( false )
1292+ self . searchInputText ( '' )
1293+ self . errorMessageIndex ( _view . connectInformationMessage . getErrorIndex ( err ) )
1294+ return self . showSearchError ( true )
1295+ }
1296+
1297+ const showItems = ( iResult ) => {
1298+ self . showInputLoading ( false )
1299+ self . currentlyShowItems ( 2 )
1300+ self . returnSearchResultItemsInit ( iResult )
1301+ self . imageSearchItemArray ( iResult )
1302+ self . searchInputText ( iResult . searchesRelated [ 0 ] )
1303+ self . showResultItems ( self , self . imageSearchItemArray ( ) )
1304+ }
1305+
13161306 if ( ! ee || ! ee . files || ! ee . files . length ) {
13171307 return
13181308 }
13191309
13201310 const file = ee . files [ 0 ]
1311+
13211312 if ( ! file || ! file . type . match ( / ^ i m a g e .( p n g $ | j p g $ | j p e g $ | g i f $ ) / ) ) {
13221313 return
13231314 }
1324-
13251315 const reader = new FileReader ( )
13261316
13271317 reader . onload = e => {
1328- const self = _view . appsManager ( ) . appScript ( )
1318+
13291319 const rawData = reader . result . toString ( )
13301320 self . showInputLoading ( true )
13311321 self . searchInputText ( ' ' )
13321322 self . searchItem ( null )
13331323 self . searchItemList ( [ ] )
13341324
1335- const errorProcess = ( err ) => {
1336- self . showInputLoading ( false )
1337- self . searchInputText ( '' )
1338- self . errorMessageIndex ( _view . connectInformationMessage . getErrorIndex ( err ) )
1339- return self . showSearchError ( true )
1340- }
1341-
13421325 return self . getPictureBase64MaxSize_mediaData ( rawData , 1024 , 1024 , ( err , data ) => {
13431326 if ( err ) {
13441327 return errorProcess ( err )
@@ -1386,15 +1369,7 @@ const _appScript = {
13861369 return errorProcess ( com . error )
13871370 }
13881371
1389-
1390- self . showInputLoading ( false )
1391- const iResult = com . Args . param
1392-
1393- self . currentlyShowItems ( 2 )
1394- self . returnSearchResultItemsInit ( iResult )
1395- self . imageItemsArray ( iResult )
1396- self . searchInputText ( iResult . searchesRelated [ 0 ] )
1397- self . showResultItems ( self , self . imageItemsArray ( ) )
1372+ return showItems ( com . Args . param )
13981373
13991374 } )
14001375 } )
0 commit comments