file_explorer.html 249 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393
  1. <html>
  2. <head>
  3. <title>File Manager</title>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
  6. <link rel="stylesheet" href="../../script/tocas/tocas.css">
  7. <link rel="icon" type="image/png" href="./img/small_icon.png">
  8. <link rel="manifest" crossorigin="use-credentials" href="manifest.json">
  9. <script type="text/javascript" src="../../script/tocas/tocas.js"></script>
  10. <script type="text/javascript" src="../../script/jquery.min.js"></script>
  11. <script type="text/javascript" src="../../script/ao_module.js"></script>
  12. <script type="text/javascript" src="../../script/forge-sha256.min.js"></script>
  13. <script type="text/javascript" src="../../script/qrcode.min.js"></script>
  14. <script type="text/javascript" src="../../script/applocale.js"></script>
  15. <script>
  16. window.mobilecheck = function() {
  17. var check = false;
  18. (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
  19. return check;
  20. };
  21. </script>
  22. <style>
  23. body{
  24. color:black;
  25. height:100%;
  26. }
  27. h1, h2, h3, p, span, div { font-family: "Microsoft JhengHei","SimHei", "Apple LiGothic Medium", "STHeiti"}
  28. html{
  29. height:100%;
  30. overflow:hidden;
  31. }
  32. body.whiteTheme{
  33. background-color:rgb(250, 250, 250);
  34. }
  35. .darkTheme{
  36. background-color:#242330 !important;
  37. color:white;
  38. }
  39. .whiteTheme{
  40. color:#0d0d0d
  41. }
  42. .navibar{
  43. position:fixed;
  44. width:100%;
  45. padding-left:12px;
  46. padding-right:12px;
  47. padding-top:6px;
  48. padding-bottom:3px;
  49. z-index: 99;
  50. }
  51. .navibar.darkTheme{
  52. background-color:#17161f !important;
  53. border-bottom:2px solid #34b7eb;
  54. }
  55. .navibar.whiteTheme{
  56. /*box-shadow: 0 2px 4px 2px rgb(224, 224, 224);*/
  57. background-color:#fcfcfc;
  58. border-bottom:2px solid #34b7eb;
  59. }
  60. .whiteTheme .button.standard{
  61. box-shadow: 0 1px 1px 0px rgb(190, 190, 190);
  62. border: 0px;
  63. }
  64. .whiteTheme .button.standard:hover{
  65. background-color:#82c2f0 !important;
  66. color:white !important;
  67. }
  68. .ts.button{
  69. margin-bottom:2px;
  70. }
  71. .ts.button.darkTheme{
  72. background-color:#17161f !important;
  73. border: 1px solid #262533;
  74. color:white;
  75. }
  76. .ts.button.active.darkTheme{
  77. background-color:#312f42 !important;
  78. border: 1px solid #262533;
  79. color:white;
  80. }
  81. .ts.button.darkTheme:hover{
  82. background-color:#312f42 !important;
  83. color:white !important;
  84. }
  85. .rightPad{
  86. margin-right:37px;
  87. }
  88. .addressBar{
  89. width:100%;
  90. padding:3px;
  91. padding-left: 0px;
  92. padding-right: 0px;
  93. min-height: 35px;
  94. padding-top:6px;
  95. }
  96. .breadcrumb.darkTheme{
  97. background-color:transparent;
  98. }
  99. .section.darkTheme{
  100. color:white !important;
  101. background-color:transparent;
  102. }
  103. .selectable{
  104. cursor:pointer;
  105. }
  106. .rightAlign{
  107. position:absolute;
  108. right:0px;
  109. top:3px;
  110. }
  111. .addressText{
  112. padding:5px;
  113. border-radius: 3px;
  114. }
  115. .addressText.darkTheme{
  116. border: 1px solid #262533;
  117. }
  118. .addressText.whiteTheme{
  119. border: 1px solid #cfcfcf;
  120. }
  121. .divider.whiteTheme{
  122. color:#262533 !important;
  123. background-color:transparent;
  124. }
  125. .divider.darkTheme{
  126. background-color:transparent;
  127. color: white !important;
  128. }
  129. #directorySidebar{
  130. padding:12px;
  131. overflow-y:auto;
  132. padding-bottom:20px;
  133. }
  134. #directorySidebar.darkTheme{
  135. border-right:2px solid rgb(25, 24, 31);
  136. color:white;
  137. position:absolute;
  138. }
  139. #directorySidebar.whiteTheme{
  140. border-right:2px solid rgba(219, 226, 241, 0.7);
  141. background-color:#f5f5f5;
  142. color:rgb(44, 44, 44);
  143. position:absolute;
  144. }
  145. #folderView{
  146. position:absolute;
  147. padding-left:2em;
  148. padding-right:2em;
  149. padding-top:2em;
  150. overflow-y:auto;
  151. }
  152. #folderView.whiteTheme{
  153. background-color:white;
  154. }
  155. .item.darkTheme{
  156. color:white;
  157. }
  158. .rightmargin.icon{
  159. margin-right:8px !important;
  160. }
  161. .dir{
  162. cursor:pointer;
  163. }
  164. .dir:hover{
  165. color:#d1d1d1 !important;
  166. }
  167. .dir.item.whiteTheme{
  168. color:rgb(78, 78, 78);
  169. }
  170. .device{
  171. cursor:pointer;
  172. }
  173. .device:hover{
  174. color:#d1d1d1;
  175. }
  176. .accordion.darkTheme{
  177. color:white !important;
  178. }
  179. .accordion.whiteTheme{
  180. background-color:transparent !important;
  181. }
  182. .fileObject{
  183. display:block !important;
  184. cursor:pointer;
  185. overflow-wrap: break-word !important;
  186. -webkit-touch-callout: none;
  187. -webkit-user-select: none;
  188. -khtml-user-select: none;
  189. -moz-user-select: none;
  190. -ms-user-select: none;
  191. user-select: none;
  192. }
  193. .fileObject.darkTheme{
  194. border:1px solid rgb(72, 69, 88) !important;
  195. }
  196. .segmented.list.darkTheme{
  197. border:1px solid rgb(8, 8, 10) !important;
  198. box-shadow: 0 0 0 0;
  199. border-radius: 0px;
  200. }
  201. .fileObject.darkTheme:hover{
  202. background-color:#17161f !important;
  203. }
  204. .fileObject.darkTheme:hover span{
  205. background-color:#17161f !important;
  206. }
  207. .fileObject.whiteTheme:hover{
  208. background-color:#f2f2f2 !important;
  209. }
  210. .fileObject.darkTheme.selected{
  211. background-color:#100f16 !important;
  212. }
  213. .fileObject.darkTheme.selected span{
  214. background-color:#100f16 !important;
  215. }
  216. .fileObject.whiteTheme.selected{
  217. background-color:#d2f2f7 !important;
  218. color:black !important;
  219. }
  220. .mobilePathDisplayWrapper{
  221. width:100%;
  222. margin-bottom:5px;
  223. }
  224. .ts.card.darkTheme{
  225. border:1px solid rgb(72, 69, 88) !important;
  226. box-shadow: 0 0 0 0 transparent;
  227. }
  228. .darkTheme.header{
  229. color:white !important;
  230. background-color:transparent !important;
  231. }
  232. .darkTheme.meta{
  233. color:rgba(255, 255, 255, 0.836) !important;
  234. background-color:transparent !important;
  235. }
  236. .darkTheme.description{
  237. color:white !important;
  238. background-color:transparent !important;
  239. }
  240. .whiteTheme.header{
  241. background-color:transparent;
  242. }
  243. .whiteTheme.meta{
  244. background-color:transparent;
  245. }
  246. .whiteTheme.description{
  247. background-color:transparent;
  248. }
  249. #folderList{
  250. margin-bottom:16px;
  251. }
  252. .msgbox{
  253. padding:3px;
  254. }
  255. .closeMsgButton{
  256. position:absolute;
  257. top:8px;
  258. right:12px;
  259. }
  260. .closeMsgButton{
  261. cursor:pointer;
  262. }
  263. .popup{
  264. position:fixed;
  265. top:30px;
  266. z-index:110;
  267. left:34%;
  268. right:34%;
  269. bottom:30px;
  270. padding-bottom:24px;
  271. border: 0px solid transparent !important;
  272. }
  273. .popup.wide{
  274. left:24%;
  275. right:24%;
  276. }
  277. .popup.darkTheme{
  278. -webkit-box-shadow: 3px 4px 5px 0px rgb(35, 33, 46) ;
  279. -moz-box-shadow: 3px 4px 5px 0px rgb(35, 33, 46);
  280. box-shadow: 3px 4px 5px 0px rgb(35, 33, 46) ;
  281. border: 1px solid rgb(22, 21, 29);
  282. }
  283. .popup.whiteTheme{
  284. -webkit-box-shadow: 3px 4px 5px 0px rgba(138,138,138,1);
  285. -moz-box-shadow: 3px 4px 5px 0px rgba(138,138,138,1);
  286. box-shadow: 3px 4px 5px 0px rgba(138,138,138,1);
  287. border: 1px solid rgb(226, 226, 226);
  288. background-color:white;
  289. }
  290. @media only screen and (max-width: 1920px) {
  291. .popup{
  292. left:35em;
  293. right:35em;
  294. }
  295. .popup.wide{
  296. left:20em;
  297. right:20em;
  298. }
  299. }
  300. @media only screen and (max-width: 1500px) {
  301. .popup{
  302. left:20em;
  303. right:20em;
  304. }
  305. .popup.wide{
  306. left:14em;
  307. right:14em;
  308. }
  309. }
  310. @media only screen and (max-width: 1200px) {
  311. .popup{
  312. left:14em;
  313. right:14em;
  314. }
  315. .popup.wide{
  316. left:5em;
  317. right:5em;
  318. }
  319. }
  320. @media only screen and (max-width: 800px) {
  321. .popup{
  322. left:5em;
  323. right:5em;
  324. }
  325. .popup.wide{
  326. left:2em;
  327. right:2em;
  328. }
  329. }
  330. @media only screen and (max-width: 600px) {
  331. .popup{
  332. position:fixed;
  333. top:5%;
  334. z-index:100;
  335. left:1em;
  336. right:1em;
  337. }
  338. }
  339. .popupheader{
  340. width:100%;
  341. padding:3px;
  342. padding-left:12px;
  343. border-bottom:2px solid #34b7eb;
  344. background-color: #171719;
  345. color: white;
  346. height:29px;
  347. }
  348. .popupcontent{
  349. height: calc(100% - 29px);
  350. overflow:auto;
  351. }
  352. .popupcloser{
  353. position:absolute;
  354. top:5px;
  355. right:0px;
  356. font-size: 120%;
  357. cursor:pointer;
  358. }
  359. .popupbuttons{
  360. cursor:pointer;
  361. padding:5px;
  362. padding-left:12px;
  363. margin-bottom:4px;
  364. border: 1px solid #dedede;
  365. border-radius: 4px;
  366. }
  367. .popupbuttons.primary.whiteTheme{
  368. background-color:#51aded;
  369. box-shadow: 0 2px 1px 0px #34a2ee !important;
  370. border: 1px solid transparent;
  371. color:white;
  372. }
  373. .popupbuttons.negative{
  374. background-color:#ed5151;
  375. box-shadow: 0 2px 1px 0px #ee3434 !important;
  376. border: 1px solid transparent;
  377. color:white;
  378. }
  379. .popupbuttons.primary.darkTheme{
  380. background-color:#413f57 !important;
  381. box-shadow: 0 2px 1px 0px #3c3b50 !important;
  382. border: 1px solid transparent;
  383. color:white;
  384. }
  385. .popupbuttons.negative.darkTheme{
  386. background-color:#ed5151 !important;
  387. }
  388. .popupbuttons.disabled{
  389. opacity: 0.4;
  390. pointer-events: none;
  391. }
  392. .popupbuttons.primary.disabled{
  393. opacity: 0.4;
  394. pointer-events: none;
  395. }
  396. .whiteTheme.allowHover:hover{
  397. background-color:rgba(238, 238, 238, 0.932);
  398. }
  399. .whiteTheme.allowHover.primary:hover{
  400. background-color:#76c0f5;
  401. }
  402. .allowHover.negative:hover{
  403. background-color:#f57676;
  404. }
  405. .allowHover.negative.darkTheme:hover{
  406. background-color:#f57676 !important;
  407. }
  408. .darkTheme.allowHover:hover{
  409. background-color:#111017 !important;
  410. }
  411. .ts.list.darkTheme{
  412. background-color:#464457 !important;
  413. }
  414. input.darkTheme{
  415. color:white !important;
  416. }
  417. .ts.segmented.list.darkTheme .item{
  418. color:white !important;
  419. }
  420. .newFileFormat{
  421. cursor:pointer;
  422. }
  423. .popupWrapper{
  424. position:fixed;
  425. top:0px;
  426. left:0px;
  427. width:100%;
  428. height:100%;
  429. z-index:99;
  430. background-color:rgba(27,27,27,0.5);
  431. display:none;
  432. }
  433. @supports (backdrop-filter: none) {
  434. .popupWrapper {
  435. backdrop-filter: blur(5px);
  436. }
  437. }
  438. .breadcrumb.whiteTheme{
  439. background-color:white;
  440. }
  441. #openWithModuleList{
  442. height:250px;
  443. overflow-y:auto;
  444. }
  445. #openWith .segment.darkTheme{
  446. color:white !important;
  447. }
  448. #openWithModuleList .item{
  449. padding:8px;
  450. padding-left:22px;
  451. border-radius: 2px;
  452. display: flex;
  453. flex-wrap: wrap;
  454. }
  455. #openWithModuleList.darkTheme .item.selected{
  456. background-color:#100f16 !important;
  457. }
  458. #openWithModuleList.whiteTheme .item.selected{
  459. background-color:#51aded !important;
  460. color:white;
  461. }
  462. #openWithModuleList.darkTheme .item.selectable:hover{
  463. background-color:rgba(250,250,250,0.05);
  464. }
  465. #openWithModuleList.whiteTheme .item.selectable:hover{
  466. background-color:rgba(35,35,35,0.14);
  467. }
  468. .contextmenu.darkTheme .item{
  469. color:white !important;
  470. }
  471. .contextmenu .item{
  472. font-size:90% !important;
  473. }
  474. #uploadTab{
  475. position:fixed;
  476. right:0px;
  477. bottom: 0px;
  478. width:300px;
  479. margin-bottom:0px !important;
  480. padding:0px !important;
  481. }
  482. #uploadTab.darkTheme{
  483. color:white;
  484. background-color:rgba(35,35,35,0.14);
  485. border: 1px solid #17161f !important;
  486. box-shadow: 0px 0px 0px 0px rgba(0,0,0,0.75);
  487. }
  488. .statusBar{
  489. height:32px;
  490. background-color:#f5f5f5;
  491. padding:8px;
  492. }
  493. .statusBar.whiteTheme{
  494. color:rgb(78, 78, 78);
  495. }
  496. .statusBar.darkTheme{
  497. background-color:#181720 !important;
  498. }
  499. .hideUploadButton{
  500. float: right;
  501. cursor:pointer;
  502. }
  503. .uploadList{
  504. margin:8px;
  505. padding-bottom:3px;
  506. margin-bottom:0px;
  507. max-height: 250px;
  508. overflow-y:auto;
  509. }
  510. .uploadTask{
  511. margin-top:6px;
  512. }
  513. .uploadTaskRemoveIcon{
  514. position:absolute;
  515. top:0px;
  516. right:0px;
  517. cursor:pointer;
  518. }
  519. .clearallButton{
  520. padding:8px;
  521. cursor:pointer;
  522. }
  523. .normal.object.whiteTheme{
  524. color:#303030;
  525. }
  526. .normal.object.darkTheme{
  527. color:white;
  528. }
  529. .sub.header.darkTheme{
  530. color:rgb(190, 190, 190) !important;
  531. }
  532. .hex.foldername{
  533. color:#2b9447 !important;
  534. }
  535. .um.filename{
  536. color: #69aaff !important;
  537. }
  538. .dropdown.inverted:not(.icon){
  539. background-color: #17161f !important;
  540. }
  541. .sharebtn{
  542. cursor: pointer;
  543. }
  544. .sharebtn.darkTheme {
  545. color: white !important;
  546. background-color: transparent !important;
  547. }
  548. .sharebtn.whiteTheme:hover{
  549. opacity: 0.5;
  550. }
  551. .sharebtn.darkTheme:hover{
  552. opacity: 0.5;
  553. }
  554. i.blue{
  555. color: #345eeb;
  556. }
  557. .fileObject.whiteTheme.hotSearchHighlight{
  558. background-color: #d2f2f7 !important;
  559. }
  560. .fileObject.darkTheme.hotSearchHighlight span{
  561. background-color: #d2f2f7 !important;
  562. }
  563. .fileObject.darkTheme.hotSearchHighlight{
  564. background-color: #100f16 !important;
  565. }
  566. .fileObject.darkTheme.hotSearchHighlight span{
  567. background-color: #100f16 !important;
  568. }
  569. </style>
  570. </head>
  571. <body class="whiteTheme">
  572. <div id="navibar" class="navibar whiteTheme">
  573. <!-- Directoy navigations -->
  574. <button id="backbtn" class="ts icon tiny button standard whiteTheme" onclick="previosPath();" title="Back"><i class="left arrow icon"></i></button>
  575. <button id="ppbtn" class="ts icon tiny button standard whiteTheme rightPad" onclick="parentDir();" title="Parent Folder"><i class="up arrow icon"></i></button>
  576. <!-- File Read Operations -->
  577. <button class="ts icon tiny button standard whiteTheme" title="Open" onclick="openViaButton();"><i class="folder open icon"></i></button>
  578. <button class="ts icon tiny button standard whiteTheme" title="Open with" onclick="openWith();"><i class="external icon"></i></button>
  579. <button class="ts icon tiny button standard whiteTheme singleObjectOnly" title="Share File" onclick="shareFile();"><i class="share alternate icon"></i></button>
  580. <button class="ts labeled icon tiny button standard whiteTheme" style="width:154px;" title="Download" onclick="downloadFile();">
  581. <i class="download icon"></i>
  582. <span locale="menu/button/download">Download</span>
  583. </button>
  584. <!-- File Edit Operations -->
  585. <button class="ts icon tiny button standard whiteTheme" title="Copy" onclick="copy();"><i class="copy icon"></i></button>
  586. <button class="ts icon tiny button standard whiteTheme" title="Paste" onclick="paste();"><i class="paste icon"></i></button>
  587. <button class="ts icon tiny button standard whiteTheme" title="Cut" onclick="cut();"><i class="cut icon"></i></button>
  588. <button class="ts icon tiny button standard whiteTheme" title="New File" onclick="newfile();"><i class="file outline icon"></i></button>
  589. <button class="ts icon tiny button standard whiteTheme" title="New Folder" onclick="newFolder();"><i class="folder outline icon"></i></button>
  590. <button class="ts icon tiny button standard whiteTheme" title="Upload" onclick="upload();"><i class="upload icon"></i></button>
  591. <button class="ts icon tiny button standard whiteTheme" title="Create Zip" onclick="zipFile();"><i class="zip file icon"></i></button>
  592. <button class="ts icon tiny button standard whiteTheme" title="Unzip Here" onclick="unzipHere();"><i class="inbox icon"></i></button>
  593. <button class="ts icon tiny button standard whiteTheme" title="Rename" onclick="rename();"><i class="i cursor icon"></i></button>
  594. <button class="ts icon tiny negative button" title="Delete" onclick="deleteFile();"><i class="trash outline icon"></i></button>
  595. <button class="ts icon tiny button standard whiteTheme" title="Refresh" onclick="refreshList();"><i class="refresh icon"></i></button>
  596. <button class="ts icon tiny button standard whiteTheme" title="Home" onclick="openHomeDir();"><i class="home icon"></i></button>
  597. <button class="ts icon tiny button standard whiteTheme" title="File Info" onclick="showFileProperties();"><i class="notice icon"></i></button>
  598. <div class="addressBar">
  599. <button class="ts icon tiny button standard whiteTheme" onclick="toggleSidebar();" title="Toggle Folder List"><i class="content icon"></i></button>
  600. <button class="ts icon tiny button inverted" title="Dark Theme" onclick="toggleDarkTheme();"><i class="moon icon" id="darkthemebtn"></i></button>
  601. <button class="ts tiny icon button standard whiteTheme" title="Edit Path" onclick="showEditCurrentPathInput(event)"><i class="ui edit icon"></i></button>
  602. <div id="pathDisplayField" class="ts breadcrumb whiteTheme addressText pathDisplay desktopOnly" ondblclick="showEditCurrentPathInput(event);">
  603. <div class="section whiteTheme selectable"><i class="folder icon"></i> user</div>
  604. <div class="divider whiteTheme">:/</div>
  605. <div class="section whiteTheme selectable">Desktop</div>
  606. </div>
  607. <div id="pathInputField" class="ts action mini input whiteTheme" style="display:none;">
  608. <input type="text" style="min-width: 200px;" class="whiteTheme" placeholder="Type a path and press enter" onkeydown="handleOpenPathKeydown(event);">
  609. <button class="ts icon button" title="Open" onclick="openEnteredPath(this);">
  610. <i class="checkmark icon"></i>
  611. </button>
  612. </div>
  613. <div class="rightAlign">
  614. <select id="sortingMethodSelector" title="Sorting Method" class="ts basic borderless mini dropdown" onchange="updateSortingMethods();" autocomplete="off">
  615. <option value="default" locale="menu/sort/asc">Ascending</option>
  616. <option value="reverse" locale="menu/sort/desc">Descending</option>
  617. <option value="smallToLarge" locale="menu/sort/small">Smallest</option>
  618. <option value="largeToSmall" locale="menu/sort/large"> Largest</option>
  619. <option value="mostRecent" locale="menu/sort/mostrecent">Most Recent</option>
  620. <option value="leastRecent" locale="menu/sort/leastrecent">Least Recent</option>
  621. </select>
  622. <button id="searhbtn" class="ts icon tiny button standard whiteTheme" title="Search" onclick="toggleSearch();"><i class="search icon"></i></button>
  623. <button class="ts icon tiny button standard whiteTheme videmode" mode="grid" title="Block View" onclick="changeViewMode(this);"><i class="block layout icon"></i></button>
  624. <button class="ts icon tiny button standard whiteTheme videmode" mode="list" title="List View" onclick="changeViewMode(this);"><i class="align justify icon"></i></button>
  625. </div>
  626. </div>
  627. <div class="mobilePathDisplayWrapper">
  628. <div id="mobilePathDisplay" style="width:100%;" class="ts pathDisplay breadcrumb whiteTheme addressText mobileOnly">
  629. <div class="section whiteTheme selectable"><i class="folder icon"></i> user</div>
  630. <div class="divider whiteTheme">:/</div>
  631. <div class="section whiteTheme selectable">Desktop</div>
  632. </div>
  633. </div>
  634. <div class="searchbar" style="z-index:999; display:none;">
  635. <div style="width: 80%; display:inline-block; margin-top:-4px;">
  636. <div class="ts mini fluid input">
  637. <input autocomplete="off" id="searchInput" type="text" class="whiteTheme" placeholder="File Search (Start wildcard search with / , e.g. /*.mp3)" onkeypress="handleSearchBarPress(event);">
  638. </div>
  639. </div>
  640. <button class="ts icon tiny button standard whiteTheme" title="Case Sensitive" onclick="toggleCaseSensitive(this);">Aa</button>
  641. <button class="ts icon tiny button standard whiteTheme" title="Search" onclick="handleSearch();"><i class="search icon"></i></button>
  642. <button class="ts icon tiny button standard whiteTheme" title="Clear Search" onclick="hideSearchBar();"><i class="remove icon"></i></button>
  643. </div>
  644. <div class="msgbox" style="z-index:999; display:none;">
  645. <i class="checkmark icon"></i> <span>No Message</span>
  646. <div class="closeMsgButton" onclick="$(this).parent().slideUp('fast');"><i class="remove icon"></i></div>
  647. </div>
  648. </div>
  649. <div id="mainWindow">
  650. <div id="directorySidebar" class="whiteTheme">
  651. <div class="ts list">
  652. <details class="ts accordion fluid whiteTheme" open>
  653. <summary>
  654. <i class="dropdown icon"></i> <span locale="sidebar/vroot/user">User</span>
  655. </summary>
  656. <div id="userroot" class="ts list" style="padding-top:0px !important;">
  657. <div class="dir item whiteTheme"><i class="loading circle notched rightmargin icon"></i> <span locale="message/initiating">Initiating</span></div>
  658. </div>
  659. </details>
  660. <details class="ts accordion fluid whiteTheme" open>
  661. <summary>
  662. <i class="dropdown icon"></i> <span locale="sidebar/vroot/fsh">Storage</span>
  663. </summary>
  664. <div id="storageroot" class="ts list" style="padding-top:0px !important;">
  665. <div class="dir item whiteTheme"><i class="loading circle notched rightmargin icon"></i> <span locale="message/initiating">Initiating</span></div>
  666. </div>
  667. </details>
  668. <!--
  669. <details class="ts accordion fluid whiteTheme" open>
  670. <summary>
  671. <i class="caret down icon"></i>Disks
  672. </summary>
  673. <div id="deviceList" class="ts list" style="padding-top:0px !important;">
  674. <div class="dir item whiteTheme"><i class="loading circle notched rightmargin icon"></i> Initiating</div>
  675. </div>
  676. </details>
  677. -->
  678. <!-- >
  679. <div class="item fluid whiteTheme">
  680. <i class="world icon"></i>Network
  681. </div>
  682. -->
  683. <br>
  684. </div>
  685. </div>
  686. <div id="folderView" class="whiteTheme" ondrop="drop(event)" ondragover="allowDrop(event)">
  687. <div id="folderList" class="ts segmented fluid list whiteTheme">
  688. </div>
  689. <div id="fileList" class="ts segmented fluid list whiteTheme">
  690. </div>
  691. <br>
  692. </div>
  693. </div>
  694. <!-- Other popup windows -->
  695. <div class="popupWrapper"></div>
  696. <!-- Overwrite Selection Box-->
  697. <div id="overwriteModeSelection" class="popup whiteTheme" style="display:none;">
  698. <div class="popupheader whiteTheme">
  699. <i class="paste icon"></i> <span locale="opr/overwrite/title">Replace, Keep or Skip Files</span>
  700. <div class="popupcloser" onclick="hideAllPopupWindows();">
  701. <i class="remove icon"></i>
  702. </div>
  703. </div>
  704. <div class="popupcontent" style="padding:12px;">
  705. <small style="font-size:80%;"><span locale="opr/overwrite/copying">Copying</span> <span class="owm-fc"></span> <span locale="opr/overwrite/files">files from</span> <span class="owm-srcdir"></span> <span locale="opr/overwrite/to">to</span> <span class="owm-destdir"></span></small>
  706. <p><span locale="opr/overwrite/dest">The destination has </span><span class="owm-fc"></span> <span locale="opr/overwrite/samename">files with the same names.</span></p>
  707. <div class="popupbuttons whiteTheme allowHover primary" onclick="changeOverwriteRule(0,true);">
  708. <i class="checkmark icon"></i> <span locale="opr/overwrite/replace">Replace the files in the destination</span>
  709. </div>
  710. <div class="popupbuttons whiteTheme allowHover" onclick="changeOverwriteRule(1,true);">
  711. <i class="reply icon"></i> <span locale="opr/overwrite/skip">Skip these files</span>
  712. </div>
  713. <div class="popupbuttons whiteTheme allowHover" onclick="changeOverwriteRule(2,true);">
  714. <i class="undo icon"></i> <span locale="opr/overwrite/keep">Rename and keep the files</span>
  715. </div>
  716. </div>
  717. </div>
  718. <!-- Force delete confirmation box -->
  719. <div id="forceDeleteConfirmBox" class="popup whiteTheme" style="display:none;">
  720. <div class="popupheader whiteTheme">
  721. <i class="trash icon"></i> <span locale="opr/per-remove/title">Permanently Remove Files</span>
  722. <div class="popupcloser" onclick="hideAllPopupWindows();">
  723. <i class="remove icon"></i>
  724. </div>
  725. </div>
  726. <div class="popupcontent" style="padding:12px;">
  727. <p locale="opr/per-remove/questions">Are you sure you want to remove these files <u>permanently?</u><br>This action is <u>irreversible</u>.</p>
  728. <div class="ts list whiteTheme deleteFilelist" style="max-height:350px;overflow-y:auto; ">
  729. </div>
  730. <div class="popupbuttons whiteTheme allowHover" style="background-color: #eb4034 !important;" onclick="forceDelete(true);";>
  731. <i class="trash icon"></i> <span locale="opr/per-remove/confirm">Confirm</span>
  732. </div>
  733. <div class="popupbuttons whiteTheme allowHover" onclick="cancelForceDelete();hideAllPopupWindows();">
  734. <i class="remove icon"></i> <span locale="opr/per-remove/cancel">Cancel</span>
  735. </div>
  736. </div>
  737. </div>
  738. <!-- Delete confirm box -->
  739. <div id="deleteConfirmBox" class="popup whiteTheme" style="display:none;">
  740. <div class="popupheader whiteTheme">
  741. <i class="recycle icon"></i> <span locale="opr/remove/title">Move files to Trash Bin</span>
  742. <div class="popupcloser" onclick="hideAllPopupWindows();">
  743. <i class="remove icon"></i>
  744. </div>
  745. </div>
  746. <div class="popupcontent" style="padding:12px;">
  747. <p locale="opr/remove/question">Are you sure you want to move these files to trash bin?</p>
  748. <div class="ts list whiteTheme deleteFilelist" style="max-height:350px;overflow-y:auto; ">
  749. </div>
  750. <div class="popupbuttons whiteTheme allowHover" style="color: #2bbbdf !important;" onclick="deleteFile(true);";>
  751. <i class="recycle icon"></i> <span locale="opr/remove/confirm">Move to Trash</span>
  752. </div>
  753. <div class="popupbuttons whiteTheme allowHover" onclick="cancelDelete();hideAllPopupWindows();">
  754. <i class="remove icon"></i> <span locale="opr/remove/cancel">Cancel</span>
  755. </div>
  756. </div>
  757. </div>
  758. <!-- Rename tool box -->
  759. <div id="renameBox" class="popup whiteTheme" style="display:none;">
  760. <div class="popupheader whiteTheme">
  761. <i class="text cursor icon"></i> <span locale="opr/rename/title">Rename Files</span>
  762. <div class="popupcloser" onclick="hideAllPopupWindows();">
  763. <i class="remove icon"></i>
  764. </div>
  765. </div>
  766. <div class="popupcontent" style="padding:12px;">
  767. <p locale="opr/rename/instruction">Enter the new filename for renaming. </p>
  768. <p class="multifileWarning"><i class="notice icon"></i> Other files will be named as file(#)</p>
  769. <div class="ts left icon small fluid input" style="margin-bottom:12px;">
  770. <input type="text" class="whiteTheme orgfn" placeholder="Original Filename" readonly="true">
  771. <i class="minus square icon" style="color:rgb(122, 176, 247)"></i>
  772. </div>
  773. <div class="ts left icon small fluid input" style="margin-bottom:12px;">
  774. <input type="text" class="whiteTheme newfn" placeholder="New Filename" onkeydown="handleEnterKeyDown(event, function(){confirmRename(true);})">
  775. <i class="add square icon" style="color:rgb(122, 176, 247)"></i>
  776. </div>
  777. <div class="popupbuttons whiteTheme allowHover primary" onclick="confirmRename(true);";>
  778. <i class="checkmark icon"></i> <span locale="opr/rename/ok">OK</span>
  779. </div>
  780. <div class="popupbuttons whiteTheme allowHover" onclick="hideAllPopupWindows();">
  781. <i class="remove icon"></i> <span locale="opr/rename/cancel">Cancel</span>
  782. </div>
  783. </div>
  784. </div>
  785. <!-- New File Dialog-->
  786. <div id="newFile" class="popup whiteTheme" style="display:none;">
  787. <div class="popupheader whiteTheme">
  788. <i class="add icon"></i> <span locale="opr/newfile/title">New File</span>
  789. <div class="popupcloser" onclick="hideAllPopupWindows();">
  790. <i class="remove icon"></i>
  791. </div>
  792. </div>
  793. <div class="popupcontent" style="padding:12px;">
  794. <p locale="opr/newfile/instruction">Select a type of file to be created.</p>
  795. <div class="ts segmented list whiteTheme newfilelist" style="max-height:18em; overflow-y:scroll">
  796. <div class="item newFileFormat" ext="php">No Item</div>
  797. </div>
  798. <p locale="opr/newfile/newempty">Or create an empty file with given filename:</p>
  799. <div class="ts left icon small fluid input" style="margin-bottom:12px;">
  800. <input id="createNewFileName" type="text" class="whiteTheme" placeholder="New Filename" onkeydown="handleEnterKeyDown(event, confirmNewFile);">
  801. <i class="add square icon" style="color:rgb(122, 176, 247)"></i>
  802. </div>
  803. <p class="duplicateWarning" style="color:#CE5F58; display:none;"><i class="caution sign icon"></i> The given filename already exist.</p>
  804. <div class="popupbuttons whiteTheme allowHover primary" onclick="confirmNewFile();";>
  805. <i class="add icon"></i> <span locale="opr/newfile/create">Create</span>
  806. </div>
  807. <div class="popupbuttons whiteTheme allowHover" onclick="hideAllPopupWindows();">
  808. <i class="remove icon"></i> <span locale="opr/newfile/cancel">Cancel</span>
  809. </div>
  810. </div>
  811. </div>
  812. <!-- New Folder Dialog-->
  813. <div id="newFolder" class="popup whiteTheme" style="display:none;">
  814. <div class="popupheader whiteTheme">
  815. <i class="folder icon"></i> <span locale="opr/newfolder/title">New Folder</span>
  816. <div class="popupcloser" onclick="hideAllPopupWindows();">
  817. <i class="remove icon"></i>
  818. </div>
  819. </div>
  820. <div class="popupcontent" style="padding:12px;">
  821. <p locale="opr/newfolder/desc">Enter the new folder name to be created.</p>
  822. <div class="ts left icon small fluid input" style="margin-bottom:12px;">
  823. <input id="createNewFolder" type="text" class="whiteTheme" placeholder="New Folder Name" onkeydown="handleEnterKeyDown(event, function(){newFolder(true);});">
  824. <i class="add square icon" style="color:rgb(122, 176, 247)"></i>
  825. </div>
  826. <p class="duplicateWarning" style="color:#CE5F58; display:none;"><i class="caution sign icon"></i> <span locale="opr/newfolder/alreadyExists">The given folder already exist.</span></p>
  827. <div class="popupbuttons whiteTheme allowHover primary" onclick="newFolder(true);";>
  828. <i class="add icon"></i> <span locale="opr/newfolder/create">Create</span>
  829. </div>
  830. <div class="popupbuttons whiteTheme allowHover" onclick="hideAllPopupWindows();">
  831. <i class="remove icon"></i> <span locale="opr/newfolder/cancel">Cancel</span>
  832. </div>
  833. </div>
  834. </div>
  835. <!-- Share File Dialog-->
  836. <div id="shareFile" class="popup wide whiteTheme" style="display:none;">
  837. <div class="popupheader whiteTheme">
  838. <i class="external icon"></i> <span locale="opr/share/title">Share File</span>
  839. <div class="popupcloser" onclick="hideShare();">
  840. <i class="remove icon"></i>
  841. </div>
  842. </div>
  843. <div>
  844. <iframe id="shareFileEmbedded" style="border: 0px solid transparent; width: 100%; height: 70vh;" allowtransparency="true">
  845. </iframe>
  846. </div>
  847. <!--
  848. <div class="popupcontent" style="padding:12px;">
  849. <div class="ts stackable grid">
  850. <div class="eight wide column">
  851. <div class="width: 100%; ">
  852. <div style="display: block; margin-left: auto; margin-right: auto;" align="center">
  853. <div id="qrcode" style="border: 10px solid white; background-color: white;"></div>
  854. </div>
  855. <a id="sharelink" href="" target="_blank" style="margin-top:8px; font-size: 120%; padding-left: 20px; padding-right: 20px; word-break: break-all;">Scan this QR Code to copy the share link</a>
  856. </div>
  857. </div>
  858. <div class="eight wide column" style="padding-left: 12px;">
  859. <div class="ts header whiteTheme">
  860. <span locale="opr/share/settings">Share Settings</span>
  861. <div class="sub header whiteTheme" locale="opr/share/setdesc">Change who can see this file</div>
  862. </div>
  863. <div id="shareSettingForm" class="ts form">
  864. <div class="field">
  865. <label><p class="whiteTheme" locale="opr/share/visableoption">Visable options:</p></label>
  866. <div class="ts checkboxes">
  867. <div class="ts radio checkbox">
  868. <input id="anyone" type="radio" class="shareoption" name="shareopt" value="anyone" checked="true">
  869. <label for="anyone">
  870. <div class="ts header">
  871. <div class="content whiteTheme">
  872. <i class="globe icon"></i> <span locale= "opr/share/anyone">Anyone with the link</span>
  873. <div class="sub header whiteTheme" locale="opr/share/anyonedesc">Anyone who has the link can access this file</div>
  874. </div>
  875. </div>
  876. </label>
  877. </div>
  878. <div class="ts radio disabled checkbox">
  879. <input id="signedin" type="radio" class="shareoption" value="signedin" name="shareopt">
  880. <label for="signedin">
  881. <div class="ts header">
  882. <div class="content whiteTheme">
  883. <i class="user circle outline icon"></i> <span locale="opr/share/signedin">Anyone signed in</span>
  884. <div class="sub header whiteTheme" locale="opr/share/signedindesc">Anyone who has signed in can access this file</div>
  885. </div>
  886. </div>
  887. </label>
  888. </div>
  889. <div class="ts radio disabled checkbox">
  890. <input id="samegroup" type="radio" class="shareoption" value="samegroup" name="shareopt">
  891. <label for="samegroup">
  892. <div class="ts header">
  893. <div class="content whiteTheme">
  894. <i class="users icon"></i> <span locale="opr/share/samegroup">Users in the same group</span>
  895. <div class="sub header whiteTheme" locale="opr/share/samegroupdesc">Anyone who is in the same group as you do</div>
  896. </div>
  897. </div>
  898. </label>
  899. </div>
  900. <br>
  901. <button class="ts small button" onclick="updateShareSettings(this)" locale="opr/share/update" style="border: 0px solid transparent;">Update</button>
  902. </div>
  903. </div>
  904. </div>
  905. </div>
  906. </div>
  907. -->
  908. <div style="padding:12px;">
  909. <div class="ts divider"></div>
  910. <div id="sharingRemoveBtn" class="popupbuttons negative whiteTheme allowHover" onclick="removeSharing()">
  911. <i class="remove icon"></i> <span locale="opr/share/remove">Remove Sharing</span>
  912. </div>
  913. <div class="popupbuttons whiteTheme allowHover" onclick="hideShare();">
  914. <i class="checkmark icon"></i> <span locale="opr/share/ok">OK</span>
  915. </div>
  916. </div>
  917. </div>
  918. </div>
  919. <!-- Open With Dialog-->
  920. <div id="openWith" class="popup whiteTheme" style="display:none;">
  921. <div class="popupheader whiteTheme">
  922. <i class="external icon"></i> <span locale="opr/openwith/title">Open File With</span>
  923. <div class="popupcloser" onclick="hideAllPopupWindows();">
  924. <i class="remove icon"></i>
  925. </div>
  926. </div>
  927. <div class="popupcontent" style="padding:12px;">
  928. <p locale="opr/openwith/desc">Select a module from the list below:</p>
  929. <div id="openWithModuleList" class="ts segment whiteTheme" style="padding:0px;">
  930. <div class="item selectable">
  931. <div class="content" style="padding-left:12px;">
  932. <div class="header" locale="opr/openwith/loading">Loading...</div>
  933. </div>
  934. </div>
  935. </div>
  936. <div class="openWithModule popupbuttons whiteTheme allowHover primary" onclick="openWithSelectedModule(this);";>
  937. <i class="external icon"></i> <span locale="opr/openwith/openWithWebApp">Open with Selected Module</span>
  938. </div>
  939. <div class="openWithModule popupbuttons whiteTheme allowHover" onclick="openFileWithModuleInNewTab(this);">
  940. <i class="add icon"></i> <span locale="opr/openwith/openWithWebAppInNewWindow">Open in new tab</span>
  941. </div>
  942. <div class="popupbuttons whiteTheme allowHover vdonly" onclick="openRawFileInFloatWindow(this);">
  943. <i class="window restore outline icon"></i> <span locale="opr/openwith/openInNewWindow">Open File directly in floatWindow</span>
  944. </div>
  945. <div class="popupbuttons whiteTheme allowHover" onclick="hideAllPopupWindows();">
  946. <i class="remove icon"></i> <span locale="opr/openwith/cancel">Cancel</span>
  947. </div>
  948. </div>
  949. </div>
  950. <!-- Context Menu -->
  951. <div id="contextmenu" class="ts small contextmenu visible whiteTheme" style="min-width:250px;">
  952. <div class="item" onclick="openViaButton();">
  953. <i class="folder open icon"></i> <span locale="contextmenu/open">Open</span>
  954. </div>
  955. <div class="item fileonly" onclick="openWith();">
  956. <i class="external icon"></i> <span locale="contextmenu/openWith">Open With</span>
  957. </div>
  958. <div class="item folderonly" onclick="openSelectedFolderInNewWindow();">
  959. <i class="external icon"></i> <span locale="contextmenu/openNewWindow">Open In New Window</span>
  960. </div>
  961. <!-- This is the vroot alternative new windows-->
  962. <div class="item vrootonly" onclick="openSelectedVroot();">
  963. <i class="external icon"></i> <span locale="contextmenu/openNewWindowVroot">Open In New Window</span>
  964. </div>
  965. <div class="item shareonly" onclick="openFileLocation();">
  966. <i class="folder outline icon"></i> <span locale="contextmenu/openFileLocation">Open File Location</span>
  967. </div>
  968. <div class="item singleObjectOnlyHide" onclick="shareFile();">
  969. <i class="share alternate icon"></i> <span locale="contextmenu/Share">Share</span>
  970. </div>
  971. <div class="item mobileonly" onclick="toggleCtrl();">
  972. <i class="mouse pointer icon"></i> <span locale="contextmenu/MuitSelect">Multi-select</span>
  973. </div>
  974. <div class="item" onclick="copy();">
  975. <i class="copy icon"></i> <span locale="contextmenu/copy">Copy</span>
  976. <span class="description">Ctrl + C</span>
  977. </div>
  978. <div class="item allowNoSelection" onclick="paste();">
  979. <i class="paste icon"></i> <span locale="contextmenu/paste">Paste</span>
  980. <span class="description">Ctrl + V</span>
  981. </div>
  982. <div class="item" onclick="cut();">
  983. <i class="cut icon"></i> <span locale="contextmenu/cut">Cut</span>
  984. <span class="description">Ctrl + X</span>
  985. </div>
  986. <div class="divider vroothide noSelectionOnly"></div>
  987. <div class="item noSelectionOnly" onclick="newfile();">
  988. <i class="file outline icon"></i> <span locale="contextmenu/newFile">New File</span>
  989. </div>
  990. <div class="item noSelectionOnly" onclick="newFolder();">
  991. <i class="folder outline icon"></i> <span locale="contextmenu/newFolder">New Folder</span>
  992. </div>
  993. <div class="divider vroothide"></div>
  994. <div class="item noSelectionOnly" onclick="upload();">
  995. <i class="upload icon"></i> <span locale="contextmenu/upload">Upload</span>
  996. </div>
  997. <div class="item" onclick="zipFile();">
  998. <i class="zip file icon"></i> <span locale="contextmenu/zip">Create Zip</span>
  999. </div>
  1000. <div class="item zipFileOnly" onclick="unzipHere();">
  1001. <i class="inbox icon"></i> <span locale="contextmenu/unzip">Unzip Here</span>
  1002. </div>
  1003. <div class="item" onclick="rename();">
  1004. <i class="i cursor icon"></i> <span locale="contextmenu/rename">Rename</span>
  1005. </div>
  1006. <div class="item" onclick="deleteFile();">
  1007. <i class="trash icon"></i> <span locale="contextmenu/delete">Delete</span>
  1008. </div>
  1009. <div class="item backuponly" onclick="openBackupManager();">
  1010. <i class="block layout icon"></i> <span locale="contextmenu/backup">Backup & Restore</span>
  1011. </div>
  1012. <div class="divider vroothide"></div>
  1013. <div class="item noSelectionOnly" onclick="refreshList();">
  1014. <i class="refresh icon"></i> <span locale="contextmenu/refresh">Refresh</span>
  1015. </div>
  1016. <div class="item" onclick="downloadFile();">
  1017. <i class="download icon"></i> <span locale="contextmenu/download">Download</span>
  1018. </div>
  1019. <div class="item" onclick="showFileProperties();">
  1020. <i class="notice icon"></i> <span locale="contextmenu/properties">Properties</span>
  1021. </div>
  1022. <!-- This properties shows the currentDirectory properties instead of the selected file properties-->
  1023. <div class="item noSelectionOnly" onclick="showCurrentDirectoryProperties();">
  1024. <i class="notice icon"></i> <span locale="contextmenu/properties">Properties</span>
  1025. </div>
  1026. <!-- This properties show the vroot properties -->
  1027. <!-- This properties shows the currentDirectory properties instead of the selected file properties-->
  1028. <div class="item vrootonly" onclick="showVrootProperties();">
  1029. <i class="notice icon"></i> <span locale="contextmenu/properties">Properties</span>
  1030. </div>
  1031. </div>
  1032. <!-- Upload Progress Bars-->
  1033. <div id="uploadTab" class="ts segment whiteTheme" style="display:none;">
  1034. <div class="statusBar whiteTheme">
  1035. <i class="upload icon"></i><span id="uploadCount">0</span> <span locale="upload/count/uploading">Files</span> / <i class="wait icon"></i> <span id="waitingCount">0</span> <span locale="upload/count/pending">Files</span>
  1036. <div class="hideUploadButton" onclick="toggleUploadList();">
  1037. <i class="caret down icon"></i>
  1038. </div>
  1039. </div>
  1040. <div class="uploadList" id="uploadProgressList">
  1041. </div>
  1042. <br>
  1043. </div>
  1044. <script>
  1045. let directorySidebarWidth = 250; //Width of the sidebar
  1046. let sideBarShown = true; //Indicate if sidebar is shown
  1047. let rootDirs = []; //Storage location for rootDirs
  1048. let currentTheme = "whiteTheme"; //Default theme
  1049. let viewMode = "list"; //Viewmode, support {list, grid, detail}
  1050. let sortMode = "default"; //Sortmode, support {default, reverse, smallToLarge, largeToSmall, mostRecent, leastRecent}
  1051. let currentPath = "user:/"
  1052. let viewHistory = []; //View history
  1053. let enableBetaFilename = false; //Enable beta filename conversion from "inith..." to "normal"
  1054. let currentFilelist = []; //The current file list in the currentPath
  1055. let currentPathHash = ""; //The folder content hash
  1056. let enableAutoRefresh = true; //Enable directory updates on file change
  1057. let filesIconTheme = "default";
  1058. //File operations
  1059. let clipboard = []; //System clipboard
  1060. let cutMode = false; //If set to true, this is cut mode. Else copy mode
  1061. let useLocalstorage = lscheck();
  1062. let overwriteMode = "keep"; //Overwrite mode, support {skip, overwrite, keep}
  1063. let thumbRenderWebSocket = null;
  1064. //Searching related
  1065. let searchCaseSensitive = false;
  1066. let searchMode = false;
  1067. let hotSearchBuffer = "";
  1068. let hotSearchTimer = null;
  1069. let hotSearchOffsetIndex = 0;
  1070. //Keypress listeners
  1071. let ctrlHold = false;
  1072. let shiftHold = false;
  1073. //Upload related
  1074. let uploadingFileCount = 0;
  1075. let maxConcurrentUpload = 4; //Maxmium number of oncurrent upload
  1076. let uploadPendingList = []; //Upload pending queue for mass upoad
  1077. let lowMemoryMode = true; //Upload with low memory mode channel
  1078. let largeFileCutoffSize = 8192 * 1024 * 1024; //Any file larger than this size is consider "large file", default to 8GB
  1079. let uploadFileChunkSize = 1024 * 512; //512KB, 4MB not working quite well on slow network
  1080. let postUploadModeCutoff = 25 * 1048576; //25MB, files smaller than this will upload using POST Mode
  1081. //File Sharing related
  1082. let shareEditingObject = "";
  1083. let shareEditingUUID = "";
  1084. //System Information
  1085. let systemUUID = "";
  1086. let systemIP = "";
  1087. //Browser detection
  1088. let isMobile = window.mobilecheck();
  1089. let isChromium = window.chrome;
  1090. let isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
  1091. let isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  1092. let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  1093. //Intiiation functions
  1094. $(document).ready(function(){
  1095. if (applocale){
  1096. //Applocale found. Do localization
  1097. applocale.init("../locale/file_explorer.json", function(){
  1098. applocale.translate();
  1099. initRootDirs();
  1100. initSystemInfo();
  1101. initUploadMode();
  1102. });
  1103. }else{
  1104. //Applocale not found. Is this a trim down version of ArozOS?
  1105. applocale = {
  1106. getString: function(key, original){
  1107. return original;
  1108. }
  1109. }
  1110. initRootDirs();
  1111. initSystemInfo();
  1112. initUploadMode();
  1113. }
  1114. if (isMobile){
  1115. //Mobile css adjustment
  1116. sideBarShown = false;
  1117. $("#directorySidebar").hide();
  1118. $("#directorySidebar").css("width",window.innerWidth + "px");
  1119. $("body").css("overflow","hidden");
  1120. directorySidebarWidth = window.innerWidth;
  1121. $("#folderView").css({
  1122. "padding-right":"1em",
  1123. "padding-left":"1em",
  1124. "padding-top":"1em",
  1125. });
  1126. $(".desktopOnly").hide();
  1127. $(".mobileOnly").show();
  1128. //Adjust minor css on mobile devices
  1129. $(".rightPad").css("margin-right", "37px");
  1130. }else{
  1131. $(".mobileOnly").hide();
  1132. $(".desktopOnly").show();
  1133. $(".rightPad").css("margin-right", "37px");
  1134. }
  1135. //Initialize view mode buttons
  1136. updateViewmodeButtons();
  1137. loadListModeFromDB();
  1138. //Initialize system theme
  1139. loadPreference("file_explorer/theme",function(data){
  1140. if (data.error === undefined){
  1141. if (data == "darkTheme"){
  1142. toggleDarkTheme();
  1143. }else{
  1144. //White theme
  1145. }
  1146. }
  1147. });
  1148. if (window.location.hash != ""){
  1149. //Check if the hash is standard open protocol. If yes, translate it
  1150. if (ao_module_loadInputFiles() === null){
  1151. //Window location hash set. List the desire directory
  1152. currentPath = window.location.hash.substring(1,window.location.hash.length);
  1153. if (currentPath.substring(currentPath.length -1) != "/"){
  1154. currentPath = currentPath + "/";
  1155. }
  1156. currentPath = decodeURIComponent(currentPath);
  1157. loadListModeFromDB(function(){
  1158. listDirectory(currentPath);
  1159. });
  1160. }else{
  1161. //This is ao_module load file input. Handle the file opening
  1162. var filelist = ao_module_loadInputFiles();
  1163. if (filelist.length > 0){
  1164. filelist = filelist[0];
  1165. //Check if this is folder or file. Only opendir when it is folder
  1166. //Updates 27-12-2020: Open folder and highlight the file if it is file
  1167. if (filelist.filename.includes(".") == false){
  1168. //Try to open it and overwrite the hash to filesystem hash
  1169. loadListModeFromDB(function(){
  1170. listDirectory(filelist.filepath);
  1171. });
  1172. }else{
  1173. //File. Open its parent folder and highlight the target file if exists
  1174. var parentdir = filelist.filepath.split("/");
  1175. let focusFilename = JSON.parse(JSON.stringify(filelist.filename));
  1176. parentdir.pop();
  1177. parentdir = parentdir.join("/");
  1178. loadListModeFromDB(function(){
  1179. listDirectory(parentdir, function(){
  1180. focusFileObject(focusFilename);
  1181. });
  1182. });
  1183. }
  1184. }
  1185. }
  1186. }else{
  1187. //Initialized directory views
  1188. loadListModeFromDB(function(){
  1189. listDirectory(currentPath);
  1190. });
  1191. }
  1192. //Create a timer to check change in current folder
  1193. setInterval(function(){
  1194. if (enableAutoRefresh == false){
  1195. return;
  1196. }
  1197. getDirHash(function(hash){
  1198. if (hash.error !== undefined){
  1199. //Something went wrong. Ignore this request
  1200. console.log(hash.error)
  1201. }else{
  1202. //Check if the hash match with the last hash.
  1203. if (hash != currentPathHash){
  1204. //console.log(currentPathHash, hash);
  1205. refreshList();
  1206. currentPathHash = hash;
  1207. if (currentPath == "user:/"){
  1208. //Reload the User root folder list
  1209. initRootDirs();
  1210. }
  1211. }
  1212. }
  1213. });
  1214. }, 5000)
  1215. });
  1216. //END OF INIT FUNCTIONS
  1217. //Get the system ID and ip address from the system id services
  1218. function initSystemInfo(){
  1219. $.get("../../system/id/requestInfo",function(data){
  1220. if (data.error !== undefined){
  1221. msgbox("remove", data.error);
  1222. }else{
  1223. systemUUID = data.SystemUUID;
  1224. systemIP = data.IpAddress;
  1225. }
  1226. });
  1227. }
  1228. //Initiate the sidebar contents
  1229. function initRootDirs(){
  1230. //Load user directories
  1231. $.ajax({
  1232. url:"../../system/file_system/listRoots?user=true",
  1233. success: function(data){
  1234. $("#userroot").html("");
  1235. for (var i =0; i < data.length; i++){
  1236. var thisRootObject = data[i];
  1237. if (thisRootObject.IsDir == true && !(thisRootObject.Filename == ".cache" || thisRootObject.Filename == ".trash")){
  1238. //Files will not be listed in the root directory list
  1239. var specifcRootInfo = getUserRootIcons(thisRootObject.Filename);
  1240. var icon = specifcRootInfo[0];
  1241. var displayName = specifcRootInfo[1];
  1242. var vpath = thisRootObject.Filepath;
  1243. $("#userroot").append(`<div class="dir item ${currentTheme}" filepath="${vpath}" type="folder" onclick="openthis(this);"><i class="${icon} rightmargin icon"></i> ${displayName}</div>`);
  1244. }
  1245. }
  1246. }
  1247. });
  1248. //Load other storage devices
  1249. $.ajax({
  1250. url:"../../system/file_system/listRoots",
  1251. success: function(data){
  1252. $("#storageroot").html("");
  1253. for (var i =0; i < data.length; i++){
  1254. var thisRoot = data[i];
  1255. var displayName = thisRoot.RootName;
  1256. var rootPath = thisRoot.RootPath;
  1257. var containBackup = thisRoot.RootBackups;
  1258. $("#storageroot").append(`<div class="dir item ${currentTheme}" contain-backup="${containBackup}" filepath="${rootPath}" type="folder" rootname="${displayName}" onclick="openthis(this);"><i class="disk outline rightmargin icon"></i> ${displayName} (${rootPath})</div>`);
  1259. }
  1260. }
  1261. });
  1262. //Initial Host device drives
  1263. /*
  1264. $.ajax({
  1265. url: "../../system/file_system/listDrives",
  1266. success: function(data){
  1267. $("#deviceList").html("");
  1268. for (var i =0; i < data.length; i++){
  1269. var drivePath = data[i].Drivepath;
  1270. var usagePercentage = ((data[i].DriveTotalSpace - data[i].DriveFreeSpace) / data[i].DriveTotalSpace) * 100;
  1271. var className = "primary";
  1272. if (usagePercentage > 90){
  1273. className = "negative";
  1274. }
  1275. $("#deviceList").append(`<div class="dir item ${currentTheme}" filepath="${drivePath}" ><i class="disk outline rightmargin icon"></i> ${drivePath}
  1276. <div style="width:100px;height:15px !important; position:absolute;right:3px;top:6px;"">
  1277. <div class="ts ${className} tiny progress">
  1278. <div class="bar" style="width: ${usagePercentage}%"></div>
  1279. </div>
  1280. </div>
  1281. </div>`);
  1282. }
  1283. }
  1284. });
  1285. */
  1286. }
  1287. function getUserRootIcons(foldername){
  1288. var icon = "folder open";
  1289. var name = foldername;
  1290. foldername = foldername.toLowerCase();
  1291. if (foldername == "desktop"){
  1292. icon = "computer";
  1293. name = applocale.getString("sidebar/vroot/desktop", name);
  1294. }else if (foldername == "document"){
  1295. icon = "file text outline";
  1296. name = applocale.getString("sidebar/vroot/document", name);
  1297. }else if (foldername == "music" || foldername == "audio"){
  1298. icon = "music";
  1299. name = applocale.getString("sidebar/vroot/music", name);
  1300. }else if (foldername == "photo" || foldername == "picture"){
  1301. icon = "image";
  1302. name = applocale.getString("sidebar/vroot/photo", name);
  1303. }else if (foldername == "video" || foldername == "film"){
  1304. icon = "video";
  1305. name = applocale.getString("sidebar/vroot/video", name);
  1306. }else if (foldername == "trash" || foldername == "bin" || foldername == "rubbish"){
  1307. icon = "trash"
  1308. name = applocale.getString("sidebar/vroot/trash", name);
  1309. }else if (foldername == "download"){
  1310. icon = "download"
  1311. name = applocale.getString("sidebar/vroot/download", name);
  1312. }else if (foldername == "www" || foldername == "web" || foldername == "mysite"){
  1313. icon = "globe"
  1314. name = applocale.getString("sidebar/vroot/web", name);
  1315. }else if (foldername == "model"){
  1316. icon = "cube"
  1317. name = applocale.getString("sidebar/vroot/model", name);
  1318. }else if (foldername == "appdata"){
  1319. icon = "code"
  1320. name = applocale.getString("sidebar/vroot/appdata", name);
  1321. }
  1322. return [icon, name];
  1323. }
  1324. // ============================== FOLDER LISTING FUNCTIONS ====================
  1325. function listDirectory(path, callback=undefined, recordUndo=true){
  1326. var recordPreviousPage = true;
  1327. if (recordUndo == false){
  1328. recordPreviousPage = false;
  1329. }
  1330. if (searchMode){
  1331. hideSearchBar(true);
  1332. }
  1333. //Backup the current selected files if it is an refresh operation
  1334. let selectedFiles = [];
  1335. if (path == currentPath){
  1336. $(".fileObject.item.selected").each(function(){
  1337. selectedFiles.push($(this).attr("filename"));
  1338. });
  1339. //Set record histroy to false on refresh
  1340. recordPreviousPage = false;
  1341. }
  1342. //Always pad slash to the end of path
  1343. if (path.substring(path.length - 1) != "/"){
  1344. path = path + "/";
  1345. }
  1346. //Clean the path if there are any malformat
  1347. if (path.indexOf("//") != -1){
  1348. path = path.split("//").join("/");
  1349. }
  1350. if (recordPreviousPage){
  1351. viewHistory.push(currentPath);
  1352. }
  1353. window.location.hash = path;
  1354. updatePathDisplay(path);
  1355. currentPath = path;
  1356. //Update floatWindow title if exists
  1357. if (ao_module_virtualDesktop){
  1358. var tmp = path.split("/");
  1359. tmp.pop();
  1360. ao_module_setWindowTitle(applocale.getString("title/title", "File Manager") + " - " + tmp.pop());
  1361. }
  1362. //Check if there are parent path for curret path
  1363. if (checkIfParentDirExists(currentPath)){
  1364. $("#ppbtn").removeClass("disabled");
  1365. }else{
  1366. $("#ppbtn").addClass("disabled");
  1367. }
  1368. if (viewHistory.length < 1){
  1369. $("#backbtn").addClass("disabled");
  1370. }else{
  1371. $("#backbtn").removeClass("disabled");
  1372. }
  1373. //Add loading screen to the folderlists and fileList
  1374. $("#fileList").html("");
  1375. if (currentTheme == "darkTheme"){
  1376. $("#folderList").html(`<div style="height: 100px;">
  1377. <div class="ts active dimmer">
  1378. <div class="ts text loader">${applocale.getString("message/loading", "Loading")}</div>
  1379. </div>
  1380. </div>`);
  1381. }else{
  1382. $("#folderList").html(`<div style="height: 100px;">
  1383. <div class="ts active inverted dimmer">
  1384. <div class="ts text loader">${applocale.getString("message/loading", "Loading")}</div>
  1385. </div>
  1386. </div>`);
  1387. }
  1388. //Get sort mode from server side
  1389. $.ajax({
  1390. url: "../../system/file_system/sortMode",
  1391. data: {opr: "get", folder: currentPath},
  1392. success: function(data){
  1393. if (data.error == undefined){
  1394. sortMode = data;
  1395. }
  1396. $("#sortingMethodSelector").val(sortMode);
  1397. //Start listdir event
  1398. $.ajax({
  1399. url: "../../system/file_system/listDir",
  1400. method: "POST",
  1401. data: {dir: decodeURIComponent(path), sort: sortMode},
  1402. success: function(data){
  1403. //Parse the filelist into global variable
  1404. currentFilelist = [];
  1405. if (data === null){
  1406. //There is nothing in this folder.
  1407. $("#folderList").hide();
  1408. $("#fileList").hide();
  1409. if (callback !== undefined){
  1410. callback();
  1411. }
  1412. return;
  1413. }
  1414. if (data.error !== undefined){
  1415. //Parse path error. Try to refresh the page
  1416. if (data.error.length >= "Redirect:".length && data.error.substr(0,9) == "Redirect:"){
  1417. var redirectAction = data.error.substr(9).trim();
  1418. if (redirectAction == "parent"){
  1419. var pdir = currentPath.split("/");
  1420. pdir.pop(); pdir.pop();
  1421. pdir = pdir.join("/");
  1422. currentPath = pdir;
  1423. listDirectory(currentPath);
  1424. }else if (redirectAction == "root"){
  1425. var currentRoot = currentPath.split("/").shift();
  1426. listDirectory(currentRoot);
  1427. }else if (redirectAction == "userroot"){
  1428. listDirectory("user:/")
  1429. }
  1430. return
  1431. }
  1432. //console.log("Path parse error! Redirecting to parent directory.", data.error);
  1433. //var pdir = currentPath.split("/");
  1434. //pdir.pop(); pdir.pop();
  1435. //pdir = pdir.join("/");
  1436. //currentPath = pdir;
  1437. enableAutoRefresh = false;
  1438. //Check if it is already rooted and no more parent ahead
  1439. if (currentPath == ""){
  1440. currentPath = "user:/";
  1441. }
  1442. //Print folder not found exceotion
  1443. $("#folderList").show();
  1444. $("#folderList").html(`<div class="ts basic segment ${currentTheme}">
  1445. <div class="ts header">
  1446. <i class="remove icon ${currentTheme}"></i> <span class="${currentTheme}">${applocale.getString("message/folderCannotOpen","This Folder Cannot Be Opened")}</span>
  1447. <div class="sub header ${currentTheme}" style="margin-top:12px;">${applocale.getString("message/folderCannotOpen/codedesc","The server return the following error message:")} <br><code>${data.error.toUpperCase()}</code><br>
  1448. ${new Date().toLocaleString(undefined, {year: 'numeric', month: '2-digit', day: '2-digit', weekday:"long", hour: '2-digit', hour12: false, minute:'2-digit', second:'2-digit'})}</div>
  1449. </div>
  1450. </div>`);
  1451. $("#fileList").hide();
  1452. //listDirectory(currentPath, function(){
  1453. // window.location.reload();
  1454. //});
  1455. return;
  1456. }else{
  1457. enableAutoRefresh = true;
  1458. //Filelist returned. Render it
  1459. renderDirectory(data,function(){
  1460. //Restore the selected file list
  1461. $(".fileObject.item").each(function(){
  1462. for (var i = 0; i < selectedFiles.length; i++){
  1463. var thisFilename = selectedFiles[i];
  1464. if (thisFilename == $(this).attr("filename")){
  1465. $(this).addClass("selected");
  1466. }
  1467. }
  1468. });
  1469. //Perform the callback
  1470. if (callback !== undefined){
  1471. callback();
  1472. }
  1473. });
  1474. }
  1475. }
  1476. });
  1477. }
  1478. });
  1479. }
  1480. //Render filelist --> Convert a file list object into the visable form of file list
  1481. function renderDirectory(filelist, callback=undefined){
  1482. var data = filelist;
  1483. $("#fileList").html("");
  1484. $("#folderList").html("");
  1485. //Build the css strcture of the list
  1486. if (viewMode == "list"){
  1487. $("#fileList").attr("class",`ts segmented fluid list ${currentTheme}`);
  1488. $("#folderList").attr("class",`ts segmented fluid list ${currentTheme}`);
  1489. }else if (viewMode == "details"){
  1490. }else if (viewMode == "grid"){
  1491. $("#fileList").attr("class",`${currentTheme}`).css("vertical-align","top");
  1492. $("#folderList").attr("class",`${currentTheme}`).css("vertical-align","top");
  1493. }
  1494. var files = [];
  1495. var folders = [];
  1496. for (var i =0; i < data.length; i++){
  1497. if (data[i].IsDir == true){
  1498. //This is folder
  1499. folders.push(data[i]);
  1500. }else{
  1501. //This is file
  1502. files.push(data[i]);
  1503. }
  1504. currentFilelist.push(JSON.parse(JSON.stringify(data[i].Filename)));
  1505. }
  1506. //Define the grid size for the interface
  1507. var gridSize = 150 ;
  1508. if (isMobile){
  1509. //Update 3/5/2021: Optimize the width calculation method to best fit
  1510. //A hack to align the divs to center of the container
  1511. $("#folderView").attr("align", "center");
  1512. $("#folderList").attr("align", "left");
  1513. $("#fileList").attr("align", "left");
  1514. //Calculate the best width to fit all the grids
  1515. var bestCount = Math.floor(parseFloat($("#folderView").width()) / parseFloat(gridSize));
  1516. var bestOffset = $("#folderView").width() % gridSize;
  1517. gridSize = gridSize + (bestOffset / bestCount) - (window.innerWidth - $("#folderView").width()) / bestCount;
  1518. }
  1519. //List all folders
  1520. for (var i =0; i < folders.length; i++){
  1521. var filename = folders[i].Filename;
  1522. var filepath = folders[i].Filepath;
  1523. var realpath = folders[i].Realpath;
  1524. var isDir = folders[i].IsDir;
  1525. var filesize = folders[i].Filesize;
  1526. var Displaysize = folders[i].Displaysize;
  1527. var isShared = folders[i].IsShared;
  1528. var ext = getExtFromPath(filepath);
  1529. //var icon = ao_module_utils.getIconFromExt(ext);
  1530. var icon = "folder";
  1531. var shareicon = "";
  1532. if (isShared == true){
  1533. shareicon = `<button class="sharebtn ${currentTheme}" onclick='handleShareFilebuttonClick(event, this);' style="margin-left: 4px; height: 16px;">
  1534. <i class='share alternate icon'></i>
  1535. </button>`
  1536. }
  1537. if (viewMode == "list"){
  1538. var textclass = "normal object";
  1539. if (currentTheme == "darkTheme"){
  1540. textclass += " darkTheme";
  1541. }
  1542. var displayName = filename;
  1543. try{
  1544. //Try to decode it using ArozOS Beta naming scheme
  1545. if (enableBetaFilename && ao_module_codec.decodeHexFoldername(displayName) != displayName){
  1546. displayName = ao_module_codec.decodeHexFoldername(displayName, false);
  1547. textclass = "hex foldername";
  1548. }
  1549. }catch(ex){
  1550. //Codec decode failed. Fallback to default name
  1551. }
  1552. $("#folderList").append(`<div class="fileObject item ${currentTheme}" draggable="true" ondragstart="onFileObjectDragStart(this,event);" ondrop="dropToFolder(event)" ondragover="allowDrop(event)" fileID="${i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event);" type="folder">
  1553. <span style="display:inline-block !important;word-break: break-all;" class="${textclass}">
  1554. <i class="${icon} icon" style="margin-right:12px; color:#eab54e;"></i> ${displayName} ${shareicon}
  1555. </span></div>`);
  1556. }else if (viewMode == "grid"){
  1557. var displayName = JSON.parse(JSON.stringify(filename));
  1558. var textclass = "normal object";
  1559. try{
  1560. //Try to decode it using ArozOS Beta naming scheme
  1561. if (enableBetaFilename && ao_module_codec.decodeHexFoldername(displayName) != displayName){
  1562. displayName = ao_module_codec.decodeHexFoldername(displayName, false);
  1563. textclass = "hex foldername";
  1564. }
  1565. }catch(ex){
  1566. //Codec decode failed. Fallback to default name
  1567. }
  1568. if (displayName.length > 16){
  1569. displayName = displayName.substring(0,16) + "...";
  1570. }
  1571. $("#folderList").append(`
  1572. <div class="ts card fileObject ${currentTheme}" draggable="true" ondragstart="onFileObjectDragStart(this,event);" ondrop="dropToFolder(event)" ondragover="allowDrop(event)" fileID="${i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event);" type="folder" style="width:${gridSize}px; display:inline-block !important;vertical-align:top; height:15em; margin-top:0px !important; overflow:hidden;">
  1573. <div class="image" style="text-align: center;">
  1574. <img draggable="true"ondragstart="disableDrag(event);" src="../../img/desktop/files_icon/${filesIconTheme}/folder.png" style="height: 148px; width: 148px; display: inline-block;">
  1575. </div>
  1576. <div class="content" style="font-size: 12px;">
  1577. <div class="header ${currentTheme} ${textclass}" title="${filename}">${displayName} ${shareicon}</div>
  1578. </div>
  1579. </div>`);
  1580. }
  1581. }
  1582. if (folders.length == 0){
  1583. $("#folderList").hide();
  1584. }else{
  1585. $("#folderList").show();
  1586. }
  1587. //List all files
  1588. var fl = folders.length;
  1589. for (var i =0; i < files.length; i++){
  1590. var filename = files[i].Filename;
  1591. var filepath = files[i].Filepath;
  1592. var realpath = files[i].Realpath;
  1593. var filesize = files[i].Filesize;
  1594. var Displaysize = files[i].Displaysize;
  1595. var isShared = files[i].IsShared;
  1596. var ext = getExtFromPath(filepath);
  1597. var icon = "file outline";
  1598. if (ext == ""){
  1599. icon = "file outline";
  1600. }else if (ext == "shortcut"){
  1601. //Use the default shortcut icon
  1602. icon = ao_module_utils.getIconFromExt(ext);
  1603. //Check if the shortcut object exists
  1604. if (files[i].Shortcut != undefined){
  1605. icon = files[i].Shortcut.Icon;
  1606. }
  1607. }else{
  1608. icon = ao_module_utils.getIconFromExt(ext);
  1609. }
  1610. var shareicon = "";
  1611. if (isShared){
  1612. shareicon = `<button class="sharebtn ${currentTheme}" onclick='handleShareFilebuttonClick(event, this);' style="margin-left: 4px; height: 16px;">
  1613. <i class='share alternate icon'></i>
  1614. </button>`
  1615. }
  1616. var fileType = "file";
  1617. if (ext == "shortcut"){
  1618. fileType = "shortcut";
  1619. }
  1620. if (viewMode == "list"){
  1621. var displayName = filename;
  1622. var textclass = "normal object";
  1623. if (currentTheme == "darkTheme"){
  1624. textclass += " darkTheme";
  1625. }
  1626. if (ext == "shortcut"){
  1627. //This is a shortcut file
  1628. displayName = files[i].Shortcut.Name;
  1629. //Adjust the icon based on its shortcut ype
  1630. switch(files[i].Shortcut.Type){
  1631. case "folder":
  1632. icon = "blue folder";
  1633. break;
  1634. case "module":
  1635. icon = "play circle";
  1636. break;
  1637. default:
  1638. icon = "external";
  1639. }
  1640. }
  1641. if (enableBetaFilename){
  1642. decodedName = ao_module_codec.decodeUmFilename(displayName);
  1643. if (decodedName != displayName){
  1644. displayName = decodedName;
  1645. textclass = "um filename";
  1646. }
  1647. filename = ao_module_codec.decodeUmFilename(filename);
  1648. }
  1649. $("#fileList").append(`<div class="fileObject item ${currentTheme}" draggable="true" ondragstart="onFileObjectDragStart(this,event);" fileID="${fl + i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event);" type="${fileType}" filesize="${filesize}" displaysize="${Displaysize}">
  1650. <span style="display:inline-block !important;word-break: break-all;text-overflow: ellipsis !important;overflow: hidden;" class="${textclass}">
  1651. <i class="${icon} icon" style="margin-right:12px;"></i>
  1652. ${displayName} ${shareicon}
  1653. </span>
  1654. </div>`);
  1655. }else if (viewMode == "grid"){
  1656. //Update the icon path depends on the type of file
  1657. var imagePath = "../../img/desktop/files_icon/" + filesIconTheme + "/" + icon + ".png";
  1658. var displayName = JSON.parse(JSON.stringify(filename));
  1659. if (ext == "shortcut"){
  1660. //This is a shortcut file. Treat it specially
  1661. if (icon.includes("http://") || icon.includes("https://")){
  1662. //Direct path. Do not add relative prefix
  1663. imagePath = icon;
  1664. }else{
  1665. imagePath = "../../" + icon;
  1666. }
  1667. displayName = files[i].Shortcut.Name;
  1668. ext = files[i].Shortcut.Type;
  1669. ext = ext.charAt(0).toUpperCase() + ext.slice(1);
  1670. }else{
  1671. ext = "." + ext;
  1672. }
  1673. var textclass = "normal object";
  1674. if (enableBetaFilename){
  1675. decodedName = ao_module_codec.decodeUmFilename(displayName);
  1676. if (decodedName != displayName){
  1677. textclass = "um filename";
  1678. displayName = decodedName;
  1679. }
  1680. filename = ao_module_codec.decodeUmFilename(filename);
  1681. }
  1682. if (displayName.length > 20){
  1683. displayName = displayName.substring(0,20) + "...";
  1684. }
  1685. $("#fileList").append(`
  1686. <div class="ts card fileObject ${currentTheme}" draggable="true" ondragstart="onFileObjectDragStart(this,event);" fileID="${fl + i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event);" type="${fileType}" style="width:${gridSize}px; display:inline-block !important;vertical-align:top; height:20em; margin-top:0px !important; overflow:hidden;">
  1687. <div class="image" style="text-align: center !important;">
  1688. <img draggable="true"ondragstart="disableDrag(event);" style="height: 148px; width: 148px; display:inline-block;" src="${imagePath}">
  1689. </div>
  1690. <div class="content">
  1691. <div class="header ${currentTheme} ${textclass}" title="${filename}" style="text-overflow: ellipsis; font-size: 100%">${displayName} ${shareicon}</div>
  1692. <div class="meta ${currentTheme}">
  1693. <div>${ext}</div>
  1694. </div>
  1695. <div class="description ${currentTheme}">
  1696. ${Displaysize}
  1697. </div>
  1698. </div>
  1699. </div>
  1700. `);
  1701. }
  1702. }
  1703. if (files.length == 0){
  1704. $("#fileList").hide();
  1705. }else{
  1706. $("#fileList").show();
  1707. }
  1708. bindFileObjectEvents();
  1709. currentFilelist.sort();
  1710. //Update the filelist hash
  1711. enableAutoRefresh = false;
  1712. getDirHash(function(hash){
  1713. currentPathHash = hash;
  1714. enableAutoRefresh = true;
  1715. });
  1716. //If viewmode is grid, load file thumbnails
  1717. if (viewMode == "grid"){
  1718. startThumbnailLoader();
  1719. }
  1720. if (callback !== undefined){
  1721. callback();
  1722. }
  1723. }
  1724. function startThumbnailLoader(){
  1725. let path = currentPath;
  1726. let protocol = "wss://";
  1727. if (location.protocol !== 'https:') {
  1728. protocol = "ws://";
  1729. }
  1730. if (path == "share:/"){
  1731. //Share root do not contains any actual folder. Fallback to file based rendering
  1732. startFallbackThumbnailLoader();
  1733. return
  1734. }
  1735. var port = window.location.port;
  1736. if (window.location.port == ""){
  1737. if (location.protocol !== 'https:') {
  1738. port = "80";
  1739. }else{
  1740. port = "443";
  1741. }
  1742. }
  1743. thumbRenderWebSocket = new WebSocket(protocol + window.location.hostname + ":" + port + "/system/file_system/handleCacheRender?folder=" + encodeURIComponent(path));
  1744. thumbRenderWebSocket.onopen = function(e) {
  1745. };
  1746. thumbRenderWebSocket.onmessage = function(event) {
  1747. //Find the correct file in the current directory and place its image
  1748. if (path == currentPath){
  1749. var thumbData = JSON.parse(event.data);
  1750. $(".fileObject").each(function(){
  1751. if (thumbData[1].length > 0){
  1752. //Extract image type from base64
  1753. let ext = getThumbnailExtensionFromBase64String(thumbData[1]);
  1754. //Put the image data to image element
  1755. if ($(this).attr("filename") == thumbData[0]){
  1756. $(this).find("img").attr("src","data:image/" + ext + ";base64," + thumbData[1]);
  1757. }
  1758. }
  1759. });
  1760. }
  1761. };
  1762. thumbRenderWebSocket.onclose = function(event) {
  1763. //Transfer ended
  1764. };
  1765. thumbRenderWebSocket.onerror = function(error) {
  1766. //Cache render on websocket failed. Fallback to AJAX request
  1767. console.log("Cannot connect to WebSocket cache renderer. Falling back to AJAX request");
  1768. startFallbackThumbnailLoader();
  1769. };
  1770. }
  1771. function getThumbnailExtensionFromBase64String(base64String){
  1772. let ext = "jpg";
  1773. if (typeof base64String === 'string' || base64String instanceof String){
  1774. let tid = base64String.charAt(0);
  1775. if (tid == "i"){
  1776. ext = "png";
  1777. }else if (tid == "R"){
  1778. ext = "gif";
  1779. }else if (tid == "U"){
  1780. ext = "webp";
  1781. }
  1782. }else{
  1783. //Not string
  1784. }
  1785. return ext;
  1786. }
  1787. function startFallbackThumbnailLoader(){
  1788. let startingCurrentDir = currentPath;
  1789. let fallbackRenderList = [];
  1790. $(".fileObject").each(function(){
  1791. let filepath = $(this).attr("filepath");
  1792. let targetDOM = $(this);
  1793. if ($(this).attr("type") != "folder"){
  1794. fallbackRenderList.push([filepath, targetDOM]);
  1795. }
  1796. });
  1797. doThumbnailSequentialLoading(startingCurrentDir, fallbackRenderList, 0);
  1798. }
  1799. function doThumbnailSequentialLoading(startingCurrentDir, renderlist, index){
  1800. if (renderlist[index] == undefined){
  1801. //Starting index out of range
  1802. return;
  1803. }
  1804. let filepath = renderlist[index][0];
  1805. let targetDOM = renderlist[index][1];
  1806. $.ajax({
  1807. url: "../../system/file_system/loadThumbnail",
  1808. data: {vpath: filepath},
  1809. success: function(data){
  1810. if (startingCurrentDir == currentPath){
  1811. //User still not changed page
  1812. let ext = getThumbnailExtensionFromBase64String(data);
  1813. if (data.error == undefined && typeof data != "undefined" && data != ""){
  1814. $(targetDOM).find("img").attr("src","data:image/" + ext + ";base64," + data);
  1815. }
  1816. if (index + 1 < renderlist.length){
  1817. doThumbnailSequentialLoading(startingCurrentDir, renderlist, index + 1);
  1818. }
  1819. }else{
  1820. //User changed page. End the sequence
  1821. }
  1822. }
  1823. });
  1824. }
  1825. //Make an div not draggable
  1826. function disableDrag(event){
  1827. event.preventDefault();
  1828. event.stopPropagation();
  1829. }
  1830. //Make fileObject draggable
  1831. function onFileObjectDragStart(object, event){
  1832. if ((ctrlHold) && $(object).hasClass("selected") == false){
  1833. $(object).addClass("selected");
  1834. }else if ($(object).hasClass("selected") == false){
  1835. $(".fileObject.selected").removeClass("selected");
  1836. $(object).addClass("selected");
  1837. }
  1838. var fileList = [];
  1839. $(".selected.fileObject").each(function(){
  1840. var filename = $(this).attr('filename');
  1841. var filepath = $(this).attr('filepath');
  1842. var sourceSystemUUID = systemUUID;
  1843. //Extra information is passed in due to the need for cross cluster communication in the future
  1844. fileList.push({
  1845. filename: filename,
  1846. filepath: filepath,
  1847. hostUUID: sourceSystemUUID
  1848. });
  1849. });
  1850. event.dataTransfer.setData("filedata", JSON.stringify(fileList));
  1851. }
  1852. //Bind onclicke events for fileObjects
  1853. var lastClickedFileID = 0;
  1854. function bindFileObjectEvents(){
  1855. $(".fileObject").off("click").on('click',function(evt){
  1856. if (!ctrlHold && isMobile && !ctrlHold){
  1857. //If on mobile, click means open (only on not muilti selection mode)
  1858. openthis(this,evt);
  1859. return
  1860. }
  1861. if (ctrlHold == true){
  1862. if ($(this).hasClass("selected")){
  1863. $(this).removeClass("selected");
  1864. }else{
  1865. $(this).addClass("selected");
  1866. }
  1867. lastClickedFileID = parseInt($(this).attr("fileid"));
  1868. }else if (shiftHold == true){
  1869. //Select everything in range lastClicked to this
  1870. var thisFileID = $(this).attr("fileid");
  1871. let start = parseInt(thisFileID);
  1872. let end = parseInt(lastClickedFileID);
  1873. if (start > end){
  1874. start = parseInt(lastClickedFileID);
  1875. end = parseInt(thisFileID);
  1876. }
  1877. //Select all fileObject in range.
  1878. $(".fileObject").each(function(){
  1879. let currentItemFileID = $(this).attr('fileid');
  1880. currentItemFileID = currentItemFileID - 0;
  1881. if (currentItemFileID >= start && currentItemFileID <= end){
  1882. $(this).addClass("selected");
  1883. }
  1884. });
  1885. }else{
  1886. //Nothing is pressed. Deselect everything and add this only
  1887. $(".fileObject.selected").removeClass("selected");
  1888. $(this).addClass("selected");
  1889. lastClickedFileID = $(this).attr("fileID");
  1890. }
  1891. if ($(".fileObject.selected").length != 1){
  1892. //Multiple object selected
  1893. $(".singleObjectOnly").addClass("disabled");
  1894. $(".singleObjectOnlyHide").hide();
  1895. }else{
  1896. //Single object
  1897. $(".singleObjectOnly").removeClass("disabled");
  1898. $(".singleObjectOnlyHide").show();
  1899. }
  1900. });
  1901. //Bind right click select on items
  1902. $(".fileObject").off("mousedown").on("mousedown",function(evt){
  1903. if (evt.which == 3){
  1904. //Right click on this file
  1905. if ($(this).hasClass('selected') == false){
  1906. $(".fileObject.selected").removeClass("selected");
  1907. $(this).addClass("selected");
  1908. }
  1909. }
  1910. });
  1911. //This function calculate and offset the context menu to not go out of the window area
  1912. function calculateContextMenuOffsets(evt){
  1913. var defaultLeftPost = evt.pageX;
  1914. var defaultTopPost =evt.pageY;
  1915. if (evt.pageX > window.innerWidth / 2){
  1916. defaultLeftPost = evt.pageX - $("#contextmenu").width() + "px";
  1917. }
  1918. if (evt.pageY > window.innerHeight / 2){
  1919. defaultTopPost = evt.pageY - $("#contextmenu").height() + "px";
  1920. }
  1921. $("#contextmenu").css({
  1922. left: defaultLeftPost,
  1923. top: defaultTopPost
  1924. });
  1925. }
  1926. //Rightclick on a file object
  1927. $(".fileObject").off("contextmenu").on("contextmenu", function(evt){
  1928. evt.preventDefault();
  1929. if (isMobile){
  1930. //Firefox Mobile. Fix select with context menu not working bug
  1931. var selectedObject = $(evt.target);
  1932. if ($(selectedObject).hasClass("fileObject")){
  1933. if (!ctrlHold){
  1934. $(".fileObject.selected").removeClass("selected");
  1935. }
  1936. $(selectedObject).addClass("selected");
  1937. }else{
  1938. //Uptrace 5 layers for fileObject
  1939. for (var i = 0; i < 5; i++){
  1940. if ($(selectedObject).hasClass("fileObject") == false){
  1941. selectedObject = $(selectedObject).parent();
  1942. }else{
  1943. break;
  1944. }
  1945. }
  1946. if (!ctrlHold){
  1947. $(".fileObject.selected").removeClass("selected");
  1948. }
  1949. $(selectedObject).addClass("selected");
  1950. }
  1951. }
  1952. calculateContextMenuOffsets(evt);
  1953. //Show all options by defaults
  1954. $("#contextmenu").find(".item").show();
  1955. $("#contextmenu").find(".vroothide").show();
  1956. $("#contextmenu").find(".noSelectionOnly").hide();
  1957. $("#contextmenu").find(".vrootonly").hide();
  1958. $("#contextmenu").find(".zipFileOnly").hide();
  1959. //Hide backup manual
  1960. $("#contextmenu").find(".backuponly").hide();
  1961. //Check if this is folder or file. Replace the suitable selections
  1962. if ($(this).attr("type") == "folder"){
  1963. //Use folder mode
  1964. $("#contextmenu").find(".folderonly").show();
  1965. $("#contextmenu").find(".fileonly").hide();
  1966. }else{
  1967. //Use file mode
  1968. $("#contextmenu").find(".folderonly").hide();
  1969. $("#contextmenu").find(".fileonly").show();
  1970. }
  1971. if (searchMode == true){
  1972. $("#contextmenu").find(".shareonly").show();
  1973. }else{
  1974. $("#contextmenu").find(".shareonly").hide();
  1975. }
  1976. $("#contextmenu").addClass("visible");
  1977. //Handle CSS offset of the contextmenu
  1978. if ($("#contextmenu").offset().top < 0){
  1979. $("#contextmenu").css("top","0px");
  1980. }else if($("#contextmenu").offset().top + $("#contextmenu").height() > window.innerHeight){
  1981. $("#contextmenu").css("top",window.innerHeight - $("#contextmenu").height() + "px");
  1982. }
  1983. if (isMobile){
  1984. $("#contextmenu").find(".mobileonly").show();
  1985. }else{
  1986. $("#contextmenu").find(".mobileonly").hide();
  1987. }
  1988. $(".fileObject.selected").each(function(){
  1989. if ($(this).attr("filename").split(".").pop().toLowerCase() == "zip"){
  1990. $(".zipFileOnly").show();
  1991. }
  1992. });
  1993. });
  1994. //Right click on empty space of the file selector
  1995. $("#folderView").off("contextmenu").on("contextmenu", function(e){
  1996. if ($(e.target).attr("id") == "folderView" || $(e.target).attr("id") == "fileList" || $(e.target).attr("id") == "folderList"){
  1997. //Context menu on the empty space of the folder / file list
  1998. e.preventDefault();
  1999. $("#contextmenu").find(".item").hide();
  2000. $("#contextmenu").find(".noSelectionOnly").show();
  2001. $("#contextmenu").find(".allowNoSelection").show();
  2002. $("#contextmenu").find(".vroothide").show();
  2003. $("#contextmenu").find(".zipFileOnly").hide();
  2004. //Calculate the position of the context menu
  2005. calculateContextMenuOffsets(e);
  2006. //Show context menu
  2007. $("#contextmenu").addClass("visible");
  2008. //Handle CSS offset of the contextmenu
  2009. if ($("#contextmenu").offset().top < 0){
  2010. $("#contextmenu").css("top","0px");
  2011. }else if($("#contextmenu").offset().top + $("#contextmenu").height() > window.innerHeight){
  2012. $("#contextmenu").css("top",window.innerHeight - $("#contextmenu").height() + "px");
  2013. }
  2014. }
  2015. });
  2016. //Handle right click on storage roots
  2017. $("#storageroot").off("contextmenu").on("contextmenu", function(e){
  2018. if ($(e.target).is("i")){
  2019. e.target = e.target.parentElement;
  2020. }
  2021. $("#storageroot").find(".dir.item").each(function(){
  2022. if ($(this).attr("rootname") != undefined){
  2023. $(this).removeClass("active");
  2024. }
  2025. });
  2026. if ($(e.target).attr("rootname") != undefined){
  2027. //Correct one. Show vroot functions
  2028. e.preventDefault();
  2029. var rootname = $(e.target).attr("rootname");
  2030. var containBackup = $(e.target).attr("contain-backup") == "true";
  2031. $(e.target).addClass("active");
  2032. $("#contextmenu").find(".item").hide();
  2033. $("#contextmenu").find(".vroothide").hide();
  2034. $("#contextmenu").find(".vrootonly").show();
  2035. //Check if this is a backup drive
  2036. if (containBackup == true){
  2037. $("#contextmenu").find(".backuponly").show();
  2038. }else{
  2039. $("#contextmenu").find(".backuponly").hide();
  2040. }
  2041. //Show context menu
  2042. calculateContextMenuOffsets(e);
  2043. $("#contextmenu").addClass("visible");
  2044. //Handle CSS offset of the contextmenu
  2045. if ($("#contextmenu").offset().top < 0){
  2046. $("#contextmenu").css("top","0px");
  2047. }else if($("#contextmenu").offset().top + $("#contextmenu").height() > window.innerHeight){
  2048. $("#contextmenu").css("top",window.innerHeight - $("#contextmenu").height() + "px");
  2049. }
  2050. }
  2051. });
  2052. $(document).on("click",function(evt){
  2053. $(".contextmenu").removeClass("visible");
  2054. });
  2055. }
  2056. //Change the current view mode
  2057. function changeViewMode(object){
  2058. var targetMode = $(object).attr("mode");
  2059. viewMode = targetMode;
  2060. listDirectory(currentPath);
  2061. updateViewmodeButtons();
  2062. setPreference("file_explorer/listmode",targetMode)
  2063. }
  2064. function updateViewmodeButtons(){
  2065. $(".videmode").removeClass('disabled');
  2066. $(".videmode").each(function(){
  2067. if ($(this).attr("mode") == viewMode){
  2068. $(this).addClass("disabled");
  2069. }
  2070. });
  2071. }
  2072. function previosPath(){
  2073. //Remove the current directory from history
  2074. if (viewHistory.length == 0){
  2075. //This is already the first page
  2076. return;
  2077. }
  2078. var previousPath = viewHistory.pop();
  2079. listDirectory(previousPath, undefined, false);
  2080. }
  2081. function parentDir(){
  2082. //If under searchmode, parentDir go back to the currentPath
  2083. if (searchMode){
  2084. hideSearchBar();
  2085. return;
  2086. }
  2087. //Check if there are any parent dir for this path
  2088. if (checkIfParentDirExists(currentPath)){
  2089. //There are parent path. Get it from currentPath
  2090. pathInfo = currentPath.split("/");
  2091. pathInfo.pop();
  2092. var parentFolderName = pathInfo.pop();
  2093. parentPath = pathInfo.join("/") + "/"
  2094. //List the parentDir
  2095. listDirectory(parentPath, function(){
  2096. focusFileObject(parentFolderName);
  2097. });
  2098. }
  2099. }
  2100. //Move the page focus to the given fileobject
  2101. function focusFileObject(targetFileName){
  2102. $(".fileObject").each(function(){
  2103. if ($(this).attr("filename") == targetFileName){
  2104. $(this).addClass("selected");
  2105. scrollToFileLocation(this);
  2106. }
  2107. });
  2108. }
  2109. function scrollToFileLocation(DOMElement){
  2110. if (DOMElement === undefined || $(DOMElement).offset() == undefined){
  2111. //DOM Element no longer exists
  2112. return;
  2113. }
  2114. //Trying to vertically align the directory from its parent list
  2115. let topPos = $("#folderView").scrollTop() + $(DOMElement).offset().top - $("#folderView").height()/2 - $(DOMElement).height()/2 - 28;
  2116. window.debug = $(DOMElement);
  2117. $("#folderView").stop().animate({
  2118. scrollTop: topPos
  2119. }, 300);
  2120. }
  2121. function loadListModeFromDB(callback = undefined){
  2122. //Get list mode from storage
  2123. loadPreference("file_explorer/listmode",function(data){
  2124. if (data != "" && data.error === undefined){
  2125. viewMode = data;
  2126. updateViewmodeButtons();
  2127. }
  2128. if (callback !== undefined){
  2129. callback();
  2130. }
  2131. });
  2132. }
  2133. function rootDir(){
  2134. //Go to the root dir of the current path
  2135. var rootDir = currentPath.split("/").shift();
  2136. rootDir = rootDir + "/";
  2137. listDirectory(rootDir);
  2138. }
  2139. function showEditCurrentPathInput(e){
  2140. e.preventDefault();
  2141. $("#pathInputField").find("input").val(currentPath);
  2142. if (isMobile){
  2143. $("#mobilePathDisplay").hide();
  2144. $(".mobilePathDisplayWrapper").append($("#pathInputField"));
  2145. $("#pathInputField").find("input").css("width", window.innerWidth - 54 + "px");
  2146. }else{
  2147. //Desktop
  2148. $("#pathInputField").find("input").css("width", $("#pathDisplayField").width() - 24+ "px");
  2149. $("#pathDisplayField").hide();
  2150. }
  2151. $("#pathInputField").show();
  2152. }
  2153. function handleOpenPathKeydown(e){
  2154. if (e.key == "enter" | e.keyCode == 13){
  2155. //Etner pressed
  2156. openEnteredPath($("#pathInputField").find("button"));
  2157. }
  2158. }
  2159. function openEnteredPath(object){
  2160. var newPath = $(object).parent().find("input").val();
  2161. //Filter out the path
  2162. newPath = newPath.split("\\").join("/");
  2163. listDirectory(newPath);
  2164. hideManualOpenPathInput();
  2165. }
  2166. function hideManualOpenPathInput(){
  2167. $("#pathInputField").hide();
  2168. if (isMobile){
  2169. $("#mobilePathDisplay").show();
  2170. }else{
  2171. $("#pathDisplayField").show();
  2172. }
  2173. }
  2174. function checkIfParentDirExists(path){
  2175. if (path.includes("/")){
  2176. pathInfo = path.split("/");
  2177. if (pathInfo[1] == ""){
  2178. return false;
  2179. }else{
  2180. return true;
  2181. }
  2182. }else{
  2183. return false;
  2184. }
  2185. }
  2186. function getDirHash(callback){
  2187. $.ajax({
  2188. url: "../../system/file_system/listDirHash",
  2189. data: {dir: currentPath},
  2190. success: function(data){
  2191. if (data.error !== undefined){
  2192. if (data.error == "Invalid dir given"){
  2193. //Storage has been unmounted. Back to parent
  2194. var pdir = currentPath.split("/");
  2195. pdir.pop();pdir.pop();
  2196. pdir = pdir.join("/");
  2197. currentPath = pdir;
  2198. listDirectory(currentPath, function(){
  2199. window.location.reload();
  2200. });
  2201. return;
  2202. }
  2203. }
  2204. callback(data);
  2205. }
  2206. })
  2207. }
  2208. function openHomeDir(){
  2209. listDirectory("user:/", function(){
  2210. hideManualOpenPathInput();
  2211. hideSearchBar();
  2212. })
  2213. }
  2214. //=================================== FILE OPERATIONS ========================
  2215. function refreshList(){
  2216. if (searchMode == true){
  2217. //Refresh the search result
  2218. if ($("#searchInput").val().length > 0){
  2219. handleSearch();
  2220. }
  2221. return;
  2222. }
  2223. shiftHold = false;
  2224. ctrlHold = false;
  2225. updateCtrlDisplay();
  2226. let currentScrollTop = JSON.parse(JSON.stringify($("#folderView").scrollTop()));
  2227. listDirectory(currentPath, function(){
  2228. //Scroll back to the original height
  2229. $("#folderView").scrollTop(currentScrollTop);
  2230. });
  2231. }
  2232. function zipFile(){
  2233. $(".popup").fadeOut('fast');
  2234. var zippingFiles = [];
  2235. $(".fileObject.selected").each(function(){
  2236. var filepath = $(this).attr("filepath");
  2237. zippingFiles.push(filepath);
  2238. });
  2239. console.log(zippingFiles);
  2240. //Request to create a zip file, named with the parent dir name
  2241. var oprConfig = {
  2242. opr: "zip",
  2243. src: zippingFiles,
  2244. dest: currentPath,
  2245. overwriteMode: "overwrite",
  2246. callbackWindowID: ao_module_windowID,
  2247. callbackFunction: `callRefresh("${currentPath}")`
  2248. }
  2249. var configHash = encodeURIComponent(JSON.stringify(oprConfig));
  2250. var title = applocale.getString("opr/zip/zipping","Zipping ") + zippingFiles.length;
  2251. if (fileList.length > 1){
  2252. title += applocale.getString("opr/zip/files", " files");
  2253. }else{
  2254. title += applocale.getString("opr/zip/file"," file");
  2255. }
  2256. if (!ao_module_virtualDesktop){
  2257. window.open("file_operation.html#" + configHash);
  2258. }else{
  2259. parent.newFloatWindow({
  2260. url: "SystemAO/file_system/file_operation.html#" + configHash,
  2261. width: 400,
  2262. height: 220,
  2263. appicon: "SystemAO/file_system/img/selector.png",
  2264. title: title
  2265. });
  2266. }
  2267. }
  2268. function unzipHere(){
  2269. $(".popup").fadeOut('fast');
  2270. //Get a list of zip files selected
  2271. var unzippingFiles = [];
  2272. $(".fileObject.selected").each(function(){
  2273. var filepath = $(this).attr("filepath");
  2274. if ((filepath.split(".").pop()).toLowerCase() == "zip"){
  2275. unzippingFiles.push(filepath);
  2276. }
  2277. });
  2278. if(unzippingFiles.length == 0){
  2279. msgbox("remove", applocale.getString("opr/zip/nozipfile", "No zip file selected"));
  2280. return;
  2281. }
  2282. //Start unzip progress
  2283. console.log(unzippingFiles);
  2284. //Unzip and open them to tmp:/
  2285. var oprConfig = {
  2286. opr: "unzip",
  2287. src: unzippingFiles,
  2288. dest: currentPath,
  2289. overwriteMode: "overwrite",
  2290. callbackWindowID: ao_module_windowID,
  2291. callbackFunction: `callRefresh("${currentPath}")`
  2292. }
  2293. //Render the dialog title name
  2294. var configHash = encodeURIComponent(JSON.stringify(oprConfig));
  2295. var title = applocale.getString("opr/zip/unzipping","Unzipping ") + unzippingFiles.length;
  2296. if (unzippingFiles.length > 1){
  2297. title += applocale.getString("opr/zip/files", " files");
  2298. }else{
  2299. title += applocale.getString("opr/zip/file"," file");
  2300. }
  2301. if (!ao_module_virtualDesktop){
  2302. window.open("file_operation.html#" + configHash);
  2303. }else{
  2304. parent.newFloatWindow({
  2305. url: "SystemAO/file_system/file_operation.html#" + configHash,
  2306. width: 400,
  2307. height: 220,
  2308. appicon: "SystemAO/file_system/img/selector.png",
  2309. title: title,
  2310. });
  2311. }
  2312. }
  2313. let renameFileObjects = [];
  2314. function rename(){
  2315. $(".popup").fadeOut('fast');
  2316. renameFileObjects = [];
  2317. var filenames = [];
  2318. $(".fileObject.selected").each(function(){
  2319. var fileObjectType = $(this).attr("type");
  2320. let fileObject = {
  2321. filename: $(this).attr('filename'),
  2322. filepath: $(this).attr("filepath"),
  2323. filetype: fileObjectType
  2324. }
  2325. renameFileObjects.push(JSON.parse(JSON.stringify(fileObject)));
  2326. filenames.push($(this).attr('filename'));
  2327. });
  2328. var oldname = "unknown file.txt";
  2329. if (renameFileObjects.length == 0){
  2330. return;
  2331. }else if (renameFileObjects.length > 0){
  2332. $("#renameBox").find(".multifileWarning").hide();
  2333. oldname = filenames[0];
  2334. }
  2335. $("#renameBox").find(".orgfn").val(oldname);
  2336. $("#renameBox").find(".newfn").val(oldname);
  2337. showPopupWrapper();
  2338. $("#renameBox").fadeIn(100);
  2339. }
  2340. function confirmRename(){
  2341. var oldName = $("#renameBox").find(".orgfn").val();
  2342. var newName = $("#renameBox").find(".newfn").val();
  2343. if (newName == oldName){
  2344. msgbox("remove",applocale.getString("message/newFilenameIdentical", "New filename is identical to the original filename."));
  2345. $("#renameBox").fadeOut(100);
  2346. $(".popupWrapper").fadeOut(100);
  2347. return;
  2348. }
  2349. var newNameWithoutExt = newName;
  2350. var newnameExt = "";
  2351. if (newName.includes(".")){
  2352. tmp = newName.split(".");
  2353. newnameExt = tmp.pop();
  2354. newNameWithoutExt = tmp.join(".");
  2355. }
  2356. var counter = 0;
  2357. var srclist = [];
  2358. var newnamelist = [];
  2359. for (var i =0; i < renameFileObjects.length; i++){
  2360. var thisFilepath = renameFileObjects[i].filepath;
  2361. var thisFiletype = renameFileObjects[i].filetype;
  2362. var thisFilename = renameFileObjects[i].filename;
  2363. var newFilename = newName;
  2364. if ( i > 0){
  2365. if (thisFiletype == "file"){
  2366. var thisFileExt = thisFilename.split(".").pop();
  2367. newFilename = newNameWithoutExt + "(" + i + ")." + thisFileExt;
  2368. }else if (thisFiletype == "folder"){
  2369. newFilename = newNameWithoutExt + "(" + i + ")";
  2370. }
  2371. }
  2372. srclist.push(thisFilepath);
  2373. newnamelist.push(newFilename);
  2374. }
  2375. console.log(srclist, newnamelist);
  2376. //Send the request to serverside
  2377. requestCSRFToken(function(token){
  2378. $.ajax({
  2379. url: "../../system/file_system/fileOpr",
  2380. method: "POST",
  2381. data: {opr: "rename", src: JSON.stringify(srclist), new: JSON.stringify(newnamelist), csrft: token},
  2382. success: function(data){
  2383. if (data.error !== undefined){
  2384. msgbox("remove",applocale.getString("message/" + data.error, data.error));
  2385. }else{
  2386. refreshList();
  2387. msgbox("checkmark",applocale.getString("message/rename/success", "Rename suceed"));
  2388. }
  2389. $("#renameBox").fadeOut(100);
  2390. $(".popupWrapper").fadeOut(100);
  2391. },
  2392. error: function(){
  2393. $("#renameBox").fadeOut(100);
  2394. $(".popupWrapper").fadeOut(100);
  2395. }
  2396. });
  2397. renameFileObjects = [];
  2398. });
  2399. hideAllPopupWindows();
  2400. }
  2401. function changeOverwriteRule(mode, doPasteAgain=false){
  2402. switch (mode){
  2403. case 0:
  2404. overwriteMode = "overwrite";
  2405. break;
  2406. case 1:
  2407. overwriteMode = "skip";
  2408. break;
  2409. case 2:
  2410. overwriteMode = "keep";
  2411. break;
  2412. default:
  2413. overwriteMode = "keep";
  2414. }
  2415. if (doPasteAgain){
  2416. //Initiate paste without checking and close the overwritemode selector
  2417. paste(undefined, true);
  2418. $("#overwriteModeSelection").fadeOut(100);
  2419. }
  2420. }
  2421. function copy(){
  2422. cutMode = false;
  2423. clipboard = [];
  2424. if ($(".fileObject.selected").length == 0){
  2425. return;
  2426. }
  2427. $(".fileObject.selected").each(function(){
  2428. var thisFilepath = $(this).attr("filepath");
  2429. clipboard.push(thisFilepath);
  2430. });
  2431. if (useLocalstorage){
  2432. localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
  2433. localStorage.setItem("ao/file_system/cutmode","false");
  2434. }
  2435. msgbox("copy",clipboard.length + applocale.getString("message/copy/success", " objects copied."))
  2436. }
  2437. function cut(){
  2438. cutMode = true;
  2439. clipboard = [];
  2440. if ($(".fileObject.selected").length == 0){
  2441. return;
  2442. }
  2443. $(".fileObject.selected").each(function(){
  2444. var thisFilepath = $(this).attr("filepath");
  2445. clipboard.push(thisFilepath);
  2446. });
  2447. if (useLocalstorage){
  2448. localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
  2449. localStorage.setItem("ao/file_system/cutmode","true");
  2450. }
  2451. msgbox("cut",clipboard.length + applocale.getString("message/move/success", " objects ready to be moved."))
  2452. }
  2453. function paste(redirectPasteTarget="", nocheck=false){
  2454. let thisOprCutMode = cutMode;
  2455. let fileList = clipboard;
  2456. let targetDir = currentPath;
  2457. if (redirectPasteTarget != ""){
  2458. //Allow redirection of paste target if necessary
  2459. targetDir = redirectPasteTarget;
  2460. }
  2461. if (useLocalstorage){
  2462. //There are localStorage. Always use localStorage if exists.
  2463. var crossFrameClipboard = localStorage.getItem("ao/file_system/clipboard");
  2464. var useCutMode = localStorage.getItem("ao/file_system/cutmode");
  2465. if (crossFrameClipboard !== "" && crossFrameClipboard !== undefined && crossFrameClipboard !== null){
  2466. fileList = JSON.parse(crossFrameClipboard);
  2467. }
  2468. if (useCutMode !== "" && useCutMode !== undefined && useCutMode !== null){
  2469. thisOprCutMode = (useCutMode == "true");
  2470. }
  2471. }
  2472. if (fileList.length == 0){
  2473. //There are nothing to paste
  2474. msgbox("question",applocale.getString("message/paste/nothing", "There are nothing to paste."))
  2475. return;
  2476. }
  2477. //console.log(fileList,JSON.stringify(fileList));
  2478. if (thisOprCutMode == true){
  2479. //Cut and paste
  2480. $.ajax({
  2481. type: 'POST',
  2482. url: `../../system/file_system/validateFileOpr`,
  2483. data: {src: JSON.stringify(fileList), dest: targetDir},
  2484. success: function(data){
  2485. if (!nocheck && data.length > 0){
  2486. //There are problem with the copy target. Pop up overwrite rule selector
  2487. showDuplicateHandler(data);
  2488. }else{
  2489. //OK!
  2490. //Clear clipboard settings
  2491. localStorage.setItem("ao/file_system/clipboard", "");
  2492. clipboard = "";
  2493. //Stsart operations
  2494. if (!ao_module_virtualDesktop){
  2495. //Not under desktop mode. Use direct copy API
  2496. requestCSRFToken(function(token){
  2497. $.ajax({
  2498. type: 'POST',
  2499. url: `../../system/file_system/fileOpr`,
  2500. data: {opr: "move" ,src: JSON.stringify(fileList), dest: targetDir,existsresp: overwriteMode, csrft: token},
  2501. success: function(data){
  2502. if (data.error !== undefined){
  2503. msgbox("remove",applocale.getString("message/" + data.error, data.error));
  2504. }else{
  2505. //OK
  2506. msgbox("checkmark",fileList.length + applocale.getString("message/move/success", " objects moved."))
  2507. refreshList();
  2508. }
  2509. hideAllPopupWindows();
  2510. }
  2511. });
  2512. });
  2513. }else{
  2514. //Pass the request to operation handler
  2515. var oprConfig = {
  2516. opr: "move",
  2517. src: fileList,
  2518. dest: targetDir,
  2519. overwriteMode: overwriteMode,
  2520. callbackWindowID: ao_module_windowID,
  2521. callbackFunction: `callRefresh("${targetDir}")`
  2522. }
  2523. var configHash = encodeURIComponent(JSON.stringify(oprConfig));
  2524. var title = "Moving " + fileList.length;
  2525. if (fileList.length > 1){
  2526. title += " files";
  2527. }else{
  2528. title += " file";
  2529. }
  2530. parent.newFloatWindow({
  2531. url: "SystemAO/file_system/file_operation.html#" + configHash,
  2532. width: 400,
  2533. height: 220,
  2534. appicon: "SystemAO/file_system/img/selector.png",
  2535. title: title
  2536. });
  2537. hideAllPopupWindows();
  2538. }
  2539. }
  2540. }
  2541. });
  2542. }else{
  2543. //Copy and paste
  2544. //Check if the file list is OK for continue without the need for overwrite
  2545. $.ajax({
  2546. type: 'POST',
  2547. url: `../../system/file_system/validateFileOpr`,
  2548. data: {src: JSON.stringify(fileList), dest: targetDir},
  2549. success: function(data){
  2550. if (!nocheck && data.length > 0){
  2551. //There are problem with the copy target. Pop up overwrite rule selector
  2552. showDuplicateHandler(data);
  2553. }else{
  2554. //OK!
  2555. if (!ao_module_virtualDesktop){
  2556. requestCSRFToken(function(token){
  2557. $.ajax({
  2558. type: 'POST',
  2559. url: `../../system/file_system/fileOpr`,
  2560. data: {opr: "copy" ,src: JSON.stringify(fileList), dest: targetDir,existsresp: overwriteMode, csrft: token},
  2561. success: function(data){
  2562. if (data.error !== undefined){
  2563. msgbox("remove",applocale.getString("message/" + data.error,data.error));
  2564. }else{
  2565. //OK
  2566. msgbox("checkmark",fileList.length + applocale.getString("message/copy/success", " objects copied."))
  2567. refreshList();
  2568. }
  2569. hideAllPopupWindows();
  2570. }
  2571. });
  2572. });
  2573. }else{
  2574. //Pass the request to operation handler
  2575. var oprConfig = {
  2576. opr: "copy",
  2577. src: fileList,
  2578. dest: targetDir,
  2579. overwriteMode: overwriteMode,
  2580. callbackWindowID: ao_module_windowID,
  2581. callbackFunction: `callRefresh("${targetDir}")`
  2582. }
  2583. var configHash = encodeURIComponent(JSON.stringify(oprConfig));
  2584. var title = "Copying " + fileList.length;
  2585. if (fileList.length > 1){
  2586. title += " files";
  2587. }else{
  2588. title += " file";
  2589. }
  2590. parent.newFloatWindow({
  2591. url: "SystemAO/file_system/file_operation.html#" + configHash,
  2592. width: 400,
  2593. height: 220,
  2594. appicon: "SystemAO/file_system/img/selector.png",
  2595. title: title
  2596. });
  2597. hideAllPopupWindows();
  2598. }
  2599. }
  2600. }
  2601. });
  2602. }
  2603. }
  2604. //Callback function for file operation display
  2605. window.callRefresh = function(targetdir){
  2606. console.log(currentPath, targetdir);
  2607. if (currentPath == targetdir){
  2608. refreshList();
  2609. }
  2610. }
  2611. //This action may duplicate files. Show handler
  2612. function showDuplicateHandler(duplicateFileList){
  2613. $(".popup").fadeOut(100);
  2614. var duplicatedFileCounts = duplicateFileList.length;
  2615. showPopupWrapper();
  2616. $("#overwriteModeSelection").fadeIn(100);
  2617. $("#overwriteModeSelection").find(".owm-fc").text(duplicatedFileCounts);
  2618. var srcpath = duplicateFileList[0];
  2619. srcpath = srcpath.split("/");
  2620. srcpath.pop();
  2621. srcpath = srcpath.join("/");
  2622. $("#overwriteModeSelection").find(".owm-srcdir").text(srcpath);
  2623. $("#overwriteModeSelection").find(".owm-destdir").text(currentPath);
  2624. }
  2625. //Force delete. Use normal delete fucntion if you want to move things to recycle bin instead.
  2626. let forceDeleteList = [];
  2627. function forceDelete(confirmed=false){
  2628. if (!confirmed){
  2629. //Show confirm box
  2630. let deletePendingList = [];
  2631. var listObject = $("#forceDeleteConfirmBox").find(".deleteFilelist")[0];
  2632. $(listObject).html("");
  2633. $(".selected.fileObject").each(function(data){
  2634. var thispath = $(this).attr("filepath");
  2635. var thisfilename = $(this).attr("filename");
  2636. var ext = thisfilename.split(".").pop();
  2637. var icon = ao_module_utils.getIconFromExt(ext);
  2638. deletePendingList.push(thispath);
  2639. $(listObject).append(`<div class="item ${currentTheme}" ><span style="display:inline-block;">${thisfilename}</span></div>`);
  2640. });
  2641. showPopupWrapper();
  2642. $("#forceDeleteConfirmBox").fadeIn(100);
  2643. forceDeleteList = deletePendingList;
  2644. }else{
  2645. //Start force delete function
  2646. $("#forceDeleteConfirmBox").fadeOut(100);
  2647. let fdlistLength = forceDeleteList.length;
  2648. requestCSRFToken(function(token){
  2649. $.ajax({
  2650. url: "../../system/file_system/fileOpr",
  2651. method:"POST",
  2652. data: {opr: "delete", src: JSON.stringify(forceDeleteList), csrft: token},
  2653. success: function(data){
  2654. if (data.error !== undefined){
  2655. msgbox("remove",applocale.getString("message/" + data.error,data.error));
  2656. }else{
  2657. refreshList();
  2658. msgbox("checkmark",fdlistLength + applocale.getString("message/remove/success", " objects removed."))
  2659. }
  2660. }
  2661. });
  2662. //Finishing up delete sequence
  2663. forceDeleteList = [];
  2664. hideAllPopupWindows();
  2665. });
  2666. }
  2667. }
  2668. let deleteFileList = [];
  2669. function deleteFile(confirmed = false){
  2670. if (!confirmed){
  2671. //Show the confirm dialog
  2672. $("#deleteConfirmBox").find(".deleteFilelist").html("");
  2673. $(".fileObject.selected").each(function(data){
  2674. var thisfilename = $(this).attr('filename');
  2675. var thisFilepath = $(this).attr('filepath');
  2676. deleteFileList.push(thisFilepath);
  2677. $("#deleteConfirmBox").find(".deleteFilelist").append(`<div class="item ${currentTheme}" ><span style="display:inline-block;">${thisfilename}</span></div>`);
  2678. });
  2679. if (deleteFileList.length == 0){
  2680. //No files selected
  2681. return;
  2682. }else{
  2683. //File selected. Continue to delete
  2684. showPopupWrapper();
  2685. $("#deleteConfirmBox").fadeIn(100);
  2686. }
  2687. }else{
  2688. //Continue to delete files
  2689. let fdlistLength = deleteFileList.length;
  2690. requestCSRFToken(function(token){
  2691. $.ajax({
  2692. url: "../../system/file_system/fileOpr",
  2693. method:"POST",
  2694. data: {opr: "recycle", src: JSON.stringify(deleteFileList), csrft: token},
  2695. success: function(data){
  2696. if (data.error !== undefined){
  2697. msgbox("remove",applocale.getString("message/" + data.error,data.error));
  2698. }else{
  2699. refreshList();
  2700. msgbox("checkmark",fdlistLength + applocale.getString("message/recycle/success", " objects moved to trash bin."))
  2701. }
  2702. if (currentPath == "user:/"){
  2703. //Reload the User root folder list
  2704. initRootDirs();
  2705. }
  2706. }
  2707. });
  2708. console.log(deleteFileList);
  2709. deleteFileList = [];
  2710. hideAllPopupWindows();
  2711. });
  2712. }
  2713. }
  2714. function cancelDelete(){
  2715. deleteFileList=[];
  2716. }
  2717. function cancelForceDelete(){
  2718. $("#forceDeleteConfirmBox").fadeOut(100);
  2719. forceDeleteList = [];
  2720. }
  2721. function upload(){
  2722. var input = document.createElement('input');
  2723. input.type = 'file';
  2724. input.multiple = true;
  2725. input.onchange = e => {
  2726. var files = e.target.files;
  2727. msgbox("upload",applocale.getString("message/upload/started", "Upload Started"));
  2728. for (var i = 0; i < files.length; i++){
  2729. uploadFile(files[i]);
  2730. }
  2731. }
  2732. input.click();
  2733. }
  2734. function updatePathDisplay(path){
  2735. var pathInfo = path.split("/");
  2736. var vdID = pathInfo[0];
  2737. //As path always end with /, pop the empty pathinfo from array
  2738. pathInfo.pop();
  2739. var l = pathInfo.length;
  2740. //Append the starting vdir
  2741. $(".pathDisplay").html("");
  2742. $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="rootDir();"><i class="folder icon"></i> ${vdID}</div>`);
  2743. $(".pathDisplay").append(`<div class="divider ${currentTheme} whiteTheme">/</div>`);
  2744. //console.log(pathInfo);
  2745. if (l > 3){
  2746. //E.g. user:/Desktop/test/boo/ => Display as user:/.../test/boo/
  2747. $(".pathDisplay").append(`<div class="section ${currentTheme}">...</div>`);
  2748. $(".pathDisplay").append(`<div class="divider ${currentTheme} whiteTheme">/</div>`);
  2749. $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="parentDir();">${shortenLongFoldername(pathInfo[l-2], 40)}</div>`);
  2750. $(".pathDisplay").append(`<div class="divider ${currentTheme} whiteTheme">/</div>`);
  2751. $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="refreshList();">${shortenLongFoldername(pathInfo[l-1], 60)}</div>`);
  2752. }else if (l == 3){
  2753. $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="parentDir();">${shortenLongFoldername(pathInfo[l-2], 40)}</div>`);
  2754. $(".pathDisplay").append(`<div class="divider ${currentTheme} whiteTheme">/</div>`);
  2755. $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="refreshList();">${shortenLongFoldername(pathInfo[l-1], 60)}</div>`);
  2756. }else if (l == 2){
  2757. //E.g. user:/Desktop or user:/
  2758. $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="refreshList();">${shortenLongFoldername(pathInfo[1], 80)}</div>`);
  2759. }
  2760. //Update the manual input field as well
  2761. $("#pathInputField").find("input").val(path);
  2762. }
  2763. function shortenLongFoldername(name, maxchar = 20){
  2764. var resultname = name;
  2765. if (name.length > maxchar){
  2766. //Shorten it
  2767. var offset = parseInt((maxchar - 2) / 2);
  2768. resultname = name.substr(0, offset) + "..." + name.substr(name.length - offset)
  2769. }
  2770. return resultname
  2771. }
  2772. function getExtFromPath(path){
  2773. if (path.includes(".") == false){
  2774. return "";
  2775. }
  2776. return path.split(".").pop();
  2777. }
  2778. function getFileObjectFromFID(fid){
  2779. var targetFileObject = null;
  2780. $(".fileObject").each(function(){
  2781. if ($(this).attr("fileid") == fid){
  2782. targetFileObject = $(this);
  2783. }
  2784. });
  2785. return targetFileObject;
  2786. }
  2787. function openViaButton(){
  2788. let fileOpenList = [];
  2789. let foldersToBeOpened=[];
  2790. $(".fileObject.selected").each(function(){
  2791. let type = $(this).attr("type");
  2792. let filepath = $(this).attr("filepath");
  2793. if (type == "file"){
  2794. fileOpenList.push(filepath);
  2795. }else if (type == "folder"){
  2796. foldersToBeOpened.push(filepath);
  2797. }
  2798. });
  2799. //Open files
  2800. openPathWithDefaultOpener(fileOpenList);
  2801. //Open folders
  2802. openFolderInNewWindow(foldersToBeOpened);
  2803. }
  2804. function openthis(object,evt=null){
  2805. if (evt !== null){
  2806. evt.preventDefault();
  2807. }
  2808. var objType = $(object).attr("type");
  2809. if ( objType == "file"){
  2810. //Open this file. Generate the access path from filepath
  2811. var filepath = $(object).attr("filepath");
  2812. //Only one path to be opened. Pass in as a single object array
  2813. openPathWithDefaultOpener([filepath]);
  2814. }else if (objType == "folder"){
  2815. //Open this folder
  2816. var folderPath = $(object).attr('filepath');
  2817. listDirectory(folderPath, function(){
  2818. //Scroll to top of the list
  2819. $("#folderView").stop().finish().animate({
  2820. scrollTop: 0
  2821. }, 300);
  2822. if ($(object).hasClass('dir') && isMobile){
  2823. toggleSidebar();
  2824. }
  2825. });
  2826. }else if (objType == "shortcut"){
  2827. //Load the shortcut information
  2828. getShortcutInfo($(object).attr('filepath'), function(shortcutInfo){
  2829. /*
  2830. Shortcut Info format
  2831. 0: Shortcut type
  2832. 1: Shortcut Name
  2833. 2: Shortcut target
  2834. 3: Shortcut icon image
  2835. */
  2836. if (shortcutInfo[0] == "module"){
  2837. //This is a module
  2838. if (ao_module_virtualDesktop){
  2839. //Open Module with VDI API
  2840. parent.openModule(shortcutInfo[2]);
  2841. }else{
  2842. //Open module in new tab
  2843. $.get("../../system/modules/getLaunchPara?module=" + shortcutInfo[2], function(data) {
  2844. window.open("../../" + data.StartDir);
  2845. });
  2846. }
  2847. }else if (shortcutInfo[0] == "folder"){
  2848. //This is a folder
  2849. listDirectory(shortcutInfo[2]);
  2850. }else if (shortcutInfo[0] == "url"){
  2851. //This is a url shortcut
  2852. //Update 2020_02-03: Open with floatWindow instead
  2853. parent.newFloatWindow({
  2854. url: shortcutInfo[2],
  2855. appicon: shortcutInfo[3],
  2856. title: shortcutInfo[1],
  2857. parent: shortcutInfo[2]
  2858. })
  2859. //window.open(shortcutInfo[2]);
  2860. }
  2861. console.log(shortcutInfo);
  2862. });
  2863. }
  2864. //Check if this opened in sidebar and in mobile mode. Close sidebar if yes
  2865. }
  2866. /*
  2867. Shortcut Info format
  2868. 0: Shortcut type
  2869. 1: Shortcut Name
  2870. 2: Shortcut target
  2871. 3: Shortcut icon image
  2872. */
  2873. function getShortcutInfo(filepath, callback){
  2874. $.get("../../media?file=" + filepath, function(data){
  2875. //This return the shortcut information. Split it and see what shortcut is this
  2876. data = data.split("\r\n").join("\n");
  2877. var shortcutInfo = data.trim().split("\n");
  2878. callback(shortcutInfo);
  2879. });
  2880. }
  2881. //Download the selected files.
  2882. function downloadFile(){
  2883. var fileList = [];
  2884. if ($(".fileObject.selected").length == 1 && $(".fileObject.selected").attr("type") == "file"){
  2885. //One file. Download directly.
  2886. var downloadURL = "../../media?file=" + encodeURIComponent($(".fileObject.selected").attr("filepath")) + "&download=true";
  2887. var filename = $(".fileObject.selected").attr("filename");
  2888. generateDownloadFromURL(downloadURL,escape(filename));
  2889. }else if ($(".fileObject.selected").length > 1 || ($(".fileObject.selected").length == 1 && $(".fileObject.selected").attr("type") == "folder")){
  2890. //Do zip and download for multiple files
  2891. $(".fileObject.selected").each(function(){
  2892. fileList.push($(this).attr("filepath"));
  2893. });
  2894. console.log("Zipping: ", fileList);
  2895. //Add a display for file compression
  2896. var fileCount = $(".fileObject.selected").length;
  2897. var displayString = applocale.getString("opr/zip/zipping", "Zipping ") + fileCount + applocale.getString("opr/zip/files", " files");
  2898. if (fileCount == 1){
  2899. //Use the filename as task name
  2900. displayString = applocale.getString("opr/zip/zipping", "Zipping ") + $(".fileObject.selected").attr("filename");
  2901. }
  2902. var taskUUID = appendUploadFileItem(displayString, -1);
  2903. $("#uploadTab").show();
  2904. //Set the progress bar to intermediate mode
  2905. let targetTaskDisplayObject = getUploadTaskByID(taskUUID);
  2906. targetTaskDisplayObject.find(".progress").addClass("preparing");
  2907. //Zip the file or folder
  2908. $.ajax({
  2909. url: "../../system/file_system/zipHandler",
  2910. data: {opr: "tmpzip", src: JSON.stringify(fileList), dest: ""},
  2911. method: "POST",
  2912. success: function(data){
  2913. if (data.error !== undefined){
  2914. //Error
  2915. targetTaskDisplayObject.find(".progress").removeClass("preparing").removeClass("primary").addClass("negative");
  2916. msgbox("remove",applocale.getString("message/" + data.error,data.error));
  2917. }else{
  2918. //Zip completed.
  2919. targetTaskDisplayObject.find(".progress").removeClass("preparing").removeClass("primary").addClass("positive");
  2920. //Open the zip file
  2921. window.open("../../media?file=" + data + "&download=true");
  2922. }
  2923. targetTaskDisplayObject.find(".bar").css("width", "100%");
  2924. //Hide the taskbar after 5 secs
  2925. setTimeout(function(){
  2926. //Fade out this task
  2927. $(targetTaskDisplayObject).fadeOut('fast',
  2928. function(){
  2929. $(this).remove();
  2930. if ($(".uploadTask").length == 0){
  2931. $("#uploadTab").hide();
  2932. }
  2933. }
  2934. );
  2935. }, 3000);
  2936. },
  2937. error: function(){
  2938. targetTaskDisplayObject.find(".progress").removeClass("preparing").removeClass("primary").addClass("negative");
  2939. targetTaskDisplayObject.find(".bar").css("width", "100%");
  2940. msgbox("remove",applocale.getString("message/zip/fail", "Zipping failed due to unknown reason"));
  2941. setTimeout(function(){
  2942. if ($(".uploadTask").length == 0){
  2943. $("#uploadTab").hide();
  2944. }
  2945. }, 3000);
  2946. }
  2947. });
  2948. }else{
  2949. alert("No file selected!")
  2950. }
  2951. }
  2952. //Create a new file
  2953. function newfile(){
  2954. $(".popup").fadeOut('fast');
  2955. showPopupWrapper();
  2956. $("#newFile").fadeIn('fast');
  2957. $("#newFile").find(".duplicateWarning").hide();
  2958. $("#createNewFileName").parent().removeClass("error");
  2959. //Update the newfile list
  2960. $("#newFile").find(".newfilelist").html("");
  2961. requestCSRFToken(function(token){
  2962. $.ajax({
  2963. url: "../../system/file_system/newItem",
  2964. data: {csrft: token},
  2965. success: function(data){
  2966. if (data.error !== undefined){
  2967. return;
  2968. }
  2969. for (var i =0; i < data.length; i++){
  2970. var desc = data[i].Desc;
  2971. var ext = data[i].Ext;
  2972. var icon = ao_module_utils.getIconFromExt(ext);
  2973. $("#newFile").find(".newfilelist").append(`<div class="item newFileFormat" ext="${ext}"><i class="${icon} icon" style="margin-right:12px;"></i> ${desc}</div>`);
  2974. }
  2975. //Initialize the new file as txt
  2976. var filename = "newfile";
  2977. var finalFilename = filename;
  2978. var i = 0;
  2979. while (currentFilelist.includes(finalFilename)){
  2980. finalFilename = finalFilename + "(" + i + ")";
  2981. i++;
  2982. }
  2983. $("#createNewFileName").val(finalFilename + ".txt");
  2984. //Hook events for on click
  2985. $(".newFileFormat").off("click").on("click",function(data){
  2986. $(".newFileFormat").removeClass("selected");
  2987. $(this).addClass("selected");
  2988. //Parse the newfilename
  2989. var selectedExt = $(this).attr("ext");
  2990. var filename = "newfile";
  2991. var finalFilename = filename;
  2992. var i = 0;
  2993. while (currentFilelist.includes(finalFilename)){
  2994. finalFilename = finalFilename + "(" + i + ")";
  2995. i++;
  2996. }
  2997. $("#createNewFileName").val(filename + "." + selectedExt);
  2998. });
  2999. }
  3000. });
  3001. });
  3002. }
  3003. function filePermission(){
  3004. //Open file permission window
  3005. if ($(".fileObject.selected").length > 0){
  3006. //Build the filelist
  3007. var fileList = [];
  3008. $(".fileObject.selected").each(function(){
  3009. var filepath = $(this).attr("filepath");
  3010. fileList.push(filepath);
  3011. });
  3012. var hashPassthrough = encodeURIComponent(JSON.stringify(fileList));
  3013. ao_module_newfw({
  3014. url: "SystemAO/file_system/file_permission.html#" + hashPassthrough,
  3015. width: 340,
  3016. height: 480,
  3017. appicon: "SystemAO/file_system/img/properties.png",
  3018. title: "File Permissions",
  3019. })
  3020. }
  3021. }
  3022. function newFolder(confirmed = false){
  3023. if (confirmed == false){
  3024. //Launch the dialog for newFolder
  3025. $(".popup").fadeOut(100);
  3026. $("#createNewFolder").val("");
  3027. $("#createNewFolder").parent().removeClass("error").removeClass("success");
  3028. $("#newFolder").find(".duplicateWarning").hide();
  3029. showPopupWrapper();
  3030. $("#newFolder").fadeIn(100);
  3031. }else{
  3032. //Create new folder
  3033. var newFoldername = $("#createNewFolder").val();
  3034. if (newFoldername == ""){
  3035. $("#createNewFolder").parent().addClass("error");
  3036. return;
  3037. }
  3038. //Check for invalid characters
  3039. if (newFoldername.includes("%")){
  3040. $("#createNewFolder").parent().addClass("error");
  3041. return;
  3042. }
  3043. if (currentFilelist.includes(newFoldername)){
  3044. //Current filelist already contain a folder with the same name
  3045. $("#createNewFolder").parent().addClass("error");
  3046. $("#newFolder").find(".duplicateWarning").show();
  3047. return;
  3048. }
  3049. //OK to proceed.
  3050. $("#createNewFolder").parent().removeClass("error").addClass("success");
  3051. $("#newFolder").find(".duplicateWarning").hide();
  3052. requestCSRFToken(function(token){
  3053. $.ajax({
  3054. url: "../../system/file_system/newItem",
  3055. data: {type: "folder", src: currentPath, filename: newFoldername, csrft: token},
  3056. success: function(data){
  3057. if (data.error !== undefined){
  3058. msgbox("remove",applocale.getString("message/" + data.error,data.error));
  3059. }else{
  3060. msgbox("checkmark",applocale.getString("message/newfolder/success", "New folder created."));
  3061. refreshList();
  3062. }
  3063. $("#newFolder").fadeOut('fast');
  3064. hideAllPopupWindows();
  3065. if (currentPath == "user:/"){
  3066. //Reload the User root folder list
  3067. initRootDirs();
  3068. }
  3069. }
  3070. });
  3071. });
  3072. }
  3073. }
  3074. function confirmNewFile(){
  3075. var filename = $("#createNewFileName").val();
  3076. if (filename == ""){
  3077. //Filename not set
  3078. $("#createNewFileName").parent().addClass("error");
  3079. return;
  3080. }else if(currentFilelist.includes(filename)){
  3081. //File with this name already exists
  3082. $("#createNewFileName").parent().addClass("error");
  3083. $("#newFile").find(".duplicateWarning").show();
  3084. return;
  3085. }
  3086. $("#createNewFileName").parent().removeClass("error");
  3087. //Ok to proceed
  3088. requestCSRFToken(function(token){
  3089. $.ajax({
  3090. url: "../../system/file_system/newItem",
  3091. data: {type: "file", src: currentPath, filename:filename,csrft: token},
  3092. success: function(data){
  3093. if (data.error !== undefined){
  3094. msgbox("remove",applocale.getString("message/" + data.error,data.error));
  3095. }else{
  3096. msgbox("checkmark",filename + applocale.getString("message/newItem/success", " created."));
  3097. refreshList();
  3098. }
  3099. }
  3100. });
  3101. });
  3102. hideAllPopupWindows();
  3103. $("#newFile").fadeOut('fast');
  3104. }
  3105. //Open File Location
  3106. function openFileLocation(){
  3107. var folders = [];
  3108. $(".selected.fileObject").each(function(){
  3109. var thisFilepath = $(this).attr('filepath');
  3110. var thisFilename = $(this).attr('filename');
  3111. openPathInNewWindow(encodeURIComponent(JSON.stringify([{
  3112. filename: thisFilename,
  3113. filepath: thisFilepath
  3114. }])))
  3115. });
  3116. }
  3117. //OpenWith dialog
  3118. function openWith(){
  3119. if ($(".selected.fileObject").length == 0){
  3120. msgbox("question",applocale.getString("message/nofileSelected", "No file selected"));
  3121. return;
  3122. }
  3123. //Get a list of modules and append it into the selection list
  3124. $.get("../../system/modules/list",function(data){
  3125. if (data.error !== undefined){
  3126. console.log(data.error);
  3127. }else{
  3128. $("#openWithModuleList").html("");
  3129. for (var i =0; i < data.length; i++){
  3130. var thisModule = data[i];
  3131. var supportFW = `<div class="ts horizontal mini label"><i class="checkmark icon"></i>floatWindow Window</div>`;
  3132. var supportEmb = `<div class="ts horizontal mini label"><i class="checkmark icon"></i>Embedded Window</div>`;
  3133. if (!thisModule.SupportFW){
  3134. supportFW = "";
  3135. }
  3136. if (!thisModule.LaunchEmb){
  3137. supportEmb = "";
  3138. }
  3139. var launchInfo = encodeURIComponent(JSON.stringify(thisModule));
  3140. $("#openWithModuleList").append(`<div class="item selectable openWithModule" launchInfo="${launchInfo}" onclick="selectOpenWithModule(this, event);" ondblclick="selectOpenWithModule(this, event); openWithSelectedModule();">
  3141. <img class="ts avatar image" src="../../${thisModule.IconPath}">
  3142. <div class="content" style="padding-left:12px;">
  3143. <div class="header">${thisModule.Name}</div>
  3144. <div class="description">
  3145. ${supportFW}
  3146. ${supportEmb}
  3147. </div>
  3148. </div>
  3149. </div>`);
  3150. }
  3151. }
  3152. });
  3153. $(".openWithModule.popupbuttons").addClass("disabled");
  3154. if (!ao_module_virtualDesktop){
  3155. $("#openWith").find(".vdonly").hide();
  3156. }
  3157. showPopupWrapper();
  3158. $("#openWith").fadeIn('fast');
  3159. }
  3160. //Functions for handling open with module selection and file opening
  3161. function selectOpenWithModule(object, event){
  3162. event.preventDefault();
  3163. $(".openWithModule.popupbuttons").removeClass("disabled");
  3164. $(".openWithModule.selected").removeClass("selected");
  3165. $(object).addClass("selected");
  3166. }
  3167. function openWithSelectedModule(btn){
  3168. if ($(btn).hasClass("disabled")){
  3169. return false;
  3170. }
  3171. var targetModuleInfo = JSON.parse(decodeURIComponent($(".openWithModule.selected").attr("launchInfo")));
  3172. var targetObjects = $(".selected.fileObject");
  3173. console.log(targetModuleInfo);
  3174. //Phrase launch mode from the module info
  3175. var launchURL = targetModuleInfo.StartDir
  3176. var launchSize = [undefined, undefined];
  3177. var iconPath = targetModuleInfo.IconPath;
  3178. var title = targetModuleInfo.Name;
  3179. if (targetModuleInfo.SupportEmb){
  3180. //Launch with embedded mode
  3181. launchURL = targetModuleInfo.LaunchEmb;
  3182. if (targetModuleInfo.InitEmbSize !== null){
  3183. launchSize = targetModuleInfo.InitEmbSize
  3184. }
  3185. }else if (targetModuleInfo.SupportFW){
  3186. //Launch with floatWindow mode
  3187. launchURL = targetModuleInfo.LaunchFWDir;
  3188. if (targetModuleInfo.InitFWSize !== null){
  3189. launchSize = targetModuleInfo.InitFWSize
  3190. }
  3191. }else if (targetModuleInfo.StartDir !== ""){
  3192. //Launch with default mode
  3193. }else{
  3194. msgbox("remove",applocale.getString("message/moduleNotSupport", "This module has no endpoint for opening a file."));
  3195. return;
  3196. }
  3197. //Parse the filelist
  3198. var filelist = [];
  3199. $(targetObjects).each(function(){
  3200. var filename = $(this).attr("filename");
  3201. var filepath = $(this).attr("filepath");
  3202. filelist.push({
  3203. filename: filename,
  3204. filepath: filepath
  3205. });
  3206. });
  3207. fileHash = encodeURIComponent(JSON.stringify(filelist));
  3208. if (ao_module_virtualDesktop){
  3209. //Open the target module in a new fw
  3210. parent.newFloatWindow({
  3211. url: launchURL + "#" + fileHash,
  3212. width: launchSize[0],
  3213. height: launchSize[1],
  3214. appicon: iconPath,
  3215. title: title
  3216. });
  3217. }else{
  3218. //Redirect current window to the target module
  3219. window.location.href = "../../" + launchURL + "#" + fileHash;
  3220. }
  3221. hideAllPopupWindows();
  3222. }
  3223. function openFileWithModuleInNewTab(btn){
  3224. if ($(btn).hasClass("disabled")){
  3225. return false;
  3226. }
  3227. var targetModuleInfo = JSON.parse(decodeURIComponent($(".openWithModule.selected").attr("launchInfo")));
  3228. var targetObjects = $(".selected.fileObject");
  3229. //Parse the filelist
  3230. var filelist = [];
  3231. $(targetObjects).each(function(){
  3232. var filename = $(this).attr("filename");
  3233. var filepath = $(this).attr("filepath");
  3234. filelist.push({
  3235. filename: filename,
  3236. filepath: filepath
  3237. });
  3238. });
  3239. //Directly passing the file information to the startdir
  3240. fileHash = encodeURIComponent(JSON.stringify(filelist));
  3241. window.open("../../" + targetModuleInfo.StartDir + "#" + fileHash);
  3242. hideAllPopupWindows();
  3243. }
  3244. function openRawFileInFloatWindow(btn){
  3245. //Directly open this (or more than one) files / folder in floatWindow
  3246. var targetObjects = $(".selected.fileObject");
  3247. $(targetObjects).each(function(){
  3248. if ($(this).attr("type") == "file"){
  3249. var launchURL = "media?file=" + $(this).attr('filepath');
  3250. parent.newFloatWindow({
  3251. url: launchURL,
  3252. appicon: "img/system/file.png",
  3253. title: $(this).attr('filename'),
  3254. "background-color": "#1f1f1f"
  3255. });
  3256. }else if ($(this).attr("type") == "folder"){
  3257. var launchURL = "SystemAO/file_system/file_explorer.html#" + $(this).attr("filepath");
  3258. parent.newFloatWindow({
  3259. url: launchURL,
  3260. appicon: "SystemAO/file_system/img/small_icon.png",
  3261. title: "File Manager - " + $(this).attr('filename'),
  3262. });
  3263. }else{
  3264. //Not supported openeing type.
  3265. console.log("Failed to open file " + $(this).attr('filepath') + " . WIP")
  3266. }
  3267. });
  3268. hideAllPopupWindows();
  3269. }
  3270. //Open the filepaths in the given paramters
  3271. function openPathWithDefaultOpener(filepaths){
  3272. console.log("Opening: ", filepaths);
  3273. for (var i =0; i < filepaths.length; i++){
  3274. let filepath = JSON.parse(JSON.stringify(filepaths[i]));
  3275. var ext = "." + filepath.split(".").pop();
  3276. $.ajax({
  3277. url: "../../system/modules/getDefault",
  3278. method: "GET",
  3279. data: {opr: "launch", ext: ext, mode: "launch"},
  3280. success: function(data){
  3281. if (data.error !== undefined){
  3282. //No default opener assigned. Launch it with opener selector
  3283. var url = "SystemAO/file_system/defaultOpener.html";
  3284. var icon = "SystemAO/file_system/img/opener.png";
  3285. var title = "Select an opener WebApp: "
  3286. var openFileList = [];
  3287. var openFileObject = {
  3288. filepath: filepath,
  3289. filename: filepath.split("/").pop()
  3290. }
  3291. openFileList.push(openFileObject);
  3292. var openParamter = encodeURIComponent(JSON.stringify(openFileObject));
  3293. var ao_module_virtualDesktop = !(!parent.isDesktopMode);
  3294. console.log(window.innerHeight/2 - 510/20);
  3295. if (ao_module_virtualDesktop){
  3296. parent.newFloatWindow({
  3297. url: url + "#" + openParamter,
  3298. width: 320,
  3299. height: 510,
  3300. appicon: icon,
  3301. title: title
  3302. });
  3303. }else{
  3304. url = "defaultOpener.html";
  3305. window.open(url + "#" + openParamter);
  3306. }
  3307. }else{
  3308. //Assigned. Launch with given paramter
  3309. var url = data["StartDir"];
  3310. var size = [undefined, undefined];
  3311. var title = data["Name"];
  3312. var icon = "img/system/favicon.png";
  3313. if (data["IconPath"] != ""){
  3314. icon = data["IconPath"];
  3315. }
  3316. //Use floatWindow if exists
  3317. if (data["SupportFW"] == true && data["LaunchFWDir"] != ""){
  3318. url = data["LaunchFWDir"];
  3319. if (data["InitFWSize"] !== null){
  3320. size = data["InitFWSize"]
  3321. }
  3322. }
  3323. //Use embedded mode if exists
  3324. if (data["SupportEmb"] == true && data["LaunchEmb"] != ""){
  3325. url = data["LaunchEmb"];
  3326. if (data["InitEmbSize"] !== null){
  3327. size = data["InitEmbSize"]
  3328. }
  3329. }
  3330. //Build open File Hash Data Format
  3331. var openFileList = [];
  3332. var openFileObject = {
  3333. filepath: filepath,
  3334. filename: filepath.split("/").pop()
  3335. }
  3336. openFileList.push(openFileObject);
  3337. var openParamter = encodeURIComponent(JSON.stringify(openFileList));
  3338. //Add launch files info and launch floatWindow
  3339. var ao_module_virtualDesktop = !(!parent.isDesktopMode);
  3340. if (ao_module_virtualDesktop){
  3341. parent.newFloatWindow({
  3342. url: url + "#" + openParamter,
  3343. width: size[0],
  3344. height: size[1],
  3345. appicon: icon,
  3346. title: title
  3347. });
  3348. }else{
  3349. window.open("../../" + url + "#" + openParamter);
  3350. }
  3351. }
  3352. }
  3353. });
  3354. }
  3355. }
  3356. function openSelectedFolderInNewWindow(){
  3357. $(".fileObject.selected").each(function(){
  3358. if ($(this).attr("type") == "folder"){
  3359. console.log($(this).attr('filepath'));
  3360. openPathInNewWindow([$(this).attr('filepath')]);
  3361. }
  3362. })
  3363. }
  3364. function openSelectedVroot(){
  3365. $("#storageroot").find(".dir.item").each(function(){
  3366. if ($(this).hasClass("active")){
  3367. var thisRootPath = $(this).attr('filepath');
  3368. openPathInNewWindow([$(this).attr('filepath')]);
  3369. }
  3370. });
  3371. }
  3372. //Always open the first object locally, and open others in new floatWindows
  3373. function openFolderInNewWindow(paths){
  3374. if (paths.length > 0){
  3375. listDirectory(paths[0]);
  3376. for (var i = 1; i < paths.length; i++){
  3377. //newFloatWindow(location.href.replace(location.hash,"") + "#" + path[i])
  3378. openPathInNewWindow(paths[i]);
  3379. }
  3380. }
  3381. }
  3382. function openPathInNewWindow(path){
  3383. console.log("Opening in new File Maanger: ", window.location.pathname + "#" + path);
  3384. ao_module_newfw({
  3385. url: window.location.pathname + "#" + path,
  3386. appicon: "SystemAO/file_system/img/small_icon.png",
  3387. title: "File Manager",
  3388. width: 1080,
  3389. height: 580,
  3390. parent: ao_module_windowID,
  3391. });
  3392. }
  3393. //Preference setting and loading functions.
  3394. function setPreference(key, value){
  3395. $.ajax({
  3396. url:"../../system/file_system/preference?key=" + key + "&value=" + value,
  3397. success: function(data){
  3398. if (data.error !== undefined){
  3399. console.log(data);
  3400. }
  3401. }
  3402. });
  3403. }
  3404. function loadPreference(key, callback){
  3405. $.get("../../system/file_system/preference?key=" + key,function(data){
  3406. callback(data);
  3407. });
  3408. }
  3409. // ============================== WINDOW RESIZE FUNCTIONS =====================
  3410. $(document).ready(function(data){
  3411. if (window.innerWidth < 620 && !isMobile){
  3412. toggleSidebar(false);
  3413. }
  3414. initWindowSizes(false);
  3415. });
  3416. $(window).on("resize",function(){
  3417. initWindowSizes(false);
  3418. if (!isMobile && window.innerWidth < 620 && sideBarShown == true){
  3419. toggleSidebar(false);
  3420. }else if (!isMobile && window.innerWidth > 650 && sideBarShown == false){
  3421. toggleSidebar(false);
  3422. }
  3423. if (isMobile){
  3424. refreshList();
  3425. }
  3426. //Resize the share iframe
  3427. resizeShareIframe()
  3428. });
  3429. function handleShareFilebuttonClick(event, object){
  3430. event.preventDefault();
  3431. event.stopImmediatePropagation();
  3432. $(".fileObject.selected").removeClass("selected");
  3433. if (viewMode == "list"){
  3434. $(object).parent().parent().addClass("selected");
  3435. }else if (viewMode == "grid"){
  3436. $(object).parent().parent().parent().addClass("selected");
  3437. }
  3438. shareFile();
  3439. }
  3440. function resizeShareIframe(){
  3441. $("#shareFileEmbedded").css("height", $("#shareFile").height() - 126 + "px");
  3442. }
  3443. function shareFile(){
  3444. var selectedFiles = [];
  3445. var selectedFileObjects = [];
  3446. $(".fileObject.selected").each(function(){
  3447. var thisFilepath = $(this).attr("filepath");
  3448. var thisFilename = $(this).attr("filename");
  3449. selectedFiles.push(thisFilepath);
  3450. selectedFileObjects.push({"filepath": thisFilepath, "filename": thisFilename});
  3451. });
  3452. if (selectedFiles.length != 1){
  3453. //Try to share more than 1 files, which is not supported
  3454. console.log("Multi share is current not supported");
  3455. return
  3456. }
  3457. //OK! Continue to generate link
  3458. var selectedFile = selectedFiles[0];
  3459. var selectedFileObject = selectedFileObjects[0];
  3460. shareEditingObject = selectedFile;
  3461. $.ajax({
  3462. url: "../../system/file_system/share/new",
  3463. data: {path: selectedFile},
  3464. success: function(data){
  3465. if (data.error !== undefined){
  3466. msgbox("remove",applocale.getString("message/" + data.error,data.error), 5000);
  3467. }else{
  3468. //Build the predicted share endpoint
  3469. /*
  3470. let protocol = "https://";
  3471. if (location.protocol !== 'https:') {
  3472. protocol = "http://";
  3473. }
  3474. //Continue to render QR Code and UI contents
  3475. $("#qrcode").html("");
  3476. var port = ":" + window.location.port;
  3477. if (window.location.port == ""){
  3478. port = "";
  3479. }
  3480. var shareURL = protocol + window.location.hostname + port + "/share/" + data.UUID;
  3481. shareEditingUUID = data.UUID;
  3482. new QRCode(document.getElementById("qrcode"), shareURL);
  3483. $("#sharelink").text(shareURL);
  3484. $("#sharelink").attr("href", shareURL);
  3485. $(".shareoption").parent().removeClass("disabled");
  3486. $("#sharingRemoveBtn").show();
  3487. //Check the correct checkbox
  3488. var tagetCheckbox = data.Permission;
  3489. if (tagetCheckbox == "anyone"){
  3490. $("#anyone")[0].checked = true;
  3491. }else if (tagetCheckbox == "signedin"){
  3492. $("#signedin")[0].checked = true;
  3493. }else if (tagetCheckbox == "samegroup"){
  3494. $("#samegroup")[0].checked = true;
  3495. }
  3496. */
  3497. selectedFileObject["QRCode"] = true;
  3498. selectedFileObject["ActionButtons"] = false;
  3499. var payload = encodeURIComponent(JSON.stringify([selectedFileObject]));
  3500. var requestURL = "file_share.html#" + payload;
  3501. console.log(selectedFileObject, requestURL);
  3502. $("#shareFileEmbedded").attr("src", requestURL);
  3503. resizeShareIframe();
  3504. //Show the share file interface
  3505. $(".popup").fadeOut('fast');
  3506. showPopupWrapper();
  3507. $("#shareFile").fadeIn("fast");
  3508. //Reload the list
  3509. listDirectory(currentPath);
  3510. }
  3511. }
  3512. });
  3513. }
  3514. function removeSharing(){
  3515. if (shareEditingObject == ""){
  3516. return
  3517. }
  3518. //The target file to remove
  3519. var selectedFile = shareEditingObject;
  3520. $("#shareFileEmbedded").attr("src", "");
  3521. $.ajax({
  3522. url: "../../system/file_system/share/delete",
  3523. data: {path: selectedFile},
  3524. success: function(data){
  3525. console.log(data);
  3526. $("#qrcode").html(`<img src="img/private.png">`);
  3527. $(".shareoption").parent().addClass("disabled");
  3528. $("#sharelink").text("(Sharing Removed)");
  3529. $("#sharelink").removeAttr("href");
  3530. //Reload the current filelist and hide the share interface
  3531. listDirectory(currentPath);
  3532. //Reset sharing file settings
  3533. shareEditingObject = ""
  3534. shareEditingUUID = ""
  3535. }
  3536. });
  3537. $("#shareFile").fadeOut(100);
  3538. $(".popupWrapper").fadeOut(100);
  3539. msgbox("checkmark", applocale.getString("message/share/removed", "File share removed"))
  3540. }
  3541. function updateShareSettings(object){
  3542. $(object).addClass("loading");
  3543. var shareMode = $("#shareSettingForm [name='shareopt']:checked").val();
  3544. $.ajax({
  3545. url: "../../system/file_system/share/edit",
  3546. data: {uuid: shareEditingUUID, mode: shareMode},
  3547. success: function(data){
  3548. if (data.error !== undefined){
  3549. alert(data.error);
  3550. }
  3551. $(object).removeClass("loading");
  3552. $(object).html(`<i class="checkmark icon"></i> Updated`);
  3553. $(object).addClass("positive");
  3554. setTimeout(function(){
  3555. $(object).html("Update");
  3556. $(object).removeClass("positive");
  3557. }, 3000);
  3558. }
  3559. })
  3560. }
  3561. function hideShare(){
  3562. hideAllPopupWindows();
  3563. $("#shareFileEmbedded").attr("src", "");
  3564. }
  3565. function toggleSidebar(useAnimation=true){
  3566. //Fixing desktop bugs on showing the sidebar
  3567. if (isMobile){
  3568. $("#directorySidebar").stop().finish().animate({left: "toggle"},200);
  3569. }else{
  3570. if ($("#directorySidebar").offset().left < 0){
  3571. $("#directorySidebar").stop().finish().animate({left: 0},200);
  3572. }else{
  3573. $("#directorySidebar").stop().finish().animate({left: -1 * directorySidebarWidth},200);
  3574. }
  3575. }
  3576. sideBarShown = !sideBarShown;
  3577. initWindowSizes(useAnimation);
  3578. }
  3579. function initWindowSizes(animate=true){
  3580. var h = $("#navibar").css("height");
  3581. var hint = $("#navibar").height();
  3582. //$("#mainWindow").css("padding-top",h);
  3583. var windowHeight = window.innerHeight - hint - 12;
  3584. //console.log(windowHeight);
  3585. if (sideBarShown){
  3586. //Resize the sidebar
  3587. $("#directorySidebar").css("top",h);
  3588. $("#directorySidebar").css("width",directorySidebarWidth);
  3589. $("#directorySidebar").css("height",windowHeight + "px");
  3590. //Resize the file viewer
  3591. $("#folderView").css("top",h);
  3592. if (window.innerWidth > 650){
  3593. if (animate){
  3594. $("#folderView").stop().finish().animate({
  3595. left: directorySidebarWidth + 'px',
  3596. width: window.innerWidth - directorySidebarWidth - 2 + "px"
  3597. },200);
  3598. }else{
  3599. $("#folderView").css({
  3600. left: directorySidebarWidth + 'px',
  3601. width: window.innerWidth - directorySidebarWidth - 2 + "px"
  3602. });
  3603. }
  3604. }else{
  3605. //Window width too small to allow resizing sidebar shown. Overlap it
  3606. if (animate){
  3607. $("#folderView").stop().finish().animate({
  3608. left: directorySidebarWidth + 'px',
  3609. width: window.innerWidth + "px"
  3610. },200);
  3611. }else{
  3612. $("#folderView").css({
  3613. left: directorySidebarWidth + 'px',
  3614. width: window.innerWidth + "px"
  3615. });
  3616. }
  3617. }
  3618. if (isChromium){
  3619. //$("#mainWindow").css("height", window.innerWidth);
  3620. }
  3621. //$("#folderView").css("left",directorySidebarWidth + "px");
  3622. $("#folderView").css("height",windowHeight + "px");
  3623. }else{
  3624. $("#folderView").css("top",h);
  3625. if (animate){
  3626. $("#folderView").stop().finish().animate({
  3627. left:'0px',
  3628. width:(window.innerWidth - 2 + "px")
  3629. },200);
  3630. }else{
  3631. $("#folderView").css({
  3632. left:'0px',
  3633. width:(window.innerWidth - 2 + "px")
  3634. });
  3635. }
  3636. $("#folderView").css("height",windowHeight + "px");
  3637. }
  3638. }
  3639. function toggleDarkTheme(){
  3640. if ($(".darkTheme").length > 0){
  3641. //Set To Whitetheme
  3642. $(".darkTheme").removeClass("darkTheme").addClass("whiteTheme");
  3643. currentTheme = "whiteTheme";
  3644. $("#darkthemebtn").attr("class","moon icon");
  3645. $("#darkthemebtn").parent().addClass("inverted");
  3646. $(".dropdown").removeClass("inverted");
  3647. setPreference("file_explorer/theme","whiteTheme");
  3648. //If in vdi mode, update desktop's listMenu as well
  3649. if (ao_module_virtualDesktop){
  3650. parent.initTheme("whiteTheme");
  3651. }
  3652. $(".rightPad").css("margin-right", "37px");
  3653. }else{
  3654. //Set to DarkTheme
  3655. $(".whiteTheme").removeClass("whiteTheme").addClass("darkTheme");
  3656. currentTheme = "darkTheme";
  3657. $("#darkthemebtn").attr("class","sun icon");
  3658. $("#darkthemebtn").parent().removeClass("inverted");
  3659. $(".dropdown").addClass("inverted");
  3660. setPreference("file_explorer/theme","darkTheme");
  3661. //If in vdi mode, update desktop's listMenu as well
  3662. if (ao_module_virtualDesktop){
  3663. parent.initTheme("darkTheme");
  3664. }
  3665. $(".rightPad").css("margin-right", "40px");
  3666. }
  3667. }
  3668. function msgbox(icon, text, delay=3000){
  3669. $($(".msgbox").find("span")[0]).text(text);
  3670. $($(".msgbox").find("i")[0]).attr("class", icon + " icon");
  3671. $(".msgbox").stop().finish().slideDown('fast').delay(delay).slideUp('fast', function(){
  3672. initWindowSizes(false);
  3673. });
  3674. }
  3675. //Keyboard hotkey events
  3676. $(document).keydown(function(event){
  3677. if ($(':focus').is("input")){
  3678. //Do not block operations on input fields.
  3679. return;
  3680. }
  3681. if(event.which==17 || event.which == 91){
  3682. ctrlHold = true;
  3683. updateCtrlDisplay();
  3684. }else if (event.which == 16){
  3685. shiftHold = true;
  3686. updateCtrlDisplay();
  3687. }else if (event.which == 67 && ctrlHold == true){
  3688. //Ctrl + C
  3689. if (!$(".popup").is(":visible")){
  3690. event.preventDefault();
  3691. copy();
  3692. }
  3693. }else if (event.which == 88 && ctrlHold == true){
  3694. //Ctrl + X
  3695. if (!$(".popup").is(":visible")){
  3696. event.preventDefault();
  3697. cut();
  3698. }
  3699. }else if (event.which == 65 && ctrlHold == true){
  3700. //Ctrl + A
  3701. event.preventDefault();
  3702. $(".fileObject").addClass("selected");
  3703. }else if (event.which == 78 && shiftHold == true){
  3704. //Shift + N, Open new file manager window with current path
  3705. event.preventDefault();
  3706. openPathInNewWindow(currentPath);
  3707. }else if (event.which == 86 && ctrlHold == true){
  3708. if (!$(".popup").is(":visible")){
  3709. paste();
  3710. }
  3711. }else if (event.which == 46 && shiftHold == true){
  3712. //Shift + delete
  3713. forceDelete();
  3714. }else if (event.which == 46){
  3715. //Delete
  3716. deleteFile();
  3717. }else if (event.which == 38){
  3718. //Up Arrow
  3719. if ($(".popup:visible").length == 0){
  3720. //No popup visiable
  3721. if (ctrlHold == true){
  3722. //Parenet path
  3723. parentDir();
  3724. }else{
  3725. //Select the file on the upper
  3726. selectPreviousFile(event);
  3727. }
  3728. }
  3729. }else if (event.which == 40){
  3730. //Down arrow
  3731. if ($(".popup:visible").length == 0){
  3732. //No popup visiable
  3733. selectNextFile(event);
  3734. }
  3735. }else if (event.which == 39){
  3736. //Right arrow
  3737. if ($(".popup:visible").length == 0 && viewMode == "grid"){
  3738. //No popup visiable and grid mode
  3739. selectRightFile(event);
  3740. }
  3741. }else if (event.which == 37){
  3742. //Left arrow
  3743. if ($(".popup:visible").length == 0 && viewMode == "grid"){
  3744. //No popup visiable and grid mode
  3745. selectLeftFile(event);
  3746. }
  3747. }else if (event.which == 13){
  3748. //Enter key
  3749. if ($(".fileObject.selected").length > 0){
  3750. openViaButton();
  3751. }else if ($(".fileObject.hotSearchHighlight").length > 0 && $(".fileObject.selected").length == 0){
  3752. //Hot search selection mode
  3753. }
  3754. }else if (event.which == 27){
  3755. //Esc key
  3756. hideAllPopupWindows();
  3757. $(".fileObject.selected").removeClass("selected");
  3758. }else{
  3759. //Handle generic file search by consecutive typing
  3760. if (hotSearchTimer != null){
  3761. clearTimeout(hotSearchTimer);
  3762. }
  3763. $(".fileObject.selected").removeClass("selected");
  3764. hotSearchTimer = setTimeout(function(){
  3765. exitHotSearch();
  3766. }, 1000);
  3767. if (hotSearchBuffer.length > 0 && event.key == hotSearchBuffer.substr(hotSearchBuffer.length - 1, 1)){
  3768. //Jump to next result
  3769. hotSearchOffsetIndex++;
  3770. }else{
  3771. hotSearchOffsetIndex = 0;
  3772. hotSearchBuffer+= event.key;
  3773. }
  3774. handleHotSearch(hotSearchBuffer, hotSearchOffsetIndex);
  3775. }
  3776. });
  3777. $(document).keyup(function(event){
  3778. if(event.which==17 || event.which == 91){
  3779. ctrlHold = false;
  3780. updateCtrlDisplay();
  3781. }else if (event.which == 16){
  3782. shiftHold = false;
  3783. }
  3784. });
  3785. $("#directorySidebar").on("click",function(evt){
  3786. //Clear the button holding
  3787. $(".fileObject.selected").removeClass("selected");
  3788. shiftHold = false;
  3789. ctrlHold = false;
  3790. updateCtrlDisplay();
  3791. });
  3792. //Check if localstorage is availble
  3793. function lscheck(){
  3794. var test = 'test';
  3795. try {
  3796. localStorage.setItem(test, test);
  3797. localStorage.removeItem(test);
  3798. return true;
  3799. } catch(e) {
  3800. return false;
  3801. }
  3802. }
  3803. function selectNextFile(e){
  3804. e.preventDefault();
  3805. //Check if there are no selection. If yes, select the first file object
  3806. if ($(".fileObject.selected").length == 0 && $(".fileObject").length > 0){
  3807. //Select the first file object
  3808. $($(".fileObject")[0]).addClass("selected");
  3809. return
  3810. }else if ( $(".fileObject").length == 0){
  3811. //No file in this folder
  3812. return
  3813. }
  3814. //Already contain selected file on the interface. Seleect it
  3815. var baseObject = $($(".fileObject.selected")[0]);
  3816. if ($(".fileObject.selected").length > 1){
  3817. $(".fileObject.selected").removeClass("selected");
  3818. }
  3819. if (viewMode == "list"){
  3820. //Select the next file
  3821. var nextObject = $(".fileObject").eq( $(".fileObject").index( $(baseObject) ) + 1 );
  3822. if (nextObject.length > 0){
  3823. nextObject.addClass("selected");
  3824. scrollToFileObject(nextObject);
  3825. $(baseObject).removeClass("selected");
  3826. }
  3827. }else if (viewMode == "grid"){
  3828. var colobj = getFileObjectInTheSameCol(baseObject);
  3829. var nextObject = baseObject;
  3830. for (var i = 0; i < colobj.length; i++){
  3831. if ($(colobj[i]).hasClass("selected") && i != colobj.length - 1){
  3832. nextObject = colobj[i + 1];
  3833. }
  3834. }
  3835. $(baseObject).removeClass("selected");
  3836. nextObject.addClass("selected");
  3837. scrollToFileObject(nextObject);
  3838. }
  3839. }
  3840. function selectPreviousFile(e){
  3841. e.preventDefault();
  3842. //Check if there are no selection. If yes, select the first file object
  3843. if ($(".fileObject.selected").length == 0 && $(".fileObject").length > 0){
  3844. //Select the first file object
  3845. $($(".fileObject")[$(".fileObject").length - 1]).addClass("selected");
  3846. return
  3847. }else if ( $(".fileObject").length == 0){
  3848. //No file in this folder
  3849. return
  3850. }
  3851. var baseObject = $($(".fileObject.selected")[0]);
  3852. if ($(".fileObject.selected").length > 1){
  3853. $(".fileObject.selected").removeClass("selected");
  3854. }
  3855. if (viewMode == "list"){
  3856. //Select the previous file
  3857. if ($(".fileObject").index( $(baseObject) ) -1 < 0){
  3858. return;
  3859. }
  3860. var previousObject = $(".fileObject").eq( $(".fileObject").index( $(baseObject) ) -1 );
  3861. if (previousObject.length > 0){
  3862. previousObject.addClass("selected");
  3863. scrollToFileObject(previousObject);
  3864. $(baseObject).removeClass("selected");
  3865. }
  3866. }else if (viewMode == "grid"){
  3867. var colobj = getFileObjectInTheSameCol(baseObject);
  3868. var prevObj = baseObject;
  3869. for (var i = 0; i < colobj.length; i++){
  3870. if ($(colobj[i]).hasClass("selected") && i > 0){
  3871. prevObj = colobj[i - 1];
  3872. }
  3873. }
  3874. $(baseObject).removeClass("selected");
  3875. prevObj.addClass("selected");
  3876. scrollToFileObject(prevObj);
  3877. }
  3878. }
  3879. function scrollToFileObject(fileObject){
  3880. if (viewMode == "grid"){
  3881. $('#folderView').scrollTop($(fileObject)[0].offsetTop - ($("#directorySidebar").height()/2 - 340));
  3882. }else{
  3883. $('#folderView').scrollTop($(fileObject)[0].offsetTop - ($("#directorySidebar").height()/2 - 140));
  3884. }
  3885. }
  3886. //Grid mode left right opr
  3887. function selectLeftFile(e){
  3888. e.preventDefault();
  3889. if (viewMode != "grid"){
  3890. return;
  3891. }
  3892. if ($(".fileObject.selected").length == 0 && $(".fileObject").length > 0){
  3893. //Select the first file object
  3894. $($(".fileObject")[$(".fileObject").length - 1]).addClass("selected");
  3895. return
  3896. }else if ( $(".fileObject").length == 0){
  3897. //No file in this folder
  3898. return
  3899. }
  3900. var baseObject = $($(".fileObject.selected")[0]);
  3901. if ($(".fileObject").index( $(baseObject) ) -1 < 0){
  3902. return;
  3903. }
  3904. var previousObject = $(".fileObject").eq( $(".fileObject").index( $(baseObject) ) -1 );
  3905. if (previousObject.length > 0){
  3906. previousObject.addClass("selected");
  3907. scrollToFileObject(previousObject);
  3908. $(baseObject).removeClass("selected");
  3909. }
  3910. }
  3911. function selectRightFile(e){
  3912. e.preventDefault();
  3913. if (viewMode != "grid"){
  3914. return;
  3915. }
  3916. if ($(".fileObject.selected").length == 0 && $(".fileObject").length > 0){
  3917. //Select the first file object
  3918. $($(".fileObject")[0]).addClass("selected");
  3919. return
  3920. }else if ( $(".fileObject").length == 0){
  3921. //No file in this folder
  3922. return
  3923. }
  3924. var baseObject = $($(".fileObject.selected")[0]);
  3925. var nextObject = $(".fileObject").eq( $(".fileObject").index( $(baseObject) ) + 1 );
  3926. if (nextObject.length > 0){
  3927. nextObject.addClass("selected");
  3928. scrollToFileObject(nextObject);
  3929. $(baseObject).removeClass("selected");
  3930. }
  3931. }
  3932. //Functions for getting file objects in the same collume
  3933. function getFileObjectInTheSameCol(baseFileObject){
  3934. if (viewMode != "grid"){
  3935. return;
  3936. }
  3937. var baseOffset = $(baseFileObject).offset().left;
  3938. var fileObjectInTheSameCol = [];
  3939. $(".fileObject").each(function(){
  3940. if ($(this).offset().left == baseOffset){
  3941. let thisFileObject = $(this);
  3942. fileObjectInTheSameCol.push(thisFileObject);
  3943. }
  3944. });
  3945. return fileObjectInTheSameCol;
  3946. }
  3947. //Function for getting file objects in the same row
  3948. function getFileObjectInTheSameRow(baseFileObject){
  3949. if (viewMode != "grid"){
  3950. return;
  3951. }
  3952. var baseOffset = $(baseFileObject).offset().top;
  3953. var fileObjectInTheSameRow = [];
  3954. $(".fileObject").each(function(){
  3955. if ($(this).offset().top == baseOffset){
  3956. let thisFileObject = $(this);
  3957. fileObjectInTheSameRow.push(thisFileObject);
  3958. }
  3959. });
  3960. return fileObjectInTheSameRow;
  3961. }
  3962. //Handle drag drop upload
  3963. function drop(event){
  3964. event.preventDefault();
  3965. console.log(event, event.target)
  3966. //Check if this is file upload or file move / copy function
  3967. let dt = event.dataTransfer
  3968. let files = dt.files
  3969. if (files.length > 0){
  3970. //Upload file via dragdrop
  3971. msgbox("upload",applocale.getString("message/upload/started", "Upload Started"));
  3972. let items = event.dataTransfer.items;
  3973. for (let i=0; i<items.length; i++) {
  3974. let item = items[i].webkitGetAsEntry();
  3975. if (item) {
  3976. recursiveScanFilesUpload(item);
  3977. }
  3978. }
  3979. }else{
  3980. //File transfer within system
  3981. let filedata = event.dataTransfer.getData("filedata");
  3982. if (filedata != ""){
  3983. try{
  3984. let fileList = JSON.parse(filedata);
  3985. //Check if the file objects are from the same host
  3986. let localFiles = [];
  3987. let remoteFiles = [];
  3988. fileList.forEach(file => {
  3989. if (file.hostUUID == systemUUID){
  3990. //Local file
  3991. localFiles.push(file);
  3992. }else{
  3993. //Remote files
  3994. remoteFiles.push(file);
  3995. }
  3996. });
  3997. //Start processing the local files
  3998. let currentVroot = currentPath.split(":/").shift();
  3999. clipboard = [];
  4000. //Assume all files are from the same directory
  4001. if (localFiles.length > 0){
  4002. //Check if drag drop from the same directory
  4003. let currentDirname = currentPath.split("/")
  4004. currentDirname.pop();
  4005. currentDirname = currentDirname.join("/");
  4006. let firstFileDirname = localFiles[0].filepath.split("/")
  4007. firstFileDirname.pop();
  4008. firstFileDirname = firstFileDirname.join("/");
  4009. if (currentDirname == firstFileDirname){
  4010. //Drag start and drop location are the same directory
  4011. msgbox("remove",applocale.getString("message/destIdentical", "Source and destination file names are the same"));
  4012. return;
  4013. }
  4014. let fileVroot = localFiles[0].filepath.split(":/").shift();
  4015. if (currentVroot == fileVroot){
  4016. //Same device same root. Move the file
  4017. cutMode = true;
  4018. }else{
  4019. //Same device differnet root. Copy the file
  4020. cutMode = false;
  4021. }
  4022. //Move all localFiles into clipboard
  4023. localFiles.forEach(file => {
  4024. clipboard.push(file.filepath);
  4025. });
  4026. if (useLocalstorage){
  4027. localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
  4028. if (cutMode){
  4029. localStorage.setItem("ao/file_system/cutmode","true");
  4030. }else{
  4031. localStorage.setItem("ao/file_system/cutmode","false");
  4032. }
  4033. }
  4034. //Paste all the files to the current path
  4035. console.log(clipboard);
  4036. paste();
  4037. }
  4038. }catch(ex){
  4039. console.log(ex);
  4040. msgbox("remove",applocale.getString("message/decodeFilelistFail", "File drop failed. Unable to decode filelist."));
  4041. }
  4042. }
  4043. }
  4044. }
  4045. function recursiveScanFilesUpload(item, rootpath="", base=""){
  4046. var filesInside = [];
  4047. if (item.isDirectory) {
  4048. //This is a directory
  4049. let directoryReader = item.createReader();
  4050. directoryReader.readEntries(function(entries) {
  4051. entries.forEach(function(entry) {
  4052. recursiveScanFilesUpload(entry, rootpath + item.name + "/", base);
  4053. });
  4054. });
  4055. }else{
  4056. //This is a file. Upload it
  4057. item.file(function(fileObject){
  4058. if (isChrome || isSafari){
  4059. //WebKits
  4060. console.log("Upload Target", fileObject, rootpath);
  4061. uploadFile(fileObject, undefined, currentPath + rootpath);
  4062. }else{
  4063. //Firefox. Special handling for root path.
  4064. //Updates for Firefox 84.0.2 (64-bit), which changed minor implementation on relative path in folder updates
  4065. //This section of code is deprecated since then
  4066. /*
  4067. //As firefox will keep its file input relative path, we need to remove the root folder
  4068. //name from the rootpath passed in by the webkit API
  4069. if (rootpath.substr(rootpath.length - 1, 1) == "/"){
  4070. rootpath = rootpath.substr(0, rootpath.length - 1);
  4071. }
  4072. var rootpathInfo = rootpath.split("/");
  4073. if (rootpathInfo.length > 1){
  4074. //Uploading folder to folder. Extract the folder root name
  4075. rootpathInfo.pop();
  4076. }else{
  4077. //Uploading file to folder. Do nothing
  4078. }
  4079. rootpath = rootpathInfo.join("/") + "/";
  4080. console.log("Upload Target", fileObject, rootpath);
  4081. uploadFile(fileObject, undefined, currentPath + rootpath);
  4082. */
  4083. //console.log(currentPath + rootpath);
  4084. uploadFile(fileObject, undefined, currentPath + base);
  4085. }
  4086. });
  4087. }
  4088. return filesInside;
  4089. }
  4090. function showCurrentDirectoryProperties(){
  4091. var fileList = [currentPath];
  4092. console.log(fileList);
  4093. var hashPassthrough = encodeURIComponent(JSON.stringify(fileList));
  4094. ao_module_newfw({
  4095. url: "SystemAO/file_system/file_properties.html#" + hashPassthrough,
  4096. width: 340,
  4097. height: 480,
  4098. appicon: "SystemAO/file_system/img/properties.png",
  4099. title: "File Properties",
  4100. });
  4101. }
  4102. function showVrootProperties(){
  4103. var rootname = [$("#storageroot").find(".dir.item.active").attr("filepath")];
  4104. var hashPassthrough = encodeURIComponent(JSON.stringify(rootname));
  4105. ao_module_newfw({
  4106. url: "SystemAO/disk/diskprop.html#" + hashPassthrough,
  4107. width: 420,
  4108. height: 580,
  4109. appicon: "img/system/drive.svg",
  4110. title: "Disk Properties",
  4111. });
  4112. }
  4113. function openBackupManager(){
  4114. var rootname = [$("#storageroot").find(".dir.item.active").attr("filepath")];
  4115. var hashPassthrough = encodeURIComponent(JSON.stringify(rootname));
  4116. ao_module_newfw({
  4117. url: "SystemAO/disk/disk_restore.html#" + hashPassthrough,
  4118. width: 410,
  4119. height: 580,
  4120. appicon: "img/system/backup.svg",
  4121. title: "Backup & Restore",
  4122. });
  4123. }
  4124. function showFileProperties(){
  4125. //Show the file list of the selected files
  4126. if ($(".fileObject.selected").length > 0){
  4127. //Build the filelist
  4128. var fileList = [];
  4129. $(".fileObject.selected").each(function(){
  4130. var filepath = $(this).attr("filepath");
  4131. fileList.push(filepath);
  4132. });
  4133. var hashPassthrough = encodeURIComponent(JSON.stringify(fileList));
  4134. ao_module_newfw({
  4135. url: "SystemAO/file_system/file_properties.html#" + hashPassthrough,
  4136. width: 340,
  4137. height: 480,
  4138. appicon: "SystemAO/file_system/img/properties.png",
  4139. title: "File Properties",
  4140. });
  4141. }
  4142. }
  4143. function initUploadMode(){
  4144. //Deprecated, will automatically decide which mode to use base on file size and disk space
  4145. /*
  4146. //Get the amount of RAM on the server side to check if low memory mode should be used.
  4147. $.ajax({
  4148. url: "../../system/info/getRAMinfo",
  4149. success: function(data){
  4150. if (data.error !== undefined){
  4151. //Permission denied or other reasons that cannot access harwdare info. Use default mode
  4152. lowMemoryMode = true;
  4153. }else{
  4154. //Check if ramsize > 3.8GB. If yes, switch to large memory upload mode
  4155. var memsize = JSON.parse(data);
  4156. if (parseFloat(memsize)/ 1024 / 1024 / 1024 >= 3.8){
  4157. console.log("[File Explorer] Entering large memory upload mode")
  4158. lowMemoryMode = false;
  4159. }
  4160. }
  4161. },
  4162. error: function(){
  4163. //Hardware mode disabled. Always use low memory upload mode instead
  4164. lowMemoryMode = true;
  4165. }
  4166. });
  4167. */
  4168. //Get the avaible space on tmp disk and decide the cutoff file size that need to directly write to disk
  4169. $.ajax({
  4170. url: "../../system/disk/space/resolve",
  4171. method: "POST",
  4172. data: {path: "tmp:/"},
  4173. success: function(data){
  4174. if (data.error !== undefined){
  4175. }else{
  4176. console.log("[File Explorer] Setting huge file cutoff size at: " + ao_module_utils.formatBytes(data.Avilable/16));
  4177. largeFileCutoffSize = data.Avilable/16 - 4096;
  4178. }
  4179. },
  4180. error: function(){
  4181. //Hardware mode disabled. Use default value.
  4182. }
  4183. });
  4184. }
  4185. let uploadBufferedRefreshTimer;
  4186. function uploadFile(file, uuid=undefined, targetDir=undefined) {
  4187. if (file.size > postUploadModeCutoff && lowMemoryMode){
  4188. /*
  4189. Low Memory Upload Mode
  4190. */
  4191. var filename = encodeURIComponent(file.name);
  4192. var filesize = file.size;
  4193. //Generate a new file item
  4194. let taskUUID = uuid; //For queueing objects
  4195. if (taskUUID == undefined){
  4196. //If this is a new file to be uploaded
  4197. taskUUID = appendUploadFileItem(file.name, file.size);
  4198. setTimeout(function(){
  4199. updateUploadFileCount();
  4200. }, 100);
  4201. }
  4202. //Push to upload pending list if the max concurrent upload is reached
  4203. if (uploadingFileCount >= maxConcurrentUpload){
  4204. let uploadDir = currentPath;
  4205. if (targetDir !== undefined){
  4206. uploadDir = targetDir;
  4207. }else if (isFirefox && uploadDir == currentPath && file.webkitRelativePath != ""){
  4208. //Use the webkitRelativePath instead of the name, this is a folder upload
  4209. //Deprecated for Firefox 84.0.2 updates
  4210. /*
  4211. let pathinfo = file.webkitRelativePath.split("/");
  4212. pathinfo.pop();
  4213. let subpath = pathinfo.join("/");
  4214. uploadDir = uploadDir + subpath;
  4215. */
  4216. uploadDir = targetDir;
  4217. }
  4218. uploadPendingList.push({
  4219. File: file,
  4220. UUID: taskUUID,
  4221. TargetDir: JSON.parse(JSON.stringify(uploadDir)),
  4222. });
  4223. return
  4224. }
  4225. function updateProgressForWebSocketUpload(uuid, progress){
  4226. $(".uploadTask").each(function(){
  4227. if ($(this).attr("taskID") == uuid){
  4228. //Update this progress bar
  4229. $(this).find(".bar").css("width",progress + "%");
  4230. if (progress == 100){
  4231. //When progress = 100 and the server is not response with 200,
  4232. //That means the upload has finish and server is processing the upload
  4233. $(this).find(".progress").addClass("indeterminate");
  4234. }
  4235. }
  4236. });
  4237. }
  4238. //Open the websocket
  4239. let path = currentPath;
  4240. let protocol = "wss://";
  4241. if (location.protocol !== 'https:') {
  4242. protocol = "ws://";
  4243. }
  4244. var port = window.location.port;
  4245. if (window.location.port == ""){
  4246. if (location.protocol !== 'https:') {
  4247. port = "80";
  4248. }else{
  4249. port = "443";
  4250. }
  4251. }
  4252. let uploadDir = currentPath;
  4253. if (targetDir !== undefined){
  4254. //Not uploading to current directory. Change upload path to target
  4255. uploadDir = targetDir;
  4256. }
  4257. //Fixing Firefox path issues on or above FF48.0
  4258. if (isFirefox && file.webkitRelativePath != ""){
  4259. //Use the webkitRelativePath instead of the name, this is a folder upload
  4260. let pathinfo = file.webkitRelativePath.split("/");
  4261. pathinfo.pop();
  4262. let subpath = pathinfo.join("/");
  4263. uploadDir = uploadDir + subpath;
  4264. //console.log("Firefox Mode: ", uploadDir, "Target Dir", targetDir)
  4265. }
  4266. let hugeFileMode = "";
  4267. if (file.size > largeFileCutoffSize){
  4268. //Filesize over cutoff line. Use huge file mode
  4269. hugeFileMode = "&hugefile=true";
  4270. }
  4271. let socket = new WebSocket(protocol + window.location.hostname + ":" + port + "/system/file_system/lowmemUpload?filename=" + encodeURIComponent(filename) + "&path=" + encodeURIComponent(uploadDir) + hugeFileMode);
  4272. let currentSendingIndex = 0;
  4273. let chunks = Math.ceil(file.size/uploadFileChunkSize,uploadFileChunkSize);
  4274. //Define a function for sending a particular chunk
  4275. function sendChunk(id){
  4276. var offsetStart = id*uploadFileChunkSize;
  4277. var offsetEnd = id*uploadFileChunkSize + uploadFileChunkSize;
  4278. var thisblob = file.slice(offsetStart,offsetEnd);
  4279. socket.send(thisblob);
  4280. //console.log(id + "/" + chunks);
  4281. //Update progress to first percentage
  4282. var progress = id / (chunks-1) * 100.0;
  4283. if (progress > 100){
  4284. progress = 100;
  4285. }
  4286. updateProgressForWebSocketUpload(taskUUID, progress)
  4287. }
  4288. //Update all UI elements
  4289. updateUploadFileCount();
  4290. uploadingFileCount++;
  4291. //Start sending
  4292. socket.onopen = function(e) {
  4293. if (filesize < uploadFileChunkSize){
  4294. //This file is smaller than chunk size, set it to somwhere within 10% - 20% so it doesn't look like it is stuck
  4295. updateProgressForWebSocketUpload(taskUUID, 10 + Math.floor(Math.random() * Math.floor(10)))
  4296. }
  4297. //Send the first chunk
  4298. sendChunk(0);
  4299. currentSendingIndex++;
  4300. };
  4301. socket.onmessage = function(event) {
  4302. //Append to the send index
  4303. var incomingValue = event.data;
  4304. if (incomingValue == "next"){
  4305. if (currentSendingIndex == chunks + 1){
  4306. //Already finished
  4307. socket.send("done");
  4308. }else{
  4309. //Send next chunk
  4310. sendChunk(currentSendingIndex);
  4311. currentSendingIndex++;
  4312. }
  4313. }else if (incomingValue == "OK"){
  4314. //Merge completed
  4315. $(".uploadTask").each(function(){
  4316. if ($(this).attr("taskID") == taskUUID){
  4317. //Update this progress bar to completed
  4318. $(this).find(".bar").css("width","100%");
  4319. $(this).find(".progress").attr("class","ts tiny positive progress");
  4320. $(this).find(".uploadTaskRemoveIcon").show();
  4321. $(this).addClass("ended");
  4322. $.when($(this).delay(1000).fadeOut("fast")).then(function(){
  4323. $(this).remove();
  4324. updateUploadFileCount();
  4325. });
  4326. }
  4327. });
  4328. }else{
  4329. //Try to parse it as JSON
  4330. try{
  4331. var resp = JSON.parse(incomingValue.split('\\' + '"').join("\""));
  4332. console.log(resp);
  4333. if (resp.error !== undefined){
  4334. //This is an error message
  4335. msgbox("remove",resp.error);
  4336. //Update the progress bar to error
  4337. $(".uploadTask").each(function(){
  4338. if ($(this).attr("taskID") == taskUUID){
  4339. //Update this progress bar to completed
  4340. $(this).find(".bar").css("width","100%");
  4341. $(this).find(".progress").attr("class","ts tiny negative progress");
  4342. $(this).find(".uploadTaskRemoveIcon").show();
  4343. $(this).addClass("ended");
  4344. }
  4345. });
  4346. }
  4347. }catch(ex){
  4348. //Something else
  4349. console.log(incomingValue);
  4350. console.log(ex);
  4351. }
  4352. }
  4353. };
  4354. socket.onclose = function(event) {
  4355. uploadingFileCount--;
  4356. updateUploadFileCount();
  4357. //After the previous file has uploaded / errored, check if there are another file needed to be uploaded
  4358. setTimeout(function(){
  4359. if (uploadPendingList.length > 0){
  4360. let nextFile = uploadPendingList.shift();
  4361. uploadFile(nextFile.File, nextFile.UUID, nextFile.TargetDir);
  4362. }
  4363. }, 100)
  4364. };
  4365. socket.onerror = function(error) {
  4366. console.log(error.message);
  4367. console.log("Unable to open WebSocket connection. Fall back to FORM POST upload mode. (Check your nginx / reverse proxy settings!!!)")
  4368. //Try to fallback to FORM POST upload mode
  4369. lowMemoryMode = false;
  4370. uploadPendingList.push({
  4371. File: file,
  4372. UUID: taskUUID,
  4373. TargetDir: JSON.parse(JSON.stringify(targetDir)),
  4374. });
  4375. return
  4376. };
  4377. }else{
  4378. /*
  4379. Standard Upload Mode
  4380. (For host with RAM >= 2GB)
  4381. */
  4382. //Create the task progress Object
  4383. let taskUUID = uuid; //For queueing objects
  4384. if (taskUUID == undefined){
  4385. //If this is a new file to be uploaded
  4386. taskUUID = appendUploadFileItem(file.name, file.size);
  4387. setTimeout(function(){
  4388. updateUploadFileCount();
  4389. }, 100);
  4390. }
  4391. //Updates 22-10-2020
  4392. //Added file upload queuing system to prevent too many request on-the-fly at the same time
  4393. if (uploadingFileCount >= maxConcurrentUpload){
  4394. //Push to upload pending list
  4395. //Sometime files will be recursively uploaded (aka retry multiple time), hence the targetDir needed to be copied as well
  4396. let uploadDir = currentPath;
  4397. if (targetDir !== undefined){
  4398. uploadDir = targetDir;
  4399. }
  4400. uploadPendingList.push({
  4401. File: file,
  4402. UUID: taskUUID,
  4403. TargetDir: JSON.parse(JSON.stringify(uploadDir)),
  4404. });
  4405. return
  4406. }
  4407. //Prase upload Form
  4408. let uploadCurrentPath = JSON.parse(JSON.stringify(currentPath));
  4409. if (targetDir !== undefined){
  4410. //The upload paramter supplied targetDir
  4411. uploadCurrentPath = targetDir;
  4412. }
  4413. let url = '../../system/file_system/upload?path=' + encodeURIComponent(uploadCurrentPath)
  4414. //console.log("Uploading To => ", uploadCurrentPath, targetDir, currentPath);
  4415. let formData = new FormData()
  4416. let xhr = new XMLHttpRequest()
  4417. formData.append('file', file);
  4418. formData.append('path', uploadCurrentPath);
  4419. xhr.open('POST', url, true)
  4420. xhr.upload.addEventListener("progress", function(e) {
  4421. var progress = (e.loaded * 100.0 / e.total) || 100;
  4422. $(".uploadTask").each(function(){
  4423. if ($(this).attr("taskID") == taskUUID){
  4424. //Update this progress bar
  4425. $(this).find(".bar").css("width",progress + "%");
  4426. if (progress == 100){
  4427. //When progress = 100 and the server is not response with 200,
  4428. //That means the upload has finish and server is processing the upload
  4429. $(this).find(".progress").addClass("indeterminate");
  4430. }
  4431. }
  4432. });
  4433. })
  4434. xhr.addEventListener('readystatechange', function(e) {
  4435. if (xhr.readyState == 4 && xhr.status == 200) {
  4436. //Upload process ended
  4437. //Update task status
  4438. $(".uploadTask").each(function(){
  4439. if ($(this).attr("taskID") == taskUUID){
  4440. //Update this progress bar to completed
  4441. $(this).find(".bar").css("width","100%");
  4442. $(this).find(".progress").attr("class","ts tiny positive progress");
  4443. $(this).find(".uploadTaskRemoveIcon").show();
  4444. $(this).addClass("ended");
  4445. //Update 15-11-2020
  4446. //Remove this taskbar after 3 secounds to prevent lags during > 2000 uploads
  4447. $.when($(this).delay(1000).fadeOut("fast")).then(function(){
  4448. $(this).remove();
  4449. updateUploadFileCount();
  4450. });
  4451. }
  4452. });
  4453. var resp = JSON.parse(e.target.response);
  4454. if (resp.error !== undefined){
  4455. msgbox("caution",resp.error);
  4456. //Something went wrong. Set the color to red
  4457. $(".uploadTask").each(function(){
  4458. if ($(this).attr("taskID") == taskUUID){
  4459. //Update this progress bar to completed
  4460. $(this).find(".bar").css("width","100%");
  4461. $(this).find(".progress").attr("class","ts tiny negative progress");
  4462. $(this).find(".uploadTaskRemoveIcon").show();
  4463. $(this).addClass("ended");
  4464. }
  4465. });
  4466. }
  4467. uploadingFileCount--;
  4468. //After the previous file has uploaded / errored, check if there are another file needed to be uploaded
  4469. setTimeout(function(){
  4470. if (uploadPendingList.length > 0){
  4471. let nextFile = uploadPendingList.shift();
  4472. uploadFile(nextFile.File, nextFile.UUID, nextFile.TargetDir);
  4473. }
  4474. }, 100)
  4475. }else if (xhr.readyState == 4 && xhr.status != 200) {
  4476. msgbox("remove",applocale.getString( "message/uploadFailed", "File too big or the target disk is fulled"));
  4477. console.log(xhr);
  4478. $(".uploadTask").each(function(){
  4479. if ($(this).attr("taskID") == taskUUID){
  4480. //Upload screwed up. Show negative
  4481. $(this).find(".progress").attr("class","ts tiny negative progress");
  4482. $(this).find(".uploadTaskRemoveIcon").show();
  4483. $(this).addClass("ended");
  4484. }
  4485. });
  4486. uploadingFileCount--;
  4487. //After the previous file has uploaded / errored, check if there are another file needed to be uploaded
  4488. setTimeout(function(){
  4489. if (uploadPendingList.length > 0){
  4490. let nextFile = uploadPendingList.shift();
  4491. uploadFile(nextFile.File, nextFile.UUID, nextFile.TargetDir);
  4492. }
  4493. }, 100)
  4494. }
  4495. updateUploadFileCount();
  4496. })
  4497. xhr.send(formData);
  4498. uploadingFileCount++;
  4499. updateUploadFileCount();
  4500. }
  4501. }
  4502. //Clear all finished upload tasks
  4503. function clearAllUploadTask(){
  4504. $(".uploadTask.ended").slideUp('300',function(){
  4505. $(this).remove();
  4506. updateUploadFileCount();
  4507. });
  4508. }
  4509. function toggleSearch(){
  4510. //Start search mode
  4511. $(".searchbar").slideDown("fast", function(){
  4512. initWindowSizes(true);
  4513. });
  4514. $("#searhbtn").addClass("disabled");
  4515. //Force videmode to list
  4516. viewMode = "list"
  4517. $(".videmode.button").each(function(){
  4518. $(this).addClass('disabled');
  4519. });
  4520. searchMode = true;
  4521. //Adjust the css for mobile interface
  4522. if (isMobile){
  4523. $("#searchInput").parent().parent().css("width", window.innerWidth - 135 + "px");
  4524. }
  4525. //Clear current folderlist
  4526. $("#folderList").show();
  4527. $("#folderList").html(`<div class="ts basic segment ${currentTheme}">
  4528. <div class="ts header">
  4529. <i class="arrow up icon ${currentTheme}"></i> <span class="${currentTheme}">${applocale.getString("func/search/typeToStart", "Type to Start Search")}</span>
  4530. <div class="sub header ${currentTheme}" style="margin-top:12px;">${applocale.getString("func/search/tip1", "Type something in the search bar to start searching.")}<br>
  4531. ${applocale.getString("func/search/tip2", `Start wildcard matching with "/" (slash) and your wildcard string (e.g. /*.mp3)`)}</div>
  4532. </div>
  4533. </div>`);
  4534. $("#fileList").hide();
  4535. }
  4536. function hideSearchBar(skipFilelistRefresh = false){
  4537. $(".searchbar").slideUp("fast", function(){
  4538. initWindowSizes(true);
  4539. });
  4540. $("#searchInput").val("");
  4541. $("#searhbtn").removeClass("disabled");
  4542. $(".videmode.button").each(function(){
  4543. if ($(this).attr("mode") != "list"){
  4544. $(this).removeClass('disabled');
  4545. }
  4546. });
  4547. if (skipFilelistRefresh == false){
  4548. listDirectory(currentPath);
  4549. }
  4550. searchMode = false;
  4551. }
  4552. //Handle case sensitive in keyword searching
  4553. function toggleCaseSensitive(btn){
  4554. if ($(btn).hasClass("active")){
  4555. $(btn).removeClass("active");
  4556. searchCaseSensitive = false;
  4557. }else{
  4558. $(btn).addClass("active");
  4559. searchCaseSensitive = true;
  4560. }
  4561. }
  4562. function exitHotSearch(){
  4563. hotSearchBuffer = "";
  4564. hotSearchTimer = null;
  4565. //Move the file to "selected" mode
  4566. $(".hotSearchHighlight").addClass("selected");
  4567. $(".hotSearchHighlight").removeClass("hotSearchHighlight");
  4568. }
  4569. function handleHotSearch(starting, offset){
  4570. if (offset < 0){
  4571. offset = 0;
  4572. }
  4573. starting = starting.toLowerCase();
  4574. console.log(starting);
  4575. $(".hotSearchHighlight").removeClass("hotSearchHighlight");
  4576. let files = $(".fileObject");
  4577. let matchingFiles = [];
  4578. for (var i = 0; i < files.length; i++){
  4579. let thisFile = files[i];
  4580. if ($(thisFile).attr("filename") != undefined && $(thisFile).attr("filename").length > starting.length && $(thisFile).attr("filename").substr(0, starting.length).toLowerCase() == starting){
  4581. matchingFiles.push(thisFile);
  4582. }
  4583. }
  4584. //Loopback if offset overflow
  4585. let newOffset = offset;
  4586. if (offset > matchingFiles.length - 1){
  4587. newOffset =offset % matchingFiles.length;
  4588. }
  4589. var targetHighlightingFile = matchingFiles[newOffset];
  4590. $(targetHighlightingFile).addClass("hotSearchHighlight");
  4591. scrollToFileLocation($(targetHighlightingFile));
  4592. return;
  4593. }
  4594. function handleSearch(){
  4595. var keyword = $("#searchInput").val();
  4596. $("#folderList").html(`<div class="ts basic segment ${currentTheme}">
  4597. <i class="loading spinner icon ${currentTheme}"></i> <span class="${currentTheme}">Searching</span>
  4598. </div>`);
  4599. $("#fileList").hide();
  4600. $("#fileList").html("");
  4601. $.ajax({
  4602. url: "../../system/file_system/search",
  4603. data: {path: currentPath, keyword: keyword, casesensitive: searchCaseSensitive},
  4604. success: function(data){
  4605. if (data.error !== undefined){
  4606. msgbox("remove", applocale.getString("message/" + data.error, data.error));
  4607. hideSearchBar();
  4608. }else{
  4609. //Render the filelist
  4610. console.log(data);
  4611. if (data.length == 0){
  4612. $("#folderList").show();
  4613. $("#folderList").html(`<div class="ts basic segment ${currentTheme}">
  4614. <div class="ts header ${currentTheme}">
  4615. <i class="question icon" ${currentTheme}></i> <span class="${currentTheme}">${applocale.getString("message/noMatchResults","No Matching Results")}</span>
  4616. <div class="sub header ${currentTheme}">${applocale.getString("message/noMatchResultsDesc","The host return no matching results for your keyword")} "${keyword}". <br>${applocale.getString("message/noMatchResultsInst","Check your spelling and your wildcard characters.")}</div>
  4617. </div>
  4618. </div>`);
  4619. }else{
  4620. renderDirectory(data);
  4621. }
  4622. }
  4623. }, error: function(){
  4624. $("#folderList").html(`<div class="ts basic segment">
  4625. <div class="ts header">
  4626. <i class="remove icon"></i> Search Error
  4627. <div class="sub header">Search timeout</div>
  4628. </div>
  4629. </div>`);
  4630. }
  4631. })
  4632. }
  4633. function handleSearchBarPress(e){
  4634. if (e.keyCode == 13 || e.key == "Enter"){
  4635. e.preventDefault();
  4636. handleSearch();
  4637. }
  4638. }
  4639. function toggleCtrl(){
  4640. ctrlHold = !ctrlHold;
  4641. updateCtrlDisplay();
  4642. }
  4643. function updateCtrlDisplay(){
  4644. if (isMobile){
  4645. //Change color of the navibar based on selection mode
  4646. if (ctrlHold){
  4647. $("#navibar").css("border-bottom","2px solid #6c06ba");
  4648. }else{
  4649. $("#navibar").css("border-bottom","2px solid #34b7eb");
  4650. }
  4651. }
  4652. }
  4653. function getUploadTaskByID(taskUUID){
  4654. var task = undefined;
  4655. $("#uploadTab").find(".uploadTask").each(function(){
  4656. if ($(this).attr("taskid") == taskUUID){
  4657. task = $(this);
  4658. }
  4659. });
  4660. return task;
  4661. }
  4662. function appendUploadFileItem(filename, filesize){
  4663. var newuuid = uuidv4();
  4664. var humanReadableFilesize = 0;
  4665. if (filesize < 0){
  4666. humanReadableFilesize = applocale.getString("message/unknownSize", "Unknown Size")
  4667. }else{
  4668. humanReadableFilesize = bytesToSize(filesize);
  4669. }
  4670. $("#uploadProgressList").append(`<div class="uploadTask" taskID="${newuuid}">
  4671. <p style="width: calc(100% - 15px);">${filename} (${humanReadableFilesize})</p>
  4672. <div class="ts tiny primary progress" style="margin-top:-12px;">
  4673. <div class="bar" style="width: 0%"></div>
  4674. </div>
  4675. <div class="uploadTaskRemoveIcon" onclick="removeThisTask(this);" style="display:none;">
  4676. <i class="remove icon"></i>
  4677. </div>
  4678. </div>`);
  4679. return newuuid;
  4680. }
  4681. function removeThisTask(object){
  4682. $(object).parent().fadeOut('fast',
  4683. function(){
  4684. $(this).remove();
  4685. updateUploadFileCount();
  4686. }
  4687. );
  4688. }
  4689. function toggleUploadList(){
  4690. $("#uploadProgressList").toggle();
  4691. if ($("#uploadProgressList").is(":visible")){
  4692. $("#hideUploadButton").html('<i class="caret down icon"></i>');
  4693. }else{
  4694. $("#hideUploadButton").html('<i class="caret up icon"></i>');
  4695. }
  4696. }
  4697. function updateUploadFileCount(){
  4698. $("#uploadCount").text(uploadingFileCount);
  4699. $("#waitingCount").text(uploadPendingList.length);
  4700. if (uploadingFileCount == 0 && $(".uploadTask").length == 0){
  4701. $("#uploadTab").hide();
  4702. }else{
  4703. $("#uploadTab").show();
  4704. }
  4705. }
  4706. function bytesToSize(bytes) {
  4707. var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'];
  4708. if (bytes == 0) return '0 Byte';
  4709. var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
  4710. return Math.round(bytes / Math.pow(1024, i) * 100, 2) / 100 + ' ' + sizes[i];
  4711. }
  4712. function uuidv4() {
  4713. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  4714. var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
  4715. return v.toString(16);
  4716. });
  4717. }
  4718. function dropToFolder(event){
  4719. event.preventDefault();
  4720. event.stopImmediatePropagation();
  4721. console.log("Drop to folder detected");
  4722. //Extract target folder path from object
  4723. var targetPath = $(event.target).attr("filepath");
  4724. if (targetPath == ""){
  4725. return
  4726. }
  4727. //Check if this is upload or file move drag
  4728. var files = event.dataTransfer.files;
  4729. if (files.length > 0){
  4730. //Upload mode. Extract the target folder basename from path
  4731. if (targetPath.substr(targetPath.length -1,1) == "/"){
  4732. targetPath = targetPath.substr(0, targetPath.length-1);
  4733. }
  4734. var folderBase = targetPath.split("/").pop() + "/";
  4735. var items = event.dataTransfer.items;
  4736. for (let i=0; i<items.length; i++) {
  4737. let item = items[i].webkitGetAsEntry();
  4738. if (item) {
  4739. recursiveScanFilesUpload(item, folderBase, folderBase);
  4740. }
  4741. }
  4742. }else if (event.dataTransfer.getData("filedata") != ""){
  4743. var targetVroot = targetPath.split(":/").shift();
  4744. //Get the source files
  4745. var filelist = JSON.parse(event.dataTransfer.getData("filedata"));
  4746. if (filelist.length > 0){
  4747. var srcVroot = filelist[0].filepath.split(":/").shift();
  4748. if (srcVroot == targetVroot){
  4749. //Use move mode
  4750. cutMode = true;
  4751. }else{
  4752. //Use copy mode
  4753. cutMode = false;
  4754. }
  4755. //Parse the filelist
  4756. clipboard = [];
  4757. filelist.forEach(file=>{
  4758. clipboard.push(file.filepath);
  4759. });
  4760. if (useLocalstorage){
  4761. localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
  4762. localStorage.setItem("ao/file_system/cutmode","true");
  4763. }
  4764. //Perform operations
  4765. paste(targetPath, false)
  4766. }
  4767. }
  4768. }
  4769. function allowDrop(event){
  4770. event.preventDefault();
  4771. }
  4772. $(".popupWrapper").on("click",function(){
  4773. hideAllPopupWindows();
  4774. });
  4775. function hideAllPopupWindows(){
  4776. $(".popup").fadeOut(100);
  4777. $(".popupWrapper").fadeOut(100);
  4778. $('body').css("overflow","");
  4779. if($("#shareFile").is(":visible")){
  4780. $("#shareFileEmbedded").attr("src", "");
  4781. }
  4782. }
  4783. function showPopupWrapper(){
  4784. $(".popupWrapper").fadeIn('fast');
  4785. $('body').css("overflow","hidden");
  4786. }
  4787. //Handle keydown of enter on certain input boxes
  4788. function handleEnterKeyDown(event, handler){
  4789. if (event.which == 13){
  4790. handler();
  4791. }
  4792. }
  4793. //Generate a download link and press it
  4794. function generateDownloadFromURL(url, filename){
  4795. let a = document.createElement('a')
  4796. a.href = url;
  4797. a.download = filename;
  4798. document.body.appendChild(a)
  4799. a.click()
  4800. document.body.removeChild(a)
  4801. }
  4802. //Update sorting method for file listing
  4803. function updateSortingMethods(){
  4804. var method = $("#sortingMethodSelector").val();
  4805. sortMode = method;
  4806. //Save it to server side
  4807. $.ajax({
  4808. url: "../../system/file_system/sortMode",
  4809. method: "POST",
  4810. data: {opr: "set", folder: currentPath, mode: sortMode},
  4811. success: function(data){
  4812. //console.log("Sort mode saved: " + data)
  4813. refreshList();
  4814. }
  4815. });
  4816. }
  4817. function requestCSRFToken(callback){
  4818. $.ajax({
  4819. url: "../../system/csrf/new",
  4820. success: function(token){
  4821. callback(token);
  4822. }
  4823. })
  4824. }
  4825. </script>
  4826. </body>
  4827. </html>