12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888 |
- <html>
- <head>
- <title>ArozOS Desktop</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="stylesheet" href="script/tocas/tocas.css">
- <link id="fwcss" rel="stylesheet" href="script/ao.css">
- <link rel="stylesheet" href="SystemAO/desktop/script/jsCalendar/source/jsCalendar.css">
- <script type="text/javascript" src="script/tocas/tocas.js"></script>
- <script type="text/javascript" src="script/jquery.min.js"></script>
- <script type="text/javascript" src="script/ao_module.js"></script>
- <script type="text/javascript" src="SystemAO/desktop/script/jsCalendar/source/jsCalendar.js"></script>
- <style>
- body {
- background-repeat: no-repeat;
- background-size: cover;
- background-position: center;
- background-image: url('img/desktop/bg/init.jpg');
- width: 100%;
- height: 100%;
- }
-
- .backgroundFrame {
- height: 100%;
- min-width: 100%;
- background-repeat: no-repeat;
- background-size: cover;
- border: 0px solid transparent;
- background-position: center;
- position: absolute;
- opacity: 0;
- top: 0;
- left: 0;
- -webkit-transition: opacity 2s ease-in-out;
- -moz-transition: opacity 2s ease-in-out;
- -o-transition: opacity 2s ease-in-out;
- transition: opacity 2s ease-in-out;
- }
-
- .background-wrapper {
- border: 0px solid transparent;
- overflow: hidden;
- width: 100%;
- height: 100%;
- position: fixed;
- left: 0px;
- top: 0px;
- user-select: none;
- -moz-user-select: none;
- -webkit-user-drag: none;
- -webkit-user-select: none;
- -ms-user-select: none;
- }
-
- .showBackground {
- opacity: 1;
- }
-
- .icon-wrapper {
- height: 100%;
- width: 100%;
- position: fixed;
- top: 0px;
- left: 0px;
- padding: 5px;
- }
-
- .launchIcon {
- position: fixed;
- cursor: pointer;
- padding: 2px;
- }
-
- .launchIconImage.small {
- width: 48px;
- height: 48px;
- }
-
- .launchIconImage.medium {
- width: 68px;
- height: 68px;
- }
-
- .launchIconImage.big {
- width: 82px;
- height: 82px;
- }
-
- .launchIconWrapper {
- height: 100%;
- width: 100%;
- border-radius: 3px;
- }
-
- .launchIconWrapper.selected {
- background: rgba(250, 250, 250, 0.4) !important;
- }
-
- .launchIconText {
- color: white;
- text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
- text-align: center;
- text-overflow: ellipsis;
- overflow: hidden;
- word-break: break-all;
- width: 100%;
- font-variant-numeric: tabular-nums lining-nums;
- }
-
- .launchIconWrapper:hover {
- background: rgba(250, 250, 250, 0.2);
- }
-
- .launchIconText.small {
- margin-top: -3px;
- font-size: 70%;
- line-height: 1.55em;
- /*
- Fixed the issue of text being trimmed off due to lineheight setting
- */
- font-family: sans-serif !important;
- }
-
- .launchIconText.medium {
- margin-top: -2px;
- font-size: 90%;
- line-height: 1.2em;
- }
-
- .launchIconText.big {
- margin-top: -6px;
- font-size: 110%;
- }
-
- .navimenu {
- position: fixed;
- z-index: 1110;
- width: 100%;
- height: 36px;
- left: 0px;
- bottom: 0px;
- padding-left: 8px;
- padding-right: 8px;
- }
- /* Connection loss indicator */
- #connectionLost{
- position: fixed;
- z-index: 1000;
- right: 1em;
- top: calc(30px + 1em);
- display: none;
- }
- #connectionLost .ts.card{
- box-shadow: none;
- border: 0px solid transparent;
- }
- /* Theme Color css settings */
- .themeColor {
- background-color: rgba(14,14,14,0.5);
- backdrop-filter: blur(4px);
- }
- .themeColorSolid{
- background-color: rgba(14,14,14,0.9);
- backdrop-filter: blur(4px);
- }
-
- .navimenu .item {
- height: 36px;
- display: inline-block;
- vertical-align: top;
- }
-
- .navimenu .item.padding {
- display: inline-block;
- width: 12px;
- }
-
- .navimenu .item.clickable:hover {
- background-color: rgba(250, 250, 250, 0.2);
- cursor: pointer;
- }
- /* Floatwindow control button related css*/
-
- .navimenu .item.floatWindowButton {
- padding: 8px;
- padding-top: 10px;
- vertical-align: top;
- width: 200px;
- overflow: hidden;
- font-size: 90%;
- text-overflow: ellipsis;
- white-space: nowrap;
- word-break: break-all;
- color: white;
- }
-
- .navimenu .item.floatWindowButton .floatWindowAppIcon {
- height: 20px;
- margin-top: -2px;
- margin-right: 8px;
- display: inline-block;
- }
-
- .navimenu .item.floatWindowButton .floatWindowTitle {
- display: inline;
- color: white;
- padding-top: 5px;
- vertical-align: top;
- }
-
- .navimenu .item.floatWindowButton.hideText {
- width: 36px;
- }
-
- .navimenu .item.floatWindowButton.hideText .floatWindowTitle {
- display: none;
- }
-
- .navimenu .item.floatWindowButton.hideText .floatWindowAppIcon {
- margin-right: 0px;
- }
-
- #fwdragpanel {
- position: fixed;
- width: 100%;
- height: 100%;
- top: 0px;
- left: 0px;
- z-index: 100;
- display: none;
- }
- #tfwdragpanel{
- position: fixed;
- width: 100%;
- height: 100%;
- top: 0px;
- left: 0px;
- z-index: 500;
- display: none;
- }
-
- #stackedWindowList {
- position: fixed;
- z-index: 1112;
- left: 0px;
- bottom: 36px;
- width: 300px;
- padding-bottom: 4px;
- display: none;
- }
-
- #stackedWindowList .item {
- padding: 6px;
- display: inline-block;
- color: white;
- width: 100%;
- }
-
- #stackedWindowList .item img {
- display: inline-block;
- vertical-align: bottom;
- width: 20px;
- height: 20px;
- margin-right: 12px;
- margin-top: 0px;
- margin-left: 4px;
- }
-
- #stackedWindowList .item span {
- overflow: hidden;
- word-break: break-all;
- text-overflow: ellipsis;
- white-space: nowrap;
- width: calc(100% - 4px);
- }
-
- #stackedWindowList .item.clickable:hover {
- background-color: rgba(250, 250, 250, 0.2);
- cursor: pointer;
- }
-
- #stackedWindowList .item .closebtn {
- position: absolute;
- right: 0px;
- top: 8px;
- }
-
- #stackedWindowList .item .closebtn>img {
- height: 15px;
- width: 15px;
- }
-
- #listMenu {
- position: fixed;
- bottom: 36px;
- left: 0px;
- height: 500px;
- width: 400px;
- background-color: #fcffff;
- box-shadow: 3px 3px 5px 0px rgba(207, 207, 207, 0.37);
- z-index: 1113;
- }
- #listMenu.darkTheme{
- background-color: #242330;
- color: white;
- -webkit-box-shadow: 7px -6px 7px -1px rgba(92,92,92,0.2);
- -moz-box-shadow: 7px -6px 7px -1px rgba(92,92,92,0.2);
- box-shadow: 7px -6px 7px -1px rgba(92,92,92,0.2);
- }
-
- #listMenu .searchBar{
- width: 100%;
- border-bottom: 2px solid #34b7eb;
- }
- #listMenu.darkTheme .searchBar input{
- background-color: #17161f !important;
- color: white !important;
- border: 1px solid #17161f;
- }
-
- #listMenu .listItemWrapper {
- overflow: hidden;
- }
-
- #listMenu .listItemWrapper .groups {
- background-color: #f5f5f5;
- width: 120px;
- height: 457px;
- display: inline-block;
- overflow-y: auto;
- padding-top: 8px;
- }
- #listMenu.darkTheme .listItemWrapper .groups {
- background-color: #17161f;
- color: white;
- }
-
- #listMenu .listItemWrapper .groups .item {
- padding-left: 7px;
- padding-bottom: 6px;
- padding-top: 6px;
- cursor: pointer;
- }
-
- #listMenu .listItemWrapper .groups .item.selected {
- color: #34b7eb;
- }
-
- #listMenu .listItemWrapper .groups .item:hover {
- background-color: #dedede;
- }
- #listMenu.darkTheme .listItemWrapper .groups .item:hover {
- background-color: #242330;
- }
-
- #listMenu .listItemWrapper .items {
- height: 457px;
- width: calc(100% - 120px - 5px);
- display: inline-block;
- overflow-y: auto;
- padding-top: 8px;
- box-shadow: -2px 0px 5px 0px rgba(194, 194, 194, 0.5);
- vertical-align: top;
- }
- #listMenu.darkTheme .listItemWrapper .items {
- box-shadow: 0px 0px 0px 0px transparent;
- }
-
- #listMenu .listItemWrapper .items .item {
- padding-left: 12px;
- padding-top: 8px;
- padding-bottom: 8px;
- cursor: pointer;
- }
-
- #listMenu .listItemWrapper .items .item:hover {
- background-color: #f5f5f5;
- }
- #listMenu.darkTheme .listItemWrapper .items .item:hover {
- background-color: #17161f !important;
- margin-right: 5px;
- }
-
- #listMenu .listItemWrapper .items .item img {
- width: 26px;
- margin-right: 12px;
- vertical-align: middle;
- }
-
- #listMenu .poweroption {
- position: absolute;
- bottom: 0px;
- left: 0px;
- padding: 6px;
- padding-left: 7px;
- width: 100%;
- cursor: pointer;
- }
-
- #listMenu .poweroption:hover {
- background-color: #dedede;
- }
- #listMenu.darkTheme .poweroption:hover {
- background-color: #242330;
- }
-
- #contextmenu {
- position: fixed;
- z-index: 3000;
- left: 20px;
- top: 20px;
- }
-
- #contextmenu .item {
- padding: 0.6em 1em !important;
- }
-
- #subcontextmenu .item {
- padding: 0.6em 1em !important;
- }
-
- #selectionPanel {
- background-color: rgba(39, 108, 227, 0.3);
- border: 1px solid #276ce3;
- position: fixed;
- height: 100px;
- width: 100px;
- display: none;
- }
-
- .renameInput {
- background-color: white;
- border: 1px solid black;
- width: 100%;
- position: absolute;
- }
-
- .renameInput.big {
- bottom: 0px;
- left: 0px;
- font-size: 16px;
- line-height: 1;
- }
-
- .renameInput.medium {
- bottom: 8px;
- left: 0px;
- height: 32px;
- font-size: 12px;
- line-height: 1;
- }
-
- .renameInput.small {
- bottom: 3px;
- left: 0px;
- height: 24px;
- font-size: 11px;
- line-height: 1;
- }
- #statusbar{
- position:absolute;
- z-index:0;
- width:100%;
- height:28px;
- background-color: rgba(0,0,0,0.9);
- color:white;
- backdrop-filter: blur(4px);
- text-align:center;
- display: table;
- }
- .statusbarpadding{
- padding:4px;
- }
- .hostname{
- display: table-cell;
- text-align:left;
- width:100px;
- pointer-events:none;
- padding-left:18px;
- white-space: nowrap;
- user-select: none;
- }
- .quicktools{
- display: table-cell;
- text-align:right;
- width:45px;
-
- }
- .qtwrapper{
- padding:4px;
- padding-right: 8px;
- cursor:pointer;
- }
- .qtwrapper:hover{
- background-color: rgba(240,240,240,0.2);
-
- }
- .notificationbar{
- position: absolute;
- top:28px;
- width:100%;
- height: calc(100% - 28px);
- z-index:1114;
- }
- .notificationbar .content{
- background-color:white;
- margin-top:6px;
- margin-left: auto;
- margin-right: auto;
- width:30%;
- min-width:650px;
- height:400px;
- z-index:1115;
- padding: 3px;
- border-radius: 5px;
- }
- .notificationbar .cover{
- backdrop-filter: blur(2px);
- -webkit-backdrop-filter: blur(2px);
- position:absolute;
- top:0px;
- left:0px;
- width:100%;
- height: calc(100%);
- }
- @supports not (backdrop-filter: blur(2px)) {
- .notificationbar .cover{
- /*
- //Replaced with Javascript implementation on Firefox
- background-color: rgba(24,24,24,0.3);
- */
- }
-
- #bgwrapper{
- transition: all 0.5s ease;
- }
- #iconwrapper{
- transition: all 0.5s ease;
- }
- #navimenu{
- transition: all 0.5s ease;
- }
- }
- .notification .title{
- font-weight:bold;
- font-size:120%;
- }
- .notification .notifycontent{
- margin-top:-12px;
- }
- .notificationbar .clearall{
- position:absolute;
- top:0px;
- right:4px;
- cursor:pointer;
- }
- .nonotification{
- opacity: 0.3;
- pointer-events:none;
- position:absolute;
- margin-top:9em;
- width:100%;
- user-select: none;
- }
- .notification.object .closebtn{
- position:absolute;
- top:3px;
- right:3px;
- cursor:pointer;
- }
- .notification.object{
- padding-left:7px;
- border-left: 3px solid transparent;
- cursor:pointer;
- }
- .notification.object:hover{
- /*
- border-left: 3px solid #83D8FF;
- */
- }
- .blured{
- filter: blur(2px);
- }
- #quickAccessPanel{
- background-color:white;
- position:absolute;
- top:28px;
- right:4px;
- z-index:114;
- width:300px;
- border-radius: 10px;
- border-top-right-radius: 0px;
- border-top-left-radius: 0px;
- border: 1px solid #ebebeb;
- padding-top:8px;
- padding-bottom:8px;
- }
- #quickAccessPanel .item{
- padding-left:12px;
- padding-right:12px;
- padding-top:6px;
- padding-bottom:2px;
- cursor:pointer;
- border-left: 3px solid transparent;
- }
- #quickAccessPanel .item:hover{
- background-color:#fafafa;
- }
- /*
- Handle dark theme for the quick access panel
- */
- #quickAccessPanel.darkTheme{
- background-color: #242330;
- color: white;
- border: 1px solid transparent;
- -webkit-box-shadow: -5px 4px 7px -1px rgba(92,92,92,0.2);
- -moz-box-shadow: -5px 4px 7px -1px rgba(92,92,92,0.2);
- box-shadow: -5px 4px 7px -1px rgba(92,92,92,0.2);
- }
- #quickAccessPanel.darkTheme .item:hover{
- background-color:#17161f;
- }
- #quickAccessPanel.darkTheme .header{
- color: white;
- }
- #quickAccessPanel.darkTheme .progress{
- background-color: #0c0c0f;
- }
- #quickAccessPanel.darkTheme .header{
- color: white;
- }
- #quickAccessPanel.darkTheme .inverted.button{
- background-color: #17161f;
- border: 1px solid black;
- }
- .item.module{
- cursor:pointer;
- }
- .item.module:hover{
- background-color:#f5f5f5 !important;
- }
- .fileShareIndicator.small{
- position: absolute;
- top: calc(50% - 8px);
- left: 8px;
- height: 10px;
- width: 10px;
- }
- .fileShareIndicator.medium{
- position: absolute;
- top: calc(50% - 8px);
- left: 10px;
- height: 16px;
- width: 16px;
- }
- .fileShareIndicator.big{
- position: absolute;
- top: calc(50% - 8px);
- left: 12px;
- height: 18px;
- width: 18px;
- }
- .fileShareIndicator img{
- width: 100%;
- }
- /* Offline blinking warning css */
- @-moz-keyframes blink {
- 0% {
- opacity:1;
- }
- 50% {
- opacity:0;
- }
- 100% {
- opacity:1;
- }
- }
- @-webkit-keyframes blink {
- 0% {
- opacity:1;
- }
- 50% {
- opacity:0;
- }
- 100% {
- opacity:1;
- }
- }
- /* IE */
- @-ms-keyframes blink {
- 0% {
- opacity:1;
- }
- 50% {
- opacity:0;
- }
- 100% {
- opacity:1;
- }
- }
- /* Opera and prob css3 final iteration */
- @keyframes blink {
- 0% {
- opacity:1;
- }
- 50% {
- opacity:0;
- }
- 100% {
- opacity:1;
- }
- }
- .blink-image {
- -moz-animation: blink normal 2s infinite ease-in-out; /* Firefox */
- -webkit-animation: blink normal 2s infinite ease-in-out; /* Webkit */
- -ms-animation: blink normal 2s infinite ease-in-out; /* IE */
- animation: blink normal 2s infinite ease-in-out; /* Opera and prob css3 final iteration */
- }
- /*
- Z-index layering
- Layer -1 : Background Images
- Layer 0 - 99: Not focused tab
- Layer 100: Focused tab drag drop layer
- Layer 101: Focused Tab
- ...
- Layer 400 - 499: Non-focused top most FloatWindows
- Layer 500: Top Mot FloatWindow drag drop layer
- Layer 501: Top Most FloatWindow
- ...
- Layer 1000: Connection lost indicator
- ...
- Layer 1110: Navigation Bar
- Layer 1112: Stacked Window List
- Layer 1113: List Menu
- Layer 1114: Notification Bar background bluring layer
- Layer 1115: Notification Bar
- ...
- Layer 3000: contextmenu
- */
- </style>
- <script>
- //Force redirection if it is on mobile
- if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
- window.location.href = "mobile.system";
- }
- </script>
- </head>
- <body style="background-color:black;">
- <!-- Background frames-->
- <div id="bgwrapper" class="background-wrapper" allowdrop="true" ondrop="drop(event)" ondragstart="return false;" onclick="event.preventDefault(); hideAllContextMenus();" ondblclick="event.preventDefault();event.stopImmediatePropagation();" ondragover="allowDrop(event);"
- align="center" draggable="false">
- </div>
- <!-- Top Status Bar -->
- <div id="statusbar" align="center">
- <div class="hostname statusbarpadding">
- Welcome
- </div>
- <div class="clock statusbarpadding" style="display: table-cell; cursor:pointer; user-select: none;" onclick="toggleNotification();" ontouchstart="toggleNotification();">
- ArozOS Desktop
- </div>
- <div class="quicktools" onclick="showToolPanel();" ontouchend="showToolPanel();">
- <div class="qtwrapper">
- <i class="content icon"></i>
- </div>
- </div>
- </div>
- <!-- Calendar and Notification -->
- <div class="notificationbar" style="display:none;">
- <div class="content">
- <div id="notificationlist" style="width: calc(100% - 302px); padding:8px; margin-top:5px; padding-top:22px; overflow-y:auto; overflow-x:hidden; height: calc(100% - 12px);">
- <div class="nonotification">
- <h4 class="ts center aligned icon header">
- <i class="bell icon"></i>No Notification
- </h4>
- </div>
- <a class="clearall" onclick="clearAllNotification();">Clear All</a>
- </div>
- <div style="position:absolute; right:3px; top:3px; padding-top:8px;">
- <div class="ts header" style="padding-left:22px;">
- <div id="dayofweek" class="sub header"></div>
- <span id="largedate" style="font-size:120%;"></span>
- </div>
- <div class="auto-jsCalendar blue"></div>
- </div>
- </div>
- <div class="cover" onclick='toggleNotification("hide");' ontouchstart='toggleNotification("hide");'>
- </div>
- </div>
- <!-- Desktop icons-->
- <div id="iconwrapper">
-
- </div>
-
- <!-- Navigation Menu-->
- <div id="navimenu" class="navimenu themeColor">
- <div class="item clickable system" onclick="toggleListMenu();" ontouchstart="toggleListMenu();" >
- <img style="height:36px;" src="img/desktop/system_icon/list.png"></img>
- </div>
- <div class="item padding system"></div>
- </div>
- <!-- floatWindow dragging panel-->
- <div id="fwdragpanel"></div>
- <div id="tfwdragpanel"></div>
- <!-- Selection panel-->
- <div id="selectionPanel"></div>
- <!-- Stacked windows listing container-->
- <div id="stackedWindowList" class="themeColor"></div>
- <!-- List menu -->
- <div id="listMenu" class="" style="display:none;">
- <div class="searchBar" onkeydown="searchModule(event);">
- <div class="ts icon fluid input" style="border-radius: 0px !important;">
- <input id="searchBar" type="text" placeholder="Search">
- <i class="search icon"></i>
- </div>
- </div>
- <dib class="listItemWrapper">
- <div class="groups">
- <div id="searchResults" class="item" style="display:none;">Search Results</div>
- <div class="item groupType selected" group="All">All</div>
- <div class="item groupType" group="Media">Media</div>
- <div class="item groupType" group="Office">Office</div>
- <div class="item groupType" group="Download">Download</div>
- <div class="item groupType" group="Files">Files</div>
- <div class="item groupType" group="Internet">Internet</div>
- <div class="item groupType" group="System Settings">System Settings</div>
- <div class="item groupType" group="System Tools">System Tools</div>
- <div class="item groupType" group="Utilities">Utilities</div>
- <div class="item groupType" group="Other">Other</div>
- <div class="poweroption">
- <img id="powerIcon" style="width:18px; vertical-align: top; margin-right:4px;" src="img/system/power.svg"></img> Exit
- </div>
- </div>
- <div id="listMenuItem" class="items">
- </div>
- </dib>
- </div>
- <div id="contextmenu" class="ts tiny contextmenu visible" style="display:none;">
- </div>
- <div id="subcontextmenu" class="ts tiny contextmenu visible" style="display:none;">
- </div>
- <!-- Disconnected. Reconnecting interface -->
- <div id="connectionLost">
- <div class="ts inverted card themeColor" style="width: 300px; background-color: rgba(14,14,14,0.5);">
- <div class="content">
- <div class="header"><img class="ts mini image blink-image" style="vertical-align:bottom; padding-right: 0.5em;" src="SystemAO/desktop/icons/connlost.svg"> Connection Lost</div>
- <div class="description">
- Connection to server is lost. Please wait until this warning disappear before further operations.
- </div>
- </div>
- <div class="ts fluid bottom attached buttons">
- <button class="ts opinion button" onclick="handleManualCheckReconnect(this);">Check Again</button>
- <button class="ts secondary opinion button">Wait</button>
- </div>
- </div>
-
-
- </div>
- <div id="quickAccessPanel" class="" style="display:none;">
- <div class="ts small single line items">
- <div class="item">
- <div class="ts mini image">
- <img class="usericon" src="img/desktop/system_icon/user.svg">
- </div>
- <div class="content">
- <div id="username" class="header">User</div>
- <div class="meta">
- <div id="usergroups">@Users</div>
- </div>
- </div>
- <div class="actions">
- <div class="ts button" onclick="logout(); hideToolPanel();">
- <i class="log out icon"></i> Logout
- </div>
- </div>
- </div>
- </div>
- <div class="item" style="padding-bottom:12px;">
- <i class="volume up icon"></i> System Global Volume
- <div class="ts fluid small progress" style="margin-top:8px; cursor:pointer;" onclick="updateVolume(this,event);" >
- <div id="volumebar" class="bar" style="width: 0%; background-color:#52C9FF; cursor:pointer;"></div>
- </div>
- </div>
- <div class="item" id="settingButton" onclick="showSystemSettings(); hideToolPanel();" ontouchend="showSystemSettings(); hideToolPanel();">
- <i class="setting icon"></i> System Settings
- <!-- <div style="float:right;"><i class="caret right icon"></i></div> -->
- </div>
- <div class="item" onclick="fullscreen(); hideToolPanel();" ontouchend="fullscreen(); hideToolPanel();">
- <i class="maximize icon"></i> Toggle Fullscreen
- </div>
- <div class="ts divider"></div>
- <div class="item hardware" onclick="restart(); hideToolPanel();" ontouchend="restart(); hideToolPanel();">
- <i class="repeat icon"></i> Restart
- </div>
- <div class="item hardware" style="color:#b51d1d;" onclick="shutdown(); hideToolPanel();" ontouchend="shutdown(); hideToolPanel();">
- <i class="power icon"></i> Power Off
- </div>
- </div>
- <script>
- /*
- ArOZ Online Desktop Interface
- This script maintain the usability of the desktop environment.
- This is not identical to the previous Desktop environment used in ArOZ Online BETA.
- */
- //System environment variables
- var isDesktopMode = true;
- var loggingOut = false;
- //Desktop background related
- var desktopThemeList = []; //Storing the list of background installed
- var currentBackgroundList = []; //Current list of background files
- var currentUserTheme = ""; //The theme for current user.
- var backgroundCrossfadeInterval = 30000; //Time between the crossfade of each background image
- var nextSlideshowIndex = 0; //The next background image index to be shown
- var backgroundIntervalCounter; //The interval object for background changer
- var desktopThemeColor = ""; //The current desktop theme color, which renders to the status bar and suchs
- //Desktop icon realted
- var desktopIconSize = "medium"; //Size of desktop icons. Allow {small / medium / big}
- var desktopIconPack = "default"; //Desktop icon pack to be used. Located under desktop/file_icon/{pack-name}
- var desktopGrids = []; //Reference virtual grid for icons on desktop
- var iconSize = []; //Defined the icon size for the desktop icons
- var desktopFileList = []; //Temperature storage of desktop filenames
- var startDragRelatuve = []; //Relative location of where the icon being start dragging
- var iconOffsetXY = [0,20]; //Pixel to offset for the icon location
- //Float window related
- var focusedWindow;
- const maxWindowCount = 100;
- var movingWindow = false;
- var resizingWindow = false;
- var resizingEdgeID = 0; //Resizing edge. {0, 1, 2, 3, 4, 5} => None, Right, Right Bottom Corner, Bottom, Left Bottom Corner, Left
- var stackedFloatWindowListShwon = false;
- //Laucnh icon related
- var multiSelecting = false;
- var multiSelectionStartPoint = [-1, -1];
- var clickDownOffset = [-1, -1];
- var renameMode = false;
- var operationTargetLaunchIcon;
- //Document key bindings
- var ctrlHold = false;
- var shiftHold = false;
- //ListMenu Related Paramters
- var moduleInstalled = [];
- var listMenuShown = false;
- //Context Menu variables
- var menuStartLocation = [0, 0];
- //Input Method Editor objects
- window.ime = {
- handler: null,
- focus: null
- };
- //Upload related
- let uploadFileChunkSize = 1024 * 512; //512KB per chunk in low memory upload
- //Others
- var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
- var daysNames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
- var hostInfo = {};
- var userInfo = {};
- var hardwareman = false;
- var downloadMode = false;
- var lowMemoryMode = true;
- //Browser detection
- var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
- var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
- var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
- var isMacOS = (navigator.appVersion.indexOf("Mac")!=-1);
- //Initiation functions
- initDesktopTheme();
- initDesktopHostInfo();
- initDesktopUserInfo();
- initBackgroundSwitchingAnimation();
- //Commented for debug purpose
- initUploadMode();
- initModuleList();
- initDesktopIconPreference()
- initUserDefinedThemeColor();
- hookFloatWindowEvents();
- hookLaunchMenuEvents();
- initTheme();
- initStartupSounds();
- //Login cookie expire check
- setInterval(function() {
- checkConnection();
- }, 15000);
- function handleManualCheckReconnect(button){
- $(button).addClass("loading");
- checkConnection(undefined, function(status){
- let oldText = $(button).text();
- $(button).removeClass("loading");
- if (status == false){
- //Still unable to connect. Show cross icon
- $(button).html(`<i class="remove icon"></i>`);
- setTimeout(function(){
- //Restore its original text after 5 sec
- $(button).text(oldText);
- }, 5000);
- }
- });
- }
- function checkConnection(timeout=15000, callback=undefined){
- $.ajax({
- url: 'system/auth/checkLogin',
- success: function(data) {
- if (data == true) {
- //Continue session
- } else {
- //Session timeout. Redirect to system index
- loggingOut = true;
- window.location.href = "index.html";
- }
- $("#connectionLost").hide();
- document.title = hostInfo.Hostname;
- if (callback != undefined){
- callback(true);
- }
- },
- error: function(evt) {
- //Server closed or freezed?
- $("#connectionLost").show();
- document.title = "Reconnecting...";
- if (callback != undefined){
- callback(false);
- }
- },
- timeout: timeout
- });
- }
- //Keep the clock updated
- setInterval(function(){
- updateClockTime();
- },5000);
- updateClockTime();
- function updateClockTime(){
- var d = new Date();
- var display = monthNames[d.getMonth()] + " " + d.getDate() + " " + zeropad(d.getHours(),2) + ":" + zeropad(d.getMinutes(),2);
-
- if ($(".notification.object").length > 0){
- display += `<span style="color: #f54242; margin-left: 8px; float: center;"><i class="notice circle icon"></i></span>`;
- }
- $(".clock").html(display);
- var largedate = monthNames[d.getMonth()] + " " + d.getDate() + " " + d.getFullYear()
- $("#largedate").text(largedate);
- var dow = daysNames[d.getDay()];
- $("#dayofweek").text(dow);
- }
- function zeropad(n, width, z) {
- z = z || '0';
- n = n + '';
- return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
- }
- function showToolPanel(){
- $("#quickAccessPanel").slideToggle("fast");
- }
- function hideToolPanel(){
- $("#quickAccessPanel").slideUp("fast");
- }
- function initStartupSounds(){
- $.ajax({
- url: "../../system/desktop/preference",
- method: "GET",
- data: {preference: "startup-audio"},
- success: function(data){
- if (data == undefined || data == ""){
- return;
- }
- var currentGlobalVol = localStorage.getItem("global_volume");
- if (currentGlobalVol != null && currentGlobalVol != undefined && currentGlobalVol != ""){
-
- }else{
- currentGlobalVol = 0;
- }
- var audio = new Audio("media?file=" + data);
- audio.volume = currentGlobalVol;
- audio.play();
- }
- });
- }
- function initDesktopUserInfo(){
- $.get("system/desktop/user", function(data){
- if (data.error !== undefined){
- alert(data.error);
- }else{
- userInfo = data;
- if (data.IsAdmin == false){
- //Hide the power buttons
- $(".hardware").hide();
- }
- //Update the user tag
- $("#username").text(userInfo.Username);
- $("#usergroups").text("@" + userInfo.UserGroups.join("/"));
- $("#usergroups").attr("title",userInfo.UserGroups.join(" / "));
- if (data.UserIcon !== ""){
- $(".usericon").attr("src",data.UserIcon);
- }
- }
- });
- }
- function initDesktopHostInfo(){
- //Load the data into variable
- $.get("system/desktop/host",function(data){
- hostInfo = data;
-
- //Update the ui element as well
- $(".hostname").text(hostInfo.Hostname);
- document.title = hostInfo.Hostname;
- });
- //Setup volume bar
- var currentGlobalVol = localStorage.getItem("global_volume");
- if (currentGlobalVol != null && currentGlobalVol != undefined && currentGlobalVol != ""){
- $("#volumebar").css("width", currentGlobalVol * 100 + "%");
- }else{
- currentGlobalVol = 0;
- localStorage.setItem("global_volume",currentGlobalVol);
- }
- //Check if hardware management mode is enabled. Hide buttons if needed
- $.get("system/power/accessCheck",function(data){
- if (data == true){
- //Hardware management mode is on
- hardwareman = true;
- }else{
- //Hardware management mode is off
- $(".item.hardware").hide();
- hardwareman = false;
- }
- });
- }
- function toggleNotification(action=undefined){
- var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
- if (typeof action == "undefined"){
- $(".notificationbar").stop().finish().fadeToggle("fast", function(){
- if ($(this).is(":visible")){
- if (isFirefox){
- $("#bgwrapper").addClass("blured");
- $("#iconwrapper").addClass("blured");
- $("#navimenu").addClass("blured");
- $(".floatWindow").addClass("blured");
- $("#listMenu").addClass("blured");
- }
- }else{
- if (isFirefox){
- $("#bgwrapper").removeClass("blured");
- $("#iconwrapper").removeClass("blured");
- $("#navimenu").removeClass("blured");
- $(".floatWindow").removeClass("blured");
- $("#listMenu").removeClass("blured");
- }
- }
- });
- }else{
- if (action == "hide"){
- $(".notificationbar").stop().finish().fadeOut("fast");
- if (isFirefox){
- $("#bgwrapper").removeClass("blured");
- $("#iconwrapper").removeClass("blured");
- $("#navimenu").removeClass("blured");
- $(".floatWindow").removeClass("blured");
- $("#listMenu").removeClass("blured");
- }
-
- }else if (action == "show"){
- $(".notificationbar").stop().finish().fadeIn("fast");
- if (isFirefox){
- $("#bgwrapper").addClass("blured");
- $("#iconwrapper").addClass("blured");
- $("#navimenu").addClass("blured");
- $(".floatWindow").addClass("blured");
- $("#listMenu").addClass("blured");
- }
- }
- }
- }
- // ===================== LIST MENU EVENTS FUNCTIONS ===============
- function toggleListMenu() {
- $("#listMenu").stop().finish().animate({
- height: "toggle"
- }, 300, function() {
- if ($("#listMenu").offset().top == 0) {
- listMenuShown = false;
- } else {
- listMenuShown = true;
- }
- });
- }
- function initDesktopIconPreference() {
- getStorage("iconsize", function(catergory) {
- if (["small", "medium", "big"].includes(catergory)) {
- desktopIconSize = catergory;
- }
- refresh();
- hideAllContextMenus();
- });
- }
- function hideListMenu() {
- if (listMenuShown) {
- $("#listMenu").animate({
- height: "hide"
- }, 300);
- listMenuShown = false;
- }
- }
- function initModuleList() {
- $.ajax({
- url: "system/modules/list",
- success: function(data) {
- moduleInstalled = data;
- listModulesType("All");
- checkFileSystemAccess();
- //Hide the system setting button if access is denied
- var allowSettingAccess = false;
- moduleInstalled.forEach(thismod => {
- if (thismod.Name == "System Setting"){
- allowSettingAccess = true;
- }
- });
- if (!allowSettingAccess){
- $("#settingButton").hide();
- }
- }
- });
- }
- function hookLaunchMenuEvents(){
- $(".groupType").on("click touchstart",function(){
- moduleTypeButtonClicked(this);
- });
- $(".poweroption").on("click touchstart",function(){
- logout();
- });
- }
- function moduleTypeButtonClicked(object) {
- var groupType = $(object).attr("group");
- listModulesType(groupType);
- $(".groupType.selected").removeClass("selected");
- $(object).addClass("selected");
- $("#searchResults").slideUp('fast');
- $("#searchBar").val("");
- }
- function listModulesType(groupType) {
- var listingItems = [];
- if (groupType == "All") {
- //List all of the items
- for (var i = 0; i < moduleInstalled.length; i++) {
- if (moduleInstalled[i]["StartDir"] != "") {
- listingItems.push(moduleInstalled[i]);
- }
- }
- } else if (groupType == "Other") {
- var excludeList = ["Media", "Office", "Download", "Files", "Internet", "System Settings", "System Tools", "Utilities"];
- //List the Other groups
- for (var i = 0; i < moduleInstalled.length; i++) {
- if (excludeList.includes(moduleInstalled[i]["Group"]) == false && moduleInstalled[i]["StartDir"] != "") {
- console.log(moduleInstalled[i]["Group"]);
- listingItems.push(moduleInstalled[i]);
- }
- }
- } else {
- //List the given group
- for (var i = 0; i < moduleInstalled.length; i++) {
- if (moduleInstalled[i]["Group"] == groupType && moduleInstalled[i]["StartDir"] != "") {
- listingItems.push(moduleInstalled[i]);
- }
- }
- }
- //List the item to the listmenu
- $("#listMenuItem").html("");
- for (var i = 0; i < listingItems.length; i++) {
- var thisModule = listingItems[i];
- generateListMenuItem(thisModule);
- }
- if (listingItems.length == 0) {
- $("#listMenuItem").html(`<div class="item module"><span><img src="img/system/not found.png">No WebApp found</span></div>`)
- }
- }
- //Given a module information and generate a selectable item in the list menu
- function generateListMenuItem(thisModule) {
- var icon = thisModule["IconPath"];
- if (icon == "") {
- //Use default system icon
- icon = "img/system/service.png";
- }
- var name = thisModule["Name"];
- var startdir = thisModule["StartDir"];
- var fwsupport = "false";
- if (thisModule["SupportFW"]) {
- fwsupport = "true";
- }
- $("#listMenuItem").append(`<div class="item module" module="${name}" startdir="${startdir}" fw="${fwsupport}" onclick="openModuleFromMenu(this);" ontouchstart="openModuleFromMenu(this);">
- <span>
- <img src="${icon}"></img>
- ${name}
- </span>
- </div>`);
- }
- function searchModule(event) {
- if (event.which == 13) {
- var keyword = $("#searchBar").val().toLowerCase();
- var results = [];
- var lessAccurateResults = [];
- $(".groupType.selected").removeClass("selected");
- $("#searchResults").addClass("selected").slideDown('fast');
- //Load all search results
- for (var i = 0; i < moduleInstalled.length; i++) {
- var thisModule = moduleInstalled[i];
- if (thisModule["StartDir"] == ""){
- continue;
- }
- var pathInfo = thisModule["StartDir"].split("/");
- for (var j = 0; j < pathInfo.length; j++) {
- pathInfo[j] = pathInfo[j].toLowerCase();
- }
- if (thisModule["Name"].toLowerCase().includes(keyword)) {
- results.push(thisModule);
- } else if (pathInfo.includes(keyword.toLowerCase()) || pathInfo.includes(keyword.split(" ").join("_").toLowerCase())) {
- lessAccurateResults.push(thisModule);
- }
- }
- results = results.concat(lessAccurateResults);
- //Append the results to list
- $("#listMenuItem").html("");
- for (var i = 0; i < results.length; i++) {
- generateListMenuItem(results[i]);
- }
- if (results.length == 0) {
- //Append a custom no results div to the content
- $("#listMenuItem").append(` <div class="item">
- <span>
- <img src="img/system/not found.png"></img>
- No Result
- </span>
- </div>`);
- }
- }
- }
- function openModuleFromMenu(object) {
- var moduleName = $(object).attr("module");
- openModule(moduleName);
- }
- function openModule(moduleName, callback=undefined) {
- $.get("system/modules/getLaunchPara?module=" + moduleName, function(data) {
- if (data.error !== undefined) {
- //Something went wrong.
- console.log("Unable to open module " + moduleName);
- if (data.error == "Not logged in."){
- //Session expired
- window.location.href = "login.system";
- }
- } else {
- //Launch the given module
- var url = data["StartDir"];
- var size = [undefined, undefined];
- var icon = "img/system/favicon.png";
- if (data["IconPath"] != "") {
- icon = data["IconPath"];
- }
- var title = data["Name"];
- //Check if the module support fw mode. If yes, launch with fwmode url. IF not, launch to index
- if (data["SupportFW"] == true) {
- if (data["LaunchFWDir"] != null) {
- url = data["LaunchFWDir"];
- }
- if (data["InitFWSize"] != null) {
- size = data["InitFWSize"];
- }
- }
- //Launch the given module
- var uuid = newFloatWindow({
- url: url,
- width: size[0],
- height: size[1],
- appicon: icon,
- title: title
- });
- if (callback !== undefined){
- callback();
- }
- hideListMenu();
- }
- });
- }
- // ===================== FLOAT WINDOWS EVENTS =====================
- function hookFloatWindowEvents() {
- //Handle floatWindow mouse drag events
- $(".fwdragger").off("mousedown").on("mousedown", function(evt) {
- evt.preventDefault();
- evt.stopImmediatePropagation();
- fwdown($(this).parent(), evt);
- });
- $(".fwdragger").off("mousemove").on("mousemove", function(evt) {
- evt.preventDefault();
- evt.stopImmediatePropagation();
- fwmove($(this).parent(), evt);
- });
- $(".fwdragger").off("mouseup").on("mouseup", function(evt) {
- evt.preventDefault();
- evt.stopImmediatePropagation();
- fwup($(this).parent(), evt);
- });
- $(".fwdragger").off("touchstart").on("touchstart", function(evt) {
- evt.preventDefault();
- evt.stopImmediatePropagation();
- fwdown($(this).parent(), evt);
- });
- $(".fwdragger").off("touchmove").on("touchmove", function(evt) {
- evt.preventDefault();
- evt.stopImmediatePropagation();
- fwmove($(this).parent(), evt);
- });
- $(".fwdragger").off("touchend").on("touchend", function(evt) {
- evt.preventDefault();
- evt.stopImmediatePropagation();
- fwup($(this).parent(), evt);
- });
- $(".fwdragger").off("dblclick").on("dblclick", function(evt) {
- //Activate full screen
- evt.preventDefault();
- evt.stopImmediatePropagation();
- //Emulate keypress on maximize btn
- toggleMax($(this).parent().find(".maxToogleButton").parent()[0], evt);
- });
- //Floatwindow operations for touch devices
- $(".maxtoggle").off("touchstart").on("touchstart",function(evt){
- evt.preventDefault();
- evt.stopImmediatePropagation();
- toggleMax(this, evt);
- });
- $(".mintoggle").off("touchstart").on("touchstart",function(evt){
- evt.preventDefault();
- evt.stopImmediatePropagation();
- min(this, evt);
- });
- $(".closetoggle").off("touchstart").on("touchstart",function(evt){
- evt.preventDefault();
- evt.stopImmediatePropagation();
- closeFloatWindow(this,evt);
- });
- //floatWindow events for mouse
- $(".maxtoggle").off("mousedown").on("mousedown",function(evt){
- evt.preventDefault();
- evt.stopImmediatePropagation();
- toggleMax(this, evt);
- });
- $(".mintoggle").off("mousedown").on("mousedown",function(evt){
- evt.preventDefault();
- evt.stopImmediatePropagation();
- min(this, evt);
- });
- $(".closetoggle").off("mousedown").on("mousedown",function(evt){
- evt.preventDefault();
- evt.stopImmediatePropagation();
- closeFloatWindow(this,evt);
- });
- //Float Window events for resizing
- $(".iframewrapper").off("mousedown").on("mousedown", function(evt) {
- evt.preventDefault();
- evt.stopImmediatePropagation();
- if ($(this).parent().hasClass("fixedsize")) {
- return false;
- }
- resizeDown($(this).parent(), evt);
- });
- $(".iframewrapper").off("mousemove").on("mousemove", function(evt) {
- evt.preventDefault();
- evt.stopImmediatePropagation();
- if (resizingWindow == true) {
- //Resizeing Move
- resizeMove($(this).parent(), evt);
- } else {
- //Dragdropping move
- fwmove($(this).parent(), evt);
- }
- });
- $(".iframewrapper").off("mouseup").on("mouseup", function(evt) {
- evt.preventDefault();
- evt.stopImmediatePropagation();
- resizeUp($(this).parent(), evt);
- });
- $(".iframewrapper").off("mouseover").on("mouseover", function(evt) {
- var object = $(this).parent();
- if ($(object).hasClass("fixedsize")) {
- return false;
- }
- var dx = event.pageX - $(object).find(".iframewrapper").offset().left;
- var dy = event.pageY - $(object).offset().top;
- if (dx < 10 && dy > $(object).height() - 10) {
- //Left Bottom Corner
- $(".iframewrapper").attr("class", "iframewrapper leftCorner");
- } else if (dx > $(object).width() - 10 && dy > $(object).height() - 10) {
- //Right Bottom Corner
- $(".iframewrapper").attr("class", "iframewrapper rightCorner");
- } else if (dx < 10) {
- //Dragging left edge
- $(".iframewrapper").attr("class", "iframewrapper widthHover");
- } else if (dx > $(object).width() - 10) {
- //Dragging right edge
- $(".iframewrapper").attr("class", "iframewrapper widthHover");
- } else if (dy > $(object).height() - 10) {
- //Bottom Edge
- $(".iframewrapper").attr("class", "iframewrapper heighHover");
- } else {
- //???
- $(".iframewrapper").attr("class", "iframewrapper");
- }
- });
- //Hook events on the floatWindow button
- $(".floatWindowButton").off("click touchstart").on("click touchstart", function(event) {
- event.preventDefault();
- event.stopImmediatePropagation();
- $("#stackedWindowList").css("left", $(this).offset().left);
- //Generate the stackedWindowList
- var windowIdList = JSON.parse(decodeURIComponent($(this).attr("windowidgroup")));
- if (windowIdList.length == 1) {
- //There are only one window in this group. Show it anyway
- var targetFW = getFloatWindowByID(windowIdList[0]);
- $(targetFW).fadeIn(100);
- MoveFloatWindowToTop(targetFW);
- stackedFloatWindowListShwon = false;
- $("#stackedWindowList").hide();
- } else {
- //Get icon for each windows and build the list objects
- $("#stackedWindowList").html("");
- for (var i = 0; i < windowIdList.length; i++) {
- var iconURL = getFloatWindowIconByID(windowIdList[i]);
- var title = getFloatWindowTitleByID(windowIdList[i]);
- $("#stackedWindowList").append(`<div class="item clickable" windowId="${windowIdList[i]}" onclick="bringFloatWindowToFrontByFWB(this,event);" ontouchstart="bringFloatWindowToFrontByFWB(this,event);"><span><img src="${iconURL}"></img>${title}</span><div class="closebtn" onclick="closeFWviaFWB(this,event);"><img src="img/system/close.png"></img></div></div>`);
- }
- $("#stackedWindowList").show();
- stackedFloatWindowListShwon = true;
- }
- });
- }
- var tapedTwiceTouch = false;
- var timeoutObject;
- var tappingTarget = undefined;
- function doubleTouchHandler(object, event, callback) {
- if(!tapedTwiceTouch) {
- tapedTwiceTouch = true;
- tappingTarget = object;
- timeoutObject = setTimeout( function() { tapedTwiceTouch = false; }, 300 );
- return false;
- }
- if (tappingTarget == object){
- //Double click on the same icon
- event.preventDefault();
- callback(object, event);
- tappingTarget = undefined;
- }else{
- //Although it touch twice within 300ms, but it is on different target
- //Update the tab target instead.
- tappingTarget = object;
- tapedTwiceTouch = true;
- clearTimeout(timeoutObject);
- timeoutObject = setTimeout( function() { tapedTwiceTouch = false; }, 300 );
- }
-
- }
- function openViaTouch(object, event){
- iconDoubleClicked(object,event);
- }
- //Handle focus through floatWindow taskbar button
- function bringFloatWindowToFrontByFWB(object, event) {
- event.preventDefault();
- event.stopImmediatePropagation();
- var targetWFID = $(object).attr("windowId");
- var targetFW = getFloatWindowByID(targetWFID);
- $(targetFW).fadeIn(100);
- MoveFloatWindowToTop(targetFW);
- stackedFloatWindowListShwon = false;
- $("#stackedWindowList").hide();
- }
- function closeFWviaFWB(object, event) {
- event.preventDefault();
- event.stopImmediatePropagation();
- var targetWFID = $(object).parent().attr("windowId");
- var targetFW = getFloatWindowByID(targetWFID);
- closeFloatWindow(targetFW.find(".close"), event);
- $(object).parent().remove();
- if ($("#stackedWindowList").find(".item").length == 0) {
- //There are no more things in this tab. Close this list as well.
- stackedFloatWindowListShwon = false;
- $("#stackedWindowList").hide();
- }
- }
- //Handle floatWindow resize events
- let resizingWindowTarget;
- let resizingMinX = 0;
- let minxWidth = 120;
- let minHeight = 100;
- function resizeDown(object, event) {
- //Mouse down, start resizing
- resizingWindow = true;
- resizingWindowTarget = object;
- resizingMinX = $(object).offset().left + $(object).width() - minxWidth;
- MoveFloatWindowToTop(object);
- if ($(object).hasClass("topmost")){
- //Top most windows
- $("#tfwdragpanel").show();
- }else{
- //Normal Windows
- $('.floatWindow.topmost').css("pointer-events", "none");
- $('.floatWindow.topmost').css("opacity", 0.7);
- $("#fwdragpanel").show();
- }
-
-
- $(object).find(".iframecover").show();
- //Check which edge is the user dragging
- var dx = event.pageX - $(object).find(".iframewrapper").offset().left;
- var dy = event.pageY - $(object).offset().top;
-
- if (dx < 10 && dy > $(object).height() - 10) {
- //Left Bottom Corner
- resizingEdgeID = 4;
- $(object).find(".iframewrapper").css('cursor', 'sw-resize');
- } else if (dx > $(object).width() - 10 && dy > $(object).height() - 10) {
- //Right Bottom Corner
- resizingEdgeID = 2;
- $(object).find(".iframewrapper").css('cursor', 'se-resize');
- } else if (dx < 10) {
- //Dragging left edge
- resizingEdgeID = 5;
- $(object).find(".iframewrapper").css('cursor', 'w-resize');
- } else if (dx > $(object).width() - 10) {
- //Dragging right edge
- resizingEdgeID = 1;
- $(object).find(".iframewrapper").css('cursor', 'w-resize');
- } else if (dy > $(object).height() - 10) {
- //Bottom Edge
- resizingEdgeID = 3;
- $(object).find(".iframewrapper").css('cursor', 's-resize');
- }
- }
- function resizeMove(object, event) {
- var posX = event.pageX;
- var posY = event.pageY;
-
- if (resizingWindow == true && resizingEdgeID != 0) {
- if (resizingEdgeID == 1) {
- //Width = posX - floatWindow width + 2 (for border width)
- var newWidth = posX - $(object).offset().left + 2;
- $(object).css("width", Math.max(newWidth, minxWidth));
- } else if (resizingEdgeID == 2) {
- var newWidth = posX - $(object).offset().left + 2;
- var newHeight = posY - $(object).offset().top + 2;
- $(object).css({
- width: Math.max(newWidth, minxWidth),
- height: Math.max(newHeight, minHeight)
- });
- } else if (resizingEdgeID == 3) {
- var newHeight = posY - $(object).offset().top + 2;
- $(object).css("height", Math.max(newHeight,minHeight));
- } else if (resizingEdgeID == 4) {
- var newWidth = $(object).offset().left - posX + $(object).width();
- var newHeight = posY - $(object).offset().top + 2;
-
- if (newWidth < minxWidth){
- posX = resizingMinX;
- }
-
- $(object).css({
- width: Math.max(newWidth, minxWidth),
- height: Math.max(newHeight, minHeight),
- left: posX
- });
- } else if (resizingEdgeID == 5) {
- var newWidth = $(object).offset().left - posX + $(object).width();
- if (newWidth < minxWidth){
- posX = resizingMinX;
- }
-
- $(object).css({
- width: Math.max(newWidth, minxWidth),
- left: posX
- });
- }
- }
- }
- function resizeUp(object, event) {
- resizingWindow = false;
- resizingEdgeID = 0;
- $("#fwdragpanel").hide();
- $("#tfwdragpanel").hide();
- $('.floatWindow.topmost').css("pointer-events", "auto");
- $('.floatWindow.topmost').css("opacity", 1);
- $(object).find(".iframecover").hide();
- $(object).find(".iframewrapper").css('cursor', '');
- //Force minmium width and height on any floatWindow objects
- if ($(object).width() < 120) {
- $(object).css("width", "120px");
- }
- if ($(object).height() < 120) {
- $(object).css("height", "120px");
- }
- resizingWindowTarget = undefined;
- $(".topmost").show();
- }
- //Hook body mousemove assistant events
- $("body").on("mousemove", function(evt) {
- if (focusedWindow !== undefined && movingWindow == true) {
- fwmove(focusedWindow, evt);
- } else if (focusedWindow !== undefined && resizingWindow == true) {
- resizeMove(focusedWindow, evt);
- } else if (multiSelecting == true) {
- movingMultiSelectionArea(evt);
- }
- });
- //Hook body clicke vents
- $("body").on("click", function(evt) {
- if (stackedFloatWindowListShwon == true) {
- //Hide the stacked Float Window list if it is shown
- $("#stackedWindowList").hide();
- stackedFloatWindowListShwon = false;
- }
- if (renameMode == true){
- //Exit rename mode if the target is not on the editing launchIcon
- console.log(evt.target);
- if ($(evt.target).is("body")){
- //End rename mode
- exitRenameMode();
- }
- }
- });
- //Convert touch events to click events
- function mapEventFromTouch(event){
- if (typeof event.originalEvent == "undefined"){
- //Mouse click / down / up events
- return event;
- }
- try{
- //Touch events
- if (typeof event.pageX == "undefined"){
- event.pageX = event.originalEvent.touches[0].pageX;
- }
- if (typeof event.pageY == "undefined"){
- event.pageY = event.originalEvent.touches[0].pageY;
- }
- return event;
- }catch{
- return event;
- }
-
- }
- //Please pass in the floatWindow object instead of the dragger
- function fwdown(object, event) {
- event = mapEventFromTouch(event);
- //Hide all contenxt menus
- hideAllContextMenus();
- //Move the window to the top layer
- MoveFloatWindowToTop(object);
- //Show the background drag panel
- if ($(object).hasClass("topmost")){
- $("#tfwdragpanel").show();
- }else{
- $('.floatWindow.topmost').css("pointer-events", "none");
- $('.floatWindow.topmost').css("opacity", 0.7);
- $("#fwdragpanel").show();
- }
-
-
- //Get the relative click offset of the down event
- clickDownOffset = [event.pageX - $(object).offset().left, event.pageY - $(object).offset().top];
- movingWindow = true;
- $(object).find(".iframecover").show();
- }
- function fwmove(object, event) {
- event = mapEventFromTouch(event);
- if (movingWindow == true) {
- //Check if the object is maximized. If yes, minimized it
- if ($(object).attr("max") == "true") {
- var originalSize = JSON.parse(decodeURIComponent($(object).attr("orgsize")));
- $(object).attr("max", "false");
- $(object).attr("orgsize", "");
- //Calculate new left right offsets
- var clickRatio = event.pageX / window.innerWidth;
- var newLeft = event.pageX - (clickRatio * originalSize[0]);
- originalSize
- $(object).css({
- width: originalSize[0],
- height: originalSize[1],
- left: newLeft,
- top: event.Y - 2
- });
- clickDownOffset[0] = clickRatio * originalSize[0];
- clickDownOffset[1] = 2;
- //Restore the maximize icon
- $(object).find(".maxToogleButton").attr('src', "img/system/max.png")
- }
- $(object).css("left", event.pageX - clickDownOffset[0]);
- $(object).css("top", event.pageY - clickDownOffset[1]);
- }
- }
- function fwup(object, event) {
- event = mapEventFromTouch(event);
- if (movingWindow) {
- $("#fwdragpanel").hide();
- $("#tfwdragpanel").hide();
- $('.floatWindow.topmost').css("pointer-events", "auto");
- $('.floatWindow.topmost').css("opacity", 1);
- $(object).find(".iframecover").hide();
- movingWindow = false;
- //Check if the window location is drag to the edge of the screen. If yes, toggle half screen fullscreen
- //Not need to check for if max because it must be minimized during drag move
- var dockMode = false;
- if (event.pageX < 10) {
- //Dock to left
- var originalSize = [$(object).width(), $(object).height(), $(object).offset().left, $(object).offset().top];
- $(object).attr("orgsize", encodeURIComponent(JSON.stringify(originalSize)));
- $(object).css({
- width: "50%",
- height: "calc(100% - 36px)",
- left: "0px",
- top: "0px"
- });
- $(object).attr("max", "true");
- $(object).find(".maxToogleButton").attr('src', "img/system/restore.png");
- } else if (event.pageX > window.innerWidth - 10) {
- //Dock to right
- var originalSize = [$(object).width(), $(object).height(), $(object).offset().left, $(object).offset().top];
- $(object).attr("orgsize", encodeURIComponent(JSON.stringify(originalSize)));
- $(object).css({
- width: "50%",
- height: "calc(100% - 36px)",
- left: (window.innerWidth / 2) + "px",
- top: "0px"
- });
- $(object).attr("max", "true");
- $(object).find(".maxToogleButton").attr('src', "img/system/restore.png");
- }
- }
- }
- //Handle floatWindow min, max and close
- function min(object, event) {
- event.preventDefault();
- event.stopImmediatePropagation();
- if (event.type == "mousedown" && event.which != 1) {
- //Ignore right mouse down
- return;
- }
- var fw = $(object).parent().parent().parent();
- $(fw).fadeOut(100);
- }
- function toggleMax(object, event) {
- event.preventDefault();
- event.stopImmediatePropagation();
- event = mapEventFromTouch(event);
- if (event.type == "mousedown" && event.which != 1) {
- //Ignore right mouse down
- return;
- }
- if ($(object).css('display') == 'none'){
- //This windows do not allow resizing.
- return;
- }
- var fw = $(object).parent().parent().parent();
- var maxedAlready = $(fw).attr('max');
- MoveFloatWindowToTop(fw);
- //Add transition animation
- $(fw).css({
- "transition": "width 0.3s ease-out, height 0.3s ease-out, top 0.3s ease-out, left 0.3s ease-out"
- });
- //Remove transition animation after complete wth 50ms buffer
- setTimeout(function(){
- $(fw).css({
- "transition": ""
- });
- }, 350);
-
- if (maxedAlready == "true") {
- //Resize to original
- console.log($(fw));
- var originalSize = JSON.parse(decodeURIComponent($(fw).attr("orgsize")));
-
- $(fw).attr("max", "false");
- $(fw).attr("orgsize", "");
- $(fw).css({
- width: originalSize[0],
- height: originalSize[1],
- left: originalSize[2],
- top: originalSize[3]
- });
- $(fw).find(".maxToogleButton").attr('src', "img/system/max.png");
- } else {
- //Maxmize
- var originalSize = [$(fw).width(), $(fw).height(), $(fw).offset().left, $(fw).offset().top];
- $(fw).attr("orgsize", encodeURIComponent(JSON.stringify(originalSize)));
- $(fw).css({
- width: "100%",
- height: "calc(100% - 36px)",
- left: "0px",
- top: "0px"
- });
- $(fw).attr("max", "true");
- $(fw).find(".maxToogleButton").attr('src', "img/system/restore.png")
- }
- }
- function closeFloatWindow(object, event) {
- if (event.type == "mousedown" && event.which != 1) {
- //Ignore right mouse down on close buttons
- return;
- }
- event.preventDefault();
- event.stopImmediatePropagation();
- if ($(object).is("img")) {
- object = $(object).panret();
- }
- var fw = $(object).parent().parent().parent();
- var contentWindow = $(fw).find("iframe")[0].contentWindow;
- try {
- if (contentWindow.ao_module_close === undefined) {
- //This module do not use ao_module wrapper. Close it directly.
- closeFwProcess($(fw).attr("windowId"));
- } else {
- //Pass the closing events to the window itself
- contentWindow.ao_module_close();
- }
- } catch (ex) {
- //Problems of closing floatWindow. Force closing.
- closeFwProcess($(fw).attr("windowId"));
- }
- //Find the btn object that contains the windowID
- var closingWindowID = $(fw).attr("windowId");
- resizeAllFloatWindowButtons();
- hideAllContextMenus();
- }
- function findFloatWindowButtonWithID(windowID) {
- var targetButtonObject;
- $(".floatWindowButton").each(function() {
- var originalIDlist = JSON.parse(decodeURIComponent($(this).attr('windowIDGroup')));
- originalIDlist = originalIDlist.map(String);
- if (originalIDlist.includes(windowID)) {
- targetButtonObject = $(this);
- }
- });
- return targetButtonObject;
- }
- function closeFwProcess(windowID) {
- //Close the floatwindow process
- $(".floatWindow").each(function() {
- if ($(this).attr("windowId") == windowID) {
- $(this).remove();
- }
- });
- //Remove the button from menu as well
- var targetTab = findFloatWindowButtonWithID(windowID);
- var originalIDlist = JSON.parse(decodeURIComponent($(targetTab).attr('windowIDGroup')));
- originalIDlist = originalIDlist.map(String);
- if (originalIDlist.length > 1) {
- //There are more than 1 floatWindow in this tab.
- var newIDList = [];
- for (var i = 0; i < originalIDlist.length; i++) {
- if (originalIDlist[i] != windowID) {
- newIDList.push(originalIDlist[i]);
- }
- }
- newIDListAttr = encodeURIComponent(JSON.stringify(newIDList));
- //console.log("Newlist",newIDList);
- $(targetTab).attr("windowIDGroup", newIDListAttr);
- } else {
- //This is the only floatWindow in this tab. Remove the tab itself.
- $(targetTab).remove();
- }
- }
- function PinFloatWindowToTopMostMode(object){
- if ($(".floatwindow.topmost").length >= 100){
- //Cannot add more topmost fw
- console.log("Max number of top most floatWindow reached")
- return
- }
- //Move the current fw to top, its z index is now 101
- MoveFloatWindowToTop(object);
- var windowID = $(object).attr("windowId");
- console.log("[Desktop] Pinning window ID: " + windowID)
- //Move this to fixed layer position
- $(object).addClass("topmost");
- $(object).css("z-index", 501);
- }
- function UnpinFloatWindowFromTopMostMode(object){
- $(object).removeClass("topmost");
- if (focusedWindow == object){
- focusedWindow = undefined;
- $(object).css("z-index", 1);
- }
-
- MoveFloatWindowToTop(object);
- }
- function MoveFloatWindowToTop(object) {
- var windowID = $(object).attr("windowId");
- var windowZindex = $(object).css("z-index");
- //Shift down all floatWindows that has z-index higher than this window by 2
- if (windowID == $(focusedWindow).attr("windowId")) {
- //This window already at the top
- return;
- }
- if ($(focusedWindow).hasClass("topmost")){
- //The previous focused windows is topmost. Move it to layer 109
- $(focusedWindow).css("z-index", 500);
- $(".floatWindow.topmost").each(function(){
- var thisWindowZIndex = $(this).css("z-index");
- if (parseInt(thisWindowZIndex) > parseInt(windowZindex)) {
- if ($(this).attr("windowId") != windowID) {
- $(this).css("z-index", thisWindowZIndex - 1);
- }
- }
- });
- }else{
- //The previous focused windows is normal windows. Move it to 100
- $(focusedWindow).css("z-index", 100);
- //Shift all the other windows down
- $(".floatWindow").each(function() {
- if ($(this).hasClass("topmost")){
- return;
- }
- var thisWindowZIndex = $(this).css("z-index");
- if (parseInt(thisWindowZIndex) > parseInt(windowZindex)) {
- if ($(this).attr("windowId") != windowID) {
- $(this).css("z-index", thisWindowZIndex - 1);
- //console.log($(this).attr("windowId"), $(this).css("z-index"));
- }
- }
- });
- }
- if ($(object).hasClass("topmost")){
- //The new windows is a topmost window
- $(object).css("z-index", 501);
- }else{
- $(object).css("z-index", 101);
- }
-
-
- focusedWindow = $(object);
-
- //Check if this div is hidden. If not, fade it in.
- if ($(object).is(":hidden")) {
- $(object).fadeIn(100);
- }
- }
- function newFloatWindow(config, callback=undefined) {
- //Check if the number of floatWindow already reaching its maxmium
- if ($(".floatWindow").length > maxWindowCount){
- console.log("Max number of floatWindow reached.")
- return;
- }
- //Generate new floatwindow startup config from object
- var url = defaultOrKey(config, "about:blank", "url");
- var uuid = defaultOrKey(config, (new Date()).getTime(), "uid");
- var width = defaultOrKey(config, 854, "width");
- var height = defaultOrKey(config, 480, "height");
- var moduleIcon = defaultOrKey(config, "img/system/favicon.png", "appicon");
- var title = defaultOrKey(config, "New floatWindow", "title");
- var left = defaultOrKey(config, 100, "left");
- var top = defaultOrKey(config, 100, "top");
- var parentWindowID = defaultOrKey(config, "", "parent");
- var callbackFunctionName = defaultOrKey(config, "", "callback");
- var bgcolor = defaultOrKey(config, "", "background-color");
- //Encode function name
- callbackFunctionName = encodeURIComponent(callbackFunctionName);
- //Validate paramters
- if (width > window.innerWidth) {
- width = window.innerWidth;
- }
- if (height > window.innerHeight) {
- height = window.innerHeight;
- }
- if (left + width > window.innerWidth) {
- left = 0;
- }
- if (top + height > window.innerHeight) {
- top = 0;
- }
- //Check if the location already cotain any window
- while (floatWindowLocationDuplicated(left, top)) {
- left += 30;
- top += 30;
- }
- //Check if the opening require a overwrite on background color
- var backgroundStyle = "";
- if (bgcolor !== ""){
- backgroundStyle = `background-color: ${bgcolor};`;
- }
- //Check if the theme color is applied. If yes, generate the floatWindow with overwritten theem color
- var overWriteThemeColor = "";
- if (desktopThemeColor != ""){
- overWriteThemeColor = `background-color: ${hexToRgbA(desktopThemeColor, 0.85)}`;
- }
- //Append the floatWindow into the body
- $("body").append(`<div class="floatWindow" windowId="${uuid}" parent="${parentWindowID}" callback="${callbackFunctionName}" style="z-index:0; width:${width}px; height:${height}px; left:${left}px; top:${top}px;${backgroundStyle}">
- <div class="controls fwdragger themeColorSolid" style="${overWriteThemeColor}">
- <img class="moduleicon" src="${moduleIcon}"></img>
- <div class="title">${title}</div>
- <div class="fwcontrol">
- <div class="buttons mintoggle">
- <img src="img/system/min.png"></img>
- </div>
- <div class="buttons maxtoggle">
- <img class="maxToogleButton" src="img/system/max.png"></img>
- </div>
- <div class="buttons closetoggle close">
- <img src="img/system/close.png"></img>
- </div>
- </div>
- </div>
- <div class="iframewrapper">
- <iframe src="${url}" allowfullscreen="true"></iframe>
- <div class="iframecover"></div>
- </div>
- </div>`);
- var newWindowObject = getFloatWindowByID(uuid);
- //console.log(newWindowObject);
- MoveFloatWindowToTop(newWindowObject);
- //Append window to taskbar
- var groupInfo = url.split("/");
- var group = "";
- if (groupInfo.length == 1) {
- group = groupInfo[0];
- } else {
- groupInfo.pop();
- group = groupInfo.join("/");
- }
- //File system windows require special grouping based on their filename
- if (url.includes("SystemAO/file_system/")){
- group = url.split("/").pop().split(".").join("_");
- }else if (url.includes("SystemAO/utilities/")){
- group = url.split("/").pop().split(".").join("_");
- if (group.includes("#")){
- group = group.split("#")[0];
- }
- }
- //Check if the group already exists.
- var groupExists = false;
- var targetGroupingTab;
- $(".floatWindowButton").each(function() {
- if ($(this).attr("group") == group) {
- groupExists = true;
- targetGroupingTab = $(this);
- }
- });
- //Check if the group is System Explorer and held special treatment if yes
- if (group.split("/").shift() == "SystemAO") {
- if (url.includes("file_explorer.html") && groupExists) {
- //File Manager. Group them
- group = "file_explorer";
- }else if (url.includes("utilities") && groupExists){
- //Allow grouping
- } else {
- //Do not group anything from SystemAO other than file explorer
- groupExists = false;
- }
- }
- if (groupExists == false) {
- //Append the item to taskbar
- var windowIDGroup = encodeURIComponent(JSON.stringify([uuid]));
- var floatWindowButtonObject = ` <div class="item clickable floatWindowButton onscreen" group="${group}" windowIDGroup="${windowIDGroup}">
- <img class="floatWindowAppIcon" src="${moduleIcon}"></img>
- <p class="floatWindowTitle">${title}</p>
- </div>`;
- $(".navimenu").append(floatWindowButtonObject);
- } else {
- //Group already exists. Add tab into that group.
- var originalIDlist = JSON.parse(decodeURIComponent($(targetGroupingTab).attr('windowIDGroup')));
- originalIDlist.push(uuid);
- //Encode and put the group list back to the object
- var newIDList = encodeURIComponent(JSON.stringify(originalIDlist));
- $(targetGroupingTab).attr("windowIDGroup", newIDList);
- }
- hookFloatWindowEvents();
- resizeAllFloatWindowButtons();
- if (callback !== undefined){
- callback(uuid);
- }
- }
- function resizeAllFloatWindowButtons() {
- var fwbTotalWidth = $(".floatWindowButton").length * 200;
- if (fwbTotalWidth > window.innerWidth * 0.7) {
- $(".floatWindowButton").addClass("hideText");
- } else {
- $(".floatWindowButton").removeClass("hideText");
- }
- }
- function floatWindowLocationDuplicated(left, top) {
- var duplicated = false;
- $(".floatWindow").each(function() {
- if ($(this).offset().left == left && $(this).offset().top == top) {
- duplicated = true;
- }
- });
- return duplicated;
- }
- function defaultOrKey(object, defaultvalue, key) {
- if (object[key] !== undefined) {
- return object[key];
- }
- return defaultvalue;
- }
- function getFloatWindowByID(id) {
- var targetWindow = undefined;
- $(".floatWindow").each(function() {
- if ($(this).attr("windowId") == id) {
- targetWindow = $(this);
- }
- });
- return targetWindow;
- }
-
- function getFloatWindowIconByID(id) {
- var targetIconURL = "img/system/favicon.png";
- $(".floatWindow").each(function() {
- if ($(this).attr("windowId") == id) {
- //This window ID matched the target fw
- targetIconURL = $(this).find(".moduleicon").attr('src');
- }
- });
- return targetIconURL;
- }
- function getFloatWindowTitleByID(id) {
- var title = "";
- $(".floatWindow").each(function() {
- if ($(this).attr("windowId") == id) {
- //This window ID matched the target fw
- title = $(this).find(".title").text();
- }
- });
- return title;
- }
- function setFloatWindowResizePolicy(targetFWId, resizble = true) {
- var targetfw = getFloatWindowByID(targetFWId);
- if (resizble) {
- $(targetfw).find(".maxtoggle").show();
- $(targetfw).removeClass("fixedsize");
- } else {
- $(targetfw).find(".maxtoggle").hide();
- $(targetfw).addClass("fixedsize");
- }
- }
- function setFloatWindowSize(targetFWId, newWidth, newHeight) {
- var targetfw = getFloatWindowByID(targetFWId);
- $(targetfw).css({
- height: newHeight,
- width: newWidth
- });
- }
- function setFloatWindowTitle(targetFWId, newTitle) {
- var targetfw = getFloatWindowByID(targetFWId);
- $(targetfw).find(".title").text(newTitle);
- }
- function openFileWithModule(moduleLaunchInfo, openFileList) {
- var url = moduleLaunchInfo["StartDir"];
- var size = [undefined, undefined];
- var title = moduleLaunchInfo["Name"];
- var icon = "img/system/favicon.png";
- if (moduleLaunchInfo["IconPath"] != "") {
- icon = moduleLaunchInfo["IconPath"];
- }
- //Use floatWindow if exists
- if (moduleLaunchInfo["SupportFW"] == true && moduleLaunchInfo["LaunchFWDir"] != "") {
- url = moduleLaunchInfo["LaunchFWDir"];
- if (moduleLaunchInfo["InitFWSize"] !== null) {
- size = moduleLaunchInfo["InitFWSize"]
- }
- }
- //Use embedded mode if exists
- if (moduleLaunchInfo["SupportEmb"] == true && moduleLaunchInfo["LaunchEmb"] != "") {
- url = moduleLaunchInfo["LaunchEmb"];
- if (moduleLaunchInfo["InitEmbSize"] !== null) {
- size = moduleLaunchInfo["InitEmbSize"]
- }
- }
- var openParamter = encodeURIComponent(JSON.stringify(openFileList));
- //Add launch files info and launch floatWindow
- parent.newFloatWindow({
- url: url + "#" + openParamter,
- width: size[0],
- height: size[1],
- appicon: icon,
- title: title
- });
- }
- //====================== DESKTOP THEME RELATED FUNCTIONS =====================
- //Initiate desktop theme list and user current theme
- function initDesktopTheme() {
- //Update 1 April 2021: Check if the user customize the desktop with the given path
- $.get("system/desktop/theme", function(data) {
- //Return a list of theme stored on the system
- desktopThemeList = data;
- $.get("system/desktop/theme?get=true", function(data) {
- //Get the user theme settings
- changeDesktopTheme(data);
- });
- });
- }
- function setDesktopTheme(themeName) {
- $.get("system/desktop/theme?set=" + themeName, function(data) {
- //Get the user theme settings
- changeDesktopTheme(themeName);
- if (data.includes("Error")) {
- console.log(data);
- }
- });
- }
- //Actiave background cross fade changing animation
- function initBackgroundSwitchingAnimation() {
- if (localStorage.getItem("ao/desktop/backgroundInterval") !== null && !isNaN(parseInt(localStorage.getItem("ao/desktop/backgroundInterval")))){
- //Localstorage has interval setting that is not NaN
- backgroundCrossfadeInterval = parseInt(localStorage.getItem("ao/desktop/backgroundInterval")) * 1000;
- }
- backgroundIntervalCounter = setInterval(function() {
- $("body").css("background-image", "none").css({
- 'background-color': '#000000'
- });
- $(".showBackground").removeClass("showBackground");
- $($(".backgroundFrame")[nextSlideshowIndex]).addClass("showBackground");
- nextSlideshowIndex++;
- if (nextSlideshowIndex > currentBackgroundList.length - 1) {
- nextSlideshowIndex = 0;
- }
- }, backgroundCrossfadeInterval);
- }
- //Function for changing the desktop theme
- function changeDesktopTheme(targetThemeName) {
- currentUserTheme = targetThemeName;
- if (currentUserTheme.includes(":/") == false){
- //This is default theme pack name
- for (var i = 0; i < desktopThemeList.length; i++) {
- var thisTheme = desktopThemeList[i];
- if (thisTheme["Theme"] == targetThemeName) {
- //Use this config as the target theme
- currentBackgroundList = thisTheme["Bglist"];
- break;
- }
- }
- //Initiate the background image.
- $("#bgwrapper").html("");
- for (var i = 0; i < currentBackgroundList.length; i++) {
- var id = "dbg" + i;
- var thisImage = "img/desktop/bg/" + currentUserTheme + "/" + currentBackgroundList[i];
- $("#bgwrapper").append('<img id="' + id + '" rel="preload" draggable="false" style="background-image:url(\'' + thisImage + '\');" class="backgroundFrame"></img>');
- }
- setTimeout(function() {
- $("#dbg0").addClass("showBackground");
- }, 300);
- if (currentBackgroundList.length == 1) {
- //There are only 1 background in this pack. Make the next slice be 0 as well.
- nextSlideshowIndex = 0;
- }else if (currentBackgroundList.length == 0){
- //Background no longer exists. Change to default
- changeDesktopTheme("default");
- } else {
- nextSlideshowIndex = 1;
- }
- }else{
- //This is user defined photo file
- $.get("system/desktop/theme?load=" + targetThemeName, function(data){
- if (data.error !== undefined){
- //The folder is gone. Use default instead
- console.log(data.error);
- changeDesktopTheme("default");
- }else{
- //OK! Load it
- currentBackgroundList = data;
-
- $("#bgwrapper").html("");
- for (var i = 0; i < currentBackgroundList.length; i++) {
- var id = "dbg" + i;
- var thisImage = "media/?file=" + currentBackgroundList[i];
- $("#bgwrapper").append('<img id="' + id + '" rel="preload" draggable="false" style="background-image:url(\'' + thisImage + '\');" class="backgroundFrame"></img>');
- }
- setTimeout(function() {
- $("#dbg0").addClass("showBackground");
- }, 300);
- if (currentBackgroundList.length == 1) {
- //There are only 1 background in this pack. Make the next slice be 0 as well.
- nextSlideshowIndex = 0;
- }else if (currentBackgroundList.length == 0){
- //Background no longer exists. Change to default
- changeDesktopTheme("default");
- } else {
- nextSlideshowIndex = 1;
- }
- }
- });
-
- }
- }
- $("#bgwrapper").on("click", function(evt) {
- evt.preventDefault();
- });
- //================== DESKTOP FILE LOCATION FUNCTIONS ====================
- function initDesktopFiles(optionObject = {}, callback = undefined) {
- $.get("system/desktop/listDesktop", function(data) {
- //Prase optionObject
- var noflash = false;
- if (typeof optionObject.noflash !== "undefined"){
- noflash = optionObject.noflash;
- }
- if (noflash){
- //Only clean out those object that not exists in the new filelist
- var existsingFilepaths = [];
- if (data != null){
- for (var i =0; i < data.length; i++){
- existsingFilepaths.push(data[i].Filepath);
- }
- }else{
- //Nothing on desktop
- }
-
- //console.log(existsingFilepaths);
- //If the launchIcon path is not in the latest list, remove it from desktop
- $(".launchIcon").each(function(){
- if (existsingFilepaths.includes($(this).attr("filepath")) == false){
- $(this).remove();
- }
- });
- }else{
- //Cleanup all previous icons
- $("#iconwrapper").html("");
- }
- //Allocate new items location
- var iheight = 106;
- var iwidth = 70;
- var padding = 16;
- if (desktopIconSize == "small") {
- iheight = 82;
- iwidth = 50;
- } else if (desktopIconSize == "medium") {
- iheight = 106;
- iwidth = 70;
- } else if (desktopIconSize == "big") {
- iheight = 124;
- iwidth = 84;
- }
- iconSize = [iwidth, iheight];
- var screenHeight = window.innerHeight;
- var screenWidth = window.innerWidth;
- var vc = Math.floor((screenHeight - 20 - padding) / iheight);
- var hc = Math.floor((screenWidth - padding) / iwidth);
- var slots = []; //A 2D array for storing relative to absolute locations
- for (var j = 0; j < hc; j++) {
- var thisLocationList = [];
- for (var i = 0; i < vc; i++) {
- var thisLocation = [j * iwidth + padding, i * iheight + padding];
- thisLocationList.push(thisLocation);
- }
- slots.push(thisLocationList);
- }
- //Store the root position (0,0) in rootPosition
- let rootPosition = JSON.parse(JSON.stringify(slots[0][0]));
- desktopGrids = JSON.parse(JSON.stringify(slots));
- //Assign items to desktop
- var unallocatedFiles = [];
- let remainingSlots = JSON.parse(JSON.stringify(slots));
- desktopFileList = [];
- if (data === null){
- //No files on desktop
- return;
- }
- for (var i = 0; i < data.length; i++) {
- var thisFile = data[i];
- desktopFileList.push(JSON.parse(JSON.stringify(thisFile.Filename)));
- //Get icon from the icon list
- var location = [thisFile.IconX, thisFile.IconY];
- if (location[0] == -1 && location[1] == -1) {
- //This file is not located. Push it into unallocatedFileList
- unallocatedFiles.push(thisFile);
- } else if (location[0] >= slots.length || location[1] >= slots[0].length) {
- //This file is outside of the screen area. Set to be be unallocatedFiles as well
- unallocatedFiles.push(thisFile);
- } else {
- //This file is already located. Push it location into occupiedSlots
- //var screenX = location[0] * iwidth + padding/2;
- //var screenY = location[1] * iheight + padding/2;
- var screenLocation = slots[location[0]][location[1]];
- //Remove this object from remaining slots
- remainingSlots[location[0]][location[1]] = undefined;
- //console.log(thisFile, screenLocation[0], screenLocation[1], iheight, iwidth);
- appendIconAtLocation(thisFile, screenLocation[0], screenLocation[1], iheight, iwidth, noflash);
- }
- }
- //Foreach remaining files, assign a location for it.
- var walk = [slots.length, slots[0].length];
- var current = [0, 0];
- for (var i = 0; i < unallocatedFiles.length; i++) {
- var thisFile = unallocatedFiles[i];
- try{
- while (typeof(remainingSlots[current[0]][current[1]]) == "undefined") {
- //This slot is not usabled. Next slot.
- current[1] += 1;
- if (current[1] >= walk[1]) {
- current[1] = 0;
- current[0] += 1;
- }
- if (typeof(remainingSlots[current[0]]) == "undefined"){
- //Not enough space to fit the item. Move it to 0 0 instead
- current = [-1,-1];
- console.log(current);
- break;
- }
-
- }
- }catch{
- //Something went wrong while assigning positions. Set at root location
- current = [-1,-1];
- }
-
- //Append the icon to screen
- if (current[0] == -1 && current[1] == -1){
- //Screen overflow. Stack the file at (0,0)
- screenLocation = [rootPosition[0], rootPosition[1]];
- console.log(screenLocation);
- }else{
- screenLocation = remainingSlots[current[0]][current[1]];
- remainingSlots[current[0]][current[1]] = undefined;
- }
-
- appendIconAtLocation(thisFile, screenLocation[0], screenLocation[1], iheight, iwidth, noflash);
- //Save the icon location to server
- $.ajax({
- url: "system/desktop/files",
- method: "POST",
- data: {"set": thisFile.Filename, "x": current[0], "y": current[1]},
- success: function(data) {
- if (data.error !== undefined) {
- console.log(data.error);
- }
- }
- });
-
- }
- //Update the desktop hash to prevent the auto refresh by hash
- getDesktopHash(function(hash){
- desktopFileHash = hash;
- });
- if (callback !== undefined) {
- //console.log(callback);
- callback();
- }
- });
- }
- //Handle desktop file multi selection and dragging
- $("#bgwrapper").on("mousedown", function(evt) {
- initMultiSelection(evt);
- });
- $("#bgwrapper").on("touchstart", function(evt) {
- initMultiSelection(evt);
- });
- $("body").on("mouseup", function(evt) {
- mainWindowMouseup(evt);
- });
- $("body").on("touchend", function(evt) {
- mainWindowMouseup(evt);
- });
- $("#selectionPanel").on("mouseup", function(event) {
- });
- function mainWindowMouseup(event) {
- if (event.pageX == multiSelectionStartPoint[0] && event.pageY == multiSelectionStartPoint[1]) {
- //Pressdown and up at the same location
- $(".launchIconWrapper.selected").removeClass("selected");
- endMultiSelection(event);
- } else {
- //Press down and up at different location
- endMultiSelection(event);
- }
- if (resizingWindow){
- //Resizing floatWindow out of the window bound (aka someone don't know how to resize a window correctly)
- resizingWindow = false;
- resizingEdgeID = 0;
- $("#fwdragpanel").hide();
- $("#tfwdragpanel").hide();
- $('.floatWindow.topmost').css("pointer-events", "auto");
- $('.floatWindow.topmost').css("opacity", 1);
- $(resizingWindowTarget).find(".iframecover").hide();
- $(resizingWindowTarget).find(".iframewrapper").css('cursor', '');
- }
-
- }
- function initMultiSelection(event) {
- event.preventDefault();
- multiSelecting = true;
- hideAllContextMenus();
- $("#selectionPanel").css({
- left: event.pageX,
- top: event.pageY,
- width: 0,
- height: 0
- });
- $("#selectionPanel").show();
- multiSelectionStartPoint = [event.pageX, event.pageY];
- }
- function movingMultiSelectionArea(event) {
- event.preventDefault();
- var sx = multiSelectionStartPoint[0];
- var sy = multiSelectionStartPoint[1];
- var ex = event.pageX;
- var ey = event.pageY;
- var newleft = sx;
- if (ex < sx) {
- newleft = ex;
- }
- var newtop = sy;
- if (ey < sy) {
- newtop = ey;
- }
- var newWidth = Math.abs(sx - ex);
- var newHeight = Math.abs(sy - ey);
- $("#selectionPanel").css({
- left: newleft,
- top: newtop,
- width: newWidth,
- height: newHeight
- });
- //Select all the launch icon selected
- selectAllLaunchIconInRange(newleft, newleft + newWidth, newtop, newtop + newHeight);
- }
- function endMultiSelection(event) {
- event.preventDefault();
- multiSelecting = false;
- multiSelectionStartPoint = [-1, -1];
- $("#selectionPanel").hide();
- }
- function selectAllLaunchIconInRange(minX, maxX, minY, maxY) {
- //Select launch icons from its center point
- var xOffset = iconSize[0] / 2;
- var yOffset = iconSize[1] / 2;
- $(".launchIconWrapper.selected").removeClass("selected");
- $(".launchIcon").each(function() {
- //Calculate center point for this icon
- var thisX = $(this).offset().left + xOffset;
- var thisY = $(this).offset().top + yOffset;
- if (thisX > minX && thisX < maxX) {
- if (thisY > minY && thisY < maxY) {
- $(this).find(".launchIconWrapper").addClass("selected");
- }
- }
- });
- }
- function redrawDesktopGrids() {
- var iheight = 106;
- var iwidth = 70;
- var padding = 16;
- if (desktopIconSize == "small") {
- iheight = 82;
- iwidth = 50;
- } else if (desktopIconSize == "medium") {
- iheight = 106;
- iwidth = 70;
- } else if (desktopIconSize == "big") {
- iheight = 124;
- iwidth = 84;
- }
- iconSize = [iwidth, iheight];
- var screenHeight = window.innerHeight;
- var screenWidth = window.innerWidth;
- var vc = Math.floor((screenHeight - 20 - padding) / iheight);
- var hc = Math.floor((screenWidth - padding) / iwidth);
- var slots = []; //A 2D array for storing relative to absolute locations
- for (var j = 0; j < hc; j++) {
- var thisLocationList = [];
- for (var i = 0; i < vc; i++) {
- var thisLocation = [j * iwidth + padding, i * iheight + padding];
- thisLocationList.push(thisLocation);
- }
- slots.push(thisLocationList);
- }
- desktopGrids = JSON.parse(JSON.stringify(slots));
- }
- function appendIconAtLocation(filedata, screenX, screenY, iheight, iwidth, updateMode=false) {
- //Get the icon from extension
- var icon = ao_module_utils.getIconFromExt(filedata.Ext.substring(1, filedata.Ext.length));
- var imagePath = "img/desktop/files_icon/" + desktopIconPack + "/" + icon + ".png";
- //Handle special icon types here
- var size = desktopIconSize;
- var filename = JSON.parse(JSON.stringify(filedata.Filename));
- var filepath = JSON.parse(JSON.stringify(filedata.Filepath));
- var isDir = JSON.parse(JSON.stringify(filedata.IsDir));
- var isEmptyDir = JSON.parse(JSON.stringify(filedata.IsEmptyDir));
- var isShared = JSON.parse(JSON.stringify(filedata.IsShared));
- var maxlength = 12;
- var type = "file";
- let shortenedName = filename;
- screenX += iconOffsetXY[0];
- screenY += iconOffsetXY[1];
-
- if (isDir) {
- //Folder objects
- icon = "folder outline";
- if (isEmptyDir){
- imagePath = "img/desktop/system_icon/folder.png";
- }else{
- imagePath = "img/desktop/system_icon/folder-with-content.png";
- }
-
- type = "folder";
- } else if (isDir == false && icon == "folder outline") {
- icon = "file outline";
- imagePath = "img/desktop/files_icon/" + desktopIconPack + "/file outline.png";
- type = "file";
- } else if (filedata.Ext == ".exe" || filedata.Ext == ".elf") {
- //Executable objects
- imagePath = "img/desktop/system_icon/script.png";
- type = "executable";
- } else if (filedata.Ext == ".shortcut") {
- //Shortcut
- var shortcutImage = filedata.ShortcutImage;
- shortenedName = JSON.parse(JSON.stringify(filedata.ShortcutName));
- imagePath = shortcutImage;
- type = "shortcut";
- }
- //Check if filename is english only.
- if (/^[a-zA-Z\d .-=+]+$/.test(filename)) {
- maxlength = 20;
- }else{
- //Check if it is under small text mode
- if (size == "small"){
- maxlength = 10;
- }
- }
-
- if (type != "shortcut" && filename.length > maxlength) {
- shortenedName = filename.substring(0, maxlength) + "...";
- }
- var compressedFiledata = ao_module_utils.objectToAttr(filedata);
- if (updateMode){
- //Update the content that already exists for the same filepath object
- var updateObject = undefined;
- $(".launchIcon").each(function(){
- if ($(this).attr("filedata") == compressedFiledata){
- updateObject = $(this);
- }
- });
- if (updateObject !== undefined){
- //Check if content identical. If yes, skip rewrite
- if (updateObject.attr("filedata") == compressedFiledata){
- //Identical. Skipping
- }else{
- //Update its contents
- updateObject.attr("type", type);
- updateObject.attr("filename", filename);
- updateObject.attr("filepath", filepath);
- updateObject.attr("filedata", compressedFiledata);
- updateObject.css("width", iwidth + "px");
- updateObject.css("height", iheight + "px");
- updateObject.css("left", screenX + "px");
- updateObject.css("top", screenY + "px");
- }
- }else{
- //No exists. Append to wrapper
- appendDesktopIcon($("#iconwrapper"),{
- type: type,
- filename: filename,
- filepath: filepath,
- compressedFiledata: compressedFiledata,
- iwidth: iwidth,
- iheight: iheight,
- screenX: screenX,
- screenY: screenY,
- size: size,
- imagePath: imagePath,
- shortenedName: shortenedName,
- isShared: isShared,
- });
- }
- }else{
- //Append into the desktop
- appendDesktopIcon($("#iconwrapper"),{
- type: type,
- filename: filename,
- filepath: filepath,
- compressedFiledata: compressedFiledata,
- iwidth: iwidth,
- iheight: iheight,
- screenX: screenX,
- screenY: screenY,
- size: size,
- imagePath: imagePath,
- shortenedName: shortenedName,
- isShared: isShared,
- });
- }
-
- }
- /*
- Main function to append desktop icon to desktop
- Usage: Pass in the target (as jquery object, usually $("#iconwrapper")) and properties with the following object
- properties = {
- type: "",
- filename: "",
- filepath: "",
- compressedFiledata: "",
- iwidth: "",
- iheight: "",
- screenX: "",
- screenY: "",
- size: "",
- imagePath: "",
- shortenedName: "",
- }
- Where the enmty string is the value that require filling in
- */
- function appendDesktopIcon(target, properties){
- var htmlType = "div";
- if (properties.type == "file" && isChrome){
- htmlType = "a";
- }
-
- var thisIcon = $(`<${htmlType} href="javascript:void(0);" class="launchIcon"
- type="${properties.type}"
- draggable="true"
- ondragover="allowDrop(event)"
- ondrop="drop(event)"
- ondragstart="drag(event)"
- onmousedown="iconClicked(this,event);"
- ondblclick="iconDoubleClicked(this,event);"
- ontouchstart="iconClicked(this,event); doubleTouchHandler(this, event,openViaTouch);"
- filename="${properties.filename}"
- filepath="${properties.filepath}"
- filedata="${properties.compressedFiledata}"
- style="width:${properties.iwidth}px; height:${properties.iheight}px;left:${properties.screenX}px; top:${properties.screenY}px;">
- <span class="launchIconWrapper">
- <img class="launchIconImage ${properties.size}" src="${properties.imagePath}" draggable="false"></img>
- <p class="launchIconText ${properties.size} ">${properties.shortenedName}</p>
- </span>
- </${htmlType}>`);
- $(target).append(thisIcon);
- //Updates 20 May 2021: Check if this file is shared. If yes, append the share icon
- if (typeof(properties.isShared) != "undefined" && properties.isShared == true){
- setFileShareIndicator(properties.filename);
- }
-
- if (properties.type == "file" && isChrome){
- console.log(isChrome);
- let thisFilepath = properties.filepath;
- $(thisIcon)[0].addEventListener("dragstart",function(evt){
- //var filecontent = toDataUrl("media/?file=" + thisFilepath);
- //var fileBase64 = window.btoa(filecontent);
- var targetMime = "plain/text";
- $.ajax({
- url: "media/getMime/?file=" + encodeURIComponent(properties.filepath),
- success: function(data){
- if (data.error !== undefined){
- targetMime = "text/directory";
- }else{
- targetMime = data;
- }
- },
- async: false
- });
- evt.dataTransfer.setData("DownloadURL",targetMime+":"+ properties.filename +":"+ location.protocol + "//" + location.hostname + ":" + location.port + "/media/?file=" + encodeURIComponent(properties.filepath));
- //evt.dataTransfer.setData("DownloadURL","video/mp4"+":"+"test.mp4"+":"+"data:"+"video/mp4"+";base64,"+fileBase64);
- },false);
- }
- }
- /*
- Share indicator settings
- This append or remove share from a particular file
- Only require filename as all files here are on desktop
- */
- function getFileObjectByFilename(filename){
- var result = null;
- $(".launchIcon").each(function(){
- var thisFilename = $(this).attr("filename");
- if (thisFilename == filename){
- result = $(this);
- }
- });
- return result;
- }
- function setFileShareIndicator(filename){
- var targetFileObject = getFileObjectByFilename(filename);
- if (targetFileObject == null){
- return;
- }
- var sharedIcon = `<div class="fileShareIndicator ${desktopIconSize}">
- <img src="img/desktop/system_icon/shared.png">
- </div>`;
- $(targetFileObject).find(".launchIconWrapper").append(sharedIcon);
- }
- function removeFileShareIndicator(filename){
- var targetFileObject = getFileObjectByFilename(filename);
- if (targetFileObject == null){
- return;
- }
- var indicator = $(targetFileObject).find(".fileShareIndicator");
- if (indicator.length > 0){
- indicator.remove();
- }
- }
- // ========================== LAUNCH ICON OPERATIONS ================
- //This function start all the launchicon related events
- function drag(ev) {
- //If rename mode, disable drag drop
- if (renameMode){
- return false;
- }
- var target = ev.target;
- if (!($(ev.target).is("div") || $(ev.target).is("a"))) {
- target = $(target).parent();
- }
- //Parse the standard filename / filepath data
- var filename = $(target).attr("filename");
- var filepath = $(target).attr('filepath');
- ev.dataTransfer.setData("filename", filename);
- ev.dataTransfer.setData("filepath", filepath);
- //Parse multifile selection filedata
- var filelist = [];
- if ($(".launchIconWrapper.selected").length > 0){
- if (ctrlHold || $(".launchIconWrapper.selected").length > 1){
- //Include all objects selected
- $(".launchIconWrapper.selected").each(function(){
- var fd = $(this).parent().attr("filedata");
- fd = JSON.parse(decodeURIComponent(fd));
- filelist.push({
- filename: fd.Filename,
- filepath: fd.Filepath,
- hostUUID: hostInfo.DeviceUUID
- });
- });
- }else{
- //Only push the one selected
- filelist.push({
- filename: filename,
- filepath: filepath,
- hostUUID: hostInfo.DeviceUUID
- });
- }
- }else{
- //There is no selected item on desktop. Use the drag drop one
- filelist.push({
- filename: filename,
- filepath: filepath
- });
- }
-
- //console.log(filelist);
- ev.dataTransfer.setData("filedata", JSON.stringify(filelist));
- console.log(filelist);
- //Set a flag on the drag events that these files are from Desktop GUI
- ev.dataTransfer.setData("desktopflag", "true");
- //Record the start drop relative position of the icon object
- var dx = ev.pageX - $(target).offset().left;
- var dy = ev.pageY - $(target).offset().top;
- startDragRelatuve = [dx, dy];
- ev.stopPropagation();
- }
- function drop(ev) {
- ev.preventDefault();
- ev.stopImmediatePropagation();
- var target = $(ev.target);
- if (!(target.is("div") || target.is("a"))) {
- target = $(target).parent();
- }
- if (target.hasClass("launchIconWrapper")) {
- target = target.parent();
- }
- var thisFilepath = $(target).attr("filepath");
- if (thisFilepath == ev.dataTransfer.getData("filepath")) {
- //Drag and drop on the same item. Ignore it
- return;
- }
- var sourceFilename = ev.dataTransfer.getData("filename");
- var sourceFilepath = ev.dataTransfer.getData("filepath");
- //To handle multiple file transfer from file explorer
- var sourceFilelist = ev.dataTransfer.getData("filedata");
- console.log(target)
- console.log(sourceFilename);
- console.log(sourceFilepath);
- if (sourceFilelist !== ""){
- sourceFilelist = JSON.parse(sourceFilelist);
- }
- //Drop opererations
- if (target.attr("id") == "bgwrapper") {
- if (sourceFilename == "" && sourceFilepath == "" && ev.dataTransfer.files.length > 0){
- //Drag drop from external source. Upload to desktop
- //Assign the locations for the objects
- var files = ev.dataTransfer.files;
- var gridMaxX = desktopGrids.length;
- var gridMaxY = desktopGrids[0].length;
- var targetLocation = findClosestGrid((ev.clientX), (ev.clientY), false);
- var targetGridLocation = targetLocation[1];
- var locations = [];
- for (var k =0; k < files.length; k++){
- var thisLocation = JSON.parse(JSON.stringify(targetGridLocation));
- //Add k to y axis of the list.
- thisLocation[1] += k;
- if (thisLocation[1] >= gridMaxY){
- thisLocation[0]++;
- thisLocation[1] = 0;
- }
- if (thisLocation[1] >= gridMaxY && thisLocation[0] >= gridMaxX){
- //Desktop full. Force put to 0 0
- thisLocation[0] = 0;
- thisLocation[1] = 0;
- break;
- }
- while (getObjectFromGridLocation(thisLocation[0], thisLocation[1]) !== undefined){
- thisLocation[1] += 1;
- if (thisLocation[1] >= gridMaxY){
- //Over the screen. Shift to the row on the right
- thisLocation[0]++;
- thisLocation[1] = 0;
- }
- if (thisLocation[1] >= gridMaxY && thisLocation[0] >= gridMaxX){
- //Desktop full. Force put to 0 0
- thisLocation[0] = 0;
- thisLocation[1] = 0;
- break;
- }
- }
- locations.push(thisLocation)
- }
- console.log(locations, ev.dataTransfer.files);
- //Register file locations
- for (var j =0; j < locations.length; j++){
- let thisFile = files[j];
- let thisFilename = files[j].name;
- let x = parseInt(locations[j][0]);
- let y = parseInt(locations[j][1]);
- let uploadIconUUID = generateUploadingIcon(thisFile.name, [x,y]);
- uploadFile(thisFile,function(){
- console.log("Uploader callback");
- $.ajax({
- url: "system/desktop/files",
- method: "POST",
- data: {"set": thisFilename, "x": x, "y": y},
- success: function(data) {
- //Refresh the desktop
- refresh(undefined, false);
- }
- });
- }, uploadIconUUID);
-
- }
- }else if (sourceFilelist.length > 0 && Array.isArray(sourceFilelist)){
- //Drag drop multiple files from desktop or file explorer to desktop
- var desktopFlag = ev.dataTransfer.getData("desktopflag");
- if (desktopFlag == "" || desktopFlag === undefined || desktopFlag == null){
- //This is a file drag drop from not desktop to desktop
- var filelist = ev.dataTransfer.getData("filedata");
- if (filelist != ""){
- filelist = JSON.parse(filelist);
- if (filelist.length == 0){
- return
- }
- //Get the position for this drop events and arrange grid locations
- var gridPosition = gridPositionAllocate(ev.clientX, ev.clientY, filelist.length);
- console.log(gridPosition)
- //Check if source is also from user:/
- var srcVroot = filelist[0].filepath.split(":/").shift();
- var mode = "copy"
- var title = "Copying "
- if (srcVroot == "user"){
- //Move
- mode = "move"
- title = "Moving "
- }
- var filepathList = [];
- filelist.forEach(file => {
- filepathList.push(file.filepath)
- });
- //Start the file operation dialog
- var oprConfig = {
- opr: mode,
- src: filepathList,
- dest: "user:/Desktop/",
- overwriteMode: "ask"
- }
- var configHash = encodeURIComponent(JSON.stringify(oprConfig));
- //Genreate window title
- title = title + filepathList.length;
- if (filepathList.length > 1){
- title += " files";
- }else{
- title += " file";
- }
- newFloatWindow({
- url: "SystemAO/file_system/file_operation.html#" + configHash,
- width: 400,
- height: 220,
- appicon: "SystemAO/file_system/img/selector.png",
- title: title
- });
- }
-
- }else{
- //This is a file drag event from desktop, but more than one files.
- //Pin the final location for the drag drop object
- var sourceObject = getObjectFromPath(sourceFilepath);
- var dx = startDragRelatuve[0];
- var dy = startDragRelatuve[1];
- var targetLocation = findClosestGrid((ev.clientX - dx), (ev.clientY - dy));
- var closestLocation = targetLocation[0];
- var duplicateObject = getObjectFromLocation(closestLocation[0] + iconOffsetXY[0], closestLocation[1] + iconOffsetXY[1]);
- if (duplicateObject !== undefined) {
- //There are already object there. Do nothing
- console.log("Drop location duplicated!")
- return;
- }
- //Get other objects that is not the one drag dropped
- var iconOffset = {};
- for (var i =0; i < sourceFilelist.length; i++){
- var thisFile = sourceFilelist[i];
- if (thisFile.filepath != sourceFilepath){
- //Calculate the x y offset of this icon to the drag drop one
- var thisIconObject = getObjectFromPath(thisFile.filepath);
- iconOffset[thisFile.filepath] = {
- dx: $(sourceObject).offset().left - $(thisIconObject).offset().left,
- dy: $(sourceObject).offset().top - $(thisIconObject).offset().top
- }
- //console.log(thisFile.filename, iconOffset[thisFile.filepath]);
- }
- }
- //Move the drag drop object to the desiged location
- $(sourceObject).css({
- left: closestLocation[0] + iconOffsetXY[0],
- top: closestLocation[1] + iconOffsetXY[1]
- });
- //Save the drag item location
- $.ajax({
- url: "system/desktop/files",
- method: "POST",
- data: {"set": sourceFilename, "x": targetLocation[1][0], "y": targetLocation[1][1]},
- success: function(data) {
- //console.log(data);
- }
- });
- //Move all the relative files to the main object
- var relocatePendingObjects = [];
- for (const [filepath, offset] of Object.entries(iconOffset)) {
- let thisIconObject = getObjectFromPath(filepath);
- let caluclatedLocation = [$(sourceObject).offset().left - offset.dx, $(sourceObject).offset().top - offset.dy];
- let finalIconLocation = findClosestGrid(caluclatedLocation[0], caluclatedLocation[1]);
-
- //Move this icon to designed location
- $(thisIconObject).css({
- left: finalIconLocation[0][0] + iconOffsetXY[0],
- top: finalIconLocation[0][1] + iconOffsetXY[1]
- });
- let thisIconFileData = JSON.parse(decodeURIComponent($(thisIconObject).attr("filedata")));
-
- //Record this in database
- $.ajax({
- url: "system/desktop/files",
- method: "POST",
- data: {"set": thisIconFileData.Filename, "x": finalIconLocation[1][0], "y": finalIconLocation[1][1]},
- success: function(data) {
- //console.log(data);
- }
- });
-
- }
- //Get duplication objects
- for (const [filepath, offset] of Object.entries(iconOffset)) {
- let thisIconObject = getObjectFromPath(filepath);
- //Check for duplication
- var iconLocation = [$(thisIconObject).offset().left, $(thisIconObject).offset().top];
- $(".launchIcon").each(function(){
- if ($(this).offset().left == iconLocation[0] && $(this).offset().top == iconLocation[1]){
- //This icon is at the target icon location
- if ($(this).attr("filepath") != filepath){
- relocatePendingObjects.push($(this));
- }
- }
- });
- }
- //Relocate objects that is in the way of moving
- for (var i = 0; i < relocatePendingObjects.length; i++){
- var thisObject = relocatePendingObjects[i];
- console.log(thisObject);
- var thisX = $(thisObject).offset().left;
- var thisY = $(thisObject).offset().top;
- var nextEmptyGrid = findClostestEmptyGridLocation(thisX, thisY);
-
- //Move this file to the next empty grid location
- $(thisObject).css({
- left: nextEmptyGrid[0][0] + iconOffsetXY[0],
- top: nextEmptyGrid[0][1] + iconOffsetXY[1]
- });
- //Save move record to db
- let thisIconFileData = JSON.parse(decodeURIComponent($(thisObject).attr("filedata")));
- $.ajax({
- url: "system/desktop/files",
- method: "POST",
- data: {"set": thisIconFileData.Filename, "x": nextEmptyGrid[1][0], "y": nextEmptyGrid[1][1]},
- success: function(data) {
- //console.log(data);
- }
- });
- }
- }
-
- }else{
- //Dropping a file onto other place on desktop
- var sourceObject = getObjectFromPath(sourceFilepath);
- var dx = startDragRelatuve[0];
- var dy = startDragRelatuve[1];
- var targetLocation = findClosestGrid((ev.clientX - dx), (ev.clientY - dy));
- var closestLocation = targetLocation[0];
- //Check if there are objects already at that location
- var duplicateObject = getObjectFromLocation(closestLocation[0], closestLocation[1]);
- if (duplicateObject !== undefined) {
- //There are already object there. Do nothing
- console.log("Drop location duplicated!")
- return;
- }
- var closestGridIndex = targetLocation[1];
- $(sourceObject).css({
- left: closestLocation[0] + iconOffsetXY[0],
- top: closestLocation[1] + iconOffsetXY[1]
- });
- $.ajax({
- url: "system/desktop/files",
- method: "POST",
- data: {"set": sourceFilename, "x": closestGridIndex[0], "y": closestGridIndex[1]},
- success: function(data) {
- //console.log(data);
- }
- });
- }
- } else if (target.attr("type") == "folder") {
- //Move this file or folder into the target folder
- var moveSources = [sourceFilepath];
- if ($(".launchIconWrapper.selected").length > 1){
- //Multi move operations
- moveSources = [];
- $(".launchIconWrapper.selected").each(function(){
- var thisFileData = $(this).parent().attr("filedata");
- thisFileData = JSON.parse(decodeURIComponent(thisFileData));
- moveSources.push(thisFileData.Filepath);
- });
- }
- //Get the move target location
- var targetFd = $(target).attr("filedata");
- targetFd = JSON.parse(decodeURIComponent(targetFd));
- //Move it
- moveSourceFilesToTarget(moveSources, targetFd.Filepath)
- } else if (target.attr("type") == "shortcut") {
- //Opening with the shortcut
- //Check shortcut type
- let shortcutData = JSON.parse(decodeURIComponent($(target).attr("filedata")));
- var shortcutType = shortcutData["ShortcutType"];
- if (shortcutType == "module") {
- //Open the source file with this module
- let openFileList = [];
- if ($(".launchiconwrapper.selected").length > 0 && !Array.isArray(sourceFilelist)) {
- $(".launchiconwrapper.selected").each(function() {
- let thisFileData = JSON.parse(decodeURIComponent($(this).parent().attr("filedata")));
- openFileList.push({
- filename: thisFileData["Filename"],
- filepath: thisFileData["Filepath"]
- });
- });
- }else if (sourceFilelist.length > 0 && Array.isArray(sourceFilelist)){
- //Open file that is transfered from file explorer.
- openFileList = sourceFilelist;
- console.log(openFileList);
- } else {
- //Only pass in the current selected file.
- openFileList.push({
- filename: sourceFilename,
- filepath: sourceFilepath
- });
- }
- var shortcutModule = getModuleFromShortcutInfo(shortcutData);
- //console.log(openFileList);
- if (shortcutModule === undefined){
- //This shortcut module is not found on this server
- return;
- }
- openFileWithModule(shortcutModule, openFileList);
- } else if (shortcutType == "folder") {
- //Move the source file into this folder
- var moveSources = [sourceFilepath];
- if ($(".launchIconWrapper.selected").length > 1){
- //Multi move operations
- moveSources = [];
- $(".launchIconWrapper.selected").each(function(){
- var thisFileData = $(this).parent().attr("filedata");
- thisFileData = JSON.parse(decodeURIComponent(thisFileData));
- moveSources.push(thisFileData.Filepath);
- });
- }
- //Extract shortcut info from the target
- var targetPath = shortcutData.ShortcutPath;
- moveSourceFilesToTarget(moveSources, targetPath);
- }
- } else {
- console.log("Unknown action type: ", target.attr("type"));
- }
- }
-
- //Use move if it is folder on desktop, use copy if it is a shortcut
- function moveSourceFilesToTarget(sourceList, target, opr="move"){
- var oprConfig = {
- opr: opr,
- src: sourceList,
- dest: target,
- callbackWindowID: "desktop",
- callbackFunction: `refresh(undefined, true)`
- }
- var configHash = encodeURIComponent(JSON.stringify(oprConfig));
- var title = "Copying " + sourceList.length;
- if (sourceList.length > 1){
- title += " files";
- }else{
- title += " file";
- }
- //Create FloatWindow to handle the file operations
- newFloatWindow({
- url: "SystemAO/file_system/file_operation.html#" + configHash,
- width: 400,
- height: 220,
- appicon: "SystemAO/file_system/img/selector.png",
- title: title
- });
- //Delete the file location from db
- sourceList.forEach(file => {
- let filename = file.split("/").pop();
- $.ajax({
- url: "system/desktop/files",
- data: {del: filename},
- success: function(data){
- if (data.error !== undefined){
- console.log(data.error);
- }
- }
- });
- });
- }
- function requestCSRFToken(callback){
- $.ajax({
- url: "system/csrf/new",
- success: function(token){
- callback(token);
- }
- });
- }
-
- function getModuleFromShortcutInfo(shortcutInfo) {
- var ShortcutPath = shortcutInfo["ShortcutPath"];
- if (ShortcutPath.includes("/") == false) {
- //Legacy defination. Append /index.html at the back.
- ShortcutPath = ShortcutPath + "/index.html";
- }
- //Try to match it with the module installed
- for (var i = 0; i < moduleInstalled.length; i++) {
- if (moduleInstalled[i]["StartDir"] == ShortcutPath || moduleInstalled[i]["Name"] == shortcutInfo["ShortcutName"]) {
- //This is the correct module to be loaded
- return moduleInstalled[i];
- }
- }
- }
- //Allocate the given number of grids from desktop
- function gridPositionAllocate(posx, posy, numberOfGridNeeded=1){
- var gridMaxX = desktopGrids.length;
- var gridMaxY = desktopGrids[0].length;
- var targetLocation = findClosestGrid(posx, posy, false);
- var targetGridLocation = targetLocation[1];
- var previousEmptyGridPosition = targetGridLocation;
- var locations = [];
- for (var k =0; k < numberOfGridNeeded; k++){
- var thisLocation = JSON.parse(JSON.stringify(previousEmptyGridPosition));
- //Add k to y axis of the list.
- thisLocation[1] += k;
- if (thisLocation[1] >= gridMaxY){
- thisLocation[0]++;
- thisLocation[1] = 0;
- }
- if (thisLocation[1] >= gridMaxY && thisLocation[0] >= gridMaxX){
- //Desktop full. Force put to 0 0
- thisLocation[0] = 0;
- thisLocation[1] = 0;
- break;
- }
- while (getObjectFromGridLocation(thisLocation[0], thisLocation[1]) !== undefined){
- thisLocation[1] += 1;
- if (thisLocation[1] >= gridMaxY){
- //Over the screen. Shift to the row on the right
- thisLocation[0]++;
- thisLocation[1] = 0;
- }
- if (thisLocation[1] >= gridMaxY && thisLocation[0] >= gridMaxX){
- //Desktop full. Force put to 0 0
- thisLocation[0] = 0;
- thisLocation[1] = 0;
- break;
- }
- }
- previousEmptyGridPosition = JSON.parse(JSON.stringify(thisLocation))
- locations.push(thisLocation)
- }
- return locations
- }
- function setIconDesktopLocation(sourceFilename, gridIndexX, gridIndexY, callback = undefined) {
- $.ajax({
- url: "system/desktop/files",
- method: "POST",
- data: {"set": sourceFilename, "x": gridIndexX, "y": gridIndexY},
- success: function(data) {
- if (data.error !== undefined) {
- console.log(data.error);
- } else {
- if (callback !== undefined) {
- callback();
- }
- }
- }
- });
- }
- //THIS FUNCTION IS NEEDED. DO NOT DELETE ALLOWDROP FUNCTION
- function allowDrop(ev) {
- ev.preventDefault();
- }
- //Pass in the object fullpath and return the icon object onscreen
- function getObjectFromPath(path) {
- var object;
- $(".launchIcon").each(function() {
- if ($(this).attr("filepath") == path) {
- object = $(this);
- }
- });
- return object;
- }
- //Pass in the coordinate and check if there is another object at the same location
- function getObjectFromLocation(x, y) {
- var object;
- $(".launchIcon").each(function() {
- if ($(this).position().left == x && $(this).position().top == y) {
- object = $(this);
- }
- });
- return object;
- }
- //Similar function to getObjectFromLocation but using grid coordinate instead of pixel coordinate
- function getObjectFromGridLocation(gx, gy){
- var pos = JSON.parse(JSON.stringify(desktopGrids[gx][gy]));
- pos[0] = pos[0] + iconOffsetXY[0];
- pos[1] = pos[1] + iconOffsetXY[1];
- return getObjectFromLocation(pos[0],pos[1]);
- }
- //Find the clostest empty grid, prioirty given to y first then x
- function findClostestEmptyGridLocation(x, y){
- //Reduce icon offset to the x y on screen coordinate
- x = x - iconOffsetXY[0];
- y = y - iconOffsetXY[1];
- //Get the grid index from absolute coordinate
- var currentGridLocation = getGridIndexFromLocation(x,y);
- console.log(currentGridLocation);
- //Search for the next empty location
- var targetLocation = [[-1,-1],[-1,-1]];
- for (var i = currentGridLocation[0]; i < desktopGrids.length; i++){
- var yStart = 0;
- if (i == currentGridLocation[0]){
- yStart = currentGridLocation[1];
- }
- for (k = yStart; k < desktopGrids[i].length; k++){
- var thisLocation = JSON.parse(JSON.stringify(desktopGrids[i][k]));
- var offsetedLocation = [thisLocation[0], thisLocation[1]];
- var possibleDuplication = getObjectFromGridLocation(i,k);
- //console.log( [i,k], offsetedLocation, possibleDuplication)
- if (possibleDuplication === undefined){
- //This is an empty slot
- targetLocation = [offsetedLocation, [i,k]];
- return targetLocation;
- }
- }
- }
- return targetLocation;
- }
- //Convert location to grid index
- function getGridIndexFromLocation(x,y){
- var gridIndex = [-1,-1];
- for (var i = 0; i < desktopGrids.length; i++){
- var thisXAxis = desktopGrids[i];
- if (thisXAxis[0][0] == x){
- //This x matches. Match y
- gridIndex[0] = i;
- for (var k = 0; k < thisXAxis.length; k++){
- var thisYAxis = thisXAxis[k];
- if (thisYAxis[1] == y){
- gridIndex[1] = k;
- return gridIndex;
- }
- }
- }
- }
- return gridIndex;
- }
- //Convert grid index to location
- function getLocationFromGridIndex(x, y){
- var location = [-1,-1];
-
- //Calculate the usable grid on screen
- var iheight = 106;
- var iwidth = 70;
- var padding = 16;
- if (desktopIconSize == "small") {
- iheight = 82;
- iwidth = 50;
- } else if (desktopIconSize == "medium") {
- iheight = 106;
- iwidth = 70;
- } else if (desktopIconSize == "big") {
- iheight = 124;
- iwidth = 84;
- }
- var screenHeight = window.innerHeight;
- var screenWidth = window.innerWidth;
- var vc = Math.floor((screenHeight - 20 - padding) / iheight);
- var hc = Math.floor((screenWidth - padding) / iwidth);
- //Calculate the position of this icon on the grid
- var resultX = padding + iwidth * x + iconOffsetXY[0];
- var resultY = padding + iheight * y + iconOffsetXY[1];
- return [resultX, resultY];
- }
- //Set allow overshoot to allow drop point to get closest grid with x / y > cursor posx /y
- function findClosestGrid(x, y, allowOvershoot = true) {
- var minDx = window.innerWidth;
- var minDy = window.innerHeight;
- var finalLocation = [-1, -1];
- var gridLocation = [-1, -1];
- for (var i = 0; i < desktopGrids.length; i++) {
- for (var j = 0; j < desktopGrids[0].length; j++) {
- var thisGridLocation = desktopGrids[i][j];
- var dx = x - thisGridLocation[0];
- var dy = y - thisGridLocation[1];
- if (allowOvershoot) {
- if (Math.abs(dx) < minDx) {
- minDx = Math.abs(x - thisGridLocation[0]);
- finalLocation[0] = thisGridLocation[0];
- gridLocation[0] = i;
- }
- if (Math.abs(dy) < minDy) {
- minDy = Math.abs(y - thisGridLocation[1]);
- finalLocation[1] = thisGridLocation[1];
- gridLocation[1] = j;
- }
- } else {
- if (dx < minDx && dx > 0) {
- minDx = Math.abs(x - thisGridLocation[0]);
- finalLocation[0] = thisGridLocation[0];
- gridLocation[0] = i;
- }
- if (dy < minDy && dy > 0) {
- minDy = Math.abs(y - thisGridLocation[1]);
- finalLocation[1] = thisGridLocation[1];
- gridLocation[1] = j;
- }
- }
- }
- }
- return [finalLocation, gridLocation];
- }
- //Ask for confirmation before window close
- //Update 16 Feb 2021: Disabled confirmation and use a new method of implementing this later
- /*
- function myConfirmation() {
- if (!loggingOut){
- return 'Your data might not been saved. Are you sure you want to quit?';
- }
- }
- window.onbeforeunload = myConfirmation;
- */
- function iconClicked(object, evt) {
- if (renameMode){
- //Exit rename mode if icon is clicked during renaming
- if ($(object).find(".renameInput").length == 0){
- exitRenameMode();
- }
-
- }
- //Clicked on a launch icon.
- var alreadyHighlighted = $(object).find(".launchIconWrapper").hasClass("selected");
- if (alreadyHighlighted){
- //Already selected
- if (ctrlHold) {
- //Selection
- $(object).find(".launchIconWrapper").removeClass("selected");
- }
- }else{
- //Not selected yet
- if (ctrlHold) {
- //Add this into selection
- $(object).find(".launchIconWrapper").addClass("selected");
- }else{
- //Remove all others and select this
- $(".launchIconWrapper.selected").removeClass("selected");
- $(object).find(".launchIconWrapper").addClass("selected");
- }
-
- }
- }
- function iconDoubleClicked(object, evt=undefined) {
- //Don't allow opening when renaming
- if (renameMode){
- return;
- }
- //Double click on a launch icon, tries to open it
- var filedata = ao_module_utils.attrToObject($(object).attr("filedata"));
- //console.log(filedata);
- if (filedata.IsDir) {
- //This is a directory. Open with file explorer
- newFloatWindow({
- url: "SystemAO/file_system/file_explorer.html#" + encodeURIComponent(filedata.Filepath),
- appicon: "SystemAO/file_system/img/small_icon.png",
- width: 1080,
- height: 580,
- title: "File Manager"
- });
- } else if (filedata.IsShortcut) {
- //This is a shortcut. Open the target endpoint
- var stype = filedata["ShortcutType"];
- if (stype == "module") {
- //Open the target module
- openModule(filedata.ShortcutPath);
- } else if (stype == "folder") {
- //Open the target folder
- openFolder(filedata.ShortcutPath)
- }else if (stype == "url"){
- //Open the target webpage in a new tab
- window.open(filedata.ShortcutPath);
- }else{
- console.log(filedata);
- }
- } else {
- //This is a file. Open it with default opener
- $.ajax({
- url: "system/modules/getDefault",
- method: "GET",
- data: {
- opr: "launch",
- ext: filedata.Ext,
- mode: "launch"
- },
- success: function(data) {
- if (data.error !== undefined) {
- //No default opener assigned
- var url = "SystemAO/file_system/defaultOpener.html";
- var icon = "SystemAO/file_system/img/opener.png";
- var title = "Select an opener WebApp: "
- var openFileList = [];
- var openFileObject = {
- filepath: filedata.Filepath,
- filename: filedata.Filename
- }
- openFileList.push(openFileObject);
- var openParamter = encodeURIComponent(JSON.stringify(openFileObject));
- newFloatWindow({
- url: url + "#" + openParamter,
- width: 320,
- height: 510,
- appicon: icon,
- title: title
- });
- } else {
- //Assigned. Launch with given paramter
- var url = data["StartDir"];
- var size = [undefined, undefined];
- var title = data["Name"];
- var icon = "img/system/favicon.png";
- if (data["IconPath"] != "") {
- icon = data["IconPath"];
- }
- //Use floatWindow if exists
- if (data["SupportFW"] == true && data["LaunchFWDir"] != "") {
- url = data["LaunchFWDir"];
- if (data["InitFWSize"] !== null) {
- size = data["InitFWSize"]
- }
- }
- //Use embedded mode if exists
- if (data["SupportEmb"] == true && data["LaunchEmb"] != "") {
- url = data["LaunchEmb"];
- if (data["InitEmbSize"] !== null) {
- size = data["InitEmbSize"]
- }
- }
- //Build open File Hash Data Format
- var openFileList = [];
- var openFileObject = {
- filepath: filedata.Filepath,
- filename: filedata.Filename
- }
- openFileList.push(openFileObject);
- var openParamter = encodeURIComponent(JSON.stringify(openFileList));
- //Add launch files info and launch floatWindow
- newFloatWindow({
- url: url + "#" + openParamter,
- width: size[0],
- height: size[1],
- appicon: icon,
- title: title
- });
- }
- }
- })
- }
- }
- $(window).on("resize", function(event) {
- redrawDesktopGrids();
- resizeAllFloatWindowButtons();
- })
- // ======================= DOCUMENT KEY BINDING =====================
- $(document).keydown(function(event) {
- if (event.which == "17") {
- //Pressdown of Ctrl key
- ctrlHold = true;
- } else if (event.which == "16") {
- //Pressdown of Shift key
- shiftHold = true;
- }else if (event.which == "27"){
- //Cancel all floatwindow events and key events
- $("#fwdragpanel").hide();
- $("#tfwdragpanel").hide();
- $(".floatWindow").find(".iframecover").hide();
- movingWindow = false;
- resizingWindow = false;
- resizingEdgeID = 0;
- multiSelecting = false;
- ctrlHold = false;
- shiftHold = false;
- }else if (event.which == "46"){
- //Delete key
- if (renameMode){
- //Deleting content in textarea. Ignore delte action
- return true
- }
- var deleteFilelist = [];
- var deleteFilenameList = [];
- $(".launchIconWrapper.selected").each(function(){
- var fileObject = $(this).parent();
- var fd = JSON.parse(decodeURIComponent((fileObject).attr("filedata")));
- deleteFilelist.push(fd.Filepath);
- deleteFilenameList.push(fd.Filename)
- });
- //Prase the filelist and pass to trash module
- console.log(deleteFilelist);
- generateCSRFToken(function(csrftoken){
- $.ajax({
- url: "system/file_system/fileOpr",
- method:"POST",
- data: {opr: "recycle", src: JSON.stringify(deleteFilelist), csrft: csrftoken},
- success: function(data){
- if (data.error !== undefined){
- alert(data.error);
- }else{
- refresh(undefined, true);
- }
- }
- });
- });
-
- //Delete the file's desktop location
- deleteFilenameList.forEach(file => {
- $.ajax({
- url: "system/desktop/files",
- data: {del: file},
- success: function(data){
- if (data.error !== undefined){
- console.log(data.error);
- }
- }
- });
- })
-
- }else if (event.which == "13"){
- //Enter key
- if (!renameMode){
- //Open selected object by emulating double click
- $(".launchIconWrapper.selected").each(function(){
- var object = $(this).parent();
- iconDoubleClicked(object);
- });
-
- }else if (renameMode){
- event.preventDefault();
- exitRenameMode();
- }
-
- }else{
- //console.log(event.which);
- }
- });
- $(document).keyup(function(event) {
- if (event.which == "17") {
- ctrlHold = false;
- } else if (event.which == "16") {
- shiftHold = false;
- }
- });
- $("#bgwrapper").on("mouseup", function(event) {
- //Deselect all selected icons
- event.preventDefault();
- event.stopImmediatePropagation();
- mainWindowMouseup(event);
- });
- function openFolder(virtualPath){
- newFloatWindow({
- url: "SystemAO/file_system/file_explorer.html#" + encodeURIComponent(virtualPath),
- appicon: "SystemAO/file_system/img/small_icon.png",
- width:1080,
- height:580,
- title: "File Manager"
- });
- }
- function logout() {
- loggingOut = true;
- if (confirm("Exiting Session. Confirm?")){
- $.get("system/auth/logout", function() {
- window.location.href = "/";
- });
- }
- hideAllContextMenus();
- }
- // ======================= CONTEXT MENU =============================
- window.addEventListener("contextmenu",
- function(e) {
- e.preventDefault();
- e.stopPropagation();
- var clickTarget = $(e.target);
- hideAllContextMenus();
- showMenu = false;
- $("#contextmenu").html("");
- if (clickTarget.hasClass("launchIcon") || clickTarget.hasClass("launchIconImage") || clickTarget.hasClass("launchIconText")) {
- //Click on an object on destkop
- if (clickTarget.hasClass("launchIcon") == false) {
- clickTarget = $(clickTarget).parent().parent();
- }
- if (!ctrlHold && !$(clickTarget).find(".launchIconWrapper").hasClass("selected")){
- $(".launchIconWrapper.selected").removeClass("selected");
- }
- //Select this object
- $(clickTarget).find(".launchIconWrapper").addClass("selected");
- var objectType = $(clickTarget).attr("type");
- operationTargetLaunchIcon = $(clickTarget);
- //Check if selected more than one object
- if ($(".launchIconWrapper.selected").length > 1){
- //When the user selected more than one item on desktop
- addContextMenuItem($("#contextmenu"), 'Open', undefined, "openIconViaMenu", false);
- addContextMenuItem($("#contextmenu"), 'Open With', "<i class='caret right icon'></i>", "handleOpenWith", true);
- //addContextMenuItem($("#contextmenu"), 'Share', "<i class='caret right icon'></i>", "handleFileShare", true);
- addContextMenuSeperator($("#contextmenu"));
- addContextMenuItem($("#contextmenu"), 'Download in Zip', "<i class='download icon'></i>", "downloadFile", false);
- addContextMenuItem($("#contextmenu"), 'Make a Copy', "<i class='copy icon'></i>", "handleCloning", false);
- addContextMenuItem($("#contextmenu"), 'Delete', "<i class='trash icon'></i>", "handleFileDelete", false);
- addContextMenuSeperator($("#contextmenu"));
- addContextMenuItem($("#contextmenu"), 'Properties', undefined, "openObjectProperty", false);
- }else{
- //When the user only selected one item
- if (objectType == "file") {
- addContextMenuItem($("#contextmenu"), 'Open', undefined, "openIconViaMenu", false);
- addContextMenuItem($("#contextmenu"), 'Open With', "<i class='caret right icon'></i>", "handleOpenWith", true);
- addContextMenuItem($("#contextmenu"), 'Share', "<i class='caret right icon'></i>", "handleFileShare", true);
- addContextMenuSeperator($("#contextmenu"));
- addContextMenuItem($("#contextmenu"), 'Download', "<i class='download icon'></i>", "downloadFile", false);
- addContextMenuItem($("#contextmenu"), 'Make a Copy', "<i class='copy icon'></i>", "handleCloning", false);
- addContextMenuItem($("#contextmenu"), 'Rename', undefined, "handleRename", false);
- addContextMenuItem($("#contextmenu"), 'Delete', "<i class='trash icon'></i>", "handleFileDelete", false);
- addContextMenuSeperator($("#contextmenu"));
- addContextMenuItem($("#contextmenu"), 'Properties', undefined, "openObjectProperty", false);
- } else if (objectType == "folder") {
- addContextMenuItem($("#contextmenu"), 'Open', undefined, "openIconViaMenu", false);
- addContextMenuItem($("#contextmenu"), 'Zip here', "<i class='zip icon'></i>", "handleZipFolder", false);
- addContextMenuItem($("#contextmenu"), 'Share', "<i class='caret right icon'></i>", "handleFileShare", true);
- addContextMenuSeperator($("#contextmenu"));
- addContextMenuItem($("#contextmenu"), 'Download as Zip', "<i class='download icon'></i>", "downloadFile", false);
- addContextMenuItem($("#contextmenu"), 'Make a Copy', "<i class='caret right icon'></i>", "handleCloning", false);
- addContextMenuItem($("#contextmenu"), 'Rename', undefined, "handleRename", false);
- addContextMenuItem($("#contextmenu"), 'Delete', "<i class='trash icon'></i>", "handleFileDelete", false);
- addContextMenuSeperator($("#contextmenu"));
- addContextMenuItem($("#contextmenu"), 'Properties', undefined, "openObjectProperty", false);
- } else if (objectType == "shortcut") {
- var fd = JSON.parse(decodeURIComponent($(clickTarget).attr("filedata")));
- console.log(fd);
- if (fd.ShortcutType == "module"){
- //Public WebApp
- addContextMenuItem($("#contextmenu"), 'Open', undefined, "openIconViaMenu", false);
- addContextMenuItem($("#contextmenu"), 'Open in New Tab', "<i class='external icon'></i>", "openWebAppInNewTab", false);
- addContextMenuItem($("#contextmenu"), 'Rename', undefined, "handleRename", false);
- addContextMenuItem($("#contextmenu"), 'Delete', "<i class='trash icon'></i>", "handleFileDelete", false);
- }else if (fd.ShortcutType == "folder"){
- //Folder
- addContextMenuItem($("#contextmenu"), 'Open', undefined, "openIconViaMenu", false);
- addContextMenuItem($("#contextmenu"), 'Open File Location', "<i class='folder open icon'></i>", "handleShortcutFolderOpen", false);
- addContextMenuItem($("#contextmenu"), 'Rename', undefined, "handleRename", false);
- addContextMenuItem($("#contextmenu"), 'Delete', "<i class='trash icon'></i>", "handleFileDelete", false);
- addContextMenuSeperator($("#contextmenu"));
- addContextMenuItem($("#contextmenu"), 'Properties', undefined, "openObjectProperty", false);
-
- }else{
- addContextMenuItem($("#contextmenu"), 'Open', undefined, "openIconViaMenu", false);
- addContextMenuItem($("#contextmenu"), 'Delete', "<i class='trash icon'></i>", "handleFileDelete", false);
- }
-
-
- }else{
- console.log("Opening context menu on unknown type: ", objectType);
- }
- }
- showMenu = true;
- } else if (clickTarget.hasClass("backgroundFrame") || ((isSafari || (isMacOS && isChrome)) && $(clickTarget).attr("id") == "selectionPanel")) {
- //Click on the background. Load background context menu.
- addContextMenuItem($("#contextmenu"), 'New', "<i class='caret right icon'></i>", "newitemmenu", true);
- addContextMenuItem($("#contextmenu"), 'Refresh', "<i class='refresh icon'></i>", "handleMenuRefresh", false);
- addContextMenuItem($("#contextmenu"), 'Open File Manager', undefined, "openfm", false);
- //addContextMenuItem($("#contextmenu"), 'Get File from URL', "<i class='download icon'></i>", "downloadURL", false);
- addContextMenuItem($("#contextmenu"), 'Personalization', "<i class='paint brush icon'></i>", "personalization", false);
- addContextMenuItem($("#contextmenu"), 'Background', "<i class='caret right icon'></i>", "background", true);
- addContextMenuItem($("#contextmenu"), 'Icon Size', "<i class='caret right icon'></i>", "listIconsize", true);
- addContextMenuItem($("#contextmenu"), 'Toggle FullScreen', "<i class='maximize icon'></i>", "fullscreen", false);
- addContextMenuItem($("#contextmenu"), 'Exit', undefined, "logout", false);
- showMenu = true;
- }else if (clickTarget.hasClass("fwdragger") || (clickTarget.hasClass("title") && clickTarget.parent().hasClass("fwdragger"))){
- //Click on the floatWindow object
- addContextMenuItem($("#contextmenu"), 'Open in New Tab', "<i class='external icon'></i>", "openSelectedFloatWindowInNewTab", false);
- addContextMenuItem($("#contextmenu"), 'Refresh', "<i class='refresh icon'></i>", "refreshSelectedFloatWindow", false);
- addContextMenuSeperator($("#contextmenu"));
- addContextMenuItem($("#contextmenu"), 'Minimize', "<i class='window minimize icon'></i>", "minimizeSelectedFloatWindow", false);
- if ($(clickTarget).parent().hasClass("fixedsize") == false && $(clickTarget).parent().parent().hasClass("fixedsize") == false){
- //This FloatWindow is resizable
- console.log($(clickTarget).parent());
- if ($(clickTarget).parent().attr("max") !== undefined && $(clickTarget).parent().attr("max") == "true"){
- addContextMenuItem($("#contextmenu"), 'Restore', "<i class='window window restore icon'></i>", "maximizeSelectedFloatWindow", false);
- }else{
- addContextMenuItem($("#contextmenu"), 'Maximize', "<i class='window maximize icon'></i>", "maximizeSelectedFloatWindow", false);
- }
-
- }
- addContextMenuItem($("#contextmenu"), 'Close', "<i class='remove icon'></i>", "closeSelectedFloatWindow", false);
- showMenu = true;
- }
-
- if (showMenu){
- //Toggle context menu
- $("#contextmenu").show();
- var startX = e.pageX;
- var startY = e.pageY;
- if (e.pageX > window.innerWidth / 2){
- startX = e.pageX - $("#contextmenu").width();
- }
- if (e.pageY > window.innerHeight / 2){
- startY = e.pageY - $("#contextmenu").height();
- }
- $("#contextmenu").css({
- left: startX,
- top: startY
- });
- menuStartLocation = [e.pageX, e.pageY];
- }
-
- }, true);
- function handleMenuRefresh() {
- //This function is here to remove the object and event passed in from menu pressed object
- refresh();
- }
- function newshortcut(){
- //Show the new shortcut creation tool
- newFloatWindow({
- url: "SystemAO/desktop/shortcutCreator.html",
- appicon: "img/desktop/system_icon/shortcut.png",
- width:815,
- height:485,
- title: "New Shortcut"
- });
- hideAllContextMenus();
- }
- function openIconViaMenu(target, event){
- $(".launchIconWrapper.selected").each(function(){
- iconObject = $(this).parent();
- //Emulate a doubleclick on icon
- iconDoubleClicked(iconObject, event);
- });
- hideAllContextMenus();
- }
- //Opening a shortcut module from desktop to new tab
- function openWebAppInNewTab(target, event){
- $(".launchIconWrapper.selected").each(function(){
- var fd = JSON.parse(decodeURIComponent($(this).parent().attr("filedata")));
- $.get("system/modules/getLaunchPara?module=" + fd.ShortcutPath, function(data) {
- if (data.error !== undefined) {
- console.log(data.error);
- }else{
- //Open in new tab
- window.open(data.StartDir)
- }
- });
- });
- }
- function downloadFile(target, event){
- if ( $(".launchIconWrapper.selected").length == 1){
- //Download this file directly
- var rawfiledata = $(".launchIconWrapper.selected").parent().attr("filedata");
- var filedata = JSON.parse(decodeURIComponent(rawfiledata));
- var filepath = filedata.Filepath;
- //Resolve the link to media download link
- var downloadLink = "media?file=" + filepath + "&download=true";
- window.open(downloadLink)
- }else if ($(".launchIconWrapper.selected").length > 1){
- //Create a zip file using the fs api
- var filelist = [];
- $(".launchIconWrapper.selected").each(function(){
- var filedata = JSON.parse(decodeURIComponent($(this).parent().attr("filedata")));
- var filepath = filedata.Filepath;
- filelist.push(filepath);
- });
- $.ajax({
- url: "system/file_system/zipHandler",
- data: {opr: "tmpzip", src: JSON.stringify(filelist), dest: ""},
- method: "POST",
- success: function(data){
- if (data.error !== undefined){
- alert(data.error);
- }else{
- //Zip completed.
- window.open("media?file=" + data + "&download=true");
- }
- }
- });
- }
-
- hideAllContextMenus();
- }
- function handleZipFolder(){
- var filelist = [];
- var filename = "desktop_" + new Date().getTime() + ".zip"
- if ($(".launchIconWrapper.selected").length == 1){
- filename = $(".launchIconWrapper.selected").parent().attr('filename') + ".zip";
- }
- $(".launchIconWrapper.selected").each(function(){
- var filedata = JSON.parse(decodeURIComponent($(this).parent().attr("filedata")));
- var filepath = filedata.Filepath;
- if (filedata.IsDir == true){
- filelist.push(filepath);
- }
- });
- $.ajax({
- url: "system/file_system/zipHandler",
- data: {opr: "zip", src: JSON.stringify(filelist), dest: "user:/Desktop/" + filename},
- method: "POST",
- success: function(data){
- if (data.error !== undefined){
- alert(data.error);
- }else{
- //Zip completed.
- console.log(data);
- }
- }
- });
- //console.log(filelist);
- hideAllContextMenus();
- }
- function handleOpenWith(target, event){
- $("#subcontextmenu").html("");
- //Updates 19 May 2021: Added support for better parsing Open With List
- var exts = [];
- //Get all exts from the selected files
- $(".launchIconWrapper.selected").each(function(){
- var filename = $(this).parent().attr("filename");
- var ext = "." + filename.split(".").pop();
- exts.push(ext);
- });
- $.get("system/modules/list",function(data){
- if (data.error !== undefined){
- alert(data.error);
- }else{
- var supportedModuleCount = 0;
- var openWithTargets = [];
- for (var i =0; i < data.length; i++){
- var thisModule = data[i];
- //If this module support this ext, add it to list
- var thisModuleSupportExt = thisModule.SupportedExt;
- if (thisModule.Name == "File Manager"){
- //Exceptional case
- addContextMenuItem($("#subcontextmenu"), thisModule.Name, "", "openSelectedWith", false);
- }
- if (thisModuleSupportExt == null || thisModuleSupportExt.length == 0){
- //Not supporting anything
- continue;
- }
- thisModuleSupportExt.forEach(supportedExt => {
- if (exts.includes(supportedExt)){
- //Add this to the menu
- addContextMenuItem($("#subcontextmenu"), thisModule.Name, "", "openSelectedWith", false);
- }
- })
-
- //if (thisModule.SupportEmb == true){
- // addContextMenuItem($("#subcontextmenu"), thisModule.Name, "", "openSelectedWith", false);
- //}
- }
- //Add select more opener option
- addContextMenuSeperator($("#subcontextmenu"));
- addContextMenuItem($("#subcontextmenu"), "Select Other WebApps", ``, "openOpenSelector", false);
- }
- showSubContextMenu(target);
- });
- }
- function handleFileShare(target, object){
- $("#subcontextmenu").html("");
- //Get the selected file
- var targetFile = $(".launchIconWrapper.selected")[0];
- var fileData = $(targetFile).parent().attr("filedata");
- if (fileData != undefined){
- fileData = JSON.parse(decodeURIComponent(fileData));
- //Check if the target file is shared
- $.ajax({
- url: "system/file_system/share/checkShared",
- data: {path: fileData.Filepath},
- success: function(data){
- if (data.IsShared == true){
- addContextMenuItem($("#subcontextmenu"), "Open Shared Link", `<i class="external icon"></i>`, "openSharedLink", false, {
- payload: {
- uuid: data.ShareUUID.UUID
- }
- });
- addContextMenuItem($("#subcontextmenu"), "Copy Link", `<i class="copy icon"></i>`, "copySharedLink", false, {
- payload: {
- uuid: data.ShareUUID.UUID
- }
- });
- addContextMenuSeperator($("#subcontextmenu"));
- addContextMenuTitle($("#subcontextmenu"), `<i class="share alternate icon"></i> Change Share Settings`);
- }else{
- addContextMenuTitle($("#subcontextmenu"), `<i class="share alternate icon"></i> Share this File`);
- }
- var checkmarkStyle = `style="color: #71ba68;"`;
- var anyoneClass = "";
- if (data.ShareUUID.Permission == "anyone"){
- anyoneClass = `<i ${checkmarkStyle} class="checkmark icon"></i>`;
- }
- var signedinClass = "";
- if (data.ShareUUID.Permission == "signedin"){
- signedinClass = `<i ${checkmarkStyle} class="checkmark icon"></i>`;
- }
- var sameGroupClass = "";
- if (data.ShareUUID.Permission == "samegroup"){
- samegroup = `<i ${checkmarkStyle} class="checkmark icon"></i>`;
- }
- addContextMenuItem($("#subcontextmenu"), `<i class="globe icon"></i> Anyone with Link`, anyoneClass, "shareWithThisPermission", false, {
- payload: {
- type: "anyone"
- }
- });
- addContextMenuItem($("#subcontextmenu"), `<i class="user circle outline icon"></i> Anyone Signed In`, signedinClass, "shareWithThisPermission", false, {
- payload: {
- type: "signedin"
- }
- });
- addContextMenuItem($("#subcontextmenu"), `<i class="users icon"></i> Same Group Users`, sameGroupClass, "shareWithThisPermission", false,{
- payload: {
- type: "samegroup"
- }
- });
- if (data.IsShared == true){
- //This file is shared.
- addContextMenuSeperator($("#subcontextmenu"));
- addContextMenuItem($("#subcontextmenu"), "Remove Share", `<i style="color: #d97762;" class="trash icon"></i>`, "shareWithThisPermission", false,{
- payload: {
- type: "remove"
- }
- });
- }
- }
- });
- }
-
- showSubContextMenu(target);
- }
- //Copy the shared link
- function copySharedLink(target, event){
- var payload = getContextMenuPayload(target);
- if (payload == null){
- //Something wrong
- return;
- }
- //Generate the share link
- let protocol = "https://";
- if (location.protocol !== 'https:') {
- protocol = "http://";
- }
- var shareURL = protocol + window.location.hostname + ":" + window.location.port + "/share?id=" + payload.uuid;
- //Copy the text to clipboard
- const area = document.createElement('textarea');
- document.body.appendChild(area);
- area.value = shareURL;
- area.select();
- document.execCommand('copy');
- document.body.removeChild(area);
- //Update status so it show the user it has been coped
- $(target).html(`<i style="color: #71ba68;" class="checkmark icon"></i> Copied!`);
- setTimeout(function(){
- if ($(target).length > 0){
- $(target).html(`Copy Link
- <span class="description">
- <i class="copy icon"></i>
- </span>`);
- }
- }, 3000);
- }
- //Open the shared file link
- function openSharedLink(target, event){
- var payload = getContextMenuPayload(target);
- if (payload == null){
- //Something wrong
- return;
- }
- var targetURL = "share?id=" + payload.uuid;
- window.open(targetURL);
- hideAllContextMenus();
- }
- function shareWithThisPermission(target, event){
- var payload = getContextMenuPayload(target);
- if (payload == null){
- //Something wrong
- return;
- }
- //Get the selected file
- var selectedFileObjects = $(".launchIconWrapper.selected");
- if (selectedFileObjects.length == 0){
- //Not found
- return
- }else if (selectedFileObjects.length > 1){
- //This should not happens. If it did happens, use the first one
- selectedFileObjects = selectedFileObjects[0];
- }
- //Extract file information
- var fileData = $(selectedFileObjects).parent().attr("filedata");
- fileData = JSON.parse(decodeURIComponent(fileData));
-
- //Convert the desktop file data to ArozOS generic filedata
- var afd = {
- "filename": fileData.Filename,
- "filepath": fileData.Filepath,
- "shareMode": payload.type
- };
- //Create a new share for this
- var targetURL = "SystemAO/file_system/file_share.html#" + encodeURIComponent(JSON.stringify([afd]));
- //Calculate the window spawn position
- var basePosition = $(selectedFileObjects).offset();
- var left = basePosition.left + 100;
- if (left + 320 > window.innerWidth){
- left = basePosition.left - 350;
- }
- var top = basePosition.top;
- if (top + 480 > window.innerHeight){
- top = window.innerHeight - 480;
- }
- newFloatWindow({
- url: targetURL,
- width: 330,
- height: 480,
- left: left,
- top: top,
- appicon: "SystemAO/file_system/img/share.svg",
- title: "Share File"
- }, function(windowUUID){
- //Set the window to fixed window
- setFloatWindowResizePolicy(windowUUID, false);
- });
- hideAllContextMenus();
- }
- function openObjectProperty(target, object){
- var filelist = [];
- $(".launchIconWrapper.selected").each(function(){
- var filepath = $(this).parent().attr("filepath");
- filelist.push(filepath);
- });
-
- var hashPassthrough = encodeURIComponent(JSON.stringify(filelist));
- newFloatWindow({
- url: "SystemAO/file_system/file_properties.html#" + hashPassthrough,
- width: 340,
- height: 480,
- appicon: "SystemAO/file_system/img/properties.png",
- title: "File Properties",
- });
- hideAllContextMenus();
- }
- //Open the file extension selector
- function openOpenSelector(target, event){
- var filedata = $($(".launchIconWrapper.selected")[0]).parent().attr("filedata")
- filedata = JSON.parse(decodeURIComponent(filedata));
-
- var fileDescriptor = {
- filepath: filedata.Filepath,
- filename: filedata.Filename
- }
-
- newFloatWindow({
- url: "SystemAO/file_system/defaultOpener.html#" + encodeURIComponent(JSON.stringify(fileDescriptor)),
- width: 320,
- height: 510,
- appicon: "SystemAO/file_system/img/opener.png",
- title: "Select WebApp to Open File",
- });
- hideAllContextMenus();
- }
- function openSelectedWith(target, event){
- var targetModulename = $(target).text().trim();
- var openFileList = [];
- $(".selected.launchIconWrapper").each(function(){
- var thisFiledata = JSON.parse(decodeURIComponent($(this).parent().attr("filedata")));
- openFileList.push({
- filename: thisFiledata.Filename,
- filepath: thisFiledata.Filepath
- });
- });
- //Find the launch info of the module
- var targetModuleInfo = undefined;
- for (var i =0; i < moduleInstalled.length; i++){
- if (moduleInstalled[i].Name == targetModulename){
- targetModuleInfo = JSON.parse(JSON.stringify(moduleInstalled[i]));
- }
- }
- //Open the files with the given module
- openFileWithModule(targetModuleInfo, openFileList);
- hideAllContextMenus();
- }
- function getModuleInfoFromName(moduleName){
- for (var i = 0; i < moduleInstalled.length; i++){
- if (moduleInstalled[i].Name == moduleName){
- return moduleInstalled[i];
- }
- }
- return false
- }
- /*
- This function is used to generate menu items for context menu.
- Options example
- {
- payload: {
- //Some JSON based payload here
- }
- }
- */
- function addContextMenuItem(target, keyword, hotkey = undefined, functionName, containSubMenu = false, options=undefined) {
- var itemClass = "item";
- if (containSubMenu) {
- itemClass = "item submenu";
- }
- var payload = "";
- if (options != undefined && options.payload != undefined){
- payload = encodeURIComponent(JSON.stringify(options.payload));
- }
- if (hotkey !== undefined) {
- target.append(`<div class="${itemClass}" onclick="${functionName}(this,event);" payload="${payload}">
- ${keyword}
- <span class="description">${hotkey}</span>
- </div>`);
- } else {
- target.append(`<div class="${itemClass}" onclick="${functionName}(this,event);" payload="${payload}">
- ${keyword}
- </div>`);
- }
- }
- function getContextMenuPayload(object){
- var encodedPayload = $(object).attr("payload");
- if (encodedPayload != ""){
- return JSON.parse(decodeURIComponent(encodedPayload));
- }else{
- return null;
- }
- }
- function listIconsize(target, event) {
- $("#subcontextmenu").html("");
- var smallCheckmark = undefined;
- var mediumCheckmark = undefined;
- var bigCheckmark = undefined;
- if (desktopIconSize == "small") {
- smallCheckmark = "<i class='checkmark icon'></i>";
- }
- if (desktopIconSize == "medium") {
- mediumCheckmark = "<i class='checkmark icon'></i>";
- }
- if (desktopIconSize == "big") {
- bigCheckmark = "<i class='checkmark icon'></i>";
- }
- addContextMenuItem($("#subcontextmenu"), "Small", smallCheckmark, "setDesktopIconSize", false);
- addContextMenuItem($("#subcontextmenu"), "Medium", mediumCheckmark, "setDesktopIconSize", false);
- addContextMenuItem($("#subcontextmenu"), "Big", bigCheckmark, "setDesktopIconSize", false);
- showSubContextMenu(target);
- }
- function setDesktopIconSize(target, evt) {
- var targetSize = $(target).text().trim().toLowerCase();
- if (["small", "medium", "big"].includes(targetSize)) {
- desktopIconSize = targetSize;
- }
- refresh();
- setStorage("iconsize", desktopIconSize);
- hideAllContextMenus();
- }
- function addContextMenuSeperator(target) {
- $(target).append(`<div class="divider"></div>`);
- }
- function addContextMenuTitle(target, title){
- $(target).append(`<div class="header">
- ${title}
- </div>`);
- }
- function downloadURL() {
- alert("WIP");
- hideAllContextMenus();
- }
- function background(target, evt) {
- $("#subcontextmenu").html('<div class="item"><i class="loading spinning icon"></i> Loading</div>');
- $.get("system/desktop/theme", function(data) {
- $("#subcontextmenu").html("");
- for (var i = 0; i < data.length; i++) {
- if (currentUserTheme == data[i].Theme) {
- addContextMenuItem($("#subcontextmenu"), data[i].Theme, "<i class='checkmark icon'></i>", "setTheme", false);
- } else {
- addContextMenuItem($("#subcontextmenu"), data[i].Theme, undefined, "setTheme", false);
- }
- }
- });
- showSubContextMenu(target);
- }
- //Set theme from button click
- function setTheme(target, evt) {
- var theme = $(target).text().trim();
- setDesktopTheme(theme);
- hideAllContextMenus();
- }
- function personalization() {
- //Show the personalization window
- newFloatWindow({
- url: "SystemAO/desktop/personalization.html",
- appicon: "SystemAO/desktop/img/personalization.png",
- width:640,
- height:480,
- title: "Personalization"
- });
- hideAllContextMenus();
- }
- //New folder on the menu start location
- function newfolder(object, event) {
- var closestLocation = findClosestGrid(menuStartLocation[0], menuStartLocation[1], false);
- let closestPixelLocation = closestLocation[0];
- let closestGridIndexLocation = closestLocation[1];
- //Generate new foldername
- var newFolderName = "New Folder";
- var counter = 1;
- while (desktopFileList.includes(newFolderName)) {
- newFolderName = `New Folder(${counter})`;
- counter++;
- }
- //Check if there are already another object at that locaton
- var duplicateObject = getObjectFromLocation(closestPixelLocation[0], closestPixelLocation[1]);
- var createObjectLocation = true;
- if (duplicateObject !== undefined) {
- //Ignore create position. Let it settle on next new slot.
- createObjectLocation = false;
- }
- //Create the folder
- requestCSRFToken(function(token){
- $.post("system/file_system/newItem", {
- type: "folder",
- src: "user:/Desktop/",
- filename: newFolderName,
- csrft: token
- }).done(function(data) {
- if (data.error !== undefined) {
- alert(data.error);
- } else {
- if (createObjectLocation) {
- setIconDesktopLocation(newFolderName, closestGridIndexLocation[0], closestGridIndexLocation[1], function() {
- //After set Desktop icon, refresh the page
- refresh(function() {
- //After refresh the page, highlight the new folder and set it to rename mode
- var targetFolderObject = getObjectFromGridLocation(closestGridIndexLocation[0], closestGridIndexLocation[1]);
- console.log(targetFolderObject);
- enableRenameOnLaunchIconObject(targetFolderObject);
- });
- });
- }
- }
- });
- });
- /*
- //Open new folder creation window
- var existsingFileList = [];
- for (var i =0; i < desktopFileList.length; i++){
- existsingFileList.push({
- filename: desktopFileList[i],
- filepath: "user:/Desktop/" + desktopFileList[i]
- });
- }
- newFloatWindow({
- url: "SystemAO/file_system/newFolder.html#" + encodeURIComponent(JSON.stringify(existsingFileList)),
- appicon: "SystemAO/file_system/img/new folder.png",
- width:560,
- height:340,
- title: "New Folder"
- });
- */
- hideAllContextMenus();
- }
- function enableRenameOnLaunchIconObject(object) {
- renameMode = true;
- $(".launchIcon").attr("draggable", "false");
- var filedata = JSON.parse(decodeURIComponent($(object).attr("filedata")));
- var originalName = filedata.Filename;
- if (filedata.IsShortcut){
- //Shortcut. Use its display name instead
- originalName = filedata.ShortcutName;
- }
- $(object).find(".launchIconText").hide();
- $(object).append(`<textarea class="renameInput ${desktopIconSize}" type="text" ondragstart="return false;" dblclick="event.stopImmediatePropagation(); event.stopImmediatePropagation();"maxlength="32">${originalName}</textarea>`);
- $(object).find(".renameInput")[0].select();
- var index = originalName.lastIndexOf(".");
- console.log(index);
- if( index >= 0){
- $(object).find(".renameInput")[0].setSelectionRange(0, index);
- }
- //Updates 4-5-2021: Added IME support on rename input
- $(object).find(".renameInput")[0].addEventListener("keydown", function(event){
- if (window.ime && window.ime.handler != null){
- window.ime.handler(event);
- }else{
- //No IME handler. Just continue the input
- }
- });
- window.ime.focus = $(object).find(".renameInput")[0];
- }
- function exitRenameMode() {
- if (renameMode) {
- $(".launchIcon").attr("draggable", "true");
- $(".launchIcon").find(".launchIconText").show();
- //Update the folder to textarea content
- $(".renameInput").each(function() {
- if ($(this).text() == "") {
- //Ignore this update
- } else {
- var filedata = JSON.parse(decodeURIComponent($(this).parent().attr("filedata")));
- var filepath = filedata.Filepath;
- var newFilename = $(this).val();
-
- if (filedata.IsShortcut == true){
- //Shortcut. Edit the shortcut content name
- let currentInputTextArea = $(this);
- $.ajax({
- url: "/system/desktop/opr/renameShortcut",
- data: {src: filepath, new: newFilename},
- success: function(data){
- if (data.error !== undefined){
- //Cancel the operation
- console.log("*ERROR* " + data.error);
- currentInputTextArea.remove();
- }else{
- //No need to update the shortcut position (as its name not changed)
- refresh(function() {
- //Refresh the desktop
- });
- }
- }
- })
- }else{
- //Normal typed files / folder. Rename the object
- let currentInputTextArea = $(this);
- generateCSRFToken(function(csrftoken){
- $.ajax({
- url: "./system/file_system/fileOpr",
- method: "POST",
- data: {opr: "rename", src: JSON.stringify([filepath]), new: JSON.stringify([newFilename]), csrft: csrftoken},
- success: function(data){
- if (data.error !== undefined){
- //Cancel the operation
- alert(data.error);
- console.log("*ERROR* " + data.error);
- currentInputTextArea.remove();
- }else{
- //Update the new file position
- let closestLocation = findClosestGrid($(currentInputTextArea).parent().offset().left, $(currentInputTextArea).parent().offset().top);
- let closestGridIndexLocation = closestLocation[1];
- setIconDesktopLocation(newFilename, closestGridIndexLocation[0], closestGridIndexLocation[1], function(){
- //Callback after setting location
- refresh(function() {
- //Refresh the desktop
- });
- });
- }
- }
- });
- });
- }
- }
- });
- renameMode = false;
- }
- }
- //Handle opening shortcut folder location
- function handleShortcutFolderOpen(object, event){
- var openPendingFolders = [];
- $(".launchIconWrapper.selected").each(function(){
- var filedata = JSON.parse(decodeURIComponent($(this).parent().attr("filedata")));
- console.log(filedata);
- if (filedata.IsShortcut == true){
- if (filedata.ShortcutType == "folder"){
- openPendingFolders.push(filedata.ShortcutPath);
- }else if (filedata.ShortcutType == "module"){
- openPendingFolders.push("web:/" + filedata.ShortcutPath);
- }
-
- }
- });
- //Open all folders
- openPendingFolders.forEach(folder => {
- newFloatWindow({
- url: "SystemAO/file_system/file_explorer.html#" + encodeURIComponent(folder),
- appicon: "SystemAO/file_system/img/small_icon.png",
- width:1080,
- height:580,
- title: "File Manager"
- });
- })
- hideAllContextMenus();
- }
- //Handle basic desktop file operations
- function handleFileDelete(object, event){
- var deleteFileList = [];
- $(".launchIconWrapper.selected").each(function(){
- var filedata = JSON.parse(decodeURIComponent($(this).parent().attr("filedata")));
- deleteFileList.push(filedata.Filepath);
- });
- console.log(deleteFileList);
- generateCSRFToken(function(csrftoken){
- $.ajax({
- url: "system/file_system/fileOpr",
- method:"POST",
- data: {opr: "recycle", src: JSON.stringify(deleteFileList), csrft: csrftoken},
- success: function(data){
- if (data.error !== undefined){
- alert(data.error);
- }else{
- refresh(undefined, true);
- }
- }
- });
- hideAllContextMenus();
- });
-
- }
- //File Rename
- let renamingItems = [];
- function handleRename(object, event){
- if ($('.launchIconWrapper.selected').length > 0){
- //Enter rename mode
- renamingItems = $('.launchIconWrapper.selected');
- let renameTarget = $('.launchIconWrapper.selected')[0]
- let fileObject = $(renameTarget).parent();
- enableRenameOnLaunchIconObject(fileObject);
- }
- hideAllContextMenus();
- }
- //New item menus.
- function newitemmenu(target, event) {
- $("#subcontextmenu").html("");
- //Append the new folder option first
- addContextMenuItem($("#subcontextmenu"), 'Folder', "<i class='folder icon'></i>", "newfolder", true);
- addContextMenuItem($("#subcontextmenu"), 'Shortcut', "<i class='external icon'></i>", "newshortcut", true);
- addContextMenuSeperator($("#subcontextmenu"));
- requestCSRFToken(function(token){
- $.ajax({
- url: "system/file_system/newItem",
- data: {csrft: token},
- success: function(data){
- for (var i = 0; i < data.length; i++) {
- var thisNewFile = data[i];
- var icon = ao_module_utils.getIconFromExt(thisNewFile.Ext);
- addContextMenuItem($("#subcontextmenu"), `<i class="${icon} icon" ext="${thisNewFile.Ext}"></i> ${thisNewFile.Desc}`, undefined, "newitem");
- }
- //Show sub-context menu
- showSubContextMenu(target);
- }
- })
- });
- }
- function showSubContextMenu(target) {
- $("#subcontextmenu").show();
- var targetLeft = $("#contextmenu").offset().left + $("#contextmenu").width() + 2;
- var targetTop = $(target).offset().top - 1;
- if (targetLeft + $("#subcontextmenu").width() > window.innerWidth){
- //Overflow. Swtich to the left side of the menu
- targetLeft = $("#contextmenu").offset().left - $("#subcontextmenu").width() - 2;
- }
- $("#subcontextmenu").css({
- left: targetLeft,
- top: targetTop
- });
-
- }
- //Create new file item with that filename
- function newitem(object, event) {
- var extension = $(object).find("i").attr("ext");
- //Generate a newfile name
- var newfn = "NewFile" + "." + extension;
- var counter = 1;
- while (desktopFileList.includes(newfn)){
- newfn = "NewFile (" + counter + ")." + extension;
- counter++;
- }
- //Get the location position
- let closestLocation = findClosestGrid(menuStartLocation[0], menuStartLocation[1], false);
- let closestGridIndexLocation = closestLocation[1];
- //Request backend to generate the new file
- $.ajax({
- url: "system/file_system/newItem",
- data: {type: "file",src: "user:/Desktop/",filename: newfn, csrft: token},
- success: function(data){
- if (data.error !== undefined){
- alert(data.error);
- }else{
- //Set the icon location
- setIconDesktopLocation(newfn, closestGridIndexLocation[0], closestGridIndexLocation[1], function(){
- //Refresh the desktop
- refresh(function(){
- var targetNewFile = getObjectFromGridLocation(closestGridIndexLocation[0], closestGridIndexLocation[1]);
- console.log("Renaming ", targetNewFile);
- enableRenameOnLaunchIconObject(targetNewFile);
- });
- });
- }
- }
- });
- hideAllContextMenus();
- }
- document.getElementById("volumebar").parentNode.addEventListener("touchstart", function(e){
- updateVolume( document.getElementById("volumebar").parentNode, e);
- });
- function getCoordinateFromEvent(e){
- var x = -1;
- var y = -1;
- if (e.originalEvent == undefined){
- e.originalEvent = e;
- }
- if(e.type == 'touchstart' || e.type == 'touchmove' || e.type == 'touchend' || e.type == 'touchcancel'){
- var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
- x = touch.pageX;
- y = touch.pageY;
- } else if (e.type == 'mousedown' || e.type == 'mouseup' || e.type == 'mousemove' || e.type == 'mouseover'|| e.type=='mouseout' || e.type=='mouseenter' || e.type=='mouseleave') {
- x = e.clientX;
- y = e.clientY;
- }else{
- x = e.clientX;
- y = e.clientY;
- }
- return [x,y];
- }
- function updateVolume(object, event){
- var width = $(object).width();
- var left = $(object).offset().left;
- var clickPosition = getCoordinateFromEvent(event)[0];
- var clickRel = clickPosition - left;
- var percentage = clickRel / width * 100;
- if (percentage < 0){
- percentage = 0;
- }else if (percentage > 100){
- percentage = 100;
- }
- //Update the global volume
- $(object).find(".bar").css("width",percentage + "%");
- localStorage.setItem("global_volume", clickRel / width);
- }
- function refresh(callback = undefined, noflash=false) {
- //Refresh desktop contents
- let launchOption = {};
- if (noflash){
- launchOption = {
- noflash: true
- };
- }else{
- $(".launchIcon").remove();
- }
- if (callback == undefined) {
- initDesktopFiles(launchOption, function(){
- startThumbnailLoader();
- });
- } else {
- initDesktopFiles(launchOption, function(){
- startThumbnailLoader();
- callback()
- });
- }
-
- hideAllContextMenus();
- }
- function startThumbnailLoader(){
- let path = "user:/Desktop";
- let protocol = "wss://";
- if (location.protocol !== 'https:') {
- protocol = "ws://";
- }
- var port = window.location.port;
- if (window.location.port == ""){
- port = "80";
- }
- thumbRenderWebSocket = new WebSocket(protocol + window.location.hostname + ":" + port + "/system/file_system/handleCacheRender?folder=" + path);
- thumbRenderWebSocket.onopen = function(e) {
- };
- thumbRenderWebSocket.onmessage = function(event) {
- //Find the correct file in the current directory and place its image
- let thumbData = JSON.parse(event.data);
- $(".launchIcon").each(function(){
- if (thumbData[1].length > 0){
- if ($(this).attr("filename") == thumbData[0]){
- let imageContainer = $(this).find(".launchIconImage");
- imageContainer.attr("src","data:image/jpg;base64," + thumbData[1]);
- imageContainer.css("padding", "0.6em");
- //Load the application icon on this file
- let filedata = $(this).attr("filedata");
- filedata = JSON.parse(decodeURIComponent(filedata));
- $.ajax({
- url: "system/modules/getDefault",
- data: {opr: "launch", ext: filedata.Ext},
- method: "GET",
- success: function(data){
- if (data.error == undefined){
- let iconSize = 20;
- let topOffset = $(imageContainer).height() - iconSize/2 + 2;
- $(imageContainer).parent().append(`<img src="${data.IconPath}" style="position: absolute; right: 0px; top: ${topOffset}px; width: ${iconSize}px; height: ${iconSize}px; pointer-events:none;"></img>`);
- }
- }
- })
- }
- }
- });
- };
- thumbRenderWebSocket.onclose = function(event) {
- //Transfer ended
- };
- thumbRenderWebSocket.onerror = function(error) {
- console.log(error);
- };
- }
- function openfm() {
- //Open file explorer on desktop
- newFloatWindow({
- url: "SystemAO/file_system/file_explorer.html#" + encodeURIComponent("user:/Desktop"),
- appicon: "SystemAO/file_system/img/small_icon.png",
- width: 1080,
- height: 580,
- title: "File Manager"
- });
- hideAllContextMenus();
- }
- /*
- Notification and Notification bar related functions
- Usage:
- title -> The title of the notification
- content -> The content of the notification
- icon (optional) -> The icon of the notification
- windowOpenOption (optional) -> The window opening option for user onclick redirection
- */
- function sendNotification(title, content, icon="notice circle", windowOpenOption=null){
- if (content.length > 100){
- shortenContent = content.substring(0,100) + "...";
- }else{
- shortenContent = content;
- }
- onClickOpenWindowOption = encodeURIComponent(JSON.parse(windowOpenOption));
- $("#notificationlist").append(` <div class="notification object" originalcontent="${content}" redirect="${onClickOpenWindowOption}" onclick="openNotification(this);">
- <p class="title"><i class="${icon} icon"></i> ${title}</p>
- <p class="notifycontent">${shortenContent}</p>
- <div class="closebtn" onclick="event.stopImmediatePropagation(); closeThisNotification(this);"><i class="remove icon"></i></div>
- <div class="ts divider"></div>
- </div>`);
- $(".nonotification").hide();
-
- }
- function openNotification(obj){
- newWindowOpeningOption = JSON.parse(decodeURIComponent($(obj).attr("redirect")));
- if (newWindowOpeningOption == null){
- //Ignore
- }else{
- //Start a floatWindow to the given target
- newFloatWindow(newWindowOpeningOption);
- }
- //Clear the notiication
- closeThisNotification($(obj).find(".closebtn"));
- }
- function closeThisNotification(obj){
- $(obj).parent().slideUp("fast",function(data){
- $(this).remove();
- if ($(".notification.object").length == 0){
- $(".nonotification").show();
- }
- });
- }
- function clearAllNotification(){
- $(".notification.object").slideUp('fast',function(data){
- $(this).remove();
- $(".nonotification").show();
- });
- }
- function hideAllContextMenus() {
- $("#subcontextmenu").hide();
- $("#contextmenu").hide()
- $("#quickAccessPanel").slideUp("fast");
- }
- function restart(){
- if (!hardwareman){
- return
- }
- var apiObject = {
- api: "/system/power/restart",
- data: {},
- title: "Password Required",
- desc: "for restarting the ArozOS Host",
- thisuser: true, //This username as default, set to false for entering other user
- method: "GET"
- }
- apiObject = encodeURIComponent(JSON.stringify(apiObject));
- newFloatWindow({
- url: "SystemAO/security/authreq.html#" + apiObject,
- width: 480,
- height: 300,
- appicon: "SystemAO/security/img/lock.svg",
- title: "Restart - Authentication Required",
- parent: ao_module_windowID,
- callback: "handleRestartCallback"
- });
- }
- function shutdown(){
- if (!hardwareman){
- return
- }
- var apiObject = {
- api: "/system/power/shutdown",
- data: {},
- title: "<i class='red exclamation triangle icon'></i> Shutdown Host <i class='red exclamation triangle icon'></i>",
- desc: "Please enter your password to confirm operation.",
- thisuser: true, //This username as default, set to false for entering other user
- method: "GET"
- }
- apiObject = encodeURIComponent(JSON.stringify(apiObject));
- newFloatWindow({
- url: "SystemAO/security/authreq.html#" + apiObject,
- width: 480,
- height: 300,
- appicon: "SystemAO/security/img/lock.svg",
- title: "Shutdown - Authentication Required",
- parent: ao_module_windowID,
- callback: "handleShutdownCallback"
- })
-
- }
- //Check if this server is a low memory one
- function initUploadMode(){
- $.ajax({
- url: "system/info/getRAMinfo",
- success: function(data){
- if (data.error !== undefined){
- //Permission denied or other reasons that cannot access harwdare info. Use default mode
- lowMemoryMode = true;
- }else{
- //Check if ramsize > 1.8 GB (2GB). If yes, switch to large memory upload mode
- var memsize = JSON.parse(data);
- if (parseFloat(memsize)/ 1024 / 1024 / 1024 >= 3.8){
- console.log("[Desktop] Setting upload mode to large memory mode")
- lowMemoryMode = false;
- }
- }
- },
- error: function(){
- //Hardware mode disabled. Always use low memory upload mode instead
- lowMemoryMode = true;
- }
- });
- }
- //Generate a loading icon for this upload task
- function generateUploadingIcon(filename, position){
- //Get position for appending
- var onScreenLocation = getLocationFromGridIndex(position[0], position[1]);
- //Append to UI
- var uploadIconUUID = Date.now();
- $("#iconwrapper").append(`<div href="javascript:void(0);" class="${uploadIconUUID} launchIcon" type="dummy" filename="${filename}" filepath="user:/Desktop/${filename}" style="width:70px; height:106px;left:${onScreenLocation[0]}px; top:${onScreenLocation[1]}px;">
- <span class="launchIconWrapper">
- <img class="launchIconImage medium" src="img/desktop/files_icon/${desktopIconPack}/file upload.png" draggable="false">
- <p class="launchIconText ${desktopIconSize}" >Uploading</p>
- <div class="ts tiny primary progress" style="margin-top: -4px;">
- <div class="bar" style="min-width: 0px !important; width: 0%;"></div>
- </div>
- </span>
- </div>`);
- return uploadIconUUID;
- }
- function uploadFile(file, callback=undefined, uploadingIconUUID = undefined) {
- if (lowMemoryMode){
- /*
- Low Memory Upload Mode
- */
- var filename = encodeURIComponent(file.name);
- var filesize = file.size;
- //Open the websocket
- let path = "user:/Desktop";
- let protocol = "wss://";
- if (location.protocol !== 'https:') {
- protocol = "ws://";
- }
- var port = window.location.port;
- if (window.location.port == ""){
- port = "80";
- }
- let uploadDir = "user:/Desktop";
-
- //Fixing Firefox path issues on or above FF48.0
- if (isFirefox && file.webkitRelativePath != ""){
- //Use the webkitRelativePath instead of the name, this is a folder upload
- let pathinfo = file.webkitRelativePath.split("/");
- pathinfo.pop();
- let subpath = pathinfo.join("/");
- uploadDir = uploadDir + subpath;
- }
- let socket = new WebSocket(protocol + window.location.hostname + ":" + port + "/system/file_system/lowmemUpload?filename=" + filename + "&path=" + uploadDir);
- let currentSendingIndex = 0;
- let chunks = Math.ceil(file.size/uploadFileChunkSize,uploadFileChunkSize);
-
- //Define a function for sending a particular chunk
- function sendChunk(id, uploadingIconUUID){
- var offsetStart = id*uploadFileChunkSize;
- var offsetEnd = id*uploadFileChunkSize + uploadFileChunkSize;
- var thisblob = file.slice(offsetStart,offsetEnd);
- socket.send(thisblob);
- //console.log(id + "/" + chunks);
- //Update progress to first percentage
- var progress = id / (chunks-1) * 100.0;
- if (progress > 100){
- progress = 100;
- }
- if (uploadingIconUUID != undefined){
- //Update the progress on the object
- $("." + uploadingIconUUID + ".launchIcon").find(".bar").css("width", progress + "%");
- if (progress == 100){
- $("." + uploadingIconUUID + ".launchIcon").find(".progress").addClass("indeterminate");
- }
- }
-
- }
- //Start sending
- socket.onopen = function(e) {
- if (filesize < uploadFileChunkSize){
- //This file is smaller than chunk size, set it to somwhere within 10% - 20% so it doesn't look like it is stuck
- $("." + uploadingIconUUID + ".launchIcon").find(".bar").css("width", "15%");
- }
-
- //Send the first chunk
- sendChunk(0, uploadingIconUUID);
- currentSendingIndex++;
- };
- socket.onmessage = function(event) {
- //Append to the send index
- var incomingValue = event.data;
- if (incomingValue == "next"){
- if (currentSendingIndex == chunks + 1){
- //Already finished
- socket.send("done");
- }else{
- //Send next chunk
- sendChunk(currentSendingIndex, uploadingIconUUID);
- currentSendingIndex++;
- }
-
- }else if (incomingValue == "OK"){
- //Merge completed
-
- }else{
- //Try to parse it as JSON
- try{
- var resp = JSON.parse(incomingValue.split('\\' + '"').join("\""));
- console.log(resp);
- if (resp.error !== undefined){
- //This is an error message
- sendNotification("Upload Failed", resp.error, "remove")
- //Update the progress bar to error
-
- }
- }catch(ex){
- //Something else
- console.log(incomingValue);
- console.log(ex);
- }
- }
- };
- socket.onclose = function(event) {
- if (callback != undefined){
- callback();
- }
- };
- socket.onerror = function(error) {
- console.log(error.message);
- console.log("[Desktop] Unable to open WebSocket connection. Fall back to FORM POST upload mode. (Check your nginx / reverse proxy settings!!!)")
- //Try to fallback to FORM POST upload mode
- lowMemoryMode = false;
- uploadFile(thisFile, callback)
- return
- };
- }else{
- let url = 'system/file_system/upload'
- let uploadCurrentPath = "user:/Desktop/";
- let formData = new FormData();
- let xhr = new XMLHttpRequest();
- formData.append('file', file);
- formData.append('path', uploadCurrentPath);
- xhr.open('POST', url, true)
- xhr.upload.addEventListener("progress", function(e) {
- console.log((e.loaded * 100.0 / e.total) || 100)
- var progress = (e.loaded * 100.0 / e.total) || 100;
- if (uploadingIconUUID != undefined){
- //Update the progress on the object
- $("." + uploadingIconUUID + ".launchIcon").find(".bar").css("width", progress + "%");
- if (progress == 100){
- $("." + uploadingIconUUID + ".launchIcon").find(".progress").addClass("indeterminate");
- }
- }
- })
- xhr.addEventListener('readystatechange', function(e) {
- if (xhr.readyState == 4 && xhr.status == 200) {
- if (callback !== undefined){
- callback(e.target.response);
- }
- }
- else if (xhr.readyState == 4 && xhr.status != 200) {
- console.log("Upload failed :" + xhr.status);
- }
- })
- xhr.send(formData);
- }
- }
- function setStorage(key, value, callback = undefined) {
- $.get("system/desktop/preference?preference=" + key + "&value=" + value, function(data) {
- if (data.error !== undefined) {
- console.log(data.error);
- } else {
- if (callback !== undefined) {
- callback();
- }
- }
- });
- }
- function getStorage(key, callback) {
- $.get("system/desktop/preference?preference=" + key, callback);
- }
- function showSystemSettings(){
- var hasAccessToSetting = false;
- moduleInstalled.forEach(thismod => {
- if (thismod.Name == "System Setting"){
- openModule("System Setting");
- }
- })
- }
- function initTheme(targetTheme=undefined){
- if (targetTheme == undefined){
- $.get("../../system/file_system/preference?key=file_explorer/theme", function(data){
- if (data == "darkTheme"){
- setDarkTheme();
- }
- });
- }else{
- //Manual override mode
- if (targetTheme == "darkTheme"){
- setDarkTheme();
- }else if (targetTheme == "whiteTheme"){
- setWhiteTheme();
- }
- }
-
- }
- function setFloatWindowTheme(fwid, theme="dark"){
- var targetFW = getFloatWindowByID(fwid);
- if (theme == "dark"){
- $(targetFW).removeClass("white");
- }else if (theme == "white"){
- $(targetFW).addClass("white");
- }
- }
- function checkFileSystemAccess(){
- var allowReadWrite = false;
- moduleInstalled.forEach(thisModule => {
- if (thisModule.Name == "File Manager"){
- //This user has read write access to file system
- allowReadWrite = true;
- }
- });
- if (!allowReadWrite){
- sendNotification("READ ONLY Account", "This account is read only. You cannot perform any file operations on this desktop.");
- }
- }
- function setDarkTheme(){
- $("#listMenu").addClass("darkTheme");
- $("#powerIcon").attr("src","img/system/power-white.svg");
- $("#quickAccessPanel").addClass("darkTheme");
- $("#quickAccessPanel").find(".button").addClass("inverted");
- }
- function setWhiteTheme(){
- $("#listMenu").removeClass("darkTheme");
- $("#powerIcon").attr("src","img/system/power.svg");
- $("#quickAccessPanel").removeClass("darkTheme");
- $("#quickAccessPanel").find(".button").removeClass("inverted");
- }
- function hexToRgbA(hex, transparent=1){
- var c;
- if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
- c= hex.substring(1).split('');
- if(c.length== 3){
- c= [c[0], c[0], c[1], c[1], c[2], c[2]];
- }
- c= '0x'+c.join('');
- return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+',' + transparent + ')';
- }
- throw new Error('Bad Hex');
- }
- function setThemeColor(newThemeColor){
- //Update the global theme color
- desktopThemeColor = newThemeColor;
- //Update the related elements
- $("#statusbar").css("background-color",newThemeColor);
- $("#navimenu").css("background-color",hexToRgbA(newThemeColor, 0.5));
- $(".floatWindow .controls").css("background-color",hexToRgbA(newThemeColor, 0.85));
- //List menu theme color bar
- $("#listMenu").find(".searchBar").css("border-bottom", "2px solid " + newThemeColor);
- $("#volumebar").css("background-color", newThemeColor);
- //Connection lost notification css
- $("#connectionLost").find(".ts.card").css("background-color", hexToRgbA(newThemeColor, 0.5));
- }
- //Load the user define theme color to overwrite the default color if exists
- function initUserDefinedThemeColor(){
- $.ajax({
- url: "../../system/file_system/preference",
- data: {key: "themecolor"},
- success: function(data){
- if (data.error == undefined && data != ""){
- setThemeColor(data);
- }
- }
- });
- }
- //Float Window context menu
- function getFocusedFloatWindowID(){
- var targetFloatWindowId = "";
- $(".floatWindow").each(function() {
- var thisWindowZIndex = $(this).css("z-index");
- if (parseInt(thisWindowZIndex) == 101){
- targetFloatWindowId = $(this).attr("windowid");
- }
- });
- return targetFloatWindowId;
- }
- function getFocusedFloatWindow(){
- var focusedFwId = getFocusedFloatWindowID();
- if (focusedFwId != ""){
- var fw = getFloatWindowByID(focusedFwId);
- return fw;
- }else{
- return undefined;
- }
- }
- function refreshSelectedFloatWindow(target, event){
- var fw = getFocusedFloatWindow();
- if (fw != undefined){
- $(fw).find("iframe")[0].contentWindow.location.reload();
- }
- hideAllContextMenus();
- }
- function maximizeSelectedFloatWindow(target, event){
- var fw = getFocusedFloatWindow();
- if (fw != undefined){
- toggleMax($(fw).find(".buttons.maxtoggle"),event);
- }
- hideAllContextMenus();
- }
- function minimizeSelectedFloatWindow(target, event){
- var fw = getFocusedFloatWindow();
- if (fw != undefined){
- min($(fw).find(".buttons.mintoggle"),event);
- }
- hideAllContextMenus();
- }
- function openSelectedFloatWindowInNewTab(){
- var fw = getFocusedFloatWindow();
- if (fw != undefined){
- var currentURL = $(fw).find("iframe")[0].contentWindow.location;
- window.open(currentURL);
- }
- hideAllContextMenus();
- }
- function closeSelectedFloatWindow(target, event){
- var fw = getFocusedFloatWindow();
- if (fw != undefined){
- closeFloatWindow($(fw).find(".buttons.closetoggle"),event);
- }
- hideAllContextMenus();
- }
- function fullscreen() {
- //Opening full screen will lead to hidden of all iframe for unknown reasons
- var isInFullScreen = (document.fullscreenElement && document.fullscreenElement !== null) ||
- (document.webkitFullscreenElement && document.webkitFullscreenElement !== null) ||
- (document.mozFullScreenElement && document.mozFullScreenElement !== null) ||
- (document.msFullscreenElement && document.msFullscreenElement !== null);
- var elem = document.documentElement;
- if (!isInFullScreen) {
- if (elem.requestFullscreen) {
- elem.requestFullscreen();
- } else if (elem.mozRequestFullScreen) { /* Firefox */
- elem.mozRequestFullScreen();
- } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
- elem.webkitRequestFullscreen();
- } else if (elem.msRequestFullscreen) { /* IE/Edge */
- elem.msRequestFullscreen();
- }
- } else {
- if (document.exitFullscreen) {
- document.exitFullscreen();
- } else if (document.webkitExitFullscreen) {
- document.webkitExitFullscreen();
- } else if (document.mozCancelFullScreen) {
- document.mozCancelFullScreen();
- } else if (document.msExitFullscreen) {
- document.msExitFullscreen();
- }
- }
- hideAllContextMenus();
- }
- /*
- Background services for keeping desktop files updated
- Same mechanism is used as file explorer
- */
- let desktopFileHash = "";
- setInterval(function(){
- getDesktopHash(function(hash){
- if (desktopFileHash == ""){
- //Initialization
- desktopFileHash = hash;
- }else if (desktopFileHash != hash){
- //Changed on desktop files. Refresh
- refresh(undefined, true);
- desktopFileHash = hash;
- }
- //Else, no file change on desktop
- });
- }, 15000);
- function generateCSRFToken(callback){
- $.ajax({
- url: "../../system/csrf/new",
- success: function(token){
- callback(token);
- }
- })
- }
- function getDesktopHash(callback){
- $.ajax({
- url: "system/file_system/listDirHash",
- data: {dir: "user:/Desktop/"},
- success: function(data){
- if (data.error !== undefined){
-
- }
- callback(data);
- }
- })
- }
- function bindObjectToIMEEvents(object){
- object.addEventListener("keydown", function(event){
- if (window.ime && window.ime.handler != null){
- window.ime.handler(event);
- }else{
- //No IME handler. Just continue the input
- }
- });
- object.addEventListener("focus", function(event){
- if (window.ime){
- //IME exists. Set this field to focused field
- window.ime.focus = event.target;
- }
- });
- }
- </script>
- </body>
- </html>
|