1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855 |
- <html>
- <head>
- <title>File Manager</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
- <link rel="stylesheet" href="../../script/tocas/tocas.css">
- <link rel="icon" type="image/png" href="./img/small_icon.png">
- <link rel="manifest" crossorigin="use-credentials" href="manifest.json">
- <script type="text/javascript" src="../../script/tocas/tocas.js"></script>
- <script type="text/javascript" src="../../script/jquery.min.js"></script>
- <script type="text/javascript" src="../../script/ao_module.js"></script>
- <script type="text/javascript" src="../../script/forge-sha256.min.js"></script>
- <script type="text/javascript" src="../../script/qrcode.min.js"></script>
- <script>
- window.mobilecheck = function() {
- var check = false;
- (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);
- return check;
- };
- </script>
- <style>
- body{
- color:black;
- height:100%;
- }
- @font-face {
- font-family: 'TaipeiSansTCBeta-Regular';
- src: url('../../script/font/TaipeiSansTCBeta-Regular.ttf');
- }
- h1, h2, h3, p, span, div,span { font-family: 'TaipeiSansTCBeta-Regular',"Lucida Console", "Courier New", monospace;}
- html{
- height:100%;
- overflow:hidden;
- }
- body.whiteTheme{
- background-color:rgb(250, 250, 250);
- }
- .darkTheme{
- background-color:#242330 !important;
- color:white;
- }
- .whiteTheme{
- color:#0d0d0d
- }
- .navibar{
- position:fixed;
- width:100%;
- padding-left:12px;
- padding-right:12px;
- padding-top:6px;
- padding-bottom:3px;
- z-index: 99;
- }
- .navibar.darkTheme{
- background-color:#17161f !important;
- border-bottom:2px solid #34b7eb;
- }
- .navibar.whiteTheme{
- /*box-shadow: 0 2px 4px 2px rgb(224, 224, 224);*/
- background-color:#fcfcfc;
- border-bottom:2px solid #34b7eb;
- }
- .whiteTheme .button.standard{
- box-shadow: 0 1px 1px 0px rgb(190, 190, 190);
- border: 0px;
- }
- .whiteTheme .button.standard:hover{
- background-color:#82c2f0 !important;
- color:white !important;
- }
- .ts.button{
- margin-bottom:2px;
- }
- .ts.button.darkTheme{
- background-color:#17161f !important;
- border: 1px solid #262533;
- color:white;
- }
- .ts.button.active.darkTheme{
- background-color:#312f42 !important;
- border: 1px solid #262533;
- color:white;
- }
- .ts.button.darkTheme:hover{
- background-color:#312f42 !important;
- color:white !important;
- }
- .rightPad{
- margin-right:40px;
- }
- .addressBar{
- width:100%;
- padding:3px;
- min-height: 35px;
- padding-top:6px;
- }
- .breadcrumb.darkTheme{
- background-color:transparent;
- }
- .section.darkTheme{
- color:white !important;
- background-color:transparent;
- }
- .selectable{
- cursor:pointer;
- }
- .rightAlign{
- position:absolute;
- right:0px;
- top:3px;
- }
- .addressText{
- padding:5px;
- border-radius: 3px;
- }
- .addressText.darkTheme{
- border: 1px solid #262533;
- }
- .addressText.whiteTheme{
- border: 1px solid #cfcfcf;
- }
- .divider.whiteTheme{
- color:#262533 !important;
- background-color:transparent;
- }
- .divider.darkTheme{
- background-color:transparent;
- color: white !important;
- }
- #directorySidebar{
- padding:12px;
- overflow-y:auto;
- padding-bottom:20px;
- }
- #directorySidebar.darkTheme{
- border-right:2px solid rgb(25, 24, 31);
- color:white;
- position:absolute;
- }
- #directorySidebar.whiteTheme{
- border-right:2px solid rgba(219, 226, 241, 0.7);
- background-color:#f5f5f5;
- color:rgb(44, 44, 44);
- position:absolute;
- }
- #folderView{
- position:absolute;
- padding-left:2em;
- padding-right:2em;
- padding-top:2em;
- overflow-y:auto;
- }
- #folderView.whiteTheme{
- background-color:white;
- }
- .item.darkTheme{
- color:white;
- }
- .rightmargin.icon{
- margin-right:8px !important;
- }
- .dir{
- cursor:pointer;
- }
- .dir:hover{
- color:#d1d1d1 !important;
- }
- .dir.item.whiteTheme{
- color:rgb(78, 78, 78);
- }
- .device{
- cursor:pointer;
- }
- .device:hover{
- color:#d1d1d1;
- }
- .accordion.darkTheme{
- color:white !important;
- }
- .accordion.whiteTheme{
- background-color:transparent !important;
- }
- .fileObject{
- display:block !important;
- cursor:pointer;
- overflow-wrap: break-word !important;
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- }
- .fileObject.darkTheme{
- border:1px solid rgb(72, 69, 88) !important;
- }
- .segmented.list.darkTheme{
- border:1px solid rgb(8, 8, 10) !important;
- box-shadow: 0 0 0 0;
- border-radius: 0px;
- }
- .fileObject.darkTheme:hover{
- background-color:#17161f !important;
- }
- .fileObject.darkTheme:hover span{
- background-color:#17161f !important;
- }
- .fileObject.whiteTheme:hover{
- background-color:#f2f2f2 !important;
- }
- .fileObject.darkTheme.selected{
- background-color:#100f16 !important;
-
- }
- .fileObject.darkTheme.selected span{
- background-color:#100f16 !important;
-
- }
- .fileObject.whiteTheme.selected{
- background-color:#d2f2f7 !important;
- color:black !important;
- }
- .mobilePathDisplayWrapper{
- width:100%;
- margin-bottom:5px;
- }
- .ts.card.darkTheme{
- border:1px solid rgb(72, 69, 88) !important;
- box-shadow: 0 0 0 0 transparent;
- }
- .darkTheme.header{
- color:white !important;
- background-color:transparent !important;
- }
- .darkTheme.meta{
- color:rgba(255, 255, 255, 0.836) !important;
- background-color:transparent !important;
- }
- .darkTheme.description{
- color:white !important;
- background-color:transparent !important;
- }
- .whiteTheme.header{
- background-color:transparent;
- }
- .whiteTheme.meta{
- background-color:transparent;
- }
- .whiteTheme.description{
- background-color:transparent;
- }
- #folderList{
- margin-bottom:16px;
- }
- .msgbox{
- padding:3px;
- }
- .closeMsgButton{
- position:absolute;
- top:8px;
- right:12px;
- }
- .closeMsgButton{
- cursor:pointer;
- }
- .popup{
- position:fixed;
- top:30px;
- z-index:110;
- left:34%;
- right:34%;
- bottom:30px;
- padding-bottom:24px;
- border: 0px solid transparent !important;
- }
- .popup.wide{
- left:24%;
- right:24%;
- }
- .popup.darkTheme{
- -webkit-box-shadow: 3px 4px 5px 0px rgb(35, 33, 46) ;
- -moz-box-shadow: 3px 4px 5px 0px rgb(35, 33, 46);
- box-shadow: 3px 4px 5px 0px rgb(35, 33, 46) ;
- border: 1px solid rgb(22, 21, 29);
- }
- .popup.whiteTheme{
- -webkit-box-shadow: 3px 4px 5px 0px rgba(138,138,138,1);
- -moz-box-shadow: 3px 4px 5px 0px rgba(138,138,138,1);
- box-shadow: 3px 4px 5px 0px rgba(138,138,138,1);
- border: 1px solid rgb(226, 226, 226);
- background-color:white;
- }
- @media only screen and (max-width: 1920px) {
- .popup{
- left:35em;
- right:35em;
- }
- .popup.wide{
- left:20em;
- right:20em;
- }
- }
- @media only screen and (max-width: 1500px) {
- .popup{
- left:20em;
- right:20em;
- }
- .popup.wide{
- left:14em;
- right:14em;
- }
- }
-
-
- @media only screen and (max-width: 1200px) {
- .popup{
- left:14em;
- right:14em;
- }
- .popup.wide{
- left:5em;
- right:5em;
- }
- }
- @media only screen and (max-width: 800px) {
- .popup{
- left:5em;
- right:5em;
- }
- .popup.wide{
- left:2em;
- right:2em;
- }
- }
- @media only screen and (max-width: 600px) {
- .popup{
- position:fixed;
- top:5%;
- z-index:100;
- left:1em;
- right:1em;
- }
- }
- .popupheader{
- width:100%;
- padding:3px;
- padding-left:12px;
- border-bottom:2px solid #34b7eb;
- background-color: #171719;
- color: white;
- height:29px;
- }
- .popupcontent{
- height: calc(100% - 29px);
- overflow:auto;
- }
- /*
- .popupheader.whiteTheme{
- background-color:#eee;
- color: #232322;
- }
- .popupheader.darkTheme{
- background-color:#111017 !important;
- color: white;
- }
- */
- .popupcloser{
- position:absolute;
- top:5px;
- right:0px;
- font-size: 120%;
- cursor:pointer;
- }
- .popupbuttons{
- cursor:pointer;
- padding:5px;
- padding-left:12px;
- margin-bottom:4px;
- border: 1px solid #dedede;
- border-radius: 4px;
- }
- .popupbuttons.primary.whiteTheme{
- background-color:#51aded;
- box-shadow: 0 2px 1px 0px #34a2ee !important;
- border: 1px solid transparent;
- color:white;
- }
- .popupbuttons.negative{
- background-color:#ed5151;
- box-shadow: 0 2px 1px 0px #ee3434 !important;
- border: 1px solid transparent;
- color:white;
- }
- .popupbuttons.primary.darkTheme{
- background-color:#413f57 !important;
- box-shadow: 0 2px 1px 0px #3c3b50 !important;
- border: 1px solid transparent;
- color:white;
- }
- .popupbuttons.negative.darkTheme{
- background-color:#ed5151 !important;
- }
- .popupbuttons.disabled{
- opacity: 0.4;
- pointer-events: none;
- }
- .popupbuttons.primary.disabled{
- opacity: 0.4;
- pointer-events: none;
- }
- .whiteTheme.allowHover:hover{
- background-color:rgba(238, 238, 238, 0.932);
- }
- .whiteTheme.allowHover.primary:hover{
- background-color:#76c0f5;
- }
- .allowHover.negative:hover{
- background-color:#f57676;
- }
- .allowHover.negative.darkTheme:hover{
- background-color:#f57676 !important;
- }
- .darkTheme.allowHover:hover{
- background-color:#111017 !important;
- }
- .ts.list.darkTheme{
- background-color:#464457 !important;
- }
- input.darkTheme{
- color:white !important;
- }
- .ts.segmented.list.darkTheme .item{
- color:white !important;
- }
- .newFileFormat{
- cursor:pointer;
- }
-
- .popupWrapper{
- position:fixed;
- top:0px;
- left:0px;
- width:100%;
- height:100%;
- z-index:99;
- background-color:rgba(27,27,27,0.5);
- display:none;
- }
- @supports (backdrop-filter: none) {
- .popupWrapper {
- backdrop-filter: blur(5px);
- }
- }
- .breadcrumb.whiteTheme{
- background-color:white;
- }
- #openWithModuleList{
- height:250px;
- overflow-y:auto;
- }
- #openWith .segment.darkTheme{
- color:white !important;
- }
- #openWithModuleList .item{
- padding:8px;
- padding-left:22px;
- border-radius: 2px;
- display: flex;
- flex-wrap: wrap;
- }
- #openWithModuleList.darkTheme .item.selected{
- background-color:#100f16 !important;
- }
- #openWithModuleList.whiteTheme .item.selected{
- background-color:#51aded !important;
- color:white;
- }
-
- #openWithModuleList.darkTheme .item.selectable:hover{
- background-color:rgba(250,250,250,0.05);
- }
- #openWithModuleList.whiteTheme .item.selectable:hover{
- background-color:rgba(35,35,35,0.14);
- }
- .contextmenu.darkTheme .item{
- color:white !important;
- }
- .contextmenu .item{
- font-size:90% !important;
- }
- #uploadTab{
- position:fixed;
- right:0px;
- bottom: 0px;
- width:300px;
- margin-bottom:0px !important;
- padding:0px !important;
- }
- #uploadTab.darkTheme{
- color:white;
- background-color:rgba(35,35,35,0.14);
- border: 1px solid #17161f !important;
- box-shadow: 0px 0px 0px 0px rgba(0,0,0,0.75);
- }
- .statusBar{
- height:32px;
- background-color:#f5f5f5;
- padding:8px;
- }
- .statusBar.whiteTheme{
- color:rgb(78, 78, 78);
- }
- .statusBar.darkTheme{
- background-color:#181720 !important;
- }
- .hideUploadButton{
- float: right;
- cursor:pointer;
- }
- .uploadList{
- margin:8px;
- padding-bottom:3px;
- margin-bottom:0px;
- max-height: 250px;
- overflow-y:auto;
- }
- .uploadTask{
- margin-top:6px;
- }
- .uploadTaskRemoveIcon{
- position:absolute;
- top:0px;
- right:0px;
- cursor:pointer;
- }
- .clearallButton{
- padding:8px;
- cursor:pointer;
- }
- .normal.object.whiteTheme{
- color:#303030;
- }
- .normal.object.darkTheme{
- color:white;
- }
- .sub.header.darkTheme{
- color:rgb(190, 190, 190) !important;
- }
- .hex.foldername{
- color:#2b9447 !important;
- }
- .um.filename{
- color: #69aaff !important;
- }
- .dropdown.inverted{
- background-color: #17161f !important;
- }
- .sharebtn{
- cursor: pointer;
- }
- .sharebtn.darkTheme {
- color: white !important;
- background-color: transparent !important;
- }
- .sharebtn.whiteTheme:hover{
- opacity: 0.5;
- }
- .sharebtn.darkTheme:hover{
- opacity: 0.5;
- }
- </style>
- </head>
- <body class="whiteTheme">
- <div id="navibar" class="navibar whiteTheme">
- <!-- Directoy navigations -->
- <button id="backbtn" class="ts icon tiny button standard whiteTheme" onclick="previosPath();" title="Back"><i class="left arrow icon"></i></button>
- <button id="ppbtn" class="ts icon tiny button standard whiteTheme rightPad" onclick="parentDir();" title="Parent Folder"><i class="up arrow icon"></i></button>
-
- <!-- File Read Operations -->
- <button class="ts icon tiny button standard whiteTheme" title="Open" onclick="openViaButton();"><i class="folder open icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="Open with" onclick="openWith();"><i class="external icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme singleObjectOnly" title="Share File" onclick="shareFile();"><i class="share alternate icon"></i></button>
- <button class="ts labeled icon tiny button standard whiteTheme" style="width:154px;" title="Download" onclick="downloadFile();">
- <i class="download icon"></i>
- Download
- </button>
- <!-- File Edit Operations -->
- <button class="ts icon tiny button standard whiteTheme" title="Copy" onclick="copy();"><i class="copy icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="Paste" onclick="paste();"><i class="paste icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="Cut" onclick="cut();"><i class="cut icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="New File" onclick="newfile();"><i class="file outline icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="New Folder" onclick="newFolder();"><i class="folder outline icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="Upload" onclick="upload();"><i class="upload icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="Create Zip" onclick="zipFile();"><i class="zip file icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="Rename" onclick="rename();"><i class="i cursor icon"></i></button>
- <button class="ts icon tiny negative button" title="Delete" onclick="deleteFile();"><i class="trash outline icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="Refresh" onclick="refreshList();"><i class="refresh icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="File Info" onclick="showFileProperties();"><i class="notice icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="Help"><i class="help icon"></i></button>
-
- <div class="addressBar">
- <button class="ts icon tiny button standard whiteTheme" onclick="toggleSidebar();" title="Toggle Folder List"><i class="content icon"></i></button>
- <button class="ts icon tiny button inverted" title="Dark Theme" onclick="toggleDarkTheme();"><i class="moon icon" id="darkthemebtn"></i></button>
- <div class="ts breadcrumb whiteTheme addressText pathDisplay desktopOnly">
- <div class="section whiteTheme selectable"><i class="folder icon"></i> user</div>
- <div class="divider whiteTheme">:/</div>
- <div class="section whiteTheme selectable">Desktop</div>
- </div>
- <div class="rightAlign">
- <select id="sortingMethodSelector" title="Sorting Method" class="ts basic borderless mini dropdown" onchange="updateSortingMethods();" autocomplete="off">
- <option value="default">Ascending</option>
- <option value="reverse">Descending</option>
- <option value="smallToLarge">Smallest</option>
- <option value="largeToSmall"> Largest</option>
- <option value="mostRecent">Most Recent</option>
- <option value="leastRecent">Least Recent</option>
- </select>
- <button id="searhbtn" class="ts icon tiny button standard whiteTheme" title="Search" onclick="toggleSearch();"><i class="search icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme videmode" mode="grid" title="Block View" onclick="changeViewMode(this);"><i class="block layout icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme videmode" mode="list" title="List View" onclick="changeViewMode(this);"><i class="align justify icon"></i></button>
- </div>
- </div>
- <div class="mobilePathDisplayWrapper">
- <div style="width:100%;" class="ts pathDisplay breadcrumb whiteTheme addressText mobileOnly">
- <div class="section whiteTheme selectable"><i class="folder icon"></i> user</div>
- <div class="divider whiteTheme">:/</div>
- <div class="section whiteTheme selectable">Desktop</div>
- </div>
- </div>
- <div class="searchbar" style="z-index:999; display:none;">
- <div style="width: 80%; display:inline-block; margin-top:-4px;">
- <div class="ts mini fluid input">
- <input autocomplete="off" id="searchInput" type="text" class="whiteTheme" placeholder="File Search (Start wildcard search with / , e.g. /*.mp3)" onkeypress="handleSearchBarPress(event);">
- </div>
- </div>
- <button class="ts icon tiny button standard whiteTheme" title="Case Sensitive" onclick="toggleCaseSensitive(this);">Aa</button>
- <button class="ts icon tiny button standard whiteTheme" title="Search" onclick="handleSearch();"><i class="search icon"></i></button>
- <button class="ts icon tiny button standard whiteTheme" title="Clear Search" onclick="hideSearchBar();"><i class="remove icon"></i></button>
- </div>
- <div class="msgbox" style="z-index:999; display:none;">
- <i class="checkmark icon"></i> <span>No Message</span>
- <div class="closeMsgButton" onclick="$(this).parent().slideUp('fast');"><i class="remove icon"></i></div>
- </div>
- </div>
-
- <div id="mainWindow">
- <div id="directorySidebar" class="whiteTheme">
- <div class="ts list">
- <details class="ts accordion fluid whiteTheme" open>
- <summary>
- <i class="dropdown icon"></i> User
- </summary>
- <div id="userroot" class="ts list" style="padding-top:0px !important;">
- <div class="dir item whiteTheme"><i class="loading circle notched rightmargin icon"></i> Initiating</div>
- </div>
- </details>
- <details class="ts accordion fluid whiteTheme" open>
- <summary>
- <i class="dropdown icon"></i> Storage
- </summary>
- <div id="storageroot" class="ts list" style="padding-top:0px !important;">
- <div class="dir item whiteTheme"><i class="loading circle notched rightmargin icon"></i> Initiating</div>
- </div>
- </details>
- <!--
- <details class="ts accordion fluid whiteTheme" open>
- <summary>
- <i class="caret down icon"></i>Disks
- </summary>
- <div id="deviceList" class="ts list" style="padding-top:0px !important;">
- <div class="dir item whiteTheme"><i class="loading circle notched rightmargin icon"></i> Initiating</div>
- </div>
- </details>
- -->
- <!-- >
- <div class="item fluid whiteTheme">
- <i class="world icon"></i>Network
- </div>
- -->
- <br>
- </div>
- </div>
- <div id="folderView" class="whiteTheme" ondrop="drop(event)" ondragover="allowDrop(event)">
- <div id="folderList">
- </div>
- <div id="fileList">
- </div>
- <br>
- </div>
- </div>
- <!-- Other popup windows -->
- <div class="popupWrapper"></div>
- <!-- Overwrite Selection Box-->
- <div id="overwriteModeSelection" class="popup whiteTheme" style="display:none;">
- <div class="popupheader whiteTheme">
- <i class="paste icon"></i> Replace, Keep or Skip Files
- <div class="popupcloser" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i>
- </div>
- </div>
- <div class="popupcontent" style="padding:12px;">
- <small style="font-size:80%;">Copying <span class="owm-fc"></span> files from <span class="owm-srcdir"></span> to <span class="owm-destdir"></span>.</small>
- <p>The destination has <span class="owm-fc"></span> files with the same names.</p>
- <div class="popupbuttons whiteTheme allowHover primary" onclick="changeOverwriteRule(0,true);">
- <i class="checkmark icon"></i> Replace the files in the destination
- </div>
- <div class="popupbuttons whiteTheme allowHover" onclick="changeOverwriteRule(1,true);">
- <i class="reply icon"></i> Skip these files
- </div>
- <div class="popupbuttons whiteTheme allowHover" onclick="changeOverwriteRule(2,true);">
- <i class="undo icon"></i> Rename and keep the files
- </div>
- </div>
- </div>
- <!-- Force delete confirmation box -->
- <div id="forceDeleteConfirmBox" class="popup whiteTheme" style="display:none;">
- <div class="popupheader whiteTheme">
- <i class="trash icon"></i> Permanently Remove Files
- <div class="popupcloser" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i>
- </div>
- </div>
- <div class="popupcontent" style="padding:12px;">
- <p>Are you sure you want to remove these files <u>permanently?</u><br>This action is <u>irreversible</u>.</p>
- <div class="ts list whiteTheme deleteFilelist" style="max-height:350px;overflow-y:auto; ">
- </div>
- <div class="popupbuttons whiteTheme allowHover" style="background-color: #eb4034 !important;" onclick="forceDelete(true);";>
- <i class="trash icon"></i> Confirm
- </div>
- <div class="popupbuttons whiteTheme allowHover" onclick="cancelForceDelete();hideAllPopupWindows();">
- <i class="remove icon"></i> Cancel
- </div>
- </div>
- </div>
- <!-- Delete confirm box -->
- <div id="deleteConfirmBox" class="popup whiteTheme" style="display:none;">
- <div class="popupheader whiteTheme">
- <i class="recycle icon"></i> Move files to Trash Bin
- <div class="popupcloser" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i>
- </div>
- </div>
- <div class="popupcontent" style="padding:12px;">
- <p>Are you sure you want to move these files to trash bin?</p>
- <div class="ts list whiteTheme deleteFilelist" style="max-height:350px;overflow-y:auto; ">
- </div>
- <div class="popupbuttons whiteTheme allowHover" style="color: #2bbbdf !important;" onclick="deleteFile(true);";>
- <i class="recycle icon"></i> Move to Trash
- </div>
- <div class="popupbuttons whiteTheme allowHover" onclick="cancelDelete();hideAllPopupWindows();">
- <i class="remove icon"></i> Cancel
- </div>
- </div>
- </div>
- <!-- Rename tool box -->
- <div id="renameBox" class="popup whiteTheme" style="display:none;">
- <div class="popupheader whiteTheme">
- <i class="text cursor icon"></i> Rename Files
- <div class="popupcloser" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i>
- </div>
- </div>
- <div class="popupcontent" style="padding:12px;">
- <p>Enter the new filename for renaming. </p>
- <p class="multifileWarning"><i class="notice icon"></i> Other files will be named as file(#)</p>
- <div class="ts left icon small fluid input" style="margin-bottom:12px;">
- <input type="text" class="whiteTheme orgfn" placeholder="Original Filename" readonly="true">
- <i class="minus square icon" style="color:rgb(122, 176, 247)"></i>
- </div>
- <div class="ts left icon small fluid input" style="margin-bottom:12px;">
- <input type="text" class="whiteTheme newfn" placeholder="New Filename" onkeydown="handleEnterKeyDown(event, function(){confirmRename(true);})">
- <i class="add square icon" style="color:rgb(122, 176, 247)"></i>
- </div>
- <div class="popupbuttons whiteTheme allowHover primary" onclick="confirmRename(true);";>
- <i class="checkmark icon"></i> OK
- </div>
- <div class="popupbuttons whiteTheme allowHover" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i> Cancel
- </div>
- </div>
- </div>
- <!-- New File Dialog-->
- <div id="newFile" class="popup whiteTheme" style="display:none;">
- <div class="popupheader whiteTheme">
- <i class="add icon"></i> New File
- <div class="popupcloser" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i>
- </div>
- </div>
- <div class="popupcontent" style="padding:12px;">
- <p>Please select a type of file to be created.</p>
- <div class="ts segmented list whiteTheme newfilelist" style="max-height:18em; overflow-y:scroll">
- <div class="item newFileFormat" ext="php">No Item</div>
- </div>
- <p>Or create an empty file with given filename:</p>
- <div class="ts left icon small fluid input" style="margin-bottom:12px;">
- <input id="createNewFileName" type="text" class="whiteTheme" placeholder="New Filename" onkeydown="handleEnterKeyDown(event, confirmNewFile);">
- <i class="add square icon" style="color:rgb(122, 176, 247)"></i>
- </div>
- <p class="duplicateWarning" style="color:#CE5F58; display:none;"><i class="caution sign icon"></i> The given filename already exist.</p>
- <div class="popupbuttons whiteTheme allowHover primary" onclick="confirmNewFile();";>
- <i class="add icon"></i> Create
- </div>
- <div class="popupbuttons whiteTheme allowHover" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i> Cancel
- </div>
- </div>
- </div>
- <!-- New Folder Dialog-->
- <div id="newFolder" class="popup whiteTheme" style="display:none;">
- <div class="popupheader whiteTheme">
- <i class="folder icon"></i> New Folder
- <div class="popupcloser" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i>
- </div>
- </div>
- <div class="popupcontent" style="padding:12px;">
- <p>Please enter the new folder name to be created.</p>
- <div class="ts left icon small fluid input" style="margin-bottom:12px;">
- <input id="createNewFolder" type="text" class="whiteTheme" placeholder="New Folder Name" onkeydown="handleEnterKeyDown(event, function(){newFolder(true);});">
- <i class="add square icon" style="color:rgb(122, 176, 247)"></i>
- </div>
- <p class="duplicateWarning" style="color:#CE5F58; display:none;"><i class="caution sign icon"></i> The given folder already exist.</p>
- <div class="popupbuttons whiteTheme allowHover primary" onclick="newFolder(true);";>
- <i class="add icon"></i> Create
- </div>
- <div class="popupbuttons whiteTheme allowHover" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i> Cancel
- </div>
- </div>
- </div>
- <!-- Share File Dialog-->
- <div id="shareFile" class="popup wide whiteTheme" style="display:none;">
- <div class="popupheader whiteTheme">
- <i class="external icon"></i> Share File
- <div class="popupcloser" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i>
- </div>
- </div>
- <div class="popupcontent" style="padding:12px;">
- <div class="ts stackable grid">
- <div class="eight wide column">
- <div class="width: 100%; ">
- <div style="display: block; margin-left: auto; margin-right: auto;" align="center">
- <div id="qrcode" style="border: 10px solid white; background-color: white;"></div>
- </div>
- <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>
- </div>
- </div>
- <div class="eight wide column" style="padding-left: 12px;">
- <div class="ts header whiteTheme">
- Share Settings
- <div class="sub header whiteTheme">Change who can see this file</div>
- </div>
- <div id="shareSettingForm" class="ts form">
- <div class="field">
- <label><p class="whiteTheme">Visable options:</p></label>
- <div class="ts checkboxes">
- <div class="ts radio checkbox">
- <input id="anyone" type="radio" class="shareoption" name="shareopt" value="anyone" checked="true">
- <label for="anyone">
- <div class="ts header">
- <div class="content whiteTheme">
- <i class="globe icon"></i> Anyone with the link
- <div class="sub header whiteTheme">Anyone who has the link can access this file</div>
- </div>
- </div>
- </label>
- </div>
- <div class="ts radio disabled checkbox">
- <input id="signedin" type="radio" class="shareoption" value="signedin" name="shareopt">
- <label for="signedin">
- <div class="ts header">
- <div class="content whiteTheme">
- <i class="user circle outline icon"></i> Anyone signed in
- <div class="sub header whiteTheme">Anyone who has signed in can access this file</div>
- </div>
- </div>
- </label>
- </div>
- <div class="ts radio disabled checkbox">
- <input id="samegroup" type="radio" class="shareoption" value="samegroup" name="shareopt">
- <label for="samegroup">
- <div class="ts header">
- <div class="content whiteTheme">
- <i class="users icon"></i> Users in the same group
- <div class="sub header whiteTheme">Anyone who is in the same group as you do</div>
- </div>
- </div>
- </label>
- </div>
- <br>
- <button class="ts small button" onclick="updateShareSettings(this)" style="border: 0px solid transparent;">Update</button>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <div class="ts divider"></div>
- <div id="sharingRemoveBtn" class="popupbuttons negative whiteTheme allowHover" onclick="removeSharing()">
- <i class="remove icon"></i> Remove Sharing
- </div>
- <div class="popupbuttons whiteTheme allowHover" onclick="hideShare()">
- <i class="checkmark icon"></i> OK
- </div>
- </div>
- </div>
- <!-- Open With Dialog-->
- <div id="openWith" class="popup whiteTheme" style="display:none;">
- <div class="popupheader whiteTheme">
- <i class="external icon"></i> Open File With
- <div class="popupcloser" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i>
- </div>
- </div>
- <div class="popupcontent" style="padding:12px;">
- <p>Select a module from the list below:</p>
- <div id="openWithModuleList" class="ts segment whiteTheme" style="padding:0px;">
- <div class="item selectable">
- <div class="content" style="padding-left:12px;">
- <div class="header">Loading...</div>
- </div>
- </div>
- </div>
- <div class="openWithModule popupbuttons whiteTheme allowHover primary" onclick="openWithSelectedModule(this);";>
- <i class="external icon"></i> Open with Selected Module
- </div>
- <div class="openWithModule popupbuttons whiteTheme allowHover" onclick="openFileWithModuleInNewTab(this);">
- <i class="add icon"></i> Open in new tab
- </div>
- <div class="popupbuttons whiteTheme allowHover vdonly" onclick="openRawFileInFloatWindow(this);">
- <i class="window restore outline icon"></i> Open File directly in floatWindow
- </div>
- <div class="popupbuttons whiteTheme allowHover" onclick="hideAllPopupWindows();">
- <i class="remove icon"></i> Cancel
- </div>
- </div>
- </div>
- <!-- Context Menu -->
- <div id="contextmenu" class="ts small contextmenu visible whiteTheme" style="min-width:250px;">
- <div class="item" onclick="openViaButton();">
- <i class="folder open icon"></i> Open
- </div>
- <div class="item fileonly" onclick="openWith();">
- <i class="external icon"></i> Open With
- </div>
- <div class="item folderonly" onclick="openSelectedFolderInNewWindow();">
- <i class="external icon"></i> Open In New Window
- </div>
- <!-- This is the vroot alternative new windows-->
- <div class="item vrootonly" onclick="openSelectedVroot();">
- <i class="external icon"></i> Open In New Window
- </div>
- <div class="item shareonly" onclick="openFileLocation();">
- <i class="folder outline icon"></i> Open File Location
- </div>
- <div class="item singleObjectOnlyHide" onclick="shareFile();">
- <i class="share alternate icon"></i> Share
- </div>
- <div class="item mobileonly" onclick="toggleCtrl();">
- <i class="mouse pointer icon"></i> Multi-select
- </div>
- <div class="item" onclick="copy();">
- <i class="copy icon"></i> Copy
- <span class="description">Ctrl + C</span>
- </div>
- <div class="item allowNoSelection" onclick="paste();">
- <i class="paste icon"></i> Paste
- <span class="description">Ctrl + V</span>
- </div>
- <div class="item" onclick="cut();">
- <i class="cut icon"></i> Cut
- <span class="description">Ctrl + X</span>
- </div>
- <div class="divider vroothide noSelectionOnly"></div>
- <div class="item noSelectionOnly" onclick="newfile();">
- <i class="file outline icon"></i> New File
- </div>
- <div class="item noSelectionOnly" onclick="newFolder();">
- <i class="folder outline icon"></i> New Folder
- </div>
- <div class="divider vroothide"></div>
- <div class="item noSelectionOnly" onclick="upload();">
- <i class="upload icon"></i> Upload
- </div>
- <div class="item" onclick="zipFile();">
- <i class="zip file icon"></i> Create Zip
- </div>
- <div class="item" onclick="rename();">
- <i class="i cursor icon"></i> Rename
- </div>
- <div class="item" onclick="deleteFile();">
- <i class="trash icon"></i> Delete
- </div>
- <div class="item backuponly" onclick="openBackupManager();">
- <i class="block layout icon"></i> Backup & Restore
- </div>
- <div class="divider vroothide"></div>
- <div class="item noSelectionOnly" onclick="refreshList();">
- <i class="refresh icon"></i> Refresh
- </div>
- <div class="item" onclick="downloadFile();">
- <i class="download icon"></i> Download
- </div>
- <div class="item" onclick="showFileProperties();">
- <i class="notice icon"></i> Properties
- </div>
- <!-- This properties shows the currentDirectory properties instead of the selected file properties-->
- <div class="item noSelectionOnly" onclick="showCurrentDirectoryProperties();">
- <i class="notice icon"></i> Properties
- </div>
- <!-- This properties show the vroot properties -->
- <!-- This properties shows the currentDirectory properties instead of the selected file properties-->
- <div class="item vrootonly" onclick="showVrootProperties();">
- <i class="notice icon"></i> Properties
- </div>
- </div>
- <!-- Upload Progress Bars-->
- <div id="uploadTab" class="ts segment whiteTheme" style="display:none;">
- <div class="statusBar whiteTheme">
- <i class="upload icon"></i><span id="uploadCount">0</span> Files / <i class="wait icon"></i> <span id="waitingCount">0</span> Files
- <div class="hideUploadButton" onclick="toggleUploadList();">
- <i class="caret down icon"></i>
- </div>
- </div>
- <div class="uploadList" id="uploadProgressList">
-
- </div>
- <br>
- <!--
- <div class="clearallButton">
- <a onclick="clearAllUploadTask();">Clear All</a>
- </div>
- -->
- </div>
-
- <script>
- let directorySidebarWidth = 250; //Width of the sidebar
- let sideBarShown = true; //Indicate if sidebar is shown
- let rootDirs = []; //Storage location for rootDirs
- let currentTheme = "whiteTheme"; //Default theme
- let viewMode = "list"; //Viewmode, support {list, grid, detail}
- let sortMode = "default"; //Sortmode, support {default, reverse, smallToLarge, largeToSmall, mostRecent, leastRecent}
- let currentPath = "user:/"
- let viewHistory = []; //View history
- let enableBetaFilename = false; //Enable beta filename conversion from "inith..." to "normal"
- let currentFilelist = []; //The current file list in the currentPath
- let currentPathHash = ""; //The folder content hash
- let enableAutoRefresh = true; //Enable directory updates on file change
- let filesIconTheme = "default";
- //File operations
- let clipboard = []; //System clipboard
- let cutMode = false; //If set to true, this is cut mode. Else copy mode
- let useLocalstorage = lscheck();
- let overwriteMode = "keep"; //Overwrite mode, support {skip, overwrite, keep}
- let thumbRenderWebSocket = null;
- let searchCaseSensitive = false;
- //Keypress listeners
- let ctrlHold = false;
- let shiftHold = false;
- //Upload related
- let uploadingFileCount = 0;
- let maxConcurrentUpload = 4; //Maxmium number of oncurrent upload
- let uploadPendingList = []; //Upload pending queue for mass upoad
- let lowMemoryMode = true; //Upload with low memory mode channel
- let uploadFileChunkSize = 1024 * 512; //512KB, 4MB not working quite well on slow network
- //File Sharing related
- let shareEditingObject = "";
- let shareEditingUUID = "";
- //System Information
- let systemUUID = "";
- let systemIP = "";
- //Browser detection
- let isMobile = window.mobilecheck();
- let isChromium = window.chrome;
- let isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
- let isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
- let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
- //Intiiation functions
- initRootDirs();
- initSystemInfo();
- initUploadMode();
- if (isMobile){
- //Mobile css adjustment
- sideBarShown = false;
- $("#directorySidebar").hide();
- $("#directorySidebar").css("width",window.innerWidth + "px");
- $("body").css("overflow","hidden");
- directorySidebarWidth = window.innerWidth;
- $("#folderView").css({
- "padding-right":"1em",
- "padding-left":"1em",
- "padding-top":"1em",
- });
- $(".desktopOnly").hide();
- $(".mobileOnly").show();
- }else{
- $(".mobileOnly").hide();
- $(".desktopOnly").show();
- }
- //Initialize view mode buttons
- updateViewmodeButtons();
- loadListModeFromDB();
- //Initialize system theme
- loadPreference("file_explorer/theme",function(data){
- if (data.error === undefined){
- if (data == "darkTheme"){
- toggleDarkTheme();
- }else{
- //White theme
-
- }
- }
- });
- if (window.location.hash != ""){
- //Check if the hash is standard open protocol. If yes, translate it
- if (ao_module_loadInputFiles() === null){
- //Window location hash set. List the desire directory
- currentPath = window.location.hash.substring(1,window.location.hash.length);
- if (currentPath.substring(currentPath.length -1) != "/"){
- currentPath = currentPath + "/";
- }
- currentPath = decodeURIComponent(currentPath);
- loadListModeFromDB(function(){
- listDirectory(currentPath);
- });
-
- }else{
- //This is ao_module load file input. Handle the file opening
- var filelist = ao_module_loadInputFiles();
- if (filelist.length > 0){
- filelist = filelist[0];
- //Check if this is folder or file. Only opendir when it is folder
- //Updates 27-12-2020: Open folder and highlight the file if it is file
- if (filelist.filename.includes(".") == false){
- //Try to open it and overwrite the hash to filesystem hash
- loadListModeFromDB(function(){
- listDirectory(filelist.filepath);
- });
- }else{
- //File. Open its parent folder and highlight the target file if exists
- var parentdir = filelist.filepath.split("/");
- let focusFilename = JSON.parse(JSON.stringify(filelist.filename));
- parentdir.pop();
- parentdir = parentdir.join("/");
- loadListModeFromDB(function(){
- listDirectory(parentdir, function(){
- focusFileObject(focusFilename);
- });
- });
- }
- }
- }
- }else{
- //Initialized directory views
- loadListModeFromDB(function(){
- listDirectory(currentPath);
- });
- }
-
-
-
- //Create a timer to check change in current folder
- setInterval(function(){
- if (enableAutoRefresh == false){
- return;
- }
- getDirHash(function(hash){
- if (hash.error !== undefined){
- //Something went wrong. Ignore this request
- console.log(hash.error)
- }else{
- //Check if the hash match with the last hash.
- if (hash != currentPathHash){
- //console.log(currentPathHash, hash);
- refreshList();
- currentPathHash = hash;
- if (currentPath == "user:/"){
- //Reload the User root folder list
- initRootDirs();
- }
- }
- }
- });
- }, 5000)
- //END OF INIT FUNCTIONS
- //Get the system ID and ip address from the system id services
- function initSystemInfo(){
- $.get("../../system/id/requestInfo",function(data){
- if (data.error !== undefined){
- msgbox("remove", data.error);
- }else{
- systemUUID = data.SystemUUID;
- systemIP = data.IpAddress;
- }
- });
- }
- //Initiate the sidebar contents
- function initRootDirs(){
- //Load user directories
- $.ajax({
- url:"../../system/file_system/listRoots?user=true",
- success: function(data){
- $("#userroot").html("");
- for (var i =0; i < data.length; i++){
- var thisRootObject = data[i];
- if (thisRootObject.IsDir == true && !(thisRootObject.Filename == ".cache" || thisRootObject.Filename == ".trash")){
- //Files will not be listed in the root directory list
- var icon = getUserRootIcons(thisRootObject.Filename);
- var displayName = thisRootObject.Filename;
- var vpath = thisRootObject.Filepath;
- $("#userroot").append(`<div class="dir item ${currentTheme}" filepath="${vpath}" type="folder" onclick="openthis(this);"><i class="${icon} rightmargin icon"></i> ${displayName}</div>`);
- }
- }
- }
- });
- //Load other storage devices
- $.ajax({
- url:"../../system/file_system/listRoots",
- success: function(data){
- $("#storageroot").html("");
- for (var i =0; i < data.length; i++){
- var thisRoot = data[i];
- var displayName = thisRoot.RootName;
- var rootPath = thisRoot.RootPath;
- var containBackup = thisRoot.RootBackups;
- $("#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>`);
- }
- }
- });
- //Initial Host device drives
- /*
- $.ajax({
- url: "../../system/file_system/listDrives",
- success: function(data){
- $("#deviceList").html("");
- for (var i =0; i < data.length; i++){
- var drivePath = data[i].Drivepath;
- var usagePercentage = ((data[i].DriveTotalSpace - data[i].DriveFreeSpace) / data[i].DriveTotalSpace) * 100;
- var className = "primary";
- if (usagePercentage > 90){
- className = "negative";
- }
- $("#deviceList").append(`<div class="dir item ${currentTheme}" filepath="${drivePath}" ><i class="disk outline rightmargin icon"></i> ${drivePath}
- <div style="width:100px;height:15px !important; position:absolute;right:3px;top:6px;"">
- <div class="ts ${className} tiny progress">
- <div class="bar" style="width: ${usagePercentage}%"></div>
- </div>
- </div>
- </div>`);
- }
- }
- });
- */
- }
-
- function getUserRootIcons(foldername){
- var icon = "folder open";
- foldername = foldername.toLowerCase();
- if (foldername == "desktop"){
- icon = "computer";
- }else if (foldername == "document"){
- icon = "file text outline";
- }else if (foldername == "music" || foldername == "audio"){
- icon = "music";
- }else if (foldername == "photo" || foldername == "picture"){
- icon = "image";
- }else if (foldername == "video" || foldername == "film"){
- icon = "video";
- }else if (foldername == "trash" || foldername == "bin" || foldername == "rubbish"){
- icon = "trash"
- }else if (foldername == "download"){
- icon = "download"
- }else if (foldername == "www" || foldername == "web" || foldername == "mysite"){
- icon = "globe"
- }else if (foldername == "model"){
- icon = "cube"
- }else if (foldername == "appdata"){
- icon = "code"
- }
- return icon;
- }
- // ============================== FOLDER LISTING FUNCTIONS ====================
- function listDirectory(path, callback=undefined, recordUndo=true){
- //If current mode is search mode, hide the serach bar
- if (searchMode == true){
- //Hide searchbar and skip refresh list
- hideSearchBar(true);
- }
- var recordPreviousPage = true;
- if (recordUndo == false){
- recordPreviousPage = false;
- }
- //Backup the current selected files if it is an refresh operation
- let selectedFiles = [];
- if (path == currentPath){
- $(".fileObject.item.selected").each(function(){
- selectedFiles.push($(this).attr("filename"));
- });
- //Set record histroy to false on refresh
- recordPreviousPage = false;
- }
-
- //Always pad slash to the end of path
- if (path.substring(path.length - 1) != "/"){
- path = path + "/";
- }
- //Clean the path if there are any malformat
- if (path.indexOf("//") != -1){
- path = path.split("//").join("/");
- }
- if (recordPreviousPage){
- viewHistory.push(currentPath);
- }
-
- window.location.hash = path;
- updatePathDisplay(path);
- currentPath = path;
- //Update floatWindow title if exists
- if (ao_module_virtualDesktop){
- var tmp = path.split("/");
- tmp.pop();
- ao_module_setWindowTitle("File Manager - " + tmp.pop());
- }
- //Check if there are parent path for curret path
- if (checkIfParentDirExists(currentPath)){
- $("#ppbtn").removeClass("disabled");
- }else{
- $("#ppbtn").addClass("disabled");
- }
- if (viewHistory.length < 1){
- $("#backbtn").addClass("disabled");
- }else{
- $("#backbtn").removeClass("disabled");
- }
- //Add loading screen to the folderlists and fileList
- $("#fileList").html("");
- if (currentTheme == "darkTheme"){
- $("#folderList").html(`<div style="height: 100px;">
- <div class="ts active dimmer">
- <div class="ts text loader">Loading</div>
- </div>
- </div>`);
- }else{
- $("#folderList").html(`<div style="height: 100px;">
- <div class="ts active inverted dimmer">
- <div class="ts text loader">Loading</div>
- </div>
- </div>`);
- }
-
- $.ajax({
- url: "../../system/file_system/listDir",
- method: "POST",
- data: {dir: decodeURIComponent(path), sort: sortMode},
- success: function(data){
- //Parse the filelist into global variable
- currentFilelist = [];
- if (data === null){
- //There is nothing is this folder.
- $("#folderList").hide();
- $("#fileList").hide();
- return;
- }
- if (data.error !== undefined){
- //Parse path error. Try to refresh the page
- console.log("Path parse error! Redirecting to parent directory.", data.error);
- var pdir = currentPath.split("/");
- pdir.pop(); pdir.pop();
- pdir = pdir.join("/");
- currentPath = pdir;
- //Check if it is already rooted and no more parent ahead
- if (currentPath == ""){
- currentPath = "user:/";
- }
-
- //listDirectory(currentPath, function(){
- // window.location.reload();
- //});
- return;
- }else{
- //Filelist returned. Render it
- renderDirectory(data,function(){
- //Restore the selected file list
- $(".fileObject.item").each(function(){
- for (var i = 0; i < selectedFiles.length; i++){
- var thisFilename = selectedFiles[i];
- if (thisFilename == $(this).attr("filename")){
- $(this).addClass("selected");
- }
- }
- });
-
- //Perform the callback
- if (callback !== undefined){
- callback();
- }
- });
- }
- }
- });
- }
- //Render filelist --> Convert a file list object into the visable form of file list
- function renderDirectory(filelist, callback=undefined){
- var data = filelist;
- $("#fileList").html("");
- $("#folderList").html("");
- //Build the css strcture of the list
- if (viewMode == "list"){
- $("#fileList").attr("class",`ts segmented fluid list ${currentTheme}`);
- $("#folderList").attr("class",`ts segmented fluid list ${currentTheme}`);
- }else if (viewMode == "details"){
-
- }else if (viewMode == "grid"){
- $("#fileList").attr("class",`${currentTheme}`).css("vertical-align","top");
- $("#folderList").attr("class",`${currentTheme}`).css("vertical-align","top");
- }
-
- var files = [];
- var folders = [];
- for (var i =0; i < data.length; i++){
- if (data[i].IsDir == true){
- //This is folder
- folders.push(data[i]);
- }else{
- //This is file
- files.push(data[i]);
- }
- currentFilelist.push(JSON.parse(JSON.stringify(data[i].Filename)));
- }
- //Define the grid size for the interface
- var gridSize = 150 ;
- if (isMobile){
- //Update 3/5/2021: Optimize the width calculation method to best fit
- /*
- if (window.innerWidth > window.innerHeight){
- //Screen using in horizontal mode
- gridSize = window.innerWidth /4 - 20 ;
- }else{
- //Screen using in vertical mode
- gridSize = window.innerWidth /2 - 20 ;
- }
- */
- //A hack to align the divs to center of the container
- $("#folderView").attr("align", "center");
- $("#folderList").attr("align", "left");
- $("#fileList").attr("align", "left");
- //Calculate the best width to fit all the grids
- var bestCount = Math.floor(parseFloat($("#folderView").width()) / parseFloat(gridSize));
- var bestOffset = $("#folderView").width() % gridSize;
- gridSize = gridSize + (bestOffset / bestCount) - (window.innerWidth - $("#folderView").width()) / bestCount;
- }
-
- //List all folders
- for (var i =0; i < folders.length; i++){
- var filename = folders[i].Filename;
- var filepath = folders[i].Filepath;
- var realpath = folders[i].Realpath;
- var isDir = folders[i].IsDir;
- var filesize = folders[i].Filesize;
- var Displaysize = folders[i].Displaysize;
- var isShared = folders[i].IsShared;
- var ext = getExtFromPath(filepath);
- //var icon = ao_module_utils.getIconFromExt(ext);
- var icon = "folder";
- var shareicon = "";
- if (isShared == true){
- shareicon = `<button class="sharebtn ${currentTheme}" onclick='handleShareFilebuttonClick(event, this);' style="margin-left: 4px; height: 16px;">
- <i class='share alternate icon'></i>
- </button>`
- }
- if (viewMode == "list"){
- var textclass = "normal object";
- if (currentTheme == "darkTheme"){
- textclass += " darkTheme";
- }
- var displayName = filename;
- try{
- //Try to decode it using ArozOS Beta naming scheme
- if (enableBetaFilename && ao_module_codec.decodeHexFoldername(displayName) != displayName){
- displayName = ao_module_codec.decodeHexFoldername(displayName, false);
- textclass = "hex foldername";
- }
- }catch(ex){
- //Codec decode failed. Fallback to default name
- }
-
- $("#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">
- <span style="display:inline-block !important;word-break: break-all;" class="${textclass}">
- <i class="${icon} icon" style="margin-right:12px; color:#eab54e;"></i> ${displayName} ${shareicon}
- </span></div>`);
- }else if (viewMode == "grid"){
- var displayName = JSON.parse(JSON.stringify(filename));
- var textclass = "normal object";
- try{
- //Try to decode it using ArozOS Beta naming scheme
- if (enableBetaFilename && ao_module_codec.decodeHexFoldername(displayName) != displayName){
- displayName = ao_module_codec.decodeHexFoldername(displayName, false);
- textclass = "hex foldername";
- }
- }catch(ex){
- //Codec decode failed. Fallback to default name
-
- }
- if (displayName.length > 16){
- displayName = displayName.substring(0,16) + "...";
- }
- $("#folderList").append(`
- <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;">
- <div class="image" style="text-align: center;">
- <img draggable="true"ondragstart="disableDrag(event);" src="../../../img/desktop/files_icon/${filesIconTheme}/folder.png" style="height: 148px; width: 148px; display: inline-block;">
- </div>
- <div class="content" style="font-size: 12px;">
- <div class="header ${currentTheme} ${textclass}" title="${filename}">${displayName} ${shareicon}</div>
- </div>
- </div>`);
- }
- }
- if (folders.length == 0){
- $("#folderList").hide();
- }else{
- $("#folderList").show();
- }
-
- //List all files
- var fl = folders.length;
- for (var i =0; i < files.length; i++){
- var filename = files[i].Filename;
- var filepath = files[i].Filepath;
- var realpath = files[i].Realpath;
- var filesize = files[i].Filesize;
- var Displaysize = files[i].Displaysize;
- var isShared = files[i].IsShared;
- var ext = getExtFromPath(filepath);
- if (ext == ""){
- var icon = "file outline";
- }else{
- var icon = ao_module_utils.getIconFromExt(ext);
- }
- var shareicon = "";
- if (isShared){
- shareicon = `<button class="sharebtn ${currentTheme}" onclick='handleShareFilebuttonClick(event, this);' style="margin-left: 4px; height: 16px;">
- <i class='share alternate icon'></i>
- </button>`
- }
-
- var fileType = "file";
- if (ext == "shortcut"){
- fileType = "shortcut";
- }
- if (viewMode == "list"){
- var displayName = filename;
- var textclass = "normal object";
- if (currentTheme == "darkTheme"){
- textclass += " darkTheme";
- }
- if (enableBetaFilename){
- decodedName = ao_module_codec.decodeUmFilename(displayName);
- if (decodedName != displayName){
- displayName = decodedName;
- textclass = "um filename";
- }
- filename = ao_module_codec.decodeUmFilename(filename);
- }
- $("#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}">
- <span style="display:inline-block !important;word-break: break-all;text-overflow: ellipsis !important;overflow: hidden;" class="${textclass}">
- <i class="${icon} icon" style="margin-right:12px;"></i>
- ${displayName} ${shareicon}
- </span>
- </div>`);
- }else if (viewMode == "grid"){
- var imagePath = "../../../img/desktop/files_icon/" + filesIconTheme + "/" + icon + ".png";
- var displayName = JSON.parse(JSON.stringify(filename));
- var textclass = "normal object";
- if (enableBetaFilename){
- decodedName = ao_module_codec.decodeUmFilename(displayName);
- if (decodedName != displayName){
- textclass = "um filename";
- displayName = decodedName;
- }
- filename = ao_module_codec.decodeUmFilename(filename);
- }
-
- if (displayName.length > 20){
- displayName = displayName.substring(0,20) + "...";
- }
- $("#fileList").append(`
- <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;">
- <div class="image" style="text-align: center !important;">
- <img draggable="true"ondragstart="disableDrag(event);" style="height: 148px; width: 148px; display:inline-block;" src="${imagePath}">
- </div>
- <div class="content">
- <div class="header ${currentTheme} ${textclass}" title="${filename}" style="text-overflow: ellipsis; font-size: 100%">${displayName} ${shareicon}</div>
- <div class="meta ${currentTheme}">
- <div>.${ext}</div>
- </div>
- <div class="description ${currentTheme}">
- ${Displaysize}
- </div>
- </div>
- </div>
- `);
- }
- }
- if (files.length == 0){
- $("#fileList").hide();
- }else{
- $("#fileList").show();
- }
- bindFileObjectEvents();
- currentFilelist.sort();
- //Update the filelist hash
- enableAutoRefresh = false;
- getDirHash(function(hash){
- currentPathHash = hash;
- enableAutoRefresh = true;
- });
- //If viewmode is grid, load file thumbnails
- if (viewMode == "grid"){
- startThumbnailLoader();
- }
- if (callback !== undefined){
- callback();
- }
- }
- function startThumbnailLoader(){
- let path = currentPath;
- let protocol = "wss://";
- if (location.protocol !== 'https:') {
- protocol = "ws://";
- }
- var port = window.location.port;
- if (window.location.port == ""){
- port = "80";
- }
- thumbRenderWebSocket = new WebSocket(protocol + window.location.hostname + ":" + port + "/system/file_system/handleCacheRender?folder=" + path);
- thumbRenderWebSocket.onopen = function(e) {
- };
- thumbRenderWebSocket.onmessage = function(event) {
- //Find the correct file in the current directory and place its image
- if (path == currentPath){
- var thumbData = JSON.parse(event.data);
- $(".fileObject").each(function(){
- if (thumbData[1].length > 0){
- if ($(this).attr("filename") == thumbData[0]){
- $(this).find("img").attr("src","data:image/jpg;base64," + thumbData[1]);
- }
- }
-
- });
- }
-
- };
- thumbRenderWebSocket.onclose = function(event) {
- //Transfer ended
- };
- thumbRenderWebSocket.onerror = function(error) {
- console.log(error);
- };
- }
- //Make an div not draggable
- function disableDrag(event){
- event.preventDefault();
- event.stopPropagation();
- }
- //Make fileObject draggable
- function onFileObjectDragStart(object, event){
- if ((ctrlHold) && $(object).hasClass("selected") == false){
- $(object).addClass("selected");
- }else if ($(object).hasClass("selected") == false){
- $(".fileObject.selected").removeClass("selected");
- $(object).addClass("selected");
- }
- var fileList = [];
- $(".selected.fileObject").each(function(){
- var filename = $(this).attr('filename');
- var filepath = $(this).attr('filepath');
- var sourceSystemUUID = systemUUID;
- //Extra information is passed in due to the need for cross cluster communication in the future
- fileList.push({
- filename: filename,
- filepath: filepath,
- hostUUID: sourceSystemUUID
- });
- });
-
- event.dataTransfer.setData("filedata", JSON.stringify(fileList));
- }
- //Bind onclicke events for fileObjects
- var lastClickedFileID = 0;
- function bindFileObjectEvents(){
- $(".fileObject").off("click").on('click',function(evt){
- if (!ctrlHold && isMobile){
- //If on mobile, click means open
- openthis(this,evt);
- return
- }
- if (ctrlHold == true){
- if ($(this).hasClass("selected")){
- $(this).removeClass("selected");
- }else{
- $(this).addClass("selected");
- }
-
- lastClickedFileID = parseInt($(this).attr("fileid"));
- }else if (shiftHold == true){
- //Select everything in range lastClicked to this
- var thisFileID = $(this).attr("fileid");
- let start = parseInt(thisFileID);
- let end = parseInt(lastClickedFileID);
- if (start > end){
- start = parseInt(lastClickedFileID);
- end = parseInt(thisFileID);
- }
- //Select all fileObject in range.
- $(".fileObject").each(function(){
- let currentItemFileID = $(this).attr('fileid');
- currentItemFileID = currentItemFileID - 0;
- if (currentItemFileID >= start && currentItemFileID <= end){
- $(this).addClass("selected");
- }
- });
- }else{
- //Nothing is pressed. Deselect everything and add this only
- $(".fileObject.selected").removeClass("selected");
- $(this).addClass("selected");
- lastClickedFileID = $(this).attr("fileID");
- }
- if ($(".fileObject.selected").length != 1){
- //Multiple object selected
- $(".singleObjectOnly").addClass("disabled");
- $(".singleObjectOnlyHide").hide();
- }else{
- //Single object
- $(".singleObjectOnly").removeClass("disabled");
- $(".singleObjectOnlyHide").show();
- }
- });
- //Bind right click select on items
- $(".fileObject").off("mousedown").on("mousedown",function(evt){
- if (evt.which == 3){
- //Right click on this file
- if ($(this).hasClass('selected') == false){
- $(".fileObject.selected").removeClass("selected");
- $(this).addClass("selected");
- }
- }
- });
- //This function calculate and offset the context menu to not go out of the window area
- function calculateContextMenuOffsets(evt){
- var defaultLeftPost = evt.pageX;
- var defaultTopPost =evt.pageY;
-
- if (evt.pageX > window.innerWidth / 2){
- defaultLeftPost = evt.pageX - $("#contextmenu").width() + "px";
- }
- if (evt.pageY > window.innerHeight / 2){
- defaultTopPost = evt.pageY - $("#contextmenu").height() + "px";
- }
- $("#contextmenu").css({
- left: defaultLeftPost,
- top: defaultTopPost
- });
- }
- //Rightclick on a file object
- $(".fileObject").off("contextmenu").on("contextmenu", function(evt){
- evt.preventDefault();
-
- if (isMobile){
- //Firefox Mobile. Fix select with context menu not working bug
- var selectedObject = $(evt.target);
-
- if ($(selectedObject).hasClass("fileObject")){
- if (!ctrlHold){
- $(".fileObject.selected").removeClass("selected");
- }
- $(selectedObject).addClass("selected");
- }else{
- //Uptrace 5 layers for fileObject
- for (var i = 0; i < 5; i++){
- if ($(selectedObject).hasClass("fileObject") == false){
- selectedObject = $(selectedObject).parent();
- }else{
- break;
- }
- }
- if (!ctrlHold){
- $(".fileObject.selected").removeClass("selected");
- }
- $(selectedObject).addClass("selected");
- }
- }
- calculateContextMenuOffsets(evt);
- //Show all options by defaults
- $("#contextmenu").find(".item").show();
- $("#contextmenu").find(".vroothide").show();
- $("#contextmenu").find(".noSelectionOnly").hide();
- $("#contextmenu").find(".vrootonly").hide();
-
- //Hide backup manual
- $("#contextmenu").find(".backuponly").hide();
- //Check if this is folder or file. Replace the suitable selections
- if ($(this).attr("type") == "folder"){
- //Use folder mode
- $("#contextmenu").find(".folderonly").show();
- $("#contextmenu").find(".fileonly").hide();
- }else{
- //Use file mode
- $("#contextmenu").find(".folderonly").hide();
- $("#contextmenu").find(".fileonly").show();
- }
- if (searchMode == true){
- $("#contextmenu").find(".shareonly").show();
- }else{
- $("#contextmenu").find(".shareonly").hide();
- }
- $("#contextmenu").addClass("visible");
- //Handle CSS offset of the contextmenu
- if ($("#contextmenu").offset().top < 0){
- $("#contextmenu").css("top","0px");
- }else if($("#contextmenu").offset().top + $("#contextmenu").height() > window.innerHeight){
- $("#contextmenu").css("top",window.innerHeight - $("#contextmenu").height() + "px");
- }
- if (isMobile){
- $("#contextmenu").find(".mobileonly").show();
- }else{
- $("#contextmenu").find(".mobileonly").hide();
- }
- });
- //Right click on empty space of the file selector
- $("#folderView").off("contextmenu").on("contextmenu", function(e){
- if ($(e.target).attr("id") == "folderView" || $(e.target).attr("id") == "fileList" || $(e.target).attr("id") == "folderList"){
- //Context menu on the empty space of the folder / file list
- e.preventDefault();
- $("#contextmenu").find(".item").hide();
- $("#contextmenu").find(".noSelectionOnly").show();
- $("#contextmenu").find(".allowNoSelection").show();
- $("#contextmenu").find(".vroothide").show();
- //Calculate the position of the context menu
- calculateContextMenuOffsets(e);
- //Show context menu
- $("#contextmenu").addClass("visible");
- //Handle CSS offset of the contextmenu
- if ($("#contextmenu").offset().top < 0){
- $("#contextmenu").css("top","0px");
- }else if($("#contextmenu").offset().top + $("#contextmenu").height() > window.innerHeight){
- $("#contextmenu").css("top",window.innerHeight - $("#contextmenu").height() + "px");
- }
- }
- });
- //Handle right click on storage roots
- $("#storageroot").off("contextmenu").on("contextmenu", function(e){
- if ($(e.target).is("i")){
- e.target = e.target.parentElement;
- }
- $("#storageroot").find(".dir.item").each(function(){
- if ($(this).attr("rootname") != undefined){
- $(this).removeClass("active");
- }
- });
- if ($(e.target).attr("rootname") != undefined){
- //Correct one. Show vroot functions
- e.preventDefault();
- var rootname = $(e.target).attr("rootname");
- var containBackup = $(e.target).attr("contain-backup") == "true";
- $(e.target).addClass("active");
- $("#contextmenu").find(".item").hide();
- $("#contextmenu").find(".vroothide").hide();
- $("#contextmenu").find(".vrootonly").show();
- //Check if this is a backup drive
- if (containBackup == true){
- $("#contextmenu").find(".backuponly").show();
- }else{
- $("#contextmenu").find(".backuponly").hide();
- }
- //Show context menu
- calculateContextMenuOffsets(e);
- $("#contextmenu").addClass("visible");
- //Handle CSS offset of the contextmenu
- if ($("#contextmenu").offset().top < 0){
- $("#contextmenu").css("top","0px");
- }else if($("#contextmenu").offset().top + $("#contextmenu").height() > window.innerHeight){
- $("#contextmenu").css("top",window.innerHeight - $("#contextmenu").height() + "px");
- }
- }
- });
- $(document).on("click",function(evt){
- $(".contextmenu").removeClass("visible");
- });
- }
- //Change the current view mode
- function changeViewMode(object){
- var targetMode = $(object).attr("mode");
- viewMode = targetMode;
- listDirectory(currentPath);
- updateViewmodeButtons();
- setPreference("file_explorer/listmode",targetMode)
- }
- function updateViewmodeButtons(){
- $(".videmode").removeClass('disabled');
- $(".videmode").each(function(){
- if ($(this).attr("mode") == viewMode){
- $(this).addClass("disabled");
- }
- });
- }
- function previosPath(){
- //Remove the current directory from history
- if (viewHistory.length == 0){
- //This is already the first page
- return;
- }
- var previousPath = viewHistory.pop();
- listDirectory(previousPath, undefined, false);
- }
- function parentDir(){
- //If under searchmode, parentDir go back to the currentPath
- if (searchMode){
- hideSearchBar();
- return;
- }
- //Check if there are any parent dir for this path
- if (checkIfParentDirExists(currentPath)){
- //There are parent path. Get it from currentPath
- pathInfo = currentPath.split("/");
- pathInfo.pop();
- var parentFolderName = pathInfo.pop();
- parentPath = pathInfo.join("/") + "/"
-
- //List the parentDir
- listDirectory(parentPath, function(){
- focusFileObject(parentFolderName);
- });
-
- }
- }
- //Move the page focus to the given fileobject
- function focusFileObject(targetFileName){
- $(".fileObject").each(function(){
- if ($(this).attr("filename") == targetFileName){
- $(this).addClass("selected");
- //Trying to vertically align the directory from its parent list
- $("#folderView").stop().finish().animate({
- scrollTop: $(this).offset().top - $("#folderView").offset().top - (window.innerHeight - $("#navibar").height())/2 + $(this).height()
- }, 300);
- }
- });
- }
- function loadListModeFromDB(callback = undefined){
- //Get list mode from storage
- loadPreference("file_explorer/listmode",function(data){
- if (data != "" && data.error === undefined){
- viewMode = data;
- updateViewmodeButtons();
- }
- if (callback !== undefined){
- callback();
- }
- });
- }
- function rootDir(){
- //Go to the root dir of the current path
- var rootDir = currentPath.split("/").shift();
- rootDir = rootDir + "/";
- listDirectory(rootDir);
- }
- function checkIfParentDirExists(path){
- if (path.includes("/")){
- pathInfo = path.split("/");
- if (pathInfo[1] == ""){
- return false;
- }else{
- return true;
- }
- }else{
- return false;
- }
- }
- function getDirHash(callback){
- $.ajax({
- url: "../../system/file_system/listDirHash",
- data: {dir: currentPath},
- success: function(data){
- if (data.error !== undefined){
- if (data.error == "Invalid dir given"){
- //Storage has been unmounted. Back to parent
- var pdir = currentPath.split("/");
- pdir.pop();pdir.pop();
- pdir = pdir.join("/");
- currentPath = pdir;
- listDirectory(currentPath, function(){
- window.location.reload();
- });
- return;
- }
- }
- callback(data);
- }
- })
- }
- //=================================== FILE OPERATIONS ========================
- function refreshList(){
- shiftHold = false;
- ctrlHold = false;
- let currentScrollTop = JSON.parse(JSON.stringify($("#folderView").scrollTop()));
- listDirectory(currentPath, function(){
- //Scroll back to the original height
- $("#folderView").scrollTop(currentScrollTop);
- });
- }
- function zipFile(){
- $(".popup").fadeOut('fast');
- var zippingFiles = [];
- $(".fileObject.selected").each(function(){
- var filepath = $(this).attr("filepath");
- zippingFiles.push(filepath);
- });
- console.log(zippingFiles);
- //Request to create a zip file, named with the parent dir name
- var oprConfig = {
- opr: "zip",
- src: zippingFiles,
- dest: currentPath,
- overwriteMode: "overwrite",
- callbackWindowID: ao_module_windowID,
- callbackFunction: `callRefresh("${currentPath}")`
- }
- var configHash = encodeURIComponent(JSON.stringify(oprConfig));
- var title = "Zipping " + zippingFiles.length;
- if (fileList.length > 1){
- title += " files";
- }else{
- title += " file";
- }
- parent.newFloatWindow({
- url: "SystemAO/file_system/file_operation.html#" + configHash,
- width: 400,
- height: 220,
- appicon: "SystemAO/file_system/img/selector.png",
- title: title
- });
- }
- let renameFileObjects = [];
- function rename(){
- $(".popup").fadeOut('fast');
- renameFileObjects = [];
- var filenames = [];
- $(".fileObject.selected").each(function(){
- var fileObjectType = $(this).attr("type");
- let fileObject = {
- filename: $(this).attr('filename'),
- filepath: $(this).attr("filepath"),
- filetype: fileObjectType
- }
- renameFileObjects.push(JSON.parse(JSON.stringify(fileObject)));
- filenames.push($(this).attr('filename'));
- });
- var oldname = "unknown file.txt";
- if (renameFileObjects.length == 0){
- return;
- }else if (renameFileObjects.length > 0){
- $("#renameBox").find(".multifileWarning").hide();
- oldname = filenames[0];
- }
- $("#renameBox").find(".orgfn").val(oldname);
- $("#renameBox").find(".newfn").val(oldname);
- showPopupWrapper();
- $("#renameBox").fadeIn(100);
- }
- function confirmRename(){
- var oldName = $("#renameBox").find(".orgfn").val();
- var newName = $("#renameBox").find(".newfn").val();
- if (newName == oldName){
- msgbox("remove","New filename is identical to the original filename.")
- $("#renameBox").fadeOut(100);
- return;
- }
- var newNameWithoutExt = newName;
- var newnameExt = "";
- if (newName.includes(".")){
- tmp = newName.split(".");
- newnameExt = tmp.pop();
- newNameWithoutExt = tmp.join(".");
- }
- var counter = 0;
- var srclist = [];
- var newnamelist = [];
- for (var i =0; i < renameFileObjects.length; i++){
- var thisFilepath = renameFileObjects[i].filepath;
- var thisFiletype = renameFileObjects[i].filetype;
- var thisFilename = renameFileObjects[i].filename;
-
- var newFilename = newName;
- if ( i > 0){
- if (thisFiletype == "file"){
- var thisFileExt = thisFilename.split(".").pop();
- newFilename = newNameWithoutExt + "(" + i + ")." + thisFileExt;
- }else if (thisFiletype == "folder"){
- newFilename = newNameWithoutExt + "(" + i + ")";
- }
- }
- srclist.push(thisFilepath);
- newnamelist.push(newFilename);
-
- }
- console.log(srclist, newnamelist);
- //Send the request to serverside
- requestCSRFToken(function(token){
- $.ajax({
- url: "../../system/file_system/fileOpr",
- method: "POST",
- data: {opr: "rename", src: JSON.stringify(srclist), new: JSON.stringify(newnamelist), csrft: token},
- success: function(data){
- if (data.error !== undefined){
- msgbox("remove",data.error);
- $("#renameBox").fadeOut(100);
- }else{
- refreshList();
- msgbox("checkmark","Rename suceed");
- $("#renameBox").fadeOut(100);
- }
- }
- });
- renameFileObjects = [];
- });
-
- hideAllPopupWindows();
- }
- function changeOverwriteRule(mode, doPasteAgain=false){
- switch (mode){
- case 0:
- overwriteMode = "overwrite";
- break;
- case 1:
- overwriteMode = "skip";
- break;
- case 2:
- overwriteMode = "keep";
- break;
- default:
- overwriteMode = "keep";
- }
- if (doPasteAgain){
- //Initiate paste without checking and close the overwritemode selector
- paste(undefined, true);
- $("#overwriteModeSelection").fadeOut(100);
- }
- }
- function copy(){
- cutMode = false;
- clipboard = [];
- if ($(".fileObject.selected").length == 0){
- return;
- }
- $(".fileObject.selected").each(function(){
- var thisFilepath = $(this).attr("filepath");
- clipboard.push(thisFilepath);
- });
- if (useLocalstorage){
- localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
- localStorage.setItem("ao/file_system/cutmode","false");
- }
- msgbox("copy",clipboard.length + " objects copied.")
- }
- function cut(){
- cutMode = true;
- clipboard = [];
- if ($(".fileObject.selected").length == 0){
- return;
- }
- $(".fileObject.selected").each(function(){
- var thisFilepath = $(this).attr("filepath");
- clipboard.push(thisFilepath);
- });
- if (useLocalstorage){
- localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
- localStorage.setItem("ao/file_system/cutmode","true");
- }
- msgbox("cut",clipboard.length + " objects ready to be moved.")
- }
- function paste(redirectPasteTarget="", nocheck=false){
- let thisOprCutMode = cutMode;
- let fileList = clipboard;
- let targetDir = currentPath;
- if (redirectPasteTarget != ""){
- //Allow redirection of paste target if necessary
- targetDir = redirectPasteTarget;
- }
- if (useLocalstorage){
- //There are localStorage. Always use localStorage if exists.
- var crossFrameClipboard = localStorage.getItem("ao/file_system/clipboard");
- var useCutMode = localStorage.getItem("ao/file_system/cutmode");
- if (crossFrameClipboard !== "" && crossFrameClipboard !== undefined && crossFrameClipboard !== null){
- fileList = JSON.parse(crossFrameClipboard);
- }
- if (useCutMode !== "" && useCutMode !== undefined && useCutMode !== null){
- thisOprCutMode = (useCutMode == "true");
- }
- }
- if (fileList.length == 0){
- //There are nothing to paste
- msgbox("question","There are nothing to paste.")
- return;
- }
- //console.log(fileList,JSON.stringify(fileList));
- if (thisOprCutMode == true){
- //Cut and paste
- $.ajax({
- type: 'POST',
- url: `../../system/file_system/validateFileOpr`,
- data: {src: JSON.stringify(fileList), dest: targetDir},
- success: function(data){
- if (!nocheck && data !== null){
- //There are problem with the copy target. Pop up overwrite rule selector
- showDuplicateHandler(data);
- }else{
- //OK!
- //Clear clipboard settings
- localStorage.setItem("ao/file_system/clipboard", "");
- clipboard = "";
- //Stsart operations
- if (!ao_module_virtualDesktop){
- //Not under desktop mode. Use direct copy API
- requestCSRFToken(function(token){
- $.ajax({
- type: 'POST',
- url: `../../system/file_system/fileOpr`,
- data: {opr: "move" ,src: JSON.stringify(fileList), dest: targetDir,existsresp: overwriteMode, csrft: token},
- success: function(data){
- if (data.error !== undefined){
- msgbox("remove",data.error);
- }else{
- //OK
- msgbox("checkmark",fileList.length + " objects moved.")
- refreshList();
- }
- hideAllPopupWindows();
- }
- });
- });
-
- }else{
- //Pass the request to operation handler
- var oprConfig = {
- opr: "move",
- src: fileList,
- dest: targetDir,
- overwriteMode: overwriteMode,
- callbackWindowID: ao_module_windowID,
- callbackFunction: `callRefresh("${targetDir}")`
- }
- var configHash = encodeURIComponent(JSON.stringify(oprConfig));
- var title = "Moving " + fileList.length;
- if (fileList.length > 1){
- title += " files";
- }else{
- title += " file";
- }
- parent.newFloatWindow({
- url: "SystemAO/file_system/file_operation.html#" + configHash,
- width: 400,
- height: 220,
- appicon: "SystemAO/file_system/img/selector.png",
- title: title
- });
- hideAllPopupWindows();
- }
- }
- }
- });
- }else{
- //Copy and paste
- //Check if the file list is OK for continue without the need for overwrite
- $.ajax({
- type: 'POST',
- url: `../../system/file_system/validateFileOpr`,
- data: {src: JSON.stringify(fileList), dest: targetDir},
- success: function(data){
- if (!nocheck && data !== null){
- //There are problem with the copy target. Pop up overwrite rule selector
- showDuplicateHandler(data);
- }else{
- //OK!
- if (!ao_module_virtualDesktop){
- requestCSRFToken(function(token){
- $.ajax({
- type: 'POST',
- url: `../../system/file_system/fileOpr`,
- data: {opr: "copy" ,src: JSON.stringify(fileList), dest: targetDir,existsresp: overwriteMode, csrft: token},
- success: function(data){
- if (data.error !== undefined){
- msgbox("remove",data.error);
- }else{
- //OK
- msgbox("checkmark",fileList.length + " objects copied.")
- refreshList();
- }
- hideAllPopupWindows();
- }
- });
- });
-
- }else{
- //Pass the request to operation handler
- var oprConfig = {
- opr: "copy",
- src: fileList,
- dest: targetDir,
- overwriteMode: overwriteMode,
- callbackWindowID: ao_module_windowID,
- callbackFunction: `callRefresh("${targetDir}")`
- }
- var configHash = encodeURIComponent(JSON.stringify(oprConfig));
- var title = "Copying " + fileList.length;
- if (fileList.length > 1){
- title += " files";
- }else{
- title += " file";
- }
- parent.newFloatWindow({
- url: "SystemAO/file_system/file_operation.html#" + configHash,
- width: 400,
- height: 220,
- appicon: "SystemAO/file_system/img/selector.png",
- title: title
- });
- hideAllPopupWindows();
- }
-
- }
- }
- });
- }
- }
- //Callback function for file operation display
- window.callRefresh = function(targetdir){
- console.log(currentPath, targetdir);
- if (currentPath == targetdir){
- refreshList();
- }
- }
- //This action may duplicate files. Show handler
- function showDuplicateHandler(duplicateFileList){
- $(".popup").fadeOut(100);
- var duplicatedFileCounts = duplicateFileList.length;
- showPopupWrapper();
- $("#overwriteModeSelection").fadeIn(100);
- $("#overwriteModeSelection").find(".owm-fc").text(duplicatedFileCounts);
- var srcpath = duplicateFileList[0];
- srcpath = srcpath.split("/");
- srcpath.pop();
- srcpath = srcpath.join("/");
- $("#overwriteModeSelection").find(".owm-srcdir").text(srcpath);
- $("#overwriteModeSelection").find(".owm-destdir").text(currentPath);
- }
- //Force delete. Use normal delete fucntion if you want to move things to recycle bin instead.
- let forceDeleteList = [];
- function forceDelete(confirmed=false){
- if (confirmed == false){
- //Show confirm box
- let deletePendingList = [];
- var listObject = $("#forceDeleteConfirmBox").find(".deleteFilelist")[0];
- $(listObject).html("");
- $(".selected.fileObject").each(function(data){
- var thispath = $(this).attr("filepath");
- var thisfilename = $(this).attr("filename");
- var ext = thisfilename.split(".").pop();
- var icon = ao_module_utils.getIconFromExt(ext);
- deletePendingList.push(thispath);
- $(listObject).append(`<div class="item ${currentTheme}" ><span style="display:inline-block;">${thisfilename}</span></div>`);
- });
- showPopupWrapper();
- $("#forceDeleteConfirmBox").fadeIn(100);
- forceDeleteList = deletePendingList;
- }else{
- //Start force delete function
- $("#forceDeleteConfirmBox").fadeOut(100);
- let fdlistLength = forceDeleteList.length;
- requestCSRFToken(function(token){
- $.ajax({
- url: "../../system/file_system/fileOpr",
- method:"POST",
- data: {opr: "delete", src: JSON.stringify(forceDeleteList), csrft: token},
- success: function(data){
- if (data.error !== undefined){
- msgbox("caution",data.error);
- }else{
- refreshList();
- msgbox("checkmark",fdlistLength + " objects removed.")
- }
- hideAllPopupWindows();
- }
- });
- //Finishing up delete sequence
- forceDeleteList = [];
- });
-
- }
- }
- let deleteFileList = [];
- function deleteFile(confirmed = false){
- if (!confirmed){
- //Show the confirm dialog
- $("#deleteConfirmBox").find(".deleteFilelist").html("");
- $(".fileObject.selected").each(function(data){
- var thisfilename = $(this).attr('filename');
- var thisFilepath = $(this).attr('filepath');
- deleteFileList.push(thisFilepath);
- $("#deleteConfirmBox").find(".deleteFilelist").append(`<div class="item ${currentTheme}" ><span style="display:inline-block;">${thisfilename}</span></div>`);
- });
- if (deleteFileList.length == 0){
- //No files selected
- return;
- }else{
- //File selected. Continue to delete
- showPopupWrapper();
- $("#deleteConfirmBox").fadeIn(100);
- }
- }else{
- //Continue to delete files
- let fdlistLength = deleteFileList.length;
- requestCSRFToken(function(token){
- $.ajax({
- url: "../../system/file_system/fileOpr",
- method:"POST",
- data: {opr: "recycle", src: JSON.stringify(deleteFileList), csrft: token},
- success: function(data){
- if (data.error !== undefined){
- msgbox("caution",data.error);
- }else{
- refreshList();
- msgbox("checkmark",fdlistLength + " objects moved to trash bin.")
- }
- if (currentPath == "user:/"){
- //Reload the User root folder list
- initRootDirs();
- }
- }
- });
- console.log(deleteFileList);
- deleteFileList = [];
- hideAllPopupWindows();
- });
-
- }
- }
- function cancelDelete(){
- deleteFileList=[];
-
- }
- function cancelForceDelete(){
- $("#forceDeleteConfirmBox").fadeOut(100);
- forceDeleteList = [];
- }
- function upload(){
- var input = document.createElement('input');
- input.type = 'file';
- input.multiple = true;
- input.onchange = e => {
- var files = e.target.files;
- msgbox("upload","Upload Started");
- for (var i = 0; i < files.length; i++){
- uploadFile(files[i]);
- }
- }
- input.click();
- }
- function updatePathDisplay(path){
- var pathInfo = path.split("/");
- var vdID = pathInfo[0];
- //As path always end with /, pop the empty pathinfo from array
- pathInfo.pop();
- var l = pathInfo.length;
- //Append the starting vdir
- $(".pathDisplay").html("");
- $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="rootDir();"><i class="folder icon"></i> ${vdID}</div>`);
- $(".pathDisplay").append(`<div class="divider ${currentTheme} whiteTheme">/</div>`);
- //console.log(pathInfo);
- if (l > 3){
- //E.g. user:/Desktop/test/boo/ => Display as user:/.../test/boo/
- $(".pathDisplay").append(`<div class="section ${currentTheme}">...</div>`);
- $(".pathDisplay").append(`<div class="divider ${currentTheme} whiteTheme">/</div>`);
- $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="parentDir();">${shortenLongFoldername(pathInfo[l-2], 40)}</div>`);
- $(".pathDisplay").append(`<div class="divider ${currentTheme} whiteTheme">/</div>`);
- $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="refreshList();">${shortenLongFoldername(pathInfo[l-1], 60)}</div>`);
- }else if (l == 3){
- $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="parentDir();">${shortenLongFoldername(pathInfo[l-2], 40)}</div>`);
- $(".pathDisplay").append(`<div class="divider ${currentTheme} whiteTheme">/</div>`);
- $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="refreshList();">${shortenLongFoldername(pathInfo[l-1], 60)}</div>`);
- }else if (l == 2){
- //E.g. user:/Desktop or user:/
- $(".pathDisplay").append(`<div class="section ${currentTheme} selectable" onclick="refreshList();">${shortenLongFoldername(pathInfo[1], 80)}</div>`);
- }
- }
- function shortenLongFoldername(name, maxchar = 20){
- var resultname = name;
- if (name.length > maxchar){
- //Shorten it
- var offset = parseInt((maxchar - 2) / 2);
- resultname = name.substr(0, offset) + "..." + name.substr(name.length - offset)
- }
- return resultname
- }
- function getExtFromPath(path){
- if (path.includes(".") == false){
- return "";
- }
- return path.split(".").pop();
- }
- function getFileObjectFromFID(fid){
- var targetFileObject = null;
- $(".fileObject").each(function(){
- if ($(this).attr("fileid") == fid){
- targetFileObject = $(this);
- }
- });
- return targetFileObject;
- }
- function openViaButton(){
- let fileOpenList = [];
- let foldersToBeOpened=[];
- $(".fileObject.selected").each(function(){
- let type = $(this).attr("type");
- let filepath = $(this).attr("filepath");
- if (type == "file"){
- fileOpenList.push(filepath);
- }else if (type == "folder"){
- foldersToBeOpened.push(filepath);
- }
- });
- //Open files
- openPathWithDefaultOpener(fileOpenList);
- //Open folders
- openFolderInNewWindow(foldersToBeOpened);
- }
- function openthis(object,evt=null){
- if (evt !== null){
- evt.preventDefault();
- }
- var objType = $(object).attr("type");
- if ( objType == "file"){
- //Open this file. Generate the access path from filepath
- var filepath = $(object).attr("filepath");
- //Only one path to be opened. Pass in as a single object array
- openPathWithDefaultOpener([filepath]);
- }else if (objType == "folder"){
- //Open this folder
- var folderPath = $(object).attr('filepath');
- listDirectory(folderPath, function(){
- //Scroll to top of the list
- $("#folderView").stop().finish().animate({
- scrollTop: 0
- }, 300);
- if ($(object).hasClass('dir') && isMobile){
- toggleSidebar();
- }
- });
- }else if (objType == "shortcut"){
- //Load the shortcut information
-
- getShortcutInfo($(object).attr('filepath'), function(shortcutInfo){
- /*
- Shortcut Info format
- 0: Shortcut type
- 1: Shortcut Name
- 2: Shortcut target
- 3: Shortcut icon image
- */
- if (shortcutInfo[0] == "module"){
- //This is a module
- if (ao_module_virtualDesktop){
- //Open Module with VDI API
- parent.openModule(shortcutInfo[2]);
- }else{
- //Open module in new tab
- $.get("../../system/modules/getLaunchPara?module=" + shortcutInfo[2], function(data) {
- window.open("../../" + data.StartDir);
- });
- }
- }else if (shortcutInfo[0] == "folder"){
- //This is a folder
- listDirectory(shortcutInfo[2]);
- }else if (shortcutInfo[0] == "url"){
- //This is a url shortcut
- window.open(shortcutInfo[2]);
- }
- console.log(shortcutInfo);
- });
-
-
- }
- //Check if this opened in sidebar and in mobile mode. Close sidebar if yes
-
- }
- /*
- Shortcut Info format
- 0: Shortcut type
- 1: Shortcut Name
- 2: Shortcut target
- 3: Shortcut icon image
- */
- function getShortcutInfo(filepath, callback){
- $.get("../../media?file=" + filepath, function(data){
- //This return the shortcut information. Split it and see what shortcut is this
- data = data.split("\r\n").join("\n");
- var shortcutInfo = data.trim().split("\n");
- callback(shortcutInfo);
- });
- }
- //Download the selected files.
- function downloadFile(){
- var fileList = [];
- if ($(".fileObject.selected").length == 1 && $(".fileObject.selected").attr("type") == "file"){
- //One file. Download directly.
- var downloadURL = "/media?file=" + encodeURIComponent($(".fileObject.selected").attr("filepath")) + "&download=true";
- var filename = $(".fileObject.selected").attr("filename");
- generateDownloadFromURL(downloadURL,escape(filename));
- }else if ($(".fileObject.selected").length > 1 || ($(".fileObject.selected").length == 1 && $(".fileObject.selected").attr("type") == "folder")){
- //Do zip and download for multiple files
- $(".fileObject.selected").each(function(){
- fileList.push($(this).attr("filepath"));
- });
- console.log("Zipping: ", fileList);
- //Add a display for file compression
- var fileCount = $(".fileObject.selected").length;
-
- var displayString = "Zipping " + fileCount + " files";
- if (fileCount == 1){
- //Use the filename as task name
- displayString = "Zipping " + $(".fileObject.selected").attr("filename");
- }
-
- var taskUUID = appendUploadFileItem(displayString, -1);
- $("#uploadTab").show();
- //Set the progress bar to intermediate mode
- let targetTaskDisplayObject = getUploadTaskByID(taskUUID);
- targetTaskDisplayObject.find(".progress").addClass("preparing");
- //Zip the file or folder
- $.ajax({
- url: "../../system/file_system/zipHandler",
- data: {opr: "tmpzip", src: JSON.stringify(fileList), dest: ""},
- method: "POST",
- success: function(data){
- if (data.error !== undefined){
- //Error
- targetTaskDisplayObject.find(".progress").removeClass("preparing").removeClass("primary").addClass("negative");
-
- msgbox("remove",data.error);
- }else{
- //Zip completed.
- targetTaskDisplayObject.find(".progress").removeClass("preparing").removeClass("primary").addClass("positive");
- //Open the zip file
- window.open("../../media?file=" + data + "&download=true");
- }
-
- targetTaskDisplayObject.find(".bar").css("width", "100%");
- //Hide the taskbar after 5 secs
- setTimeout(function(){
- //Fade out this task
- $(targetTaskDisplayObject).fadeOut('fast',
- function(){
- $(this).remove();
- if ($(".uploadTask").length == 0){
- $("#uploadTab").hide();
- }
- }
- );
-
- }, 3000);
-
- },
- error: function(){
- targetTaskDisplayObject.find(".progress").removeClass("preparing").removeClass("primary").addClass("negative");
- targetTaskDisplayObject.find(".bar").css("width", "100%");
- msgbox("remove","Zipping failed due to unknown reason");
- setTimeout(function(){
- if ($(".uploadTask").length == 0){
- $("#uploadTab").hide();
- }
- }, 3000);
- }
- });
-
- }else{
- alert("No file selected!")
- }
-
- }
- //Create a new file
- function newfile(){
- $(".popup").fadeOut('fast');
- showPopupWrapper();
- $("#newFile").fadeIn('fast');
- $("#newFile").find(".duplicateWarning").hide();
- $("#createNewFileName").parent().removeClass("error");
- //Update the newfile list
- $("#newFile").find(".newfilelist").html("");
- $.ajax({
- url: "../../system/file_system/newItem",
- success: function(data){
- if (data.error !== undefined){
- return;
- }
- for (var i =0; i < data.length; i++){
- var desc = data[i].Desc;
- var ext = data[i].Ext;
- var icon = ao_module_utils.getIconFromExt(ext);
- $("#newFile").find(".newfilelist").append(`<div class="item newFileFormat" ext="${ext}"><i class="${icon} icon" style="margin-right:12px;"></i> ${desc}</div>`);
- }
- //Initialize the new file as txt
- var filename = "newfile";
- var finalFilename = filename;
- var i = 0;
- while (currentFilelist.includes(finalFilename)){
- finalFilename = finalFilename + "(" + i + ")";
- i++;
- }
- $("#createNewFileName").val(finalFilename + ".txt");
- //Hook events for on click
- $(".newFileFormat").off("click").on("click",function(data){
- $(".newFileFormat").removeClass("selected");
- $(this).addClass("selected");
- //Parse the newfilename
- var selectedExt = $(this).attr("ext");
- var filename = "newfile";
- var finalFilename = filename;
- var i = 0;
- while (currentFilelist.includes(finalFilename)){
- finalFilename = finalFilename + "(" + i + ")";
- i++;
- }
- $("#createNewFileName").val(filename + "." + selectedExt);
- });
- }
- });
- }
- function filePermission(){
- //Open file permission window
- if ($(".fileObject.selected").length > 0){
- //Build the filelist
- var fileList = [];
- $(".fileObject.selected").each(function(){
- var filepath = $(this).attr("filepath");
- fileList.push(filepath);
- });
- var hashPassthrough = encodeURIComponent(JSON.stringify(fileList));
- ao_module_newfw({
- url: "SystemAO/file_system/file_permission.html#" + hashPassthrough,
- width: 340,
- height: 480,
- appicon: "SystemAO/file_system/img/properties.png",
- title: "File Permissions",
- })
- }
- }
- function newFolder(confirmed = false){
- if (confirmed == false){
- //Launch the dialog for newFolder
- $(".popup").fadeOut(100);
- $("#createNewFolder").val("");
- $("#createNewFolder").parent().removeClass("error").removeClass("success");
- $("#newFolder").find(".duplicateWarning").hide();
- showPopupWrapper();
- $("#newFolder").fadeIn(100);
- }else{
- //Create new folder
- var newFoldername = $("#createNewFolder").val();
- if (newFoldername == ""){
- $("#createNewFolder").parent().addClass("error");
- return;
- }
- if (currentFilelist.includes(newFoldername)){
- //Current filelist already contain a folder with the same name
- $("#createNewFolder").parent().addClass("error");
- $("#newFolder").find(".duplicateWarning").show();
- return;
- }
- //OK to proceed.
- $("#createNewFolder").parent().removeClass("error").addClass("success");
- $("#newFolder").find(".duplicateWarning").hide();
- $.ajax({
- url: "../../system/file_system/newItem",
- data: {type: "folder", src: currentPath, filename: newFoldername},
- success: function(data){
- if (data.error !== undefined){
- msgbox("remove", data.error);
- }else{
- msgbox("checkmark","New folder created.");
- refreshList();
- }
- $("#newFolder").fadeOut('fast');
- hideAllPopupWindows();
- if (currentPath == "user:/"){
- //Reload the User root folder list
- initRootDirs();
- }
- }
- });
- }
- }
- function confirmNewFile(){
- var filename = $("#createNewFileName").val();
- if (filename == ""){
- //Filename not set
- $("#createNewFileName").parent().addClass("error");
- return;
- }else if(currentFilelist.includes(filename)){
- //File with this name already exists
- $("#createNewFileName").parent().addClass("error");
- $("#newFile").find(".duplicateWarning").show();
- return;
- }
- $("#createNewFileName").parent().removeClass("error");
- //Ok to proceed
- $.ajax({
- url: "../../system/file_system/newItem",
- data: {type: "file", src: currentPath, filename:filename},
- success: function(data){
- if (data.error !== undefined){
- msgbox("remove",data.error);
- }else{
- msgbox("checkmark",filename + " created.");
- refreshList();
- }
- }
- });
- hideAllPopupWindows();
- $("#newFile").fadeOut('fast');
- }
- //Open File Location
- function openFileLocation(){
- var folders = [];
- $(".selected.fileObject").each(function(){
- var thisFilepath = $(this).attr('filepath');
- var thisFilename = $(this).attr('filename');
- openPathInNewWindow(encodeURIComponent(JSON.stringify([{
- filename: thisFilename,
- filepath: thisFilepath
- }])))
- });
-
- }
- //OpenWith dialog
- function openWith(){
- if ($(".selected.fileObject").length == 0){
- msgbox("question","No file selected");
- return;
- }
- //Get a list of modules and append it into the selection list
- $.get("../../system/modules/list",function(data){
- if (data.error !== undefined){
- console.log(data.error);
- }else{
- $("#openWithModuleList").html("");
- for (var i =0; i < data.length; i++){
- var thisModule = data[i];
- var supportFW = `<div class="ts horizontal mini label"><i class="checkmark icon"></i>floatWindow Window</div>`;
- var supportEmb = `<div class="ts horizontal mini label"><i class="checkmark icon"></i>Embedded Window</div>`;
- if (!thisModule.SupportFW){
- supportFW = "";
- }
- if (!thisModule.LaunchEmb){
- supportEmb = "";
- }
- var launchInfo = encodeURIComponent(JSON.stringify(thisModule));
- $("#openWithModuleList").append(`<div class="item selectable openWithModule" launchInfo="${launchInfo}" onclick="selectOpenWithModule(this, event);" ondblclick="selectOpenWithModule(this, event); openWithSelectedModule();">
- <img class="ts avatar image" src="../../${thisModule.IconPath}">
- <div class="content" style="padding-left:12px;">
- <div class="header">${thisModule.Name}</div>
- <div class="description">
- ${supportFW}
- ${supportEmb}
- </div>
- </div>
- </div>`);
- }
- }
- });
- $(".openWithModule.popupbuttons").addClass("disabled");
- if (!ao_module_virtualDesktop){
- $("#openWith").find(".vdonly").hide();
- }
- showPopupWrapper();
- $("#openWith").fadeIn('fast');
- }
- //Functions for handling open with module selection and file opening
- function selectOpenWithModule(object, event){
- event.preventDefault();
- $(".openWithModule.popupbuttons").removeClass("disabled");
- $(".openWithModule.selected").removeClass("selected");
- $(object).addClass("selected");
- }
- function openWithSelectedModule(btn){
- if ($(btn).hasClass("disabled")){
- return false;
- }
- var targetModuleInfo = JSON.parse(decodeURIComponent($(".openWithModule.selected").attr("launchInfo")));
- var targetObjects = $(".selected.fileObject");
- console.log(targetModuleInfo);
- //Phrase launch mode from the module info
- var launchURL = targetModuleInfo.StartDir
- var launchSize = [undefined, undefined];
- var iconPath = targetModuleInfo.IconPath;
- var title = targetModuleInfo.Name;
- if (targetModuleInfo.SupportEmb){
- //Launch with embedded mode
- launchURL = targetModuleInfo.LaunchEmb;
- if (targetModuleInfo.InitEmbSize !== null){
- launchSize = targetModuleInfo.InitEmbSize
- }
-
- }else if (targetModuleInfo.SupportFW){
- //Launch with floatWindow mode
- launchURL = targetModuleInfo.LaunchFWDir;
- if (targetModuleInfo.InitFWSize !== null){
- launchSize = targetModuleInfo.InitFWSize
- }
- }else if (targetModuleInfo.StartDir !== ""){
- //Launch with default mode
- }else{
- msgbox("remove","This module has no endpoint for opening a file.");
- return;
- }
- //Parse the filelist
- var filelist = [];
- $(targetObjects).each(function(){
- var filename = $(this).attr("filename");
- var filepath = $(this).attr("filepath");
- filelist.push({
- filename: filename,
- filepath: filepath
- });
- });
- fileHash = encodeURIComponent(JSON.stringify(filelist));
- if (ao_module_virtualDesktop){
- //Open the target module in a new fw
- parent.newFloatWindow({
- url: launchURL + "#" + fileHash,
- width: launchSize[0],
- height: launchSize[1],
- appicon: iconPath,
- title: title
- });
- }else{
- //Redirect current window to the target module
- window.location.href = "../../" + launchURL + "#" + fileHash;
- }
- hideAllPopupWindows();
- }
- function openFileWithModuleInNewTab(btn){
- if ($(btn).hasClass("disabled")){
- return false;
- }
- var targetModuleInfo = JSON.parse(decodeURIComponent($(".openWithModule.selected").attr("launchInfo")));
- var targetObjects = $(".selected.fileObject");
- //Parse the filelist
- var filelist = [];
- $(targetObjects).each(function(){
- var filename = $(this).attr("filename");
- var filepath = $(this).attr("filepath");
- filelist.push({
- filename: filename,
- filepath: filepath
- });
- });
- //Directly passing the file information to the startdir
- fileHash = encodeURIComponent(JSON.stringify(filelist));
- window.open("../../" + targetModuleInfo.StartDir + "#" + fileHash);
- hideAllPopupWindows();
- }
- function openRawFileInFloatWindow(btn){
- //Directly open this (or more than one) files / folder in floatWindow
- var targetObjects = $(".selected.fileObject");
- $(targetObjects).each(function(){
- if ($(this).attr("type") == "file"){
- var launchURL = "media?file=" + $(this).attr('filepath');
- parent.newFloatWindow({
- url: launchURL,
- appicon: "img/system/file.png",
- title: $(this).attr('filename'),
- "background-color": "#1f1f1f"
- });
- }else if ($(this).attr("type") == "folder"){
- var launchURL = "SystemAO/file_system/file_explorer.html#" + $(this).attr("filepath");
- parent.newFloatWindow({
- url: launchURL,
- appicon: "SystemAO/file_system/img/small_icon.png",
- title: "File Manager - " + $(this).attr('filename'),
- });
- }else{
- //Not supported openeing type.
- console.log("Failed to open file " + $(this).attr('filepath') + " . WIP")
- }
- });
- hideAllPopupWindows();
- }
- //Open the filepaths in the given paramters
- function openPathWithDefaultOpener(filepaths){
- console.log("Opening: ", filepaths);
- for (var i =0; i < filepaths.length; i++){
- let filepath = JSON.parse(JSON.stringify(filepaths[i]));
- var ext = "." + filepath.split(".").pop();
- $.ajax({
- url: "../../system/modules/getDefault",
- method: "GET",
- data: {opr: "launch", ext: ext, mode: "launch"},
- success: function(data){
- if (data.error !== undefined){
- //No default opener assigned. Launch it with opener selector
- var url = "SystemAO/file_system/defaultOpener.html";
- var icon = "SystemAO/file_system/img/opener.png";
- var title = "Select an opener WebApp: "
- var openFileList = [];
- var openFileObject = {
- filepath: filepath,
- filename: filepath.split("/").pop()
- }
- openFileList.push(openFileObject);
- var openParamter = encodeURIComponent(JSON.stringify(openFileObject));
- var ao_module_virtualDesktop = !(!parent.isDesktopMode);
- console.log(window.innerHeight/2 - 510/20);
- if (ao_module_virtualDesktop){
- parent.newFloatWindow({
- url: url + "#" + openParamter,
- width: 320,
- height: 510,
- appicon: icon,
- title: title
- });
- }else{
- url = "defaultOpener.html";
- window.open(url + "#" + openParamter);
- }
- }else{
- //Assigned. Launch with given paramter
- var url = data["StartDir"];
- var size = [undefined, undefined];
- var title = data["Name"];
- var icon = "img/system/favicon.png";
- if (data["IconPath"] != ""){
- icon = data["IconPath"];
- }
- //Use floatWindow if exists
- if (data["SupportFW"] == true && data["LaunchFWDir"] != ""){
- url = data["LaunchFWDir"];
- if (data["InitFWSize"] !== null){
- size = data["InitFWSize"]
- }
- }
- //Use embedded mode if exists
- if (data["SupportEmb"] == true && data["LaunchEmb"] != ""){
- url = data["LaunchEmb"];
- if (data["InitEmbSize"] !== null){
- size = data["InitEmbSize"]
- }
- }
- //Build open File Hash Data Format
- var openFileList = [];
- var openFileObject = {
- filepath: filepath,
- filename: filepath.split("/").pop()
- }
- openFileList.push(openFileObject);
- var openParamter = encodeURIComponent(JSON.stringify(openFileList));
-
- //Add launch files info and launch floatWindow
- var ao_module_virtualDesktop = !(!parent.isDesktopMode);
- if (ao_module_virtualDesktop){
- parent.newFloatWindow({
- url: url + "#" + openParamter,
- width: size[0],
- height: size[1],
- appicon: icon,
- title: title
- });
- }else{
- window.open("../../" + url + "#" + openParamter);
- }
-
- }
- }
- });
- }
- }
- function openSelectedFolderInNewWindow(){
- $(".fileObject.selected").each(function(){
- if ($(this).attr("type") == "folder"){
- console.log($(this).attr('filepath'));
- openPathInNewWindow([$(this).attr('filepath')]);
- }
- })
- }
- function openSelectedVroot(){
- $("#storageroot").find(".dir.item").each(function(){
- if ($(this).hasClass("active")){
- var thisRootPath = $(this).attr('filepath');
- openPathInNewWindow([$(this).attr('filepath')]);
- }
- });
- }
- //Always open the first object locally, and open others in new floatWindows
- function openFolderInNewWindow(paths){
- if (paths.length > 0){
- listDirectory(paths[0]);
- for (var i = 1; i < paths.length; i++){
- //newFloatWindow(location.href.replace(location.hash,"") + "#" + path[i])
- openPathInNewWindow(paths[i]);
- }
- }
- }
- function openPathInNewWindow(path){
- console.log("Opening in new File Maanger: ", window.location.pathname + "#" + path);
- ao_module_newfw({
- url: window.location.pathname + "#" + path,
- appicon: "SystemAO/file_system/img/small_icon.png",
- title: "File Manager",
- width: 1080,
- height: 580,
- parent: ao_module_windowID,
- });
- }
- //Preference setting and loading functions.
- function setPreference(key, value){
- $.ajax({
- url:"../../system/file_system/preference?key=" + key + "&value=" + value,
- success: function(data){
- if (data.error !== undefined){
- console.log(data);
- }
- }
- });
- }
- function loadPreference(key, callback){
- $.get("../../system/file_system/preference?key=" + key,function(data){
- callback(data);
- });
- }
- // ============================== WINDOW RESIZE FUNCTIONS =====================
- $(document).ready(function(data){
- if (window.innerWidth < 620 && !isMobile){
- toggleSidebar(false);
- }
- initWindowSizes(false);
- });
- $(window).on("resize",function(){
- initWindowSizes(false);
- if (!isMobile && window.innerWidth < 620 && sideBarShown == true){
- toggleSidebar(false);
- }else if (!isMobile && window.innerWidth > 650 && sideBarShown == false){
- toggleSidebar(false);
- }
- if (isMobile){
- refreshList();
- }
- });
- function handleShareFilebuttonClick(event, object){
- event.preventDefault();
- event.stopImmediatePropagation();
- $(".fileObject.selected").removeClass("selected");
- if (viewMode == "list"){
- $(object).parent().parent().addClass("selected");
- }else if (viewMode == "grid"){
- $(object).parent().parent().parent().addClass("selected");
- }
-
- shareFile();
- }
-
- function shareFile(){
- var selectedFiles = [];
- $(".fileObject.selected").each(function(){
- var thisFilepath = $(this).attr("filepath");
- selectedFiles.push(thisFilepath);
- });
- if (selectedFiles.length != 1){
- //Try to share more than 1 files, which is not supported
- console.log("Multi share is current not supported");
- return
- }
- //OK! Continue to generate link
- var selectedFile = selectedFiles[0];
- shareEditingObject = selectedFile;
- $.ajax({
- url: "../../system/file_system/share/new",
- data: {path: selectedFile},
- success: function(data){
- if (data.error !== undefined){
- alert(data.error);
- }else{
- //Build the predicted share endpoint
- let protocol = "https://";
- if (location.protocol !== 'https:') {
- protocol = "http://";
- }
- //Continue to render QR Code and UI contents
- $("#qrcode").html("");
- var shareURL = protocol + window.location.hostname + ":" + window.location.port + "/share?id=" + data.UUID;
- shareEditingUUID = data.UUID;
- new QRCode(document.getElementById("qrcode"), shareURL);
- $("#sharelink").text(shareURL);
- $("#sharelink").attr("href", shareURL);
- $(".shareoption").parent().removeClass("disabled");
- $("#sharingRemoveBtn").show();
- //Check the correct checkbox
- var tagetCheckbox = data.Permission;
- if (tagetCheckbox == "anyone"){
- $("#anyone")[0].checked = true;
- }else if (tagetCheckbox == "signedin"){
- $("#signedin")[0].checked = true;
- }else if (tagetCheckbox == "samegroup"){
- $("#samegroup")[0].checked = true;
- }
- //Show the share file interface
- $(".popup").fadeOut('fast');
- showPopupWrapper();
- $("#shareFile").fadeIn("fast");
- //Reload the list
- listDirectory(currentPath);
- }
-
- }
- });
-
- }
- function removeSharing(){
- if (shareEditingObject == ""){
- return
- }
- //The target file to remove
- var selectedFile = shareEditingObject;
- $.ajax({
- url: "../../system/file_system/share/delete",
- data: {path: selectedFile},
- success: function(data){
- console.log(data);
- $("#qrcode").html(`<img src="img/private.png">`);
- $(".shareoption").parent().addClass("disabled");
- $("#sharelink").text("(Sharing Removed)");
- $("#sharelink").removeAttr("href");
- $("#sharingRemoveBtn").hide();
- //Reload the current filelist and hide the share interface
- listDirectory(currentPath);
- //Reset sharing file settings
- shareEditingObject = ""
- shareEditingUUID = ""
- }
- });
- }
- function updateShareSettings(object){
- $(object).addClass("loading");
- var shareMode = $("#shareSettingForm [name='shareopt']:checked").val();
- $.ajax({
- url: "../../system/file_system/share/edit",
- data: {uuid: shareEditingUUID, mode: shareMode},
- success: function(data){
- if (data.error !== undefined){
- alert(data.error);
- }
- $(object).removeClass("loading");
- $(object).html(`<i class="checkmark icon"></i> Updated`);
- $(object).addClass("positive");
- setTimeout(function(){
- $(object).html("Update");
- $(object).removeClass("positive");
- }, 3000);
- }
- })
- }
- function hideShare(){
- hideAllPopupWindows();
- }
- function toggleSidebar(useAnimation=true){
- //Fixing desktop bugs on showing the sidebar
- if (isMobile){
- $("#directorySidebar").stop().finish().animate({left: "toggle"},200);
- }else{
- if ($("#directorySidebar").offset().left < 0){
- $("#directorySidebar").stop().finish().animate({left: 0},200);
- }else{
- $("#directorySidebar").stop().finish().animate({left: -1 * directorySidebarWidth},200);
- }
- }
-
- sideBarShown = !sideBarShown;
- initWindowSizes(useAnimation);
- }
- function initWindowSizes(animate=true){
- var h = $("#navibar").css("height");
- var hint = $("#navibar").height();
- //$("#mainWindow").css("padding-top",h);
- var windowHeight = window.innerHeight - hint - 12;
- //console.log(windowHeight);
- if (sideBarShown){
- //Resize the sidebar
- $("#directorySidebar").css("top",h);
- $("#directorySidebar").css("width",directorySidebarWidth);
- $("#directorySidebar").css("height",windowHeight + "px");
- //Resize the file viewer
- $("#folderView").css("top",h);
- if (window.innerWidth > 650){
- if (animate){
- $("#folderView").stop().finish().animate({
- left: directorySidebarWidth + 'px',
- width: window.innerWidth - directorySidebarWidth - 2 + "px"
- },200);
- }else{
- $("#folderView").css({
- left: directorySidebarWidth + 'px',
- width: window.innerWidth - directorySidebarWidth - 2 + "px"
- });
- }
- }else{
- //Window width too small to allow resizing sidebar shown. Overlap it
- if (animate){
- $("#folderView").stop().finish().animate({
- left: directorySidebarWidth + 'px',
- width: window.innerWidth + "px"
- },200);
- }else{
- $("#folderView").css({
- left: directorySidebarWidth + 'px',
- width: window.innerWidth + "px"
- });
- }
- }
-
- if (isChromium){
- //$("#mainWindow").css("height", window.innerWidth);
- }
- //$("#folderView").css("left",directorySidebarWidth + "px");
- $("#folderView").css("height",windowHeight + "px");
- }else{
- $("#folderView").css("top",h);
- if (animate){
- $("#folderView").stop().finish().animate({
- left:'0px',
- width:(window.innerWidth - 2 + "px")
- },200);
- }else{
- $("#folderView").css({
- left:'0px',
- width:(window.innerWidth - 2 + "px")
- });
- }
- $("#folderView").css("height",windowHeight + "px");
-
- }
- }
- function toggleDarkTheme(){
- if ($(".darkTheme").length > 0){
- //Set To Whitetheme
- $(".darkTheme").removeClass("darkTheme").addClass("whiteTheme");
- currentTheme = "whiteTheme";
- $("#darkthemebtn").attr("class","moon icon");
- $("#darkthemebtn").parent().addClass("inverted");
- $(".dropdown").removeClass("inverted");
- setPreference("file_explorer/theme","whiteTheme");
- //If in vdi mode, update desktop's listMenu as well
- if (ao_module_virtualDesktop){
- parent.initTheme("whiteTheme");
- }
-
- }else{
- //Set to DarkTheme
- $(".whiteTheme").removeClass("whiteTheme").addClass("darkTheme");
- currentTheme = "darkTheme";
- $("#darkthemebtn").attr("class","sun icon");
- $("#darkthemebtn").parent().removeClass("inverted");
- $(".dropdown").addClass("inverted");
- setPreference("file_explorer/theme","darkTheme");
- //If in vdi mode, update desktop's listMenu as well
- if (ao_module_virtualDesktop){
- parent.initTheme("darkTheme");
- }
- }
-
- }
- function msgbox(icon, text){
- $($(".msgbox").find("span")[0]).text(text);
- $($(".msgbox").find("i")[0]).attr("class", icon + " icon");
- $(".msgbox").stop().finish().slideDown('fast').delay(3000).slideUp('fast');
- }
- //Keyboard hotkey events
- $(document).keydown(function(event){
- if ($(':focus').is("input")){
- //Do not block operations on input fields.
- return;
- }
- if(event.which==17 || event.which == 91){
- ctrlHold = true;
- }else if (event.which == 16){
- shiftHold = true;
- }else if (event.which == 67 && ctrlHold == true){
- //Ctrl + C
- if (!$(".popup").is(":visible")){
- event.preventDefault();
- copy();
- }
- }else if (event.which == 88 && ctrlHold == true){
- //Ctrl + X
- if (!$(".popup").is(":visible")){
- event.preventDefault();
- cut();
- }
- }else if (event.which == 65 && ctrlHold == true){
- //Ctrl + A
- event.preventDefault();
- $(".fileObject").addClass("selected");
- }else if (event.which == 78 && shiftHold == true){
- //Shift + N, Open new file manager window with current path
- event.preventDefault();
- openPathInNewWindow(currentPath);
- }else if (event.which == 86 && ctrlHold == true){
- if (!$(".popup").is(":visible")){
- paste();
- }
- }else if (event.which == 46 && shiftHold == true){
- //Shift + delete
- forceDelete();
- }else if (event.which == 46){
- //Delete
- deleteFile();
- }else if (event.which == 38){
- //Up Arrow
- if ($(".popup:visible").length == 0){
- //No popup visiable
- if (ctrlHold == true){
- //Parenet path
- parentDir();
- }else{
- //Select the file on the upper
- selectPreviousFile(event);
- }
- }
- }else if (event.which == 40){
- //Down arrow
- if ($(".popup:visible").length == 0){
- //No popup visiable
- selectNextFile(event);
- }
- }else if (event.which == 39){
- //Right arrow
- if ($(".popup:visible").length == 0 && viewMode == "grid"){
- //No popup visiable and grid mode
- selectRightFile(event);
- }
- }else if (event.which == 37){
- //Left arrow
- if ($(".popup:visible").length == 0 && viewMode == "grid"){
- //No popup visiable and grid mode
- selectLeftFile(event);
- }
- }else if (event.which == 13){
- //Enter key
- if ($(".fileObject.selected").length > 0){
- openViaButton();
- }
- }else if (event.which == 27){
- //Esc key
- hideAllPopupWindows();
- $(".fileObject.selected").removeClass("selected");
- }else{
- //console.log(event.which);
- }
- });
- $(document).keyup(function(event){
- if(event.which==17 || event.which == 91){
- ctrlHold = false;
- }else if (event.which == 16){
- shiftHold = false;
- }
- });
- $("#directorySidebar").on("click",function(evt){
- //Clear the button holding
- $(".fileObject.selected").removeClass("selected");
- shiftHold = false;
- ctrlHold = false;
- });
- //Check if localstorage is availble
- function lscheck(){
- var test = 'test';
- try {
- localStorage.setItem(test, test);
- localStorage.removeItem(test);
- return true;
- } catch(e) {
- return false;
- }
- }
- function selectNextFile(e){
- e.preventDefault();
- //Check if there are no selection. If yes, select the first file object
- if ($(".fileObject.selected").length == 0 && $(".fileObject").length > 0){
- //Select the first file object
- $($(".fileObject")[0]).addClass("selected");
- return
- }else if ( $(".fileObject").length == 0){
- //No file in this folder
- return
- }
- //Already contain selected file on the interface. Seleect it
- var baseObject = $($(".fileObject.selected")[0]);
- if ($(".fileObject.selected").length > 1){
- $(".fileObject.selected").removeClass("selected");
- }
- if (viewMode == "list"){
- //Select the next file
- var nextObject = $(".fileObject").eq( $(".fileObject").index( $(baseObject) ) + 1 );
- if (nextObject.length > 0){
- nextObject.addClass("selected");
- scrollToFileObject(nextObject);
- $(baseObject).removeClass("selected");
- }
- }else if (viewMode == "grid"){
- var colobj = getFileObjectInTheSameCol(baseObject);
- var nextObject = baseObject;
- for (var i = 0; i < colobj.length; i++){
- if ($(colobj[i]).hasClass("selected") && i != colobj.length - 1){
- nextObject = colobj[i + 1];
- }
- }
- $(baseObject).removeClass("selected");
- nextObject.addClass("selected");
- scrollToFileObject(nextObject);
- }
- }
- function selectPreviousFile(e){
- e.preventDefault();
- //Check if there are no selection. If yes, select the first file object
- if ($(".fileObject.selected").length == 0 && $(".fileObject").length > 0){
- //Select the first file object
- $($(".fileObject")[$(".fileObject").length - 1]).addClass("selected");
- return
- }else if ( $(".fileObject").length == 0){
- //No file in this folder
- return
- }
- var baseObject = $($(".fileObject.selected")[0]);
- if ($(".fileObject.selected").length > 1){
- $(".fileObject.selected").removeClass("selected");
- }
- if (viewMode == "list"){
- //Select the previous file
- if ($(".fileObject").index( $(baseObject) ) -1 < 0){
- return;
- }
- var previousObject = $(".fileObject").eq( $(".fileObject").index( $(baseObject) ) -1 );
- if (previousObject.length > 0){
- previousObject.addClass("selected");
- scrollToFileObject(previousObject);
- $(baseObject).removeClass("selected");
- }
-
-
- }else if (viewMode == "grid"){
- var colobj = getFileObjectInTheSameCol(baseObject);
- var prevObj = baseObject;
- for (var i = 0; i < colobj.length; i++){
- if ($(colobj[i]).hasClass("selected") && i > 0){
- prevObj = colobj[i - 1];
- }
- }
- $(baseObject).removeClass("selected");
- prevObj.addClass("selected");
- scrollToFileObject(prevObj);
- }
- }
- function scrollToFileObject(fileObject){
- if (viewMode == "grid"){
- $('#folderView').scrollTop($(fileObject)[0].offsetTop - ($("#directorySidebar").height()/2 - 340));
- }else{
- $('#folderView').scrollTop($(fileObject)[0].offsetTop - ($("#directorySidebar").height()/2 - 140));
- }
- }
- //Grid mode left right opr
- function selectLeftFile(e){
- e.preventDefault();
- if (viewMode != "grid"){
- return;
- }
- if ($(".fileObject.selected").length == 0 && $(".fileObject").length > 0){
- //Select the first file object
- $($(".fileObject")[$(".fileObject").length - 1]).addClass("selected");
- return
- }else if ( $(".fileObject").length == 0){
- //No file in this folder
- return
- }
- var baseObject = $($(".fileObject.selected")[0]);
- if ($(".fileObject").index( $(baseObject) ) -1 < 0){
- return;
- }
- var previousObject = $(".fileObject").eq( $(".fileObject").index( $(baseObject) ) -1 );
- if (previousObject.length > 0){
- previousObject.addClass("selected");
- scrollToFileObject(previousObject);
- $(baseObject).removeClass("selected");
- }
- }
- function selectRightFile(e){
- e.preventDefault();
- if (viewMode != "grid"){
- return;
- }
-
- if ($(".fileObject.selected").length == 0 && $(".fileObject").length > 0){
- //Select the first file object
- $($(".fileObject")[0]).addClass("selected");
- return
- }else if ( $(".fileObject").length == 0){
- //No file in this folder
- return
- }
- var baseObject = $($(".fileObject.selected")[0]);
- var nextObject = $(".fileObject").eq( $(".fileObject").index( $(baseObject) ) + 1 );
- if (nextObject.length > 0){
- nextObject.addClass("selected");
- scrollToFileObject(nextObject);
- $(baseObject).removeClass("selected");
- }
- }
- //Functions for getting file objects in the same collume
- function getFileObjectInTheSameCol(baseFileObject){
- if (viewMode != "grid"){
- return;
- }
- var baseOffset = $(baseFileObject).offset().left;
- var fileObjectInTheSameCol = [];
- $(".fileObject").each(function(){
- if ($(this).offset().left == baseOffset){
- let thisFileObject = $(this);
- fileObjectInTheSameCol.push(thisFileObject);
- }
- });
- return fileObjectInTheSameCol;
- }
- //Function for getting file objects in the same row
- function getFileObjectInTheSameRow(baseFileObject){
- if (viewMode != "grid"){
- return;
- }
- var baseOffset = $(baseFileObject).offset().top;
- var fileObjectInTheSameRow = [];
- $(".fileObject").each(function(){
- if ($(this).offset().top == baseOffset){
- let thisFileObject = $(this);
- fileObjectInTheSameRow.push(thisFileObject);
- }
- });
-
- return fileObjectInTheSameRow;
- }
- //Handle drag drop upload
- function drop(event){
- event.preventDefault();
- console.log(event, event.target)
- //Check if this is file upload or file move / copy function
- let dt = event.dataTransfer
- let files = dt.files
- if (files.length > 0){
- //Upload file via dragdrop
- msgbox("upload","Upload Started");
- let items = event.dataTransfer.items;
- for (let i=0; i<items.length; i++) {
- let item = items[i].webkitGetAsEntry();
- if (item) {
- recursiveScanFilesUpload(item);
- }
- }
-
- }else{
- //File transfer within system
- let filedata = event.dataTransfer.getData("filedata");
- if (filedata != ""){
- try{
- let fileList = JSON.parse(filedata);
- //Check if the file objects are from the same host
- let localFiles = [];
- let remoteFiles = [];
- fileList.forEach(file => {
- if (file.hostUUID == systemUUID){
- //Local file
- localFiles.push(file);
- }else{
- //Remote files
- remoteFiles.push(file);
- }
- });
- //Start processing the local files
- let currentVroot = currentPath.split(":/").shift();
- clipboard = [];
- //Assume all files are from the same directory
- if (localFiles.length > 0){
- //Check if drag drop from the same directory
- let currentDirname = currentPath.split("/")
- currentDirname.pop();
- currentDirname = currentDirname.join("/");
- let firstFileDirname = localFiles[0].filepath.split("/")
- firstFileDirname.pop();
- firstFileDirname = firstFileDirname.join("/");
- if (currentDirname == firstFileDirname){
- //Drag start and drop location are the same directory
- msgbox("remove","Source and destination file names are the same")
- return;
- }
- let fileVroot = localFiles[0].filepath.split(":/").shift();
- if (currentVroot == fileVroot){
- //Same device same root. Move the file
- cutMode = true;
- }else{
- //Same device differnet root. Copy the file
- cutMode = false;
- }
- //Move all localFiles into clipboard
- localFiles.forEach(file => {
- clipboard.push(file.filepath);
- });
- if (useLocalstorage){
- localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
- if (cutMode){
- localStorage.setItem("ao/file_system/cutmode","true");
- }else{
- localStorage.setItem("ao/file_system/cutmode","false");
- }
-
- }
- //Paste all the files to the current path
- console.log(clipboard);
- paste();
- }
-
-
- }catch(ex){
- console.log(ex);
- msgbox("remove","File drop failed. Unable to decode filelist.");
- }
- }
-
-
- }
-
- }
- function recursiveScanFilesUpload(item, rootpath="", base=""){
- var filesInside = [];
- if (item.isDirectory) {
- //This is a directory
- let directoryReader = item.createReader();
- directoryReader.readEntries(function(entries) {
- entries.forEach(function(entry) {
- recursiveScanFilesUpload(entry, rootpath + item.name + "/", base);
- });
- });
- }else{
- //This is a file. Upload it
- item.file(function(fileObject){
- if (isChrome || isSafari){
- //WebKits
- console.log("Upload Target", fileObject, rootpath);
- uploadFile(fileObject, undefined, currentPath + rootpath);
-
- }else{
- //Firefox. Special handling for root path.
-
- //Updates for Firefox 84.0.2 (64-bit), which changed minor implementation on relative path in folder updates
- //This section of code is deprecated since then
- /*
- //As firefox will keep its file input relative path, we need to remove the root folder
- //name from the rootpath passed in by the webkit API
-
- if (rootpath.substr(rootpath.length - 1, 1) == "/"){
- rootpath = rootpath.substr(0, rootpath.length - 1);
- }
- var rootpathInfo = rootpath.split("/");
- if (rootpathInfo.length > 1){
- //Uploading folder to folder. Extract the folder root name
- rootpathInfo.pop();
- }else{
- //Uploading file to folder. Do nothing
- }
- rootpath = rootpathInfo.join("/") + "/";
- console.log("Upload Target", fileObject, rootpath);
- uploadFile(fileObject, undefined, currentPath + rootpath);
- */
- console.log(currentPath + rootpath);
- uploadFile(fileObject, undefined, currentPath + base);
- }
-
- });
- }
- return filesInside;
- }
- function showCurrentDirectoryProperties(){
- var fileList = [currentPath];
- console.log(fileList);
- var hashPassthrough = encodeURIComponent(JSON.stringify(fileList));
- ao_module_newfw({
- url: "SystemAO/file_system/file_properties.html#" + hashPassthrough,
- width: 340,
- height: 480,
- appicon: "SystemAO/file_system/img/properties.png",
- title: "File Properties",
- });
- }
- function showVrootProperties(){
- var rootname = [$("#storageroot").find(".dir.item.active").attr("filepath")];
- var hashPassthrough = encodeURIComponent(JSON.stringify(rootname));
- ao_module_newfw({
- url: "SystemAO/disk/diskprop.html#" + hashPassthrough,
- width: 410,
- height: 580,
- appicon: "img/system/drive.svg",
- title: "Disk Properties",
- });
- }
- function openBackupManager(){
- var rootname = [$("#storageroot").find(".dir.item.active").attr("filepath")];
- var hashPassthrough = encodeURIComponent(JSON.stringify(rootname));
- ao_module_newfw({
- url: "SystemAO/disk/disk_restore.html#" + hashPassthrough,
- width: 410,
- height: 580,
- appicon: "img/system/backup.svg",
- title: "Backup & Restore",
- });
- }
- function showFileProperties(){
- //Show the file list of the selected files
- if ($(".fileObject.selected").length > 0){
- //Build the filelist
- var fileList = [];
- $(".fileObject.selected").each(function(){
- var filepath = $(this).attr("filepath");
- fileList.push(filepath);
- });
- var hashPassthrough = encodeURIComponent(JSON.stringify(fileList));
- ao_module_newfw({
- url: "SystemAO/file_system/file_properties.html#" + hashPassthrough,
- width: 340,
- height: 480,
- appicon: "SystemAO/file_system/img/properties.png",
- title: "File Properties",
- });
- }
-
- }
- function initUploadMode(){
- //Get the amount of RAM on the server side to check if low memory mode should be used.
- $.ajax({
- url: "../../system/info/getRAMinfo",
- success: function(data){
- if (data.error !== undefined){
- //Permission denied or other reasons that cannot access harwdare info. Use default mode
- lowMemoryMode = true;
- }else{
- //Check if ramsize > 1.8 GB (2GB). If yes, switch to large memory upload mode
- var memsize = JSON.parse(data);
- if (parseFloat(memsize)/ 1024 / 1024 / 1024 >= 3.8){
- console.log("[File Explorer] Entering large memory upload mode")
- lowMemoryMode = false;
- }
- }
- },
- error: function(){
- //Hardware mode disabled. Always use low memory upload mode instead
- lowMemoryMode = true;
- }
- });
- }
- let uploadBufferedRefreshTimer;
-
- function uploadFile(file, uuid=undefined, targetDir=undefined) {
- if (lowMemoryMode){
- /*
- Low Memory Upload Mode (Experimental)
- (For host with less than 2GB RAM)
- */
- var filename = encodeURIComponent(file.name);
- var filesize = file.size;
- //Generate a new file item
- let taskUUID = uuid; //For queueing objects
- if (taskUUID == undefined){
- //If this is a new file to be uploaded
- taskUUID = appendUploadFileItem(file.name, file.size);
- }
- //Push to upload pending list if the max concurrent upload is reached
- if (uploadingFileCount >= maxConcurrentUpload){
- let uploadDir = currentPath;
- if (targetDir !== undefined){
- uploadDir = targetDir;
- }else if (isFirefox && uploadDir == currentPath && file.webkitRelativePath != ""){
- //Use the webkitRelativePath instead of the name, this is a folder upload
- //Deprecated for Firefox 84.0.2 updates
- /*
- let pathinfo = file.webkitRelativePath.split("/");
- pathinfo.pop();
- let subpath = pathinfo.join("/");
- uploadDir = uploadDir + subpath;
- */
- uploadDir = targetDir;
- }
- uploadPendingList.push({
- File: file,
- UUID: taskUUID,
- TargetDir: JSON.parse(JSON.stringify(uploadDir)),
- });
- return
- }
- function updateProgressForWebSocketUpload(uuid, progress){
- $(".uploadTask").each(function(){
- if ($(this).attr("taskID") == uuid){
- //Update this progress bar
- $(this).find(".bar").css("width",progress + "%");
- if (progress == 100){
- //When progress = 100 and the server is not response with 200,
- //That means the upload has finish and server is processing the upload
- $(this).find(".progress").addClass("indeterminate");
- }
- }
- });
- }
- //Open the websocket
- let path = currentPath;
- let protocol = "wss://";
- if (location.protocol !== 'https:') {
- protocol = "ws://";
- }
- var port = window.location.port;
- if (window.location.port == ""){
- port = "80";
- }
- let uploadDir = currentPath;
- if (targetDir !== undefined){
- //Not uploading to current directory. Change upload path to target
- uploadDir = targetDir;
- }
- //Fixing Firefox path issues on or above FF48.0
- if (isFirefox && file.webkitRelativePath != ""){
- //Use the webkitRelativePath instead of the name, this is a folder upload
- let pathinfo = file.webkitRelativePath.split("/");
- pathinfo.pop();
- let subpath = pathinfo.join("/");
- uploadDir = uploadDir + subpath;
- //console.log("Firefox Mode: ", uploadDir, "Target Dir", targetDir)
- }
- let socket = new WebSocket(protocol + window.location.hostname + ":" + port + "/system/file_system/lowmemUpload?filename=" + filename + "&path=" + uploadDir);
- let currentSendingIndex = 0;
- let chunks = Math.ceil(file.size/uploadFileChunkSize,uploadFileChunkSize);
-
- //Define a function for sending a particular chunk
- function sendChunk(id){
- var offsetStart = id*uploadFileChunkSize;
- var offsetEnd = id*uploadFileChunkSize + uploadFileChunkSize;
- var thisblob = file.slice(offsetStart,offsetEnd);
- socket.send(thisblob);
- //console.log(id + "/" + chunks);
- //Update progress to first percentage
- var progress = id / (chunks-1) * 100.0;
- if (progress > 100){
- progress = 100;
- }
- updateProgressForWebSocketUpload(taskUUID, progress)
-
- }
- //Update all UI elements
- updateUploadFileCount();
- uploadingFileCount++;
- //Start sending
- socket.onopen = function(e) {
- if (filesize < uploadFileChunkSize){
- //This file is smaller than chunk size, set it to somwhere within 10% - 20% so it doesn't look like it is stuck
- updateProgressForWebSocketUpload(taskUUID, 10 + Math.floor(Math.random() * Math.floor(10)))
- }
-
- //Send the first chunk
- sendChunk(0);
- currentSendingIndex++;
- };
- socket.onmessage = function(event) {
- //Append to the send index
- var incomingValue = event.data;
- if (incomingValue == "next"){
- if (currentSendingIndex == chunks + 1){
- //Already finished
- socket.send("done");
- }else{
- //Send next chunk
- sendChunk(currentSendingIndex);
- currentSendingIndex++;
- }
-
- }else if (incomingValue == "OK"){
- //Merge completed
- $(".uploadTask").each(function(){
- if ($(this).attr("taskID") == taskUUID){
- //Update this progress bar to completed
- $(this).find(".bar").css("width","100%");
- $(this).find(".progress").attr("class","ts tiny positive progress");
- $(this).find(".uploadTaskRemoveIcon").show();
- $(this).addClass("ended");
- $.when($(this).delay(1000).fadeOut("fast")).then(function(){
- $(this).remove();
- updateUploadFileCount();
- });
-
- }
- });
- }else{
- //Try to parse it as JSON
- try{
- var resp = JSON.parse(incomingValue.split('\\' + '"').join("\""));
- console.log(resp);
- if (resp.error !== undefined){
- //This is an error message
- msgbox("remove",resp.error);
- //Update the progress bar to error
- $(".uploadTask").each(function(){
- if ($(this).attr("taskID") == taskUUID){
- //Update this progress bar to completed
- $(this).find(".bar").css("width","100%");
- $(this).find(".progress").attr("class","ts tiny negative progress");
- $(this).find(".uploadTaskRemoveIcon").show();
- $(this).addClass("ended");
- }
- });
- }
- }catch(ex){
- //Something else
- console.log(incomingValue);
- console.log(ex);
- }
- }
- };
- socket.onclose = function(event) {
- uploadingFileCount--;
- updateUploadFileCount();
- //After the previous file has uploaded / errored, check if there are another file needed to be uploaded
- setTimeout(function(){
- if (uploadPendingList.length > 0){
- let nextFile = uploadPendingList.shift();
- uploadFile(nextFile.File, nextFile.UUID, nextFile.TargetDir);
- }
- }, 100)
- };
- socket.onerror = function(error) {
- console.log(error.message);
- console.log("Unable to open WebSocket connection. Fall back to FORM POST upload mode. (Check your nginx / reverse proxy settings!!!)")
- //Try to fallback to FORM POST upload mode
- lowMemoryMode = false;
-
- uploadPendingList.push({
- File: file,
- UUID: taskUUID,
- TargetDir: JSON.parse(JSON.stringify(targetDir)),
- });
-
-
- return
- /*
- msgbox("caution","Upload failed due to unknown reason");
- //Something went wrong. Set the color to red
- $(".uploadTask").each(function(){
- if ($(this).attr("taskID") == taskUUID){
- //Update this progress bar to completed
- $(this).find(".bar").css("width","100%");
- $(this).find(".progress").attr("class","ts tiny negative progress");
- $(this).find(".uploadTaskRemoveIcon").show();
- $(this).addClass("ended");
- }
- });
- */
- };
- }else{
- /*
- Standard Upload Mode
- (For host with RAM >= 2GB)
- */
- //Create the task progress Object
- let taskUUID = uuid; //For queueing objects
- if (taskUUID == undefined){
- //If this is a new file to be uploaded
- taskUUID = appendUploadFileItem(file.name, file.size);
- }
-
- //Updates 22-10-2020
- //Added file upload queuing system to prevent too many request on-the-fly at the same time
- if (uploadingFileCount >= maxConcurrentUpload){
- //Push to upload pending list
- //Sometime files will be recursively uploaded (aka retry multiple time), hence the targetDir needed to be copied as well
- let uploadDir = currentPath;
- if (targetDir !== undefined){
- uploadDir = targetDir;
- }
- uploadPendingList.push({
- File: file,
- UUID: taskUUID,
- TargetDir: JSON.parse(JSON.stringify(uploadDir)),
- });
- return
- }
- //Prase upload Form
- let uploadCurrentPath = JSON.parse(JSON.stringify(currentPath));
- if (targetDir !== undefined){
- //The upload paramter supplied targetDir
- uploadCurrentPath = targetDir;
- }
- let url = '../../system/file_system/upload?path=' + uploadCurrentPath
- //console.log("Uploading To => ", uploadCurrentPath, targetDir, currentPath);
- let formData = new FormData()
- let xhr = new XMLHttpRequest()
- formData.append('file', file);
- formData.append('path', uploadCurrentPath);
- xhr.open('POST', url, true)
- xhr.upload.addEventListener("progress", function(e) {
- var progress = (e.loaded * 100.0 / e.total) || 100;
- $(".uploadTask").each(function(){
- if ($(this).attr("taskID") == taskUUID){
- //Update this progress bar
- $(this).find(".bar").css("width",progress + "%");
- if (progress == 100){
- //When progress = 100 and the server is not response with 200,
- //That means the upload has finish and server is processing the upload
- $(this).find(".progress").addClass("indeterminate");
- }
- }
- });
- })
- xhr.addEventListener('readystatechange', function(e) {
- if (xhr.readyState == 4 && xhr.status == 200) {
- //Upload process ended
- //Update task status
- $(".uploadTask").each(function(){
- if ($(this).attr("taskID") == taskUUID){
- //Update this progress bar to completed
- $(this).find(".bar").css("width","100%");
- $(this).find(".progress").attr("class","ts tiny positive progress");
- $(this).find(".uploadTaskRemoveIcon").show();
- $(this).addClass("ended");
- //Update 15-11-2020
- //Remove this taskbar after 3 secounds to prevent lags during > 2000 uploads
- $.when($(this).delay(1000).fadeOut("fast")).then(function(){
- $(this).remove();
- updateUploadFileCount();
- });
-
- }
- });
- var resp = JSON.parse(e.target.response);
- if (resp.error !== undefined){
- msgbox("caution",resp.error);
- //Something went wrong. Set the color to red
- $(".uploadTask").each(function(){
- if ($(this).attr("taskID") == taskUUID){
- //Update this progress bar to completed
- $(this).find(".bar").css("width","100%");
- $(this).find(".progress").attr("class","ts tiny negative progress");
- $(this).find(".uploadTaskRemoveIcon").show();
- $(this).addClass("ended");
- }
- });
- }
- uploadingFileCount--;
- //After the previous file has uploaded / errored, check if there are another file needed to be uploaded
- setTimeout(function(){
- if (uploadPendingList.length > 0){
- let nextFile = uploadPendingList.shift();
- uploadFile(nextFile.File, nextFile.UUID, nextFile.TargetDir);
- }
- }, 100)
-
- }else if (xhr.readyState == 4 && xhr.status != 200) {
- msgbox("remove","File too big or the target disk is fulled");
- console.log(xhr);
- $(".uploadTask").each(function(){
- if ($(this).attr("taskID") == taskUUID){
- //Upload screwed up. Show negative
- $(this).find(".progress").attr("class","ts tiny negative progress");
- $(this).find(".uploadTaskRemoveIcon").show();
- $(this).addClass("ended");
- }
- });
- uploadingFileCount--;
- //After the previous file has uploaded / errored, check if there are another file needed to be uploaded
- setTimeout(function(){
- if (uploadPendingList.length > 0){
- let nextFile = uploadPendingList.shift();
- uploadFile(nextFile.File, nextFile.UUID, nextFile.TargetDir);
- }
- }, 100)
- }
-
- updateUploadFileCount();
- })
- xhr.send(formData);
- uploadingFileCount++;
- updateUploadFileCount();
- }
- }
- //Clear all finished upload tasks
- function clearAllUploadTask(){
- $(".uploadTask.ended").slideUp('300',function(){
- $(this).remove();
- updateUploadFileCount();
- });
-
- }
- var searchMode = false;
- function toggleSearch(){
- //Start search mode
- $(".searchbar").slideDown("fast", function(){
- initWindowSizes(true);
- });
- $("#searhbtn").addClass("disabled");
- //Force videmode to list
- viewMode = "list"
- $(".videmode.button").each(function(){
- $(this).addClass('disabled');
- });
- searchMode = true;
- //Clear current folderlist
- $("#folderList").show();
- $("#folderList").html(`<div class="ts basic segment ${currentTheme}">
- <div class="ts header">
- <i class="arrow up icon ${currentTheme}"></i> <span class="${currentTheme}">Type to Start Search</span>
- <div class="sub header ${currentTheme}" style="margin-top:12px;">Type something in the search bar to start searching.<br>
- Start wildcard matching with "/" (slash) and your wildcard string (e.g. /*.mp3)</div>
- </div>
- </div>`);
- $("#fileList").hide();
- }
- function hideSearchBar(skipFilelistRefresh = false){
- $(".searchbar").slideUp("fast", function(){
- initWindowSizes(true);
- });
- $("#searchInput").val("");
- $("#searhbtn").removeClass("disabled");
- $(".videmode.button").each(function(){
- if ($(this).attr("mode") != "list"){
- $(this).removeClass('disabled');
- }
- });
- if (skipFilelistRefresh == false){
- listDirectory(currentPath);
- }
- searchMode = false;
- }
-
- //Handle case sensitive in keyword searching
- function toggleCaseSensitive(btn){
- if ($(btn).hasClass("active")){
- $(btn).removeClass("active");
- searchCaseSensitive = false;
- }else{
- $(btn).addClass("active");
- searchCaseSensitive = true;
- }
- }
- function handleSearch(){
- var keyword = $("#searchInput").val();
- $("#folderList").html(`<div class="ts basic segment ${currentTheme}">
- <i class="loading spinner icon ${currentTheme}"></i> <span class="${currentTheme}">Searching</span>
- </div>`);
- $("#fileList").hide();
- $("#fileList").html("");
-
- $.ajax({
- url: "../../system/file_system/search",
- data: {path: currentPath, keyword: keyword, casesensitive: searchCaseSensitive},
- success: function(data){
- if (data.error !== undefined){
- msgbox("remove", data.error);
- }else{
- //Render the filelist
- console.log(data);
- if (data.length == 0){
- $("#folderList").show();
- $("#folderList").html(`<div class="ts basic segment ${currentTheme}">
- <div class="ts header ${currentTheme}">
- <i class="question icon" ${currentTheme}></i> <span class="${currentTheme}">No Matching Results</span>
- <div class="sub header ${currentTheme}">The host return no matching results for your keyword "${keyword}". <br>Check your spelling and if your wildcard are valid.</div>
- </div>
- </div>`);
- }else{
- renderDirectory(data);
- }
-
- }
- }, error: function(){
- $("#folderList").html(`<div class="ts basic segment">
- <div class="ts header">
- <i class="remove icon"></i> Search Error
- <div class="sub header">Search timeout has occurred during file searching.</div>
- </div>
- </div>`);
- }
- })
- }
- function handleSearchBarPress(e){
- if (e.keyCode == 13){
- e.preventDefault();
- handleSearch();
- }
- }
- function toggleCtrl(){
- ctrlHold = !ctrlHold;
- }
- function getUploadTaskByID(taskUUID){
- var task = undefined;
- $("#uploadTab").find(".uploadTask").each(function(){
- if ($(this).attr("taskid") == taskUUID){
- task = $(this);
- }
- });
- return task;
- }
- function appendUploadFileItem(filename, filesize){
- var newuuid = uuidv4();
- var humanReadableFilesize = 0;
- if (filesize < 0){
- humanReadableFilesize = "Unknown Size"
- }else{
- humanReadableFilesize = bytesToSize(filesize);
- }
-
- $("#uploadProgressList").append(`<div class="uploadTask" taskID="${newuuid}">
- <p style="width: calc(100% - 15px);">${filename} (${humanReadableFilesize})</p>
- <div class="ts tiny primary progress" style="margin-top:-12px;">
- <div class="bar" style="width: 0%"></div>
- </div>
- <div class="uploadTaskRemoveIcon" onclick="removeThisTask(this);" style="display:none;">
- <i class="remove icon"></i>
- </div>
- </div>`);
- return newuuid;
- }
- function removeThisTask(object){
- $(object).parent().fadeOut('fast',
- function(){
- $(this).remove();
- updateUploadFileCount();
- }
- );
-
- }
- function toggleUploadList(){
- $("#uploadProgressList").toggle();
- if ($("#uploadProgressList").is(":visible")){
- $("#hideUploadButton").html('<i class="caret down icon"></i>');
- }else{
- $("#hideUploadButton").html('<i class="caret up icon"></i>');
- }
- }
- function updateUploadFileCount(){
- $("#uploadCount").text(uploadingFileCount);
- $("#waitingCount").text(uploadPendingList.length);
- if (uploadingFileCount == 0 && $(".uploadTask").length == 0){
- $("#uploadTab").hide();
- }else{
- $("#uploadTab").show();
- }
- }
- function bytesToSize(bytes) {
- var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
- if (bytes == 0) return '0 Byte';
- var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
- return Math.round(bytes / Math.pow(1024, i) * 100, 2) / 100 + ' ' + sizes[i];
- }
- function uuidv4() {
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
- var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
- return v.toString(16);
- });
- }
- function dropToFolder(event){
- event.preventDefault();
- event.stopImmediatePropagation();
- console.log("Drop to folder detected");
- //Extract target folder path from object
- var targetPath = $(event.target).attr("filepath");
- if (targetPath == ""){
- return
- }
-
- //Check if this is upload or file move drag
- var files = event.dataTransfer.files;
- if (files.length > 0){
- //Upload mode. Extract the target folder basename from path
- if (targetPath.substr(targetPath.length -1,1) == "/"){
- targetPath = targetPath.substr(0, targetPath.length-1);
- }
- var folderBase = targetPath.split("/").pop() + "/";
- var items = event.dataTransfer.items;
- for (let i=0; i<items.length; i++) {
- let item = items[i].webkitGetAsEntry();
- if (item) {
- recursiveScanFilesUpload(item, folderBase, folderBase);
- }
- }
- }else if (event.dataTransfer.getData("filedata") != ""){
- var targetVroot = targetPath.split(":/").shift();
- //Get the source files
- var filelist = JSON.parse(event.dataTransfer.getData("filedata"));
- if (filelist.length > 0){
- var srcVroot = filelist[0].filepath.split(":/").shift();
- if (srcVroot == targetVroot){
- //Use move mode
- cutMode = true;
-
- }else{
- //Use copy mode
- cutMode = false;
- }
- //Parse the filelist
- clipboard = [];
- filelist.forEach(file=>{
- clipboard.push(file.filepath);
- });
- if (useLocalstorage){
- localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
- localStorage.setItem("ao/file_system/cutmode","true");
- }
-
- //Perform operations
- paste(targetPath, false)
- }
- }
- }
- function allowDrop(event){
- event.preventDefault();
- }
- $(".popupWrapper").on("click",function(){
- hideAllPopupWindows();
- });
- function hideAllPopupWindows(){
- $(".popup").fadeOut(100);
- $(".popupWrapper").fadeOut(100);
- $('body').css("overflow","");
- }
- function showPopupWrapper(){
- $(".popupWrapper").fadeIn('fast');
- $('body').css("overflow","hidden");
- }
- //Handle keydown of enter on certain input boxes
- function handleEnterKeyDown(event, handler){
- if (event.which == 13){
- handler();
- }
- }
- //Generate a download link and press it
- function generateDownloadFromURL(url, filename){
- let a = document.createElement('a')
- a.href = url;
- a.download = filename;
- document.body.appendChild(a)
- a.click()
- document.body.removeChild(a)
- }
- //Update sorting method for file listing
- function updateSortingMethods(){
- var method = $("#sortingMethodSelector").val();
- sortMode = method;
- refreshList();
- }
- function requestCSRFToken(callback){
- $.ajax({
- url: "../../system/csrf/new",
- success: function(token){
- callback(token);
- }
- })
- }
- </script>
- </body>
- </html>
|