file_explorer.html 220 KB

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