1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839 |
- ///<jscompress sourcefile="Onload.js" />
- //------------------------------------------------------------------------------------用户桌面和程序数据初始化区域----------------------------------------------------------------------------------------------------------------
- Namespace.register("U.MD.D"); //桌面onload和桌面总控的命名空间
- /*
- window.onload的流程:
- 1、自由属性的设置,例如:页面识别id。允许浏览器多页面浏览www.1473.cn
- 2、加载各种事件绑定,如:页面大小监视,不允许选择桌面文字,ie7以下浏览器页面提示
- 3、加载桌面图标。
- 4、加载跨域设置,如果没有跨域,首页数据无法获取
- 4、加载首页
- 5、加载广告,QQ登录等外链。
- UD和UC区别 uc是框架函数 ud为操作系统原壳 这里的简化的目标很简单 只要有人应用ud 就会引用一个web操作系统 提供操作系统的功能应用
- 难题 :
- 1、命名和用户冲突 会导致原web系统不可使用
- 2、函数冲突 如 用户自带window.resize这样的函数 我们提供了接口 但是这个接口的的暴露性可见性体现出文档的重要 宣传文档也就是文宣的重要性高了
- 3、有参数注释的都为暴露接口类型 其他都为内部使用 更好的体现方式
- */
- //#region 配置区域,相当于全局变量定义
- U.MD.D.IsUseStudio = (window.location.host.indexOf("www.1473.cn") > -1 ||
- window.location.host.indexOf("m.1473.cn") > -1 ||
- window.location.host == "1473.cn" ||
- window.location.host.indexOf("www.boomyun.com") > -1 ||
- window.location.host == "boomyun.com"); //此处为判断是否是我们主域名 我们分为两个域名 一个为www.1473.cn 一个为www.bomyun.com
- //本地存储类
- U.MD.D.LocalStorage = null;
- //#endregion
- //#region onload处理
- /**
- * 系统初始化处理
- *
- * @param {function} 在外部项目应用该项目的时候 可以传入cb这个参数,如果传入了这个参数在回调跨域main.1473.cn加载成功会就会直接回调
- */
- window.onload = function () {
- U.MD.D.Load();
- }
- /**
- * 供外部调用的window.onload函数云端系统启动项
- *
- * @param {function} 在外部项目应用该项目的时候 可以传入cb这个参数,如果传入了这个参数在回调跨域main.1473.cn加载成功会就会直接回调
- */
- U.MD.D.Load = U.MD.D.FLoad = function (cb) {
- //这里判断是如果是www.1473.cn 或者 www.boomyun.com项目的时候 或者是 通过ufrom的跨域函数加载成功页面时候可以执行window.onload, 添加判断的目的主要是反正 其他项目引用uformd的时候自动执行window.onload报错。
- //当引用云端硬盘,好友模块时需要在自己的js文件中添加window.onload入口函数,否则会触发云端的window.onload,导致系统报错,
- //初始化桌面,如果是1473主站点那么初始化桌面系统,否则外部引入1473不加载桌面
- //系统初始化、第一个就是加载桌面,然后初始化全局变量、绑定事件、最后加载数据(加载数据需要跨域加载,因为项目分离的原因,我们有disk.1473.cn、user.1473.cn、firend.1473.cn里面有静态数据,还有动态的后台)
- if (U.MD.D.IsUseStudio) {
- //桌面初始化弹出
- U.selectEl("#UD_Dtop")[0].style.display = "block";
- //桌面做为一个置底的窗体
- new U.UF.UI.form(false, U.selectEl("#UD_Dtop")[0], { onresize: false, style: { "cssText": "width:100%;height:100%;padding:0;border:0;border-radius:0;box-shadow:0;position:static;" }, "className": "" },
- { istop: false, isdrag: false, isdrag: false, isstretching: false, isenlarge: false, isnarrow: false, isclose: false }, null, { style: { "padding": "0" } });
- }
- //这里加判断的原因是怕有开发者开发的过程中直接调用uformd.js没有写跨域加载,没有写window.onload导致再运行的过程中找不到元素报错
- if ($("#U_MD_Home")[0]) {
- //设置页面大小等的全局变量
- U.MD.D.settingGlobalVariables();
- //浏览器事件监视及处理
- U.MD.D.addEvents();
- var _browserinfo = U.UF.CI.getBrowser(); //获取浏览器
- //ie7以下的浏览器弹出不兼容的处理
- if (_browserinfo["browser"] == "msie" && parseInt(_browserinfo["ver"]) < 7) {
- //弹出不兼容的处理
- U.MD.D.A.browserCompatibleForm();
- }
- }
- //跨域加载
- U.MD.D.crossDomain(cb); //跨域初始化,里面包含了用户登录
- }
- /**
- * 设置当前使用页面大小
- */
- U.MD.D.settingGlobalVariables = function () {
- //获取页面的大小
- var _size = U.selectEl("body").getElementInfo();
- US.height = _size["CH"]; //获取高度
- US.width = _size["CW"]; //获取宽度
- //1473的登录识别id
- US.systemId = 1;
- //页面识别id 页面唯一的识别 作为用户访问1473的唯一识别码,在之前用户获取聊天室的信息的唯一识别码
- US.pageId = Guid.newGuid();
- }
- /**
- * 系统监视
- */
- U.MD.D.addEvents = function () {
- //页面活动状态监视,失焦的时候停止五秒刷新,聚焦的时候开始刷新
- U.UF.EV.IsActivity(U.MD.D.focus, U.MD.D.blur);
- //监视页面的点击 使得窗体点击为顶部
- U.UF.F.clickTopWindow();
- //页面大小变化监视
- window.onresize = U.MD.D.reSize;
- //如果是云端1473则屏蔽菜单和错误弹框
- if (U.MD.D.IsUseStudio) {
- if (window.print) { //判断是否有右键菜单
- document.oncontextmenu = U.UF.EV.stopDefault; //阻止桌面右键默认菜单
- }
- document.onselectstart = U.UF.C.shieldedSelect; //禁止文本选择处理
- U.UF.EV.addElementEvent("keydown", document, U.UF.C.shieldedBackspace); //禁止浏览器回退
- window.onerror = U.MD.D.error; //错误提示屏蔽
- }
- //允许错误提示和右键菜单
- else {
- window.onerror = null;
- }
- //页面路由事件处理
- U.UF.N.route(U.MD.N.urlGuide);
- }
- /**
- * 页面大小变化时,需要重新排列图标及任务栏大小的变化.
- */
- U.MD.D.reSize = function () {
- //处理窗体区域 随着页面大小变化而变化
- U.UF.UI.form.windowResize();
- //页面变化处理
- //获取页面的大小
- var _size = U.selectEl("body").getElementInfo();
- US.height = _size["CH"]; //获取高度
- US.width = _size["CW"]; //获取宽度;
- //任务栏处理
- if ($("#U_MD_D_RW")) {
- U.selectEl("#U_MD_D_RW").css("width", US.width - 165 + "px");
- U.MD.D.T.taskbar.multitask($("#U_MD_D_RW")[0]);
- //桌面图标处理
- U.MD.D.iconPostion($("#U_MD_D_K").Child());
- }
- }
- /**
- * 跨域引入1473
- * @param {function} 跨域加载成功后的回调函数
- */
- U.MD.D.crossDomain = function (cb) {
- //跨域加载,如果是1473的跨域,那么则添加跨域的iframe处理
- if (document.domain == "1473.cn") {
- U.UF.CD.loadAjaxCrossDomain(function () {
- U.MD.D.loadApplication(cb);
- });
- }
- //如果是非1473的跨域,添加跨域的iframe
- else {
- U.UF.CD.thirdPartyLoadAjaxCrossDomain(function () {
- U.MD.D.loadApplication(cb);
- });
- }
- }
- /**
- * 加载user 、 friend 、disk的js
- */
- U.MD.D.loadApplication = function (cb) {
- U.UF.CD.loadApplication(function () {
- U.MD.D.asynCrossDomain(cb);
- });
- }
- /**
- * 域名加载成功后异步 此处可正式获取数据
- * @param {function} 跨域加载成功后的回调函数
- */
- U.MD.D.asynCrossDomain = function (cb) {
- //初始化url的处理
- U.MD.N.urlGuide();
- //通过cookie登录
- U.MD.U.L.cookieLogin();
- //如果是1473则弹出1473的首页
- if (U.MD.D.IsUseStudio) {
- U.MD.D.I.openApplication("boomYun");
- }
- //其它模块加载处理
- U.MD.D.otherModularLoad();
- //添加用户访问记录
- U.UF.CI.getUserLocation(U.MD.D.visitLog);
- //桌面开始点,起始函数
- if ($("#UD_Dtop")[0]) {
- U.MD.D.I.init();
- }
- //如果其他站点进入1473,这里是引入成功的回调处理
- if (U.UF.C.isFunction(cb)) {
- cb(); //回调处理
- }
- }
- /**
- * 其它模块的加载
- */
- U.MD.D.otherModularLoad = function () {
- //计时器消息初始化 每个3秒刷一次消息
- U.MD.C.T.onesetInterval();
- //加载如广告 各模块加载
- U.MD.D.thirdPartyLoad(); //页面插件加载
- //html5本地存储,暂时用来完成本地页面交互消息 作用共享页面信息,还未完善。
- //U.MD.D.record();
- }
- /**
- * 第三方广告和登录加载处理
- */
- U.MD.D.thirdPartyLoad = function () {
- //阿里巴巴广告加载
- // U.UF.DL.C.AD.alimama([
- // { pid: "mm_32325420_3265865_24254681", appkey: "", unid: "" },
- // { pid: "mm_32325420_3265865_14752067", appkey: "", unid: "" },
- // { pid: "mm_32325420_3265865_24246760", appkey: "", unid: "" },
- // { pid: "mm_32325420_3265865_24254681", appkey: "", unid: ""}]);
- //qq登录加载按钮
- // U.MD.U.OT.qqLoadJs({ btnId: "U_MD_U_L_login_O_T_app_QQ", size: "C_S" });
- //微博登录加载按钮
- // U.MD.U.OT.weiboLoadJs({ id: "U_MD_U_L_login_O_T_app_I", type: "3,2", show_head: false, show_name: false, show_cancel: false,
- // callback: { login: U.MD.U.OT.weiboLoginCallBack }
- // });
- //百度统计加载
- // U.UF.DL.C.AD.onloadBaiduJs("1fce47ee7e8655ddd108fca7116f0752");
- // U.UF.DL.C.AD.onloadBaiduJs("f0ececeb4f687bc4d4ffb7719f4cf6a7");
- }
- /**
- * 写入访问用户信息
- */
- U.MD.D.visitLog = function () {
- U.A.Request(US.USER, ["AddToLoginLog", US.userInfo.UserId || US.EMPTYGUID, US.city.userAllLocation || ""], function () { }); //访问日志添加消息
- }
- //#endregion
- //#region 页面事件处理
- //关闭页面处理 把页面的活动数-1
- window.onunload = function () {
- try {
- var _userinfo = US.userInfo;
- if (U.MD.D.LocalStorage) {
- var _count = U.MD.D.LocalStorage.get("ati") || 0;
- if (_count > 0) { _count-- };
- U.MD.D.LocalStorage.set("ati", _count); //这是活动用户-1
- }
- if (_userinfo.UserId && U.A) { //在状态中让这个活动用户下线
- U.A.Request(US.USER, ["UserOffline", _userinfo.UserId], function () { }, []);
- }
- }
- catch (e) { }
- }
- //错误处理,前端错误需要在控制台输出,同时提交到错误数据库
- //window.onerror = function(sMessage,sUrl,sLine,columnNumber,errorObj){};
- //onerror函数的五个参数用于确定错误确切的信息,代表的意思依次为:
- //* @param {String} errorMessage errorMessage 错误信息
- //* @param {String} scriptURI 出错的文件
- //* @param {Long} lineNumber 出错代码的行号
- //* @param {Long} columnNumber 出错代码的列号
- //* @param {Object} errorObj 错误的详细信息,Anything
- U.MD.D.error = function (errorMessage, scripturi, linenumber, columnnumber, errorobj) {
- errorobj = errorobj || {}; //屏蔽js错误
- U.A.Request(US.USER, ["SetError", 0, (event.errorMessage || event || errorMessage), (scripturi || event.filename || event.errorUr) + "。行号:" + (linenumber || event.lineno || event.errorLine)], function () { }, []); //错误消息发送到数据库
- U.UF.C.console(event.errorMessage || event || errorobj); //console 输出错误信息
- return true; //不让浏览器弹出错误报告,浏览器会弹出一个comfirm的错误。
- }
- //#endregion
- //#region 获取ifram下的html
- U.MD.D.getIfraemHtml = function (src) {
- var _iframe = $$("iframe", { src: src, style: { display: "none" } });
- //跨域回调设置
- U.UF.DL.iframeLoad(_iframe, function () {
- var _html = _iframe.contentWindow.document.body.innerHTML;
- console.log(_html);
- U.selectEl(_iframe).remove();
- });
- U.selectEl(_iframe).appendTo($('body')[0]);
- };
- //#endregion
- ;
- ///<jscompress sourcefile="Desktop.js" />
- /*
- 此处为桌面系统启动应用区域
- */
- Namespace.register("U.MD.D.I"); //桌面应用处理
- //判断图片是否在拖拽,如果是拖拽图标的过程是不会打开图片的
- U.MD.D.I.IsDrag;
- //桌面图标的全局变量
- U.MD.D.I.DeskIcon = [
- // { "Name": "我的云盘", "Url": "disk", "Img": { "x": "-15", "y": "-296"} },
- // { "Name": "互联办公", "Url": "boomYun", "Img": { "x": "-844", "y": "-419"} },
- // { "Name": "Word", "Url": "word", "Img": { "x": "-462", "y": "-296"} },
- // { "Name": "Execl", "Url": "excel", "Img": { "x": "-523", "y": "-296"} },
- // { "Name": "文本文件", "Url": "txt", "Img": { "x": "-267", "y": "-413"} },
- // { "Name": "我的好友", "Url": "friend", "Img": { "x": "-648", "y": "-297"} },
- // { "Name": "查找好友", "Url": "lookupFriend", "Img": { "x": "-85", "y": "-413"} },
- // { "Name": "我的设置", "Url": "set", "Img": { "x": "-400", "y": "-296"} },
- // { "Name": "系统设置", "Url": "systemSet", "Img": { "x": "-144", "y": "-413"} },
- // { "Name": "云端下载", "Url": "client", "Img": { "x": "-648", "y": "-357"} },
- // { "Name": "云端产品", "Url": "xz", "Img": { "x": "-24", "y": "-413"} }
- // { "Name": "FTP", "Url": "ftp", "Img": { "x": "-24", "y": "-413"} },
- // { "Name": "群文档", "Url": "group", "Img": { "x": "-85", "y": "-413"} },
- // { "Name": "web编程", "Url": "frontEndProgramming", "Img": { "x": "-275", "y": "-297"} },
- // { "Name": "后端编程", "Url": "backEndProgramming", "Img": { "x": "-275", "y": "-297"} },
- { "Name": "项目管理", "Url": "projectList", "style": { "backgroud": "url(../img/icon/project.png)" } },
- { "Name": "学生列表", "Url": "studentList", "style": { "backgroud": "url(../img/icon/student.png)" } },
- ];
- //#region 桌面初始化
- /**
- * 初始化桌面的起始函数
- *
- */
- U.MD.D.I.init = function () {
- if ($("#U_MD_D_K")[0]) {
- //初始化桌面图标
- U.MD.D.I.initDesktopIcons($("#U_MD_D_K")[0]);
- //初始化任务栏,因为是静态的,所以直接改变样式即可.
- U.selectEl("#U_MD_D_RW").css("width", US.width - 165 + "px");
- }
- }
- /**
- * 隐藏任务栏
- *
- * @param {element} 桌面元素
- */
- U.MD.D.I.hiddenTaskbar = function (el) {
- //任务栏位置变小
- U.selectEl(el).parentElement(3).css({ "bottom": "-63px" });
- //桌面的位置变大
- // U.selectEl("#U_MD_D_K").css({ "left": "5px" });
- }
- /**
- * 初始化打印桌面图标
- *
- * @param {element} 桌面元素
- */
- U.MD.D.I.initDesktopIcons = function (el) {
- var i, //用于循环
- _content, //桌面图标元素
- _iconcontent, //桌面图标元素
- _frag = $$("frag"), //定义一个碎片元素
- _DesktopIconInfo = U.MD.D.I.DeskIcon; //获取桌面图标
- //清楚桌面图标
- el.innerHTML = "";
- //循环创建桌面图标
- for (i = 0; i < _DesktopIconInfo.length; i++) {
- _content = $$("div", {
- className: "U_MD_D_KO",
- "onmousedown": U.UF.C.closure(function (obj) {
- //防止拖动图标即打开了桌面应用
- U.MD.D.click(this, obj);
- }, [_DesktopIconInfo[i]]),
- "onclick": U.UF.C.closure(function (obj) {
- //防止拖动图标即打开了桌面应用
- U.MD.D.click(this, obj);
- }, [_DesktopIconInfo[i]])
- }, _frag); //
- _iconcontent = $$("div", { className: "U_MD_D_KOA" }, _content);
- $$("div", { className: "U_MD_D_KOS U_Img", "style": { "backgroundPosition": _DesktopIconInfo[i].Img.x + "px " + _DesktopIconInfo[i].Img.y + "px" } }, _iconcontent);
- $$("div", { className: "U_MD_D_KOX", "style": { "cssText": "text-shadow: #000 2px 1px 3px,#666 0 1px 0,#555 -1px 0 0,#999 0 -1px 0; -webkit-text-shadow: #333 1px 0 0,#666 0 1px 0,#555 -1px 0 0,#999 0 -1px 0; -moz-text-shadow: #333 1px 0 0,#666 0 1px 0,#555 -1px 0 0,#999 0 -1px 0; filter: Glow(color=#777777, strength=1)\9;" }, "innerHTML": _DesktopIconInfo[i].Name }, _iconcontent);
- }
- //加载好后给图标定位
- U.MD.D.iconPostion($(_frag).Child());
- //把图标加载到页面
- el.appendChild(_frag);
- }
- /**
- * 显示任务栏
- *
- * @param {element} 桌面元素
- */
- U.MD.D.I.displayTaskbar = function (el) {
- //判断是否需要形式任务栏,由于用了mouseover事件会冒泡响应多次,这里做了过滤
- if (!U.UF.EV.stopBubbleMouseOutOrOver(el) && U.selectEl(el).css("bottom") != "0px") {
- //任务栏位置变化
- U.selectEl(el).css({ "bottom": "0px" });
- //桌面位置变话
- // U.selectEl("#U_MD_D_K").css({ "left": "70px" });
- }
- }
- //#region 桌面图标拖动逻辑
- /**
- * 桌面排列图标
- *
- * @param {element} 桌面元素
- * @param {object} 上下相距的距离
- * @param {object} 左右相距的距离
- * @return {object} 命名空间
- */
- U.MD.D.iconPostion = function (childs, top, left) {
- var i; //用于循环处理
- top = top || 15; //如果没有设置元素的间距处理默认上间距为15
- left = left || 20; //如果没有设置元素的间距处理默认左间距为15
- //循环所有的图标,设置每个图标的间距,打印顺序是竖排打印的方式
- for (i = 0; i < childs.length; i++) {
- //如果竖排top超过了范围处理
- if (top + 95 > US.height - 85) {
- //left超过了页面范围处理,则向上重叠打印处理
- if ((left + 180) > US.width) {
- top -= 115;
- left -= 90;
- }
- //没有超过范围,那么left+90添加到下一个竖排打印
- else {
- left += 90;
- top = 15;
- };
- }
- //给图标的位置赋值
- U.selectEl(childs[i]).css({ top: top + "px", left: left + "px" });
- if (i < childs.length - 1) {
- //页面图标每次向下加115
- top += 115;
- }
- }
- //返回最后调用的图标的位置
- return [top, left];
- }
- /**
- * 桌面点击事件逻辑
- *
- * @param {element} 桌面元素
- * @param {object} 上下相距的距离
- * @param {object} 左右相距的距离
- * @return {object} 命名空间
- */
- U.MD.D.click = function (el, obj) {
- var _buttonnumber = event.button; //点击的按钮的事件值
- U.UF.EV.stopBubble(); //阻止向上冒泡
- //onmousedown 包含了左键和右键 这里大于2是为了兼容 所有浏览器的右键处理
- if (_buttonnumber < 2) {
- //如果是click事件的处理
- if (event.type == "click") {
- //如果元素在mousemove事件中没有移动则出发click事件
- if (!U.MD.D.I.IsDrag) {
- //打开应用处理
- U.MD.D.I.openApplication(obj.Url, { "userid": US.userInfo.UserId, "directoryid": US.FTPFOLDERID });
- }
- }
- //如果是mouse事件的处理
- else {
- //拖动处理,添加拖动和拖动结束事件
- U.UF.F.drag(el, U.MD.D.iconMove, U.MD.D.iconUp);
- }
- U.MD.D.I.IsDrag = false;
- }
- }
- /**
- * 拖动的处理
- *
- */
- U.MD.D.iconMove = function () {
- //如果当前位置点击初始化的位置出现了变化,则设置是否拖动的属性 U.MD.D.I.IsDrag为true
- U.MD.D.I.IsDrag = true;
- }
- /**
- * 拖动结束后,这里是定位处理,以网状的形式定位
- *
- * @param {element} 拖动的元素
- * @return {object} 命名空间
- */
- U.MD.D.iconUp = function (el) {
- var _top = 15,
- _left = 20,
- _margin,
- _childs = U.selectEl("#U_MD_D_K").Child(), //桌面所有的图标
- _positioninfo = U.UF.EL.getElementInfo(el); //获取拖动结束的元素的位置
- if (_positioninfo["OT"] > 15) {
- //网状的形式定位,如果差超过了55,那么向下定位,否则向上定位
- _margin = ((_positioninfo["OT"] - 15) % 115 > 55 && _positioninfo["OT"] + 115 < US.height) ? 1 : 0;
- _top = (Math.floor((_positioninfo["OT"] - 15) / 115) + _margin) * 115 + 15;
- }
- if (_positioninfo["OL"] > 20) {
- //网状的形式定位,如果差超过了90,那么向右定位,否则向左定位
- _margin = ((_positioninfo["OL"] - 20) % 90 > 45 && _positioninfo["OL"] + 90 < US.width) ? 1 : 0;
- _left = (Math.floor((_positioninfo["OL"] - 20) / 90) + _margin) * 90 + 20
- }
- //while循环判断么一个重叠的元素
- do {
- _positioninfo = U.MD.D.iconPostion([el], _top, _left); //给重叠的元素向下定位
- _top = _positioninfo[0] + 115; //得到定位后的top
- _left = _positioninfo[1]; //得到定位后的left
- } while (el = U.MD.D.isOverlap(el, _childs, _positioninfo))
- }
- /**
- * 判断拖动后图标是否重叠
- *
- * @param {element} 拖动的元素
- * @param {element} 桌面所有的元素
- * @param {array} 拖动元素的位置
- ----------[0] 上 top
- ----------[1] 左 left
- * @return {object} 命名空间
- */
- U.MD.D.isOverlap = function (el, childs, postionarray) {
- //循环所有的图标
- for (var i = 0; i < childs.length; i++) {
- //判断有没有和该图标诶子重叠的元素
- if (el != childs[i] && (childs[i].offsetTop == postionarray[0] && childs[i].offsetLeft == postionarray[1])) {
- return childs[i]; //如果有返回
- }
- }
- }
- //#endregion
- //#endregion
- //#region 桌面应用
- /**
- * 打开应用
- *
- * @param {string} 类型
- -----------------Disk 网盘系统
- -----------------PDisk 学习系统网盘
- -----------------Poto 图片
- -----------------Video 视频
- -----------------Music 音乐
- -----------------Word word
- -----------------Excel excel
- -----------------Txt 记事本
- -----------------PB 学习系统
- -----------------Blog 朋友圈系统
- -----------------FTP ftp系统
- -----------------Group 好友群
- -----------------SY 首页系统
- -----------------Set 个人设置
- -----------------XSet 系统设置
- -----------------App 我们所有的app
- -----------------BC c.1473.cn 平台
- -----------------CWeb d.1473.cn 变成平台
- -----------------其他的外联系统 我们统一用iframe打开
- * @param {array} 类型
- 如果第一个参数为"disk",则第二个参数为object,里面包含了用户id和目录id{userid:"",directoryid:""}
- 如果第一个参数为"word"或者"excel","txt",则第二个参数为文件信息fileinfo。
- 如果第一个参数为"blog"或者"PDisk"。建议删除。
- 如果第一个参数为其他,则无第二个参数
- * @returns {array}
- */
- U.MD.D.I.openApplication = function (str, obj, info) {
- obj = obj || {};
- var _taskbar, //_taskbar 作为任务栏显示的元素,包含图标和名字
- _formdiv, //创建任务栏时同时弹出的窗体元素。
- _userinfo = US.userInfo, //登录用户信息
- _userid = obj.userid || _userinfo.UserId //登录用户id
- ;
- //选择应用处理
- switch (str) {
- case "friend": //好友打开
- U.MD.D.I.IsDrag = true;
- U.MD.F.W.viewFriend(info); //打开好友
- // U.MD.N.urlWrite("friend/" + obj.directoryid, "好友"); //好友的url重写
- break;
- case "domain":
- var _iframe = $$('iframe', { src: '//domain.1473.cn/DomainSystem.aspx/?fileId=' + info.fileId + '&type=' + info.type + '&mode=' + info.mode, frameborder: "0", style: { cssText: "width:100%;height:100%;border:0px" } });
- _formdiv = new U.UF.UI.form("域名管理", _iframe, { id: "U_MD_DS_DomainShare", style: { "width": "370px", "height": "390px" } }).form;
- if (_formdiv) {
- //生成任务栏的变量
- _taskbar = { "id": str + _formdiv.id, "backgroundPostion": "-15px -296px", "name": "网盘", "forms": _formdiv, "click": function () { U.MD.D.I.openApplication(str, obj, info); } }
- }
- break;
- case "disk": //个人网盘查看
- _formdiv = U.MD.DK.initDisk(_userid, obj.directoryid); //根据网盘数据,并加载网盘,里面包含了url重写
- if (_formdiv) {
- //生成任务栏的变量
- _taskbar = { "id": str + _formdiv.id, "backgroundPostion": "-15px -296px", "name": "网盘", "forms": _formdiv, "click": function () { U.MD.D.I.openApplication(str, obj); } }
- }
- break;
- case "word": //Word打开
- var _wordinfo = U.MD.O.word(_userinfo, obj, arguments[2]); //初始化word的处理
- _formdiv = _wordinfo[0];
- if (_formdiv) {
- //生成任务栏的变量
- _taskbar = { "id": str + _formdiv.id, "backgroundPostion": "-462px -296px", "name": "文档", "forms": _formdiv, "click": function () { U.MD.D.I.openApplication(str, _wordinfo[1]); } }
- }
- if (obj.UrlType != 'join') {
- U.MD.N.urlWrite("word/" + _formdiv.id.substr(-36), "在线文档"); //word的url重写
- }
- break;
- case "excel": //Excel打开
- _formdiv = U.MD.O.excel(_userinfo, obj);
- if (_formdiv) {
- //生成任务栏的变量
- _taskbar = { "id": str + _formdiv.id, "backgroundPostion": "-523px -296px", "name": "在线表格", "forms": _formdiv, "click": function () { U.MD.D.I.openApplication(str, obj); } }
- }
- U.MD.N.urlWrite("excel/" + _formdiv.id.substr(-36), "在线表格");
- break;
- case "txt": //Txt打开
- _formdiv = U.MD.D.Txt.textCreate();
- if (_formdiv) {
- //生成任务栏的变量
- _taskbar = { "id": str + obj.directoryid, "backgroundPostion": "-267px -413px", "name": "在线文本", "forms": _formdiv, "click": function () { U.MD.D.I.openApplication(str, obj); } }
- }
- U.MD.N.urlWrite("txt/" + _formdiv.id.substr(-36), "在线文本");
- break;
- case "lookupFriend":
- _formdiv = U.MD.F.S.popSearchFriendsOrGroupForm(0);
- //生成任务栏的变量
- _taskbar = { "id": str + _formdiv.id, "backgroundPostion": "-85px -413px", "name": "查找好友", "forms": _formdiv, "click": function () { U.MD.D.I.openApplication(str, obj); } }
- U.MD.N.urlWrite("lookupfriend/" + obj.directoryid.substr(-36), "查找好友"); //查找好友的url重写
- break;
- case "ftp": //Ftp
- _formdiv = U.MD.F.S.popupsSearchFtp();
- //生成任务栏的变量
- _taskbar = { "id": str + _formdiv.id, "backgroundPostion": "-144px -413px", "name": "FTP", "forms": _formdiv, "click": function () { U.MD.D.I.openApplication(str, obj); } }
- break;
- case "group": //群组
- _formdiv = U.MD.F.S.popupsSearchGroups(0);
- //生成任务栏的变量
- _taskbar = { "id": str + _formdiv.id, "backgroundPostion": "-85px -413px", "name": "群组", "forms": _formdiv, "click": function () { U.MD.D.I.openApplication(str, obj); } }
- break;
- case "set": //个人设置
- _formdiv = U.MD.U.P.userDataSet();
- if (_formdiv) {
- //生成任务栏的变量
- _taskbar = { "id": str + _formdiv.id, "backgroundPostion": "-400px -296px", "name": "个人设置", "forms": _formdiv, "click": function () { U.MD.D.I.openApplication(str, obj); } }
- }
- break;
- case "systemSet": //系统设置
- _formdiv = U.MD.D.B.init();
- //生成任务栏的变量
- _taskbar = { "id": str + _formdiv.id, "backgroundPostion": "-400px -296px", "name": "系统设置", "forms": _formdiv, "click": function () { U.MD.D.I.openApplication(str, obj); } }
- break;
- case "boomYun": //BoomYun
- _formdiv = U.Boom.I.onload();
- //生成任务栏的变量
- _taskbar = { "id": str + _formdiv.id, "backgroundPostion": "-844px -419px", "name": "互联办公", "forms": _formdiv, "click": function () { U.MD.D.I.openApplication(str, obj); } }
- U.MD.N.urlWrite("boomyun", "互联办公"); //boomyun的url重写
- break;
- case "xz": //App下载
- window.open("http://xz.1473.cn");
- break;
- case "client": //App下载
- window.open("http://client.1473.cn");
- break;
- case "backEndProgramming": //在线编程平台打开
- window.open("http://c.1473.cn");
- break;
- case "frontEndProgramming": //在线web编程
- window.open("http://d.1473.cn");
- break;
- default: break;
- }
- //如果有任务栏信息
- if (_taskbar) {
- U.MD.D.T.taskbar(_taskbar); //创建任务处理
- }
- }
- //#endregion
- ;
- ///<jscompress sourcefile="taskbar.js" />
- /**
- * 任务栏管理系统
- */
- Namespace.register("U.MD.D.T.taskbar"); //任务栏 命名空间
- /**
- * 任务管理函数
- * @param applyinfo {object} 任务信息
- * 形如:{
- * id: _taskId, //任务识别id
- * backgroundPostion: _taskbar[0], //任务图标定位
- * name: _taskbar[1], //任务名称
- * forms: _taskbar[2], //任务所在的窗体
- * click: function () { U.MD.D.I.openApplication(str, obj); } //任务点击打开的函数
- * }
- * @param taskbarEle 任务管理器所在的元素 默认为$("#U_MD_D_T_taskbar_Bar_Main")[0]元素
- */
- U.MD.D.T.taskbar = function (applyinfo, taskbarEle) {
- taskbarEle = taskbarEle || U.selectEl("#U_MD_D_RW")[0]; //任务管理器所在的元素
- var _tasks = U.selectEl('#U_MD_D_T_taskbar_' + applyinfo.id, taskbarEle)[0]; //查找当前任务是否存在
- //如果不存在则创建任务
- if (!_tasks) {
- //创建任务
- U.MD.D.T.taskbar.create(applyinfo, taskbarEle);
- //检查任务是否过多
- U.MD.D.T.taskbar.multitask(taskbarEle);
- }
- else {
- _tasks.forms = applyinfo.forms;
- }
- }
- //是否触发拖动监听变量
- U.MD.D.T.taskbar.drag = 0;
- /**
- * 任务创建函数
- * @param applyinfo {object} 任务信息 与任务管理函数参数相同
- * @param taskbarEle {element} 任务管理器所在的元素 默认为$("#U_MD_D_T_taskbar_Bar_Main")[0]元素 与任务管理函数参数相同
- */
- U.MD.D.T.taskbar.create = function (applyinfo, taskbarEle) {
- //动态创建任务
- var _task = $$("div", { id: "U_MD_D_T_taskbar_" + applyinfo.id, className: "U_MD_D_BZMO", title: applyinfo.name, "forms": applyinfo.forms });
- var _taskMain = $$("div", {
- className: "U_MD_D_BZMOA",
- //绑定点下事件 勇于拖动监听
- onmousedown: U.UF.C.apply(null, function () { U.MD.D.T.taskbar.dragClose(_taskMain); }),
- //绑定点击事件 需判断是否在拖动状态
- onclick: function () {
- if (!(U.MD.D.T.taskbar.drag > 1)) {
- applyinfo.click();
- }
- U.MD.D.T.taskbar.drag = 0;
- }
- }, _task);
- //动态创建任务图标
- $$("div", { className: "U_MD_D_BZMOI U_Img", style: { backgroundPosition: applyinfo.backgroundPostion } }, _taskMain);
- //动态创建任务名称
- // $$("div", { className: "U_MD_D_BZMON U_MD_D_Text_Abbreviation", innerHTML: applyinfo.name }, _taskMain);
- var _taskName = $$("div", {
- className: "U_MD_D_T_taskbar_Name",
- style: { "position": "absolute", "left": "-26px", "bottom": "83px" }/*,
- innerHTML: applyinfo.name*/
- }, _task);
- $$("div", {
- className: "U_MD_D_BZMON U_MD_D_Text_Abbreviation",
- style: { "float": "left", "width": "100px", "margin-top": "7%", "color": "#FFFFFF", "font-family": "MicrosoftYaHei" },
- innerHTML: applyinfo.name
- }, _taskName);
- $$("div", { className: "U_MD_D_T_taskbar_Close", style: { "display": "none" }, innerHTML: "x", onclick: function () { U.UF.EV.stopBubble(); U.MD.D.T.taskbar.close(applyinfo) } }, _taskMain);
- $$("div", { className: "U_MD_D_T_taskbar_Close", innerHTML: "x", onclick: function () { U.UF.EV.stopBubble(); U.MD.D.T.taskbar.close(applyinfo) } }, _taskName);
- //添加到任务栏的最前面
- if (taskbarEle) {
- U.selectEl(taskbarEle).append(_task, 0, taskbarEle.firstChild);
- }
- //任务栏中大于或等于28个时,才出现上下分页按钮;
- if ($(".U_MD_D_BZMOA").length >= 28) {
- U.selectEl(".U_MD_D_RW_R")[0].style.display = "block";
- } else {
- U.selectEl(".U_MD_D_RW_R")[0].style.display = "none";
- }
- }
- //当前页监听
- U.MD.D.T.taskbar.page = 1;
- //最大页码
- U.MD.D.T.taskbar.maxPage = 1;
- //每页最多放置任务数
- U.MD.D.T.taskbar.pageNum = 1;
- /**
- * 检查任务过多情况
- * @param taskbarEle {element} 任务管理器所在的元素 默认为$("#U_MD_D_T_taskbar_Bar_Main")[0]元素 与任务管理函数参数相同
- */
- U.MD.D.T.taskbar.multitask = function (taskbarEle) {
- //每页最多放置任务数
- U.MD.D.T.taskbar.pageNum = Math.floor($(taskbarEle).width() / 65);
- //获取所有任务
- var _tasks = U.selectEl(taskbarEle).Child();
- //获取任务总数
- var _tasksTotal = _tasks.length;
- //判断是否为多页情况
- if (_tasksTotal > U.MD.D.T.taskbar.pageNum) {
- //计算最大总共有多少页
- U.MD.D.T.taskbar.maxPage = Math.ceil(_tasksTotal / U.MD.D.T.taskbar.pageNum);
- }
- U.MD.D.T.taskbar.page = 1;
- U.MD.D.T.taskbar.switchPage(0);
- }
- /**
- * 多任务切换页面
- * @param mark {number} 页码标记 在前台页上加或者减多少页
- * @param taskbarEle {element} 任务管理器所在的元素 默认为$("#U_MD_D_T_taskbar_Bar_Main")[0]元素 与任务管理函数参数相同
- */
- U.MD.D.T.taskbar.switchPage = function (mark, taskbarEle) {
- //任务管理器位置
- taskbarEle = taskbarEle || U.selectEl("#U_MD_D_RW")[0];
- //页面切换设置
- U.MD.D.T.taskbar.page += mark;
- //页面最小值限制
- if (U.MD.D.T.taskbar.page < 1) { U.MD.D.T.taskbar.page = 1; }
- //页面最大值限制
- if (U.MD.D.T.taskbar.page > U.MD.D.T.taskbar.maxPage) { U.MD.D.T.taskbar.page = U.MD.D.T.taskbar.maxPage; }
- //获取所有任务
- var _tasks = U.selectEl(taskbarEle).Child();
- //计算当前页面从第几个任务开始显示
- var _startLength = (U.MD.D.T.taskbar.page - 1) * U.MD.D.T.taskbar.pageNum;
- //计算当前页面从第几个任务结束显示
- var _endLength = Math.min(U.MD.D.T.taskbar.page * U.MD.D.T.taskbar.pageNum, _tasks.length);
- //影藏所有任务
- U.selectEl($(taskbarEle).Child()).css('display', 'none');
- //循环显示当前页面的任务
- var i;
- for (_startLength; _startLength < _endLength; _startLength++) {
- U.selectEl(_tasks[_startLength]).css('display', 'block');
- }
- }
- /**
- * 任务关闭函数
- * @param applyinfo {object} 任务信息
- */
- U.MD.D.T.taskbar.close = function (applyinfo) {
- var i,
- _child = U.selectEl("#U_MD_D_RW").Child(),
- _form = U.UF.C.isElement(applyinfo.forms) ? applyinfo.forms : applyinfo.forms.form;
- //执行窗体关闭函数
- if (applyinfo.forms) {
- U.UF.F.closeWindow(_form, "remove");
- }
- //通过applyinfo删除的模式
- if (applyinfo.id) {
- //删除任务
- U.selectEl('#U_MD_D_T_taskbar_' + applyinfo.id).remove();
- }
- else {
- //循环找出需要移除的form窗体
- for (i = 0; i < _child.length; i++) {
- if (_child[i].forms == _form) {
- U.selectEl(_child[i]).remove();
- }
- }
- }
- }
- /**
- * 清空任务管理器
- * @param taskEle {Element} 任务管理器位置
- */
- U.MD.D.T.taskbar.clear = function (taskEle) {
- //任务管理器位置
- taskEle = taskEle || U.selectEl("#U_MD_D_RW")[0];
- //循环执行所有任务的关闭点击事件
- var _i, _tasksClose = U.selectEl('.U_MD_D_T_taskbar_Close', taskEle);
- for (_i = 0; _i < _tasksClose.length; _i++) {
- _tasksClose[_i].onclick();
- }
- }
- /**
- * 任务拖拽关闭函数
- * @param taskEle {Element} 被操作任务的元素
- */
- U.MD.D.T.taskbar.dragClose = function (taskEle) {
- U.MD.D.T.taskbar.drag = 0;
- //获取鼠标位置 定义该位置为起始位置
- //U.MD.D.T.taskbar.stratX = U.UF.EL.getMousePosition().x;
- U.MD.D.T.taskbar.stratY = U.UF.EL.getMousePosition().y;
- //记录当前样式
- U.MD.D.T.taskbar.preStyle = U.selectEl(taskEle).css('cssText');
- //设置元素绝对定位
- var _taskEleCssPostion = U.selectEl(taskEle).css("postion");
- if (_taskEleCssPostion == "static" || !_taskEleCssPostion) { U.selectEl(taskEle).css("position", "absolute") };//改G
- //设置置顶
- U.selectEl(taskEle).css("z-index", 9999);
- //绑定事件
- U.MD.D.T.taskbar.bindDragEvent(taskEle);
- }
- /**
- * 拖拽事件绑定
- */
- U.MD.D.T.taskbar.bindDragEvent = function (taskEle) {
- var _event = {
- "mousemove": function () {
- //执行拖拽事件
- U.MD.D.T.taskbar.dragMove(taskEle);
- //绑定鼠标离开元素事件,防止失焦后元素不受控制
- U.selectEl(taskEle).mouseleave(function () {
- U.MD.D.T.taskbar.dragEnd(taskEle);
- });
- //设置拖拽开始
- U.MD.D.T.taskbar.drag++;
- },
- "mouseup": function () {
- //执行拖拽结束函数
- U.MD.D.T.taskbar.dragEnd(taskEle);
- //解绑当前绑定的函数
- U.selectEl(taskEle).unbind(_event);
- //清楚
- U.selectEl(taskEle).mouseleave(null);
- }
- };
- //绑定事件
- U.selectEl(taskEle).bind(_event);
- }
- /**
- * 拖拽函数
- */
- U.MD.D.T.taskbar.dragMove = function (taskEle) {
- //计算拖动距离
- //U.MD.D.T.taskbar.dragX = U.UF.EL.getMousePosition().x - U.MD.D.T.taskbar.stratX;
- U.MD.D.T.taskbar.dragY = U.MD.D.T.taskbar.stratY - U.UF.EL.getMousePosition().y;
- //根据拖动距离计算透明度 最大拖动距离为100
- //var _opacity = 100 - U.MD.D.T.taskbar.dragX;
- var _opacity = 100 - U.MD.D.T.taskbar.dragY;
- //限制透明度值最小为1
- if (_opacity < 1) { _opacity = 1 };
- //设置CSS透明度属性
- U.selectEl(taskEle).css({
- //left: U.MD.D.T.taskbar.dragX + "px",
- bottom: U.MD.D.T.taskbar.dragY + "px",
- filter: "alpha(opacity=" + _opacity + ")",
- "-ms-filter": "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + _opacity + ")", //ie兼容设置
- "-moz-opacity": _opacity / 100,
- "-khtml-opacity": _opacity / 100, //其他浏览器兼容 firefox safari、chrome
- "opacity": _opacity / 100
- });
- }
- /**
- * 拖拽结束函数
- */
- U.MD.D.T.taskbar.dragEnd = function (taskEle) {
- if (U.MD.D.T.taskbar.dragY > 50) {
- //若拖动距离大于40则执行关闭任务函数
- U.selectEl('.U_MD_D_T_taskbar_Close', taskEle)[0].onclick();
- }
- else {
- //否则执行打开函数,并设置回元素的样式
- U.selectEl(taskEle).css("cssText", U.MD.D.T.taskbar.preStyle);
- //taskEle.click();
- }
- }
- $(window).bind('onsize', U.MD.D.T.taskbar.multitask);;
- ///<jscompress sourcefile="Background.js" />
- Namespace.register("U.MD.D.B"); //背景设置
- U.MD.D.B.url = "/img/background/ZMYT.jpg"; //默认背景设计图
- U.MD.D.B.backUrl = ""; //存放默认壁纸的全局变量
- /*
- * 作用: 弹出桌面背景框
- *
- */
- U.MD.D.B.init = function () {
- if ($("#U_MD_D_A_A")[0]) {//判断是否有系统图片
- return U.selectEl("#U_MD_D_A_A").css("display", "block")//显示系统图片
- }
- var _systemimg = U.selectEl("#U_MD_D_Set_BG").css("display", "block")[0]//显示系统图片
- //创建系统设置的弹窗
- var _system = new U.UF.UI.form("<div class='U_MD_F_S_TI'>系统设置</div>",
- _systemimg,
- {
- "id": "U_MD_D_A_A",
- "style": {
- "width": "746px",
- "height": "500px"
- }
- },
- {
- isnarrow: false,
- isenlarge: false
- }).form;
- U.MD.D.B.look(); //添加图片到_el
- return _system; //返回父级元素
- }
- /*
- * 作用: 打印默认可选择的背景图片
- *
- */
- U.MD.D.B.look = function () {
- var i, _img, _imgparent, //i循环所有图片 _img获取显示图片的div _imgparent获取创建包含图片的div层
- _frag = $$("frag"), //创建图片的最高级元素
- _url = "/img/background/", //图片地址
- _pchild = U.selectEl($("#U_MD_D_Set_BG").childs()[0]).Child(), //获取父级元素的第一个子元素,并且获取默认壁纸div
- _imgname = ["3DBox", "cloud", "fruit", "green", "userbackgound", "Dream_train", "ZMYT"], //建立包含图片名称的对象
- _img = U.selectEl(_pchild[0]).Child()[1]; //获取显示图片的div
- _img.innerText = ""; //清空显示图片的div
- if (_imgname.hasOwnProperty) {//忽略从原型链继承的属性
- for (i = 0; i < _imgname.length; i++) {
- _imgparent = $$("div", {
- "className": "U_MD_D_Set_BG_OCO", "title": "设为背景",
- "onclick": U.UF.C.closure(function (i) {//U.UF.C.closure 解决闭包问题
- U.MD.D.B.setBackgroundImage(_url + _imgname[i] + ".jpg"); //给每一个默认壁纸图片添加点击事件
- }, [i])
- }, _frag); //创建包含图片的div
- _imgparent = $$("div", {}, _imgparent); ////创建包含图片的div的下层div_url + _imgname[i][j] + "(1)." + i
- var _addimg = U.UF.IMG.imgReady(_url + _imgname[i] + "(1).jpg", null, function () { /**U.MD.D.H.DYWPTP(_imgparent);*/ }, function () { U.MD.C.imgError(this); }); //获取图片 添加图片
- _imgparent.appendChild(_addimg); //添加图片到父级元素中,并显示出来
- }
- }
- _img.appendChild(_frag); //图片添加到默认图片
- }
- /*
- * 作用: 切割图片的路径包括图片文件夹和图片的名称的字符串数组
- * @param {array} imageurl 图片路径
- * return {array} 返回切割好的数组
- */
- U.MD.D.B.split = function (imageurl) {
- if (imageurl) {//参数有值
- var _i = imageurl.lastIndexOf("/"); //获取/最后出现的位置
- return [imageurl.substr(0, _i), imageurl.substr(_i + 1)]; //图片文件夹 和 图片的名称 的字符串数组
- }
- return ["", ""]; //返回切割好的数组
- }
- /*
- * 作用:同作用于服务器,通过数据库修改,完成壁纸的更改
- * @param {array} url 图片的路径
- * @param {string} str 图片的标识
- */
- U.MD.D.B.asyn = function (url, str) {
- if (!U.MD.U.L.isLogin()) {//判断用户是否登录,如果未登录,则弹出登录窗体
- url = url || U.MD.D.B.backUrl[0]; //获取图片的地址
- str = str || U.MD.D.B.backUrl[1]; //获取图片的标识
- US.userInfo.UserBackGroundImage = url; //讲图片的地址传入服务器中
- U.alert("修改中.."); //弹出提示框
- //插入数据库,并且通过数据返回数据出来。
- U.A.Request(US.CD, [US.DB, "UseStudio_Users", "UpdateUserDesktopInfo", US.userInfo.UserId, url + "/" + str, "", ""],
- function () { U.alert("设置成功"); }); //对调函数,弹出提示框
- // U.A.Request('UseStudioManage.SetUserBackgroudnImage', [US.userInfo.UserId, url, str], function(){U.alert("设置成功");}, []);
- }
- }
- /*
- * 作用:点击网盘上传图片
- * @param {element} el 图片的元素
- * @param {array} url 图片的路径
- * @param {string} str 图片的标识
- */
- U.MD.D.B.disk = function (el, url, str) {
- U.MD.D.B.setBackgroundImage(url, "S"); //调用设置用户点击的背景图片的功能函数
- }
- /*
- * 作用:设置用户点击的背景图片
- * @param {array} imageurl 图片的地址
- * @param {string} typename 图片的标识
- */
- U.MD.D.B.setBackgroundImage = function (imageurl, typename) {
- var _el = U.selectEl("#U_MD_D_BG")[0]; //需要设置背景图片的地方
- typename = typename || "S"; //设置背景时 undefined 所以值是 "S"
- //如果没有传递需要设置的背景图片,那么就设置默认的背景图片
- if (imageurl == null) {//判断图片的路径是否正确
- imageurl = U.MD.D.B.url; //如果图片的路径传值为空的话,则图片路径为默认图片路径
- //判断是否有用户设置的图片路径,如果有,则改变全局变量的图片路径为用户设置的图片路径,如果没有,则用默认图片路径。
- U.MD.D.B.backUrl = US.userInfo.UserBackGroundImage ? U.MD.D.B.split(US.userInfo.UserBackGroundImage) : [U.MD.D.B.url, typename];
- } else {//如果图片的路径不为空
- U.MD.D.B.backUrl = [imageurl, typename]; //则全局变量为图片的路径的传值,以及图片的标识传值
- }
- //各种背景设置
- switch (typename) {
- case "T": //标识为T时
- //重叠出现
- U.selectEl(el).addAttrArray({//改变图片路径
- style: {
- background: "#F0F0F0 url(" + imageurl + ")"
- }
- });
- break; //跳出循环
- case "M": //标识为M时
- //原图大小
- U.selectEl(el).addAttrArray({//改变图片为原图大小
- style: {
- background: "#F0F0F0 url(" + imageurl + ") 0 0 no-repeat"
- }
- });
- break; //跳出循环
- case "S": //标识为S时
- //全屏展示
- if (imageurl) {
- U.selectEl(_el).addAttrArray({
- style: {
- filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + imageurl + ",sizingMethod=scale)",
- background: "#F0F0F0 url(" + imageurl + ") 0 0 no-repeat",
- backgroundSize: "100% 100%",
- MozBackgroundSize: "100% 100%"
- }
- });
- }
- break; //全屏
- default: break;
- }
- }
- /*
- * 作用:上传本地图片的设置
- * @param {element} el 图片元素
- */
- U.MD.D.B.upload = function (el) { //上传图片设置
- if (U.UF.UP.isImg(el.value)) {//判断是否是图片
- //上传图片 调用上传函数,传入图片元素,上传地址,上传成功的回调函数,回调函数的传参
- U.UF.UP.inputUpload([el], "http://disk.1473.cn/USUpfile.ashx?typename=UploadWallpaper", U.MD.D.B.asynUp, [el]);
- }
- }
- /*
- * 作用:上传背景的设置
- * @param {element} url 图片的元素
- */
- U.MD.D.B.asynUp = function (url) { //上传背景设置
- var i, _userchild, _imginfo, //i 循环图片文件信息的长度;_userchild 获取用户id的子元素;_imginfo获取图片的信息
- _userinfo = US.userInfo; //用户信息
- _userid = _userinfo.BHID, //用户的BHID?
- _userchange = U.MD.DK.M.diskOperatingSwitch(_userinfo.UserId); //用户操作切换,可以查看多个用户的硬盘,所以需要切换。登录用户和非登录用户有不同权限。
- r = url.value; //图片文件信息?
- if (_userid && _userchange[_userid] && (_userchild = _userchange[_userid].Child)) {//false 不进去???
- for (i = 0; i < r.length; i++) {//循环图片文件信息的长度
- _imginfo = r[i]; //获取图片的信息
- //上传文件成功后,由前端的数据结构生成一个数据实体,实际传参请参考函数里面的数据结构
- _imginfo = new U.MD.DK.M.entity(_imginfo.UserFilesID, _imginfo.UserFilesSize, _imginfo.UserDirectoryID, _imginfo.UserFilesName, _imginfo.UserFilesName, _imginfo.UserFilesExtendName, US.FILESYSTEMURL + _imginfo.UserFilesServerName, _imginfo.UserFilesAddTime, _imginfo.UseFilesServerThumbnailName, 9999, null, "", 1, _imginfo.UserFilesDescript, "", null)
- _userchange[_userid].Child.push(_imginfo); //把上传文件成功的数据结构插入数组中
- }
- }
- U.MD.D.B.setBackgroundImage(U.MD.C.getHeadImage(r[0].UserFilesServerName)); //设置背景
- }
- /*
- * 作用:从网盘上传图片
- * @param {element} url 图片的元素
- */
- U.MD.D.B.uploadByPan = function () {
- U.MD.DK.VW.choseFile(function (obj) {
- U.MD.D.B.setBackgroundImage('http://fs.1473.cn/' + obj.UserDirectoryUrl, 'S'); //给每一个默认壁纸图片添加点击事件
- });
- };
- ///<jscompress sourcefile="AboutUs.js" />
- Namespace.register("U.MD.D.A"); //桌面提示框
- //#region 用户协议
- /*
- * 用户协议
- *
- * @param {element} 用户协议内容元素
- */
- U.MD.D.A.agreement = function (_el) {
- return new U.UF.UI.form("<div class='U_MD_F_S_TI'>安全协议</div>",
- U.selectEl(_el).parentElement().css("display", "block")[0],
- {
- "id": "U_MD_UI_UP_O",
- "style": {
- "width": "600px",
- "height": "452px"
- }
- },
- {
- isnarrow: false,
- isenlarge: false
- }).form;
- }
- //#endregion
- //#region 关于我们
- /*
- * 打开关于我们窗体
- *
- */
- U.MD.D.A.aboutUs = function () {
- var _el = U.selectEl("#U_MD_D_A_OT");
- _el.css("display", "block");
- new U.UF.UI.form("<div class='U_MD_F_S_TI'>关于我们</div>", _el[0],
- {
- "id": "U_MD_D_A_OT_A",
- "style": {
- "width": "920px",
- "height": "600px"
- }
- },
- {
- isnarrow: false,
- isenlarge: false
- });
- }
- //#endregion
- /*
- * 浏览器更新窗体
- *
- */
- U.MD.D.A.browserCompatibleForm = function () {
- new U.UF.UI.form("<div class='U_MD_F_S_TI'>浏览器更新</div>",
- U.selectEl("#U_MD_D_A")[0],
- {
- "id": "U_MD_D_A_A",
- "style": {
- "width": "970px",
- "height": "605px"
- }
- },
- {
- isnarrow: false,
- isenlarge: false
- });
- }
- //#endregion;
- ///<jscompress sourcefile="Disk.js" />
- ///<jscompress sourcefile="Disk.js" />
- Namespace.register("U.MD.DK"); //Disk的主命名空间
- //#region 初始化网盘
- //初始化网盘
- //
- //* @param {string} 用户id,可以是自己的用户id或者其他人的用户id。当为其他人的用户id时,为查看其他人的网盘信息
- //* @param {string} 目录id
- //* @returns {} 无
- //
- U.MD.DK.initDisk = function (userid, dirid) {
- //判断用户id是否存在,如果不存在说明是桌面的点击,那么就必须要求用户登录
- if (userid) {
- //获取网盘弹窗
- var _formdiv = U.selectEl("#U_D_" + userid)[0],
- _diskinfo = US.disk.Disks[userid];
- //如果网盘已经弹出,直接定位
- if (_formdiv) {
- U.UF.F.windowTopCenter(_formdiv);
- U.selectEl("#U_MD_DK_LTXO", _formdiv)[0].innerHTML = ""; //清除树状图
- //判断是否为本人网盘
- //如果是的话则显示完整的左侧树目录
- if (userid == US.userInfo.UserId) {
- U.MD.DK.LL.printLeftTreeDirectory(_diskinfo.directoryOrFiles.slice(0, 5), U.selectEl("#U_MD_DK_LTXO", _formdiv)[0], userid, ["U_MD_DK_LCD", "U_MD_DK_LCS", "U_MD_DK_LCD", "U_MD_DK_LCB", "U_MD_DK_LCF", "U_MD_DK_LCT", "U_MD_DK_LCP", "U_MD_DK_LCY"])
- }
- //非本人操作的处理
- else {
- U.MD.DK.LL.printLeftTreeDirectory(_diskinfo.directoryOrFiles.slice(4, 5), U.selectEl("#U_MD_DK_LTXO", _formdiv)[0], userid, ["U_MD_DK_LCD", "U_MD_DK_LCS", "U_MD_DK_LCD", "U_MD_DK_LCB", "U_MD_DK_LCF", "U_MD_DK_LCT", "U_MD_DK_LCP", "U_MD_DK_LCY"])
- }
- U.MD.DK.openDirByDirID(userid, dirid); //导航到制定目录
- }
- //如果网盘没有弹出的处理
- else if (!_diskinfo) {
- var _diskel = U.selectEl("#U_MD_DK").clone(true)[0],
- _loginuserid = US.userInfo.UserId || US.EMPTYGUID; //网盘内容元素
- _diskel.id = "U_MD_DK__" + userid; //网盘内容的元素id设置为U_MD_DK__加上用户id
- _diskel.style.display = "block"; //显示
- //云盘拖拽
- //$('.U_MD_DK_RZA', _diskel).bind('mousedown', function () { console.log(0); })
- //窗体的事件处理,api中没有,需要补充。
- _formdiv = new U.UF.UI.form("<div class='U_MD_F_S_TI'>网盘</div>",
- _diskel, {
- "onmousedown": function () {
- U.MD.DK.M.diskOperatingSwitch(userid);
- }, //鼠标单击事件。打开多个网盘时,切换网盘数据,此处需要修正,并删除.
- "onresize": function () {
- U.MD.DK.size(_diskel);
- }, //窗体放大缩小时的处理。
- "id": "U_D_" + userid,
- "style": {
- "width": "80%",
- "height": "85%"
- }
- }).form;
- //数据库获取指定用户指定目录下的网盘数据
- U.A.Request(US.DISK, ["InitDisk", _loginuserid, userid, dirid], U.MD.DK.asynInitDisk, [_diskel, userid, dirid, US.userInfo.UserId || US.EMPTYGUID, _formdiv]); //服务器加载
- }
- return _formdiv;
- //没有用户id说明用户没有登录点击桌面的网盘。
- }
- else {
- U.MD.U.L.login();
- }
- }
- /**
- * 得到后台获取的用户数据
- *
- * @param {object} request返回值
- * context 上下文之间的传参
- * value服务器返回值 0 用户初始化定位到指定文件夹下面的所有文件和文件夹 1 用户的信息 2 用户的网盘信息
- **/
- U.MD.DK.asynInitDisk = function (r) {
- var _dirinfo,
- _context = r.context, //获取上下文传参
- _diskel = _context[0], //disk内容元素
- _userid = _context[1], //用户的id
- _dirid = _context[2], //目录id
- _loginuserid = _context[3], //用户登录id
- _formdiv = _context[4], //网盘窗体元素
- _value = r.value //数据库返回的值
- ;
- //判断根据用户id是否能获取到用户的资料
- if (_value) {
- //设置用户全局变量
- var _diskinfo = U.MD.DK.setUserGlobalVariable(_userid, _dirid, _value);
- //初始化左侧的头部样式
- U.MD.DK.VW.followState(_formdiv, _userid, _loginuserid);
- //初始化当前用户网盘前进后退
- U.UF.N.createNav("disk" + _userid);
- //初始化按钮点击事件
- U.MD.DK.initDiskButton(_diskinfo);
- //网盘大小初始化设置
- U.MD.DK.size(_diskinfo.formel);
- //初始化用户信息
- U.MD.DK.initDiskUserInfo(_diskinfo);
- //打印左边树目录信息
- if (_diskinfo.userInfo.UserId == _diskinfo.operator) {
- U.MD.DK.LL.printLeftTreeDirectory(_diskinfo.directoryOrFiles.slice(0, 5), U.selectEl("#U_MD_DK_LTXO", _diskinfo.formel)[0], _userid, ["U_MD_DK_LCD", "U_MD_DK_LCS", "U_MD_DK_LCD", "U_MD_DK_LCB", "U_MD_DK_LCF", "U_MD_DK_LCT", "U_MD_DK_LCP", "U_MD_DK_LCY"])
- }
- else {
- U.MD.DK.LL.printLeftTreeDirectory(_diskinfo.directoryOrFiles.slice(4, 5), U.selectEl("#U_MD_DK_LTXO", _diskinfo.formel)[0], _userid, ["U_MD_DK_LCD", "U_MD_DK_LCS", "U_MD_DK_LCD", "U_MD_DK_LCB", "U_MD_DK_LCF", "U_MD_DK_LCT", "U_MD_DK_LCP", "U_MD_DK_LCY"])
- }
- U.MD.DK.openDirByDirID(_userid, _dirid); //导航到制定目录上
- }
- //获取用户资料失败
- else {
- U.alert("帐号不存在...");
- //移除网盘窗体
- U.selectEl(_diskinfo.formel).remove();
- }
- }
- /**
- * 根据目录id打开目录
- *
- * @param {string} 目录id
- **/
- U.MD.DK.openDirByDirID = function (userid, dirid) {
- var _diskinfo = US.disk.Disks[userid];
- if (_diskinfo) {
- //导航到达指定的目录
- //打开文件,目录及导航到达区域。因为现在是按需加载数据,不可能完全导航到达指定位置,则不做左边树目录展开功能
- var _dirinfo = U.Json.select(_diskinfo.directoryOrFiles, { "UserDirectoryID": dirid })[0]; //获取当前需要打开的文件夹信息
- //如果目录存在的处理
- if (_dirinfo) {
- //如果左边的目录可以输出的处理
- if ($("#L" + _dirinfo["UserDirectoryID"], _diskinfo.formel)[0]) {
- U.MD.DK.LL.leftTreeClick(_dirinfo, U.selectEl("#L" + _dirinfo["UserDirectoryID"], _diskinfo.formel)[0], userid); //打开该文件夹
- }
- //否则直接打印数据
- else {
- U.MD.DK.LE.openFileDirectory(_dirinfo, userid);
- }
- }
- //目录查看不了或者是不允许查看
- else {
- //打印数据
- U.MD.DK.VW.printContent([], U.selectEl("#U_MD_DK_RZ", _diskinfo.formel)[0]);
- }
- }
- }
- /**
- * 打开应用
- *
- * @param {string} 用户id
- * @param {string} 目录id
- * @param {object} directoryOrFiles是dirid目录下所有的文件和文件夹 userInfo是用户的信息+用户的网盘信息
- **/
- U.MD.DK.setUserGlobalVariable = function (userid, dirid, diskinfo) {
- var _dirinfo,
- _basicdirectory = U.MD.DK.getBasicDirectory(diskinfo), //获取一级目录
- _groupdirectory = U.MD.DK.getGroupDirectory(diskinfo.groups, _basicdirectory, diskinfo.userInfo.UserId) //获取群目录
- ;
- _basicdirectory = _basicdirectory.concat(_groupdirectory); //群和一级目录合并生成初始化目录
- //_basicdirectory[1].Child = _groupdirectory; //把群添加到文档群的的下面,作为文件夹
- //diskinfo.directoryOrFile是第一次进入的时候获取的文件夹下面的文件,那么这个时候就要添加到指定的目录的child里面
- _dirinfo = U.Json.select(_basicdirectory, { "UserDirectoryID": dirid }, 1)[0];
- if (!_dirinfo && diskinfo.currentdirectory[0]) {
- _dirinfo = diskinfo.currentdirectory[0]; //获取服务器返回的当前目录
- _dirinfo = new U.MD.DK.M.entity(_dirinfo.UserDirectoryID, 0,
- _dirinfo.UserDirectoryParentID, _dirinfo.UserDirectoryName, _dirinfo.UserDirectoryName, _dirinfo.UserDirectoryExtendType,
- "", _dirinfo.UserDirectoryAddTime, _dirinfo.UserDirectoryUrl, _dirinfo.UserDirectoryDeep, _dirinfo.UserDirectoryModifyTime,
- _dirinfo.UserDirectoryEncrypt, 0, "", _dirinfo.GroupID);
- _basicdirectory.push(_dirinfo);
- }
- //判断是在制定的以及目录下的子文件的处理
- if (_dirinfo) {
- _dirinfo.Child = diskinfo.directoryOrFiles;
- U.Json.add(diskinfo.directoryOrFiles, { "Parent": _dirinfo });
- }
- diskinfo.directoryOrFiles = _basicdirectory.concat(diskinfo.directoryOrFiles); //基础目录加上dirid获取的数据
- //设置用户的全局变量
- US.disk.Disks[userid] = diskinfo; //diskinfo.directoryOrFiles是dirid目录下所有的文件和文件夹 userInfo是用户的信息+用户的网盘信息
- US.disk.Disks[userid].formel = U.selectEl("#U_D_" + userid)[0]; //对应的网盘窗体元素
- US.disk.Disks[userid].directoryid = dirid; //当前打开的目录id
- US.disk.Disks[userid].currentDirectoryFile = []; //当前目录下所有的文件
- US.disk.Disks[userid].operator = US.userInfo.UserId; //操作用户id
- return US.disk.Disks[userid]; //返回用户网盘的信息
- }
- /**
- * 获取一个一级目录
- *
- **/
- U.MD.DK.getBasicDirectory = function (diskinfo) {
- var i,
- _diskdir = US.disk.initTree.concat(); //concat相当于数组的克隆,克隆一个一级目录数组
- //补充disk网盘的全局变量数据 补充左边初始化目录数据我的电脑等
- for (i = 0; i < _diskdir.length; i++) { //初始化查看
- //创建一个一级目录对象
- _diskdir[i] = new U.MD.DK.M.entity(_diskdir[i][0], _diskdir[i][1], _diskdir[i][2], _diskdir[i][3], _diskdir[i][4],
- _diskdir[i][5], _diskdir[i][6], _diskdir[i][7], _diskdir[i][8], _diskdir[i][9],
- _diskdir[i][10], _diskdir[i][11], _diskdir[i][12], _diskdir[i][13], _diskdir[i][14],
- _diskdir[i][15], diskinfo.userInfo.UserId, diskinfo.userInfo.UserNickName, diskinfo.userInfo.UserName, diskinfo.userInfo.UserThumbnailImageHead);
- };
- //返回一级目录
- return _diskdir;
- }
- /**
- * 生成群目录
- * @param {array} 群数组
- * @param {array} 目录id
- * @param {string} 用户id
- *
- **/
- U.MD.DK.getGroupDirectory = function (groups, basicdirectory, userid) {
- if (groups != null) {
- var i, _diskgroupinfo; //concat相当于数组的克隆,克隆一个一级目录数组
- //还没有初始化群的处理
- if (!basicdirectory[1].Child) {
- basicdirectory[1].Child = [];
- }
- //还没有初始化群的处理
- if (!basicdirectory[2].Child) {
- basicdirectory[2].Child = [];
- }
- //补充disk网盘的全局变量数据 补充左边初始化目录数据我的电脑等
- for (i = 0; i < groups.length; i++) { //初始化查看
- _diskgroupinfo = groups[i];
- //创建一个一级目录对象
- groups[i] = new U.MD.DK.M.entity(groups[i].GroupManageID, 0, US.EMPTYGUID, groups[i].GroupManageName,
- groups[i].GroupManageName, "folder", null, U.UF.D.toTimeStamp(new Date()), U.MD.DK.C.getIcon("folder")[1],
- 1, null, null, 0, "", groups[i].GroupManageID, null, groups[i].GroupManageUserID, groups[i].GroupManageName, groups[i].GroupManageName);
- //如果是群主的处理,那么就做为协同文件
- if (_diskgroupinfo.GroupManageCreateUserID == userid) {
- basicdirectory[1].Child.push(groups[i]);
- groups[i].Parent = basicdirectory[1];
- }
- //非群主的,作为协同他人的处理
- else {
- basicdirectory[2].Child.push(groups[i]);
- groups[i].Parent = basicdirectory[2];
- }
- };
- }
- //返回一级目录
- return groups || [];
- }
- /**
- * 初始化硬盘点击按钮
- *
- * @param {string} 用户网盘信息
- **/
- U.MD.DK.initDiskButton = function (diskinfo) {
- var _navchildel = U.selectEl("#U_MD_DK_RKZ", diskinfo.formel).Child(),
- _viewchildel = U.selectEl("#U_MD_DK_RM", diskinfo.formel).Child(),
- _child = U.selectEl("#U_MD_DK_RY", diskinfo.formel).Child(),
- _headchild = U.selectEl("#U_MD_DK_RT", diskinfo.formel).Child(),
- _userid = diskinfo.userInfo.UserId,
- _el = U.selectEl("#U_MD_DK_RZ", diskinfo.formel)[0]
- ; //头部新建文件夹等按钮
- //上传事件
- _headchild[0].onclick = function () {
- U.MD.DK.C.upload(diskinfo);
- }
- //新建目录事件
- _headchild[1].onclick = function () {
- U.MD.DK.RE.newFolder(diskinfo);
- }
- //新建文本事件
- _headchild[2].onclick = function () {
- U.MD.DK.RE.newText(diskinfo);
- }
- //新建文档事件
- _headchild[3].onclick = function () {
- U.MD.DK.RE.newDocument(diskinfo);
- }
- //新建导航文档事件
- _headchild[4].onclick = function () {
- U.MD.DK.RE.newopenApplication(diskinfo);
- }
- //新建表格事件
- _headchild[5].onclick = function () {
- U.MD.DK.RE.newExcel(diskinfo);
- }
- //创建站点
- _headchild[6].onclick = function () {
- var _dirinfo = U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": diskinfo.directoryid })[0];
- //如果是初始化目录的处理
- if (_dirinfo.UserDirectoryDeep == 0) {
- window.open('http://' + diskinfo.directoryid + '.1473.cn?userid=' + diskinfo.userInfo.UserId);
- }
- //非初始化目录
- else if (_dirinfo.UserDirectoryDeep == 1) {
- window.open('http://' + diskinfo.directoryid + '.1473.cn?userid=' + _dirinfo.UserId);
- } else {
- window.open('http://' + diskinfo.directoryid + '.1473.cn');
- }
- }
- //前进事件
- _child[0].onclick = function () {
- U.UF.N.backOff("disk" + _userid); //前进事件
- }
- //后退事件
- _child[1].onclick = function () {
- U.UF.N.goAhead("disk" + _userid); //后退事件
- }
- //刷新按钮
- _child[2].onclick = function () {
- U.MD.DK.RE.refresh(_userid, U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": diskinfo.directoryid })[0], diskinfo); //刷新函数
- }
- //右键菜单点击处理
- _el.oncontextmenu = function () {
- U.MD.DK.RM.rightMenu(null, null, diskinfo);
- };
- //拖选元素处理
- _el.onmousedown = function () {
- U.MD.DK.C.selectElement(_el, diskinfo);
- };
- //左键点击空白处理
- U.UF.EV.addElementEvent("mousedown", window, function () {
- U.selectEl("#U_MD_DK_M", diskinfo.formel)[0].style.display = "none";
- });
- //时间排序按钮
- _navchildel[0].onclick = function () {
- U.MD.DK.VW.SortView(diskinfo, "UserDirectoryAddTime", function (timeone, timetwo) {
- return U.UF.D.sizeComparison(timeone, timetwo) == false;
- }); //时间排序处理
- }
- //普通视图
- _navchildel[1].onclick = function () {
- //视图按钮切换
- _navchildel[1].className = "U_MD_DK_RKZOI U_MD_DK_Img U_MD_DK_RKZOS U_MD_DK_RKZOSI";
- _navchildel[2].className = "U_MD_DK_RKZOI U_MD_DK_Img U_MD_DK_RKZOP";
- //普通视图
- U.MD.DK.VW.viewsSwitch("Normal", diskinfo);
- }
- //详细视图
- _navchildel[2].onclick = function () {
- //视图按钮切换
- _navchildel[1].className = "U_MD_DK_RKZOI U_MD_DK_Img U_MD_DK_RKZOS";
- _navchildel[2].className = "U_MD_DK_RKZOI U_MD_DK_Img U_MD_DK_RKZOP U_MD_DK_RKZOPI";
- //详细视图
- U.MD.DK.VW.viewsSwitch("Detailed", diskinfo);
- }
- //文件名排序
- _viewchildel[2].onclick = function () {
- U.MD.DK.VW.SortView(diskinfo, "UserallDirectoryName", function (dirnameone, dirnametwo) { //时间排序处理
- return dirnameone.localeCompare(dirnametwo, "zh") == 1;
- });
- }
- //分享次数排序,暂时分享次数没有用处
- // _child[2].onclick = function () {
- // U.MD.DK.VW.SortView(diskinfo, "", function (timeone, timetwo) {
- // return U.UF.D.sizeComparison(timeone, timetwo) == false;
- // }); //时间排序处理
- // }
- //来源名字排序
- _viewchildel[6].onclick = function () {
- U.MD.DK.VW.SortView(diskinfo, "UserNickName", function (nameone, nametwo) { //根据用户名排序
- return nameone.localeCompare(nametwo, "zh") == 1;
- });
- }
- //类型排序
- _viewchildel[8].onclick = function () {
- U.MD.DK.VW.SortView(diskinfo, "UserDirectoryExtendType", function (typeone, typetwo) { //根据类型排序
- return typeone.localeCompare(typetwo, "zh") == 1;
- });
- }
- //大小排序排序
- _viewchildel[10].onclick = function () {
- U.MD.DK.VW.SortView(diskinfo, "UserDirectorySize", function (sizeone, sizetwo) { //根据文件大小排序
- return sizeone > sizetwo;
- });
- }
- //时间排序排序
- _viewchildel[12].onclick = function () {
- U.MD.DK.VW.SortView(diskinfo, "UserDirectoryAddTime", function (timeone, timetwo) { //根据添加事件排序
- return U.UF.D.sizeComparison(timeone, timetwo) == 1;
- });
- }
- }
- /**
- * 打印网盘用户资料
- *
- * @param {string} 用户网盘信息
- **/
- U.MD.DK.initDiskUserInfo = function (diskinfo) {
- var _formel = diskinfo.formel,
- _userinfo = diskinfo.userInfo,
- _child
- ;
- //用户头像
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": U.MD.C.imgError,
- "title": "点击查看",
- "src": U.MD.C.getHeadImage(_userinfo.UserThumbnailImageHead)
- }, U.selectEl("#U_MD_DK_LIL", _formel)[0]);
- //用户名
- U.selectEl("#U_MD_DK_LIRN", _formel)[0].innerText = _userinfo.UserNickName || _userinfo.UserName;
- //用户个人简介
- U.selectEl("#U_MD_DK_LIRZ", _formel)[0].innerText = _userinfo.UserIndividualitysignature || "暂无个人简介";
- //用户硬盘信息打印
- _child = U.selectEl("#U_MD_DK_LS", _formel).find("div");
- _child[4].innerText = U.UF.UP.minUnitToMaxUnit(_userinfo.UserDiskSpace + "M"); //用户有多少网盘空间
- _child[7].innerText = U.UF.UP.minUnitToMaxUnit(_userinfo.FileSize + "B"); //用户用了多少网盘空间
- }
- /**
- * 网盘大小调整
- *
- * @param {element} 网盘窗体元素
- **/
- U.MD.DK.size = function (formel) {
- var _contentel = U.selectEl("#U_MD_DK_RZ", formel); //获取中间显示内容区域的大小
- _contentel.css("height", _contentel.Parent(2).offsetHeight - 79 + "px"); //设置内容区域的大小
- }
- //#endregion
- ;
- ///<jscompress sourcefile="DiskCommon.js" />
- Namespace.register("U.MD.DK.C"); //网盘功能使用区域
- /**
- * 获取目录树的一条线上的所有祖先
- * @param {string} 操作的目录id
- * @param {array} 用户的网盘信息
- * @param {object} 在该目录下操作的文件
- * @return {array} 得到操作权限数组
- */
- U.MD.DK.C.getAncestors = function (fileinfo, diskinfo) {
- var _dirinfo = fileinfo, //目录数据
- _ancestors = [] //这里是需要返回的祖先
- ;
- //不断的循环寻找自己的祖先
- while (_dirinfo) {
- _ancestors.push(_dirinfo); //找到后追加
- _dirinfo = U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": _dirinfo.UserDirectoryParentID }, 1)[0]; //设置搜索的目录id为上级的id不断的向上搜索祖先
- }
- return _ancestors; //返回自己的祖先元素
- }
- /**
- * 判断是否具有添加网盘的操作权限 判断是否有添加的权限 和 获取的权限
- * @param {string} 操作的目录id
- * @param {array} 用户的网盘信息
- * @return {array} 文件的权限信息
- * 0 目录id
- * 1-n 所有涉及到权限信息 (1只允许上传 2只允许下载)
- **/
- U.MD.DK.C.readWritePermission = function (dirid, diskinfo) {
- var i,
- _permi,
- _dirs = [],
- _returns = [],
- _fileinfo = U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": dirid }, 1)[0] //获取当前操作目录的目录信息
- ;
- //该目录未加载或者该目录id加载的不是目录,如我的协同、最近文件等
- if (_fileinfo) {
- //获取当前操作的目录所有的祖先文件夹
- _dirs = U.MD.DK.C.getAncestors(_fileinfo, diskinfo);
- _returns.push(_dirs);
- //循环所有的祖先集,找出读写权限
- for (i = 0; i < _dirs.length; i++) {
- _permi = _dirs[i].UserDirectoryEncrypt; //获取该目录的操作权限的方式
- if (_permi == "1" || _permi == "2") { //判断是否有上传下载权限
- _returns.push(_permi); break;
- }
- } //获取权限
- }
- return _returns;
- }
- /**
- * 判断是否具有添加网盘的操作权限 判断是否有添加的权限 和 获取的权限
- * @param {string} 操作的目录id
- * @param {array} 用户的网盘信息
- * @param {object} 在该目录下操作的文件
- * @return {array} 得到操作权限数组
- * 0 判断该目录是否允许上传 1、自己建立的目录是可以下载的 2、没有限制只允许上传的可以下载
- * 1 判断该目录是否允许下载 1、自己建立的目录是可以上传的 2、ftp中没有限制只允许上传的是可以下载
- * 2 判断是否具有添加网盘的操作权限 判断是否有添加的权限 和 获取的权限
- * 3 获取上传的目录用户对应的临时目录
- * 4 判断操作的文件是否有本人有关 包含是本人创建、本人网盘里、在本人创建的群里
- */
- U.MD.DK.C.getDirectoryPermissions = function (fileordirid, diskinfo) {
- diskinfo = diskinfo || US.disk.UserDisk; //需要操作的当前用户的网盘信息
- var _isftp, //是否操作ftp
- _ismyself, //是否操作本人网盘内容
- _isuserdisk, //是否在自己的网盘中
- _isgroup, //是否在群里
- _isgroupmain,
- _permissions = US.permission.getDiskPermission(), //调用方法,从权限变量文件中获取克隆一份权限
- _permissioninfo = U.MD.DK.C.readWritePermission(fileordirid, diskinfo), //获取权限
- _dirinfo = _permissioninfo[0][_permissioninfo[0].length - 1], //所操作的文件或者是文件夹所操作的目录
- _currentfileordir = _permissioninfo[0][0], //当前操作的文件或者文件夹
- _readwrite = _permissioninfo.splice(1) //得到文件的读写权限和祖先元素
- ;
- //如果是未登录、群、最新文档,协同文档,则没有权限操作
- if (_currentfileordir && !US.userInfo.UserId || _currentfileordir.UserDirectoryID == diskinfo.directoryOrFiles[0].UserDirectoryID || _currentfileordir.UserDirectoryID == diskinfo.directoryOrFiles[1].UserDirectoryID || _currentfileordir.UserDirectoryID == diskinfo.directoryOrFiles[2].UserDirectoryID) {
- _permissions.isopen = false; //是否允许打开, 现在所有的文件都有打开权限
- _permissions.isupadte = false; //是否允许修改, 只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- _permissions.isdelete = false; //是否允许删除, 只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- _permissions.iscopy = false; //是否允许复制,现在所有的文件都有复制权限
- _permissions.isshear = false; //是否允许剪切,只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- _permissions.isencryption = false; //是否允许加密,展示取消这个功能。
- _permissions.isreply = false; //是否允许加密,展示取消这个功能。
- _permissions.isdownload = false; //是否允许下载,只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- _permissions.isnew = false; //是否允许新建, 只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- _permissions.ispaste = false; //是否允许粘贴,只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- _permissions.isrefresh = false; //是否允许刷新, 现在所有的文件都有刷新权限
- _permissions.isupload = false; //是否允许上传,文件夹设置了不允许下载的文件夹和文件夹下的所有文件都不允许下载,其他都有权限
- _permissions.isview = false; //是否允许视图切换,所有的文件夹都支持
- _permissions.isedit = false; //是否允许编辑,只有拥有可修改权限的文本文件才能修改
- }
- else {
- //在我的ftp中,我可以操作所有人的东西,我具备所有的权限
- _isgroup = _dirinfo.GroupID != ""; //是否是群文件
- _isftp = _currentfileordir.GroupID == ""; //判断是否为ftp目录下的文件
- //_isftp = diskinfo.userInfo.UserId == _currentfileordir.UserId; //判断是否为ftp目录下的文件
- _isuserdisk = (diskinfo.userInfo.UserId == diskinfo.operator); //是否是属于自己的网盘
- _isgroupmain = U.Json.select(diskinfo.groups, { "UserDirectoryID": _dirinfo.GroupID, "UserId": diskinfo.operator }).length > 0; //判断自己是否是群主
- _ismyself = _currentfileordir.UserId == diskinfo.operator; //判断是否是操作本人的文件,群里的文件非本人创建的或者不是自己的群都不为自己的文件
- //在我的ftp中,我可以操作所有人的东西,我具备所有的权限
- //判断是否为本人操作
- if (!_isuserdisk) {
- //如果不是,为外来访客
- //判断是否为ftp文件,如果不是
- if (!_isftp) {
- _permissions.isnew = false; //不允许新建
- _permissions.isopen = false; //不允许打开
- }
- //判断是否为本人文件,如果不是
- if (!_ismyself) {
- _permissions.isupadte = false; //不允许修改
- _permissions.isdelete = false; //不允许删除
- _permissions.isshear = false; //不允许剪切
- _permissions.isencryption = false; //不允许加密
- _permissions.ispaste = false; //不允许粘贴
- _permissions.isedit = false; //不允许编辑
- }
- } else {
- //如果是自己的文件夹中
- //判断是否为他人邀请文件夹,如果是
- //判断是否为自己的文件,如果不是
- if (_isgroup && !_ismyself && !_isgroupmain) {
- _permissions.isupadte = false; //不允许修改
- _permissions.isdelete = false; //不允许删除
- _permissions.isshear = false; //不允许剪切
- _permissions.isencryption = false; //不允许加密
- _permissions.ispaste = false; //不允许粘贴
- _permissions.isedit = false; //不允许编辑
- }
- //判断是否为协同文档的第一层,协同群,如果是
- if (_isgroup && _currentfileordir.UserDirectoryDeep == 1) {
- _permissions.isupadte = false; //不允许修改
- _permissions.isdelete = false; //不允许删除
- _permissions.isshear = false; //不允许剪切
- _permissions.isencryption = false; //不允许加密
- _permissions.ispaste = false; //不允许粘贴
- _permissions.isedit = false; //不允许编辑
- _permissions.iscopy = false; //不予许复制
- _permissions.isdownload = false; //不予许下载
- if (_currentfileordir.UserDirectoryName == "我的协同" || _currentfileordir.UserDirectoryName == "他人邀请") {
- _permissions.isnew = false; //不允许新建
- }
- }
- }
- //1只允许上传
- if (!_ismyself && _readwrite.indexOf("1") > -1) {
- _permissions.isdownload = false; //不允许下载
- _permissions.copy = false; //不允许复制
- _permissions.isshear = false; //不允许剪切
- }
- //2只允许下载
- if (!_ismyself && _readwrite.indexOf("2") > -1) {
- _permissions.isnew = false; //不允许新建
- _permissions.isupload = false; //不允许上传
- _permissions.ispaste = false; //不允许粘贴
- }
- //如果是文件的话就没有视图模式
- if (fileordirid && fileordirid.filetype == 1) {
- _permissions.isview = false;
- }
- else {
- _permissions.isreply = false;
- }
- if (!diskinfo.pasteDirOrFile) {
- _permissions.ispaste = false; //不允许粘贴
- }
- }
- //选择了多目录的处理
- if (diskinfo.selectElement && diskinfo.selectElement.length > 1) {
- _permissions.isopen = false; //取消同时打开的功能
- _permissions.isupadte = false; //取消修改的功能
- }
- diskinfo.permissions = _permissions; //设置权限
- return _permissions;
- }
- /**
- * 判断是否具有添加网盘的操作权限 判断是否有添加的权限 和 获取的权限
- * @param {string} 操作的目录id
- * @param {array} 用户的网盘信息
- * @param {object} 在该目录下操作的文件
- * @return {array} 得到操作权限数组
- * 0 判断该目录是否允许上传 1、自己建立的目录是可以下载的 2、没有限制只允许上传的可以下载
- * 1 判断该目录是否允许下载 1、自己建立的目录是可以上传的 2、ftp中没有限制只允许上传的是可以下载
- * 2 判断是否具有添加网盘的操作权限 判断是否有添加的权限 和 获取的权限
- * 3 获取上传的目录用户对应的临时目录
- * 4 判断操作的文件是否有本人有关 包含是本人创建、本人网盘里、在本人创建的群里
- U.MD.DK.C.getDirectoryPermissions = function (fileordirid, diskinfo) {
- diskinfo = diskinfo || US.disk.UserDisk; //需要操作的当前用户的网盘信息
- var _isftp, //是否操作ftp
- _ismyself, //是否操作本人网盘内容
- _isuserdisk, //是否在自己的网盘中
- _isgroup, //是否在群里
- _isgroupmain,
- _permissions = { //所有的权限
- "isopen": true, //是否允许打开, 现在所有的文件都有打开权限
- "isupadte": true, //是否允许修改, 只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- "isdelete": true, //是否允许删除, 只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- "iscopy": true, //是否允许复制,现在所有的文件都有复制权限
- "isshear": true, //是否允许剪切,只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- "isencryption": false, //是否允许加密,展示取消这个功能。
- "isreply": true, //是否允许加密,展示取消这个功能。
- "isdownload": true, //是否允许下载,只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- "isnew": true, //是否允许新建, 只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- "ispaste": true, //是否允许粘贴,只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- "isrefresh": true, //是否允许刷新, 现在所有的文件都有刷新权限
- "isupload": true, //是否允许上传,文件夹设置了不允许下载的文件夹和文件夹下的所有文件都不允许下载,其他都有权限
- "isview": true, //是否允许视图切换,所有的文件夹都支持
- "isedit": true //是否允许编辑,只有拥有可修改权限的文本文件才能修改
- },
- _permissioninfo = U.MD.DK.C.readWritePermission(fileordirid, diskinfo), //获取权限
- _dirinfo = _permissioninfo[0][_permissioninfo[0].length - 1], //所操作的文件或者是文件夹所操作的目录
- _currentfileordir = _permissioninfo[0][0], //当前操作的文件或者文件夹
- _readwrite = _permissioninfo.splice(1) //得到文件的读写权限和祖先元素
- ;
- //如果是未登录、群、最新文档,协同文档,则没有权限操作
- if (_currentfileordir && !US.userInfo.UserId || _currentfileordir.UserDirectoryID == diskinfo.directoryOrFiles[0].UserDirectoryID || _currentfileordir.UserDirectoryID == diskinfo.directoryOrFiles[1].UserDirectoryID || _currentfileordir.UserDirectoryID == diskinfo.directoryOrFiles[2].UserDirectoryID) {
- _permissions = { //所有的权限
- "isopen": false, //是否允许打开, 现在所有的文件都有打开权限
- "isupadte": false, //是否允许修改, 只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- "isdelete": false, //是否允许删除, 只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- "iscopy": false, //是否允许复制,现在所有的文件都有复制权限
- "isshear": false, //是否允许剪切,只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- "isencryption": false, //是否允许加密,展示取消这个功能。
- "isreply": false, //是否允许加密,展示取消这个功能。
- "isdownload": false, //是否允许上传,只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- "isnew": false, //是否允许新建, 只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- "ispaste": false, //是否允许粘贴,只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- "isrefresh": false, //是否允许刷新, 现在所有的文件都有刷新权限
- "isupload": false, //是否允许下载,文件夹设置了不允许下载的文件夹和文件夹下的所有文件都不允许下载,其他都有权限
- "isview": false, //是否允许视图切换,所有的文件夹都支持
- "isedit": false //是否允许编辑,只有拥有可修改权限的文本文件才能修改
- }
- }
- // //如果是群目录下的处理
- // else if (_currentfileordir.filetype == 0 && _dirinfo.GroupID == _currentfileordir.GroupID) {
- // _permissions = { //所有的权限
- // "isopen": false, //是否允许打开, 现在所有的文件都有打开权限
- // "isupadte": false, //是否允许修改, 只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- // "isdelete": false, //是否允许删除, 只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- // "iscopy": false, //是否允许复制,现在所有的文件都有复制权限
- // "isshear": false, //是否允许剪切,只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- // "isencryption": false, //是否允许加密,展示取消这个功能。
- // "isreply": true, //是否允许加密,展示取消这个功能。
- // "isdownload": false, //是否允许上传,只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- // "isnew": true, //是否允许新建, 只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- // "ispaste": true, //是否允许粘贴,只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- // "isrefresh": true, //是否允许刷新, 现在所有的文件都有刷新权限
- // "isupload": true, //是否允许下载,文件夹设置了不允许下载的文件夹和文件夹下的所有文件都不允许下载,其他都有权限
- // "isview": true, //是否允许视图切换,所有的文件夹都支持
- // "isedit": true //是否允许编辑,只有拥有可修改权限的文本文件才能修改
- // }
- // }
- else {
- //在我的ftp中,我可以操作所有人的东西,我具备所有的权限
- _isgroup = _dirinfo.GroupID != null; //是否是群文件
- _isftp = _dirinfo.GroupID == _currentfileordir.GroupID; //判断是否为ftp目录下的文件
- _isuserdisk = (diskinfo.userInfo.UserId == diskinfo.operator); //是否是属于自己的网盘
- _isgroupmain = U.Json.select(diskinfo.groups, { "UserDirectoryID": _dirinfo.GroupID, "UserId": diskinfo.operator }).length > 0; //判断自己是否是群主
- _ismyself = _currentfileordir.UserId == diskinfo.operator; //判断是否是操作本人的文件,群里的文件非本人创建的或者不是自己的群都不为自己的文件
- //不是自己的文件,同时不是在ftp,或者不是群主的处理
- if (!_ismyself && !_isftp && !_isgroupmain) {
- _permissions.isupadte = false; //不允许修改
- _permissions.isdelete = false; //不允许删除
- _permissions.isshear = false; //不允许剪切
- _permissions.isencryption = false; //不允许加密
- _permissions.ispaste = false; //不允许粘贴
- _permissions.isedit = false; //不允许编辑
- //如果不是ftp连新建的权限也取消
- if (!_isftp) {
- _permissions.isnew = false; //不允许新建
- }
- }
- //1只允许上传
- if (!_ismyself && _readwrite.indexOf("1") > -1) {
- _permissions.isdownload = false; //不允许下载
- _permissions.copy = false; //不允许复制
- _permissions.isshear = false; //不允许剪切
- }
- //2只允许下载
- if (!_ismyself && _readwrite.indexOf("2") > -1) {
- _permissions.isnew = false; //不允许新建
- _permissions.isupload = false; //不允许上传
- _permissions.ispaste = false; //不允许粘贴
- }
- //如果是文件的话就没有视图模式
- if (fileordirid && fileordirid.filetype == 1) {
- _permissions.isview = false;
- }
- else {
- _permissions.isreply = false;
- }
- if (!diskinfo.pasteDirOrFile) {
- _permissions.ispaste = false; //不允许粘贴
- }
- }
- //选择了多目录的处理
- if (diskinfo.selectElement && diskinfo.selectElement.length > 1) {
- _permissions.isopen = false; //取消同时打开的功能
- _permissions.isupadte = false; //取消修改的功能
- }
- diskinfo.permissions = _permissions; //设置权限
- return _permissions;
- }
- */
- /**
- * 弹出选择网盘还是上传
- *
- * @param {string} 文件的后缀
- * @return {object}
- */
- U.MD.DK.C.getIcon = function (extendtype) {
- var i,
- _application = US.disk.applicationTypes //获取所有打开应用的信息
- ;
- if (extendtype) {
- //循环信息中找到指定的应用的信息
- for (i in _application) {
- //找到后缀名对应的程序信息
- if (_application[i].types.indexOf(extendtype.toLowerCase()) > -1) {
- return _application[i]; //返回应用的信息
- }
- }
- }
- return _application["unknownfile"]; //如果是本站未知的后缀直接归属于文件
- }
- /**
- * 网盘上传的处理
- * @param {object} 获取服务器返回值
- * @param {string} 上传文件的唯一识别id
- */
- U.MD.DK.C.upload = function (diskinfo) {
- //判断该目录是否允许上传的处理
- if (diskinfo.permissions.isupload) {
- var _groupid,
- _ancestors,
- _directoryid = diskinfo.directoryid,
- _dirinfo = U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": _directoryid })[0]
- ;
- //获取粘贴到制定目录的群id
- _ancestors = U.MD.DK.C.getAncestors(_dirinfo, diskinfo); //获取所有的祖先
- //如果是ftp目录,那么groupid就是用户id
- if (_ancestors[_ancestors.length - 1].UserDirectoryID == US.FTPFOLDERID) {
- _groupid = diskinfo.userInfo.UserId;
- }
- //否则就是对应的群id,如果不存在那么就是""
- else {
- _groupid = _ancestors[_ancestors.length - 1].GroupID || "";
- }
- //调用上传处理
- U.MD.UI.upload(
- "http://disk.1473.cn/USUpfile.ashx?typename=UploadFlashfile&DirectoryId=" + _directoryid + "&Encrypt=" + _groupid + "&UserId=" + US.userInfo.UserId + "&IsF=true", //上传的地址
- //上传成功的回调函数
- function (r, fileinfo) {
- var _data = r.data //获取服务器返回值
- ; //根据文件的唯一识别id获取文件的信息
- //获取从服务器获取的值,这里加一个错误处理,因为如果后台出现了错误,那么eval的过程就会失败
- try {
- _data = eval("0," + _data);
- }
- catch (e) { }
- //文件上传成功
- if (_data) {
- U.MD.DK.C.success({
- "UserFilesServerName": _data[0], //上传成功后存在fs.1473.cn的地址
- "UseFilesServerThumbnailName": _data[1], //如果是图片上传,那么这里有缩略图的地址
- "UserFilesID": _data[2], //文件在数据的id
- "size": _data[3], //文件的大小
- "UserDirectoryEncrypt": _data[4], //文件的加密情况,这里和分组id是一样的
- "UserDirectoryID": _data[5], //文件归属的目录id
- "UserDirectoryName": fileinfo.name
- }, _dirinfo, diskinfo);
- }
- },
- //得到md5的回调函数
- function (md5, fileinfo, cb) {
- //根据用户的md5值判断用户是否需要上传,如果需要上传则需要执行上传处理,如果已经存在后台直接给用户生成文件路径等录入数据库
- U.A.Request(US.DISK, ["IfFileExistInsertDB", US.userInfo.UserId, _directoryid, _groupid, fileinfo.size, md5, U.UF.UP.getFileNameAndExtension(fileinfo.name)[1], fileinfo.name],
- //判断上传文件是否存在
- function (r) {
- var _userid = US.userInfo.UserId; //当前登录用户的id
- r = r.value;
- //获取服务器返回的值,如果服务器响应出问题了,eval的时候就会报错。
- try {
- r = eval(r)[0];
- }
- catch (e) { }
- //当用户想上传的文件已经在数据库里存在了,那么后台会执行复制数据的操作。
- if (r) {
- U.MD.DK.C.success({
- "UserFilesServerName": r.UserFilesServerName, //上传成功后存在fs.1473.cn的地址
- "UseFilesServerThumbnailName": r.UserDirectoryUrl, //如果是图片上传,那么这里有缩略图的地址
- "UserFilesID": r.UserDirectoryID, //文件在数据的id
- "size": r.UserDirectorySize, //文件的大小
- "UserDirectoryEncrypt": r.UserDirectoryEncrypt, //文件的加密情况,这里和分组id是一样的
- "UserDirectoryID": r.UserDirectoryParentID, //文件归属的目录id
- "UserDirectoryName": r.UserDirectoryName
- }, _dirinfo, diskinfo);
- cb(false);
- }
- //否则调用flash里面的函数执行用户的上传操作。
- else {
- cb(true);
- }
- });
- });
- }
- }
- /**
- * 上传成功直接添加
- * @param {object} 获取服务器返回值
- * @param {string} 上传文件的唯一识别id
- */
- U.MD.DK.C.success = function (uploadinfo, dirinfo, diskinfo) {
- var _userinfo = US.userInfo, //上传用户的信息
- _extendtype = U.UF.UP.getFileNameAndExtension(uploadinfo.UserDirectoryName)[1], //上传文件的后缀名
- _img = uploadinfo.UseFilesServerThumbnailName, //上传文件展示到网盘的图片
- _groupid = uploadinfo.GroupID,
- //上传文件成功后,由前端的数据结构生成一个数据实体,实际传参请参考函数里面的数据结构
- _fileinfo = new U.MD.DK.M.entity(
- uploadinfo.UserFilesID, //上传文件的id
- uploadinfo.size, //上传文件的大小
- uploadinfo.UserDirectoryID, //上传文件对应的目录id
- uploadinfo.UserDirectoryName.addEllipsis(20), //上传文件的简写名
- uploadinfo.UserDirectoryName, //上传文件的名字
- _extendtype, //上传文件的后缀
- uploadinfo.UserFilesServerName, //上传文件的服务器地址
- U.UF.D.toTimeStamp(new Date()), //上传文件成功的时间
- _img ? _img : U.MD.DK.C.getIcon(_extendtype)[1], //上传文件展示到网盘的图片
- 9999, //上传文件的层次,这里文件是没有层次的,所以以9999区表达
- null, //文件的修改时间
- uploadinfo.UserDirectoryEncrypt, //上传文件的加密或者是限制
- 1, //标识该文件在网盘中识别为文件
- "", //上传文件的描述
- _groupid, //归属的群id
- "", //uw office内容
- _userinfo.UserId, //归属用户的id
- _userinfo.UserNickName, //归属用户的名字
- _userinfo.UserName, //归属用户的用户名
- _userinfo.UserThumbnailImageHead //归属用户的头像
- );
- //如果是上传到网盘的处理
- if (_fileinfo) {
- U.MD.DK.RE.addFileOrFolder([_fileinfo], diskinfo, dirinfo); //添加值
- diskinfo && U.Alert("文件: " + _fileinfo.UserDirectoryName + " 已上传至" + dirinfo.UserallDirectoryName + "目录下");
- }
- return _fileinfo;
- }
- /**
- * 拖动选择多个元素的处理
- * @param {element} 拖动的区域元素
- */
- U.MD.DK.C.selectElement = function (el, diskinfo) {
- var i, classname, hoverclass,
- _viewtype = diskinfo.viewtype || "Normal",
- _child = U.selectEl(el).Child(),
- _fileinfo = U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": diskinfo.directoryid })[0];
- diskinfo.selectElement = []; //清空所有的选择元素
- //如果是在他人邀请 最新文档 我的协同里 则没有拖选按钮
- if (_fileinfo && _fileinfo.GroupID !== true) {
- //普通视图的处理
- if (_viewtype == "Normal") {
- classname = "U_MD_DK_RZO";
- hoverclass = "U_MD_DK_RZO U_MD_DK_RZOI";
- }
- //详细视图的处理
- else {
- classname = "U_MD_DK_RZS U_MD_DK_RZXO";
- hoverclass = "U_MD_DK_RZS U_MD_DK_RZXO U_MD_DK_RZXOO";
- }
- //如果不是空文件状态下的处理
- if (_child[0].className != "U_MD_DK_RZF") {
- //点击的时候循环清空所有元素选择状态
- for (i = 0; i < _child.length; i++) {
- //如果元素状态是选中状态的处理
- if (_child[i].className == hoverclass) {
- _child[i].className = classname;
- }
- }
- //拖动选择处理
- U.UF.F.dragSelect(el, function (arr) {
- var i,
- _isclass;
- //循环元素的处理
- for (i = 0; i < _child.length; i++) {
- _isclass = arr.indexOf(_child[i]);
- //判断元素是否
- if (_isclass == -1 && _child[i].className == hoverclass) {
- _child[i].className = classname;
- }
- //判断
- else if (_isclass > -1) {
- _child[i].className = hoverclass;
- }
- }
- diskinfo.selectElement = arr; //得到所有的选择元素
- });
- }
- }
- };
- ///<jscompress sourcefile="DiskData.js" />
- Namespace.register("U.MD.DK.M"); //Disk树操作
- //disk变量使用区域
- //硬盘里面复制粘贴的全局变量。,暂未整理。
- //US.disk.DiskDaren = {};
- //包含了当前所有用户的硬盘目录文件等数据的信息.
- US.disk.Disks = {};
- //当前操作用户的网盘数据,相当于US.disk.Disks[userid]。
- US.disk.UserDisk = null;
- // US.disk.Disks 用户网盘数据前台存储的全局变量 该全局变量为一个数组
- // US.disk.Disks[userid].directoryOrFiles 0为该userid用户下面的所有网盘目录及文件的数据信息。以数组形式展示
- // US.disk.Disks[userid].userInfo 用户信息,包含了用户在网盘的信息
- // US.disk.Disks[userid].directoryid 1为当前打开目录的id
- // US.disk.Disks[userid].currentDirectoryFile 当前打开目录下面所有的文件和文件夹
- // US.disk.Disks[userid].formel formel为当前网盘用户的弹框,这个是唯一的。
- // US.disk.Disks[userid].operator 使用该用户网盘的用户id,为登录用户的id或者是全0的guid
- //例:US.disk.Disks["张三"]; //张三的网盘信息,张三需要用guid表示,US.disk.Disks["95f7bacc-0b3a-4265-a2ea-15e066b97bf7"]
- //例:US.disk.Disks["李四"]; //李四的网盘信息,李四需要用guid表示。US.disk.Disks["f6d7a4b6-e34c-4964-beed-24187b2cb1ba"]
- //
- //disk文件和文件夹实体,US.disk.Disks里面的内容的数据结构。
- U.MD.DK.M.entity = function (directoryid, size, parentid, shortname, name, extendtype, serverurl, addtime, iconurl, deep, modifytime, encryt, filetype, descript, groupid, officevalue, userid, usernickname, username, imagehead) {
- this.UserDirectoryID = directoryid; //文件id或者目录id
- this.UserDirectorySize = size; //文件大小。
- this.UserDirectoryParentID = parentid; //父亲id
- this.UserDirectoryName = shortname; //文件名或者文件夹名,
- this.UserallDirectoryName = name; //文件名或者文件夹名,会删除不要
- this.UserDirectoryExtendType = extendtype; //文件扩展名,目录扩展名为folder,加密的目录也有一个标识。
- this.UserFilesServerName = serverurl; //文件服务器链接地址,需要统一加US.FILESYSTEMURL + filesinfo.UserDirectoryUrl
- this.UserDirectoryAddTime = addtime; //文件或者文件夹添加时间
- this.UserDirectoryUrl = iconurl; //文件服务器链接地址,缩略图,需要统一加US.FILESYSTEMURL + filesinfo.UserDirectoryUrl
- this.UserDirectoryDeep = deep; //文件夹深度
- this.UserDirectoryModifyTime = modifytime; //文件或者文件夹修改时间
- this.UserDirectoryEncrypt = encryt; //文件夹加密
- this.filetype = filetype; //文件类型,文件夹为1,文件为0
- this.Descript = descript; //文件描述。例如图片,声音,视频的描述
- this.GroupID = groupid; //群id,用于群文件
- this.UsOffice = officevalue; //文件内容。
- this.UserId = userid; //文件或者文件夹所属用户id
- this.UserNickName = usernickname; //文件或者文件夹所属用户昵称
- this.UserName = username; //文件或者文件夹所属用户账号
- this.UserThumbnailImageHead = imagehead; //文件或者文件夹所属用户头像
- this.Child = null; //文件夹中的子文件夹数组。
- this.Parent = null; //文件或者文件夹的父亲
- }
- //初始化一级目录的全局变量。即左边树目录结构。
- US.disk.initTree = [
- [Guid.newGuid(), 0, US.MYDISK, "最新文档", "最新文档", "folder", null, null, null, 0, null, null, 0, "", true],
- [Guid.newGuid(), 0, US.MYDISK, "我的协同", "我的协同", "folder", null, null, null, 0, null, null, 0, "", true],
- [Guid.newGuid(), 0, US.MYDISK, "他人邀请", "他人邀请", "folder", null, null, null, 0, null, null, 0, "", true],
- [US.MYFOLDERID, 0, US.MYDISK, "电脑", "我的文档(私密)", "folder", null, null, null, 0, null, null, 0, ""],
- [US.FTPFOLDERID, 0, US.MYDISK, "ftp", "共享文档", "folder", null, null, null, 0, null, null, 0, "", ""]
- ];
- // [US.VIDEOFOLDERID, 0, US.MYDISK, "视频", "在线视频", "folder", null, null, null, 1, null, null, 0, ""],
- // [US.IMAGEFOLDERID, 0, US.MYDISK, "相册", "图片、相册", "folder", null, null, null, 1, null, null, 0, ""],
- // [US.MUSICEFOLDERID, 0, US.MYDISK, "音乐", "音乐收听", "folder", null, null, null, 1, null, null, 0, ""]
- //文件类型全局变量。
- US.disk.fileType = {
- "image": ["jpg", "gif", "png", "bmp", "jpeg", "JPG", "GIF", "BMP", "PNG", "JPEG"],
- "music": ["mp3"],
- "video": ["wmv", "video", "ogg", "webm", "mp4"],
- "usword": ["uw"],
- "word": ["doc", "docx"],
- "usnav": ["un"],
- "usexcel": ["ue"],
- "text": ["rtf", "mht", "txt", "htm", "html", "wsh", "wsf", "cpp", "c", "css", "txt", "php", "cs", "java", "log", "sql", "jsp"]
- }
- //全局变量,应用程序类型,包含了应用扩展名,id,中文描述,图标的css名。
- US.disk.applicationTypes = {
- "image": {
- //图片类型的后缀
- "types": US.disk.fileType.image,
- //该格式对应在网盘的目录id
- "directoryid": US.IMAGEFOLDERID,
- //格式对应的名字
- "name": "图片",
- //格式对应的样式
- "classname": ["U_MD_UI_UP_COIT"]
- },
- "music": {
- //音乐类型的后缀
- "types": US.disk.fileType.music,
- //该格式对应在网盘的目录id
- "directoryid": US.MUSICEFOLDERID,
- //格式对应的名字
- "name": "音乐",
- //格式对应的样式
- "classname": ["U_MD_UI_UP_COIY", "U_MD_DK_RZOY", "U_MD_DK_LCY"]
- },
- "video": {
- //视频类型的后缀
- "types": US.disk.fileType.video,
- //该格式对应在网盘的目录id
- "directoryid": US.VIDEOFOLDERID,
- //格式对应的名字
- "name": "视频",
- //格式对应的样式
- "classname": ["U_MD_UI_UP_COIS", "U_MD_DK_RZOP", "U_MD_DK_LCP"]
- },
- "word": {
- //互联办公word文档格式
- "types": US.disk.fileType.word,
- //该格式对应在网盘的目录id
- "directoryid": US.MYFOLDERID,
- //格式对应的名字
- "name": "Office文档",
- //格式对应的样式
- "classname": ["U_MD_UI_UP_COIW", "U_MD_DK_REODW", "U_MD_DK_LCD"]
- },
- "uw": {
- //互联办公word文档格式
- "types": US.disk.fileType.usword,
- //该格式对应在网盘的目录id
- "directoryid": US.MYFOLDERID,
- //格式对应的名字
- "name": "文档",
- //格式对应的样式
- "classname": ["U_MD_UI_UP_COIW", "U_MD_DK_RZOD", "U_MD_DK_LCD"]
- },
- "un": {
- //互联办公word文档格式
- "types": US.disk.fileType.usnav,
- //该格式对应在网盘的目录id
- "directoryid": US.MYFOLDERID,
- //格式对应的名字
- "name": "建站文档",
- //格式对应的样式
- "classname": ["U_MD_UI_UP_COIW", "U_MD_DK_REODN", "U_MD_DK_LCD"]
- },
- "ue": {
- //互联办公Excel文档格式
- //视频类型的后缀
- "types": US.disk.fileType.usexcel,
- //该格式对应在网盘的目录id
- "directoryid": US.EMPTYGUID,
- //格式对应的名字
- "name": "文档",
- //格式对应的样式
- "classname": ["U_MD_UI_UP_COIE", "U_MD_DK_RZOE", "U_MD_DK_LCE"]
- },
- "text": {
- //可以通过记事本打开的文件格式
- "types": US.disk.fileType.text,
- //该格式对应在网盘的目录id
- "directoryid": US.EMPTYGUID,
- //格式对应的名字
- "name": "文件",
- //格式对应的样式
- "classname": ["U_MD_UI_UP_COIT", "downel_content_a_r", "U_MD_DK_LCB"]
- },
- "folder": {
- //文件夹处理,一种是加密文件夹,一种是不加密
- "types": ["folder", "folderencrypt"],
- //该格式对应在网盘的目录id
- "directoryid": US.EMPTYGUID,
- //格式对应的名字
- "name": "文件夹",
- //格式对应的样式
- "classname": ["", "U_MD_DK_RZOW", "U_MD_DK_LCW"]
- },
- "group": {
- //文件夹处理,一种是加密文件夹,一种是不加密
- "types": ["group"],
- //该格式对应在网盘的目录id
- "directoryid": US.EMPTYGUID,
- //格式对应的名字
- "name": "群",
- //格式对应的样式
- "classname": ["", "U_MD_DK_RZOG", "U_MD_DK_LCW"]
- },
- "unknownfile": {
- //无法用应用打开的文件类型
- "types": [],
- //该格式对应在网盘的目录id
- "directoryid": US.MYFOLDERID,
- //格式对应的名字
- "name": "文件",
- //格式对应的样式
- "classname": ["U_MD_UI_UP_COIT", "downel_content_a_r", "U_MD_DK_LCB"]
- }
- }
- /**
- * 循环添加文件到全局树里
- * @param {array} 文件数组
- * @param {object} 网盘全局信息
- * @param {object} 添加文件是否具有群id
- */
- U.MD.DK.M.entity.add = function (filesinfo, diskinfo, isgroup) {
- var i;
- for (i = 0; i < filesinfo.length; i++) {
- //如果是新建群文件,则通过放在前面,这样的话查询方便
- if (isgroup) {
- diskinfo.directoryOrFiles.splice(5, 0, filesinfo[i]);
- }
- //普通文件添加处理
- else {
- diskinfo.directoryOrFiles.push(filesinfo[i]);
- }
- }
- }
- /**
- * 循环添加文件到全局树里
- * @param {array} 文件数组
- * @param {object} 制定的文件夹的信息
- */
- U.MD.DK.M.entity.addChild = function (filesinfo, dirinfo) {
- //在指定的目录下的文件添子文件或者文件夹
- if (!dirinfo.Child) { //如果有子目录那么就直接添加
- dirinfo.Child = [];
- }
- //循环文件处理
- for (var i = 0; i < filesinfo.length; i++) {
- dirinfo.Child.push(filesinfo[i]);
- filesinfo[i].Parent = dirinfo;
- }
- }
- /**
- * 循环添加文件到全局树里
- * @param {array} 文件数组
- * @param {object} 制定文件夹的信息
- * @param {object} 添加文件是否具有群id
- */
- U.MD.DK.M.entity.del = function (filesinfo, diskinfo) {
- var i,
- j,
- _parent,
- // _delfilesize = 0, //删除的文件大小
- // _delfilenum = 0, //删除的文件数量
- _diskfileanddir = diskinfo.directoryOrFiles //网盘
- ;
- //文件信息
- for (i = 0; i < filesinfo.length; i++) {
- //网盘所有的文件信息
- for (j = 0; j < _diskfileanddir.length; j++) {
- //找到指定需要删除的文件
- if (_diskfileanddir[j].UserDirectoryID == filesinfo[i].UserDirectoryID) {
- _diskfileanddir.splice(j, 1); //在disk里面删除文件或者文件夹
- break;
- }
- }
- _parent = filesinfo[i].Parent; //获取移除目录的上级目录
- //循环移除子元素
- for (j = 0; j < _parent.Child.length; j++) {
- //找到指定需要删除的文件
- if (_parent.Child[j].UserDirectoryID == filesinfo[i].UserDirectoryID) {
- _parent.Child.splice(j, 1); //在disk里面删除文件或者文件夹
- }
- }
- }
- }
- /**
- * 递归修改所有的子目录文件的Id
- * @param {array} 文件数组
- * @param {object} 修改的属性 例:{groupid:a} //修改所有的群id
- */
- U.MD.DK.M.recursionUpdateDirectory = function (filesinfo, attribute) {
- //循环所有的文件修改
- for (i = 0; i < filesinfo.length; i++) {
- //修改文件的属性
- U.UF.C.AddObj(filesinfo[i], attribute);
- //如果文件是文件夹,那么查找自己节点元素,不断的递归修改
- if (!filesinfo[i].fileType && filesinfo[i].Child) {
- //递归修改
- U.MD.DK.M.recursionUpdateDirectory(filesinfo[i].Child, attribute);
- }
- }
- }
- /**
- * 用户操作切换,可以查看多个用户的硬盘,所以需要切换。登录用户和非登录用户有不同权限。
- * @param {string} 用户id
- * @param {string} 用户名
- * @return {object} 用户在网盘的全局变量。
- */
- U.MD.DK.M.diskOperatingSwitch = function (userid, username) {
- userid = userid || US.userInfo.UserId; //如果有用户id,则userid为用户id,否则为登录用户id。
- if (userid) {
- var i, _userinfo, //需要返回的用户网盘信息
- _diskinfo = US.disk.Disks; //_UCE为包含了所有用户硬盘信息的集合。
- if (_diskinfo && !_diskinfo[userid]) { //判断用户的网盘信息是否可以通过userid找到
- for (i in _diskinfo) { //循环网盘信息
- if (_diskinfo[i] && _diskinfo[i][1] && _diskinfo[i][1][0] && _diskinfo[i][1][0].UserName == username) { //这里也会有null情况,因为这个变量的定义在U.A.Request之前,所以可能会存在还没有获取数据就在此进入这个函数的情况
- userid = _diskinfo[i][1][0].UserId;
- }
- }
- }
- US.disk.UserDisk = _diskinfo[userid]; //设置当前使用的网盘用户的信息为得到的用户id
- return _diskinfo[userid];
- }
- }
- /**
- * 通过用户名搜索用户网盘信息
- * @param {string} 用户名
- * @return {object} 用户在网盘的全局变量。
- */
- U.MD.DK.getUserDiskByName = function (username) {
- var i,
- _userdisk, //获取的用户硬盘信息
- _diskinfo = US.disk.Disks; //存储打开用户的网盘的信息
- for (i in _diskinfo) { //循环获取
- _userdisk = _diskinfo[i][1]; //查看用户网盘信息
- if (_userdisk && _userdisk[0].UserName == username) { //判断网盘信息的用户名是否等于传入的用户名
- return _userdisk[0];
- }
- }
- return {};
- }
- ;
- ///<jscompress sourcefile="DiskHome.js" />
- ;
- ///<jscompress sourcefile="DiskSearch.js" />
- //---------------------------------------------------------------------------网络硬盘搜索------------------------------------------------------------------------------
- Namespace.register("U.MD.DK.S"); //Disk搜索的命名空间
- //#region 本地搜索
- /**
- * 自己的网盘搜索
- *
- * @param {element} 输入的元素
- * @param {element} 输入的元素
- **/
- U.MD.DK.S.search = function (inputel, diskinfo) {
- var _value = inputel.value, //搜索框内容
- _diskinfo = diskinfo || US.disk.UserDisk, //网盘信息
- _searchfileordir = []; //搜索文件或目录
- if (_value == "") {//如果没有搜索内容
- _searchfileordir = _diskinfo.currentDirectoryFile; //显示当前所有文件
- }
- else {
- for (var i = 0; i < _diskinfo.directoryOrFiles.length; i++) {//模糊搜索
- if (_diskinfo.directoryOrFiles[i].UserallDirectoryName.indexOf(_value) >= 0) {//如果文件夹名包含搜索框的内容
- _searchfileordir.push(_diskinfo.directoryOrFiles[i]); //则显示到网盘中
- }
- }
- }
- //以后做新窗口弹出。
- _content = U.selectEl("#U_MD_DK_RZ", _diskinfo.formel)[0]; //用户的网盘打印内容
- _content.innerText = "";
- U.selectEl(".U_MD_DK_RKR")[1].innerHTML = "当前文件的数量:" + (_searchfileordir.length); //当前文件的数量
- U.MD.DK.VW.printContent(_searchfileordir, _content); //打印搜索的结果。
- }
- //#endregion
- ;
- ///<jscompress sourcefile="DiskView.js" />
- Namespace.register("U.MD.DK.VW"); //Disk视图操作命名空间
- //#region 追随设置
- /* 跟新追随信息
- *
- * @param diskel {element} 网盘窗体元素
- * @param userid {string} 用户id
- **/
- U.MD.DK.VW.followState = function (diskel, userid) {
- var _followbutton = U.selectEl(".U_MD_DK_LIRS", diskel);
- _followbutton.attr("user", userid);
- if (userid == US.userInfo.UserId) {
- _followbutton[0].innerHTML = "本人";
- }
- else if (US.friend.friends && U.Json.select(US.friend.friends, { UserId: userid })[0]) {
- _followbutton[0].innerHTML = "已追随";
- _followbutton.addClass("U_MD_DK_LIRSED");
- } else {
- _followbutton[0].innerHTML = "追随";
- _followbutton.removeClass("U_MD_DK_LIRSED");
- }
- }
- /* 追随按钮点击事件
- *
- **/
- U.MD.DK.VW.followState.click = function (button) {
- var _userid = U.selectEl(button).attr("user");
- var _userinfo;
- if (_userid == US.userInfo.UserId) {
- return;
- } else if (US.friend.friends && (_userinfo = U.Json.select(US.friend.friends, { UserId: _userid })[0])) {
- U.MD.F.M.deleteFriend(_userinfo, function () {
- button.innerHTML = "追随";
- U.selectEl(button).removeClass("U_MD_DK_LIRSED");
- });
- } else {
- U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserId", _userid], function (r) {//根据用户名获取用户信息
- if (r.value && r.value[0]) {
- U.MD.F.M.addFriend(r.value[0], function () {
- button.innerHTML = "已追随";
- U.selectEl(button).addClass("U_MD_DK_LIRSED");
- });
- } else {
- U.Alert("用户信息有误,请稍后尝试...");
- }
- });
- }
- }
- //#endregin
- //#region 目录文件打印
- /**
- * 打印网盘视图输出判断的地方 分为普通视图输出和详细视图输出
- * @param {array} 需要输出的文件或者文件夹信息
- * @param {element} 输出到那个区域
- **/
- U.MD.DK.VW.viewsSwitch = function (viewtype, diskinfo) {
- var _contentel = U.selectEl("#U_MD_DK_RZ", diskinfo.formel)[0], //内容元素
- _viewnav = U.selectEl(_contentel).prev()[0] //导航元素
- ;
- diskinfo.viewtype = _contentel.viewtype = viewtype; //视图
- if (diskinfo.currentDirectoryFile.length) {
- _contentel.innerHTML = ""; //先清空处理
- U.MD.DK.VW.printContent(diskinfo.currentDirectoryFile, _contentel); //打印内容
- //这里是普通视图处理
- if (viewtype == "Normal") {
- _contentel.style.width = ""; //普通视图不修改大小
- _viewnav.style.display = "none";
- _contentel.style.height = U.selectEl(_contentel).Parent(2).offsetHeight - 79 + "px"
- }
- //详细视图处理
- else {
- U.MD.DK.VW.size(diskinfo); //详细视图的时候需要设置大小和样式,这里统一处理
- }
- }
- }
- /**
- * 根据时间排序
- * @param {object} 用户网盘信息
- **/
- U.MD.DK.VW.SortView = function (diskinfo, type, cb) {
- var _filesinfo = diskinfo.currentDirectoryFile, //用户展示在改文件夹下所有的文件
- _contentel = U.selectEl("#U_MD_DK_RZ", diskinfo.formel)[0]
- ;
- //判断文件是否存在,如果有打印文件,那么就进行文件的打印,否则不做任何处理
- if (_filesinfo.length) {
- //判断头两个文件的创建时间,进行排序处理
- if (_filesinfo[0].UserDirectoryAddTime > _filesinfo[1].UserDirectoryAddTime) {
- //文件降序处理
- U.UF.Math.sequence(_filesinfo, type, cb, 1);
- } else {
- //文件升序处理
- U.UF.Math.sequence(_filesinfo, type, cb, -1);
- }
- //重新打印内容
- _contentel.innerHTML = "";
- U.MD.DK.VW.printContent(_filesinfo, _contentel); //打印
- }
- }
- /**
- * 打印网盘视图输出判断的地方 分为普通视图输出和详细视图输出
- * @param {array} 需要输出的文件或者文件夹信息
- * @param {element} 输出到那个区域
- **/
- U.MD.DK.VW.printContent = function (filesinfo, el) {
- var _diskinfo = US.disk.UserDisk, //用户网盘的数据
- _viewtype = el.viewtype || "Normal", //打印的格式
- _viewnav = U.selectEl(el).prev()[0] //视图导航
- ;
- //判断是否有需要输出的文件信息
- if (filesinfo.length) {
- //打印的模式 这里是普通视图输出
- if (_viewtype == "Normal") {
- U.MD.DK.VW.printNormalView(filesinfo, el); //输出
- }
- //详细视图输出
- else {
- U.MD.DK.VW.printDetailedView(filesinfo, el); //详细视图输出
- }
- }
- //如果还有输出的信息在div上面那么不输出空文件的提示
- else if (!$(el).Child().length) {
- U.MD.DK.VW.printNullView(el); //没有文件的时候样式输出
- }
- }
- /**
- * 空文件提示信息输出
- * @param {element} 输出到那个区域
- **/
- U.MD.DK.VW.printNullView = function (el) {
- var _viewel,
- _infoel,
- _promptel,
- _viewel = $$("div", { "className": "U_MD_DK_RZF" }, el);
- _infoel = $$("div", { "className": "U_MD_DK_RZFS" }, _viewel);
- $$("div", { "className": "U_MD_DK_RZTSL U_MD_DK_RZFSL", "innerHTML": "!" }, _infoel);
- _promptel = $$("div", { "className": "U_MD_DK_RZFSR" }, _infoel);
- //提示信息
- _infoel = $$("div", { "className": "U_MD_DK_RZFSRS" }, _promptel);
- $$("div", { "className": "U_MD_DK_RZFSRS", "innerHTML": "这地方暂时" }, _infoel);
- $$("div", { "className": "U_MD_DK_RZFSRS", "innerHTML": " 没有资源哦。" }, _infoel);
- $$("div", { "className": "U_MD_DK_RZTSRX U_MD_DK_RZFSRX", "innerHTML": "Nothing!!" }, _promptel);
- }
- /**
- * 普通视图打印
- * @param {array} 需要输出的文件或者文件夹信息
- * @param {element} 输出到那个区域
- **/
- U.MD.DK.VW.printNormalView = function (filesinfo, el) {
- //变量定义区域
- var i, //用于循环
- _isencryp, //判断文件夹是否加密处理
- _date, //文件当前使用时间
- _icon, //获取文件的icon样式,包含多种
- _imgicon, //打印给用户看到的文件类型对应的图标的样式,上面的是
- _iconel, //图标元素
- _imgeel, //输入给用户看到的元素
- _infoel, //信息输出元素
- _userimg, //用户头像
- _frag = $$("frag"), //临时panel
- _diskinfo = US.disk.UserDisk, //用户网盘信息
- _userid = _diskinfo.userInfo.UserId //当前使用用户的id
- ;
- //逻辑输出区域
- for (i = 0; i < filesinfo.length; i++) {
- //获取文件的信息
- _isencryp = (filesinfo[i]["UserDirectoryEncrypt"] && filesinfo[i]["UserDirectoryEncrypt"] != _userid); //判断文件夹是否是加密属性
- _date = U.UF.D.formatDateToArray(filesinfo[i]["UserDirectoryAddTime"], "Array"); //获取文件的创建时间数组 返回值包含 [年, 月, 日]
- //判断是否为协同群文件
- if (U.MD.DK.VW.collaborativeFileJudgment(filesinfo[i]) == true && filesinfo[i].UserDirectoryExtendType == "folder" && filesinfo[i].Parent.UserDirectoryName == "我的协同" || U.MD.DK.VW.collaborativeFileJudgment(filesinfo[i]) == true && filesinfo[i].UserDirectoryExtendType == "folder" && filesinfo[i].Parent.UserDirectoryName == "他人邀请") {
- filesinfo[i].UserDirectoryExtendType = "group";
- }
- _icon = U.MD.DK.C.getIcon(filesinfo[i].UserDirectoryExtendType); //根据文件扩展名,得到图标的样式
- //创建一个文件夹图标或者文件图标。
- _viewel = $$("div", {
- "title": filesinfo[i]["UserallDirectoryName"],
- "className": "U_MD_DK_RZO",
- "id": "R" + (filesinfo[i].UserDirectoryID),
- "onmousedown": function () {
- var _isindex = _diskinfo.selectElement.indexOf(this); //元素是否在多选元素的位置
- if (_isindex > -1) {
- U.UF.EV.stopBubble(); //onmousedown设置阻止冒泡
- }
- },
- "oncontextmenu": U.UF.C.closure(function (fileinfo) {
- U.UF.EV.stopBubble();
- U.UF.EV.stopDefault();
- U.MD.DK.RM.rightMenu(this, fileinfo, US.disk.UserDisk); //右键菜单
- }, [filesinfo[i]])
- }, _frag);
- //设置点击事件
- if (filesinfo[i].filetype == "1") { //普通文件的处理
- _viewel.onclick = U.UF.C.closure(function (fileinfo) {
- U.MD.DK.LE.openFileDirectory(fileinfo, _userid);
- }, [filesinfo[i]]);
- }
- else { //文件夹的处理,文件夹的处理这里加一个前进后退的添加
- _viewel.onclick = U.UF.C.closure(function (fileinfo) {
- U.MD.DK.LE.openFileDirectory(fileinfo, _userid);
- }, [filesinfo[i]]);
- }
- //图标处理
- _imgicon = "";
- _iconel = $$("div", { "className": "U_MD_DK_RZOA" }, _viewel);
- //文件夹处理
- if (filesinfo[i].filetype != 1) {
- //加密的处理
- if (_isencryp) {
- _imgicon = "U_MD_DK_Img U_MD_DK_RZOM";
- }
- //未加密的处理
- else {
- _imgicon = _icon.classname[1] ? "U_MD_DK_Img " + _icon.classname[1] : "U_MD_DK_Img U_MD_DK_RZOW";
- }
- }
- //根据上面根据类型获取的图标输出图标样式
- else if (_icon.classname[1]) {
- _imgicon = "U_MD_DK_Img " + _icon.classname[1];
- }
- _imgeel = $$("div", { "className": "U_MD_DK_RZOS " + _imgicon }, _iconel);
- //如果图标是空图标,给空图标写入后缀名
- if (_icon.name == "文件") {
- $$("div", { "className": "U_MD_DK_RZOSZ", "innerHTML": filesinfo[i].UserDirectoryExtendType || "" }, _imgeel);
- }
- else if (!_icon.classname[1]) {
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": function () {
- U.MD.C.imgError(this, 1);
- },
- "title": "点击查看",
- "src": U.MD.C.getHeadImage(filesinfo[i].UserDirectoryUrl)
- }, _imgeel);
- }
- //目录名输出
- _infoel = $$("div", { "className": "U_MD_DK_RZOZO" }, _iconel);
- $$("div", { "className": "U_MD_DK_RZOZ", "innerHTML": filesinfo[i]["UserallDirectoryName"] }, _infoel);
- //大小
- _infoel = $$("div", { "className": "U_MD_DK_RZOFXJ U_MD_D_Text_Abbreviation" }, _infoel);
- $$("span", { "className": "U_MD_DK_RZOFXJO", "innerHTML": _date[0] + "-" + _date[1] + "-" + _date[2] }, _infoel);
- if (filesinfo[i].filetype != 0) {
- $$("span", { "className": "U_MD_DK_RZOFXJT", "innerHTML": U.UF.UP.minUnitToMaxUnit(filesinfo[i]["UserDirectorySize"]) }, _infoel);
- }
- //线面输入文件归属用户的信息 头像和名字
- _infoel = $$("div", { "className": "U_MD_DK_RZOF" }, _viewel);
- _infoel = $$("div", { "className": "U_MD_DK_RZOFD" }, _infoel);
- _userimg = $$("div", { "className": "U_MD_DK_RZOFDI" }, _infoel);
- //用户头像输出
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": U.MD.C.imgError, "title": "点击查看",
- "src": U.MD.C.getHeadImage(filesinfo[i].UserThumbnailImageHead),
- "onclick": function () {
- U.UF.EV.stopBubble(); U.MD.U.V.ViewOtherUserInfo(filesinfo[i].UserId);
- }
- }, _userimg);
- //归属用户名输出
- $$("div", { "className": "U_MD_DK_RZOFDN U_MD_D_Text_Abbreviation", "innerHTML": filesinfo[i].UserNickName || filesinfo[i]["UserallDirectoryName"] }, _infoel);
- }
- //追加元素
- U.selectEl(el).append(_frag); // , 0, el.firstChild
- }
- /**
- * 详细视图输出
- * @param {array} 需要输出的文件或者文件夹信息
- * @param {element} 输出到那个区域
- **/
- U.MD.DK.VW.printDetailedView = function (filesinfo, el) {
- //变量定义区域
- var i, //用于循环
- _isencryp, //判断文件夹是否加密处理
- _date, //文件当前使用时间
- _icon, //获取文件的icon样式,包含多种
- _iconandnameel, //图标和名字展示的区域
- _ischecked = false, //判断文件是否给选中
- _userimg, //用户头像
- _frag = $$("frag"), //临时panel
- _userid = US.disk.UserDisk.userInfo.UserId //当前使用用户的id
- ;
- //逻辑输出区域
- for (i = 0; i < filesinfo.length; i++) {
- //获取文件的信息
- _isencryp = (filesinfo[i]["UserDirectoryEncrypt"] && filesinfo[i]["UserDirectoryEncrypt"] != _userid); //判断文件夹是否是加密属性
- _date = U.UF.D.formatDateToArray(filesinfo[i]["UserDirectoryAddTime"]); //获取文件的创建时间数组 返回值包含 [年, 月, 日]
- _icon = U.MD.DK.C.getIcon(filesinfo[i].UserDirectoryExtendType); //根据文件扩展名,得到图标的样式
- //创建一个文件夹图标或者文件图标。
- _viewel = $$("div", { "title": filesinfo[i]["UserallDirectoryName"], "className": "U_MD_DK_RZS U_MD_DK_RZXO", "id": "R" + (filesinfo[i].UserDirectoryID) }, _frag);
- //设置右键按钮的处理
- _viewel.oncontextmenu = function () {
- U.UF.EV.stopBubble();
- U.MD.DK.RM.rightMenu(_viewel, filesinfo[i], US.disk.UserDisk);
- };
- _viewel.onmousedown = function () {
- var _isindex = _diskinfo.selectElement.indexOf(this); //元素是否在多选元素的位置
- if (_isindex > -1) {
- U.UF.EV.stopBubble(); //onmousedown设置阻止冒泡
- }
- }
- //设置点击事件
- _viewel.onclick = U.UF.C.closure(function (fileinfo) {
- U.MD.DK.LE.openFileDirectory(fileinfo, _userid);
- }, [filesinfo[i]]);
- _iconandnameel = $$("div", { "className": "U_MD_DK_RZSO", "style": { "marginLeft": "0px" } }, _viewel);
- //多选的按钮设置
- $$("input", {
- "className": "U_MD_DK_RZSOI",
- "checked": _ischecked,
- "type": "checkbox",
- "onclick": function () {
- U.UF.EV.stopBubble();
- U.MD.DK.VW.checkFile(this);
- }
- }, _iconandnameel);
- _iconandnameel = $$("div", { "className": "U_MD_DK_RZSM U_MD_D_Text_Abbreviation" }, _viewel);
- //设置图标如果有图标设置图标,没有图标的是图片
- if (_icon.classname[2]) {
- $$("span", { "className": _icon.classname[2] + " U_MD_DK_RZSMI U_MD_DK_Img U_MD_D_Text_Abbreviation", "innerHTML": " " }, _iconandnameel);
- }
- else {
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": function () {
- U.MD.C.imgError(this, 1);
- },
- "title": "点击查看",
- "src": U.MD.C.getHeadImage(filesinfo[i].UserDirectoryUrl || (US.FILESYSTEMURL + filesinfo[i].UseFilesServerThumbnailName))
- }, _iconandnameel);
- }
- //文件名
- $$("span", { "className": "U_MD_DK_RZSMN", "innerHTML": filesinfo[i]["UserallDirectoryName"] }, _iconandnameel);
- //引用次数,暂时没有功能
- $$("div", { "className": "U_MD_DK_RZSF U_MD_DK_RZSFO U_MD_D_Text_Abbreviation", "innerHTML": 0 }, _viewel);
- //归属用户名字
- $$("div", { "className": "U_MD_DK_RZSL U_MD_D_Text_Abbreviation", "innerHTML": filesinfo[i]["UserNickName"] }, _viewel);
- //文件类别名字,如文件夹、图片等等
- $$("div", { "className": "U_MD_DK_RZSX U_MD_D_Text_Abbreviation", "innerHTML": _icon.name }, _viewel);
- //文件大小
- $$("div", { "className": "U_MD_DK_RZSD U_MD_D_Text_Abbreviation", "innerHTML": U.UF.UP.minUnitToMaxUnit(filesinfo[i]["UserDirectorySize"]) }, _viewel);
- //时间
- $$("div", { "className": "U_MD_DK_RZST U_MD_D_Text_Abbreviation", "innerHTML": _date[0] + "-" + _date[1] + "-" + _date[2] + " " + _date[3] + ":" + _date[4] }, _viewel);
- }
- //追加元素
- el.appendChild(_frag);
- }
- /**
- * 判断文件是否为群文件
- * @param {array} 文件夹信息
- **/
- U.MD.DK.VW.collaborativeFileJudgment = function (filesinfo) {
- if (filesinfo.Parent != null) {//判断文件是否为最高及,如果不是
- return U.MD.DK.VW.collaborativeFileJudgment(filesinfo.Parent); //获取它的高级,进行自循环
- }
- if (filesinfo.GroupID == true && filesinfo.UserDirectoryName == "我的协同" || filesinfo.GroupID == true && filesinfo.UserDirectoryName == "他人邀请") {//判断文件是否为我的协同或他人邀请,如果是
- return true; //返回true
- }
- return false; //如果不是,返回false
- }
- /**
- * 详细视图的大小变化使用
- * @param {array} 需要输出的文件或者文件夹信息
- * @param {element} 输出到那个区域
- **/
- U.MD.DK.VW.size = function (diskinfo) {
- var i, j, k, //循环变量
- _childel,
- _size = [0.1, 0.2, 0.1, 0.15, 0.15, 0.15, 0.14], //详细视图每一格的大小
- _contentel = U.selectEl("#U_MD_DK_RZ", diskinfo.formel)[0], //内容元素
- _contentchildel = U.selectEl(_contentel).Child(), //内容的子元素
- _navel = U.selectEl(_contentel).prev()[0], //导航元素
- _navchildel = U.selectEl(_navel).Child(), //导航的子元素
- _width = U.selectEl(_contentel).width(), //获取编辑区域的长度
- _height = U.selectEl(_contentel).height() //获取编辑区域的高度
- ;
- _navel.style.display = "block"; //导航按钮出现
- //视图格式处理,要满足有数据,没有数据不做任何处理
- if (_contentel.viewtype === "Detailed" && diskinfo.currentDirectoryFile.length) {
- for (i = 0; i < _size.length; i++) {
- //导航按钮区域处理
- for (j = 0; j < _navchildel.length; j += 2) {
- _navchildel[j].style.width = _width * _size[j / 2] + "px"; //导航按钮带下处理
- }
- //内容区域处理
- for (j = 0; j < _contentchildel.length; j++) {
- _childel = U.selectEl(_contentchildel).Child();
- for (k = 0; k < _childel.length; k++) {
- _childel[k].style.width = _width * _size[k] + "px"; //内容区域大小处理
- }
- }
- }
- _navel.style.width = _width + "px"; //导航区域设置大小
- _contentel.style.height = _height + "px";
- }
- }
- /**
- * 全选文件
- * @param {element} 输出到那个区域
- * @param {string} 输出到那个区域
- **/
- U.MD.DK.VW.checkAllFile = function (el) {
- var i,
- _ischeck = el.checked, //选择的状态
- _classname = "U_MD_DK_RZS U_MD_DK_RZXO" + (_ischeck ? " U_MD_DK_RZXOO" : ""), //选择或者取消选择的样式
- _contentel = U.selectEl($(el).Parent(2)).next()[0], //内容区域的元素
- _childel = U.selectEl(_contentel).Child() //所有输出的文件或者文件夹
- ;
- for (i = 0; i < _childel.length; i++) {
- _childel[i].className = _classname; //样式处理
- U.selectEl("input", _childel[i])[0].checked = _ischeck; //选中状态
- }
- }
- /**
- * 再详细视图下选择文件
- * @param {element} 输出到那个区域
- * @param {string} 输出到那个区域
- **/
- U.MD.DK.VW.checkFile = function (el) {
- var _ischeck = el.checked; //获取文件是选择还是取消选择
- //选择或者取消选择的处理
- U.selectEl(el).Parent(2).className = "U_MD_DK_RZS U_MD_DK_RZXO" + (_ischeck ? " U_MD_DK_RZXOO" : "");
- }
- //#endregion
- //#region 选择保存位置窗口
- /**
- * 选择文件保存位置窗口打印
- * @param postfix {string} 文件后缀 文件类型
- * @param filename {string} 文件名
- * @param callback {function} 回调函数
- * @param formtitle {string} 窗体名称
- * @param extendtype {string} 显示的文件属性
- **/
- U.MD.DK.VW.chosenSaveFile = function (postfix, fileid, filename, callback, formtitle, extendtype) {
- if (!U.MD.U.L.isLogin()) {//是否登录
- extendtype = extendtype || "folder"; //默认只显示文件夹
- var _diskinfo = US.disk.Disks[US.userInfo.UserId]; //获取当前登录用户的网盘信息
- var _formel = U.selectEl('#U_MD_DK_VW_ChosenSaveFile')[0]; //获取窗体元素
- var _file; //定义变量
- if (_formel) { //判断窗体是否存在
- //存在则居中显示
- U.UF.F.windowTopCenter(_formel);
- //获取文件区域
- _file = U.selectEl('#U_MD_DK_VW_ChosenSaveFile_File')[0];
- _file.innerHTML = "";
- U.selectEl('.U_MD_DK_VW_ChosenSaveFile button', _formel)[1].onclick = function () {
- U.MD.DK.VW.chosenSaveFile.ensure(_formel, U.selectEl('.U_MD_DK_VW_ChosenSaveFile input', _formel)[0], postfix, fileid, callback);
- }
- U.selectEl('.U_MD_DK_VW_ChosenSaveFile input', _formel)[0].value = "";
- }
- else {
- var _box = $$('div', { style: { position: "relative", overflow: "hidden" }, "className": "U_MD_DK_VW_ChosenSaveFile" }); //创建文件区域容器
- var _newfolder = $$('button', { style: { position: "absolute", right: "0", top: "2px" }, innerHTML: "新建文件夹" }, _box); //创建新建文件夹按钮
- $$("div", { style: { "font-size": "16px", padding: "12px 10px 2px" }, innerHTML: "选择文件夹" }, _box); //创建标题
- $$("hr", {}, _box); //创建分割线
- _file = $$("div", { "className": "U_MD_DK_VW_ChosenSaveFile_File", id: "U_MD_DK_VW_ChosenSaveFile_File" }, _box); //创建文件区域
- var _inputarea = $$('div', {}, _box); //创建填写文件名区域
- $$('span', { 'innerHTML': '文件名:' }, _inputarea); //标题
- var _input = $$('input', { placeholder: filename || "请输入文件名...", style: { width: "89%", "text-indent": "5px", "line-height": "26px" } }, _inputarea); //文件名输入框
- var _ensure = $$('button', { innerHTML: "确定" }, _box); //确定按钮
- var _cancel = $$('button', { innerHTML: "取消" }, _box); //取消按钮
- //创建窗体
- _formel = new U.UF.UI.form(
- "<span id='U_MD_DK_VW_ChosenSaveFile_Title'>" + (formtitle || "新建文件") + "</span>",
- _box, {
- "id": "U_MD_DK_VW_ChosenSaveFile",
- "style": {
- "width": "600px",
- "height": "450px"
- }
- }).form;
- //绑定新建文件夹事件
- _newfolder.onclick = function () {
- U.MD.DK.VW.chosenSaveFile.newFolder();
- }
- //绑定确定按钮事件
- _ensure.onclick = function () {
- U.MD.DK.VW.chosenSaveFile.ensure(_formel, _input, postfix, fileid, callback);
- }
- //取消函数
- _cancel.onclick = function () {
- U.UF.F.windowMinimize(_formel);
- }
- }
- //默认创建初始化目录
- U.MD.DK.VW.chosenSaveFile.printFolder(_diskinfo.directoryOrFiles.slice(1, 5), _file, 0, ["U_MD_DK_LCD", "U_MD_DK_LCS", "U_MD_DK_LCD", "U_MD_DK_LCB", "U_MD_DK_LCF", "U_MD_DK_LCT", "U_MD_DK_LCP", "U_MD_DK_LCY"], _file, extendtype);
- }
- }
- /**
- * 答应文件夹函数
- * @param data {array} 数据源
- * @param filearea {Element} 创建文件位置
- * @param deviant {int} 偏移值
- * @param iconclass {array} 文件图标class
- * @param extendtype {string} 显示的文件属性
- **/
- U.MD.DK.VW.chosenSaveFile.printFolder = function (data, filearea, deviant, iconclass, topfilearea, extendtype) {
- extendtype = extendtype || "folder";
- var i, //定义循环变量
- _class; //定义样式记录属性
- for (i = 0; i < data.length; i++) { //循环答应
- _class = null;
- if (extendtype == "*" || extendtype.indexOf(extendtype) > -1) { //判断文件类型为文件夹才打印
- if ((iconclass || "").length) { //判断文件图片class是否有传入
- _class = iconclass[i] || iconclass; //设置样式名
- } else if (data[i].UserDirectoryExtendType == extendtype || extendtype == "*") { //判断其能否显示,是不是想要的文件类型
- switch (data[i].UserDirectoryExtendType) {
- case "folder":
- _class = "U_MD_DK_LCW"; //设置默样式名
- break;
- case "UW": case "txt": case "html": case "uw":
- _class = "U_MD_DK_LCB";
- break;
- case "jpg": case "png":
- _class = "U_MD_DK_LCT";
- break;
- case "mp4":
- _class = "U_MD_DK_LCP";
- break;
- }
- }
- if (_class) { //判断其是否有样式,没有就不打印
- U.MD.DK.VW.chosenSaveFile.Print(data[i], filearea, deviant, _class, topfilearea, extendtype); //调用单个打印函数
- }
- }
- }
- }
- /**
- * 打印文件夹函数
- * @param data {object} 数据源
- * @param filearea {Element} 创建文件位置
- * @param deviant {int} 偏移值
- * @param iconclass {string} 文件图标class
- * @param extendtype {string} 显示的文件属性
- **/
- U.MD.DK.VW.chosenSaveFile.Print = function (data, filearea, deviant, iconclass, topfilearea, extendtype) {
- var _filediv, _fileel, _folder; //设置变量
- _folder = false; //
- if (data.UserDirectoryExtendType == "folder") {//判断文件是否是文件夹
- _folder = true;
- };
- _filediv = $$('div', { "className": "U_MD_DK_VW_ChosenSaveFile_File_Box" }, filearea); //创建单个文件区域
- _fileel = $$('div', {
- id: data["UserDirectoryID"] ? "CS" + data["UserDirectoryID"] : "",
- "className": "U_MD_DK_LTXOS",
- style: { 'padding-left': deviant + 'px' },
- onclick: U.UF.C.closure(function (directoryinfo, el) { //设置点击事件
- var _thisdate = data;
- var _thisfolder = _folder;
- U.UF.EV.stopBubble();
- if (_thisfolder) {//判断点击的是否是文件夹
- //如果是文件夹,就打开文件夹
- U.MD.DK.VW.chosenSaveFile.forderClick(directoryinfo, el, topfilearea, extendtype);
- //并且在选择该文件夹
- if ($('.U_MD_DK_VW_ChosenSaveFileName')[0]) {
- U.selectEl('.U_MD_DK_VW_ChosenSaveFileName')[0].value = data.UserallDirectoryName;
- U.selectEl('.U_MD_DK_VW_ChosenSaveFileName')[0].data = data;
- }
- } else {
- //不是文件夹就选择该文件
- if ($('.U_MD_DK_VW_ChosenSaveFileName')[0]) {
- U.selectEl('.U_MD_DK_VW_ChosenSaveFileName')[0].value = data.UserallDirectoryName;
- U.selectEl('.U_MD_DK_VW_ChosenSaveFileName')[0].data = data;
- }
- }
- }, [data, _filediv])
- }, _filediv); //创建文件
- if (_folder) {
- $$('div', { className: "U_MD_DK_LTXOSI U_MD_DK_Img" }, _fileel); //创建文件角标
- } else {
- $$('div', { className: "U_MD_DK_LTXOSI" }, _fileel); //不创建文件角标
- }
- $$('div', { className: "U_MD_DK_LCOI U_MD_DK_LTXOST U_MD_DK_Img " + iconclass }, _fileel); //创建文件icon
- $$('span', { innerHTML: data.UserallDirectoryName }, _fileel); //创建文件名
- return _filediv; //返回创建的文件元素
- }
- /**
- * 文件夹展开关闭函数
- * @param directoryinfo {object} 文件夹信息
- * @param el {Element} 文件位置
- * @param extendtype {string} 显示的文件属性
- **/
- U.MD.DK.VW.chosenSaveFile.forderClick = function (directoryinfo, el, topfilearea, extendtype) {
- var //_filearea = U.selectEl('.U_MD_DK_VW_ChosenSaveFile_File')[0], //获取文件区域
- _folder = U.selectEl(el).Child()[0], //获取每个文件
- _deviant = parseInt(_folder.style.paddingLeft || 0) + 5; //计算偏移值
- var _icon = U.selectEl('.U_MD_DK_LTXOSI', _folder); //获取角标
- U.selectEl('.U_MD_DK_LTXOSO', topfilearea).removeClass('U_MD_DK_LTXOSO'); //清楚上一个选择的文件背景
- U.selectEl(_folder).addClass('U_MD_DK_LTXOSO'); //设置当前文件背景为选中
- if (_icon.hasClass('U_MD_DK_LTXOSIO')) { //判断文件是否展开
- //已展开
- _icon.removeClass('U_MD_DK_LTXOSIO'); //清楚展开角标样式
- var _nextlevel = U.selectEl(_folder).next(); //判断是否加载了子文件夹
- U.selectEl(_nextlevel).remove(); //删除子文件夹
- } else {
- //未展开
- _icon.addClass('U_MD_DK_LTXOSIO'); //添加角标打开class
- if (directoryinfo.Child) { //判断是否已获取子文件数据
- //已获取
- U.MD.DK.VW.chosenSaveFile.printFolder(directoryinfo.Child, $$('div', {}, el), _deviant, null, null, extendtype); //打印子级文件夹
- } else {
- //未获取则去数据库获取
- U.MD.DK.LE.getChildsByDirectoryId(US.userInfo.UserId, directoryinfo, topfilearea, function () {
- //打印文件夹
- U.MD.DK.VW.chosenSaveFile.printFolder(directoryinfo.Child, $$('div', {}, el), _deviant, null, null, extendtype);
- });
- }
- }
- }
- /**
- * 确定按钮函数
- * @param formel {object} 文件夹信息
- * @param input {Element} 文件名输入框
- * @param postfix {string} 文件后缀名
- * @param callback {function} 回调函数
- **/
- U.MD.DK.VW.chosenSaveFile.ensure = function (formel, input, postfix, fileid, callback) {
- var _name = input.value; //获取文件名
- if (_name.trim() == "") { //判断是否为空
- return U.Alert('请填写文件名!');
- }
- //判断文件名是否符合规范
- if (U.UF.S.ZWFileName.test(_name)) {
- var _nowfile = U.selectEl('.U_MD_DK_LTXOSO', formel)[0]; //获取当前选择的文件夹
- if (!_nowfile) { //如果获取不到则为未选择
- U.Alert('请选择文件夹新建的目录!'); //提示未选择文件
- } else {
- var _parentid = _nowfile.id.replace('CS', ''); //获取文件目录ID
- var _userid = US.userInfo.UserId; //获取用户ID
- var _diskinfo = US.disk.Disks[_userid]; //获取用户网盘信息
- var _dirinfo = U.Json.select(_diskinfo.directoryOrFiles, { UserDirectoryID: _parentid })[0]; //获取文件夹信息
- if (!U.MD.DK.C.getDirectoryPermissions(_dirinfo.UserDirectoryID, _diskinfo).isnew) {
- return U.Alert(_dirinfo.Child.length ? '分类目录无法操作,请选择群文件或文件夹!' : '分类目录无法操作,请新建群或者选择其他群文件夹'); //提示未选择文件
- }
- //获取粘贴到制定目录的群id
- _ancestors = U.MD.DK.C.getAncestors(_dirinfo, _diskinfo); //获取所有的祖先
- //如果是ftp目录,那么groupid就是用户id
- if (_ancestors[0].UserDirectoryID == US.FTPFOLDERID) {
- _groupid = _diskinfo.userInfo.UserId;
- }
- //否则就是对应的群id,如果不存在那么就是""
- else {
- _groupid = _ancestors[0].GroupID || "";
- }
- var _newfileid = fileid || Guid.newGuid();
- //去数据库添加文件
- U.A.Request(US.DISK, ["CreateFile", _userid, _newfileid, _parentid, _name, "", "", "", postfix, _groupid], function (r) {
- //创建文件
- var _fileinfo = new U.MD.DK.M.entity(_newfileid, 0, _parentid, _name, _name, postfix, "", U.UF.D.toTimeStamp(), "", "9999", null, "", 1, "", _groupid, "", _userid, US.userInfo.UserNickName, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead)
- U.MD.DK.RE.addFileOrFolder([_fileinfo], _diskinfo, _dirinfo); //添加到页面上中
- U.UF.F.windowMinimize(formel);
- //如果存在就执行
- if (U.UF.C.isFunction(callback)) {//判断是否有点击事件的方法,如果有,运行它
- callback(_fileinfo);
- }
- }, []);
- }
- } else {
- //不符合规范
- U.Alert('请填写文件名符合规范!');
- }
- }
- /**
- * 新建文件夹函数
- *
- **/
- U.MD.DK.VW.chosenSaveFile.newFolder = function () {
- var _nowfile = U.selectEl('.U_MD_DK_VW_ChosenSaveFile_File .U_MD_DK_LTXOSO')[0]; //获取当前选择的文件夹
- if (!_nowfile) { //如果获取不到则为未选择
- return U.Alert('请选择文件夹新建的目录!'); //提示未选择文件
- }
- var _userid = US.userInfo.UserId; //获取用户ID
- var _parentid = _nowfile.id.replace('CS', ''); //获取文件目录ID
- var _diskinfo = US.disk.Disks[_userid]; //获取用户网盘信息
- if (_diskinfo.directoryOrFiles[0].UserDirectoryID == _parentid || _diskinfo.directoryOrFiles[1].UserDirectoryID == _parentid || _diskinfo.directoryOrFiles[2].UserDirectoryID == _parentid) {//新建文件权限
- U.Alert('该目录下无法新建文件夹,请重新选择目录!');
- } else {
- //创建新建文件名输入框
- var _input = $$('input', { placeholder: "请输入文件夹名字...", style: { width: '180px', height: "25px", margin: "30px auto", display: "block", "text-indent": "5px" } });
- //创建提示框
- U.UF.UI.confirm(_input, function () {
- //确定函数
- var _name = _input.value; //获取输入文件夹名字
- if (U.UF.S.ZWFileName.test(_name)) { //判断文件名是否符合规范
- var _dirinfo = U.Json.select(_diskinfo.directoryOrFiles, { UserDirectoryID: _parentid })[0]; //获取文件夹信息
- //获取粘贴到制定目录的群id
- _ancestors = U.MD.DK.C.getAncestors(_dirinfo, _diskinfo); //获取所有的祖先
- //如果是ftp目录,那么groupid就是用户id
- if (_ancestors[_ancestors.length - 1].UserDirectoryID == US.FTPFOLDERID) {
- _groupid = _diskinfo.userInfo.UserId;
- }
- //否则就是对应的群id,如果不存在那么就是""
- else {
- _groupid = _ancestors[_ancestors.length - 1].GroupID || "";
- }
- var _newfolderid = Guid.newGuid(); //随机生成文件夹ID
- //填写文件名符合规范 将文件夹以及文件夹名字保存到数据库
- U.A.Request(US.DISK, ["CreateDirectory", _userid, _newfolderid, _dirinfo.UserDirectoryDeep + 1, _name, _parentid, "", _groupid, ""], //保存到数据库
- function (r) {
- //异步回调函数
- var _nextlevel = U.selectEl(_nowfile).next()[0] || $$('div', {}, U.selectEl(_nowfile).Parent()); //获取或选择自己文件夹创建位置
- var _fileinfo = new U.MD.DK.M.entity(_newfolderid, 0, _parentid, _name, _name, "folder", "", U.UF.D.toTimeStamp(), "", _dirinfo.UserDirectoryDeep + 1,
- null, "", 0, "", _groupid, "", _userid, US.userInfo.UserNickName, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead); //创建本地文件信息
- U.MD.DK.RE.addFileOrFolder([_fileinfo], _diskinfo, _dirinfo); //添加到页面上中
- _filediv = U.MD.DK.VW.chosenSaveFile.Print(_fileinfo, _nextlevel, parseInt(_nowfile.style.paddingLeft || 0) + 6, "U_MD_DK_LCW"); //打印新建文件夹
- _nextlevel.insertBefore(_filediv, U.selectEl(_nextlevel).Child()[0]); //在最前方插入
- });
- } else {
- //提示文件名不符合规范
- U.Alert('请填写文件名符合规范!');
- return false;
- }
- });
- }
- }
- //#endregion
- //#region 保存到指定协同群窗口
- /**
- * 保存到指定协同群窗口
- *
- * @param postfix {string} 文件后缀 文件类型
- * @param fileinfo {object} 文件信息
- * @param filename {string} 文件名
- * @param type {string} 操作类型 move 移动 new 新建
- * @param callback {function} 回调函数
- *
- **/
- U.MD.DK.VW.saveSynergy = function (postfix, fileinfo, filename, type, callback) {
- if (!U.MD.U.L.isLogin()) {//是否登录
- var _grouplistarr = US.disk.Disks[US.userInfo.UserId]; //获取当前登录用户的网盘信息
- var _formel = U.selectEl('#U_MD_O_SaveSynergy')[0]; //获取窗体元素
- var _grouplist; //定义变量
- if (_formel) { //判断窗体是否存在
- //存在则居中显示
- U.UF.F.windowTopCenter(_formel);
- //获取文件区域
- _grouplist = U.selectEl('#U_MD_O_SaveSynergy_GroupList')[0];
- _grouplist.innerHTML = "";
- U.selectEl('.U_MD_DK_VW_ChosenSaveFile button', _formel)[1].onclick = function () {
- U.MD.DK.VW.saveSynergy.ensure(_formel, U.selectEl('.U_MD_DK_VW_ChosenSaveFile input', _formel)[0], postfix, fileinfo, type, callback);
- }
- U.selectEl('.U_MD_DK_VW_ChosenSaveFile input', _formel)[0].value = "";
- }
- else {
- var _box = $$('div', { style: { position: "relative", overflow: "hidden" }, "className": "U_MD_DK_VW_ChosenSaveFile" }); //创建文件区域容器
- var _creategroup = $$('button', { style: { position: "absolute", right: "0", top: "-2px" }, innerHTML: "新建群", id: "U_MD_O_SaveSynergy_CreateGroup", onclick: 'U.MD.DK.VW.saveSynergy.swith()' }, _box); //创建新建文件夹按钮
- $$("div", { style: { "font-size": "16px", padding: "6px 10px 7px" }, innerHTML: "群列表" }, _box); //创建标题
- $$("hr", {}, _box); //创建分割线
- var _newgroup = $$("div", { "className": "U_MD_DK_VW_ChosenSaveFile_File", id: "U_MD_O_SaveSynergy_NewGroup", style: { display: 'none', overflow: 'hidden' } }, _box); //创建文件区域
- _grouplist = $$("div", { "className": "U_MD_DK_VW_ChosenSaveFile_File", id: "U_MD_O_SaveSynergy_GroupList" }, _box); //创建文件区域
- var _inputarea = $$('div', {}, _box); //创建填写文件名区域
- $$('span', { 'innerHTML': '文件名:' }, _inputarea); //标题
- var _input = $$('input', {
- placeholder: "请输入文件名...",
- value: filename == "未命名文档(点击编辑)..." ? "" : filename,
- //onfocus: "U.UF.MR.inputPlaceholder(this,'未命名文档(点击编辑)...','')",
- //onblur: "U.UF.MR.inputPlaceholder(this,'','未命名文档(点击编辑)...');",
- style: { width: "89%", "text-indent": "5px", "line-height": "26px" }
- }, _inputarea); //文件名输入框
- var _ensure = $$('button', { innerHTML: "确定" }, _box); //确定按钮
- var _cancel = $$('button', { innerHTML: "取消" }, _box); //取消按钮
- //创建窗体
- _formel = new U.UF.UI.form(
- "<span id='U_MD_O_SaveSynergy_Title'>" + (type == 'move' ? "将文档移动到" : "选择保存到") + "指定群</span>",
- _box, {
- "id": "U_MD_O_SaveSynergy",
- "style": {
- "width": "600px",
- "height": "450px"
- }
- }).form;
- //绑定确定按钮事件
- _ensure.onclick = function () {
- U.MD.DK.VW.saveSynergy.ensure(_formel, _input, postfix, fileinfo, type, callback);
- }
- //取消函数
- _cancel.onclick = function () {
- U.UF.F.windowMinimize(_formel);
- }
- }
- //打印文件
- U.MD.DK.VW.chosenSaveFile.printFolder(_grouplistarr.directoryOrFiles.slice(1, 3), _grouplist, 0, ["U_MD_DK_LCD", "U_MD_DK_LCS"]);
- //默认切换 选择群状态
- U.MD.DK.VW.saveSynergy.swith(true);
- }
- };
- /**
- * 保存到指定协同群窗口 确定函数
- *
- * @param formel {element} 窗体元素
- * @param input {element} 文件名输入框
- * @param postfix {string} 文件后缀 文件类型
- * @param fileinfo {object} 文件信息
- * @param type {string} 操作类型 move 移动 new 新建
- * @param callback {function} 回调函数
- *
- **/
- U.MD.DK.VW.saveSynergy.ensure = function (formel, input, postfix, fileinfo, type, callback) {
- var _name = input.value; //获取文件名
- if (_name.trim() == "") { //判断是否为空
- return U.Alert('请填写文件名!');
- }
- //判断文件名是否符合规范
- if (U.UF.S.ZWFileName.test(_name)) {
- var _dirinfo;
- var _userid = US.userInfo.UserId; //获取用户ID
- var _diskinfo = US.disk.Disks[_userid]; //获取用户网盘信息
- if ($('#U_MD_O_SaveSynergy_GroupList').css('display') == 'none') {
- var _groupName = '协同文档群--' + new Date().getHours() + ":" + new Date().getMinutes(), //默认群名/也是文档名
- _groupDesc = "由" + US.userInfo.UserName + "发起的互联办公群组。";
- U.MD.F.J.determineCreateGroupAndAddGroupUser(false, null, null, false, _groupName, _groupDesc, function (groupid) {
- _dirinfo = U.Json.select(_diskinfo.directoryOrFiles, { UserDirectoryID: groupid })[0]; //获取文件夹信息
- U.MD.DK.VW.saveSynergy.ensure.operate(formel, _dirinfo, fileinfo, groupid, groupid, type, postfix, _name, callback);
- });
- } else {
- var _groupid, _parentid;
- var _nowfile = U.selectEl('.U_MD_DK_LTXOSO', formel)[0]; //获取当前选择的文件夹
- _parentid = _nowfile.id.replace('CS', ''); //获取文件目录ID
- _dirinfo = U.Json.select(_diskinfo.directoryOrFiles, { UserDirectoryID: _parentid })[0]; //获取文件夹信息
- if (!U.MD.DK.C.getDirectoryPermissions(_dirinfo.UserDirectoryID, _diskinfo).isnew) {
- return U.Alert(_dirinfo.Child.length ? '分类目录无法操作,请选择群文件或文件夹!' : '分类目录无法操作,请新建群或者选择其他群文件夹'); //提示未选择文件
- }
- //获取粘贴到制定目录的群id
- _ancestors = U.MD.DK.C.getAncestors(_dirinfo, _diskinfo); //获取所有的祖先
- //如果是ftp目录,那么groupid就是用户id
- if (_ancestors[0].UserDirectoryID == US.FTPFOLDERID) {
- _groupid = _diskinfo.userInfo.UserId;
- }
- //否则就是对应的群id,如果不存在那么就是""
- else {
- _groupid = _ancestors[0].GroupID || "";
- }
- U.MD.DK.VW.saveSynergy.ensure.operate(formel, _dirinfo, fileinfo, _parentid, _groupid, type, postfix, _name, callback);
- }
- } else {
- U.Alert('请填写文件名符合规范!');
- }
- }
- /**
- * 执行对应操作函数
- *
- * @param formel {element} 窗体元素
- * @param dirinfo {object} 文件夹信息
- * @param fileinfo {object} 文件信息
- * @param parentid {string} 文件目录ID
- * @param groupid {string} 群ID
- * @param type {string} 操作类型 move 移动 new 新建
- * @param postfix {string} 文件后缀 文件类型
- * @param name {string} 文件名
- * @param callback {function} 回调函数
- *
- **/
- U.MD.DK.VW.saveSynergy.ensure.operate = function (formel, dirinfo, fileinfo, parentid, groupid, type, postfix, name, callback) {
- var _fileid = fileinfo.UserDirectoryID;
- var _userid = US.userInfo.UserId; //获取用户ID
- var _diskinfo = US.disk.Disks[_userid]; //获取用户网盘信息
- if (type == "move") {
- var _pastecontent = US.disk.Disks[_userid].pasteDirOrFile = {
- "type": "shear", //复制或者剪切 "copy" || "shear"
- "UserDirectoryID": groupid, //在哪个目录复制或者剪切
- "dirorfile": fileinfo, //复制的内容
- "userid": _userid //用户id
- }
- U.A.Request(US.DISK, ["CutAndPasteFiles", fileinfo.UserId, groupid, fileinfo.UserDirectoryID, groupid, groupid],
- top.U.MD.DK.RE.asynPaste, ["", dirinfo, groupid, _pastecontent, _diskinfo]);
- U.A.Request(US.DISK, ["UpdateFileInfo", _fileid, name], function () {
- fileinfo.UserallDirectoryName = name; //文件全写的名字
- fileinfo.UserDirectoryName = name.addEllipsis(20); //文件的缩略名
- fileinfo.GroupId = fileinfo.UserDirectoryEncrypt = groupid;
- //如果存在就执行
- if (U.UF.C.isFunction(callback)) {//判断是否有点击事件的方法,如果有,运行它
- callback(fileinfo);
- }
- U.UF.F.windowMinimize(formel);
- });
- } else {
- //去数据库添加文件
- U.A.Request(US.DISK, ["CreateFile", _userid, _fileid, parentid, name, "", "", "", postfix, groupid], function (r) {
- //创建文件
- var _fileinfo = new U.MD.DK.M.entity(_fileid, 0, parentid, name, name, postfix, "", U.UF.D.toTimeStamp(), "", "9999", null, "", 1, "", groupid, "", _userid, US.userInfo.UserNickName, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead)
- U.MD.DK.RE.addFileOrFolder([_fileinfo], _diskinfo, dirinfo); //添加到页面上中
- U.UF.F.windowMinimize(formel);
- //如果存在就执行
- if (U.UF.C.isFunction(callback)) {//判断是否有点击事件的方法,如果有,运行它
- callback(_fileinfo);
- }
- U.UF.F.windowMinimize(formel);
- }, []);
- }
- }
- /**
- * 选择群、新建群方式切换
- *
- * @param init {boole} 是否为默认状态 选择群状态
- *
- **/
- U.MD.DK.VW.saveSynergy.swith = function (init) {
- var _newgroup = U.selectEl('#U_MD_O_SaveSynergy_NewGroup'); //新建群元素
- var _grouplist = U.selectEl('#U_MD_O_SaveSynergy_GroupList'); //群列表
- var _creategroup = U.selectEl('#U_MD_O_SaveSynergy_CreateGroup'); //按钮
- if (_newgroup.css('display') == 'none' && !init) { //是否为新建群状态
- _newgroup.css('display', 'block'); //新建群元素显示
- _grouplist.css('display', 'none'); //选择群元素影藏
- _creategroup[0].innerHTML = "返回群列表"; //修改按钮提示字
- _creategroup[0].nextElementSibling.innerHTML = "选择联系人"; //修改标题
- if (_newgroup.Child().length == 0) { //判断初始化窗体是否打印
- U.MD.DK.VW.saveSynergy.createGroupInit(); //未打印则执行打印
- }
- U.MD.DK.VW.saveSynergy.Friends(); //打印可选好友
- } else {
- _newgroup.css('display', 'none'); //新建群元素显隐藏
- _grouplist.css('display', 'block'); //选择群元素显示
- _creategroup[0].innerHTML = "新建群"; //修改按钮提示字
- _creategroup[0].nextElementSibling.innerHTML = "群列表"; //修改标题
- }
- }
- /**
- * 新建群区域初始化
- *
- **/
- U.MD.DK.VW.saveSynergy.createGroupInit = function () {
- var _newgroup = U.selectEl('#U_MD_O_SaveSynergy_NewGroup')[0];
- var _left = $$('div', { style: { borderRight: "1px solid #ccc", position: "relative" } }, _newgroup);
- var _right = $$('div', { style: { overflow: "hidden" } }, _newgroup);
- var _count = $$('div', { style: { lineHeight: '30px' }, innerHTML: '已选择联系人:<span>1</span>' }, _right);
- var _select = $$('div', { id: "U_MD_O_SaveSynergy_NewGroup_Select", style: { height: '265px', overflow: 'auto' } }, _right);
- var _box = $$('div', { "className": 'U_MD_O_SaveSynergy_NewGroup_Friend', style: { paddingLeft: '5px' } }, _select);
- $$('img', { "onerror": U.MD.C.imgError, src: U.MD.C.getHeadImage(US.userInfo.UserThumbnailImageHead) }, _box);
- $$('span', { innerHTML: US.userInfo.UserNickName || US.userInfo.UserName }, _box);
- }
- /**
- * 打印好友列表
- *
- **/
- U.MD.DK.VW.saveSynergy.Friends = function () {
- var i, _box, //定义变量
- _friends = US.friend.friends; //好友列表
- var _child = U.selectEl('#U_MD_O_SaveSynergy_NewGroup').Child(); //获取新建群区域的子级
- var _friendel = _child[0]; //获取好友列表区域
- var _countel = U.selectEl('span', U.selectEl(_child[1]).Child()[0])[0]; //获取选择计数元素
- var _selectel = U.selectEl("#U_MD_O_SaveSynergy_NewGroup_Select"); //获取选中好友列表
- _friendel.innerHTML = ""; //清空好友列表
- _countel.innerHTML = "1"; //设置默认选择人数为1 默认选择自己
- U.MD.F.J.selectUserInfo.NeedUser = []; //清空选中全局
- var _oldfriend = _selectel.Child(); //获取遗留选中好友
- //清除遗留选中好友
- for (i = 1; i < _oldfriend.length; i++) {
- U.selectEl(_oldfriend[i]).remove();
- }
- //如果存在好友
- if (_friends.length > 0) {
- //循环打印好友
- for (i = 0; i < _friends.length; i++) {
- //创建好友盒子
- var _box = $$('div', {
- "className": 'U_MD_O_SaveSynergy_NewGroup_Friend', onclick: U.UF.C.closure(function (friendinfo) {
- U.MD.DK.VW.saveSynergy.Friends.Select(friendinfo, _selectel[0], _countel);
- }, [_friends[i]]), friendid: _friends[i].FriendsID
- }, _friendel);
- //创建头像
- $$('img', { "onerror": U.MD.C.imgError, src: U.MD.C.getHeadImage(_friends[i].UserThumbnailImageHead) }, _box);
- //创建用户名
- $$('span', { innerHTML: _friends[i].UserNickName || _friends[i].UserName }, _box);
- }
- }
- //如果不存在好友
- else {
- //创建提示字
- $$('p', {
- style: { cssText: "font-weight: bold; font-size: 14px;padding-left:60px;padding-top:60px;" },
- innerHTML: '您暂无添加好友,</br> 快去<span style="cursor:pointer;color:rgb(41, 103, 167);" onclick="U.MD.F.S.popSearchFriendsOrGroupForm(0);">添加你的好友</span>吧。 </br>'
- }, _friendel);
- //创建刷新按钮
- $$('span', {
- innerHTML: "已添加完好友点击刷新好友列表", onclick: function () {
- U.UF.DL.loading(_friendel);
- setTimeout(function () { U.MD.DK.VW.saveSynergy.Friends(); U.UF.DL.uploading(_friendel); }, 300);
- }, style: { color: "red", cursor: "pointer", position: "absolute", bottom: "0px", fontSize: "12px" }
- }, _friendel);
- }
- }
- /**
- * 选择好友操作
- *
- * @param friendinfo {object} 好友信息
- * @param selectel {element} 选中好友列表区域
- * @param countel {element} 计数元素
- *
- **/
- U.MD.DK.VW.saveSynergy.Friends.Select = function (friendinfo, selectel, countel) {
- var i, //定义变量
- _isselect = U.Json.select(U.MD.F.J.selectUserInfo.NeedUser, { UserId: friendinfo.UserId })[0]; //判断是否已选中
- if (!_isselect) { //如果未选中
- countel.innerHTML = parseInt(countel.innerHTML) + 1; //计数+1
- U.MD.F.J.selectUserInfo.NeedUser.push(friendinfo); //加入选中好友全局
- //打印选择好友
- var _box = $$('div', {
- "className": 'U_MD_O_SaveSynergy_NewGroup_Friend', style: { paddingLeft: '5px' }, onclick: function () {
- U.selectEl(this).remove();
- U.Json.del(U.MD.F.J.selectUserInfo.NeedUser, { "UserId": friendinfo.UserId });
- countel.innerHTML = parseInt(countel.innerHTML) - 1;
- }
- }, selectel);
- //打印头像
- $$('img', { "onerror": U.MD.C.imgError, src: U.MD.C.getHeadImage(friendinfo.UserThumbnailImageHead) }, _box);
- //打印姓名
- $$('span', { innerHTML: friendinfo.UserNickName || friendinfo.UserName }, _box);
- }
- }
- /*
- U.MD.DK.VW.choseFile
- 参数一:选择文件
- 参数二: 显示文件类型
-
- */
- U.MD.DK.VW.choseFile = function (cb, type) {
- var _diskinfo = US.disk.Disks[US.userInfo.UserId]; //获取当前登录用户的网盘信息
- var _formel = U.selectEl('#U_MD_DK_VW_ChosenSaveFile')[0]; //获取窗体元素
- var _file; //定义变量
- type = type ? type : "*"; //默认为全部
- if (_formel) { //判断窗体是否存在
- //存在则居中显示
- U.UF.F.windowTopCenter(_formel);
- //获取文件区域
- _file = U.selectEl('#U_MD_DK_VW_ChosenSaveFile_File')[0];
- _file.innerHTML = "";
- }
- else {
- var _box = $$('div', { style: { position: "relative", overflow: "hidden" }, "className": "U_MD_DK_VW_ChosenSaveFile" }); //创建文件区域容器
- var _newfolder = $$('button', { style: { position: "absolute", right: "0", top: "2px" }, innerHTML: "新建文件夹" }, _box); //创建新建文件夹按钮
- $$("div", { style: { "font-size": "16px", padding: "12px 10px 2px" }, innerHTML: "文件名称" }, _box); //创建标题
- $$("hr", {}, _box); //创建分割线
- _file = $$("div", { "className": "U_MD_DK_VW_ChosenSaveFile_File", id: "U_MD_DK_VW_ChosenSaveFile_File" }, _box); //创建文件区域
- var _inputarea = $$('div', {}, _box); //创建填写文件名区域
- $$('span', { 'innerHTML': '文件名:' }, _inputarea); //标题
- var _input = $$('input', { "className": "U_MD_DK_VW_ChosenSaveFileName", placeholder: "请输入文件名...", style: { width: "89%", "text-indent": "5px", "line-height": "26px" } }, _inputarea); //文件名输入框
- var _ensure = $$('button', { innerHTML: "确定" }, _box); //确定按钮
- var _cancel = $$('button', { innerHTML: "取消" }, _box); //取消按钮
- //创建窗体
- _formel = new U.UF.UI.form(
- "<span id='U_MD_DK_VW_ChosenSaveFile_Title'>选择文件</span>",
- _box, {
- "id": "U_MD_DK_VW_ChosenSaveFile",
- "style": {
- "width": "600px",
- "height": "450px"
- }
- }).form;
- //绑定新建文件夹事件
- _newfolder.onclick = function () {
- U.MD.DK.VW.chosenSaveFile.newFolder();
- }
- //绑定确定按钮事件
- _ensure.onclick = function () {
- cb($('.U_MD_DK_VW_ChosenSaveFileName')[0].data); //回调
- U.UF.F.windowMinimize(_formel); //隐藏弹框
- _input.value = ""; //清空显示
- _input.data = null; //清空数据
- }
- //取消函数
- _cancel.onclick = function () {
- U.UF.F.windowMinimize(_formel);
- }
- }
- //默认创建初始化目录
- U.MD.DK.VW.chosenSaveFile.printFolder(_diskinfo.directoryOrFiles.slice(1, 5), _file, 0, ["U_MD_DK_LCD", "U_MD_DK_LCS", "U_MD_DK_LCD", "U_MD_DK_LCB", "U_MD_DK_LCF", "U_MD_DK_LCT", "U_MD_DK_LCP", "U_MD_DK_LCY"], _file, type);
- }
- //#endregion;
- ///<jscompress sourcefile="LeftClick.js" />
- /*
- 存在问题
- 1、非能打开文件处理
- */
- Namespace.register("U.MD.DK.LE"); //Disk左键事件命名空间
- //#region 左键事件处理
- //#region 当前网盘打开
- //文件点击,文件夹点击,及url导航到达区域。
- /*
- 文件管理区域点击事件,暂时分为:音乐、图片、视频、文件。
- 参数一:fileinfo为单击的文件对象
- 参数四:userid为用户id。
- */
- U.MD.DK.LE.openFileDirectory = function (fileinfo, userid) {
- var i,
- _content,
- _div,
- _apptype, //打开应用的名字
- _applicationame, //应用的名字
- _types = US.disk.applicationTypes, //所有的文件类型
- _navarray, //导航数组
- _extension, //文件扩展名
- _diskinfo = U.MD.DK.M.diskOperatingSwitch(userid); //根据用户id找到其所有硬盘数据。
- U.UF.EV.stopBubble(); //阻止冒泡
- //fileinfo.filetype == 1是文件 == 0 是文件夹
- //如果是文件的情况下的处理
- if (fileinfo.filetype) {
- _extension = fileinfo["UserDirectoryExtendType"].toLocaleLowerCase(); //得到文件扩展名
- //根据文件类型进入不同的应用。
- _types = US.disk.applicationTypes;
- _applicationame;
- //判断后缀名归属于哪一个应用程序。得到应用程序的名称。
- for (i in _types) {
- if (_types[i].types.indexOf(_extension) > -1) { //判断文件类型是否归属该应用
- _applicationame = i;
- break;
- }
- }
- //根据应用名称打开不同的应用。
- switch (_applicationame) {
- case "music": //播放制定的音乐,需要流程图
- U.MD.DK.LE.music(fileinfo); //音乐控件
- break;
- case "image": //图片查看,需要流程图
- U.MD.DK.LE.img(fileinfo); //图片控件
- break;
- case "video": //视频处理 需要流程图
- U.MD.DK.LE.video(fileinfo); //视频控件
- break;
- case "text": //文本文件需要流程图
- U.MD.D.Txt.textCreate(fileinfo);
- break;
- case "usoffice": //如果是云端系统自有格式文件。 需要流程图
- //excel处理
- case "ue": //word处理
- U.MD.D.I.openApplication("excel", fileinfo); //弹出应用处理
- break;
- case "uw": case "un": //word处理
- U.MD.D.I.openApplication("word", fileinfo); //弹出应用处理
- break;
- case "word":
- U.MD.D.I.openApplication("word", fileinfo); //弹出应用处理
- break;
- case "txt": //txt处理
- U.MD.D.I.openApplication("txt", fileinfo); //弹出应用处理
- break;
- //windows上传的不可识别的文件打开,直接跳转到下载页面。
- default:
- U.MD.DK.RE.downloadFile(fileinfo.UserDirectoryID, false);
- break;
- }
- }
- //打印目录信息
- else {
- //添加前进后退事件
- U.UF.N.addEvent(function () {
- U.MD.DK.LE.openDirectory(fileinfo, userid); //打开目录
- }, "disk" + userid);
- }
- //设置文件及文件夹的修改时间,打开文件或者文件夹时,把打开文件的时间记录到数据库。以实现最近访问文件,最近访问文件夹的功能。fileinfo.filetype == 0 表示文件夹 fileinfo.filetype == 1表示文件
- if (fileinfo.UserDirectoryDeep > 1) {
- //filetype = 0的情况是文件夹的处理
- if (fileinfo.filetype == 0) {
- U.A.Request(US.DISK, ["UpdateDirectoryInfo", fileinfo.UserDirectoryID, ""], function () { });
- }
- //文件的处理
- else {
- U.A.Request(US.DISK, ["UpdateFileInfo", fileinfo.UserDirectoryID, ""], function () { });
- }
- //设置文件更新时间
- fileinfo["UserDirectoryModifyTime"] = U.UF.D.toTimeStamp(); //修改前台的时间
- }
- }
- /**
- * 打开目录
- * @param {array} 需要输出的文件或者文件夹信息
- * @param {element} 输出到那个区域
- **/
- U.MD.DK.LE.openDirectory = function (fileinfo, userid) {
- var _groupinfo,
- _groupdirectory,
- _leftel, //左边元素
- _diskinfo = U.MD.DK.M.diskOperatingSwitch(userid), //获取网盘信息
- _content = U.selectEl("#U_MD_DK_RZ", _diskinfo.formel)[0]; //获取打印内容的元素
- _diskinfo.selectElement = []; //切换文件夹修改选择文件
- _content.innerText = ""; //清空内容
- _diskinfo.directoryid = fileinfo["UserDirectoryID"]; //设置当前打开目录的id.看全集变量US.disk.Disks
- //设置url重写
- U.MD.N.urlWrite("disk/" + _diskinfo.userInfo.UserId + "/" + _diskinfo.directoryid, _diskinfo.userInfo.UserNickName + "的网盘");
- //判断这个目录下面有没有孩子节点,如果有就可以直接打印,如果没有那么需要去数据库取数据
- if (fileinfo.Child) { //已加载文件
- U.MD.DK.LE.loadDirectory(fileinfo, _diskinfo, userid);
- }
- //去数据库取文件夹及文件信息,异步加载
- else {
- //如果是最新文档的数据处理
- if (_diskinfo.directoryOrFiles[0].UserDirectoryID == fileinfo.UserDirectoryID) {
- U.MD.DK.LE.getNewDocument(userid, fileinfo, _content);
- }
- //如果是点击他人邀请或者是我的协同的处理
- else if (_diskinfo.directoryOrFiles[1].UserDirectoryID == fileinfo.UserDirectoryID || _diskinfo.directoryOrFiles[2].UserDirectoryID == fileinfo.UserDirectoryID) {
- if (US.friend.group) {
- _groupinfo = US.friend.group.concat();
- _diskinfo.groups = _groupdirectory = U.MD.DK.getGroupDirectory(_groupinfo, _diskinfo.directoryOrFiles, userid); //初始化
- _diskinfo.directoryOrFiles = _diskinfo.directoryOrFiles.concat(_groupdirectory); //合并数组
- }
- U.MD.DK.LE.loadDirectory(fileinfo, _diskinfo, userid); //打印目录信息
- }
- //获取文件夹下面的文件或者文件夹
- else {
- U.MD.DK.LE.getChildsByDirectoryId(userid, fileinfo, _content);
- }
- }
- }
- /**
- * 初始化目录
- * @param {object} 文档信息
- * @param {object} 网盘信息
- * @param {string} 用户id
- **/
- U.MD.DK.LE.loadDirectory = function (fileinfo, diskinfo, userid) {
- //展开下级文件夹
- var _childs = fileinfo.Child || [],
- _leftel = U.selectEl("#L" + fileinfo["UserDirectoryID"], diskinfo.formel)[0],
- _content = U.selectEl("#U_MD_DK_RZ", diskinfo.formel)[0];
- //左边树目录处理
- if (_leftel) {
- U.MD.DK.LL.printLeftTreeDirectory(U.Json.select(_childs, { "filetype": 0 }), _leftel, userid); //如果左边数目显示了
- }
- U.selectEl("#U_MD_DK_RKR", diskinfo.formel)[0].innerHTML = "当前文件的数量:" + _childs.length;
- diskinfo.currentDirectoryFile = _childs; //把当前显示打印的资料显示到网盘中。
- //头部导航打印
- var _navarray = U.MD.DK.C.getAncestors(fileinfo, diskinfo); //获取需要输出的导航信息,这里直接获取这个目录一条线上的祖先元素
- U.MD.DK.LL.printNavigation(_navarray, U.selectEl("#U_MD_DK_RYB", diskinfo.formel)[0], userid); //打印出导航数据
- //打印数据
- U.MD.DK.VW.printContent(_childs, _content);
- //给当前目录设置权限
- var _permissions = U.MD.DK.C.getDirectoryPermissions(fileinfo.UserDirectoryID, diskinfo);
- var _permissioninfo = U.MD.DK.C.readWritePermission(fileinfo.UserDirectoryID, diskinfo)
- U.MD.DK.LE.myCollJudgment(_permissions, _permissioninfo[0][0]);
- }
- /**
- * 权限按钮显示方法
- * @param {object} 权限数据
- * @param {object} 文件信息
- **/
- U.MD.DK.LE.myCollJudgment = function (permissions, permissioninfo) {
- var _div = U.selectEl(".U_MD_DK_RT")[1].children; //获取上边所有按钮
- if (permissions.isupadte == false && permissions.isdownload == false && permissions.isnew == false) {//判断是否为我的协同或他人邀请,如果是
- _div[0].style.display = "none"; //修改上传按钮的显示,为隐藏
- _div[1].style.display = "none"; //修改新建文件夹按钮的显示,为隐藏
- _div[2].style.display = "none"; //修改新建文件按钮的显示,为隐藏
- _div[3].style.display = "none"; //修改新建文档按钮的显示,为隐藏
- _div[4].style.display = "none"; //修改导航文档按钮的显示,为隐藏
- _div[5].style.display = "none"; //修改新建工作表按钮的显示,为隐藏
- _div[6].style.display = "none"; //修改建立网站按钮的显示,为隐藏
- _div[7].style.display = "none"; //隐藏新建协同按钮
- if (permissioninfo.UserDirectoryName == "我的协同") {//进行判断,如为我的协同文件夹
- _div[7].style.display = "block"; //显示新建协同按钮
- _div[7].onclick = function () {//赋予点击事件
- U.MD.F.J.groupInfoForm(); //调用方法,添加协同文件
- }
- }
- } else {//如果不是
- _div[0].style.display = "block"; //修改上传按钮的显示,为显示
- _div[1].style.display = "block"; //修改新建文件夹按钮的显示,为显示
- _div[2].style.display = "block"; //修改新建文件按钮的显示,为显示
- _div[3].style.display = "block"; //修改新建文档按钮的显示,为显示
- _div[4].style.display = "block"; //修改导航文档按钮的显示,为显示
- _div[5].style.display = "block"; //修改新建工作表按钮的显示,为显示
- _div[6].style.display = "block"; //修改建立网站按钮的显示,为显示
- _div[7].style.display = "none"; //隐藏新建协同按钮
- }
- }
- //加载当前网盘内容
- //
- //* @param {string} 用户id
- //* @param {object} 目录信息
- //* @param {element} loading的元素。
- //* @param {callback} 回调函数
- //* @returns {} 无
- //
- U.MD.DK.LE.getChildsByDirectoryId = function (userid, fileinfo, loading, cb) {
- //如果没有孩子节点,则去数据库取数据。
- U.A.Request(US.DISK, ["GetChildsByDirectoryId", userid, fileinfo.UserDirectoryID, fileinfo.GroupID], U.MD.DK.LE.asynGetChildsByDirectoryId, [loading, userid, fileinfo, cb]);
- }
- //加载当前网盘内容
- //
- //* @param {string} 用户id
- //* @param {object} 目录信息
- //* @param {element} loading的元素。
- //* @param {callback} 回调函数
- //* @returns {} 无
- //
- U.MD.DK.LE.getNewDocument = function (userid, fileinfo, loading, cb) {
- //用户必须登录才能查看自己网盘的内容
- if (US.userInfo.UserId) {
- //如果没有孩子节点,则去数据库取数据。
- U.A.Request(US.CD, [US.DB, "UseStudio_Office", "GetCollaborativeDocument", US.userInfo.UserId, "00000000-0000-0000-0000-000000000000", "", 0, 0, 100], function (r) {
- var i;
- for (i = 0; i < r.value.length; i++) {
- r.value[i] = new U.MD.DK.M.entity(r.value[i].UserFilesID, r.value[i].UserFilesSize, r.value[i].UserDirectoryID, r.value[i].UserFilesName, r.value[i].UserFilesName, r.value[i].UserFilesExtendName, r.value[i].UserFilesServerName, r.value[i].UserFilesAddTime, "", "9999", r.value[i].UserFilesModifyTime, r.value[i].UserDirectoryEncrypt, 1, r.value[i].UserFilesDescript, r.value[i].UserDirectoryEncrypt, "", r.value[i].UserID, r.value[i].UserName, r.value[i].UserName, r.value[i].UserThumbnailImageHead);
- }
- U.MD.DK.LE.asynGetChildsByDirectoryId(r);
- }, [loading, userid, fileinfo, cb]);
- }
- //直接打印空数据
- else {
- U.MD.DK.LE.asynGetChildsByDirectoryId({ "context": [loading, userid, fileinfo, cb], "value": [] });
- }
- }
- /**
- * 获取网盘数据异步,这里处理了后台数据返回后吧数据写到了全局变量US.disk.Disks[userid][0]和US.disk.Disks[userid][4]中
- *
- * @param {object} ajax异步数据
- */
- U.MD.DK.LE.asynGetChildsByDirectoryId = function (r) {
- var _context = r.context, //获取异步的传参
- _userid = _context[1], //用户的id
- _fileinfo = _context[2], //文件的信息
- _cb = _context[3], //回调函数
- _dirid = _fileinfo.UserDirectoryID, //当前获取数据的目录id
- _diskinfo = U.MD.DK.M.diskOperatingSwitch(_userid); //获取用户的disk信息
- r = r.value;
- //把获取的数据设置到网盘全局变量中,为啥有两种数据结构?
- U.Json.del(_diskinfo.directoryOrFiles, { "UserDirectoryParentID": _dirid }); //移除原本有的目录文件
- _fileinfo.Child = r; //设置目录的子目录或者文件
- U.Json.add(r, { "Parent": _fileinfo });
- //添加文件
- U.MD.DK.M.entity.add(r, _diskinfo); //把文件写入到全局变量中 在_diskinfo[0]和_diskinfo[4]写入获取文件的信息
- //执行回调处理
- if (U.UF.C.isFunction(_cb)) {
- _cb();
- }
- //否则执行获取数据后打开文件的处理
- else if (_fileinfo.UserDirectoryID == _diskinfo.directoryid) {
- //如果用户还在等待当前目录信息出现,那么就展示,如果用户在loading的时候已经切换到其他地方去查看,那么则不展示数据更新
- U.MD.DK.LE.openDirectory(_fileinfo, _userid); //打开目录操作
- }
- }
- /**
- * 根据应用名称打开音乐播放器
- *
- *参数一:fileinfo为单击的文件对象
- */
- U.MD.DK.LE.music = function (fileinfo) {
- var _mp3arr, i,
- _num = 0, //索引位置
- _diskinfo = US.disk.UserDisk,
- _arr = []; //空数组
- //判断是否单独打开还是打开文件夹下所有的音乐
- if (fileinfo.UserDirectoryParentID) {
- _mp3arr = U.Json.select(_diskinfo.currentDirectoryFile, { "UserDirectoryExtendType": "mp3", "UserDirectoryParentID": fileinfo.UserDirectoryParentID });
- //当前打开的文件夹的所有音乐文件信息
- for (i = 0; i < _mp3arr.length; i++) {
- _arr[i] = {
- "title": _mp3arr[i].UserallDirectoryName, //音乐名
- "author": "", //歌手名
- "src": "http://fs.1473.cn/" + _mp3arr[i].UserFilesServerName, //音乐播放路径
- "cover": _mp3arr[i].UserThumbnailImageHead, //音乐封面路径
- "lrc": ""//歌词
- }
- if (_mp3arr[i].UserDirectoryID == fileinfo.UserDirectoryID) {//判断在哪个音乐文件打开的
- _num = i; //索引位置
- }
- }
- }
- else {
- _arr[0] = {
- "title": fileinfo.UserallDirectoryName, //音乐名
- "author": "", //歌手名
- "src": "http://fs.1473.cn/" + fileinfo.UserFilesServerName, //音乐播放路径
- "cover": fileinfo.UserThumbnailImageHead, //音乐封面路径
- "lrc": ""//歌词
- }
- }
- U.MD.UI.music(_arr, _num, true); //音乐控件
- U.MD.D.T.taskbar({ "id": "music", "backgroundPostion": "-144px -296px", "name": "音乐播放器", "forms": U.MD.UI.music.player, "click": function () { U.UF.F.topWindow(U.MD.UI.music.player.form); } });
- // var _userid = US.disk.UserDisk.userInfo.UserId; //当前打开网盘ID
- // var _diskinfo = U.MD.DK.M.diskOperatingSwitch(_userid); //磁盘信息
- // var _music = U.Json.select(_diskinfo.currentDirectoryFile, { "UserDirectoryExtendType": "mp3" }); //获取当前打开的文件夹的所有音乐文件信息
- // var _arr = []; //空数组
- // var _num1 = 0; //索引位置
- // for (var _num = 0; _num < _music.length; _num++) {//当前打开的文件夹的所有音乐文件信息
- // _arr[_num] = { title: _music[_num].UserallDirectoryName, //音乐名
- // author: "", //歌手名
- // src: "http://fs.1473.cn/" + _music[_num].UserFilesServerName, //音乐播放路径
- // cover: _music[_num].UserThumbnailImageHead, //音乐封面路径
- // lrc: ""//歌词
- // }
- // if (_music[_num].UserDirectoryID == fileinfo.UserDirectoryID) {//判断在哪个音乐文件打开的
- // _num1 = _num; //索引位置
- // }
- // }
- // U.MD.UI.music(_arr, _num1, true); //音乐控件
- // if (!$('#U_MD_D_T_taskbar_music')[0]) {
- // U.MD.UI.music.player.id = "music";
- // U.MD.D.T.taskbar({ "id": "music", "backgroundPostion": "-144px -296px", "name": "音乐播放器", "forms": U.MD.UI.music.player, "click": function () { U.UF.F.topWindow(U.MD.UI.music.player.form); } });
- // }
- // U.MD.UI.music(_arr, _num1, true); //音乐控件
- // U.MD.D.T.taskbar({ "id": "music", "backgroundPostion": "-144px -296px", "name": "音乐播放器", "forms": U.MD.UI.music.player, "click": function () { U.UF.F.topWindow(U.MD.UI.music.player.form); } });
- }
- /**
- * 根据应用名称打开图片
- *
- *参数一:fileinfo为单击的文件对象
- */
- U.MD.DK.LE.img = function (fileinfo) {
- var _diskinfo = US.disk.UserDisk;
- U.UF.DL.asynLoadCss({ "href": "/css/Controls/Basic/Picture.css", type: "text/css", rel: "stylesheet" }); //动态添加css文件
- U.UF.DL.asynLoadJs({ type: "text/javascript", src: "/js/Controls/Basic/Picture.js" }, function () {
- var i,
- j = 0,
- _arr = [], //空数组
- _num = 0;
- //判断打开的图片是在自己本地下的
- if (_diskinfo && fileinfo.UserDirectoryParentID && _diskinfo.userInfo.UserId == fileinfo.UserId) {
- for (i = 0; i < _diskinfo.currentDirectoryFile.length; i++) {//当前打开文件夹的文件
- if (fileinfo.UserDirectoryParentID == _diskinfo.currentDirectoryFile[i].UserDirectoryParentID && U.UF.UP.isImg(_diskinfo.currentDirectoryFile[i].UserDirectoryExtendType)) {
- _arr[j] = "http://fs.1473.cn/" + _diskinfo.currentDirectoryFile[i].UserFilesServerName; //图片地址
- if (_diskinfo.currentDirectoryFile[i].UserDirectoryID == fileinfo.UserDirectoryID) {//判断在哪个音乐文件打开的
- _num = j; //索引位置
- }
- j++;
- }
- }
- }
- if (_arr.length == 0) {
- _arr.push("http://fs.1473.cn/" + fileinfo.UserFilesServerName);
- }
- U.MD.UI.picture(_arr, _num)//图片控件
- U.UF.F.topWindow($('#U_MD_UI_PictureForm')[0], true); //窗体置顶
- });
- }
- /**
- * 根据应用名称打开视频
- *
- *参数一:fileinfo为单击的文件对象
- */
- U.MD.DK.LE.video = function (fileinfo) {
- var _form = new U.UF.UI.form(fileinfo.UserallDirectoryName, "", { "style": { "width": "780px", "height": "330px", "margin": "0" } }, { istop: true, isstretching: false, isenlarge: false, isnarrow: false }); //窗体
- U.UF.DL.asynLoadCss({ rel: "stylesheet", type: "text/css", href: "/css/Controls/Basic/Video.css" }); //动态添加css文件
- U.UF.DL.asynLoadJs({ src: "/js/Controls/Basic/Video.js", "charset": "utf-8", "type": "text/javascript" }, function () {//动态添加js文件
- var _video = U.MD.UI.video(("http://fs.1473.cn/" + fileinfo.UserFilesServerName), 780, 300, false, _form.middle); //视频控件
- //窗体关闭,声音停止
- _form.closecallback = function () {
- _video.video.pause();
- }
- // U.selectEl(".U_MD_UI_video_VideoDiv")[$(".U_MD_UI_video_VideoDiv").length - 1].style.position = "absolute"; //视频的位置
- // U.selectEl(".U_MD_UI_video_VideoDiv")[$(".U_MD_UI_video_VideoDiv").length - 1].style.top = "0px"; //视频的定位高低
- // U.selectEl(".U_MD_UI_video_VideoDiv")[$(".U_MD_UI_video_VideoDiv").length - 1].style.left = "0px"; //视频的定位左右
- });
- }
- //#endregion
- ;
- ///<jscompress sourcefile="LeftTree.js" />
- Namespace.register("U.MD.DK.LL"); //Disk导航命名空间
- //#region 导航
- /**
- * 导航打印(树导航)
- * @param {object} 左边一级层级树目录的相关信息
- * @param {element} 输出到那个区域
- * @param {array} 树目录的class样式数组
- * @param {element} 树目录区域
- * @param {str} 当前用户ID
- **/
- U.MD.DK.LL.printLeftTreeDirectory = function (directorys, el, userid, classes) {
- var _dtorydiv, //目录元素
- _namediv, //名字元素
- _frag = $$("div"), //临时块元素
- _padding = 3 //左对齐
- ;
- //判断展开的基本是否大于二级,大于二级则设置padding
- if ($(el).Child()[0]) {
- _padding = parseInt($(el).Child()[0].style.paddingLeft || 0) + 5;
- //如果不展开的处理
- if ($($(el).Child()[0]).Child()[0].className.indexOf("U_MD_DK_LTXOSIO") == -1) {
- return;
- }
- }
- //如果已经展开的处理
- if ($(el).Child()[1]) {
- el.removeChild($(el).Child()[1]);
- }
- //打印所有需要打印的目录信息
- for (i = 0; i < directorys.length; i++) {
- if (directorys[i].filetype == 0) {
- //得到打印文件夹的图标样式
- if ((classes || "").length) {
- _Img = classes[i] || classes;
- }
- else {
- if ((directorys[i]["UserDirectoryEncrypt"] && directorys[i]["UserDirectoryEncrypt"] != userid)) {
- _Img = "U_MD_DK_LCJ";
- }
- else {
- _Img = "U_MD_DK_LCW";
- }
- }
- //创建左边树目录
- _dtorydiv = $$("div", { "id": directorys[i]["UserDirectoryID"] ? "L" + directorys[i]["UserDirectoryID"] : "", "className": "U_MD_DK_LTXOA" }, _frag);
- _namediv = $$("div", {
- "className": "U_MD_DK_LTXOS",
- "style": {
- "paddingLeft": _padding + "px"
- },
- //导航点击事件的处理
- "onclick": U.UF.C.closure(function (directoryinfo, el) {
- U.UF.EV.stopBubble();
- U.MD.DK.LL.leftTreeClick(directoryinfo, el, userid)
- }, [directorys[i], _dtorydiv]),
- //右键处理
- "oncontextmenu": U.UF.C.closure(function (directoryinfo) {
- U.UF.EV.stopBubble();
- U.UF.EV.stopDefault();
- U.MD.DK.RM.rightMenu(this, directoryinfo, US.disk.UserDisk);
- }, [directorys[i]])
- }, _dtorydiv);
- $$("div", {
- "className": "U_MD_DK_LTXOSI U_MD_DK_Img"
- }, _namediv);
- $$("div", { "className": "U_MD_DK_LCOI U_MD_DK_LTXOST U_MD_DK_Img " + _Img }, _namediv);
- //文件名
- $$("div", {
- "className": "U_MD_DK_LTXOSN U_MD_D_Text_Abbreviation",
- "innerHTML": directorys[i].UserallDirectoryName,
- "ondblclick": U.UF.C.closure(function (directoryinfo) {
- U.UF.EV.stopBubble();
- U.MD.DK.RE.rename(this, directoryinfo);
- }, [directorys[i]])
- }, _namediv);
- }
- }
- el.appendChild(_frag);
- }
- /**
- * 导航点击处理
- * @param {object} 左边一级层级树目录的相关信息
- * @param {element} 输出到那个区域
- * @param {string} 当前用户ID
- **/
- U.MD.DK.LL.leftTreeClick = function (fileinfo, el, userid) {
- var _childel = U.selectEl(el).Child()[0];
- //权限判断
- //打开文件夹的图标高亮处理
- if ($(_childel).Child()[0].className.indexOf("U_MD_DK_LTXOSIO") > -1) {
- U.selectEl(_childel).Child()[0].className = "U_MD_DK_LTXOSI U_MD_DK_Img"; //图标展开的形式
- //打开文件夹处理
- var _contentel = U.selectEl(_childel).next();
- // _childel.className = "U_MD_DK_LTXOS"//重新设置class
- if (_contentel[0]) {
- el.removeChild(_contentel[0]); //清除元素
- }
- }
- else {
- // U.MD.DK.LL.leftTreeHighlight(el); //左边树点击处理
- U.selectEl(_childel).Child()[0].className = "U_MD_DK_LTXOSI U_MD_DK_Img U_MD_DK_LTXOSIO"; //图标展开的形式
- }
- U.selectEl(".U_MD_DK_LTXOSO").removeClass('U_MD_DK_LTXOSO');
- U.selectEl(_childel).addClass('U_MD_DK_LTXOSO');
- //打开文件夹处理
- U.MD.DK.LE.openFileDirectory(fileinfo, userid);
- }
- /**
- * 导航点击处理
- * @param {object} 左边一级层级树目录的相关信息
- * @param {element} 输出到那个区域
- * @param {string} 当前用户ID
- **/
- U.MD.DK.LL.leftTreeHighlight = function (el) {
- var i,
- _childel,
- _parentel = el
- ;
- //递归处理上级高亮处理
- do {
- _parentel = el.parentNode; //获取高亮元素的上级父亲
- _childel = U.selectEl(_parentel).Child(); //获取该级的所有子节点
- //如果在同一个文件夹下只能高亮一个文件目录,这样看起来才能显示当前点击的文件夹
- for (i = 0; i < _childel.length; i++) {
- U.selectEl(_childel[i]).Child()[0].className = el == _childel[i] ? "U_MD_DK_LTXOS U_MD_DK_LTXOSO" : "U_MD_DK_LTXOS";
- }
- } while ((el = _parentel.parentNode) && el.id != "U_MD_DK_LTXO")
- }
- /**
- * 生成导航(面包屑导航)
- * @param {array} 所有要追加的导航元素
- * @param {element} 导航的元素
- * @param {string} 用户的id
- */
- U.MD.DK.LL.printNavigation = function (navarray, el, userid) {
- var i, //用于循环
- _frag = $$("frag"), //临时的panel
- _click //导航点击事件处理
- ;
- el.innerText = ""; //清空导航区域
- //循环打印导航
- for (i = navarray.length - 1; i > -1; i--) {
- //创建一个导航, 如果导航是目录的导航,则点击的时候可以跳到指定的导航中
- $$("div", {
- "className": "U_MD_DK_RYBO", "innerHTML": navarray[i]["UserallDirectoryName"],
- "onclick": U.UF.C.closure(function (nav) {
- U.MD.DK.LE.openFileDirectory(nav, userid);
- }, [navarray[i]])
- }, _frag);
- }
- el.appendChild(_frag); //添加导航
- //每一次导航追加的时候需要如果超过了大小则需要隐藏前面的导航
- var _navchild = U.selectEl(el).Child(); //导航元素
- while (el.scrollHeight > 30) {
- _navchild[i].style.display = "none";
- }
- }
- //#endregion
- ;
- ///<jscompress sourcefile="RightClick.js" />
- Namespace.register("U.MD.DK.RE"); //Disk右键功能命名空间
- //#region 文件属性
- /**
- * 用户属性框的样式
- * @param {object} 目录目录或者文件信息
- * @param {string} 用户id
- */
- U.MD.DK.RE.attribute = function (fileordir, userid) {
- var _diskinfo = U.MD.DK.M.diskOperatingSwitch(userid),
- _attributeel = U.MD.DK.RE.attributeStyle(fileordir, true, _diskinfo); //用户属性框的样式
- U.UF.UI.alertClick(_attributeel);
- }
- /**
- * 用户属性框的样式
- * @param {object} 目录目录或者文件信息
- * @param {bool} 是否需要设置权限
- */
- U.MD.DK.RE.attributeStyle = function (fileordir, issetpermissions, diskinfo) {
- var _selected = 2;
- var _icon = U.MD.DK.C.getIcon(fileordir.UserDirectoryExtendType.toLowerCase())
- var _box = $$("div", { className: "U_MD_DK_fileInfo" });
- var _head = $$("div", { className: "U_MD_DK_fileInfo_head" }, _box);
- $$("div", { className: "U_MD_DK_fileInfo_line" }, _box);
- var _info = $$("div", { className: "U_MD_DK_fileInfo_info" }, _box);
- //图片样式设置
- if (U.UF.UP.isImg(fileordir.UserDirectoryExtendType)) {
- var _img = $$("div", { className: "U_MD_DK_fileInfo_img" }, _head);
- $$("img", { "onerror": U.MD.C.imgError, "src": U.MD.C.getHeadImage(fileordir.UserDirectoryUrl) }, _img);
- }
- else {
- $$("div", { className: "U_MD_DK_fileInfo_icon U_MD_DK_Img " + _icon.classname[1] }, _head);
- }
- $$("div", { style: { "cssText": "overflow:hidden;white-space: nowrap;text-overflow: ellipsis;line-height: 42px;padding-left:10px;" }, innerHTML: fileordir.UserallDirectoryName, "title": fileordir.UserallDirectoryName }, _head);
- //文件处理
- if (fileordir.filetype) {
- $$("div", { "innerHTML": "<span>类型:</span>文件" }, _info);
- $$("div", {
- "spellcheck": "false", "onselectstart": U.UF.EV.stopBubble,
- "innerHTML": "<span>路径:</span>" + "http://fs.1473.cn/" + fileordir["UserDirectoryID"] + ""
- }, _info);
- }
- else if (issetpermissions) {
- $$("div", { "innerHTML": "<span>类型:</span>" + "文件夹" }, _info);
- var _permission = $$("div", { "className": "", "innerHTML": "<span>权限选择:</span>" }, _info);
- var _select = $$("select", { "onchange": function () { U.MD.DK.RE.setpermissions(this, fileordir, diskinfo); } }, _permission);
- $$('option', { value: "1", innerHTML: "只允许上传" }, _select);
- $$('option', { value: "2", innerHTML: "只允许下载" }, _select);
- $$('option', { value: "", innerHTML: "无限制" }, _select);
- if (fileordir.UserDirectoryEncrypt == "1") {
- _selected = 0;
- }
- else if (fileordir.UserDirectoryEncrypt == "2") {
- _selected = 1;
- }
- U.selectEl('option', _select)[_selected].selected = true; //选中
- }
- $$("div", { "innerHTML": "<span>大小:</span>" + U.UF.UP.minUnitToMaxUnit(fileordir.UserDirectorySize) }, _info);
- $$("div", { "innerHTML": "<span>创建时间:</span>" + U.UF.D.getYearMonthDay(fileordir.UserDirectoryAddTime) }, _info);
- return _box;
- }
- /**
- * 共享文件夹设置权限
- * @param {element} 目录目录或者文件信息
- * @param {object} 是否需要设置权限
- */
- U.MD.DK.RE.setpermissions = function (selectel, dirinfo, diskinfo) {
- var _value = selectel.options[selectel.selectedIndex].value; //获取设置权限的值
- U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "SetFtpPriviledge", dirinfo.UserDirectoryID, _value], U.MD.DK.RE.asynSetPermissions, ["", dirinfo, _value, diskinfo]);
- U.alert("权限设置中...");
- }
- /**
- * 共享文件夹设置权限
- * @param {element} 目录目录或者文件信息
- * @param {object} 是否需要设置权限
- */
- U.MD.DK.RE.asynSetPermissions = function (r) {
- var _leftel,
- _rightel,
- _imgicon,
- _context = r.context,
- _dirinfo = _context[1], //文件夹信息
- _value = _context[2],
- _diskinfo = _context[3]; //加密的值
- r = r.value;
- //判断设置操作
- if (r) {
- _dirinfo.UserDirectoryEncrypt = _value; //设置加密的值
- _leftel = U.selectEl("#L" + _dirinfo.UserDirectoryID, _diskinfo.formel)[0]; //左边的导航,文件夹同时展开的时候会存在
- _rightel = U.selectEl("#R" + _dirinfo.UserDirectoryID, _diskinfo.formel)[0]; //右边文件或者文件夹的处理
- //左边的目录处理
- if (_leftel) {
- //加密的处理
- if (_value != "") {
- _imgicon = "U_MD_DK_LCOI U_MD_DK_LTXOST U_MD_DK_Img U_MD_DK_LCJ";
- }
- //未加密的处理
- else {
- _imgicon = "U_MD_DK_LCOI U_MD_DK_LTXOST U_MD_DK_Img U_MD_DK_LCW";
- }
- U.selectEl("div", _leftel)[2].className = _imgicon;
- }
- //右边的目录处理
- if (_rightel) {
- //加密的处理
- if (_value != "") {
- _imgicon = "U_MD_DK_RZOS U_MD_DK_Img U_MD_DK_RZOM";
- }
- //未加密的处理
- else {
- _imgicon = "U_MD_DK_RZOS U_MD_DK_Img U_MD_DK_RZOW";
- }
- U.selectEl("div", _rightel)[1].className = _imgicon;
- }
- }
- //设置权限或者加密解密
- else {
- U.alert("设置失败");
- }
- }
- //#endregion
- //#region 新建文件夹
- /**
- * 新建文件夹处理的新建提示框
- * @param {array} 需要删除文件的数组
- * @param {string} 用户id
- **/
- U.MD.DK.RE.addFileOrFolder = function (fileordirinfo, diskinfo, dirinfo) {
- var _nowdiskinfo = US.disk.UserDisk, //当前使用用户的网盘
- _leftel = U.selectEl("#L" + dirinfo["UserDirectoryID"], diskinfo.formel)[0],
- _el = U.selectEl("#U_MD_DK_RZ", diskinfo.formel)[0];
- //在粘贴网盘的数组目录中添加值
- U.MD.DK.M.entity.add(fileordirinfo, diskinfo); //添加到用户disk全局变量中
- U.MD.DK.M.entity.addChild(fileordirinfo, dirinfo); //添加到子节点中
- //操作的文件夹是否在异步结束后还在同一个文件夹下,如果是那么就添加
- if (fileordirinfo[0].UserDirectoryParentID == _nowdiskinfo.directoryid && diskinfo == _nowdiskinfo && _nowdiskinfo.directoryid == diskinfo.directoryid) {
- //如果里面没有内容是展示没有资源的处理
- if ($(_el).Child()[0].className == "U_MD_DK_RZF") {
- _el.innerText = "";
- }
- U.MD.DK.VW.printContent(fileordirinfo, _el); //打印到网盘中
- //添加到侧边栏
- if (_leftel) {
- U.MD.DK.LL.printLeftTreeDirectory(fileordirinfo, _leftel, diskinfo.userInfo.UserId); //如果左边数目显示了
- }
- }
- _el.scrollTop = _el.offsetHeight;
- U.selectEl(_el.lastChild).addClass("U_MD_DK_RZOI");
- }
- /**
- * 新建文件夹处理
- **/
- U.MD.DK.RE.newFolder = function (diskinfo) {
- if (!U.MD.U.L.isLogin()) {//是否登录
- var _directoryid = diskinfo.directoryid//目录id
- if (U.MD.DK.C.getDirectoryPermissions(_directoryid, diskinfo).isnew) {//新建文件权限
- U.MD.DK.RE.newFolder.confirm(diskinfo, _directoryid); //新建提示框
- }
- else { U.alert("无权限访问此文件夹"); }; /// <reference path="../../robots.txt" />
- }
- }
- /**
- * 新建文件夹处理的新建提示框
- * @param {array} 需要删除文件的数组
- * @param {string} 用户id
- **/
- U.MD.DK.RE.newFolder.confirm = function (diskinfo, directoryid) {
- var _ancestors, //目录的祖先元素
- _groupid, //群id
- _newguid = Guid.newGuid(), //新建文件夹的id
- _dirinfo = U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": directoryid })[0], //目录网盘信息
- _userid = US.userInfo.UserId, //新建用户id
- _input = $$("input", { "placeholder": "请输入文件夹名字", "style": { "width": "180px", "height": "25px" } }) //输入的名字
- //弹出comfir
- U.MD.DK.RE.newconfirm(
- _input,
- function () {
- var _name = _input.value;
- //获取粘贴到制定目录的群id
- _ancestors = U.MD.DK.C.getAncestors(_dirinfo, diskinfo); //获取所有的祖先
- //如果是ftp目录,那么groupid就是用户id
- if (_ancestors[_ancestors.length - 1].UserDirectoryID == US.FTPFOLDERID) {
- _groupid = diskinfo.userInfo.UserId;
- }
- //否则就是对应的群id,如果不存在那么就是""
- else {
- _groupid = _ancestors[_ancestors.length - 1].GroupID || "";
- }
- //文件名判断
- if (U.UF.S.ZWFileName.test(_input.value)) {
- //填写文件名符合规范 将文件夹以及文件夹名字保存到数据库
- U.A.Request(US.DISK, ["CreateDirectory", _userid, _newguid, _dirinfo.UserDirectoryDeep + 1, _input.value, directoryid, "", _groupid, ""], //保存到数据库
- function (r) {
- var _fileinfo = new U.MD.DK.M.entity(_newguid, 0, directoryid, _name, _name, "folder", "", U.UF.D.toTimeStamp(), "", _dirinfo.UserDirectoryDeep + 1,
- null, "", 0, "", _groupid, "", _userid, US.userInfo.UserNickName, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead)
- U.MD.DK.RE.addFileOrFolder([_fileinfo], diskinfo, _dirinfo); //添加到页面上中
- }, []);
- }
- else {
- U.alert("文件名过长或者为空");
- return false;
- }
- },
- function () { },
- "新建文件夹"
- );
- }
- /**
- * 新建文件处理
- **/
- U.MD.DK.RE.newText = function (diskinfo, fun) {
- if (!U.MD.U.L.isLogin()) {//是否登录
- var _directoryid = diskinfo.directoryid; //目录id
- if (U.MD.DK.C.getDirectoryPermissions(_directoryid, diskinfo).isnew) {//新建文件权限
- top.U.MD.DK.VW.chosenSaveFile('txt', null, '新建文件', fun); //新建提示框
- }
- else { U.alert("无权限访问此文件"); };
- }
- }
- /**
- * 新建文件处理的新建提示框
- **/
- U.MD.DK.RE.newText.confirm = function (diskinfo, directoryid, fun) {
- var _ancestors, //目录的祖先元素
- _groupid, //群id
- _newguid = Guid.newGuid(), //新建文件夹的id
- _dirinfo = U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": directoryid })[0], //目录网盘信息
- _userid = US.userInfo.UserId, //新建用户id
- _input = $$("input", { "placeholder": "请输入新文本文档的命名", "style": { "width": "180px", "height": "25px", "padding-left": "7px" } }); //输入的名字
- //弹出comfirm
- U.MD.DK.RE.newconfirm(_input,
- function () {
- var _name = _input.value;
- //获取粘贴到制定目录的群id
- _ancestors = U.MD.DK.C.getAncestors(_dirinfo, diskinfo); //获取所有的祖先
- //如果是ftp目录,那么groupid就是用户id
- if (_ancestors[_ancestors.length - 1].UserDirectoryID == US.FTPFOLDERID) {
- _groupid = diskinfo.userInfo.UserId;
- }
- //否则就是对应的群id,如果不存在那么就是""
- else {
- _groupid = _ancestors[_ancestors.length - 1].GroupID || "";
- }
- //文件名判断
- if (U.UF.S.ZWFileName.test(_input.value)) {
- //去数据库添加文件
- U.A.Request(US.DISK, ["CreateFile", _userid, _newguid, directoryid, _input.value, "", "", "", "txt", _groupid], function (r) {
- //创建文件
- var _fileinfo = new U.MD.DK.M.entity(_newguid, 0, directoryid, _name, _name, "txt", "", U.UF.D.toTimeStamp(), "", "9999", null, "", 1, "", _groupid, "", _userid, US.userInfo.UserNickName, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead)
- U.MD.DK.RE.addFileOrFolder([_fileinfo], diskinfo, _dirinfo); //添加到页面上中
- //如果存在就执行
- if (fun) {//判断是否有点击事件的方法,如果有,运行它
- fun(_fileinfo);
- }
- }, []);
- }
- else {
- U.alert("文件名过长或者为空");
- return false;
- }
- },
- function () { }, "新建文本文件");
- }
- /**
- * 新建文档处理
- **/
- U.MD.DK.RE.newDocument = function (diskinfo, fun, fileid) {
- if (!U.MD.U.L.isLogin()) {//是否登录
- var _directoryid = diskinfo.directoryid; //目录id
- if (U.MD.DK.C.getDirectoryPermissions(_directoryid, diskinfo).isnew) {//新建文档权限
- return U.MD.DK.RE.newDocument.confirm(diskinfo, _directoryid, fun, fileid);
- }
- else { U.alert("无权限访问此文档"); };
- }
- }
- /**
- * 新建文档处理的新建提示框
- **/
- U.MD.DK.RE.newDocument.confirm = function (diskinfo, directoryid, fun, fileid) {
- var _ancestors, //目录的祖先元素
- _groupid, //群id
- _newguid = fileid || Guid.newGuid(), //新建文件夹的id
- _dirinfo = U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": directoryid })[0], //目录网盘信息
- _userid = US.userInfo.UserId, //新建用户id
- _input = $$("input", { "placeholder": "请输入文档名字", "style": { "width": "180px", "height": "25px" } }); //输入的名字
- return U.MD.DK.RE.newconfirm(_input, //创建文档的框
- function () {
- var _name = _input.value;
- //获取粘贴到制定目录的群id
- _ancestors = U.MD.DK.C.getAncestors(_dirinfo, diskinfo); //获取所有的祖先
- //如果是ftp目录,那么groupid就是用户id
- if (_ancestors[0].UserDirectoryID == US.FTPFOLDERID) {
- _groupid = diskinfo.userInfo.UserId;
- }
- //否则就是对应的群id,如果不存在那么就是""
- else {
- _groupid = _ancestors[0].GroupID || "";
- }
- //文件名判断
- if (U.UF.S.ZWFileName.test(_input.value)) {
- //去数据库添加文件
- U.A.Request(US.DISK, ["CreateFile", _userid, _newguid, directoryid, _input.value, "", "", "", "uw", _groupid], function (r) {
- //创建文件
- var _fileinfo = new U.MD.DK.M.entity(_newguid, 0, directoryid, _name, _name, "uw", "", U.UF.D.toTimeStamp(), "", "9999", null, "", 1, "", _groupid, "", _userid, US.userInfo.UserNickName, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead)
- U.MD.DK.RE.addFileOrFolder([_fileinfo], diskinfo, _dirinfo); //添加到页面上中
- //如果存在就执行
- if (fun) {//判断是否保存到数据库
- fun(_fileinfo);
- }
- }, []);
- }
- else {
- U.alert("文件名过长或者为空");
- return false;
- }
- }, function () { }, "新建文档");
- }
- U.MD.DK.RE.newopenApplication = function (diskinfo, fun, fileid) {
- if (!U.MD.U.L.isLogin()) {//是否登录
- var _directoryid = diskinfo.directoryid; //目录id
- if (U.MD.DK.C.getDirectoryPermissions(_directoryid, diskinfo).isnew) {//新建文档权限
- return U.MD.DK.RE.newopenApplication.confirm(diskinfo, _directoryid, fun, fileid);
- }
- else { U.alert("无权限访问此文档"); };
- }
- }
- U.MD.DK.RE.newopenApplication.confirm = function (diskinfo, _directoryid, fun, fileid) {
- var _ancestors, //目录的祖先元素
- _groupid, //群id
- _taskbar, //_taskbar 作为任务栏显示的元素,包含图标和名字
- _formdiv, //创建任务栏时同时弹出的窗体元素。
- _newguid = fileid || Guid.newGuid(), //新建文件夹的id
- _dirinfo = U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": _directoryid })[0], //目录网盘信息
- _userid = US.userInfo.UserId, //新建用户id
- _input = $$("input", { "placeholder": "请输入文档名字", "style": { "width": "180px", "height": "25px" } }); //输入的名字
- U.MD.DK.RE.newconfirm(_input, //创建文档的框
- function () {
- var _name = _input.value;
- //获取粘贴到制定目录的群id
- _ancestors = U.MD.DK.C.getAncestors(_dirinfo, diskinfo); //获取所有的祖先
- //如果是ftp目录,那么groupid就是用户id
- if (_ancestors[0].UserDirectoryID == US.FTPFOLDERID) {
- _groupid = diskinfo.userInfo.UserId;
- }
- //否则就是对应的群id,如果不存在那么就是""
- else {
- _groupid = _ancestors[0].GroupID || "";
- }
- //文件名判断
- if (U.UF.S.ZWFileName.test(_input.value)) {
- //去数据库添加文件
- U.A.Request(US.DISK, ["CreateFile", _userid, _newguid, _directoryid, _input.value, "", "", "", "un", _groupid], function (r) {
- //创建文件
- var _fileinfo = new U.MD.DK.M.entity(_newguid, 0, _directoryid, _name, _name, "un", "", U.UF.D.toTimeStamp(), "", "9999", null, "", 1, "", _groupid, "", _userid, US.userInfo.UserNickName, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead)
- _fileinfo.UserDirectoryExtendType = 'un';
- _fileinfo.UsOffice = U.A.Request(US.CD, ([US.DB, "UseStudio_Disk",
- "GetFileContent", "6a8a235a-41c4-c3d2-8dd5-b6ee851e1967"])).value[0].UsOffice.unEscapeQuotes();
- _fileinfo.newfile = true;
- U.MD.DK.RE.addFileOrFolder([_fileinfo], diskinfo, _dirinfo); //添加到页面上中
- //U.MD.D.I.openApplication("word",{ UserDirectoryExtendType: "un" });
- //如果存在就执行
- if (fun) {//判断是否保存到数据库
- fun(_fileinfo);
- }
- }, []);
- }
- else {
- U.alert("文件名过长或者为空");
- return false;
- }
- }, function () { }, "新建导航文档");
- }
- /**
- * 新建工作表处理
- **/
- U.MD.DK.RE.newExcel = function (diskinfo) {
- if (!U.MD.U.L.isLogin()) {//是否登录
- var _directoryid = diskinfo.directoryid; //目录id
- if (U.MD.DK.C.getDirectoryPermissions(_directoryid, diskinfo).isnew) {//新建工作表权限
- U.MD.DK.RE.newExcel.confirm(diskinfo, _directoryid); //新建提示框
- }
- else { U.alert("无权限访问此工作表"); };
- }
- }
- /**
- * 新建工作表处理的新建提示框
- **/
- U.MD.DK.RE.newExcel.confirm = function (diskinfo, directoryid) {
- var _ancestors, //目录的祖先元素
- _groupid, //群id
- _newguid = Guid.newGuid(), //新建文件夹的id
- _dirinfo = U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": directoryid })[0], //目录网盘信息
- _userid = US.userInfo.UserId, //新建用户id
- _input = $$("input", { "placeholder": "请输入表格名字", "style": { "width": "180px", "height": "25px" } }); //输入的名字
- U.MD.DK.RE.newconfirm(_input, //创建文档的框
- function () {
- var _name = _input.value;
- //获取粘贴到制定目录的群id
- _ancestors = U.MD.DK.C.getAncestors(_dirinfo, diskinfo); //获取所有的祖先
- //如果是ftp目录,那么groupid就是用户id
- if (_ancestors[_ancestors.length - 1].UserDirectoryID == US.FTPFOLDERID) {
- _groupid = diskinfo.userInfo.UserId;
- }
- //否则就是对应的群id,如果不存在那么就是""
- else {
- _groupid = _ancestors[_ancestors.length - 1].GroupID || "";
- }
- //文件名判断
- if (U.UF.S.ZWFileName.test(_input.value)) {
- //去数据库添加文件
- U.A.Request(US.DISK, ["CreateFile", _userid, _newguid, directoryid, _input.value, "", "", "", "ue", _groupid], function (r) {
- //创建文件
- var _fileinfo = new U.MD.DK.M.entity(_newguid, 0, directoryid, _name, _name, "ue", "", U.UF.D.toTimeStamp(), "", "9999", null, "", 1, "", _groupid, "", _userid, US.userInfo.UserNickName, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead)
- U.MD.DK.RE.addFileOrFolder([_fileinfo], diskinfo, _dirinfo); //添加到页面上中
- }, []);
- }
- else {
- U.alert("文件名过长或者为空");
- return false;
- }
- }, function () { }, "新建工作表");
- }
- /**
- * 新建文件对话框
- * @content {string/elemnet} 内容
- * @determineFun {function} 确认回调函数
- * @cancelFun {function} 取消回调函数
- * @string {string} 对话框的标题名字
- */
- U.MD.DK.RE.newconfirm = function (content, determineFun, cancelFun, str) {
- //创建对话框主体元素
- var _confirm = $$("div", { "style": { "cssText": "width: 100%; background: rgb(255,255,255); overflow:hidden; " }, id: "123133456" });
- var _string = str || "提示框";
- //创建内容区域
- var _content = $$("div", { "style": { "cssText": "text-align: center; margin: 30px 20px 30px 20px; " } }, _confirm);
- //判断内容是否为元素
- if (U.UF.C.isElement(content)) {
- //如果为元素则动态添加到对话框中
- U.selectEl(_content).append(content);
- } else {
- //如果为文字则修改inerHTML。
- _content.innerHTML = content || '内容';
- }
- //创建页脚部分
- var _footer = $$("div", { "style": { "cssText": " height:45px;" } }, _confirm);
- //调用Uform窗体创建函数将主体内容添加到窗体中
- var _form = new U.UF.UI.form(
- _string,
- _confirm,
- {
- 'className': 'U_MD_DK_RE_confirmForm',
- "style": {
- "cssText": "font-size: 16px; background: rgb(255,255,255); width: 300px; position: fixed; box-shadow: 0 0 10px 3px rgb(0,0,0); border-radius: 5px;"
- }
- },
- {
- "istop": true,
- "isenlarge": false,
- "isstretching": false,
- "isnarrow": false
- },
- {
- "style": {
- "cssText": " background: rgb(59,88,120); padding: 10px;padding-left: 20px; color: rgb(255,255,255); "
- }
- });
- //创建确定按钮 绑定点击事件,默认点击后执行关闭窗体函数
- $$("div", {
- "style": {
- "cssText": "text-align: center; color: rgb(255,255,255); width: 30%; padding: 5px; background: rgb(48,126,208); border-radius: 5px;float: right; margin-right:35px;"
- },
- innerHTML: "确定",
- onclick: function () {
- var _bool = true;
- if (U.UF.C.isFunction(determineFun)) {
- _bool = determineFun(); //判断是否存在回调 有则执行。
- }
- if (_bool !== false) {
- U.UF.F.closeWindow(_form.form); //关闭窗口函数
- }
- }
- }, _footer);
- content.onkeydown = function (e) { //input键盘按键事件
- var ev = document.all ? window.event : e;
- if (ev.keyCode == 13) { //当按下回车时触发 确定按钮点击事件
- if ($('.U_MD_DK_RE_confirmForm').length > 0) {
- for (var i = 0; i < U.selectEl('.U_MD_DK_RE_confirmForm').length; i++) {
- if ($('.U_MD_DK_RE_confirmForm')[i].style.display == "block") { //检查新建文档窗体是否显示
- var _bool = true;
- if (U.UF.C.isFunction(determineFun)) {
- _bool = determineFun(); //判断是否存在回调 有则执行。
- }
- if (_bool !== false) {
- U.UF.F.closeWindow(_form.form); //关闭窗口函数
- }
- }
- }
- }
- }
- }
- //创建取消按钮 绑定点击事件,默认点击后执行关闭窗体函数
- $$("div", {
- "style": {
- "cssText": "text-align: center; color: rgb(255,255,255); width: 30%; padding: 5px; background: rgb(48,126,208); border-radius: 5px;background: rgb(170,170,170); float: left; margin-left:35px;"
- },
- "innerHTML": "取消",
- "onclick": function () {
- U.UF.C.isFunction(cancelFun) && cancelFun(); //判断是否存在回调 有则执行。
- U.UF.F.closeWindow(_form.form); //关闭窗口函数
- }
- }, _footer);
- content.focus(); //输入框焦点聚集
- return _form;
- }
- /**
- * 新建互联办公文件对话框
- * @determineFun {function} 确认回调函数
- * @cancelFun {function} 取消回调函数
- */
- U.MD.DK.RE.newDocConfirm = function (diskinfo/*determineFun cancelFun*/) {
- if (!U.MD.U.L.isLogin()) {//是否登录
- var _directoryid = diskinfo.directoryid; //目录id
- if (U.MD.DK.C.getDirectoryPermissions(_directoryid, diskinfo).isnew) {//新建工作表权限
- var _confirm = $$('div'),
- _pickarea = $$("div", { "style": { "cssText": "display:table; width: 100%; height: auto; " } }, _confirm),
- _picklocal = $$("div", { "id": "U_MD_DK_RE_localDoc", "style": { "cssText": "display:table-cell; width:235px; height:170px; background-color:#f5f5f5;text-align:center; vertical-align: middle;cursor: pointer;" } }, _pickarea),
- _pickline = $$("div", { "style": { "cssText": "display:table-cell; width:1px; height: 100%; background-color:#cecece;" } }, _pickarea),
- _pickoa = $$("div", { "style": { "cssText": "display:table-cell; width:234px; height:100%; background-color:#f5f5f5;text-align:center; vertical-align: middle;cursor: pointer;" } }, _pickarea);
- $$("img", { "onerror": U.MD.C.imgError, src: "/img/officefileicon.png", style: { "vertical-align": "middle" } }, _picklocal);
- $$("img", { "onerror": U.MD.C.imgError, src: "/img/oaofficeicon.png", style: { "vertical-align": "middle" } }, _pickoa);
- $$('span', { innerText: '互联文档', style: { "margin-left": "10px" } }, _pickoa);
- $$('span', { innerText: '本地文档', style: { "margin-left": "10px" } }, _picklocal);
- //创建对话框主体元素
- var _enter = $$("div", { "style": { "cssText": "width: 100%; background: rgb(255,255,255); overflow:hidden; display:none" }, id: "123133456" }, _confirm);
- var _string = "新建文档";
- //创建内容区域
- var _content = $$("div", { "style": { "cssText": "text-align: center; margin: 30px 20px 30px 20px;" } }, _enter)
- //创建页脚部分
- var _footer = $$("div", { "style": { "cssText": " height:45px;" } }, _enter);
- //调用Uform窗体创建函数将主体内容添加到窗体中
- var _form = new U.UF.UI.form(
- _string,
- _confirm,
- {
- "style": {
- "cssText": "font-size: 16px; background: rgb(255,255,255); width: 470px; position: fixed; box-shadow: rgb(0, 0, 0) 2px 1px 5px; "
- }
- },
- {
- "istop": true,
- "isenlarge": false,
- "isstretching": false,
- "isnarrow": false
- },
- {
- "style": {
- "cssText": " background: #3c475b;padding:4px 0 ; color: rgb(255,255,255); "
- }
- });
- U.selectEl(_picklocal).bind({
- "mouseover": function () { _picklocal.style.backgroundColor = "#dcdcdc"; }, "mouseout": function () { _picklocal.style.backgroundColor = "#f5f5f5"; }, "click": function () {
- U.MD.DK.RE.newDocument(diskinfo);
- U.UF.F.closeWindow(_form.form, "remove");
- }
- })
- U.selectEl(_pickoa).bind({
- "mouseover": function () { _pickoa.style.backgroundColor = "#dcdcdc"; }, "mouseout": function () { _pickoa.style.backgroundColor = "#f5f5f5"; }, "click": function () {
- // U.selectEl('#U_UF_UI_confirm')[0].style.display = "none";
- var _docId = Guid.newGuid();
- U.MD.O.word(US.userInfo, { 'UserDirectoryID': _docId }, function () {
- var _iframe = U.selectEl('#UD_Word' + _docId).find('iframe')[0].contentWindow;
- _iframe.document.getElementById('U_MD_O_H_body_left_invite_user').children[0].click();
- U.UF.F.closeWindow(_form.form, "remove");
- });
- }
- })
- return _form;
- }
- else { U.alert("无权限访问此工作表"); };
- }
- }
- //#endregion
- //#region 删除文件
- /**
- * 删除文件
- *
- * @param {array} 需要删除文件的数组
- * @param {string} 用户id
- */
- U.MD.DK.RE.deleteFileOrDir = function (fileordirs, userid, diskinfo) {
- var _contentel, _fileordir;
- //多文件删除
- if (fileordirs.length > 1) {
- _contentel = $$("div", { "style": { "cssText": "text-align:center;width:100%;height:30px;padding:5% 0 0% 0;" } });
- $$("span", { "style": { "cssText": "font-weight:bold;" }, "innerHTML": "你确定要删除这" + fileordirs.length + "项吗?" }, _contentel);
- U.UF.UI.confirm(_contentel, function () {//弹出多选判断框
- _fileordir = true; //定义变量_fileordir的初始值,为true
- for (var i = 0; i < fileordirs.length; i++) {//开始循环,循环对象为多选后的文件对象
- if (fileordirs[i].UserDirectoryExtendType == "folder") {//判断是否有文件夹,如果有
- U.alert("删除失败,多选无法删除文件夹"); //弹出提示,方法结束
- _fileordir = false; //修改变量的值
- }
- }
- if (_fileordir == true) {//通过判断变量_fileordir的值,判断是否可以删除,如果可以
- U.MD.DK.RE.deleteDirectoryOrFile(fileordirs, userid); //调用接口,进行删除
- }
- })
- }
- //单文件处理
- else {
- U.A.Request(US.DISK, ["GetChildsByDirectoryId", userid, fileordirs.UserDirectoryID, ""], function (r) {//调用接口,在后台查找这个文件有没有附属文件
- if (r.value.length == 0) {//如果没有
- _contentel = U.MD.DK.RE.attributeStyle(fileordirs, null, diskinfo);
- fileordirs = [fileordirs];
- //弹出提示框,确认后删除文件
- U.UF.UI.confirm(_contentel, function () {
- U.MD.DK.RE.deleteDirectoryOrFile(fileordirs, userid);
- });
- } else {//如果有
- U.alert("删除失败,请先清除文件夹中的文件"); //弹出提示,方法结束
- }
- });
- }
- }
- /**
- * 删除文件接口
- *
- * @param {array} 需要删除文件的数组
- * @param {string} 用户id
- */
- U.MD.DK.RE.deleteDirectoryOrFile = function (fileordirs, userid) {
- var _allfileordirid = U.Json.toKeyArray(fileordirs, "UserDirectoryID").join(","); //所有删除的文件和文件夹的合并id
- U.A.Request(US.DISK, ["DeleteDirectoryOrFile", _allfileordirid, fileordirs[0].GroupID || ""], U.MD.DK.RE.asynDeleteDirectoryOrFile, ["", fileordirs, userid]); //文件夹和文件同时删除
- }
- /**
- * 删除文件异步
- *
- * @param {array} 需要删除文件的数组
- * @param {string} 用户id
- */
- U.MD.DK.RE.asynDeleteDirectoryOrFile = function (r) {
- var i,
- _dirid,
- _context = r.context,
- _fileordirs = _context[1], //文件或者是文件夹信息
- _userid = _context[2], //用户id
- _diskinfo = U.MD.DK.M.diskOperatingSwitch(_userid) //获取用户硬盘的信息
- ;
- r = r.value;
- //允许删除
- if (r) {
- U.MD.DK.M.entity.del(_fileordirs, _diskinfo); //删除diskinfo数组里面的文件或者文件夹
- U.MD.DK.RE.delPageFileOrDir(_fileordirs, _diskinfo); //删除文件在页面上的元素
- }
- else {
- U.alert("操作失败!"); //弹出操作失败
- }
- }
- /**
- * 删除文件在页面上的显示
- *
- * @param {array} 文件或者是目录
- * @param {string} 删除用户网盘的信息
- */
- U.MD.DK.RE.delPageFileOrDir = function (fileordirs, diskinfo) {
- var i,
- _parentdirinfo,
- _contentel = U.selectEl("#U_MD_DK_RZ", diskinfo.formel); //中间的内容
- //循环文件或者文件夹处理
- for (i = 0; i < fileordirs.length; i++) {
- U.selectEl("#L" + fileordirs[i].UserDirectoryID, diskinfo.formel).remove(); //移除左边的导航
- U.selectEl("#R" + fileordirs[i].UserDirectoryID, diskinfo.formel).remove(); //移除右边的文件或者文件夹
- //判断删除的位置是否是当前打开的位置,如果是则保持
- if (fileordirs[i].UserDirectoryID == diskinfo.directoryid) {
- _parentdirinfo = fileordirs[i].Parent;
- }
- }
- //如果删除的位置是当前打开的位置
- if (_parentdirinfo) {
- //重新打印
- U.MD.DK.LE.openFileDirectory(_parentdirinfo, diskinfo.userInfo.UserId);
- }
- //如果文件或者文件夹给全部删除,那么就打印空视图
- else if (_contentel.Child() == 0) {
- U.MD.DK.VW.printNullView(_contentel[0]); //重新打印空视图
- }
- U.selectEl('#U_MD_DK_RKR', diskinfo.formel)[0].innerHTML = '当前文件的数量:' + U.selectEl('.U_MD_DK_RZO').length//删除之后当前文件的数量正确显示
- }
- //#endregion
- //#region 重命名
- /**
- * 删除文件在页面上的元素
- *
- * @param {element} 元素
- * @param {string} 用户id
- */
- U.MD.DK.RE.rename = function (el, fileordir, diskinfo) {
- var _input, _el; //创建一个可输入的input标签
- if (el.firstChild.children[1]) {//判断是否在左边菜单栏插入
- _el = el.firstChild.children[1].children[0]; //插入地方
- _el.innerText = ""//清除原文件名,并在上面设置一个input输出框
- } else {
- _el = el.lastElementChild; //插入地方
- _el.innerText = ""//清除原文件名,并在上面设置一个input输出框
- }
- _input = $$("input", {//创建input框
- "ondblclick": U.UF.EV.stopBubble, //阻止冒泡
- "onblur": function () {//失焦
- U.MD.DK.RE.detemineReName(this, fileordir, diskinfo); //确定修改
- },
- //回车会理
- "onkeyup": function () {
- if (event.keyCode == 13 || event.keyCode == 10) {
- this.onblur(); //失焦
- }
- },
- "onclick": U.UF.EV.stopBubble, //阻止冒泡
- "className": "U_MD_U_P_C_P_N_I", //设置class
- "value": fileordir.UserallDirectoryName.replace("." + fileordir.UserDirectoryExtendType, "")//文件名+后缀
- }, _el); //在哪里插入
- _input.focus(); //聚焦到重命名的input框上面
- }
- /**
- * 確定修改文件名
- *
- * @param {element} 元素
- * @param {string} 用户id
- */
- U.MD.DK.RE.detemineReName = function (inputel, fileordir, diskinfo) {
- var _leftel,
- _rightel,
- _extendtype = fileordir.UserDirectoryExtendType, //文件扩展名
- _name = inputel.value.replaceHtmlSign() + (fileordir.filetype ? "." + _extendtype : ""); //文件或者文件夹的名字
- //修改的名字没有变化
- if (_name != fileordir.UserallDirectoryName) {
- //判断文件名输入符不符合规范
- if (U.UF.S.FileName.test(_name)) {
- //目录的处理
- if (_extendtype == "folder") {
- U.A.Request(US.DISK, ["UpdateDirectoryInfo", fileordir.UserDirectoryID, _name], U.MD.DK.RE.asynDetemineReName, ["", fileordir, _name, diskinfo]);
- }
- //文件的处理
- else {
- U.A.Request(US.DISK, ["UpdateFileInfo", fileordir.UserDirectoryID, _name], U.MD.DK.RE.asynDetemineReName, ["", fileordir, _name, diskinfo]);
- }
- _leftel = U.selectEl("#L" + fileordir.UserDirectoryID, diskinfo.formel)[0]; //左边的导航,文件夹同时展开的时候会存在
- _rightel = U.selectEl("#R" + fileordir.UserDirectoryID, diskinfo.formel)[0]; //右边文件或者文件夹的处理
- //左边的目录处理
- if (_leftel) {
- U.selectEl("div", _leftel)[3].innerText = _name;
- }
- //右边的目录处理
- if (_rightel) {
- U.selectEl("div", _rightel)[3].innerText = _name;
- }
- }
- }
- }
- /**
- * 確定修改文件名
- *
- * @param {element} 元素
- * @param {string} 用户id
- */
- U.MD.DK.RE.asynDetemineReName = function (r) {
- var _context = r.context,
- _fileordir = _context[1], //文件或者文件夹信息
- _name = _context[2] //文件名
- ;
- r = r.value;
- //判断服务器修改是否成功的处理,处理成功后修改文件的信息
- if (r) {
- _fileordir.UserallDirectoryName = _name; //文件全写的名字
- _fileordir.UserDirectoryName = _name.addEllipsis(20); //文件的缩略名
- }
- }
- //#endregion
- //#region 复制 剪切 粘贴
- /**
- * 删除文件在页面上的元素
- *
- * @param {array} 复制粘贴的元素
- * @param {string} 粘贴的格式
- */
- U.MD.DK.RE.copyorshear = function (dirorfile, type, diskinfo) {
- var _userid = US.disk.UserDisk.userInfo.UserId, //用户id
- _dirid = dirorfile.UserDirectoryParentID //复制的目录id
- ;
- //复制的目录转化成数组
- if (!Array.isArray(dirorfile)) {
- dirorfile = [dirorfile];
- }
- //添加复制的全局变量
- US.disk.Disks[_userid].pasteDirOrFile = {
- "type": type, //复制或者剪切 "copy" || "shear"
- "UserDirectoryID": _dirid, //在哪个目录复制或者剪切
- "dirorfile": dirorfile, //复制的内容
- "userid": _userid //用户id
- };
- }
- /**
- * 粘贴文件
- *
- * @param {array} 复制粘贴的元素
- * @param {string} 粘贴的格式
- */
- U.MD.DK.RE.paste = function (diskinfo) {
- var _ancestors, //祖先元素
- _groupid, //群元素
- _fileordirids, //文件和目录的id集合
- _dirid = diskinfo.directoryid, //当前目录id
- _dirinfo = U.Json.select(diskinfo.directoryOrFiles, { "UserDirectoryID": _dirid }, 1)[0], //当前目录的信息
- _userid = US.disk.UserDisk.userInfo.UserId, //用户id
- _pastecontent = US.disk.Disks[_userid].pasteDirOrFile, //粘贴的内容
- _type = _pastecontent.type, //粘贴的格式
- _pastedirid = _pastecontent.UserDirectoryID, //粘贴目录id
- _dirorfile = _pastecontent.dirorfile, //粘贴文件和目录的数组
- _pasteuserid = _pastecontent.userid //祖先元素
- ;
- //需要剪切的内容存在,无需判断权限了,能触发改函数说明是有权限的。 如果剪切文件,同时不是剪切到同一个目录里
- if (_pastecontent && (_type == "copy" || _dirid != _pastedirid || _pasteuserid != _userid)) { // && (_dirid != _pastedirid || _pasteuserid != _userid)
- //获取粘贴到制定目录的群id
- _ancestors = U.MD.DK.C.getAncestors(_dirinfo, diskinfo); //获取所有的祖先
- //如果是ftp目录,那么groupid就是用户id
- if (_ancestors[_ancestors.length - 1].UserDirectoryID == US.FTPFOLDERID) {
- _groupid = diskinfo.userInfo.UserId;
- }
- //否则就是对应的群id,如果不存在那么就是""
- else {
- _groupid = _ancestors[_ancestors.length - 1].GroupID || "";
- }
- _fileordirids = U.Json.toKeyArray(_dirorfile, "UserDirectoryID").join(","); //文件
- //处理粘贴在数据库的过程
- //剪切的处理
- if (_type == "shear") {
- //调用剪切的函数 用户ID 粘贴目录id 文件和目录的id集合 群元素
- U.A.Request(US.DISK, ["CutAndPasteFiles", US.userInfo.UserId, _dirid, _fileordirids, _groupid, _dirorfile[0].GroupID], U.MD.DK.RE.asynPaste, ["", _dirinfo, _groupid, _pastecontent, diskinfo, _pastecontent.type]);
- _pastecontent.type = "copy";
- }
- //复制的处理
- else {
- //调用复制的函数
- U.A.Request(US.DISK, ["CopyAndPasteFiles", US.userInfo.UserId, _dirid, _fileordirids, _groupid], U.MD.DK.RE.asynPaste, ["", _dirinfo, _groupid, _pastecontent, diskinfo, _pastecontent.type]);
- }
- }
- }
- /**
- * 粘贴文件
- *
- * @param {object} ajax的传参处理
- */
- U.MD.DK.RE.asynPaste = function (r) {
- var i,
- _context = r.context, //上线文的传参
- _dirinfo = _context[1], //粘贴到制定的目录
- _groupid = _context[2], //粘贴的群id
- _pastecontent = _context[3], //粘贴的文件或者文件夹内容
- _diskinfo = _context[4], //粘贴的网盘信息
- _type = _context[5], //判断是复制还是剪切
- _copyorshearinfo = US.disk.Disks[_pastecontent.userid], //粘贴网盘的信息
- _pasteinfo = r.value //目录信息
- ;
- //剪切处理的话,先要移除原本的文件,然后在重新处理
- if (_type == "shear") {
- U.MD.DK.M.entity.del(_pastecontent.dirorfile, _copyorshearinfo); //在制定的用户中移除
- U.MD.DK.RE.delPageFileOrDir(_pastecontent.dirorfile, _copyorshearinfo); //剪切的话会在之前目录里面删除
- }
- //循环设置粘贴文件的属性
- for (i = 0; i < _pasteinfo.length; i++) {
- _pasteinfo[i] = new U.MD.DK.M.entity(_pasteinfo[i].UserDirectoryID, _pasteinfo[i].UserDirectorySize, _pasteinfo[i].UserDirectoryParentID, _pasteinfo[i].UserDirectoryName, _pasteinfo[i].UserDirectoryName, _pasteinfo[i].UserDirectoryExtendType, _pasteinfo[i].UserDirectoryUrl, _pasteinfo[i].UserDirectoryAddTime, _pasteinfo[i].UserDirectoryUrl, _pasteinfo[i].UserDirectoryDeep, null, _pasteinfo[i].UserDirectoryEncrypt, _pasteinfo[i].UserDirectoryExtendType == "folder" ? 0 : 1, "", _pasteinfo[i].UserDirectoryEncrypt, "", US.userInfo.UserId, US.userInfo.UserNickName, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead)
- }
- //在粘贴网盘的数组目录中添加值
- U.MD.DK.RE.addFileOrFolder(_pasteinfo, _diskinfo, _dirinfo);
- }
- //#endregion
- //#region 文件下载
- //弹出下载的处理
- U.MD.DK.RE.downloadFile = function (dirorfileid, isdir) {
- window.open("/Pages/Download.htm?id=" + dirorfileid + "&type=" + (isdir || ""));
- }
- //#endregion
- //#region 查看评论
- /**
- * 查看评论
- *
- * @param {object} 文件信息
- */
- U.MD.DK.RE.replay = function (fileinfo) {
- // U.MD.I.Img(UDE, UDE);
- // U.MD.D.CM.CKPLXS(UDE.UserDirectoryID, UDE.UserallDirectoryName);
- }
- //#endregion
- //#region 刷新
- /**
- * 刷新
- *
- * @param {string} 用户id
- * @param {object} 目录信息
- */
- U.MD.DK.RE.refresh = function (userid, fileinfo, diskinfo) {
- //如果文档不是最新文档、我的协同、他人邀请的处理
- if (fileinfo.GroupID !== true) {
- U.MD.DK.LE.getChildsByDirectoryId(userid, fileinfo, U.selectEl("#U_MD_DK_RZ", diskinfo.formel)[0]); //加载当前网盘内容
- }
- }
- //#endregion
- ;
- ///<jscompress sourcefile="RightMenu.js" />
- //--------------------------------------------------------------右键菜单----------------------------------------------------------------------
- Namespace.register("U.MD.DK.RM"); //Disk的右键命名空间
- //#region 右键查看处理
- /**
- * 右键菜单弹出
- *
- **/
- U.MD.DK.RM.rightMenu = function (el, fileordir, diskinfo) {
- var _ids,
- _diskinfo = diskinfo || US.disk.UserDisk, //网盘信息
- _selectElement = diskinfo.selectElement, //多选的元素
- _userid = _diskinfo.userInfo.UserId, //用户ID
- _fileordir = fileordir || U.Json.select(_diskinfo.directoryOrFiles, { "UserDirectoryID": _diskinfo.directoryid })[0], //右键的文件或者文件夹
- _permissions = U.MD.DK.C.getDirectoryPermissions(_fileordir.UserDirectoryID, _diskinfo), //获取操作的权限
- _rightel = U.selectEl("#U_MD_DK_M", _diskinfo.formel)[0], //右键菜单
- _childel = U.selectEl(_rightel).Child() //右键的菜单节点
- ;
- if (_selectElement.length > 1) {
- _ids = U.Json.toKeyArray(_selectElement, "id").join(",");
- fileordir = U.Json.like(diskinfo.currentDirectoryFile, { "UserDirectoryID": _ids });
- }
- //打开权限的处理
- if (_permissions.isopen && fileordir) {
- _childel[0].style.display = "block";
- _childel[0].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.LE.openFileDirectory(fileordir, _userid); //打开文件或者文件夹
- };
- }
- else {
- _childel[0].style.display = "none";
- }
- //修改权限的处理 重命名
- if (_permissions.isupadte && fileordir) {
- _childel[1].style.display = "block";
- _childel[1].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.rename(el, fileordir, _diskinfo); //打开文件或者文件夹
- };
- }
- else {
- _childel[1].style.display = "none";
- }
- //删除权限的处理
- if (_permissions.isdelete && fileordir) {
- _childel[2].style.display = "block";
- _childel[2].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.deleteFileOrDir(fileordir, _userid, _diskinfo); //删除文件或者文件夹
- }
- }
- else {
- _childel[2].style.display = "none";
- }
- //复制权限的处理
- if (_permissions.iscopy && fileordir) {
- _childel[3].style.display = "block";
- _childel[3].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.copyorshear(fileordir, "copy", _diskinfo); //复制文件或者文件夹
- }
- }
- else {
- _childel[3].style.display = "none";
- }
- //剪切权限的处理
- if (_permissions.isshear && fileordir) {
- _childel[4].style.display = "block";
- _childel[4].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.copyorshear(fileordir, "shear", _diskinfo); //剪贴文件或者文件夹
- }
- }
- else {
- _childel[4].style.display = "none";
- }
- //加密权限的处理
- if (_permissions.isencryption && fileordir) {
- _childel[5].style.display = "block";
- _childel[5].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.asynSetPermissions(fileordir);
- }
- }
- else {
- _childel[5].style.display = "none";
- }
- //下载权限的处理
- if (_permissions.isdownload && fileordir) {
- _childel[6].style.display = "block";
- _childel[6].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.downloadFile(fileordir.UserDirectoryID || U.Json.toKeyArray(fileordir, "UserDirectoryID").join(","), fileordir.filetype == 0); //弹出下载的处理
- }
- }
- else {
- _childel[6].style.display = "none";
- }
- //新建权限的处理
- if (_permissions.isnew && !fileordir) {
- _childel[7].style.display = "block";
- _childel[8].style.display = "block";
- _childel[9].style.display = "block";
- _childel[10].style.display = "block";
- _childel[7].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.newFolder(_diskinfo); //新建文件夹
- }
- _childel[8].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.newText(_diskinfo); //新建txt文件
- }
- _childel[9].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.newDocument(_diskinfo); //新建word文件
- }
- _childel[10].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.newExcel(_diskinfo); //新建excel文件
- }
- }
- else {
- _childel[7].style.display = "none";
- _childel[8].style.display = "none";
- _childel[9].style.display = "none";
- _childel[10].style.display = "none";
- }
- //评论权限的处理
- if (_permissions.isreply && !fileordir) {
- _childel[11].style.display = "block";
- _childel[11].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.replay(fileordir);
- }
- }
- else {
- _childel[11].style.display = "none";
- }
- //粘贴权限处理
- if (_permissions.ispaste && !fileordir) {
- _childel[12].style.display = "block";
- _childel[12].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.paste(_diskinfo); //粘贴函数
- }
- }
- else {
- _childel[12].style.display = "none";
- }
- //刷新权限处理
- if (_permissions.isrefresh && !fileordir) {
- _childel[13].style.display = "block";
- _childel[13].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.refresh(_userid, _fileordir, _diskinfo); //刷新函数
- }
- }
- else {
- _childel[13].style.display = "none";
- }
- //上传权限的处理
- if (_permissions.isupload && !fileordir) {
- _childel[14].style.display = "block";
- _childel[14].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.C.upload(_diskinfo); //文件上传
- }
- }
- else {
- _childel[14].style.display = "none";
- }
- //视图权限的处理
- if (_permissions.isview && !fileordir) {
- _childel[15].style.display = "block";
- _childel[16].style.display = "block";
- _childel[15].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.VW.viewsSwitch("Normal", _diskinfo); //普通视图
- }
- _childel[16].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.VW.viewsSwitch("Detailed", _diskinfo); //详细视图
- }
- }
- else {
- _childel[15].style.display = "none";
- _childel[16].style.display = "none";
- }
- //允许查看属性
- if (fileordir && _permissions.isopen) {
- _childel[17].style.display = "block";
- _childel[17].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.attribute(fileordir);
- }
- }
- else {
- _childel[17].style.display = "none";
- }
- //编辑权限的处理
- if (_permissions.isedit && US.disk.fileType.text.indexOf(_fileordir.UserDirectoryExtendType) > -1) {
- _childel[18].style.display = "block";
- _childel[18].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.D.I.openApplication("txt", _fileordir); //弹出应用处理
- }
- }
- else {
- _childel[18].style.display = "none";
- }
- //显示右键菜单
- _rightel.style.display = "block";
- if (_rightel.offsetHeight < 10) { //判断是否需要展开右键菜单的处理
- _rightel.style.display = "none"
- }
- else {
- //给右键菜单定位
- U.UF.C.rightClickMenuLocation(_rightel);
- }
- }
- /**
- * 隐藏右键菜单
- * @param {object} 网盘的值
- *
- **/
- U.MD.DK.RM.hiddenRightMenu = function (diskinfo) {
- U.selectEl("#U_MD_DK_M", diskinfo.formel)[0].style.display = "none";
- }
- /**
- * 多文件右键菜单的显示
- * @param {object} 网盘的值
- *
- **/
- U.MD.DK.RM.getSelectionFilesOrDir = function (el) {
- // var i, _UCE = [];
- // for (i = 0; i < UDAD.length; i++) {
- // _UCE.push(UDAD[i].id);
- // };
- // return U.Json.Like(UGE, { "UserDirectoryID": _UCE.join(",") });
- }
- //#endregion
- ;
- ///<jscompress sourcefile="SitePreview.js" />
- /*
- 网站预览 目录展示
- */
- Namespace.register("U.MD.DK.SP"); //Disk左键事件命名空间
- //window.onload = function () {
- // U.MD.DK.SP.getDirectioryInfo(directoryid);
- //}
- /**
- *获取用户信息
- *
- *
- */
- U.MD.DK.SP.getUser = function (userid) {
- var _userid = userid;
- if (userid) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserId", _userid], function (r) {//根据用户名获取用户信息
- console.log(r.value);
- U.selectEl('.U_MD_DK_SP_Head_Logo_name')[0].innerHTML = r.value[0].UserNickName + '的云盘';
- if (r.value[0].UserImageHead) {
- U.selectEl('.U_MD_DK_SP_Head_UImg')[0].src = "http://fs.1473.cn/" + r.value[0].UserImageHead;
- }
- U.selectEl('.U_MD_DK_SP_Head_UImg')[0].title = r.value[0].UserNickName;
- });
- }
- }
- /**
- * 获取目录信息
- * @param {guid} directoryid 目录ID
- */
- U.MD.DK.SP.getDirectioryInfo = function (directoryid, userid) {
- U.UF.CD.loadPageCrossDomain(function () {
- U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "GetDirectroyById", directoryid], U.MD.DK.SP.getDirectioryInfo.asyn, [null, userid, directoryid]);
- });
- }
- /**
- * 获取目录信息异步
- *
- */
- U.MD.DK.SP.getDirectioryInfo.asyn = function (r) {
- var _directioryinfo = r.value[0],
- _userid = r.context[1],
- _dirid = r.context[2];
- U.MD.DK.SP.getUser(_userid);
- U.MD.DK.SP.getAllFileInfo(_dirid, _userid, _directioryinfo ? _directioryinfo.GroupID : "");
- }
- /**
- * 获取目录下的文件
- *
- */
- U.MD.DK.SP.getAllFileInfo = function (directoryid, userid, groupid) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "GetChildsByDirectoryId", userid, directoryid, groupid || directoryid], U.MD.DK.SP.getAllFileInfo.asyn);
- }
- /**
- * 获取目录下的文件 异步
- *
- */
- U.MD.DK.SP.getAllFileInfo.asyn = function (r) {
- console.log(r.value);
- var _contentBox = U.selectEl('.U_MD_DK_SP_ContentList')[0];
- U.MD.DK.SP.getParentFile(r.value[0].UserDirectoryParentID);
- for (var i = 0; i < r.value.length; i++) {
- var _fileli = $$('div', { 'className': 'U_MD_DK_SP_Li', 'id': 'U_MD_DK_SP_Li' + i }, _contentBox);
- $$('div', { 'className': 'U_MD_DK_SP_CTopNum', 'innerHTML': i > 8 ? (i + 1) : '0' + (i + 1) }, U.selectEl('#U_MD_DK_SP_Li' + i)[0]);
- var _icon = U.MD.DK.SP.getIcon(r.value[i].UserDirectoryExtendType); //根据文件扩展名,得到图标的样式
- if (!_icon.classname[2]) {
- _icon.classname[2] = 'U_MD_DK_SP_unfile';
- }
- var _filename = $$('div', { 'className': 'U_MD_DK_SP_CTopFileName', 'title': r.value[i].UserallDirectoryName }, U.selectEl('#U_MD_DK_SP_Li' + i)[0]);
- $$('span', { 'className': _icon.classname[2] + ' U_MD_DK_SP_Img U_MD_DK_SP_RZSMI ', 'innerHTML': ' ' }, _filename);
- _filename.innerHTML += r.value[i].UserallDirectoryName;
- $$('div', { 'className': 'U_MD_DK_SP_CTopFileType', 'innerHTML': r.value[i].UserDirectoryExtendType }, U.selectEl('#U_MD_DK_SP_Li' + i)[0]);
- $$('div', { 'className': 'U_MD_DK_SP_CTopFileSize', 'innerHTML': U.UF.UP.minUnitToMaxUnit(r.value[i].UserDirectorySize) }, U.selectEl('#U_MD_DK_SP_Li' + i)[0]);
- $$('div', { 'className': 'U_MD_DK_SP_CTopFileAuthor', 'innerHTML': r.value[i].UserNickName }, U.selectEl('#U_MD_DK_SP_Li' + i)[0]);
- var _date = U.UF.D.formatDateToArray(r.value[i].UserDirectoryAddTime);
- $$('div', { 'className': 'U_MD_DK_SP_CTopFileUpdateTime', 'innerHTML': _date[0] + "-" + _date[1] + "-" + _date[2] + " " + _date[3] + ":" + _date[4] }, U.selectEl('#U_MD_DK_SP_Li' + i)[0]);
- _fileli.onclick = U.UF.C.closure(function (fileinfo) {
- console.log(fileinfo);
- if (fileinfo.UserDirectoryExtendType == 'folder') {
- window.location.href = window.location.origin + window.location.pathname + window.location.search + "/" + fileinfo.UserallDirectoryName;
- }
- else {
- //window.open(window.location.origin + window.location.pathname + "/" + fileinfo.UserallDirectoryName + window.location.search);
- var i,
- _applicationame,
- _types = US.disk.applicationTypes,
- _extension = fileinfo["UserDirectoryExtendType"].toLocaleLowerCase();
- for (i in _types) {
- if (_types[i].types.indexOf(_extension) > -1) { //判断文件类型是否归属该应用
- _applicationame = i;
- break;
- }
- }
- console.log(_applicationame);
- switch (_applicationame) {
- case "music": //播放制定的音乐,需要流程图
- U.MD.DK.LE.music(fileinfo); //音乐控件
- break;
- case "image": //图片查看,需要流程图
- U.MD.DK.LE.img(fileinfo); //图片控件
- break;
- case "video": //视频处理 需要流程图
- U.MD.DK.LE.video(fileinfo); //视频控件
- break;
- case "text": //文本文件需要流程图
- U.MD.D.Txt.textCreate(fileinfo);
- break;
- case "usoffice": //如果是云端系统自有格式文件。 需要流程图
- //excel处理
- case "ue": //word处理
- U.MD.D.I.openApplication("excel", fileinfo); //弹出应用处理
- break;
- case "uw": case "un": //word处理
- U.MD.D.I.openApplication("word", fileinfo); //弹出应用处理
- break;
- case "word":
- U.A.Request(US.DISK, ["GetFileContent", fileinfo.UserDirectoryID], function (r) {
- //获取word内容
- if (r.value && r.value.UsOffice !== undefined && r.value.UsOffice != null) {
- fileinfo.UsOffice = r.value.UsOffice.unEscapeQuotes();
- U.MD.D.I.openApplication("word", fileinfo); //弹出应用处理
- }
- //如果内容不存在则去office系统中获取
- else {
- U.A.Request("http://office.1473.cn/Officetohtml.ashx", ["Open", fileinfo.UserDirectoryExtendType, fileinfo.UserFilesServerName], function (r) {
- if (r.value.value != undefined) {
- r = r.value;
- fileinfo.UsOffice = r.value.getBodyHtml().replace(/src=[\'\"]?([^\'\"]*)[\'\"]?/ig, function (str1, str2) {
- return "src=\"http://office.1473.cn/usoffice/" + str2 + "\"";
- });
- U.MD.D.I.openApplication("word", fileinfo); //弹出应用处理
- } else {
- U.Alert('文档已丢失。。。');
- }
- });
- }
- });
- break;
- case "txt": //txt处理
- U.MD.D.I.openApplication("txt", fileinfo); //弹出应用处理
- break;
- //windows上传的不可识别的文件打开,直接跳转到下载页面。
- default:
- U.MD.DK.RE.downloadFile(fileinfo.UserDirectoryID, false);
- break;
- }
- }
- }, [r.value[i]]);
- }
- }
- /***
- *获取图标
- *extendtype {string} 文件种类
- */
- U.MD.DK.SP.getIcon = function (extendtype) {
- var i,
- _application = US.disk.applicationTypes //获取所有打开应用的信息
- ;
- if (extendtype) {
- //循环信息中找到指定的应用的信息
- for (i in _application) {
- //找到后缀名对应的程序信息
- if (_application[i].types.indexOf(extendtype.toLowerCase()) > -1) {
- return _application[i]; //返回应用的信息
- }
- }
- }
- return _application["unknownfile"]; //如果是本站未知的后缀直接归属于文件
- }
- /***
- *获取上一次文件夹
- *extendtype {string} 文件种类
- */
- U.MD.DK.SP.getParentFile = function (parentid) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "GetDirectroyById", parentid], function (r) {
- if (r.value[0]) {
- U.selectEl('.U_MD_DK_SP_Head_Logo_name')[0].innerHTML += '-' + r.value[0].UserDirectoryName + '文档详细列表';
- }
- }, []);
- }
- ;
- ;
- ///<jscompress sourcefile="Friend.js" />
- ///<jscompress sourcefile="Add.js" />
- Namespace.register("U.MD.F.J"); //好友加群加好友的命名空间
- /*
- * U.MD.F.J.groupInfoForm 显示添加群的窗口(创建一个群添加的窗口)
- */
- //#region 创建群组
- //听见群用户的信息
- U.MD.F.J.selectUserInfo = {
- NeedUser: [], //需要添加的群用户
- SelectUser: [], //已经选择过的用户
- CallBack: null //添加后的回调
- };
- /**
- * 显示添加群窗口
- *
- * @param {object} 群信息
- * @param {element} 元素处理
- * @param {boolean}
- */
- U.MD.F.J.groupInfoForm = function (groupinfo, chatel) {
- var _formel, //窗体
- _groupuserinfo, //获取所有的群好友
- _determinebottom,
- _closebottom,
- _isgroupmain,
- _isdeletegroup,
- _groupinfoel = U.selectEl("#U_MD_F_Add"), //添加群的窗体
- _addgroupuserel = U.selectEl("#U_MD_F_RC_C")[0], //内容区域
- _groupinfochildsel = _groupinfoel.Child(), //群信息窗体子元素
- _inputel = U.selectEl("input,textarea", _groupinfochildsel[0]); //内容输出
- //清空群用户
- U.MD.F.J.selectUserInfo.NeedUser.splice(0, U.MD.F.J.selectUserInfo.NeedUser.length);
- //设置该联系人进入群
- _groupinfochildsel[1].innerHTML = "";
- //如果群存在的处理
- if (groupinfo) {
- //是否是新建群或者是群主,
- if ($('.U_MD_F_Add_TNM_ADD2')[0]) {
- U.selectEl('.U_MD_F_Add_TNM_ADD2')[0].style.display = "none";
- }
- if ($('.U_MD_F_Add_TNMO')[0]) {
- U.selectEl('.U_MD_F_Add_TNMO')[0].style.display = "block";
- }
- if ($('.U_MD_F_Add_C_D')[0]) {
- U.selectEl('.U_MD_F_Add_C_D')[0].style.display = "block";
- }
- if (groupinfo) {
- _isgroupmain = groupinfo.GroupManageCreateUserID == US.userInfo.UserId; //群主
- } else {
- _isgroupmain = !groupinfo; //新建群
- }
- //判断是否是群主还是群成员
- if (_isgroupmain) {
- _isdeletegroup = "解散该群"; //群主
- } else {
- _isdeletegroup = "退出该群"; //群成员
- }
- //设置是否显示解散该群还是退出该群
- U.selectEl(_groupinfoel[0]).Child()[2].style.display = "block";
- //设置群名,群描述等
- _inputel[0].value = groupinfo.GroupManageName;
- _inputel[1].value = groupinfo.GroupManageDescript;
- //获取群用户的信息
- _groupuserinfo = U.Json.select(US.friend.groupusers, { "GroupManageID": groupinfo.GroupManageID });
- //获取群成员人数
- U.selectEl('.U_MD_F_Add_TNM_Number')[0].innerHTML = _groupuserinfo.length + "人";
- //设置已经选择过的用户
- U.MD.F.J.selectUserInfo.SelectUser = _groupuserinfo;
- //打印当前群的用户
- U.MD.F.J.printGroupUserInfo(_groupinfochildsel[1], _groupuserinfo, groupinfo);
- //点击退出按钮事件设置
- U.selectEl(_groupinfochildsel[2]).addAttrArray({
- "onclick": function () {
- U.MD.F.J.groupExit(groupinfo, U.Json.selectOne(_groupuserinfo, { "UserId": US.userInfo.UserId }), _groupinfoel);
- },
- "innerHTML": _isdeletegroup
- });
- }
- //创建新群,清空数据
- else {
- //设置群名,群描述等
- _inputel[0].value = "";
- _inputel[1].value = "";
- U.selectEl(_groupinfoel[0]).Child()[2].style.display = "none";
- U.selectEl('.U_MD_F_Add_TNMO')[0].style.display = "none";
- U.selectEl('.U_MD_F_Add_C_D')[0].style.display = "none";
- U.selectEl('.U_MD_F_Add_TNM_ADD2')[0].style.display = "block";
- }
- _groupinfoel[0].style.display = "block";
- //弹出窗体
- _formel = new U.UF.UI.form("群聊信息", _groupinfoel[0], { "id": "U_MD_F_Add_O", "style": { "width": "480px" } }, { isnarrow: false, isenlarge: false }).form;
- if (!groupinfo) {
- U.selectEl($(_formel).Child()[2]).Child()[0].style.MaxHeight = "650px";
- U.selectEl(_formel)[0].style.Maxheight = "650px";
- }
- //确定添加群处理
- _determinebottom = U.selectEl(_groupinfochildsel[3]).Child()[0];
- _determinebottom.onclick = function () {
- if ($('#U_MD_F_addFriendorGroup')[0]) {
- U.selectEl('#U_MD_F_addFriendorGroup')[0].style.display = "none";
- }
- U.MD.F.J.determineCreateGroupAndAddGroupUser(groupinfo ? groupinfo.GroupManageID : null, _groupinfochildsel[0], chatel);
- };
- //邀请好友处理
- _invitationbottom = U.selectEl($(_groupinfochildsel[0]).Child()[1]).Child()[1];
- _invitationbottom.onclick = function () {
- U.MD.F.J.selectFriendForm(function () {
- U.MD.F.J.determineCreateGroupAndAddGroupUser(groupinfo ? groupinfo.GroupManageID : null, _groupinfochildsel[0], chatel, true);
- }, 'friend', "", 1);
- }
- U.selectEl('#U_MD_F_Add_TNM_ADD2_add')[0].onclick = function () {
- U.MD.F.J.selectFriendForm(function () {
- U.MD.F.J.determineCreateGroupAndAddGroupUser(groupinfo ? groupinfo.GroupManageID : null, _groupinfochildsel[0], chatel, true);
- }, 'friend', "", 0);
- }
- //确定取消群处理
- _closebottom = U.selectEl(_groupinfochildsel[3]).Child()[1];
- _closebottom.onclick = function () {
- U.UF.F.windowMinimize(_formel);
- }
- return _formel;
- }
- /**
- * 打印群用户
- *
- * @param {element} 添加进入的元素
- * @param {object} 添加的用户信息
- */
- U.MD.F.J.printGroupUserInfo = function (el, groupuserinfo, groupinfo) {
- var i,
- //临时元素变量
- _tempel,
- _temponeel,
- _temptwoel,
- _tempname,
- _frag = $$("frag"),
- _childsel = U.selectEl(el).Child(),
- _isgroupmain;
- //判断是否是群主
- if (groupinfo) {
- _isgroupmain = groupinfo.GroupManageCreateUserID == US.userInfo.UserId;
- }
- else {
- _isgroupmain = !groupuserinfo;
- }
- //获取不同的classname
- if (_isgroupmain) {
- _tempname = "U_MD_F_Add_R" + " U_MD_F_Add_RS"
- }
- else {
- _tempname = "U_MD_F_Add_R" + ""
- }
- //打印群用户显示的样式
- for (i = 0; i < groupuserinfo.length; i++) { //循环添加
- _tempel = $$("div", { "className": "U_MD_F_Add_CO" }, _frag);
- _tempell = $$("div", { "style": { "width": "32%", "height": "30px", "float": "left" } }, _tempel);
- $$("img", { "onerror": U.MD.C.imgError, "onerror": U.MD.C.imgError, "title": "点击查看", "src": U.MD.C.getHeadImage(groupuserinfo[i].UserThumbnailImageHead) }, _tempell);
- $$("div", { "className": "U_MD_F_Add_COM U_MD_D_Text_Abbreviation", "innerHTML": groupuserinfo[i].UserName }, _tempell);
- _temponeel = $$("div", { "className": "U_MD_F_Add_COM U_MD_D_Text_Abbreviation UD_UserName", "style": { "width": "32%", "margin-left": "2%" }, "innerHTML": groupuserinfo[i].GroupUsersDescript || groupuserinfo[i].UserNickName || groupuserinfo[i].UserName }, _tempel);
- _temptwoel = $$("div", { "className": _tempname }, _tempel);
- //这有已经新建的群
- if (groupinfo) {
- //只有本人或者群主才能修改群名片
- if (_isgroupmain || groupuserinfo[i].UserId == US.userInfo.UserId) {
- $$("img", {
- "src": "/img/Edit1.png",
- "title": "修改群名片",
- "onclick": (function (i) {
- return U.UF.C.closure(U.MD.F.J.upateGroupUserDescriptForm, [groupuserinfo[i], _temponeel]);
- })(i)
- }, _temptwoel);
- }
- $$("img", {
- "src": "/img/personalCard1.png", "title": "查看用户资料",
- "onclick": (function (i) {
- return U.UF.C.closure(U.MD.U.V.ViewOtherUserInfo, [groupuserinfo[i].UserId]);
- })(i)
- }, _temptwoel);
- $$("img", {
- "src": "/img/Add1.png", "title": "添加好友",
- "onclick": (function (i) {
- return U.UF.C.closure(U.MD.F.M.addFriend, [groupuserinfo[i], null, _tempel]);
- })(i)
- }, _temptwoel);
- }
- //如果是群主有移除权限
- if (_isgroupmain) {
- $$("img", {
- "src": "/img/exit1.png", "title": "移除",
- "onclick": (function (i) {
- return U.UF.C.closure(U.MD.F.J.groupExit, [groupinfo, groupuserinfo[i], _tempel]);
- })(i)
- }, _temptwoel);
- }
- }
- //判断元素是否存在,如果存在则,追加元素,如果不存在则添加到最后面
- if (_childsel.length) {
- el.insertBefore(_frag, _childsel[_childsel.length - 1]);
- }
- else {
- el.appendChild(_frag);
- }
- }
- /**
- * 显示添加群窗口
- *
- * @param {object} 群好友信息
- */
- U.MD.F.J.upateGroupUserDescriptForm = function (groupuserinfo, el) {
- var _tempel,
- _temponeel,
- _temptwoel,
- _groupname = groupuserinfo.GroupUsersDescript || groupuserinfo.UserName
- ;
- if (groupuserinfo) {
- //创建好友分组的样式
- _tempel = $$("div", { "className": "U_MD_U_L_Box_I U_MD_F_Add_TNL U_MD_F_G" });
- _temponeel = $$("div", {}, _tempel)
- _temptwoel = $$("input",
- {
- "value": _groupname,
- "onfocus": function () {
- U.UF.MR.inputPlaceholder(this, _groupname, "");
- },
- "onblur": function () {
- U.UF.MR.inputPlaceholder(this, "", _groupname);
- }
- }, _temponeel);
- //弹出好友对话框
- U.UF.UI.confirm(_tempel, function () {
- U.MD.F.J.determineUpateGroupUserDescript(groupuserinfo, _temptwoel, el);
- });
- }
- else {
- U.alert("暂无群信息");
- }
- }
- /**
- * 确定设置群信息
- *
- * @param {object} 群好友信息
- */
- U.MD.F.J.determineUpateGroupUserDescript = function (groupuserinfo, inputel, el) {
- //判断用户是否输入正确的备注名
- if (inputel.value && U.UF.S.NickName.test(inputel.value)) {
- U.A.Request(US.FRIEND, ["UpdateGroupMemberInfo", US.userInfo.UserId, groupuserinfo.GroupManageID, groupuserinfo.UserId, inputel.value],
- U.MD.F.J.asynDetermineUpateGroupUserDescript, [null, groupuserinfo, inputel.value, el]);
- }
- else {
- U.alert("备注名格式不对");
- return true;
- }
- }
- /**
- * 修改群备注异步
- *
- * @param {object} 群好友信息
- */
- U.MD.F.J.asynDetermineUpateGroupUserDescript = function (r) {
- var _context = r.context,
- _groupuserinfo = _context[1], //群用户信息
- _descriptname = _context[2], //修改后的备注名
- _el = _context[3]; //元素
- //修改groupuserinfo里面的用户备注的变量和修改显示给用户看到的备注
- _el.innerText = _groupuserinfo.GroupUsersDescript = _descriptname;
- U.alert("修改备注成功!");
- }
- /**
- * 退出或者踢人
- *
- * @param {object} 群信息
- * @param {object} 好友信息
- */
- U.MD.F.J.groupExit = function (groupinfo, userinfo, el) {
- var _userid = US.userInfo.UserId, //用户id
- _isgroupmain = groupinfo.GroupManageCreateUserID == _userid //判断用户是否是群主
- ;
- //如果推出群的是群主处理
- if (_isgroupmain) {
- //如果群主自己推出,则解散群
- if (userinfo.UserId == _userid) {
- U.UF.UI.confirm("是否解散该群", function () {
- U.MD.F.J.enterGroupExit(groupinfo, userinfo, true, el);
- }); //创建提示框 提示是否删除备份
- }
- //否则则移除群好友
- else {
- //创建提示框 提示是否删除备份
- U.UF.UI.confirm("是否移除该群用户", function () {
- U.MD.F.J.enterGroupExit(groupinfo, userinfo, false, el);
- });
- }
- }
- //不是群主的处理
- else {
- U.UF.UI.confirm("是否确定退出该群", function () { U.MD.F.J.enterGroupExit(groupinfo, userinfo, false, el); }); //创建提示框 提示是否删除备份
- }
- }
- /**
- * 移除群异步
- *
- * @param {object} 群信息
- * @param {object} 好友信息
- * @param {bool} 是否为删除群
- */
- U.MD.F.J.enterGroupExit = function (groupinfo, userinfo, isdelete, el) {
- if (isdelete === true) {
- U.A.Request(US.FRIEND, ["DeleteGroup", US.userInfo.UserId, groupinfo.GroupManageID], U.MD.F.J.asynGroupExit, ["", groupinfo, userinfo, isdelete, el]); //解散群
- }
- else {
- U.A.Request(US.FRIEND, ["ExitGroup", US.userInfo.UserId, groupinfo.GroupManageID, userinfo.UserId], U.MD.F.J.asynGroupExit, ["", groupinfo, userinfo, isdelete, el]);
- }
- }
- /**
- * 群移除异步
- *
- * @param {object} 群信息
- * @param {object} 好友信息
- * @param {bool} 是否为删除群
- */
- U.MD.F.J.asynGroupExit = function (r) {
- var _context = r.context,
- _chatfrom,
- _groupinfo = _context[1], //群信息
- _friendinfo = _context[2], //自己在群里的信息
- _isdelete = _context[3], //是解散群还是退出(移除)群用户
- _el = _context[4], //弹出的群窗体
- _chatformel = U.selectEl("#U_MD_F")[0]; //聊天框元素
- //删除群处理 或者退出群
- if (_isdelete) {
- //清空用户在群的数据
- U.Json.del(US.friend.group, { "GroupManageID": _groupinfo.GroupManageID }); //删除群
- U.Json.del(US.friend.groupusers, { "GroupManageID": _friendinfo.GroupManageID }); //删除群用户
- //用户面板里是否存在群,存在删除
- U.selectEl("#U_MD_F_H_ZLZ").find("[tid='" + _groupinfo.GroupManageID + "']").remove(); //删除群
- //判断好友是否出现在聊天框里,如果是则移除聊天框
- if (U.MD.F.W.isCreateForm(_groupinfo.GroupManageID)) {
- U.MD.F.W.delteFriendChat(_groupinfo.GroupManageID, _chatformel);
- }
- //弹出群消息的弹窗
- if (_el) {
- _el = U.selectEl(_el).Parent({ usform: "true" });
- _el.close();
- }
- U.alert('解散群成功');
- }
- //群主删除好友处理
- else if (_groupinfo.GroupManageUserID == US.userInfo.UserId && _isdelete == false) {
- U.selectEl(_el).remove(); //删除好友
- U.Json.del(US.friend.groupusers, { "GroupManageID": _friendinfo.GroupManageID, "UserId": _friendinfo.UserId }); //删除群指定的用户
- U.Json.del(U.MD.F.J.selectUserInfo.SelectUser, { "UserId": _friendinfo.UserId }); //删除群指定的用户
- U.alert('已将成员移除群聊');
- }
- //自己退出群处理
- else {
- //移除群好友
- U.MD.F.W.delteFriendChat(_friendinfo.GroupManageID, _chatformel);
- U.selectEl("#U_MD_F_H_ZLZ").find("[tid='" + _groupinfo.GroupManageID + "']").remove(); //删除群
- U.Json.del(US.friend.group, { "GroupManageID": _friendinfo.GroupManageID }); //删除群指定的用户
- U.Json.del(US.friend.recentcontacts, { "GroupManageID": _friendinfo.GroupManageID }); //删除最近聊天中被删除的群
- //弹出群消息的弹窗
- if (_el) {
- _el = U.selectEl(_el).Parent({ usform: "true" });
- _el.close();
- }
- U.alert('已退出群聊');
- }
- }
- /**
- * 选择联系人弹框
- *
- * @param {object} 添加进入的元素
- * @param {function} 添加的用户信息
- * @param {number} 0 新创群 1邀请好友
- */
- U.MD.F.J.selectFriendForm = function (cb, type, fileinfo, group) {
- //添加好友弹框调用,用户必须登录和已经加载了好友数据
- if (!U.MD.U.L.isLogin() && US.friend.friends) {
- var i, //用于循环所有的是否在群里的人
- _formel, //用于存储创建群选择好友的弹框
- _gel = U.selectEl("#U_MD_F_RC_G_C")[0], //获取组元素
- _fel = U.selectEl("#U_MD_F_RC_F_C")[0], //获取好友元素
- _elparent = U.selectEl("#U_MD_F_RC")[0], //获取存放该元素的父级元素
- _clone = _elparent.cloneNode(true), //克隆元素
- _allfriendinfo = U.Json.select(US.friend.friends.concat([])), //所有的联系人
- _addfriendinfo = U.MD.F.J.selectUserInfo, //选择用户的信息
- _selectfriend = _addfriendinfo.SelectUser, //添加好友信息
- _clickEl = U.selectEl('#U_MD_F_RC_Friend')[0],
- _groupEl = U.selectEl('#U_MD_F_RC_Group')[0],
- _joinEl = U.selectEl('#U_MD_F_RC_Join')[0]
- if (group == 1) {
- //已经在群里的就不添加了
- for (i = 0; i < _selectfriend.length; i++) {
- U.Json.del(_allfriendinfo, { "UserId": _selectfriend[i].UserId }); //删除所有在群里的用户id
- }
- }
- //弹出创建群选择好友的框
- var _form = new U.UF.UI.form("选择联系人",
- _elparent,
- {
- "id": "U_MD_F_RC_O",
- "style": {
- "width": "480px",
- "height": "530px",
- "min-width": "480px"
- }
- },
- {
- isnarrow: false,
- isenlarge: false
- });
- //_formel = _form.form;
- _addfriendinfo.CallBack = cb; //回调函数
- if (US.friend.friends.length) {
- //打印可以选择的联系人
- if (!type || type == 'friend') {
- U.MD.F.J.printSelectFriend(_fel, _allfriendinfo, _elparent);
- _clickEl.onclick = function () {
- _clickEl = U.MD.F.J.alterNately($(_elparent).find('#U_MD_F_RC_F_C')[0], U.selectEl(_elparent).find('#U_MD_F_RC_G_C')[0], _elparent, _clickEl, this)
- }
- }
- //打印可以选择的群
- if (!type || type == 'group') {
- U.MD.F.J.printSelectGroupUser(_gel, US.friend.group, _elparent);
- _groupEl.onclick = function () {
- _clickEl = U.MD.F.J.alterNately($(_elparent).find('#U_MD_F_RC_G_C')[0], U.selectEl(_elparent).find('#U_MD_F_RC_F_C')[0], _elparent, _clickEl, this)
- }
- }
- if (type == 'friend' || type == 'group') {
- _clickEl.style.display = 'none';
- _groupEl.style.display = 'none';
- } else {
- _clickEl.style.display = 'block';
- _groupEl.style.display = 'block';
- }
- } else {
- _clickEl.style.display = 'none';
- _groupEl.style.display = 'none';
- _joinEl.style.display = 'block';
- U.selectEl('.U_MD_F_RC_Join_btn')[0].onclick = function () {
- var _input = $$('input', {}, _joinEl),
- _fileType = fileinfo.UserDirectoryExtendType == 'uw' ? 'word' : 'execl';
- _input.value = "/" + _fileType + '/join/' + fileinfo.UserDirectoryID;
- _input.select();
- document.execCommand("Copy");
- U.selectEl(_input).remove();
- U.Alert('复制成功,赶快分享给小伙伴吧!');
- }
- }
- _addfriendinfo.NeedUser = [];
- _elparent.parentNode.style.backgroundColor = "#f3f3f3"
- U.selectEl(_elparent)[0].style.display = "block"; //显示出添加好友的信息
- U.selectEl("#U_MD_Home")[0].appendChild(_clone); //把克隆的元素打印出来
- return _formel; //返回窗体元素
- }
- }
- /**
- * 打印可以添加的用户
- *
- * @param {object} 添加联系人的元素
- * @param {function} 选择的好友
- */
- U.MD.F.J.printSelectFriend = function (el, friendinfo, boxele) {
- var i, //用于循环所有联系人打印
- _tempel, //用于创建元素
- _temponeel, //用于创建元素
- _frag = $$("frag"); //创建新的元素
- //联系人打印,循环所有还有信息的长度
- for (i = 0; i < friendinfo.length; i++) {
- _tempel = $$("div",
- {
- "className": "U_MD_F_RC_CO",
- "FID": friendinfo[i].UserId,
- "onclick": U.UF.C.closure(function (firendinfo) {
- U.MD.F.J.clickSelectFriend(this, firendinfo); //选择后的点击事件
- U.MD.F.J.showChoose(firendinfo, U.selectEl(this).find('.U_MD_F_RC_COC ')[0], boxele, 'friend')
- }, [friendinfo[i]])
- },
- _frag);
- $$("div", { "className": "U_MD_F_RC_COI U_Img" }, _tempel); //创建元素
- _temponeel = $$("div", { "className": "U_MD_F_RC_COC U_MD_D_Text_Abbreviation" }, _tempel); //创建元素
- $$("img",
- {
- "onerror": U.MD.C.imgError,
- "title": "点击查看",
- "onclick": function (n) {
- return function () {
- U.UF.EV.stopBubble(); //阻止冒泡时间
- U.MD.U.V.ViewOtherUserInfo(friendinfo[n].UserId); //打印个人用户信息
- }
- }(i),
- "src": U.MD.C.getHeadImage(friendinfo[i].UserThumbnailImageHead), //获取好友头像img
- "alt": friendinfo[i].FriendsDescript//获取好友描述
- },
- _temponeel);
- $$("div", { "className": "U_MD_F_RC_COCN", "innerHTML": friendinfo[i].UserNickName }, _temponeel); //创建元素,获取好友用户名
- }
- //显示到框
- el.innerHTML = ""; //清空数据
- el.appendChild(_frag); //获取所有的打印的用户到显示框内
- }
- /**
- * 打印可以添加的群用户
- *
- * @param {object} 添加联系人的元素
- * @param {function} 选择的好友
- */
- U.MD.F.J.printSelectGroupUser = function (el, groupinfo, boxele) {
- var i, //获取循环的元素
- _tempel, //创建元素
- _temponeel, //创建元素
- _frag = $$("frag"); //创建元素的父级元素
- //循环打印,循环所有群信息的长度
- for (i = 0; i < groupinfo.length; i++) {
- _tempel = $$("div",
- {
- "className": "U_MD_F_RC_CO",
- "FID": groupinfo[i].GroupManageID, //fid为群的群id
- "onclick": function (n) {
- return function () {
- U.MD.F.J.showChoose(firendinfo, U.selectEl(this).find('.U_MD_F_RC_COC ')[0], boxele, 'group', this)
- U.MD.F.J.clickSelectGroup(this, groupinfo[n]); //选择群后的点击事件
- }
- }(i)
- }, _frag);
- $$("div", { "className": "U_MD_F_RC_COI U_Img" }, _tempel); //创建元素
- _temponeel = $$("div", { "className": "U_MD_F_RC_COC U_MD_D_Text_Abbreviation" }, _tempel); //创建元素
- $$("img",
- {
- "title": "点击查看",
- "onclick": function (n) {
- return function () {
- U.UF.EV.stopBubble(); //阻止冒泡事件
- U.MD.U.V.GroupInfo(groupinfo[n]); //打印群的所有信息
- }
- }(i),
- "src": "/img/chatgroup.png"//显示群的群头像
- }, _temponeel);
- $$("div", { "className": "U_MD_F_RC_COCN", "innerHTML": groupinfo[i].GroupManageName }, _temponeel); //获取群的群名
- }
- el.appendChild(_frag); //打印群信息
- }
- /**
- * 搜索联系人
- *
- * @param {object} 用户信息
- */
- U.MD.F.J.searchSelectFriend = function (groupinfo) {
- var _searchel = U.selectEl("#U_MD_F_RC_C")[0],
- _UDTD = U.selectEl("div@FID=" + groupinfo.UserId)[0]; //获取选中的添加的元素
- if (_UDTD) {
- _UDTD.onclick();
- U.UF.EV.scrollToPosition(_UDTD); //滚动到指定的位置
- }
- else { U.alert("好友已经添加到群组里~"); }
- }
- /**
- * 选择添加后的效果
- *
- * @param {element} 添加好友的元素
- * @param {object} 好友信息
- */
- U.MD.F.J.clickSelectFriend = function (el, friendinfo) {
- var _selectel = U.selectEl("div", el)[0]; //选择的元素
- //如果元素没有给选择,那么点击选择
- if (_selectel.className == "U_MD_F_RC_COI U_Img") {
- _selectel.className += " U_MD_F_RC_COIO"; //设置点击后的效果样式
- U.MD.F.J.selectUserInfo.NeedUser.push(friendinfo); //最后需要添加的用户
- }
- //如果元素已经是选择的状态,那么点击后则取消选择
- else {
- _selectel.className = "U_MD_F_RC_COI U_Img"; //设置点击后的效果样式
- U.Json.del(U.MD.F.J.selectUserInfo.NeedUser, { "UserId": friendinfo.UserId }); //删除最后需要添加的用户
- }
- }
- /**
- * 选择添加群后的效果
- *
- * @param {element} 添加群的元素
- * @param {object} 群的信息 U.Json()
- */
- U.MD.F.J.clickSelectGroup = function (el, groupinfo) {
- var i,
- _selectel = U.selectEl("div", el)[0], //点击的元素
- _needuser = U.MD.F.J.selectUserInfo.NeedUser, //最后需要添加的用户
- _groupuser = U.Json.select(US.friend.groupusers, { "GroupManageID": groupinfo.GroupManageID }); //选择群里所有的群用户
- //如果元素没有给选择,那么点击选择
- if (_selectel.className == "U_MD_F_RC_COI U_Img") {
- _selectel.className += " U_MD_F_RC_COIO"; //设置点击后的效果样式
- _needuser = _needuser.concat(_groupuser); //把群用户添加到需要添加的用户集合里
- }
- //如果元素已经是选择的状态,那么点击后则取消选择
- else { //添加删除效果
- _selectel.className = "U_MD_F_RC_COI U_Img"; //设置点击后的效果样式
- //移除群里的每一个用户
- for (i = 0; i < _groupuser.length; i++) {
- U.Json.del(_needuser, { "UserId": _groupuser[i].UserId });
- }
- }
- }
- /**
- * 创建群取消按钮
- *
- * @param {element} 添加好友窗体
- */
- U.MD.F.J.closeSelectFriendForm = function (el) {
- U.UF.F.closeWindow($(el).Parent({ usform: "true" }), "remove"); //移除创建群的弹窗
- }
- /**
- * 确定添加按钮
- *
- * @param {element} 添加好友窗体
- */
- U.MD.F.J.determineSelectFriend = function (el) {
- var _selectuserinfo = U.MD.F.J.selectUserInfo, //获取所有选择信息
- _groupid = U.selectEl(el).find('.U_MD_F_RC_COIO')[0] && U.selectEl(el).find('.U_MD_F_RC_COIO')[0].parentNode.getAttribute('fid');
- _groupid = U.Json.select(US.friend.group, { "GroupManageID": _groupid })[0] ? _groupid : false;
- //回调函数处理
- if (_selectuserinfo.CallBack) {
- _selectuserinfo.CallBack(_groupid);
- _selectuserinfo.CallBack = null;
- }
- U.UF.F.closeWindow(el, "remove"); //取消窗口
- }
- /**
- * 显示输入文档名对话框
- *
- */
- U.MD.F.J.inputDocName = function () {
- var _confirmEl = U.selectEl('#U_UF_UI_confirm')
- U.UF.F.topWindow(_confirmEl[0])
- U.selectEl(_confirmEl).find('#U_MD_DK_RE_localDoc')[0].click()
- }
- /**
- * 确定添加按钮
- * 点击好友添加确定按钮,去数据库创建一个群
- * @param {element} 添加好友窗体
- * @param {string} 群id
- * @param {boolean} 是否是新建
- */
- U.MD.F.J.determineCreateGroupAndAddGroupUser = function (groupid, el, chatel, update, groupname, groupdescript, cb) {
- var i,
- _groupinfo, //群信息
- _inputs = U.selectEl("input,textarea", el), //输入的群信息
- _adduserinfo = U.MD.F.J.selectUserInfo.NeedUser, //需要添加用户的集合
- _userid = US.userInfo.UserId, //用户的id
- _groupname = groupname == undefined ? _inputs[0].value : groupname, //创建的群名
- _groupdescript = groupdescript == undefined ? _inputs[1].value : groupdescript, //创建的群描述
- _groupuserids = U.Json.toKeyArray(_adduserinfo, "UserId").join(",") //添加进入群所有好友的id
- ;
- //如果群不存在则创建
- if (!groupid) {
- if (_groupname == "") {
- for (var i = 0; i < _adduserinfo.length; i++) {
- _groupname = _groupname + "、" + _adduserinfo[i].UserNickName;
- }
- _groupname = _groupname + "、" + US.userInfo.UserNickName;
- _groupname = _groupname.substr(1, _groupname.length);
- }
- groupid = Guid.newGuid(); //新建一个群id
- _groupinfo = new U.MD.F.T.groupEntity(groupid, _groupname, new Date(), _userid, _groupdescript, null); //添加群实体
- //获取创建群后,拉进群用户里包括自己
- _adduserinfo.push(US.userInfo);
- if (_groupuserids) {
- _groupuserids = _userid + "," + _groupuserids;
- } else {
- _groupuserids = _userid;
- }
- //关闭弹框
- U.UF.F.closeWindow($(el).Parent({ usform: "true" }), "remove");
- }
- //群存在操作
- else {
- _groupinfo = U.Json.select(US.friend.group, { "GroupManageID": groupid })[0]; //获取群
- }
- // _adduserinfo = _adduserinfo.splice(0, _adduserinfo.length); //移除全局变量,把需要添加的用户删除
- //创建群成员,给每个群成员发送一条建立群给拉入群的消息
- U.A.Request(US.FRIEND, ["CreateGroupAndAddUser", _userid, groupid, _groupname, _groupdescript, _groupuserids],
- U.MD.F.J.asynDetermineCreateGroupAndAddGroupUser, ["", _groupinfo, _adduserinfo, groupid, _groupname, _groupdescript, el, chatel, _groupuserids, update, cb]); //添加到数据库
- }
- /**
- * 异步创建群
- * @param {object} 服务器返回的值
- */
- U.MD.F.J.asynDetermineCreateGroupAndAddGroupUser = function (r) {
- var i,
- _context = r.context, //回调函数的值
- _directory,
- _diskinfo,
- _groupuser,
- _userinfo = US.userInfo, //回调的用户信息
- _groupinfo = _context[1], //当前群信息
- _groupuserinfo = _context[2], //用户信息集合
- _groupid = _context[3], //群id
- _groupname = _context[4], //群名
- _groupdescript = _context[5] //群描述
- ;
- r = r.value; //获取服务器的返回值
- //创建群或者修改群成功o
- if (r !== false) {
- //如果新建的群不存在全局变量中,则新建一个
- if (!U.Json.select(US.friend.group, { "GroupManageID": _groupid })[0]) {
- US.friend.group.unshift(_groupinfo); //把群插入全局变量中
- //新建一个群目录
- _directory = new U.MD.DK.M.entity(_groupinfo.GroupManageID, 0, US.userInfo.UserId, _groupinfo.GroupManageName, _groupinfo.GroupManageName,
- "folder", null, new Date(), U.MD.DK.C.getIcon("folder")[1], 1, null, null, 0, "", _groupinfo.GroupManageID);
- //调用添加文件到disk全局的方法
- _diskinfo = U.MD.DK.M.diskOperatingSwitch(_userinfo.UserId); //根据userid获取网盘的信息
- U.MD.DK.M.entity.add([_directory], _diskinfo); //添加到disk全局里
- }
- //如果群已经存在了,那么修改群名和群描述
- else {
- _groupinfo.GroupManageName = _groupname; //群名
- _groupinfo.GroupManageDescript = _groupdescript; //群描述
- }
- //把群的用户添加到群用户数组里
- for (i = 0; i < _groupuserinfo.length; i++) {
- _groupuser = new U.MD.F.T.groupUserEntity(_groupuserinfo[i].UserId, _groupuserinfo[i].UserImageHead,
- _groupuserinfo[i].UserNickName, _groupuserinfo[i].UserName, _groupuserinfo[i].UserThumbnailImageHead,
- _groupuserinfo[i].UserNickName, _groupid, 1); //新建一个群用户
- US.friend.groupusers.push(_groupuser); //添加到群用户里
- }
- //创建群成功后,直接点击查看群。
- U.selectEl($("#U_MD_F_H_ZLTA").Child()[2]).Child()[0].onclick();
- //提示语
- if (_groupinfo && _groupuserinfo.length > 0) { //判断是否有邀请好友
- if (_groupinfo) {
- var _alert = _groupname + "邀请成功";
- } else {
- var _alert = "邀请好友请入群成功~";
- }
- //清空群用户
- U.MD.F.J.selectUserInfo.NeedUser.splice(0, U.MD.F.J.selectUserInfo.NeedUser.length);
- U.Alert(_alert);
- //点击'确定'按钮
- } else {
- U.selectEl('#U_MD_F_Add_O')[0].style.display = "none";//隐藏群组信息窗口
- }
- }
- //创建失败的提示
- else {
- U.Alert("服务器繁忙,请从新创建!!");
- }
- }
- /*
- * 弹框询问用户是否创建这个群
- * @param groupid 群的id
- * @param groupname 群名
- * @param groups 群的描述
- * @param fileid 文件id
- * @param cb 回调函数 点击确定后的回调函数
- */
- U.MD.F.J.isCreateGroup = function (groupid, groupname, groupds, fileid, cb) {
- _isgroup = U.Json.select(US.friend.group, { "GroupManageID": groupid })[0]; //判断群是否已经存在在列表中
- //判断是否存在这个群
- if (!_isgroup) {
- var _elparent = $$("div", {}); //创建父级元素
- var _elcontent = $$("div",
- {
- "className": "U_MD_F_A_T",
- "innerHTML": "您的文档将移至新建群里(" + groupds + "),是否新建群组?"
- }, //创建弹窗内容
- _elparent);
- var _elall = $$("div",
- {
- "className": "U_MD_F_A_T_All"
- }, //创建信息父级元素
- _elparent);
- var _elbutton = $$("div",
- {
- "className": "U_MD_F_A_T_OFF",
- "innerHTML": "取消"
- }, //取消按钮
- _elall);
- $$("div",
- {
- "className": "U_MD_F_A_T_OUT",
- "innerHTML": "确认",
- "onclick": function () {
- U.MD.F.J.changeInfo(groupid, groupname, groupds, fileid, cb); //点击确定后的点击事件
- }
- }, //确定按钮
- _elall);
- _elbutton.onclick = function () {
- U.selectEl("#U_MD_D_emp_CK")[0].close()
- } //点击取消按钮后关闭窗口
- new U.UF.UI.form("提示",
- _elparent,
- {
- "id": "U_MD_D_emp_CK",
- "style": {
- "width": "250px",
- "height": "170px"
- }
- },
- {
- istop: true,
- isdrag: false,
- isnarrow: false,
- isenlarge: false
- }).form;
- } else {
- U.MD.F.J.changeInfo(groupid, groupname, groupds, fileid, cb)//判断群存在时,默认执行点击确定后的点击事件
- }
- }
- /*
- * 获取所选择的联系人,发送消息
- * @param groupid 群id
- * @param grouopname 群名
- * @param groupds 群描述
- * @param fileid 文件id
- * @param cb 回调函数
- */
- U.MD.F.J.changeInfo = function (groupid, groupname, groupds, fileid, cb) {
- var i, _isgroup,
- // _UCB = U.MD.F.J.asynDetermineCreateGroupAndAddGroupUser, //创建群异步回调
- _groupsign = 1, //判断是否已经创建。如果没有创建,就把_UTF的值设置为0,0在存储过程的传参作用是创建群, 1是不创建直接修改群名
- _userid = US.userInfo.UserId, //当前用户id 也是群主id
- _groupinfo = [groupname, groupds], //群名和群描述的数组 [0]群名 [1]群描述
- _groupfriend = U.MD.F.J.selectUserInfo.NeedUser, //需要添加用户的集合(群用户)
- _grouparr = new Array(); //创建一个新的数组
- //循环所有需要添加用户的集合
- for (var i = 0; i < _groupfriend.length; i++) {
- var pd = 0;
- //循环群数组里是否有内容
- for (var u = 0; u < _grouparr.length; u++) {
- if (_grouparr[u].UserId == _groupfriend[i].UserId || _groupfriend[i].UserId == US.userInfo.UserId) {//判断群数组是否存有需要添加到群的用户
- pd++
- }
- }
- if (pd == 0) {
- _grouparr.push(_groupfriend[i]); //把需要添加的用户信息存入数组中
- }
- }
- _frienduser = U.Json.toKeyArray(_grouparr, "UserId").join(","), //用,分割群用户的id 例: userid,userid
- _useridarr = U.Json.toKeyArray(_grouparr, "UserId").join(","); //用,分割群用户的id 例: userid,userid
- _isgroup = U.Json.select(US.friend.group, { "GroupManageID": groupid })[0]; //判断群是否已经存在在列表中
- if (!_isgroup) { //判断群是否存在
- _groupsign = 0;
- groupid = groupid || Guid.newGuid(); //没有群id创建一个群id
- //创建群的实体,主要是用于添加到US.friend[2]这个群集合里面
- _isgroup = new U.MD.F.T.groupEntity((groupid = groupid || Guid.newGuid()), _groupinfo[0], new Date(), _userid, _groupinfo[1], null); //拼接群用户id 把本人也添加到这个群里
- //判断是否有分割群用户的id,如果有,就拼接起来
- if (_useridarr) {
- _useridarr = _userid + "," + _useridarr
- } else { //如果没有,就直接添加
- _useridarr = _userid + "" + _useridarr
- }
- }
- // _groupfriend.splice(0, _groupfriend.length); //添加成功后移除用户
- //创建群成员,给每个群成员发送一条建立群给拉入群的消息
- U.A.Request(US.FRIEND, ["CreateGroupAndAddUser", _userid, groupid, _groupinfo[0], _groupinfo[1], _useridarr], U.MD.F.J.asynChangeInfo, ["", _isgroup, _grouparr.splice(0, _grouparr.length), groupid, _groupinfo[0], _groupinfo[1], cb, _frienduser, groupid, _groupinfo[0]]); //添加到数据库
- // U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "CreateGroupAndAddUser", _userid, _groupinfo[0], _groupinfo[1], groupid, _useridarr, _groupsign], U.MD.F.J.asynChangeInfo, ["", _isgroup, _grouparr.splice(0, _grouparr.length), groupid, _groupinfo[0], _groupinfo[1], cb, _frienduser, groupid, _groupinfo[0]]); //添加到数据库
- //给每个群成员发送一条有关于这个uw文件的消息
- // U.A.Request(US.CD, ([US.DB, "UseStudio_Friends", "SentMessageToFriend", US.userInfo.UserId, _frienduser, US.userInfo.UserNickName || US.userInfo.UserName, '' + groupid + ',' + _groupinfo[0] + ',' + _isgroup.GroupManageCreateDate + ',' + fileid + ',' + _isgroup.GroupManageName + '.UW', 5, false]), function(){}, [""]);
- U.selectEl("#U_MD_D_emp_CK").hide()//隐藏元素
- }
- /**
- * 确定添加按钮
- *点击好友添加确定按钮,去数据库创建一个群
- * @param {object} 添加好友窗体
- */
- U.MD.F.J.asynChangeInfo = function (r) {
- U.MD.F.J.asynDetermineCreateGroupAndAddGroupUser(r); //回调原本创建群的流程函数 这里地方不调用的话 会导致原本在好友聊天中创建群成员和群用不了
- var _context = r.context; //获取信息
- _context[6](_context[1], _context[7], _context[8], _context[9]); //回调群id
- }
- /**
- * 无认证直接加入群
- *
- * @param {object} 群信息
- * @param {function} 群id
- */
- U.MD.F.J.addUsersToGroup = function (groupinfo, cb) {
- if (!U.MD.U.L.isLogin()) {//判断是否登录
- var _userinfo = US.userInfo, //用户信息表
- _userid = _userinfo.UserId, //用户id
- _groups = US.friend.group, //用户群
- _group = U.Json.select(_groups, { "GroupManageID": groupinfo.GroupManageID })[0]; //用户群
- //判断用户是否已经加入群组
- if (!_group) {
- U.alert("正在加入,请稍等..");
- //加入群组处理
- U.A.Request(US.FRIEND, ["AddUsersToGroup", US.userInfo.UserId, groupinfo.GroupManageID, _userid], U.MD.F.J.asynAddUsersToGroup, ["", { MessageContent: groupinfo.GroupManageID, MessageDescript: groupinfo.GroupManageName, UserId: groupinfo.UserId },]);
- }
- //否则直接查看群消息
- else {
- if (cb) {
- cb();
- }
- else { U.MD.F.W.viewFriend(_group); }
- }
- }
- }
- //用户直接进入群异步
- U.MD.F.J.asynAddUsersToGroup = function (r) {
- var _context = r.context,
- _cb = _context[2], //回调函数
- _userid = US.userInfo.UserId, //用户id
- _diskinfo = US.disk.Disks[_userid], //网盘信息
- _groupinfo = U.MD.F.N.asynPulledIntoGroups(r); //添加群文件
- //回调函数处理
- if (_cb) {
- U.UF.C.apply(this, _cb)();
- }
- //查看用户信息
- else {
- U.MD.F.W.viewFriend(_groupinfo);
- }
- U.selectEl($("#U_MD_F_H_ZLTA").Child()[2]).Child()[0].onclick();
- U.alert("成功加入该群");
- }
- //#endregion
- /**
- * 弹出好友添加使用
- *
- * @param {object} 群信息
- */
- U.MD.F.J.addPopup = function () {
- var _el;
- _el = $$("div", { "className": "U_MD_F_A" });
- $$("div", { "className": "U_MD_F_RA", "onclick": U.MD.F.M.createFriendGroupPopup, "innerHTML": "添加分组" }, _el); //添加分组按钮
- $$("div", { "className": "U_MD_F_RA_E", "onclick": "U.MD.F.S.popSearchFriendsOrGroupForm(0);", "innerHTML": "添加/<br>查找好友" }, _el); //查找好友
- $$("div", { "className": "U_MD_F_RA", "onclick": "U.MD.F.S.popSearchFriendsOrGroupForm(1)", "innerHTML": "加入群组" }, _el); //加入群聊 U.MD.F.S.popupsSearchGroups
- $$("div", { "className": "U_MD_F_RA", "onclick": "U.MD.F.J.groupInfoForm();", "innerHTML": "创建群组" }, _el); //创建群聊
- new U.UF.UI.form("添加好友/群聊", _el, { 'id': 'U_MD_F_addFriendorGroup', "style": { "width": "390px", "height": "220px" } }, { isenlarge: false, isnarrow: false });
- };
- /**
- *
- * @param el 准备隐藏的元素
- * @param nel 准备显示的元素
- * @param elparent 准备隐藏的元素的父亲元素
- * @param clickel 上一次点击的元素
- * @param thisel 点击的元素
- * @returns {*} 返回这次点击的元素
- */
- U.MD.F.J.alterNately = function (el, nel, elparent, clickel, thisel) {
- if (thisel != clickel) {
- nel.style.display = 'none';
- nel.previousElementSibling.children[0].src = "/img/arrowR.png";
- var con = U.selectEl(nel).find('.U_MD_F_RC_COIO');
- for (var i = 0; i < con.length; i++) {
- con[i].className = "U_MD_F_RC_COI U_Img"
- }
- U.MD.F.J.selectUserInfo.NeedUser = [];
- U.selectEl(elparent).find('.U_MD_F_RC_C_C')[0].innerHTML = "";
- U.selectEl(elparent).find('.U_MD_F_RC_C_T')[0].innerText = 0;
- }
- if (el.style.display == 'none') {
- el.style.display = 'block';
- el.previousElementSibling.children[0].src = "/img/arrowB.png";
- } else {
- el.style.display = 'none';
- el.previousElementSibling.children[0].src = "/img/arrowR.png";
- }
- return thisel
- }
- /**
- * 选择联系人选择功能
- * @param el 用户信息元素
- * @param boxele 选择联系人大元素
- * @param type 点击的类型 分为'group'和'friend'
- * @param cthis 选中的元素
- */
- U.MD.F.J.showChoose = function (firendinfo, el, boxele, type, cthis) {
- var _fel = U.selectEl($(boxele).find('.U_MD_F_RC_C_C')[0]).find("div[fid='" + U.selectEl(el.parentNode).attr('fid') + "']")[0],
- _leftShowEl = U.selectEl(boxele).find('.U_MD_F_RC_C_C')[0],
- _cNam = cthis && U.selectEl(cthis.parentNode).find('.U_MD_F_RC_COIO') || []
- if (_cNam.length && _cNam[0].parentNode.getAttribute('fid') != U.selectEl(cthis).attr('fid')) {
- var _delElFid = U.selectEl($(_cNam)[0].parentNode).attr('fid')
- _cNam[0].className = _cNam[0].className.replace(' U_MD_F_RC_COIO', '');
- U.selectEl($(boxele).find("div[fid='" + _delElFid + "']")[1]).remove()
- U.MD.F.J.selectUserInfo.NeedUser = []
- }
- if (!_fel) {
- var addel = $$('div', { className: "U_MD_F_RC_C_C_A", fid: U.selectEl(el.parentNode).attr('fid') });
- $$('img', { "onerror": U.MD.C.imgError, src: el.firstElementChild.src }, addel);
- $$('span', { innerText: el.lastElementChild.innerText }, addel)
- addel.onclick = function () {
- U.MD.F.J.clearDefaultStyle();
- addel.className += " U_MD_F_A_AddNewGrouper";
- $$("div", {
- "id": "U_MD_F_A_XX",
- "style": {
- "width": "19px",
- "height": "19px",
- "background-image": "url('/img/YS2017.png')",
- "display": "inline-block",
- "background-repeat": "no-repeat",
- "background-position": "-984px -407px",
- "float": "right",
- "margin": "12px",
- "cursor": "pointer"
- },
- "onclick": function () {
- U.MD.F.J.deleteClick(this, firendinfo, boxele);
- }
- }, addel);
- }
- if (type == "friend") {
- U.selectEl(boxele).find('.U_MD_F_RC_C_C')[0].appendChild(addel);
- } else if (type == "group") {
- _leftShowEl.innerHTML = "";
- if (!cthis.firstChild.className.match('U_MD_F_RC_COIO')) {
- var _groupFid = U.selectEl(el.parentNode).attr('fid'),
- _groupFriends = U.Json.select(US.friend.groupusers, { "GroupManageID": _groupFid })
- _newEl = $$('div');
- for (var i = 0; i < _groupFriends.length; i++) {
- var _cloneEl = addel.cloneNode(true);
- _cloneEl.setAttribute('fid', _groupFriends[i].UserId)
- _cloneEl.fid = _groupFriends[i].UserId;
- _cloneEl.firstChild.src = U.MD.C.getHeadImage(_groupFriends[i].UserImageHead) || "/img/UserHead/UseHead.jpg";
- _cloneEl.lastChild.innerText = _groupFriends[i].UserName;
- _newEl.appendChild(_cloneEl);
- }
- _leftShowEl.appendChild(_newEl);
- U.MD.F.J.selectUserInfo.NeedUser = _groupFriends;
- }
- U.selectEl(boxele).find('.U_MD_F_RC_C_T')[0].innerText = _leftShowEl.children[0] ? _leftShowEl.children[0].children.length : 0;
- return;
- }
- } else {
- U.selectEl(_fel).remove()
- }
- U.MD.F.J.clearDefaultStyle();
- var _lastChild = U.selectEl(".U_MD_F_RC_C_C.U_MD_F_RC_C")[1].lastChild;
- _lastChild.className += " U_MD_F_A_AddNewGrouper";
- $$("div", {
- "id": "U_MD_F_A_XX",
- "style": {
- "width": "19px",
- "height": "19px",
- "background-image": "url('/img/YS2017.png')",
- "display": "inline-block",
- "background-repeat": "no-repeat",
- "background-position": "-984px -407px",
- "float": "right",
- "margin": "12px"
- },
- "onclick": function () {
- U.MD.F.J.deleteClick(this, firendinfo, boxele);
- }
- }, _lastChild);
- U.selectEl(boxele).find('.U_MD_F_RC_C_T')[0].innerText = _leftShowEl.children.length;
- }
- /**
- * 清空默认选中样式功能
- */
- U.MD.F.J.clearDefaultStyle = function () {
- var targerList = U.selectEl(".U_MD_F_RC_C_C.U_MD_F_RC_C")[1].children//已选择联系人的列表
- for (var i = 0; i < targerList.length; i++) {
- targerList[i].className = "U_MD_F_RC_C_C_A"; //修改所有已选择联系人className
- U.selectEl("#U_MD_F_A_XX")[0] ? U.selectEl("#U_MD_F_A_XX")[0].remove() : ""; //判断是否含有删除按钮
- };
- }
- /**
- * 删除已选择联系人功能
- * @param div 选中元素
- * @param firendinfo 用户信息元素
- * @param boxele 选择联系人窗口
- */
- U.MD.F.J.deleteClick = function (div, firendinfo, boxele) {
- window.event ? window.event.cancelBubble = true : e.stopPropagation();
- var _fid = div.parentNode.fid; //该联系人fid
- U.Json.del(U.MD.F.J.selectUserInfo.NeedUser, { "UserId": firendinfo.UserId }); //从json数组中删除该联系人
- div.parentNode.remove(); //从已选择联系人列表里删除该联系人
- U.selectEl(boxele).find('.U_MD_F_RC_C_T')[0].innerText = U.selectEl(boxele).find('.U_MD_F_RC_C_C')[0].children.length; //更改已选择联系人的数量
- var _list = U.selectEl(".U_MD_F_RC_CO"); //好友列表
- for (var x = 0; x < _list.length; x++) {
- if (_list[x].FID == _fid) {//判断是否等于该联系人fid
- _list[x].children[0].className = "U_MD_F_RC_COI U_Img"; //修改该联系人已选中的按钮样式
- }
- }
- }
- /**
- * 一键创建群聊
- * @param div 选中元素
- */
- U.MD.F.J.oneKeyCreateGroup = function (groupid, el, chatel, update, cb) {
- var i,
- _groupinfo, //群信息
- //_inputs = U.selectEl("input,textarea", el), //输入的群信息
- _adduserinfo = U.MD.F.J.selectUserInfo.NeedUser, //需要添加用户的集合
- _userid = US.userInfo.UserId, //用户的id
- _groupname = "协同文档群-" + (new Date().getHours().toString()[1] ? new Date().getHours() : "0" + new Date().getHours()) + ":" + (new Date().getMinutes().toString()[1] ? new Date().getMinutes() : "0" + new Date().getMinutes()), //创建的群名
- _groupdescript = "", //创建的群描述
- _groupuserids = U.Json.toKeyArray(_adduserinfo, "UserId").join(",") //添加进入群所有好友的id
- ;
- //如果群不存在则创建
- if (!groupid) {
- if (_groupname == "") {
- for (var i = 0; i < _adduserinfo.length; i++) {
- _groupname = _groupname + "、" + _adduserinfo[i].UserNickName;
- }
- _groupname = _groupname + "、" + US.userInfo.UserNickName;
- _groupname = _groupname.substr(1, _groupname.length);
- }
- groupid = Guid.newGuid(); //新建一个群id
- _groupinfo = new U.MD.F.T.groupEntity(groupid, _groupname, new Date(), _userid, _groupdescript, null); //添加群实体
- //获取创建群后,拉进群用户里包括自己
- _adduserinfo.push(US.userInfo);
- if (_groupuserids) {
- _groupuserids = _userid + "," + _groupuserids;
- } else {
- _groupuserids = _userid;
- }
- //关闭弹框
- //U.UF.F.closeWindow($(el).Parent({ usform: "true" }), "remove");
- }
- // _adduserinfo = _adduserinfo.splice(0, _adduserinfo.length); //移除全局变量,把需要添加的用户删除
- //创建群成员,给每个群成员发送一条建立群给拉入群的消息
- U.A.Request(US.FRIEND, ["CreateGroupAndAddUser", _userid, groupid, _groupname, _groupdescript, _groupuserids],
- U.MD.F.J.asynDetermineCreateGroupAndAddGroupUser, ["", _groupinfo, _adduserinfo, groupid, _groupname, _groupdescript, el, chatel, _groupuserids, update, cb]); //添加到数据库
- };
- ///<jscompress sourcefile="Friend.js" />
- /*
- 问题:
- 1、整套好友的功能流程图
- 2、设计缺少流程 只有大流程 没有那个按钮的细节流程
- */
- Namespace.register("U.MD.F"); //好友主命名空间
- /*
- * U.MD.F.initFriend 初始化加载好友(初始化好友模块)判断好友窗体是否创建,创建了则初始化创建消息提示图标,点击好友窗体的最近功能按钮
- * U.MD.F.newFriendTips 创建用户提示图标 (在桌面创建一个企鹅图标) 添加用户提示区域
- * U.MD.F.printFriendGroupOrFriend 用户列表好友打印 (点击左上好友功能打印好友列表) 清空好友窗体左边列表内容,判断用户是否拥有好友,有则先创建好友分组,然后根据好友分组打印好友,最后添加进好友窗体。如果没有好友窗体,则触发U.MD.F.printHasNoFriend(_frag)向用户推荐好友
- * U.MD.F.printFriendOrGroup 好友和群样式输出 (打印好友或群的样式在左边聊天列表) 根据用户好友或群数量打印在左边列表,并添加好友或群头像,名字等样式,然后根据UserId和GroupManageID区分好友和群分别添加点击事件,鼠标右击事件,
- * U.MD.F.openOrCloseFriendClass 好友功能下点击分组 (显示或隐藏好友分组下的好友列表) 获取您点击的分组的好友列表元素,判断它的状态(style.display)是隐藏还是显示。隐藏则显示,显示就隐藏
- *
- */
- //#region 初始化好友
- //初始化好友函数
- /**
- * 初始化加载好友
- */
- U.MD.F.initFriend = U.MD.F.CSHFG = function () {
- //如果第三方应用1473,包含了好友窗体。
- if ($("#U_MD_F_H_Z")[0]) {
- var i,
- _friendinfo,
- _selectbottomel,
- _childsel,
- _chatform = U.selectEl("#U_MD_F_H_Z")[0], //好友窗体
- _userinfoel = U.selectEl("#U_MD_F_H_ZLTI", _chatform)[0]; //多好友分栏
- //初始化出现右边的好友聊天
- U.MD.F.W.friendDisplayAndNone([{
- "display": "none",
- "left": "auto"
- },
- {
- "display": "block",
- "top": (US.height - 530) / 2,
- "right": "0px"
- }], true);
- //添加当前使用用户的头像
- U.selectEl($("img", _userinfoel)[0] || $$("img")).addAttrArray({
- "onerror": U.MD.C.imgError,
- "src": U.MD.C.getHeadImage(US.userInfo.UserThumbnailImageHead),
- "onclick": U.MD.U.P.userDataSet
- }).appendTo(_userinfoel);
- if (US.friend.recentcontacts.length) {
- _friendinfo = US.friend.recentcontacts;
- }
- else {
- _friendinfo = US.friend.friends;
- }
- U.MD.F.printRightFormFriend(_friendinfo, U.selectEl("#U_MD_F_H_RC")[0]); //右侧好友最近联系人
- U.MD.F.newFriendTips(); //初始化好友提示
- //我的好友、我的群组等按钮,默认显示我的好友 所以找到我的好友的按钮,并且默认调用onclick
- _selectbottomel = U.selectEl("#U_MD_F_H_ZLTA").Child()[0];
- U.selectEl(_selectbottomel).Child()[0].onclick();
- }
- }
- /**
- * 初始化右边好友出现
- *
- * @param {object} 好友头像处理
- * @param {element} 元素处理
- */
- U.MD.F.printRightFormFriend = function (friendinfo, el) {
- var i,
- _tempel,
- _temponeel,
- _frag = $$("frag"),
- _childs = U.selectEl(el).Child();
- //如果是用户登录多次,移除之前残留的信息
- for (i = 1; i < _childs.length; i++) {
- el.removeChild(_childs[i]);
- }
- //如果有好友资料输出
- if (friendinfo.length) {
- //循环打印好友资料
- for (i = 0; (i < friendinfo.length && i < 11); i++) {
- //群信息打印
- if (friendinfo[i].tf == 1) {
- friendinfo[i] = U.Json.select(US.friend.group, { "GroupManageID": friendinfo[i].UserId })[0];
- _friendoneel = $$("div", {
- "className": "U_MD_F_H_ZLZOCOI", "style": { "margin": "9px 0 0 10px" }, "title": friendinfo[i].GroupManageName, "onclick": U.UF.C.closure(function (friendinfo) {
- U.UF.EV.stopBubble();
- U.MD.F.W.popupFriendsForm(friendinfo);
- }, [friendinfo[i]])
- }, _frag);
- U.MD.F.printGroupHeadImage(friendinfo[i], _friendoneel, 4, [35, 35]);
- }
- //用户打印
- else {
- $$("img", {
- "onerror": U.MD.C.imgError,
- "title": friendinfo[i]["FriendsDescript"],
- "className": "U_MD_F_H_RCI",
- "src": U.MD.C.getHeadImage(friendinfo[i].UserThumbnailImageHead),
- "alt": friendinfo[i].FriendsDescript || friendinfo[i].UserNickName,
- "onclick": U.UF.C.closure(function (friendinfo) {
- U.UF.EV.stopBubble();
- U.MD.F.W.popupFriendsForm(friendinfo);
- U.MD.F.N.canelMarkMessage(friendinfo);
- }, [friendinfo[i]])
- }, _frag);
- }
- }
- }
- //暂无好友追随
- else {
- _tempel = $$("div", { "className": "U_MD_F_H_RCT" }, _frag);
- _temponeel = $$("div", { "className": "U_MD_F_H_RCTS" }, _tempel);
- $$("img", { "onerror": U.MD.C.imgError, "src": "/img/YSUN.png" }, _temponeel);
- $$("div", { "className": "U_MD_F_H_RCTZ U_Img" }, _tempel);
- $$("div", { "className": "U_MD_F_H_RCTX", "innerHTML": "暂时无追随" }, _tempel);
- }
- el.appendChild(_frag);
- }
- /**
- * 用户提示区域
- *
- */
- U.MD.F.newFriendTips = function () {
- if (!$('.U_MD_D_NewsTipsIcon')[0]) {//判断图标是否已经存在
- var _tipsicon = $$("div", { className: "U_MD_D_NewsTipsIcon" }, U.selectEl("#U_MD_F_H_R")[0]);
- _tipsicon.onmousedown = function () { U.UF.F.drag(_tipsicon); };
- }
- }
- /**
- * 用户列表好友打印
- *
- * @param {element} 元素11
- */
- U.MD.F.printFriendGroupOrFriend = function (el) {
- var i,
- _tempel,
- _temponeel,
- _classinfo,
- _friendinfo = US.friend.allclass,
- _frag = $$("frag");
- el.innerText = "";
- //如果用户有好友则打印
- if (US.friend.friends.length) {
- //循环打印好友分组
- for (i = 0; i < _friendinfo.length; i++) {
- _classinfo = U.Json.select(US.friend.friends, { "FriendsGroupID": _friendinfo[i].FriendsGroupID }); //根据好友分组获取好友
- //打印好友分组
- _tempel = $$("div", { id: "g" + _friendinfo[i].FriendsGroupID, "tid": _friendinfo[i].FriendsGroupID, "className": "U_MD_F_H_ZLZO" }, _frag);
- U_MD_F_H_ZLZOT_Img = '<div class="U_MD_F_H_ZLZOT_img"></div>';//插入分组前图标样式
- $$("div", {
- "className": "U_MD_F_H_ZLZOT",
- "innerHTML": U_MD_F_H_ZLZOT_Img + _friendinfo[i].FriendsGroupName + "(" + _classinfo.length + ")",
- "onclick": U.UF.C.closure(function (i) {
- U.MD.F.openOrCloseFriendClass(this);
- }, [i]),
- "oncontextmenu": U.UF.C.closure(function (i) {
- U.MD.F.R.friendClassRightClickMenu(US.friend.allclass[i], this);
- }, [i])
- }, _tempel);
- _temponeel = $$("div", { "className": "U_MD_F_H_ZLZOC" }, _tempel);
- //打印好友
- U.MD.F.printFriendOrGroup(_temponeel, _classinfo);
- }
- }
- //无好友打印提示
- else {
- U.MD.F.printHasNoFriend(_frag);
- }
- el.appendChild(_frag);
- }
- /**
- * 好友和群样式输出
- *
- * @param {element} 元素
- * @param {array} 好友数组
- */
- U.MD.F.printFriendOrGroup = function (el, friendorgroupinfo, isinsert) {
- var i,
- _isfront,
- _friendel,
- _friendoneel,
- _friendtwoel,
- _onlinefrag = $$("frag"),
- _offlinefrag = $$("frag");
- //循环所有的好友或者群,打印到左边好友或群面板中
- if (friendorgroupinfo.length == 0) {
- $$("div", { "class": "U_MD_F_H_ZLZOCO_under", "style": { "margin": "9px 0 0 10px" }, "innerHTML": "该分组暂无好友" }, el);
- }
- else {
- for (i = 0; i < friendorgroupinfo.length; i++) {
- if (friendorgroupinfo[i].tf == 1) {
- friendorgroupinfo[i] = U.Json.select(US.friend.group, { "GroupManageID": friendorgroupinfo[i].UserId })[0]
- }
- _friendel = $$("div", {
- "className": "U_MD_F_H_ZLZOCO",
- "onclick": U.UF.C.closure(function (friendorgroupinfo) {
- U.MD.F.N.canelMarkMessage(friendorgroupinfo);
- U.MD.F.N.cancelNewsMessage(friendorgroupinfo); //点击删除新消息提示图标的提示
- U.MD.F.W.popupFriendsForm(friendorgroupinfo, this);
- }, [friendorgroupinfo[i]]),
- "tid": friendorgroupinfo[i].GroupManageID || friendorgroupinfo[i].UserId,
- "oncontextmenu": U.UF.C.closure(function (friendorgroupinfo) {
- if (friendorgroupinfo.UserId) {
- U.MD.F.R.friendsRightClickMenu(this, friendorgroupinfo);
- U_MD_F_G_Group.style.display = "none";
- }
- else if (friendorgroupinfo.GroupManageID) {
- U.MD.F.R.GroupRightClickMenu(this, friendorgroupinfo);
- U_MD_F_G_Div.style.display = "none";
- }
- }, [friendorgroupinfo[i]])
- });
- _friendoneel = $$("div", { "className": "U_MD_F_H_ZLZOCOI" }, _friendel);
- //如果是群的处理,群的头像输出
- if (friendorgroupinfo[i].GroupManageID) {
- U.MD.F.printGroupHeadImage(U.Json.select(US.friend.group, { "GroupManageID": friendorgroupinfo[i].GroupManageID || friendorgroupinfo[i].UserId })[0], _friendoneel, 4, [35, 35]);
- }
- //好友头像输出
- else {
- $$("img", { "onerror": U.MD.C.imgError, "title": "点击查看", "src": U.MD.C.getHeadImage(friendorgroupinfo[i].UserThumbnailImageHead) }, _friendoneel);
- }
- _friendtwoel = $$("div", { "className": "U_MD_F_H_ZLZOCOR U_MD_D_Text_Abbreviation" }, _friendel);
- $$("div", { "className": "U_MD_F_H_ZLZOCORN U_MD_D_Text_Abbreviation", "innerHTML": friendorgroupinfo[i].FriendsDescript || friendorgroupinfo[i].UserNickName || friendorgroupinfo[i].GroupManageName }, _friendtwoel);
- $$("div", { "className": "U_MD_F_H_ZLZOCORT U_MD_D_Text_Abbreviation", "innerHTML": friendorgroupinfo[i].UserIndividualitysignature || (friendorgroupinfo[i].GroupManageDescript == friendorgroupinfo[i].GroupManageName ? "" : friendorgroupinfo[i].GroupManageDescript) || "" }, _friendtwoel);
- //如果用户在线那么插入到最前面
- if (friendorgroupinfo[i].IsLogin == 1) {
- _onlinefrag.appendChild(_friendel);
- }
- //否则插入到后面
- else {
- _offlinefrag.appendChild(_friendel);
- }
- }
- el.insertBefore(_onlinefrag, el.firstChild); //在线用户插入到最前面
- //如果需要插入到最前面,那么则不管在不在线的用户都插入到最前面
- if (isinsert) {
- el.insertBefore(_offlinefrag, el.firstChild); //用户插入到最前面
- }
- else {
- el.appendChild(_offlinefrag); //非在线用户插入到最后米娜
- }
- }
- }
- /**
- * 打开分组展开好友
- *
- * @param {element} 展开好友的区域
- */
- U.MD.F.openOrCloseFriendClass = function (el) {
- var _firendel = U.selectEl($(el).Parent()).Child()[1]; //获取好友分组对应的好友元素
- //如果现在隐藏了则打开
- if (_firendel.style.display == "none") {
- U.selectEl($($(el).Parent()).Child()[0]).Child()[0].style.cssText += "height:6px;width:10px;background:url(/BoomYun/img/pc/U_MD_F_H_ZLZOT_Open.png)";
- _firendel.style.display = "block";
- }
- //如果是显示则隐藏
- else {
- U.selectEl($($(el).Parent()).Child()[0]).Child()[0].style.cssText += "height:10px;width:6px;background:url(/BoomYun/img/pc/U_MD_F_H_ZLZOT_Retract.png)";
- _firendel.style.display = "none";
- }
- }
- /**
- * 打印空好友
- *
- * @param {element} 打印的区域
- */
- U.MD.F.printHasNoFriend = function (el) {
- var _tempel,
- _temponeel
- ;
- _tempel = $$("div", { "className": "U_MD_F_H_ZLZT" }, el);
- _temponeel = $$("div", { "className": "U_MD_F_H_ZLZTS" }, _tempel);
- $$("img", { "onerror": U.MD.C.imgError, "src": "/img/YSUN.png" }, _temponeel);
- $$("div", { "className": "U_MD_F_H_ZLZTZ U_Img" }, _tempel);
- $$("div", { "className": "U_MD_F_H_ZLZTX", "innerHTML": "暂时没有添加追随!!" }, _tempel);
- }
- //#endregion
- //#region 好友功能
- /**
- * 打印空好友
- *
- * @param {string} 切换类型
- * @param {element} 点钱点击的区域
- * @param {element} 变化的样式
- */
- U.MD.F.switchFriendOrGroup = function (typename, el, classname) {
- var i,
- _chatform = U.selectEl("#U_MD_F_H_ZLZ")[0], //打印内容区域
- _childsel = U.selectEl(el).parentElement(2).Child(), //所有参与切换的元素
- _classarray = ["U_MD_F_H_ZLTT", "U_MD_F_H_ZLTO", "U_MD_F_H_ZLTS", "U_MD_F_H_ZLTF"]; //切换样式数组
- //切换按钮的样式,把样式改成用户默认按钮的样式
- for (i = 0; i < _childsel.length; i++) {
- U.selectEl(_childsel[i]).Child()[0].className = _classarray[i] + " U_Img U_MD_F_H_ZLTOK";
- }
- //设置选中的按钮样式
- el.className = classname + " U_Img U_MD_F_H_ZLTOK";
- //点击好友添加按钮
- if (typename == "A") {
- U.MD.F.M.createFriendGroupPopup(); //调用创建群弹框
- }
- else {
- //群成员
- if (typename == "H") {
- var _grouparr = US.friend.group; //获取用户或有群信息
- _chatform.innerText = ""; //清空展示区域的内容
- U.MD.F.printFriendOrGroup(_chatform, _grouparr); //打印
- }
- //最近联系人
- else if (typename == "G") {
- var _recentcontacts = US.friend.recentcontacts;
- _chatform.innerText = ""; //清空展示区域的内容
- U.MD.F.printFriendOrGroup(_chatform, _recentcontacts); //打印
- }
- //打印好友,由于好友有好友分组,所以不能直接调用U.MD.F.printFriendOrGroup输出
- else {
- U.MD.F.printFriendGroupOrFriend(_chatform); //打印
- }
- }
- }
- /**
- * 获取群里头像集
- *
- * @param {object} 群信息
- * @param {element} 添加指定的元素
- * @param {element} 变化的样式
- * @param {element} 最大长度
- */
- U.MD.F.printGroupHeadImage = function (groupinfo, el, num, size) {
- var i, j,
- _groupnameel,
- _horizontal,
- _vertical,
- _imageel,
- _groupuserinfo = U.Json.select(US.friend.groupusers, { "GroupManageID": groupinfo.GroupManageID }, (num || 9)); //获取当前群
- if (_groupuserinfo.length < 3) {
- _horizontal = _groupuserinfo.length;
- }
- else {
- if (_groupuserinfo.length > 6) {
- _horizontal = 3;
- } else {
- _horizontal = 2;
- }
- }
- //每排几个
- if (_groupuserinfo.length > 4) {
- _vertical = 3
- }
- else {
- if (_groupuserinfo.length > 1) {
- _vertical = 2
- } else {
- _vertical = 1
- }
- } //一共多少行
- size = size || [el.offsetHeight || 40, el.offsetWidth || 40]; //最大长宽
- _groupnameel = $$("div", { "className": "U_MD_HomeSSZFZAIO", "title": groupinfo.GroupManageName }); //群名
- //打印所有群成员头像 横排打印
- for (i = 0; i < _horizontal; i++) {
- _imageel = $$("div", { "style": { "width": "100%", "height": Math.floor(size[0] / _horizontal) + "px" } }, _groupnameel);
- //竖排打印
- for (j = i * _vertical; j < i * _vertical + _vertical && j < _groupuserinfo.length; j++) {
- $$("img",
- {
- "onerror": U.MD.C.imgError,
- "src": U.MD.C.getHeadImage(_groupuserinfo[j].UserThumbnailImageHead),
- "style":
- {
- "width": Math.floor(size[1] / _vertical) + "px",
- "height": Math.floor(size[0] / _vertical) + "px"
- }
- }, _imageel);
- }
- };
- //追加
- el.appendChild(_groupnameel);
- }
- //#endregion
- ;
- ///<jscompress sourcefile="FriendData.js" />
- /*
- 此处为数据对应库
- US.friend 集合,里面包含了好友分组,好友,群,群成员,最近联系人。
- US.friend.allclass 数组 是所有的好友分组,结构参见好友分组实体U.MD.F.T.friendGroupEntity
- US.friend.friends 数组 是所有的好友,结构参见好友实体U.MD.F.T.friendEntity
- US.friend.group 数组 是所有的群,结构参见群实体U.MD.F.T.groupEntity
- US.friend.groupusers 数组 是所有的群好友,结构参见群成员实体U.MD.F.T.groupUserEntity
- US.friend.recentcontacts 数组 是所有的在线好友,结构为U.MD.F.T.recentContactsEntity
- 从数据库中取出的数据都要放到此全局变量中,当新建好友,新建分组等时,需要用下面的结构生成新的实体。
- */
- Namespace.register("U.MD.F.T"); //好友数据源操作命名空间
- /**
- * 好友实体
- *
- * @param {array} 好友信息
- ----------[0] 好友签名
- ----------[1] 好友用户id
- ----------[2] 好友原图
- ----------[3] 好友小图
- ----------[4] 好友别名
- ----------[5] 好友用户名
- ----------[6] 好友id
- ----------[7] 好友备注
- ----------[8] 好友分组id
- ----------[9] 是否在线
- */
- U.MD.F.T.friendEntity = function (signature, userid, userimagehead, thumbnailheadimage, nickname, name, friendid, descript, groupid, islogin) {
- this.UserIndividualitysignature = signature;
- this.UserId = userid;
- this.UserImageHead = userimagehead;
- this.UserThumbnailImageHead = thumbnailheadimage;
- this.UserNickName = nickname;
- this.UserName = name;
- this.FriendsID = friendid;
- this.FriendsDescript = descript;
- this.FriendsGroupID = groupid;
- this.IsLogin = islogin;
- }
- /**
- * 最近联系人
- *
- * @param {array} 在线好友信息
- ----------[0] 好友用户id
- ----------[1] 好友用户名
- ----------[2] 好友大图
- ----------[3] 好友昵称
- ----------[4] 好友小图
- ----------[5] 最后聊天时间
- ----------[6] 好友备注
- ----------[7] 好友签名
- ----------[8] 是否在线
- */
- U.MD.F.T.recentContactsEntity = function (userid, username, userimagehead, usernickname, userthumbnailimagehead, sendtime, descript, signature, islogin) {
- this.UserId = userid;
- this.UserName = username;
- this.UserImageHead = userimagehead;
- this.UserNickName = usernickname;
- this.UserThumbnailImageHead = userthumbnailimagehead;
- this.maxMessageSendTime = sendtime;
- this.FriendsDescript = descript;
- this.UserIndividualitysignature = signature;
- this.IsLogin = islogin;
- }
- /**
- * 好友分组实体
- *
- * @param {array} 好友分组信息
- ----------[0] 分组描述
- ----------[1] 分组分组id
- ----------[2] 分组名
- */
- U.MD.F.T.friendGroupEntity = function (groupid, groupname, descript) {
- this.FriendsGroupID = groupid;
- this.FriendsGroupName = groupname;
- this.FriendsGroupDescript = descript;
- }
- /**
- * 群实体
- *
- * @param {array} 群信息
- ----------[0] 群id
- ----------[1] 群名
- ----------[2] 群创建时间
- ----------[3] 群创建用户id
- ----------[4] 群管理用户id
- ----------[5] 群描述
- ----------[6] 群备注
- */
- U.MD.F.T.groupEntity = function (groupid, name, date, userid, descript, remark) {
- this.GroupManageID = groupid;
- this.GroupManageName = name;
- this.GroupManageCreateDate = date;
- this.GroupManageCreateUserID = userid;
- this.GroupManageUserID = userid;
- this.GroupManageDescript = descript;
- this.GroupManageRemark = remark;
- }
- /**
- * 群成员实体
- *
- * @param {array} 群信息
- ----------[0] 群用户id
- ----------[1] 群用户头像
- ----------[2] 群用户昵称
- ----------[3] 群用户名
- ----------[4] 群用户小图
- ----------[5] 群用户描述
- ----------[6] 群id
- ----------[6] 群用户登录信息
- */
- U.MD.F.T.groupUserEntity = function (userid, userimagehead, nickname, name, thumbnailimagehead, descript, groupid, islogin) {
- this.UserId = userid;
- this.UserImageHead = userimagehead;
- this.UserNickName = nickname;
- this.UserName = name;
- this.UserThumbnailImageHead = thumbnailimagehead;
- this.GroupUsersDescript = descript;
- this.GroupManageID = groupid;
- this.IsLogin = islogin;
- }
- /**
- * 循环所有好友,让在线用户都置顶在最上面。
- *
- */
- U.MD.F.T.initFriendInfo = function () {
- var i,
- j,
- _arr = ["friends", "groupusers", "recentcontacts"],
- _userinfo;
- //循环US.friend变量,修改里面的好友、群好友、在线联系人的信息为默认信息,同事设置用户是否在线
- for (i = 0; i < _arr.length; i++) {
- //0 好友分组 1好友信息 2群分组 3群用户 4最近联系人 5在线好友 这里只修改有用户信息的 所以修改为1、3、4
- // if (i == 1 && i == 3 && i == 4) {
- for (j = 0; j < US.friend[_arr[i]].length; j++) {
- _userinfo = US.friend[_arr[i]][j];
- //判断用户是否在线,如果在线设置在线属性为在线
- if (US.friend.onlinefirendinfo.indexOf(_userinfo.UserId) > -1) {
- _userinfo.IsLogin = 1; //设置在线
- }
- //如果是好友信息的修改,由于从数据库里面选出来的数据有null值,所以这里把null过滤了
- if (i != 1) {
- U.Json.Change(_userinfo, {
- "UserIndividualitysignature": _userinfo["UserIndividualitysignature"] || "",
- "UserNickName": _userinfo.UserName,
- "FriendsDescript": _userinfo["FriendsDescript"] || _userinfo.UserName
- });
- }
- //如果是群好友信息的修改,由于从数据库里面选出来的数据有null值,所以这里把null过滤了
- else {
- U.Json.Change(_userinfo, {
- "UserNickName": _userinfo.UserName,
- "GroupUsersDescript": _UFE[j]["GroupUsersDescript"] || _userinfo.UserName
- });
- }
- }
- //除了最近联系人以外,其他的都要重新排序
- if (i != "recentcontacts") {
- U.Json.Reset(US.friend[_arr[i]], "IsLogin", 1); //设置完在线后,把在线用户发在最前面,这里是根据IsLogin = 1的排序
- }
- }
- // }
- }
- ;
- ///<jscompress sourcefile="FriendSearch.js" />
- Namespace.register("U.MD.F.S");
- U.MD.F.S.SearchPostion; //搜索的时候判断位置
- //#region 本地好友搜索处理
- /**
- * 搜索好友
- *
- * @param {object} 用户信息
- * @param {element} 打印显示的元素
- * @param {object} 回调函数
- * @param {object} 搜索的类型
- * F 好友
- * G 群
- * "" 好友和群
- */
- U.MD.F.S.searchFriendsOrGroupForm = function (inputs, el, cb, typename) {
- var _searchfriendinfo = [], //搜索好友的数组
- _searchvalue = inputs.value, //获取搜索的内容
- _isserch = U.MD.F.S.searchFriendsKeyboardHandle(el, inputs) //是否允许搜索
- ;
- //判断用户键盘输入的内容,是否需要进行搜索
- if (_isserch) {
- //获取搜索好友的值
- if (!typename || typename == "F") {
- _searchfriendinfo = _searchfriendinfo.concat(U.Json.like(US.friend.friends, { "FriendsDescript": _searchvalue, "UserNickName": _searchvalue, "UserName": _searchvalue })); //获取用户好友
- }
- //获取搜索群的值
- if (!typename || typename == "G") {
- _searchfriendinfo = _searchfriendinfo.concat(U.Json.like(US.friend.group, { "GroupManageName": _searchvalue })); //获取好友群
- }
- //显示清空
- el.style.display = "block";
- el.innerText = "";
- //搜索好友的打印
- U.MD.F.S.printSearchFriends(_searchfriendinfo, el, cb);
- };
- }
- /**
- * 搜索键盘的处理
- *
- * @param {object} 用户信息
- */
- U.MD.F.S.searchFriendsKeyboardHandle = function (el, inputs) {
- var _keycode;
- //获取键盘的值
- if (event) {
- _keycode = event.keyCode
- }
- else {
- _keycode = 0
- }
- _childs = U.selectEl(el).Child(), //搜索的内容子元素
- _searchvalue = inputs.value, //搜索的值
- _position = U.MD.F.S.SearchPostion, //搜索的位置
- _searchel = _childs[_position] //搜索得到的元素
- ;
- //判断搜索的值是否存在,不存在则隐藏
- if (_searchvalue == "" || _searchvalue == inputs.defaultValue) {
- el.style.display = "none";
- }
- //如果搜索的内容存在,同时用户执行了回车处理
- else if (_position > -1 && _keycode == 13 || _keycode == 10 && _childs[_position].onmousedown) {
- _childs[_position].onclick();
- }
- //如果不是上下键,那么允许用户继续搜索
- else if (_keycode != 38 && _keycode != 40) {
- U.MD.F.S.SearchPostion = -1; //搜索选择的位置设置为-1
- return true;
- }
- return false;
- }
- /**
- * 打印搜索好友
- *
- * @param {object} 用户信息
- */
- U.MD.F.S.printSearchFriends = function (friendinfo, el, cb) {
- var i,
- _name,
- _tempel,
- _temponeel,
- _temptwoel,
- _frag = $$("frag"),
- _childs = U.selectEl(el).Child();
- //没有搜索到好友的提示
- if (!friendinfo[0]) {
- $$("div", { "className": "U_MD_F_S_Local_NoData", "innerText": "很抱歉,没有找到您搜索的好友" }, el);
- }
- else {
- //循环打印搜索的好友
- for (i = 0; i < friendinfo.length; i++) {
- (function (i) {
- //搜索的名字
- _name = friendinfo[i].GroupManageName || friendinfo[i].FriendsDescript || friendinfo[i].UserNickName || friendinfo[i].UserName;
- //打印的样式
- _tempel = $$("div", {
- "title": "点击查看",
- "className": "U_MD_F_S_Local_Result",
- // "onclick": function () {
- // U.MD.F.S.switchSearchFriendsOrGroup(el, i);
- // },
- "onclick": function () {
- U.MD.F.W.popupFriendsForm(friendinfo[i]);
- U.MD.F.S.hideSearchFriendsOrGroupForm(el);
- }
- }, _frag);
- _temptwoel = $$("div", { "className": "U_MD_F_H_ZLZOCOI", "title": _name }, _tempel);
- if (friendinfo[i].GroupManageID) {
- U.MD.F.printGroupHeadImage(friendinfo[i], _temptwoel, 4, [35, 35]);
- }
- else {
- $$("img", { "onerror": U.MD.C.imgError, "className": "U_MD_HomeSSZJDAO", "src": U.MD.C.getHeadImage(friendinfo[i].UserThumbnailImageHead) }, _temptwoel);
- }
- $$("span", { "className": "U_MD_F_S_Local_UserName", "innerHTML": _name }, _tempel);
- })(i);
- }
- el.appendChild(_frag);
- }
- U.MD.F.S.SearchPostion = -1; //搜索选择的位置设置为-1
- return _childs;
- }
- /**
- * 上下切换搜索的好友或者群
- *
- * @param {element} 切换元素
- * @param {number} 当前所在的位置
- */
- U.MD.F.S.switchSearchFriendsOrGroup = function (el, switchposition) {
- var _switchel,
- _top,
- _scrolltop,
- _isswitch = null,
- _keycode = event.keyCode, //键盘码
- _childs = U.selectEl(el).Child(), //获取所有搜索的值
- _postion = U.MD.F.S.SearchPostion, //当前选择好友或者去的位置
- _index = switchposition || U.MD.F.S.SearchPostion,
- _nowswitchel = _index > -1 ? _childs[switchposition || U.MD.F.S.SearchPostion] : null //之前聚焦显示的元素
- ;
- if (_keycode == 38) {
- _isswitch = -1
- }
- else if (_keycode == 40) {
- _isswitch = 1
- }
- //判断是否需要重新选择
- if (_isswitch || (switchposition != null && switchposition != _postion)) {
- //如果需要指定切换到那个位置
- if (switchposition != null) {
- U.MD.F.S.SearchPostion = switchposition;
- }
- //上下切换的处理
- else {
- U.MD.F.S.SearchPostion += _isswitch; //加上上下的处理 如果键盘向上则-1 向下+1
- }
- //如果位置大于最后一个,则位置设置为最后一个
- if (U.MD.F.S.SearchPostion > _childs.length - 1) {
- U.MD.F.S.SearchPostion = 0; //设置位置
- }
- else if (U.MD.F.S.SearchPostion < 0) {
- U.MD.F.S.SearchPostion = _childs.length - 1;
- }
- switchposition = U.MD.F.S.SearchPostion;
- _switchel = _childs[switchposition]; //判断选择好友或者群有没有元素
- //选择的位置
- if (_switchel) {
- U.selectEl('.U_MD_F_S_Local_Result_Hover').removeClass('U_MD_F_S_Local_Result_Hover')
- _switchel.className = "U_MD_F_S_Local_Result U_MD_F_S_Local_Result_Hover"; //取消上一个
- //下面计算需要显示的元素是否在滚动条可见范围,如果不在,那么滚动滚动条设置
- _top = _switchel.offsetTop;
- _scrolltop = el.scrollTop;
- if (_top > el.offsetHeight + _scrolltop - 40) {
- el.scrollTop = _top - el.offsetHeight;
- }
- if (_top < el.scrollTop) {
- el.scrollTop = _top; //滚动条的位置
- }
- }
- }
- }
- /**
- * 隐藏
- *
- * @param {element} 切换元素
- */
- U.MD.F.S.hideSearchFriendsOrGroupForm = function (el) {
- el.style.display = "none";
- U.selectEl(el).prev().Child()[0].value = "联系人、好友讨论组";
- }
- //#endregion
- //#region 窗体搜索
- /**
- * 弹出群搜索
- *
- */
- U.MD.F.S.popupsSearchGroups = function () {
- //弹出群搜索的窗体
- var _form = new U.UF.UI.form('<div class="U_MD_F_S_TO U_MD_F_S_TR">群文档搜索查看区域</div><div class="U_MD_F_S_TD" onmousedown="U.UF.EV.stopBubble();"><div class="U_MD_F_S_TDL"><input id="U_MD_F_S_GF_Search" value="群文档搜索" onblur="U.UF.MR.inputPlaceholder(this,\'\',\'群文档搜索\');" onfocus="U.UF.MR.inputPlaceholder(this,\'群文档搜索\',\'\');" placeholder="群文档搜索" onkeyup="if (event.keyCode == 13 || event.keyCode == 10) {$(this).parentElement(2).Child()[1].onclick();}" /></div><div id="U_MD_F_S_TDR_GF" class="U_MD_F_S_TDR">搜索</div></div>',
- "<div class='U_MD_F_S_CX'></div><div class='U_MD_F_S_CD'></div>", { "onresize": U.MD.F.S.searchGroupsFormSize, "id": "U_MD_F_S", "style": { "width": "71.5%", "height": "70%" } }, null, { "style": { "padding": "10px 0" } });
- var _formel = _form.form; //获取整个窗体
- U.selectEl(_formel).find("input")[0].focus(); //窗体头部的输入框聚焦
- U.selectEl('#U_MD_F_S_TDR_GF')[0].onclick = function () {
- U.MD.F.S.searchAjax(1, 1, _formel.children[2].children[0], U.selectEl('#U_MD_F_S_GF_Search')[0])
- }
- U.MD.F.S.searchGroupsFormSize(_formel); //窗体的大小设置
- U.MD.F.S.searchAjax($(_form.middle).Child()[1], 1, _formel.children[2].children[0], U.selectEl('#U_MD_F_S_GF_Search')[0]); //初始化数据
- return _formel;
- }
- /**
- * 弹出Ftp搜索
- *
- */
- U.MD.F.S.popupsSearchFtp = function () {
- var _form = new U.UF.UI.form('<div class="U_MD_F_S_TO U_MD_F_S_TR">FTP共享区域查看</div><div class="U_MD_F_S_TD" onmousedown="U.UF.EV.stopBubble();"><div class="U_MD_F_S_TDL"><input id="U_MD_F_S_FTP_Search" value="FTP搜索" onblur="U.UF.MR.inputPlaceholder(this,\'\',\'FTP搜索\');" onfocus="U.UF.MR.inputPlaceholder(this,\'FTP搜索\',\'\');" placeholder="FTP搜索" onkeyup="if (event.keyCode == 13 || event.keyCode == 10) {$(this).parentElement(2).Child()[1].onclick();}" /></div><div id="U_MD_F_S_TDR" class="U_MD_F_S_TDR">搜索</div></div>',
- "<div class='U_MD_F_S_CX'></div><div class='U_MD_F_S_CD'></div>", { "onresize": U.MD.F.S.searchGroupsFormSize, "id": "U_MD_F_F", "style": { "width": "70%", "height": "70%" } }, null, { "style": { "padding": "10px 0" } });
- var _formel = _form.form; //获取整个窗体
- U.selectEl('#U_MD_F_S_TDR')[0].onclick = function () {
- U.MD.F.S.searchAjax(1, 0, U.selectEl("#U_MD_F_F")[0].children[2].children[0], U.selectEl("#U_MD_F_S_FTP_Search")[0])
- }
- U.selectEl(_formel).find("input")[0].focus(); //窗体头部的输入框聚焦
- U.MD.F.S.searchGroupsFormSize(_formel); //窗体的大小设置
- U.MD.F.S.searchAjax($(_form.middle).Child()[1], 0, _formel.children[2].children[0], U.selectEl('#U_MD_F_S_FTP_Search')[0]); //初始化数据
- return _formel;
- }
- /**
- * 搜索内容大小变化
- *
- */
- U.MD.F.S.searchGroupsFormSize = function (contentel) {
- var _parentel = U.selectEl(contentel).Parent(3);
- contentel.style.width = Math.floor(_parentel.offsetWidth / 225) * 225 + "px";
- U.selectEl(contentel).Parent().style.height = _parentel.offsetHeight - 125 + "px";
- }
- /**
- * 搜索开始
- *
- */
- U.MD.F.S.searchAjax = function (page, isgroupserch, contentel, inputel) {
- var _searchvalue = inputel.value == inputel.defaultValue ? "" : inputel.value;
- //判断是否
- if (_searchvalue != "") {
- U.MD.F.S.searchGroupOrFriend(page, isgroupserch, contentel, inputel);
- }
- //热门查看
- else {
- U.MD.F.S.getHotFriendOrGroup(1, isgroupserch, contentel);
- }
- }
- /**
- * 搜索开始
- *
- */
- U.MD.F.S.searchGroupOrFriend = function (page, isgroupserch, contentel, inputel) {
- var _searchvalue = inputel.value == inputel.defaultValue ? "" : inputel.value, //输入的内容
- _end = page * 80, //结束的位置
- _start = _end - 79, //开始的位置
- _loadingel = page > 1 ? U.selectEl(contentel).parentElement(2).Child()[2] : U.selectEl(contentel).parentElement()[0]
- ;
- //群搜索的ajax处理
- if (isgroupserch) {
- //后台搜索群
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SearchGroupInfo", _searchvalue, _start, _end],
- U.MD.F.S.ajaxSearchAjax, [_loadingel, page, _searchvalue, contentel, isgroupserch]);
- }
- //ftp搜索的ajax处理
- else {
- //后台搜索好友的ftp
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SearchFriendInfo", US.userInfo.UserId || US.EMPTYGUID, _searchvalue, _start, _end],
- U.MD.F.S.ajaxSearchAjax, [_loadingel, page, _searchvalue, contentel, isgroupserch]);
- }
- //滚动加载设置
- U.UF.EV.scrollLoad($(contentel).Parent(), function () {
- U.MD.F.S.searchAjax(page + 1, isgroupserch, contentel, inputel);
- });
- }
- /**
- * 获取热门的群或者好友
- *
- */
- U.MD.F.S.getHotFriendOrGroup = function (page, isgroup, el) {
- var i,
- _loadingel = page > 1 ? U.selectEl(el).parentElement(2).Child()[2] : U.selectEl(el).parentElement()[0],
- _end = page * 80,
- _start = _end - 79
- ;
- //滚动加载设置
- if (page == 1) {
- //设置滚动加载函数
- U.UF.EV.scrollLoad($(el).Parent(), function () {
- U.MD.F.S.getHotFriendOrGroup(page + 1, isgroup, el); //加载热门好友和群
- });
- }
- //群的加载处理
- if (isgroup) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "RecommendGroups", _start, _end],
- U.MD.F.S.asynGetHotFriendOrGroup, [_loadingel, el, isgroup]);
- }
- //好友ftp加载处理
- else {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetFtpHotUser", _start, _end],
- U.MD.F.S.asynGetHotFriendOrGroup, [_loadingel, el, isgroup]);
- }
- }
- /**
- * 热门群或者好友获取异步
- *
- */
- U.MD.F.S.asynGetHotFriendOrGroup = function (r) {
- var _context = r.context,
- _el = _context[1], //打印区域的元素
- _isgroup = _context[2]; //是否是群的处理
- r = r.value;
- //打印内容
- U.MD.F.S.printSearchContent(r, _el, _isgroup);
- //如果搜索的内容已经不足的时候,那么就取消滚动加载函数
- if (r.length < 80) {
- U.selectEl(_el).Parent().onscroll = null;
- }
- }
- /**
- * 搜索异步
- *
- */
- U.MD.F.S.ajaxSearchAjax = function (r) {
- //参数处理
- var _context = r.context,
- _page = _context[1], //页码
- _searchvalue = _context[2], //搜索内容
- _el = _context[3],
- _isgroup = _context[4]; //是否是群搜索
- r = r.value;
- //如果是第一页
- if (_page == 1) {
- _el.innerHTML = ""; //清空之前的数据
- //如果获取的值不存在,那么就直接打印搜索是否为空
- if (!r || !r.length) {
- U.MD.F.S.printNullSearch(_el); //打印空搜索
- }
- }
- //如果搜索有内容,那么打印内容
- if (r && r.length) {
- U.MD.F.S.printSearchContent(r, _el, _isgroup); //打印搜索营部
- }
- }
- /**
- * 打印搜索内容
- *
- */
- U.MD.F.S.printSearchContent = function (friendsinfo, el, isgroup) {
- var i, _el, _tempel, _tempela, _tempelb, _tempelc, _arr,
- _userid = US.userInfo.UserId || "",
- _frag = $$("frag");
- if (isgroup) {
- _arr = ["GroupManageName", "+加群"];
- }
- else {
- _arr = ["UserNickName", "+好友"];
- }
- //循环打印好友数据
- for (i = 0; i < friendsinfo.length; i++) {
- _el = $$("div", {
- "className": "U_MD_F_S_Pop_Content_G U_MD_D_Radius_5",
- "onclick": U.UF.C.closure(function (friendinfo) {
- if (isgroup) {
- }
- else {
- U.MD.D.I.openApplication("disk", { "userid": friendinfo.UserId, "directoryid": US.FTPFOLDERID });
- }
- }, [friendsinfo[i]])
- }, _frag);
- _tempel = $$("div", { "className": "U_MD_F_S_Pop_Content_G_T" }, _el);
- _tempela = $$("div", { "className": "U_MD_F_S_Pop_Content_G_T_L" }, _tempel);
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": U.MD.C.imgError,
- "src": isgroup ? "" : U.MD.C.getHeadImage(friendsinfo[i]["UserThumbnailImageHead"]),
- "title": friendsinfo[i][_arr[0]],
- "onclick": U.UF.C.closure(function (friendinfo) {
- U.UF.EV.stopBubble();
- //群处理
- if (isgroup) {
- }
- //好友处理
- else {
- U.MD.U.V.ViewOtherUserInfo(friendinfo.UserId);
- }
- }, [friendsinfo[i]])
- }, _tempela);
- _tempelb = $$("div", { "className": "U_MD_F_S_Pop_Content_G_T_R" }, _tempel);
- $$("div", { "className": "U_MD_F_S_Pop_Content_G_T_R_T U_MD_D_Text_Abbreviation", "innerHTML": friendsinfo[i][_arr[0]] }, _tempelb);
- $$("div", { "className": "U_MD_F_S_Pop_Content_G_T_R_C U_MD_D_Text_Abbreviation", "innerHTML": (isgroup ? "目前人数:" : "目前好友:") + (friendsinfo[i].FCount || 0) }, _tempelb);
- $$("div", { "className": "U_MD_F_S_Pop_Content_G_T_R_B U_MD_D_Text_Abbreviation", "innerHTML": "ftp文件:" + (friendsinfo[i].DCount || 0) }, _tempelb);
- _tempelc = $$("div", { "className": "U_MD_F_S_Pop_Content_G_B" }, _el);
- $$("div", {
- "className": "U_MD_F_S_Pop_Content_G_B_A U_MD_D_Radius_5", "innerHTML": _arr[1],
- "onclick": U.UF.C.closure(function (friendinfo) {
- U.UF.EV.stopBubble();
- //群的处理
- if (isgroup) { U.MD.F.J.addUsersToGroup(friendinfo); }
- //好友的处理
- else { U.MD.F.M.addFriend(friendinfo); }
- }, [friendsinfo[i]])
- }, _tempelc);
- }
- el.appendChild(_frag);
- }
- /**
- * 空查询
- *
- */
- U.MD.F.S.printNullSearch = function (el) {
- $$("div", { "className": "U_MD_F_S_CXT", "innerHTML": "暂无搜索消息, 请稍候搜索。" }, el);
- }
- //#endregion
- //#region 新搜索
- /**
- * 搜索好友
- *
- * @param {object} 用户信息
- * @param {element} 打印显示的元素
- * @param {object} 回调函数
- * @param {object} 搜索的类型
- * @param {number} defaultindex 0好友 1群组 2ftp
- */
- U.MD.F.S.popSearchFriendsOrGroupForm = function (defaultindex) {
- var _searchel = U.selectEl("#U_MD_F_S_Pop")[0],
- _contentel = U.selectEl($(_searchel).Child()[1]).Child()[0],
- _inputel = U.selectEl("input", _searchel)[0]
- ;
- _searchel.style.display = "block";
- //弹出群搜索的窗体
- var _form = new U.UF.UI.form("查找好友/群",
- _searchel,
- {
- "onresize": function () { U.MD.F.S.searchGroupsFormSize(_contentel); },
- "id": "U_MD_F_S",
- "style": {
- "width": "70%",
- "height": "70%"
- }
- }, null);
- var _formel = _form.form; //获取整个窗体
- _inputel.focus(); //窗体头部的输入框聚焦
- U.MD.F.S.searchGroupsFormSize(_contentel); //窗体的大小设置
- U.MD.F.S.searchFriendsOrGroupFormClick($("span", _searchel)[defaultindex]); //默认选择查找用户
- return _formel;
- }
- /**
- * 搜索好友
- *
- * @param {object} 用户信息
- */
- U.MD.F.S.clickSearch = function (el) {
- var i,
- _changeel,
- _topel = U.selectEl(el).Parent(2),
- _childel = U.selectEl($(_topel).Child()[0]).Child();
- ;
- for (i = 0; i < _childel.length; i++) {
- _changeel = U.selectEl(_childel[i]).Child()[0];
- if (_changeel.className == "U_MD_F_S_Pop_Head_Nav_fonto") {
- U.MD.F.S.searchFriendsOrGroupFormClick(_changeel);
- return;
- }
- }
- }
- /**
- * 搜索好友
- *
- * @param {object} 用户信息
- */
- U.MD.F.S.searchFriendsOrGroupFormClick = function (el) {
- var i, j,
- _changeel,
- _parentel = U.selectEl(el).Parent(2),
- _childel = U.selectEl(_parentel).Child(),
- _topel = U.selectEl(_parentel).Parent(2),
- _contentel = U.selectEl($(_topel).Child()[1]).Child()[0],
- _inputel = U.selectEl("input", _topel)[0]
- ;
- //循环处理样式
- for (i = 0; i < _childel.length; i++) {
- _changeel = U.selectEl(_childel[i]).Child()[0];
- //如果是点击的对象
- if (_changeel == el) {
- el.className = "U_MD_F_S_Pop_Head_Nav_fonto";
- j = i;
- }
- //点击的对象
- else {
- _changeel.className = "";
- }
- }
- _contentel.innerText = "";
- U.MD.F.S.searchAjax(1, j == 1, _contentel, _inputel); //初始化数据
- }
- //#endregion;
- ///<jscompress sourcefile="FriendWindow.js" />
- /*
- 好友初始化区域 此文件为好友窗体使用初始化窗体
- */
- Namespace.register("U.MD.F.W"); //好友和群窗口区域命名空间
- //#region 好友聊天
- /**
- * 弹出好友窗体处理
- *
- * @param {object} 群信息
- */
- U.MD.F.W.viewFriend = U.MD.F.W.SLHCK = function (friendinfo) {
- //使用好友系统必须登录
- if (!(U.MD.U.L.isLogin())) {
- var _childs, //所有的好友元素
- _friendel; //好友的信息元素
- //如果有传入好友的信息,则查看指定的好友的信息,否则弹出默认的好友窗体
- if (friendinfo) {
- //如果用户是和自己聊天,那么直接提示不允许,否则弹出好友聊天框
- if (friendinfo.UserId == US.userInfo.UserId) {
- U.alert("无法与本人聊天!");
- }
- else {
- //获取制定好友的点击元素
- _friendel = U.selectEl("#U_MD_F_H_RCO").find("[tid='" + friendinfo.UserId + "']")[0];
- //如果查看的好友在好友列表里
- if (_friendel) {
- _friendel.onclick();
- }
- //弹出好有窗体
- else {
- U.MD.F.W.popupFriendsForm(friendinfo);
- }
- }
- }
- //弹出默认的好友窗体
- else {
- _childs = U.selectEl("#U_MD_F_H_RCO").Child(); //右侧栏
- friendinfo = (US.friend.recentcontacts[0] || US.friend.friends[0]); //最近联系人、 我的好友列表
- //如果有显示的好友,则弹出第一个好友聊天
- if (_childs.length) {
- _childs[0].onclick();
- }
- //查看好友
- else {
- //这里判断如果弹出的是群聊天框,则选择群信息,需要修改
- if (friendinfo && friendinfo.tf) {
- friendinfo = U.Json.select(US.friend.group, { "GroupManageID": friendinfo.UserId })[0];
- }
- U.selectEl("#U_MD_F_H_ZRO").remove(); //清除推荐元素
- //弹出好友信息
- U.MD.F.W.popupFriendsForm(friendinfo);
- //如果用户没有好友和群,那么则直接弹出推荐好友
- if (!friendinfo || (!friendinfo.UserId && !friendinfo.GroupManageID)) {
- U.MD.F.W.recommendFriend($("#U_MD_F_H_ZR")[0], 0);
- }
- }
- }
- }
- }
- //#region 空好友提示
- ///**
- //* 空好友的提示
- //*
- //*/
- //U.MD.F.W.recommendFriend = function () {
- // U.MD.F.W.printRecommendFriend(US.userInfo.TJF.slice(0, 8), U.selectEl("#U_MD_F_H_ZR")[0], 1); //推荐好友提示
- // U.MD.F.W.friendDisplayAndNone([{ "display": "block" }, { "display": "none"}], true); //弹出好友窗体,隐藏右边好友栏
- //}
- /**
- * 空用户的提示
- *
- */
- U.MD.F.W.printRecommendFriend = function (friendinfo, el, page) {
- //变量定义
- var _tempel, //临时元素变量
- _temponeel, //临时元素变量
- _temptwoel, //临时元素变量
- _tempthreeel, //临时元素变量
- _tempfourel, //临时元素变量
- _tempfiveel //临时元素变量
- ;
- //清空内容
- el.innerText = "";
- //创建显示
- _tempel = $$("div", { "className": "U_MD_F_H_ZRO", "id": "U_MD_F_H_ZRO", "onmousedown": U.UF.EV.stopBubble });
- _temponeel = $$("div", { "className": "U_MD_F_H_ZROS" }, _tempel);
- $$("div", { "className": "U_MD_F_H_ZROSS", "innerHTML": "这里暂时没有任何内容哦" }, _temponeel);
- $$("div", { "className": "U_MD_F_H_ZROSZ", "innerHTML": "Nothing!!" }, _temponeel);
- _temptwoel = $$("div", { "className": "U_MD_F_H_ZROSX" }, _temponeel);
- $$("div", { "className": "U_MD_F_H_ZROSXL", "innerHTML": "可尝试点击左边的头像,或追随一下的用户!" }, _temptwoel);
- $$("div", { "className": "U_MD_F_H_ZROSXR U_Img" }, _temptwoel);
- _temponeel = $$("div", { "className": "U_MD_F_H_ZROX" }, _tempel);
- _temptwoel = $$("div", { "className": "U_MD_F_H_ZROXT" }, _temponeel);
- $$("div", { "className": "U_MD_HomeSXLTTO U_MD_HomeSXROHTO", "innerHTML": "推荐追随" }, _temptwoel);
- $$("div",
- {
- "className": "U_MD_HomeSXLTTI U_Img",
- "onclick": function () {
- U.MD.F.W.recommendFriend(el, page);
- }
- }, _temptwoel);
- _temptwoel = $$("div", { "className": "U_MD_F_H_ZROXX" }, _temponeel);
- //推荐好友循环打印区域
- for (i = 0; i < friendinfo.length; i++) {
- _tempthreeel = $$("div", { "className": "U_MD_F_H_ZROXXO", "style": { "marginLeft": "65px" } }, _temptwoel);
- _tempfourel = $$("div", { "className": "U_MD_F_H_ZROXXOS" }, _tempthreeel);
- _tempfiveel = $$("div", { "className": "U_MD_F_H_ZROXXOSL" }, _tempfourel);
- $$("img",
- {
- "onerror": U.MD.C.imgError,
- "title": "点击查看",
- "onclick": function () {
- U.UF.EV.stopBubble();
- U.MD.U.V.ViewOtherUserInfo(friendinfo[i].UserId);
- },
- "src": U.MD.C.getHeadImage(friendinfo[i].UserThumbnailImageHead),
- "alt": friendinfo[i].UserName
- },
- _tempfiveel);
- $$("div", { "className": "U_MD_F_H_ZROXXOSN U_MD_D_Text_Abbreviation", "innerHTML": friendinfo[i].UserName }, _tempfourel);
- $$("div",
- {
- "className": "U_MD_F_H_ZROXXOSR",
- "title": "点击追随该用户",
- "innerHTML": "追随",
- "onclick": function () {
- U.MD.F.M.addFriend(friendinfo[i]);
- }
- },
- _tempfourel);
- _tempfourel = $$("div", { "className": "U_MD_F_H_ZROXXOX U_MD_HomeSXZLLZOOX" }, _tempthreeel);
- $$("div", { "className": "U_MD_F_W_S", "innerHTML": "▲" }, _tempfourel);
- $$("div", {
- "className": "U_MD_F_W_X",
- "innerHTML": friendinfo[i].UserIndividualitysignature ? friendinfo[i].UserIndividualitysignature.substring(0, 15).trim() : ("添加我为好友吧,分享我们的信息,让我们距离更近一步").trim()
- }, _tempfourel);
- }
- //添加内容
- el.appendChild(_tempel);
- }
- //好友推荐变化
- U.MD.F.W.recommendFriend = function (el, page) {
- var _userinfo = US.userInfo, //登录用户资料
- _start = page * 30, //分页的开始
- _end = (page + 1) * 30, //分页的结束
- _recommendfriend = US.friend.commonfriend.slice(_start, _end) //分页获取推荐的用户
- ;
- //获取的用户存在则打印
- if (_recommendfriend.length) {
- U.MD.F.W.printRecommendFriend(_recommendfriend, el, page + 1);
- }
- //否则去数据库取数
- else {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "RecommendFriends", _userinfo.UserId || US.EMPTYGUID, _userinfo.length, _userinfo.length + 4], U.MD.F.W.asynRecommendFriend, [el, el, page]);
- }
- }
- //获取推荐好友
- U.MD.F.W.asynRecommendFriend = function (r) {
- var _userinfo = US.userInfo, //登录用户资料
- _context = r.context, //回调的参数
- _el = _context[1], //输出的内容区域
- _page = _context[2] //输出的号码
- ;
- r = r.value; //获取推荐用户的返回值
- _userinfo = US.friend.commonfriend.concat(r); //获取的推荐用户存储到用户推荐用户信息里
- U.MD.F.W.printRecommendFriend(r, _el, _page + 1); //打印推荐好友
- }
- //#endregion
- //#region
- /**
- * 好友聊天器里查看好友聊天
- *
- * @param {object} 群信息
- */
- U.MD.F.W.popupFriendsForm = function (friendinfo, el) {
- //登录的用户才能弹出窗体
- var _close;
- if (!U.MD.U.L.isLogin()) {
- var _friendform = U.selectEl("#U_MD_F_H_ZA")[0];
- //判断窗体是否创建如果创建直接显示,如果没有则创建
- if (!_friendform) {
- U.selectEl("#U_MD_F_H_Z")[0].style.display = "block";
- //创建窗体弹出窗体
- var _window = new U.UF.UI.form("<div class='U_MD_F_S_TI'>聊天对话</div>", U.selectEl("#U_MD_F_H_Z")[0],
- {
- "onresize": U.MD.F.W.reSize,
- "id": "U_MD_F_H_ZA",
- "style": {
- "display": "block",
- "height": "80%",
- "min-width": '882px'
- }
- },
- {
- isstretching: false,
- isnarrow: false,
- closecallback: function () {
- U.MD.F.W.friendDisplayAndNone([{ "display": "none" }, { "display": "block" }], { "left": "auto", "right": "0px" });
- }
- });
- }
- //指定元素
- else {
- U.UF.F.topWindow($("#U_MD_F_H_ZA")[0]);
- }
- if (friendinfo) {
- U.MD.F.W.openFriendChat(friendinfo); //打开指定的好友聊天显示
- U.MD.F.N.canelMarkMessage(friendinfo); //消除标记信息
- U.MD.F.W.addChecked(friendinfo);
- U.MD.F.W.reSize(); //好友聊天区域大小初始化
- }
- }
- }
- /**
- * 根据群切换到好友或者群面板
- *
- * @param {object} 好友获取群信息
- */
- U.MD.F.W.switchFileOrGroup = function (friendinfo) {
- var infotid = (friendinfo.UserId == null) ? friendinfo.GroupManageID : friendinfo.UserId;
- if (infotid == friendinfo.UserId) {
- U.selectEl($("#U_MD_F_H_ZLTA").Child()[1]).Child()[0].onclick();
- }
- else if (infotid == friendinfo.GroupManageID) {
- U.selectEl($("#U_MD_F_H_ZLTA").Child()[2]).Child()[0].onclick();
- }
- }
- /**
- * 初始化好友聊天区域
- *
- * @param {object} 群信息
- */
- U.MD.F.W.openFriendChat = function (friendinfo) {
- var _friendfromel = U.selectEl("#U_MD_F_H_ZR")[0], //整个好友窗体元素
- _friendchatfrom = U.selectEl("#U_MD_F")[0], //好友聊天区域元素
- _userid = friendinfo.GroupManageID || friendinfo.UserId, //打开群或者好友的窗体
- _chatform = U.MD.F.W.isCreateForm(_userid), //判断窗体是否已经打开创建
- _isgroup = friendinfo.GroupManageID != null
- ;
- _friendchatfrom.style.display = "block"; //默认是隐藏,这些显示
- _friendfromel.appendChild(_friendchatfrom); //追加聊天区域
- //如果好友聊天框不存在,则创建好友聊天框
- if (!_chatform) {
- _chatform = U.MD.F.W.createFriendChat(friendinfo);
- }
- //选择到指定的窗体
- U.MD.F.W.switchFriendsChat(_chatform, friendinfo);
- //好友聊天查看
- U.MD.F.H.getFriendOrGroupNews(_userid, function (r) {
- U.MD.F.N.asynReceiveMessages(_isgroup, _chatform[1], r.value);
- }, _isgroup);
- }
- //大小变化处理
- U.MD.F.W.reSize = function () {
- U.MD.F.W.leftSize(); //左边的处理
- if ($("#U_MD_F_H_ZA")[0]) {
- U.MD.F.W.chatBoxSize($("#U_MD_F_H_ZA")[0], U.MD.F.W.switchFriendsChat.Ele || U.selectEl("#U_MD_F")[0].childs[0].element[1]); //右边聊天框处理
- }
- }
- /**
- * 好友聊天左边聊天框显示,主要是好友显示的区域的大小加上上面的导航等于整个左边的高
- *
- */
- U.MD.F.W.leftSize = function () {
- //获取容器DIV
- var _content = U.selectEl("#U_MD_F_H_ZA")[0];
- if (_content) {
- //得到高度
- var _height = _content.offsetHeight,
- _childs = U.selectEl(".U_MD_F_H_ZL").Child(); //获取下面的所有的孩子节点
- //设置下面的高度等于整个高度-导航的高度
- U.selectEl("#U_MD_F_H_ZLZ")[0].style.height = _height - _childs[0].offsetHeight - _childs[1].offsetHeight - 30 + "px";
- }
- }
- //调整好友聊天框
- U.MD.F.W.chatBoxSize = function (el, chatel) {
- var i, //用于循环
- _childs, //0 聊天区域 1聊天记录区域
- _rightchilds = U.selectEl(chatel).Child(), //获取整个右边好友聊天区域的子元素
- _chatchilds = U.selectEl(chatel.parentNode).Child(), //获取聊天区域的子元素
- _height = el.offsetHeight, //右边的高
- _width = chatel.offsetWidth; //右边的长
- //循环设置
- for (i = 0; i < _chatchilds.length; i++) {
- //聊天记录和聊天框的大小设置
- _childs = U.selectEl(_chatchilds[i]).Child();
- _childs[0].style.width = _width - _childs[1].offsetWidth - 1 + "px";
- _childs[1].style.height = _height - 90 + "px";
- //聊天框的大小设置
- U.selectEl(".U_MD_F_CA", _chatchilds[i]).css("height", _height - 380 + "px");
- }
- }
- /**
- * 设置好友窗体打开和关闭的状态
- *
- * @param {array} 显示隐藏的集合
- */
- U.MD.F.W.friendDisplayAndNone = function (style) {
- var _friendform = U.selectEl("#U_MD_F_H_ZA"), //好友窗体
- _friendright = U.selectEl("#U_MD_F_H_R"); //好友右侧
- _friendform.addAttrArray({ "style": style[0] }); //给窗体设置参入的css值
- _friendright.addAttrArray({ "style": style[1] }); //给窗体设置参入的css值
- }
- //#endregion
- //判断是否需要创建
- /**
- * 根据friendid判断好友窗体是否创建
- *
- * @param {object} 群信息
- */
- U.MD.F.W.isCreateForm = function (friendid) {
- var i, //用于循环处理
- _friendchatform = U.selectEl("#U_MD_F")[0]; //好友聊天框
- if (_friendchatform.childs) { //判断是否打开了聊天
- for (i = 0; i < _friendchatform.childs.length; i++) { //循环所有打开的聊天找到已经和friendid对应打开的好友聊天
- if (_friendchatform.childs[i].formid == friendid) { //如果找到匹配的好友聊天框或者群聊天框,则直接返回
- return _friendchatform.childs[i].element;
- }
- }
- }
- }
- /**
- * 生成统一的好友窗体区域
- *
- * @param {object} 好友或群信息
- */
- U.MD.F.W.createFriendChat = function (friendandgroupinfo) {
- //变量定义
- var _headel,
- _headimageel,
- _chatel,
- _chatleftel,
- _chatheadel,
- _chatheadimageel,
- _chatheadcontentel,
- _chatheadpromptel,
- _chatcontentel,
- _chatcontentnewsel,
- _chatnewsel,
- _chatnewsoneel,
- _chatnewstwoel,
- _chateditel,
- _chatbuttonel,
- _chatbuttonsendel,
- _chatrecordel,
- _buttondiv,
- _userid,
- _name,
- descript,
- _chatformel,
- _chatformchilds,
- _navichilds;
- //群id获取好友id,作为窗体的唯一识别id
- _userid = friendandgroupinfo.GroupManageID ||
- friendandgroupinfo.UserId;
- //显示在聊天框的名字,群名、好友描述、好友名字
- _name = friendandgroupinfo.GroupManageName ||
- friendandgroupinfo.FriendsDescript ||
- friendandgroupinfo.UserNickName;
- //群描述、好友签名
- descript = friendandgroupinfo.GroupManageDescript ||
- friendandgroupinfo.UserIndividualitysignature ||
- "暂时没有填写介绍..";
- //聊天框元素
- _chatformel = U.selectEl("#U_MD_F")[0];
- //聊天区域的还在元素
- _chatformchilds = U.selectEl(_chatformel).Child();
- //头部切换导航区域的元素
- _navichilds = U.selectEl(_chatformchilds[0]).Child();
- //头部标签
- _headel = $$("div", {
- "className": "U_MD_F_TO",
- "onmousedown": U.UF.EV.stopBubble
- }, _navichilds[0], _navichilds[0].firstChild);
- _headimageel = $$("div", { "className": "U_MD_F_TOI" }, _headel);
- U.selectEl(_headel).attr("user", _userid);
- //好友显示头像
- if (friendandgroupinfo.UserId) {
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": U.MD.C.imgError,
- "title": "点击查看",
- "src": U.MD.C.getHeadImage(friendandgroupinfo.UserThumbnailImageHead),
- "alt": friendandgroupinfo.UserNickName
- }, _headimageel);
- }
- //群显示头像
- else {
- U.MD.F.printGroupHeadImage(friendandgroupinfo, _headimageel, 4, [25, 25]);
- }
- $$("div", { "className": "U_MD_F_TON U_MD_D_Text_Abbreviation", "innerHTML": _name }, _headel);
- $$("div", {
- "className": "U_MD_F_TOC U_Img",
- "onclick": function () {
- U.MD.F.W.delteFriendChat(_userid, _chatformel, friendandgroupinfo);
- }
- }, _headel);
- //聊天区
- _chatel = $$("div", { "className": "U_MD_F_NA" });
- _chatformchilds[1].insertBefore(_chatel, _chatformchilds[1].firstChild);
- //左侧
- _chatleftel = $$("div", { "className": "U_MD_F_N" }, _chatel);
- //头部信息
- _chatheadel = $$("div", { "className": "U_MD_F_H" }, _chatleftel);
- _chatheadimageel = $$("div", { "className": "U_MD_F_HH" }, _chatheadel);
- if (friendandgroupinfo.GroupManageID) {
- U.MD.F.printGroupHeadImage(friendandgroupinfo, _chatheadimageel);
- U.selectEl(_chatheadimageel).addAttrArray({ onclick: function () { U.MD.F.J.groupInfoForm(friendandgroupinfo, _chatleftel); }, title: friendandgroupinfo["GroupManageName"] });
- }
- else {
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": U.MD.C.imgError,
- "title": "点击查看",
- "onclick": function () {
- U.UF.EV.stopBubble();
- if (U.MD.D.IsUseStudio) {
- U.MD.U.V.ViewOtherUserInfo(_userid);
- }
- },
- "src": U.MD.C.getHeadImage(friendandgroupinfo.UserThumbnailImageHead),
- "alt": friendandgroupinfo.UserNickName
- }, _chatheadimageel);
- }
- _chatheadcontentel = $$("div", { "className": "U_MD_F_HT U_MD_D_Text_Abbreviation" }, _chatheadel);
- $$("div", { "className": "U_MD_F_HTN", "innerHTML": _name }, _chatheadcontentel);
- $$("div", { "className": "U_MD_F_HTC", "innerHTML": (friendandgroupinfo.GroupManageDescript || friendandgroupinfo.UserIndividualitysignature || "暂时没有填写介绍..") }, _chatheadcontentel);
- _chatheadpromptel = $$("div", { "className": "U_MD_F_HG" }, _chatleftel);
- $$("div", { "className": "U_MD_F_GI U_Img" }, _chatheadpromptel);
- $$("div", { "className": "U_MD_F_GC", "innerHTML": "交谈中请勿轻信汇款、中奖信息、陌生电话..." }, _chatheadpromptel);
- $$("div", {
- "style": {
- "width": "10px",
- "height": "10px",
- "background-image": "url('/img/YS2017.png')",
- "display": "inline-block",
- "background-repeat": "no-repeat",
- "background-position": "-817px -482px",
- "float": "right",
- "margin": "8px"
- },
- "onclick": function () { _chatheadpromptel.style.visibility = "hidden"; }
- }, _chatheadpromptel);
- //内容发布区
- _chatcontentel = $$("div", { "className": "U_MD_F_CA" }, _chatleftel);
- _chatcontentnewsel = $$("div", { "className": "U_MD_F_C" }, _chatcontentel);
- //发布内容区域
- _chatnewsel = $$("div", { "className": "U_MD_F_D", "style": { "position": "relative" } }, _chatleftel);
- _chatnewsoneel = $$("div", { "className": "U_MD_F_DA" }, _chatnewsel);
- _chatnewstwoel = $$("div", { "className": "U_MD_F_DT" }, _chatnewsoneel);
- _chateditel = $$("div", { "className": "U_MD_F_DC", "contentEditable": "true" }, _chatnewsoneel);
- $$("div", { "className": "U_MD_F_DJ U_Img" }, _chatnewsoneel);
- // 按钮区域
- _chatface = $$("div", { "style": { "margin-top": "-194px", "margin-left": "14px" } }, _chatformel);
- _chatbuttonel = $$("div", { "className": "U_MD_F_X" }, _chatleftel);
- _chatbuttonsendel = $$("div", {
- "className": "U_MD_F_XE",
- "innerHTML": "发送(Ctrl+Enter)",
- "style": {
- "marginRight": "15px"
- },
- "onclick": function () {
- U.MD.F.H.sendFriendOrGroupChatMessage(friendandgroupinfo, _chateditel, _chatcontentnewsel, (friendandgroupinfo.UserId == null));
- }
- }, _chatbuttonel);
- $$("div", {
- "className": "U_MD_F_XC",
- "innerHTML": "关闭(n)",
- "onclick": function () {
- U.MD.F.W.friendDisplayAndNone([{ "display": "none" }, { "display": "block" }], { "left": "auto", "right": "0px" });
- }
- }, _chatbuttonel);
- //右侧聊天记录
- _chatrecordel = $$("div", { "className": "U_MD_F_L" }, _chatel);
- $$("div", { "className": "U_MD_F_LA" }, _chatrecordel);
- $$("div", { "className": "U_MD_F_LB" }, _chatrecordel);
- //事件赋值
- _buttondiv = $$("div", {
- "className": "U_MD_F_DTF U_MD_F_W_Face",
- "title": "发送表情",
- "style": {
- "margin": "0",
- "position": "relative",
- "background": "url(/img/face.png) no-repeat 0",
- "background-size": "20px"
- }
- }, _chatnewstwoel);
- $$("button", {
- "style": {
- "opacity": "0",
- "width": "28px",
- "height": "28px"
- },
- "onmousedown": function () {
- U.MD.UI.face(_chatface, _chateditel);
- },
- "onclick": U.UF.EV.stopBubble
- }, _buttondiv);
- _chatheadimageel = $$("div", {
- "className": "U_MD_F_UploadPng U_Img",
- "title": "添加文件",
- "style": { "cssText": "margin-left:5px" },
- "onclick": function (e) {
- if ($(".U_MD_F_UploadInput")[0]) {
- //删除弹出框
- U.selectEl(".U_MD_F_UploadInput")[0].remove();
- return;
- }
- var _firendinfo = friendandgroupinfo;
- var _div = $$("div", { "className": "U_MD_F_UploadInput", style: { "cssText": "width:154px;float:none;position:absolute;background-color:#fff;z-Index:999;border:1px solid #ccc;height:80px;text-align:center;top:26px;left:56px" } }, _chatheadimageel);
- var _local = $$("div", {
- "className": "U_MD_F_LoaclChose", innerHTML: "选择本地上传文件", style: { "cssText": "position:relative;float:none;width:100%;height:32px;margin:8px 0 0 0;line-height:32px" },
- onclick: function () {
- var _groupid,
- _ancestors,
- _directoryid = US.disk.Disks[US.userInfo.UserId].directoryid,
- _dirinfo = U.Json.select(US.disk.Disks[US.userInfo.UserId].directoryOrFiles, { "UserDirectoryID": _directoryid })[0];
- //获取粘贴到制定目录的群id
- _ancestors = U.MD.DK.C.getAncestors(_dirinfo, US.disk.Disks[US.userInfo.UserId]); //获取所有的祖先
- //如果是ftp目录,那么groupid就是用户id
- if (_ancestors[_ancestors.length - 1].UserDirectoryID == US.FTPFOLDERID) {
- _groupid = US.disk.Disks[US.userInfo.UserId].userInfo.UserId;
- }
- //否则就是对应的群id,如果不存在那么就是""
- else {
- _groupid = _ancestors[_ancestors.length - 1].GroupID || "";
- }
- U.MD.UI.upload(
- "http://disk.1473.cn/USUpfile.ashx?typename=UploadFlashfile&DirectoryId=" + _directoryid + "&Encrypt=" + _groupid + "&UserId=" + US.userInfo.UserId + "&IsF=true", //上传的地址
- //上传成功的回调函数
- function (r, fileinfo) {
- var _data = r.data //获取服务器返回值
- ; //根据文件的唯一识别id获取文件的信息
- //获取从服务器获取的值,这里加一个错误处理,因为如果后台出现了错误,那么eval的过程就会失败
- try {
- _data = eval("0," + _data);
- }
- catch (e) { }
- var _fileInfo = {
- "UserFilesServerName": _data[0],
- "UserallDirectoryName": fileinfo.name,
- "UserDirectoryExtendType": U.UF.UP.getFileNameAndExtension(fileinfo.name)[1],
- "UserDirectorySize": _data[3],
- "UserDirectoryID": _data[2],
- "UserDirectoryUrl": _data[1]
- }
- U.MD.F.W.printMessageContent(_fileInfo.UserDirectoryExtendType, _fileInfo, _chatcontentnewsel, true, _firendinfo);
- },
- //得到md5的回调函数
- function (md5, fileinfo, cb) {
- //根据用户的md5值判断用户是否需要上传,如果需要上传则需要执行上传处理,如果已经存在后台直接给用户生成文件路径等录入数据库
- U.A.Request(US.DISK, ["IfFileExistInsertDB", US.userInfo.UserId, _directoryid, _groupid, fileinfo.size, md5, U.UF.UP.getFileNameAndExtension(fileinfo.name)[1], fileinfo.name],
- //判断上传文件是否存在
- function (r) {
- var _userid = US.userInfo.UserId; //当前登录用户的id
- r = r.value;
- //获取服务器返回的值,如果服务器响应出问题了,eval的时候就会报错。
- try {
- r = eval(r)[0];
- }
- catch (e) { }
- //当用户想上传的文件已经在数据库里存在了,那么后台会执行复制数据的操作。
- if (r) {
- var _fileInfo = {
- "UserFilesServerName": r.UserFilesServerName,
- "UserallDirectoryName": r.UserDirectoryName.addEllipsis(20),
- "UserDirectoryExtendType": U.UF.UP.getFileNameAndExtension(r.UserDirectoryName)[1],
- "UserDirectorySize": r.UserDirectorySize,
- "UserDirectoryID": r.UserDirectoryID,
- "UserDirectoryUrl": r.UserDirectoryUrl
- }
- U.MD.F.W.printMessageContent(_fileInfo.UserDirectoryExtendType, _fileInfo, _chatcontentnewsel, true, _firendinfo);
- cb(false);
- }
- //否则调用flash里面的函数执行用户的上传操作。
- else {
- cb(true);
- }
- });
- });
- //阻止冒泡
- U.UF.EV.stopBubble()
- //删除弹出框
- U.selectEl(".U_MD_F_UploadInput").remove();
- }
- }, _div);
- // var _localinput = $$('input', { 'type': 'file', style: { "cssText": "position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0;" },
- // onchange: function () {
- // if (this.files.length) { //判断是否存在文件
- // var _range = U.UF.E.getRangeAt(); //获取光标处理
- // U.UF.UP.inputUpload([this], 'http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor', function (r) { //调用统一上传处理
- // var _file, _filetype, _input = r.context[0];
- // var _imgtype = /.*(jpg|png|gif|jpeg|JPG|PNG|GIF|JPEG|bmp|BMP)$/;
- // var _filearray = []; //记录上传图片的数组
- // if (Object.prototype.toString.call(r.value[0]) != "[object Array]") { //根据返回值类型判断是否多图上传
- // _filearray = [r.value]; //单图用数组则直接记录
- // }
- // else {
- // _filearray = r.value; //多图则直接替换即可
- // }
- // var _el, _frag = $$('frag');
- // for (i = 0; i < _filearray.length; i++) { //循环评接拼接
- // _file = _input.files[i];
- // _filetype = _file.name.substring(_file.name.lastIndexOf('.') + 1, _file.name.length); //获取文件后缀名
- // if (_filetype.match(_imgtype)) {//图片类型处理
- // _el = $$("div", {}, _frag); ;
- // $$('span', { innerHTML: ' <img src="http://fs.1473.cn/' + _filearray[i][0] + '">' }, _el);
- // }
- // else { //其余文件类型处理
- // _el = U.UF.E.attachment.create(_file, _filearray[i][2], _filetype);
- // U.selectEl(_el).appendTo(_frag);
- // }
- // }
- // var _filedata = { 'UserallDirectoryName': _file.name, 'UserDirectoryExtendType': _filetype, 'UserDirectorySize': _file.size, 'UserDirectoryID': r.value[2], 'UserDirectoryUrl': r.value[0] };
- // U.MD.F.W.printMessageContent(_filetype, _filedata, _chatcontentnewsel, true, _firendinfo);
- // }, [this]);
- // }
- // }
- // }, _local);
- var _disk = $$("div", {
- "className": "U_MD_F_DiskChose", innerHTML: "选择网盘上传文件", style: { "cssText": "float:none;width:100%;height:32px;margin:0 0 0 0;line-height:32px" },
- onclick: function () {
- //阻止冒泡
- U.UF.EV.stopBubble()
- U.MD.DK.VW.choseFile(function (data) {
- //根据选择的文件生成内容
- U.MD.F.W.printMessageContent(data.UserDirectoryExtendType, data, _chatcontentnewsel, true, friendandgroupinfo);
- //删除弹出框
- U.selectEl(".U_MD_F_UploadInput").remove();
- })
- }
- }, _div);
- U.UF.EV.stopBubble();
- }
- }, _chatnewstwoel);
- if (friendandgroupinfo.GroupManageID) {
- $$("div", {
- "className": "U_MD_F_DTS U_Img",
- "title": "网盘提交",
- "onclick": function () {
- U.MD.D.I.openApplication("disk",
- {
- "userid": US.userInfo.UserId,
- "directoryid": friendandgroupinfo.GroupManageID
- });
- }
- }, _chatnewstwoel);
- }
- $$("div", {
- "className": "U_MD_F_DTJ U_Img",
- "title": "聊天记录",
- "onclick": function () {
- U.MD.F.H.viewFriendsChatRecords(_chatrecordel, friendandgroupinfo, 1, (friendandgroupinfo.UserId == null));
- }
- }, _chatnewstwoel);
- U.selectEl(_chateditel).bind("keydown", function () {
- if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) {
- _chatbuttonsendel.onclick(); //发送消息
- U.UF.EV.stopDefault(); //回车处理
- }
- });
- U.UF.E.initEditor(_chateditel); //初始化编辑器处理
- _headel.onclick = function () {
- U.MD.F.W.switchFriendsChat([_headel, _chatel], friendandgroupinfo);
- }; //切换事件
- //设置光标处理
- // U.UF.E.GetSelectionRange(window, _chateditel, { "TF": "Friend" });
- //创建的好友窗体记录
- if (_chatformel.childs == null) {
- _chatformel.childs = [];
- }
- _chatformel.childs.unshift({ "formid": _userid, "element": [_headel, _chatel], "info": friendandgroupinfo }); //添加记录
- return _chatformel.childs[0].element;
- }
- //
- /**
- * 好友聊天切换
- *
- * @param {string} 好友的id
- * @param {element} 窗体元素
- */
- U.MD.F.W.switchFriendsChat = function (elements, friendorgroupinfo) {
- var i,
- _friendchatel,
- _topleftbottom,
- _chatel = U.selectEl(elements[1]).Parent(2),
- _topbottom = U.selectEl($(_chatel).Child()[0]).Child()[2], //右上角功能按钮
- _chatchilds = U.selectEl(_chatel)[0].childs;
- //判断右上角功能按钮是否存在
- if (_topbottom.children[0]) {
- _topbottom.children[0].remove();
- }
- //显示当前elements的聊天窗体,其他的隐藏
- for (i = 0; i < _chatchilds.length; i++) {
- _friendchatel = _chatchilds[i].element;
- if (_friendchatel[0] == elements[0] && _friendchatel[1] == elements[1]) { //需要显示的聊天框
- U.MD.F.W.switchFriendsChat.Ele = elements[1];
- U.selectEl(elements[0]).addClass("U_MD_F_TOT");
- U.selectEl(elements[1]).css("display", "block");
- //可编辑区域聚焦
- U.selectEl(".U_MD_F_DC", elements[1])[0].focus();
- }
- else { //需要隐藏的聊天框
- U.selectEl(_friendchatel[0]).removeClass("U_MD_F_TOT");
- U.selectEl(_friendchatel[1]).css("display", "none");
- }
- }
- //右上角功能点击处理处理
- _topbottom.onclick = function () { U.MD.F.R.popupRightCornerMenu(friendorgroupinfo, _topbottom); };
- if (friendorgroupinfo.UserId) {
- _topleftbottom = "个人信息";
- } else {
- _topleftbottom = "创建群";
- }
- _topbottom.title = _topleftbottom;
- //好友聊天框
- U.MD.F.W.chatBoxSize($(elements[1]).Parent(7), elements[1]);
- }
- /**
- * 删除单个好友聊天
- *
- * @param {string} 好友的id
- * @param {element} 窗体元素
- */
- U.MD.F.W.delteFriendChat = function (friendid, el) {
- var i, j, //循环处理
- _chatinfo, //好友聊天的好友或者群信息
- _elements, //好友聊天信息的框
- _childs = U.selectEl(el)[0].childs; //获取所有的聊天框
- U.UF.EV.stopBubble();
- //剩下最后一个直接关闭聊天框
- if (_childs.length == 1 && _childs[0].formid == friendid) {
- U.MD.F.W.friendDisplayAndNone([{ "display": "none" }, { "display": "block" }], { "left": "auto", "right": "0px" }); //移除
- }
- else {
- //循环找到friendid对应的弹框
- for (i = 0; i < _childs.length; i++) {
- //判断窗体的id和好友的id是否一致
- if (_childs[i].formid == friendid) {
- _elements = _childs[i]["element"]; //获取根据friendid创建的所有的元素
- for (j = 0; j < _elements.length; j++) { //循环所有的元素,然后全部删除
- U.selectEl(_elements[j]).remove(); //移除元素处理
- }
- _childs.splice(i, 1); //在所有孩子元素中删除该元素
- //判断当前窗体是否在正在进行的聊天窗体,如果是的话,删除了这个窗体后要把下面的窗体显示出来
- if (_elements[0].className.indexOf("U_MD_F_TOT") > -1) {
- //获取下一个要显示的聊天框
- _chatinfo = _childs[i] || _childs[i - 1]; //下一个或者是上一个
- //显示该聊天框
- U.MD.F.W.switchFriendsChat(_chatinfo["element"], _chatinfo["info"]);
- }
- break;
- }
- }
- }
- }
- /**
- * 移除所有聊天窗体
- *
- */
- U.MD.F.W.delteAllFriendChat = function () {
- }
- //生成发表聊天消息和获取聊天消息区域
- /**
- * 查看聊天好友
- * @param {element} 打印的内容区域
- * @param {array} 打印消息的数组
- * @param {boolean} 判断消息是自己发送的还是获取的
- ---------- true 自己发送的
- ---------- flase 获取的带的
- */
- U.MD.F.W.printFriendChatMessage = function (el, newsinfo, issend) {
- var i,
- _mydate,
- _month,
- _date, //打印的时间
- _contentel,
- _content,
- _chatcontentel,
- _contentoneel,
- _contentimgel,
- _chatcontentoneel,
- _chatcontentwordsel,
- _chatel = el.parentNode, //聊天框
- _frag = $$("frag");
- //发送者和接受者的样式区分
- //发送者的样式
- if (issend) {
- _stylearray = ["U_MD_F_CT", " U_MD_F_CTLC U_MD_F_GCTLC", " U_MD_F_COLCOO", " U_MD_F_CTTO", " "];
- }
- //接受者的样式
- else {
- _stylearray = ["U_MD_F_CO", "U_MD_F_CTLC_Receive U_MD_F_GCTLC", " U_MD_F_COLCOT", " U_MD_F_CTT"];
- }
- //打印的消息
- var _el;
- for (i = 0; i < newsinfo.length; i++) {
- _mydate = new Date(); //获取时间
- _month = _mydate.getMonth() + 1; //获取月份
- _date = newsinfo[i]["Time"] || U.MD.F.N.getHoursMinutesSeconds(newsinfo[i]["GroupMessageSendTime"] || newsinfo[i]["MessageSendTime"], "Array");
- _contentBox = $$("div", { "style": { "margin": " 0 10px" } }, _frag);
- //没有打印任何消息,时间必须打印
- if (el.innerText == "") {
- _time = $$("div", { "className": "U_MD_F_COTO U_MD_F_CTO", "style": { "margin": " 0 10px", "text-align": "center", "color": "#aaaaaa", "font-size": "13px" }, "innerHTML": (_date) }, _contentBox); //el.innerText.slice(0,8)
- }
- //打印消息判断时间差,如果是在两分钟内的 则不添加新的时间提示
- else {
- _time = $$("div", { "className": "U_MD_F_COTO U_MD_F_CTO", "style": { "display": "none", "margin": " 0 10px", "text-align": "center", "color": "#aaaaaa", "font-size": "13px" }, "innerHTML": (_mydate.getFullYear() + "/" + _month + "/" + _mydate.getDate() + " " + _date) }, _contentBox);
- var _pastTime = _chatel.firstChild.lastChild.firstChild.innerText;
- if (_mydate.getTime() / 1000 - new Date(_pastTime).getTime() / 1000 >= 120) {
- _time = $$("div", { "className": "U_MD_F_COTO U_MD_F_CTO", "style": { "margin": " 0 10px", "text-align": "center", "color": "#aaaaaa", "font-size": "13px" }, "innerHTML": (_date) }, _contentBox);
- }
- }
- _contentel = $$("div", { "className": _stylearray[0], "title": newsinfo[i].GroupMessageSendUsername || newsinfo[i].MessageDescript || newsinfo[i].Name }, _contentBox);
- _content = $$("div", {}, _contentel);
- _contentoneel = $$("div", { "className": "U_MD_F_COLC" + " " + _stylearray[1] }, _content);
- _contentimgel = $$("img",
- {
- "onerror": U.MD.C.imgError,
- "title": "点击查看",
- 'i': i,
- "onclick": function () {
- U.MD.U.V.ViewOtherUserInfo(newsinfo[this.i].GroupMessageSendUser || newsinfo[this.i].UserId || newsinfo[this.i].MessageSendUserID);
- },
- "src": U.MD.C.getHeadImage((newsinfo[i].IMG || newsinfo[i].UserThumbnailImageHead || '/img/UserHead/UseHead.jpg' || U.selectEl('.U_MD_F_HH')[0].children[0].src)),
- "className": "U_MD_F_COLCI"
- }, _contentel);
- //如果消息类型为6,文件消息处理
- if (newsinfo[i].MessageIsVerify == 6) {
- var _filedata = JSON.parse(newsinfo[i].MessageContent),
- //生成盒子,并且绑定点击事件
- _filebox = $$('div', { style: { cssText: 'position:relative; padding: 10px; background-color: #fff; border:1px solid silver; overflow:hidden; cursor: pointer;' } }, _contentoneel)
- U.MD.F.W.printFileContent(_filedata, _filebox)
- }
- else {
- _el = newsinfo[i]["MessageContent"] || newsinfo[i]["GroupMessageContent"] || newsinfo[i]["Content"]
- if (U.UF.C.isElement(_el)) {
- _contentwordsel = $$("div", { "className": "U_MD_F_COLCO " + _stylearray[2] }, _contentoneel);
- U.selectEl(_el).appendTo(_contentwordsel);
- }
- else {
- _contentwordsel = $$("div", { "className": "U_MD_F_COLCO " + _stylearray[2], "innerHTML": _el }, _contentoneel);
- }
- }
- if (issend) {
- _contentoneimgel = $$("div", { "style": { "width": "6px", "height": "10px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-984px -344px", "margin": "10px 4px 10px 0px" } }, _content);
- _content.style.float = "right";
- _contentel.insertBefore(_contentimgel, _content);
- _contentimgel.style.float = "right";
- _content.style.marginRight = "8px";
- }
- else {
- _contentoneimgel = $$("div", { "style": { "width": "6px", "height": "10px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-1004px -344px", "margin": "10px 0px 10px 4px" } }, _content);
- _content.style.float = "left";
- _contentel.insertBefore(_contentimgel, _content);
- }
- }
- el.appendChild(_frag);
- //消息定位到底部
- _chatel.scrollTop = _chatel.scrollHeight - _chatel.offsetHeight;
- }
- /**
- * 查看聊天 好友或者群
- * @param {element} 打印的内容区域
- * @param {array} 打印消息的数组
- * @param {boolean} 判断消息是自己发送的还是获取的
- ---------- true 自己发送的
- ---------- flase 获取的带的
- */
- U.MD.F.W.printGroupChatMessage = function (el, newsinfo, issend) {
- var i,
- _date,
- _contentel,
- _contentoneel,
- _contentwordsel,
- _contentimgel,
- _contentnameel,
- _stylearray,
- _chatcontentel = el.parentNode,
- _frag = $$("frag");
- //发送消息是自己和他人区别的样式
- if (issend) {
- _stylearray = ["U_MD_F_CT", " U_MD_F_CTLC U_MD_F_GCTLC", " U_MD_F_COLCOO", " U_MD_F_CTTO", " "];
- }
- else {
- _stylearray = ["U_MD_F_CO", "U_MD_F_CTLC_Receive U_MD_F_GCTLC", " U_MD_F_COLCOT", " U_MD_F_CTT"];
- }
- //循环打印聊天消息
- for (i = 0; i < newsinfo.length; i++) {
- var _i = i;
- var _isFile = true;
- var _mydate = new Date(),
- _month = _mydate.getMonth() + 1; //获取月份
- _mydate.getHours(); //获取系统时,
- _mydate.getMinutes(); //分
- _mydate.getSeconds(); //秒
- _date = newsinfo[i]["Time"] || U.MD.F.N.getHoursMinutesSeconds(newsinfo[i]["GroupMessageSendTime"]), "Array";
- _contentBox = $$("div", { "style": { "margin": " 0 10px" } }, _frag);
- if (el.innerText == "") {
- _time = $$("div", { "className": "U_MD_F_COTO U_MD_F_CTO", "style": { "margin": " 0 10px", "text-align": "center", "color": "#aaaaaa", "font-size": "13px" }, "innerHTML": (_date) }, _contentBox);
- } else {
- _time = $$("div", { "className": "U_MD_F_COTO U_MD_F_CTO", "style": { "display": "none", "margin": " 0 10px", "text-align": "center", "color": "#aaaaaa", "font-size": "13px" }, "innerHTML": (_mydate.getFullYear() + "/" + _month + "/" + _mydate.getDate() + " " + _date) }, _contentBox);
- var _pastTime = _chatcontentel.firstChild.lastChild.firstChild.innerText;
- if (_mydate.getTime() / 1000 - new Date(_pastTime).getTime() / 1000 >= 120) {
- _time = $$("div", { "className": "U_MD_F_COTO U_MD_F_CTO", "style": { "margin": " 0 10px", "text-align": "center", "color": "#aaaaaa", "font-size": "13px" }, "innerHTML": (_date) }, _contentBox);
- }
- }
- _contentel = $$("div", { "className": _stylearray[0], "title": newsinfo[i].GroupMessageSendUsername || newsinfo[i].MessageDescript || newsinfo[i].Name }, _contentBox);
- _content = $$("div", {}, _contentel);
- _contentoneel = $$("div", { "className": "U_MD_F_COLC" + " " + _stylearray[1] }, _content);
- _contentimgel = $$("img", {
- "onerror": U.MD.C.imgError,
- "title": "点击查看",
- "onclick": function () {
- U.MD.U.V.ViewOtherUserInfo(newsinfo[_i].GroupMessageSendUser || newsinfo[_i].UserId);
- }, "src": U.MD.C.getHeadImage((newsinfo[i].IMG || newsinfo[i].UserThumbnailImageHead)), "className": "U_MD_F_COLCI"
- }, _contentel);
- if (_isFile) {
- _contentwordsel = $$("div", { "className": "U_MD_F_COLCO " + _stylearray[2], "innerHTML": newsinfo[i]["Content"] || newsinfo[i]["GroupMessageContent"] }, _contentoneel);
- }
- else {
- var _filedata = newsinfo[i].Content,
- _filebox = $$('div', {
- style: { cssText: 'position:relative; padding: 10px; background-color: #fff; border:1px solid silver; overflow:hidden; cursor: pointer;' }, onclick: U.UF.C.closure(function (i, filedata) {
- var _type = '';
- switch (filedata.fileType) {
- case "uw": _type = 'word'; break;
- case "ue": _type = 'excel'; break;
- }
- U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", filedata.fileID]), function (r) {
- U.MD.D.I.openApplication(_type, r.value[0])
- });
- }, [i, _filedata])
- }, _contentoneel)
- $$('span', { className: 'U_MD_DK_RZOS U_MD_DK_Img U_MD_DK_RZOD' }, _filebox);
- $$('span', { style: { cssText: 'vertical-align: top; padding-left: 20px; padding-right: 40px;' }, innerText: _filedata.fileName + '.' + _filedata.fileType }, _filebox);
- $$('div', { style: { cssText: 'position: absolute; right: 10px; bottom: 10px;' }, innerText: '查看' }, _filebox)
- }
- if (issend) {
- _contentoneimgel = $$("div", { "style": { "width": "6px", "height": "10px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-984px -344px", "margin": "10px 4px 10px 0px" } }, _content);
- _content.style.float = "right";
- _contentel.insertBefore(_contentimgel, _content);
- _contentimgel.style.float = "right";
- _content.style.marginRight = "8px";
- }
- else {
- _contentoneimgel = $$("div", { "style": { "width": "6px", "height": "10px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-1004px -344px", "margin": "10px 0px 10px 4px" } }, _content);
- _content.style.float = "left";
- _contentel.insertBefore(_contentimgel, _content);
- }
- }
- //追加消息
- el.appendChild(_frag);
- //消息定位到底部
- _chatcontentel.scrollTop = _chatcontentel.scrollHeight - _chatcontentel.clientHeight;
- }
- /**
- * 查看聊天好友
- * @param {element} 打印的内容区域
- * @param {array} 打印消息的数组
- * @param {boolean} 判断消息是自己发送的还是获取的
- ---------- true 自己发送的
- ---------- flase 获取的带的
- */
- U.MD.F.W.addFile = function (friendinfo, el, thumbnail, fileurl, fileinfo) {
- //临时元素变量
- var _tempel,
- _temponeel,
- _temptwoel,
- _tempthreeel,
- _isgroup = friendinfo.UserId == null;
- //图片发送方式
- if (U.UF.UP.isImg(fileinfo.UserDirectoryExtendType)) {
- //创建一个元素
- _tempel = $$("div", {});
- //创建一个图片标签,添加图片
- $$("img", { "onerror": U.MD.C.imgError, "className": "U_MD_F_CI", "src": U.MD.C.getHeadImage(thumbnail), "title": U.MD.C.getHeadImage(fileurl) },
- _messageel).onclick = "U.UF.EV.stopBubble();U.MD.I.Img(US.userInfo, { 'Thm': '" + fileurl + "', 'Img': '" + fileurl + "'})"; //图片内容
- //发送图片
- U.MD.F.H.sendFriendOrGroupChatMessage(friendinfo, _messageel, el, _isgroup, true);
- }
- //文件发送方式
- else {
- _tempthreeel = $$("div");
- //发表文章样式
- _tempel = $$("div", { "className": "U_MD_F_F" }, _tempthreeel);
- _temponeel = $$("div", { "className": "U_MD_F_FS" }, _tempel);
- _temptwoel = $$("div", { "className": "U_MD_F_FSS" }, _temponeel);
- $$("div", { "innerHTML": fileinfo["UserDirectoryExtendType"] }, _temptwoel);
- _temptwoel = $$("div", { "className": "U_MD_F_FSX" }, _temponeel);
- $$("div", { "className": "U_MD_F_FSXN", "innerHTML": fileinfo["UserallDirectoryName"] }, _temptwoel);
- $$("div", { "className": "U_MD_F_FSXS", "innerHTML": "已成功发送" }, _temptwoel);
- _temponeel = $$("div", { "className": "U_MD_F_FX" }, _tempel);
- //如果是在1473上看到该信息,则可以直接打开网盘到指定的地方
- if (U.MD.D.IsUseStudio) {
- _tempel.onclick = "U.UF.EV.stopBubble();YDHJH('disk', ['" + fileinfo.UserId + "', '" + fileinfo.UserDirectoryID + "'])"
- _temptwoel = $$("div", { "innerHTML": "打开我的云盘", "title": "打开我的云盘" }, _temponeel);
- _temptwoel.onclick = "U.UF.EV.stopBubble();YDHJH('disk', ['" + fileinfo.UserId + "','" + fileinfo.UserDirectoryParentID + "'])";
- _temptwoel = $$("div", { "innerHTML": "打开", "title": "打开" }, _temponeel);
- _temptwoel.onclick = "U.UF.EV.stopBubble();YDHJH('disk', ['" + fileinfo.UserId + "','" + fileinfo.UserDirectoryID + "'])";
- }
- //如果是第三方调用我们的好友,则出现下载
- else {
- _temptwoel = $$("div", { "innerHTML": "下载", "title": "下载" }, _temponeel);
- _temptwoel.onclick = "U.UF.EV.stopBubble();U.UF.UP.download('" + fileinfo.UserallDirectoryName + "','" + fileinfo.UserFilesServerName + "')";
- }
- //显示出文件的样式
- U.MD.F.H.sendFriendOrGroupChatMessage(friendinfo, _tempthreeel, el, _isgroup, true);
- }
- }
- //#endregion
- //右侧好友定位
- U.MD.F.W.rightFormlocation = function () {
- U.selectEl("#U_MD_F_H_R").addAttrArray({
- "style":
- {
- "top": (US.height - 530) / 2,
- "right": "0px"
- }
- }); //
- }
- /*
- 打印消息内容
- 参数一:type(string) 消息种类 例如 文件夹folder 图片 jpg 等
- 参数二:data(json) 文件数据
- 参数三:parent(element) 生成元素
- 参数五:send(boolean) 发送消息为true ,接受消息为false
- 参数四:friend(json) 好友数据
- */
- U.MD.F.W.printMessageContent = function (type, data, parent, send, friend) {
- var _content = $$('div', {}),
- _folder = $$("div", { style: { "cssText": "padding:8px;background:#fff;border-radius:2px;position:relative" } }, _content);
- //创建文件信息类
- var _message = {
- UserFilesServerName: data.UserFilesServerName,
- fileName: data.UserallDirectoryName,
- fileType: data.UserDirectoryExtendType,
- fileSize: data.UserDirectorySize,
- fileID: data.UserDirectoryID,
- fileUrl: data.UserDirectoryUrl,
- filetype: fileType = "folder" ? 1 : 0,
- UserDirectoryExtendType: data.UserDirectoryExtendType,
- UserDirectoryID: data.UserDirectoryID,
- UserallDirectoryName: data.UserallDirectoryName
- };
- U.MD.F.W.printFileContent(_message, _folder);
- //生成消息数据
- var _newsinfo = [{
- "UserId": US.userInfo.UserId,
- "Time": new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds(),
- "Content": _content,
- "IMG": US.userInfo.UserThumbnailImageHead,
- "Name": US.userInfo.UserNickName
- }];
- //是否发送消息
- if (send) {
- //发送记录到数据库
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SentMessageToFriend", US.userInfo.UserId, friend.UserId, US.userInfo.UserNickName, JSON.stringify(_message), 6, false], function () { });
- }
- //打印在好友聊天
- U.MD.F.W.printFriendChatMessage(parent, _newsinfo, true);
- }
- /*
- 打印消息文件内容
- 参数一:data(json) 文件数据
- 参数二:parent(element) 生成元素
- */
- U.MD.F.W.printFileContent = function (data, parent) {
- var _content, _titile, _icon,
- _type = data.fileType.toLowerCase();
- switch (data.fileType) {
- case "folder": //打印文件夹类型的文件
- _content = $$("div", { style: { "cssText": "width:100%" } }, parent);
- $$("div", { "className": "U_MD_DK_RZOS U_MD_DK_Img U_MD_DK_RZOW", style: { "cssText": "float:none;display:inline-block;" } }, _content);
- _titile = $$("div", { "className": "", style: { "cssText": "display:inline-block;margin:0px 5px;width:155px;vertical-align:top;" } }, _content);
- $$("div", { innerHTML: data.fileName, style: { "cssText": "color:#000" } }, _titile);
- $$("div", { innerHTML: "(" + U.UF.UP.minUnitToMaxUnit(data.fileSize) + ")", style: { "cssText": "color:#aaaaaa;font-size:10px;line-height:10px" } }, _titile);
- $$("div", { onclick: function () { U.MD.DK.LE.openFileDirectory(data, US.userInfo.UserId) }, innerHTML: "打开", style: { "cssText": "color:#429bfe;margin-top:-20px;text-align: right;cursor: pointer;" } }, parent);
- break;
- case "txt": case "html": case "uw": case "ue": //打印文本文件
- _content = $$("div", { style: { "cssText": "width:100%" } }, parent);
- $$("div", { "className": "U_MD_DK_RZOD U_MD_DK_RZOS", style: { "cssText": "float:none;display:inline-block;" } }, _content);
- _titile = $$("div", { "className": "", style: { "cssText": "display:inline-block;margin:0px 5px;width:155px;vertical-align:top;" } }, _content);
- $$("div", { innerHTML: data.fileName, style: { "cssText": "color:#000" } }, _titile);
- $$("div", { onclick: function () { U.MD.DK.LE.openFileDirectory(data, US.userInfo.UserId) }, innerHTML: "查看", style: { "cssText": "color:#429bfe;margin-top:-20px;text-align: right;cursor: pointer;" } }, parent);
- break;
- case "jpg": case "png": //打印图片文件
- $$("img", { "onclick": function () { U.MD.DK.LE.openFileDirectory(data, US.userInfo.UserId) }, "onerror": U.MD.C.imgError, "src": "http://fs.1473.cn/" + data.fileUrl, "style": { "cssText": "width:100%;max-width:300px;min-width:30px;min-height:30px" } }, parent);
- break;
- case "mp4": //打印视频文件
- if (parent.parentElement.className == "U_MD_F_LO") {
- _content = $$("div", { style: { "cssText": "width:100%" } }, parent);
- $$("div", { "className": "U_MD_DK_RZOS U_MD_DK_VIDEO", style: { "cssText": "float:none;display:inline-block;width:40px;height:40px;background-image:url('/img/YS2017.png');background-repeat:no-repeat;background-position:-1081px -527px;" } }, _content);
- _titile = $$("div", { "className": "", style: { "cssText": "display:inline-block;margin:0px 5px;width:155px;vertical-align:top;" } }, _content);
- $$("div", { innerHTML: data.fileName, style: { "cssText": "color:#000" } }, _titile);
- $$("div", { onclick: function () { U.MD.DK.LE.openFileDirectory(data, US.userInfo.UserId) }, innerHTML: "查看", style: { "cssText": "color:#429bfe;margin-top:-20px;float:right" } }, parent);
- }
- else {
- $$("img", { "onerror": U.MD.C.imgError, "src": "http://fs.1473.cn/" + data.fileUrl, "style": { "cssText": "width:100%;max-width:300px;" } }, parent);
- _content = $$("div", {}, parent);
- $$("div", { onclick: function () { U.MD.DK.LE.openFileDirectory(data, US.userInfo.UserId) }, "style": { "width": "97px", "height": "96px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-1015px -362px", "position": "absolute", "top": "25%", "left": "28%" } }, _content);
- $$("div", { "innerHTML": data.fileName, "style": { "cssText": "color:white;font-size:16px;position: absolute;top: 137px;margin-left: 10px;" } }, _content);
- $$("span", { "innerHTML": U.UF.UP.minUnitToMaxUnit(data.fileSize), "style": { "cssText": "color:#d4d3d1;font-size:14px;position: absolute;top: 155px;margin-left: 10px;" } }, _content);
- $$("span", { "innerHTML": "已发送", "style": { "cssText": "color:#d4d3d1;font-size:14px;position: absolute;top: 155px;right:20px" } }, _content);
- }
- break;
- default:
- _content = $$("div", { style: { "cssText": "width:100%" } }, parent);
- _icon = $$("div", { "className": "U_MD_DK_RZOS U_MD_DK_Img downel_content_a_r", style: { "cssText": "float:none;display:inline-block;" } }, _content);
- $$("div", { "className": "U_MD_DK_RZOSZ", 'innerHTML': data.fileType }, _icon);
- _titile = $$("div", { "className": "", style: { "cssText": "display:inline-block;margin:0px 5px;width:155px;vertical-align:top;" } }, _content);
- $$("div", { innerHTML: data.fileName, style: { "cssText": "color:#000" } }, _titile);
- $$("div", { innerHTML: "(" + U.UF.UP.minUnitToMaxUnit(data.fileSize) + ")", style: { "cssText": "color:#aaaaaa;font-size:10px;line-height:10px" } }, _titile);
- $$("div", { "onclick": function () { U.MD.DK.LE.openFileDirectory(data, US.userInfo.UserId); }, innerHTML: "打开", style: { "cssText": "color:#429bfe;margin-top:-20px;text-align: right;cursor: pointer;" } }, parent);
- break;
- };
- }
- /**
- *添加聚焦效果
- *
- */
- U.MD.F.W.addChecked = function (friendinfo) {
- var _infotid = friendinfo.UserId || friendinfo.GroupManageID;
- if ($('.U_MD_F_H_ZLZOCOChecked')[0]) {
- U.UF.EL.removeClass($('.U_MD_F_H_ZLZOCOChecked')[0], "U_MD_F_H_ZLZOCOChecked");
- }
- if ($("[tid='" + _infotid + "']")[0]) {
- U.UF.EL.addClass($("[tid='" + _infotid + "']")[0], "U_MD_F_H_ZLZOCOChecked");
- }
- };
- ///<jscompress sourcefile="HistroyMessage.js" />
- Namespace.register("U.MD.F.H"); //好友聊天和群聊天消息命名空间
- //#region 好友和群聊天记录
- //#region 聊天记录
- /**
- * 好友或者群消息
- * @param {element} 聊天框
- * @param {object} 好友或者群信息
- * @param {int} 第几页
- * @param {string} 变化的样式
- */
- U.MD.F.H.viewFriendsChatRecords = function (el, friendandgroupinfo, page, isgroup) {
- //如果聊天记录在显示,那么隐藏聊天记录
- if (el.style.display == "block") {
- el.style.display = "none";
- U.MD.F.W.chatBoxSize($(el).Parent(3), U.selectEl(el).Parent()); //调整大小
- }
- //如果聊天记录没有打开,那么打开聊天记录
- else {
- U.selectEl(el).Child()[1].innerHTML = ""; //清空聊天记录
- U.MD.F.H.chatRecord(el, friendandgroupinfo, page, isgroup);
- el.style.display = "block"; //显示聊天记录框
- }
- U.MD.F.W.chatBoxSize($(el).Parent(8), U.selectEl(el).Parent()); //调整大小
- }
- //
- /**
- * 聊天记录分页
- * @param {element} 聊天框
- * @param {object} 好友或者群信息
- * @param {int} 第几页
- * @param {string} 变化的样式
- */
- U.MD.F.H.chatRecord = function (el, friendandgroupinfo, page, isgroup) {
- var _end = page * 20, //分页的结束位置
- _start = _end - 20; //分页的开始位置
- //群的获取聊天记录
- if (isgroup) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetGroupChatHistory", friendandgroupinfo.GroupManageID, _start, _end], U.MD.F.H.asynChatRecord, ["", el, friendandgroupinfo, page, isgroup]);
- }
- //好友的获取聊天记录
- else {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetFriendChatHistory", US.userInfo.UserId, friendandgroupinfo.UserId, _start, _end], U.MD.F.H.asynChatRecord, ["", el, friendandgroupinfo, page, isgroup]);
- }
- }
- //获取聊天记录异步
- U.MD.F.H.asynChatRecord = function (r) {
- var _context = r.context,
- _recentcontactsel = _context[1], //聊天记录元素
- _friendandgroupinfo = _context[2], //好友或者群的信息
- _page = _context[3], //页数
- _isgroup = _context[4], //是否群聊天记录
- _childs = U.selectEl(_recentcontactsel).Child(); //0 聊天记录查看区域 1 分页区域
- r = r.value;
- _childs[0].innerText = ""; //清空聊天记录
- if (r.length) {
- //打印聊天记录
- U.MD.F.H.printChatRecord(_childs[0], r, _friendandgroupinfo);
- //聊天记录到底部
- _childs[0].scrollTop = _childs[0].scrollHeight;
- //如果没有加载分页控件,则加载
- // if (!$("div", _childs[1]).length) {
- // //调用分页接口打印分页
- // new U.UF.P.page(_childs[1], r[0].AllC, 50, _page,
- // function (_page) { U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _page, _isgroup); }, 1);
- // }
- //如果没有加载日历控件,则加载
- if (!$("div", _childs[1]).length) {
- var _calendarinput,
- _date = new Date(),
- _allpage = Math.ceil(r[0].AllC / 20),
- _month = _date.getMonth() + 1;
- $$("div", {
- "style": { "width": "16px", "height": "17px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-855px -481px", "margin": "5px 0 5px 61px" },
- "onclick": function () {
- U.UF.EV.stopBubble();
- U.selectEl(document).bind("click", function (e) {
- U.selectEl(".U_MD_UI_calendar_bigboard")[0].style.cssText = "display:none";
- })
- U.MD.UI.calendar(_calendarinput, _calendarPlace, false);
- }
- }, _childs[1]); //日历按钮样式
- $$("div", {
- "className": "U_MD_F_H_checkAllCalendar", "style": { "width": "49px", "height": "19px", "position": "absolute", "bottom": "-1px", "right": "222px", "line-height": "19px", "display": "inline-block", "margin": "5px 0 7px 0px", "text-align": "center", "border-radius": "3px", "border": "1px solid #ccc", "cursor": "pointer" }, "innerHTML": "全部",
- onclick: function () {
- _calendarinput.value = '';
- _childs[0].innerText = ""; //清空聊天记录
- //打印聊天记录
- U.MD.F.H.printChatRecord(_childs[0], r, _friendandgroupinfo);
- //聊天记录到底部
- _childs[0].scrollTop = _childs[0].scrollHeight;
- }
- }, _childs[1]); //全部按钮样式
- _calendarinput = $$("input", { "value": _date.getFullYear() + "-" + _month + "-" + _date.getDate(), "readOnly": "true", "style": { "width": "68px", "height": "17px", "display": "block", "margin": "5px 0 5px 5px", "position": "absolute", 'bottom': '2px', 'left': "76px", 'border': '0px' } }, _childs[1]);
- $$("div", {
- "style": { "width": "13px", "height": "18px", "background-image": "url('/img/YS2017.png')", "background-position": "-891px -481px", "display": "inline-block", "margin": "5px 20px 4px 76px" },
- onclick: function () {
- // this.style.cssText += 'background-position:0;background:url(/BoomYun/img/pc/U_MD_F_H_firstPage.png)';
- _page = Math.ceil(r[0].AllC / 20);
- U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _page, _isgroup);
- }
- }, _childs[1]);
- $$("div", {
- "style": { "width": "11px", "height": "18px", "background-image": "url('/img/YS2017.png')", "background-position": "-924px -481px", "display": "inline-block", "margin": "5px 20px 4px 0px" },
- onclick: function () {
- if (_page <= _allpage - 1) {
- _page++;
- U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _page, _isgroup);
- }
- }
- }, _childs[1]);
- $$("div", {
- "style": { "width": "10px", "height": "17px", "background-image": "url('/img/YS2017.png')", "background-position": "-957px -481px", "display": "inline-block", "margin": "5px 20px 4px 0px" },
- onclick: function () {
- if (_page > 1) {
- _page--;
- U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _page, _isgroup);
- }
- }
- }, _childs[1]);
- $$("div", {
- "style": { "width": "13px", "height": "18px", "background-image": "url('/img/YS2017.png')", "background-position": "-987px -481px", "display": "inline-block", "margin": "5px 13px 4px 0px" },
- onclick: function () {
- // this.style.cssText += 'background-position:0;background:url(/BoomYun/img/pc/U_MD_F_H_lastPage.png)'
- _page = 1;
- U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _page, _isgroup);
- }
- }, _childs[1]);
- _calendarPlace = $$('div', { "style": { cssText: "position:absolute; bottom: 400px; right:317px" } }, _childs[1]);
- U.MD.UI.calendar.SetCallBack("CheckedDay", function () { U.MD.F.H.asynGetRecordByCalendar(_calendarinput.value, _friendandgroupinfo, _childs[0]); });
- }
- }
- else {
- U.alert("暂无消息记录");
- }
- }
- /**
- * 获取指定时间内的消息记录
- * calenderday @param {string} 日历上点击的日期
- * friendandgroupinfo @param {object} 好友或群信息
- * contactsel {element} 消息记录显示位置
- */
- U.MD.F.H.asynGetRecordByCalendar = function (calenderday, friendandgroupinfo, contactsel) {
- var _previousdate = calenderday,
- _nextdate = U.MD.F.H.asynGetNextDay(_previousdate), //获取下一天的时间
- _userid = friendandgroupinfo.UserId ? friendandgroupinfo.UserId : friendandgroupinfo.GroupManageID;
- if (friendandgroupinfo.UserId) {//判断是好友或群的消息记录
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetFriendChatHistoryByDate",
- US.userInfo.UserId, _userid, _previousdate, _nextdate], function (r) {
- contactsel.innerText = "";
- U.MD.F.H.printChatRecord(contactsel, r.value, friendandgroupinfo);
- }, [contactsel, friendandgroupinfo]);
- } else {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetGroupChatHistoryByDate",
- _userid, _previousdate, _nextdate], function (r) {
- contactsel.innerText = "";
- U.MD.F.H.printChatRecord(contactsel, r.value, friendandgroupinfo);
- }, [contactsel, friendandgroupinfo]);
- }
- }
- /**
- * 获取指定时间的下一天
- * date @param {string} 日历上点击的日期
- *
- */
- U.MD.F.H.asynGetNextDay = function (date) {
- var _currdate = new Date(date),
- _nextdate = new Date(_currdate.getTime() + 24 * 60 * 60 * 1000),
- _nextdateyear = (_nextdate.getFullYear().toString())[1] ? _nextdate.getFullYear() : '0' + _nextdate.getFullYear(),
- _nextdatemonth = (_nextdate.getMonth().toString())[1] ? (_nextdate.getMonth() + 1) : '0' + (_nextdate.getMonth() + 1),
- _nextdateday = (_nextdate.getDate().toString())[1] ? _nextdate.getDate() : '0' + _nextdate.getDate(),
- _nextday = _nextdateyear + '-' + _nextdatemonth + '-' + _nextdateday;
- return _nextday;
- }
- /**
- * 聊天记录分页
- * @param {element} 聊天框
- * @param {object} 聊天信息
- * @param {object} 好友信息
- */
- U.MD.F.H.printChatRecord = function (el, recordinfo, friendandgroupinfo) {
- var _tempel,
- _temponeel,
- _temptwoel,
- i = recordinfo.length,
- _frag = $$("frag");
- //循环打印群聊天记录
- while (i--) {
- //U.MD.F.W.printFileContent
- if (recordinfo[i].MessageContent ? recordinfo[i].MessageContent.indexOf("fileName") != -1 : recordinfo[i].GroupMessageContent.indexOf("fileName") != -1) {
- _tempel = $$("div", { "className": "U_MD_F_LO" }, _frag);
- _temponeel = $$("div", { "className": "U_MD_F_LOT" }, _tempel);
- $$("div", { "className": "U_MD_F_LOTN", "innerHTML": recordinfo[i].MessageDescript || recordinfo[i].GroupMessageSendUsername || friendandgroupinfo.FriendsDescript || friendandgroupinfo.GroupManageName }, _temponeel);
- $$("div", { "className": "U_MD_F_LOTT", "innerHTML": U.UF.D.getDateInterval(recordinfo[i].MessageSendTime || recordinfo[i].GroupMessageSendTime) }, _temponeel);
- var _data = JSON.parse(recordinfo[i].MessageContent);
- if (_data.fileType == "jpg" || _data.fileType == "png" || _data.fileType == "mp4") { //判断文件格式是否为图片或者视频 , 不是的话加边框
- var _content = $$("div", { "style": { "cssText": "padding:8px 8px 8px 8px;background:#fff;border-radius:2px;margin-top:12px;position:relative" } }, _tempel);
- } else {
- var _content = $$("div", { "style": { "cssText": "padding:8px 8px 8px 8px;background:#fff;border-radius:2px;margin-top:12px;border:1px #d3d3d3 solid;background:#f9f9f9;" } }, _tempel);
- }
- U.MD.F.W.printFileContent(_data, _content);
- } else {
- _tempel = $$("div", { "className": "U_MD_F_LO" }, _frag);
- _temponeel = $$("div", { "className": "U_MD_F_LOT" }, _tempel);
- $$("div", { "className": "U_MD_F_LOTN", "innerHTML": recordinfo[i].MessageDescript || recordinfo[i].GroupMessageSendUsername || friendandgroupinfo.FriendsDescript || friendandgroupinfo.GroupManageName }, _temponeel);
- $$("div", { "className": "U_MD_F_LOTT", "innerHTML": U.UF.D.getDateInterval(recordinfo[i].MessageSendTime || recordinfo[i].GroupMessageSendTime) }, _temponeel);
- $$("div", { "className": "U_MD_F_LOD", "innerHTML": recordinfo[i].MessageContent || recordinfo[i].GroupMessageContent }, _tempel);
- }
- }
- el.appendChild(_frag);
- }
- //#endregion
- /**
- * 发送消息统一调用函数
- * @param {object} 统一发送好友信息id
- ----------好友id
- ----------群id
- ----------群发id
- * @param {element} 发送信息原
- * @param {element} 打印区域函数
- * @param {boolean} 判断消息
- ---------- true 获取群消息 或者发送 群消息
- ---------- false 获取好友消息或者 获取好友消息
- * @param {boolean} 是否清空发送
- */
- U.MD.F.H.sendFriendOrGroupChatMessage = function (friendandgroupinfo, chateditel, chatcontentnewsel, isgroup, isupload) {
- var _newsinfo, //发送消息的打印的变量
- _chatcontent = chateditel.innerHTML, //发送的内容
- _hours = new Date().getHours().toString()[1] ? new Date().getHours() : '0' + new Date().getHours(), //判断时间是否是两位数不是则在前面加0
- _minutes = new Date().getMinutes().toString()[1] ? new Date().getMinutes() : '0' + new Date().getMinutes(),
- _seconds = new Date().getSeconds().toString()[1] ? new Date().getSeconds() : '0' + new Date().getSeconds(),
- _friendid = friendandgroupinfo.UserId || friendandgroupinfo.GroupManageID; //发送给好友或者群的id
- //不为空允许发送内容
- if (_chatcontent.isHtmlNull()) {
- U.MD.F.H.sendChatMessageToDb(_friendid, _chatcontent, null, isgroup); //调用发送数据库的函数
- //发送消息的信息
- _newsinfo = [{
- "UserId": US.userInfo.UserId,
- "Time": _hours + ":" + _minutes + ":" + _seconds,
- "Content": _chatcontent,
- "IMG": US.userInfo.UserThumbnailImageHead,
- "Name": US.userInfo.UserNickName
- }]
- //内容显示在聊天区域
- if (isgroup) {
- U.MD.F.W.printGroupChatMessage(chatcontentnewsel, _newsinfo, true); //打印在群聊天
- }
- else {
- U.MD.F.W.printFriendChatMessage(chatcontentnewsel, _newsinfo, true); //打印在好友聊天
- }
- //判断是否是上传文件,如果是上传文件,那么不清空输入区域的内容直接显示到聊天区域。
- if (!isupload) {
- chateditel.innerText = ""
- }
- }
- }
- /**
- * 查看聊天 好友或者群
- * @param {element} 发送好友的id
- * @param {string} 发送的内容
- ----------如果这里为空 那么就是获取好友信息
- * @param {function} 发送成功回调函数
- * @param {boolean} 判断消息
- ---------- true 获取群消息 或者发送 群消息
- ---------- flase 获取好友消息或者 获取好友消息
- */
- U.MD.F.H.sendChatMessageToDb = function (friendid, message, cb, isgroup) {
- var _friendorgroupinfo, //好友或者群信息
- _userinfo = US.userInfo; //用户的信息
- //发送群消息到数据库
- if (isgroup) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SendMessageToGroup", friendid, Guid.newGuid(), _userinfo.UserId, message, _userinfo.UserNickName], function () { }, [""]);
- }
- //发送好友消息到数据库
- else {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SentMessageToFriend", _userinfo.UserId, friendid, _userinfo.UserNickName, message, 0, false], function () { }, [""]);
- }
- //发送消息后根据id得到发送的消息的群或者用户id得到详细信息,然后把这个群或者用户的信息变成第一个最近联系人的第一个
- //如果是群,则获取群用户信息
- if (isgroup) {
- _friendorgroupinfo = U.Json.select(US.friend.group, { "GroupManageID": friendid })[0];
- }
- //如果是聊天好友,则获取群用户信息
- else {
- //从最近聊天里面获取信息
- _friendorgroupinfo = U.Json.select(US.friend.recentcontacts, { "UserId": friendid })[0];
- //如果最近聊天里面没有获取用户的信息,那么就从好友里面获取
- if (_friendorgroupinfo) {
- //获取好友群消息
- _friendorgroupinfo = U.Json.select(US.friend.friends, { "UserId": friendid })[0];
- }
- }
- //如果判断发送的好友或者是群确实在用户好友里,则把该用户设置为最近联系人
- if (_friendorgroupinfo) {
- U.MD.F.H.recentContacts(_friendorgroupinfo); //设置最近联系人
- }
- }
- /**
- * 查看聊天 好友或者群
- * @param {element} 发送好友的id
- * @param {string} 发送的内容
- ----------如果这里为空 那么就是获取好友信息
- * @param {function} 发送成功回调函数
- * @param {boolean} 判断消息
- ---------- true 获取群消息 或者发送 群消息
- ---------- flase 获取好友消息或者 获取好友消息
- */
- U.MD.F.H.getFriendOrGroupNews = function (friendid, cb, isgroup) {
- var _userinfo = US.userInfo; //获取用户的资料
- //如果是群信息获取
- if (isgroup) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetGroupUnreadMessage", _userinfo.UserId, friendid], cb, ["", friendid, isgroup]);
- }
- //如果是好友信息的获取
- else {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetFriendUnreadMessage", _userinfo.UserId, friendid], cb, ["", friendid, isgroup]);
- }
- }
- /**
- * 生成最近联系人
- * @param {object} 用户信息
- */
- U.MD.F.H.recentContacts = function (userinfo) {
- var _recentcontactsel,
- _num,
- _recentcontactsinfo,
- _contentel = U.selectEl("#U_MD_F_H_ZLZ")[0];
- if (US.friend.recentcontacts) {
- //判断联系人是否已经在最近联系人中
- _num = US.friend.recentcontacts.objIndexOf({ "UserId": userinfo.UserId }) || US.friend.recentcontacts.objIndexOf({ "GroupManageID": userinfo.GroupManageID });
- //如果存在最近联系人,那么直接从最近联系人中找到
- if (_num > -1) {
- _recentcontactsinfo = US.friend.recentcontacts.splice(_num, 1)[0];
- }
- //否则生成一个新的最近联系人
- else {
- //生成一个新的最近联系人
- _recentcontactsinfo = new U.MD.F.T.recentContactsEntity(userinfo.GroupManageID || userinfo.UserId,
- userinfo.GroupManageName || userinfo.UserName, userinfo.UserImageHead || "", userinfo.UserNickName || "",
- userinfo.UserThumbnailImageHead || "", userinfo.maxMessageSendTime || new Date(),
- userinfo.GroupManageDescript || userinfo.FriendsDescript, userinfo.GroupManageRemark || userinfo.UserIndividualitysignature || "",
- userinfo.IsLogin || 3, userinfo.GroupManageID ? 1 : 0);
- }
- //如果存在就直接置顶 不存在添加新的
- US.friend.recentcontacts.unshift(_recentcontactsinfo);
- //找到最近联系人按钮
- _recentcontactsel = U.selectEl("#U_MD_F_H_ZLTA").childs()[0];
- _recentcontactsel = U.selectEl(_recentcontactsel).Child()[0];
- //如果当前显示的不是好友、群而是最近联系人,那么则重新打印
- if (_recentcontactsel.className.indexOf("U_MD_F_H_ZLTSO") > -1) {
- _recentcontactsel = U.selectEl("[tid='" + (userinfo.GroupManageID || userinfo.UserId + "']"), U.selectEl("#U_MD_F_H_ZLZ")[0])[0]; //获取最近联系人
- //如果最近联系人原本就存在,则直接追加到最前面
- if (_recentcontactsel) {
- ($(_recentcontactsel).appendTo(_contentel, 0, _contentel.firstChild)); //追加到第一个
- }
- //否则打印最近联系人
- else {
- U.MD.F.printFriendOrGroup(_contentel, US.friend.recentcontacts[0], true); //插入最新联系人在最前面
- }
- }
- }
- }
- /**
- *检查当前页数的前后两页是否有消息记录,没有则取消点击事件
- *
- *
- */
- //U.MD.F.H.nextOrPreviousNoRecord = function (el, friendandgroupinfo, page, isgroup) {
- // var _previouspage = page - 1,
- // _nextpage = page + 1,
- // _recentcontactsel = el,
- // _friendandgroupinfo = friendandgroupinfo,
- // _previousend = _previouspage * 20, //分页的结束位置
- // _previousstart = _previousend - 20, //分页的开始位置
- // _nextend = _nextpage * 20, //分页的结束位置
- // _nextstart = _nextend - 20; //分页的开始位置
- // //群的获取聊天记录
- // if (isgroup) {
- // U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetGroupChatHistory", friendandgroupinfo.GroupManageID, _previousstart, _previousend], function (r) {
- // if (!r.value.length) {
- // el.children[1].children[3].style.cssText += 'background-position:0;background:url(/BoomYun/img/pc/U_MD_F_H_firstPage.png)';
- // el.children[1].children[4].style.cssText += 'background-position:0;background:url(/BoomYun/img/pc/U_MD_F_H_previousPage.png)'
- // el.children[1].children[4].onclick = function () { };
- // }
- // else {
- // el.children[1].children[3].style.cssText += 'background-position: -891px -481px;background-image: url(/img/YS2017.png)';
- // el.children[1].children[4].style.cssText += 'background-position: -924px -481px;background-image: url(/img/YS2017.png);'
- // el.children[1].children[4].onclick = function () {
- // U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _previouspage, isgroup);
- // };
- // }
- // }, ["", el, friendandgroupinfo, page, isgroup]);
- // U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetGroupChatHistory", friendandgroupinfo.GroupManageID, _nextstart, _nextend], function (r) {
- // if (!r.value.length) {
- // el.children[1].children[6].style.cssText += 'background-position:0;background:url(/BoomYun/img/pc/U_MD_F_H_lastPage.png)'
- // el.children[1].children[5].style.cssText += 'background-position:0;background:url(/BoomYun/img/pc/U_MD_F_H_nextPage.png)'
- // el.children[1].children[5].onclick = function () { };
- // } else {
- // el.children[1].children[6].style.cssText += 'background-position: -987px -481px;background-image: url(/img/YS2017.png);'
- // el.children[1].children[5].style.cssText += 'background-position: -957px -481px;background-image: url(/img/YS2017.png);'
- // el.children[1].children[5].onclick = function () {
- // U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _nextpage, isgroup);
- // };
- // }
- // }, ["", el, friendandgroupinfo, page, isgroup]);
- // }
- // //好友的获取聊天记录
- // else {
- // U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetFriendChatHistory", US.userInfo.UserId, friendandgroupinfo.UserId, _previousstart, _previousend], function (r) {
- // if (!r.value.length) {
- // el.children[1].children[3].style.cssText += 'background-position:0;background:url(/BoomYun/img/pc/U_MD_F_H_firstPage.png)';
- // el.children[1].children[4].style.cssText += 'background-position:0;background:url(/BoomYun/img/pc/U_MD_F_H_previousPage.png)'
- // el.children[1].children[4].onclick = function () { };
- // } else {
- // el.children[1].children[3].style.cssText += 'background-position: -891px -481px;background-image: url(/img/YS2017.png)';
- // el.children[1].children[4].style.cssText += 'background-position: -924px -481px;background-image: url(/img/YS2017.png);'
- // el.children[1].children[4].onclick = function () {
- // U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _previouspage, isgroup);
- // };
- // }
- // }, ["", el, friendandgroupinfo, page, isgroup]);
- // U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetFriendChatHistory", US.userInfo.UserId, friendandgroupinfo.UserId, _nextstart, _nextend], function (r) {
- // if (!r.value.length) {
- // el.children[1].children[6].style.cssText += 'background-position:0;background:url(/BoomYun/img/pc/U_MD_F_H_lastPage.png)'
- // el.children[1].children[5].style.cssText += 'background-position:0;background:url(/BoomYun/img/pc/U_MD_F_H_nextPage.png)'
- // el.children[1].children[5].onclick = function () { };
- // } else {
- // el.children[1].children[6].style.cssText += 'background-position: -987px -481px;background-image: url(/img/YS2017.png);'
- // el.children[1].children[5].style.cssText += 'background-position: -957px -481px;background-image: url(/img/YS2017.png);'
- // el.children[1].children[5].onclick = function () {
- // U.MD.F.H.chatRecord(_recentcontactsel, _friendandgroupinfo, _nextpage, isgroup);
- // };
- // }
- // }, ["", el, friendandgroupinfo, page, isgroup]);
- // }
- //}
- //#endregion
- ;
- ///<jscompress sourcefile="Manage.js" />
- /*
- 好友管理器中心 包含了 删除好友 修改好友名字等接口
- */
- Namespace.register("U.MD.F.M"); //好友管理器的命名空间
- //#region 添加好友分组
- /**
- * 弹出好友分组
- *
- */
- U.MD.F.M.createFriendGroupPopup = function () {
- var _tempel,
- _temponeel,
- _temptwoel;
- //创建好友分组的样式
- _tempel = $$("div", { "className": "U_MD_U_L_Box_I U_MD_F_Add_TNLFZ U_MD_F_G" });
- _temponeel = $$("div", {}, _tempel)
- _temptwoel = $$("input",
- {
- "placeholder": "请输入你要创建的分组",
- "onfocus": function () {
- U.UF.MR.inputPlaceholder(this, '请输入你要创建的分组名', "")
- },
- "onblur": function () {
- U.UF.MR.inputPlaceholder(this, "", '请输入你要创建的分组名');
- }
- }, _temponeel);
- //弹出好友对话框
- U.UF.UI.confirm(_tempel, function () {
- U.MD.F.M.createFriendGroup(_temptwoel);
- }); //创建一个对话框
- }
- /**
- * 确定添加好友
- *
- * @param {string} 好友分组id
- */
- U.MD.F.M.createFriendGroup = function (inputel) {
- var _value = inputel.value, //好友分组名字
- _groupid = Guid.newGuid(); //好友分组id
- //好友分组的名字不能大于20
- if (_value.length > 20) {
- U.alert("分组名不可超过20个字符");
- }
- //好友分组名字必须填写
- else if (!_value.isStrNull() && _value != inputel.defaultValue) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "CreateFriendClass", _groupid, US.userInfo.UserId, _value, ""], U.MD.F.M.asynCreateFriendGroup, ["", _value, _groupid]); //发送添加分组的请求
- }
- //没有输入的提示
- else {
- U.alert("请输入正确的群名");
- }
- }
- //添加好友分组异步
- U.MD.F.M.asynCreateFriendGroup = function (r) {
- var _groupinfo,
- _context = r.context;
- r = r.value; //得到服务器返回的值
- _groupinfo = new U.MD.F.T.friendGroupEntity(_context[2], _context[1], ""); //初始化一个好友分组
- //在好友数组的全局变量中添加好友分组的信息
- US.friend.allclass.push(_groupinfo);
- //重新点击打印好友分组,重新刷新分组
- U.selectEl($("#U_MD_F_H_ZLTA").Child()[1]).Child()[0].onclick();
- //提示创建成功
- U.alert("创建" + _context[1] + "分组成功");
- }
- //#endregion
- //#region 删除好友
- /**
- * 删除好友
- *
- * @param {object} 删除用户信息
- */
- U.MD.F.M.deleteFriend = function (friendinfo, callback) {
- //数据库中删除好友
- U.A.Request(US.FRIEND, ["DeleteFriend", US.userInfo.UserId, friendinfo.FriendsID, friendinfo.UserId], U.MD.F.M.asynDeleteFriend, ["", friendinfo, callback]); //ajax删除好友
- }
- /**
- * 删除好友异步
- *
- * @param {object} 删除用户信息
- */
- U.MD.F.M.asynDeleteFriend = function (r) {
- var _context = r.context,
- _message = "好友已删除",
- _friendinfo = _context[1]; //好友的信息;
- U.Json.del(US.friend.friends, { "FriendsID": _friendinfo.FriendsID }); //好友集里删除好友
- U.Json.del(US.friend.recentcontacts, { "UserId": _friendinfo.UserId }); //最近聊天集里删除好友
- //判断是否在当前好友选取下
- if ($('#U_MD_F_H_ZLTA .U_MD_F_H_ZLTOO')[0]) {
- var _friendclassinfo = U.Json.select(US.friend.allclass, { "FriendsGroupID": _friendinfo.FriendsGroupID })[0], //好友分组的信息
- _friendclassuserinfo = U.Json.select(US.friend.friends, { "FriendsGroupID": _friendinfo.FriendsGroupID }), //好友分组的信息
- _el = U.selectEl(".U_MD_F_H_ZLZOCO"), //获取用户的所有好友
- _friendel = U.selectEl('#g' + _friendclassinfo.FriendsGroupID).Child(),
- _switchbootom = U.selectEl("#U_MD_F_H_ZLTA").Child(); //好友或者群切换按钮
- //删除好友元素
- for (var i = 0; i < _el.length; i++) {
- if (_el[i].tid == _friendinfo.UserId) {//获取指定的删除的好友
- U.selectEl(_el[i]).remove(); //删除指定的好友元素
- U.MD.F.W.delteFriendChat(_el[i].tid, U.selectEl("#U_MD_F")[0]); //删除指定的好友聊天窗口
- _friendel[0].innerHTML = _friendclassinfo.FriendsGroupName + "(" + (_friendclassuserinfo.length) + ")"; //修改分组长度
- break;
- }
- }
- //修改好友信息
- //如果所有好友都清空了,那么则打印空好友的提示
- if (US.friend.allclass.length == 1 && !_friendclassuserinfo.length) {
- U.MD.F.printHasNoFriend(_friendel[1]);
- }
- _message = '好友' + (_friendinfo.UserNickName || _friendinfo.UserName) + '已从好友列表中删除';
- }
- //判断是否在最近聊天选取下
- if ($('#U_MD_F_H_ZLTA .U_MD_F_H_ZLTTO')[0]) {
- var _el = U.selectEl(".U_MD_F_H_ZLZOCO"); //获取用户的所有好友
- //删除好友元素
- for (var i = 0; i < _el.length; i++) {
- if (_el[i].tid == _friendinfo.UserId) {//获取指定的删除的好友
- U.selectEl(_el[i]).remove(); //删除指定的好友元素
- U.MD.F.W.delteFriendChat(_el[i].tid, U.selectEl("#U_MD_F")[0]); //删除指定的好友聊天窗口
- break;
- }
- }
- }
- var _win = U.selectEl('.U_MD_F_TO[user="9dff9339-2d37-4072-b62e-3b0a027ae997"]');
- _win[0] && U.selectEl('.U_MD_F_TOC', _win)[0].onclick();
- U.UF.C.isFunction(_context[2]) && _context[2]();
- U.alert(_message);
- };
- //#endregion
- //#region 添加好友
- /**
- * 添加好友
- *
- * @param {object} 用户信息
- * @param {object} 回调函数
- * @param {object} 删除用户信息
- */
- U.MD.F.M.addFriend = function (userinfo, cb, typename) {
- if (!U.MD.U.L.isLogin()) {
- typename = typename || "1"; //判断是添加直接对方为好友还是添加对方为好友需好友验证。
- //无法加本人为好友 同时不可与本人对话
- if (userinfo.UserId != US.userInfo.UserId) {
- //在好友里获取用户
- var _friendinfo = U.Json.select(US.friend.friends, { "UserId": userinfo.UserId })[0];
- //判断是否已经添加了用户
- if (!_friendinfo) {
- U.MD.F.M.addFriendForm(userinfo, cb, typename); //弹出添加好友框
- }
- //如果用户已经是自己的好友,那么直接跳出聊天
- else {
- U.MD.F.W.popupFriendsForm(_friendinfo); //弹出聊天框
- }
- } else { U.Alert("不可以添加自己为好友哟!"); }
- }
- else { U.Alert("快速登录关注他(她)吧"); }
- }
- /**
- * 添加好友
- *
- * @param {object} 用户信息
- * @param {object} 删除用户信息
- */
- U.MD.F.M.addFriendForm = function (userinfo, cb, typename) {
- var i,
- _formel,
- _tempel,
- _temponeel,
- _temptwoel,
- _tempthreeel,
- _tempfourel,
- _friendgroupinfo = US.friend.allclass; //好友分组
- var _date = new Date();
- //创建添加好友信息分组信息
- _tempel = $$("div", { "className": "U_MD_U_UV_IAC" });
- _temponeel = $$("div", { "className": "U_MD_U_UV_IACA" }, _tempel);
- _temptwoel = $$("div", { "className": "U_MD_U_UV_IACL" },
- _temponeel); _tempthreeel = $$("div", { "className": "U_MD_U_UV_IACLT" }, _temptwoel);
- $$("img",
- {
- "onerror": U.MD.C.imgError,
- "title": "点击查看",
- "src": U.MD.C.getHeadImage(userinfo.UserThumbnailImageHead)
- },
- _tempthreeel);
- _tempthreeel = $$("div", { "className": "U_MD_U_UV_IACLB" }, _temptwoel);
- $$("div", { "className": "U_MD_D_Text_Abbreviation", "innerHTML": userinfo.UserNickName || userinfo.UserName }, _tempthreeel);
- $$("div", { "className": "U_MD_D_Text_Abbreviation", "innerHTML": "性别:" + (userinfo.UserSex ? "男" : "女") }, _tempthreeel);
- $$("div", { "className": "U_MD_D_Text_Abbreviation", "innerHTML": "年龄:" + (U.UF.D.getYearMonthDay(_date.toLocaleDateString())[3] - U.UF.D.getYearMonthDay(userinfo.Birthday)[3]) }, _tempthreeel);
- _temptwoel = $$("div", { "className": "U_MD_U_UV_IACR" }, _temponeel);
- _tempthreeel = $$("div", { "className": "U_MD_U_UV_IACRT" }, _temptwoel);
- $$("div", { "className": "U_MD_U_UV_IACRTL", "innerHTML": "备注姓名:" }, _tempthreeel);
- _tempthreeel = $$("div", { "className": "U_MD_U_UV_IACRTR" }, _tempthreeel);
- _memoName = $$("input", { "value": userinfo.UserNickName || userinfo.UserName }, _tempthreeel);
- _tempthreeel = $$("div", { "className": "U_MD_U_UV_IACRB" }, _temptwoel);
- $$("div", { "className": "U_MD_U_UV_IACRBL", "innerHTML": "分       组:" }, _tempthreeel);
- _tempthreeel = $$("div", { "className": "U_MD_U_UV_IACRBR" },
- _tempthreeel);
- _tempfourel = $$("select", {}, _tempthreeel);
- //添加用户到制定的好友分组处理
- _tempfourel.options.length = _friendgroupinfo.length;
- for (i = 0; i < _friendgroupinfo.length; i++) {
- _tempfourel.options[i].text = _friendgroupinfo[i].FriendsGroupName;
- }
- //创建好友分组的弹框
- _formel = U.UF.UI.confirm(_tempel, function () {
- U.MD.F.M.addFriendToDb(userinfo, cb, _tempfourel, _temponeel, typename, _memoName.value);
- });
- _formel.form.style.width = "400px";
- }
- /**
- * 确定添加好友
- *
- * @param {object} 删除用户信息
- * @param {function} 删除用户信息
- */
- U.MD.F.M.addFriendToDb = function (userinfo, cb, selectel, loadingel, typename, _memoName) {
- var _friendgroupinfo = US.friend.allclass[selectel.selectedIndex], //获取用户选择的分组
- _groupid = _friendgroupinfo.FriendsGroupID, //好友分组id
- _friendid = Guid.newGuid(), //用户在分组里面的唯一识别id
- _messageid = Guid.newGuid(); //用户发送的消息的唯一识别id
- _descript = U.selectEl(".U_MD_U_UV_IACRTR")[0].childNodes[0].value; //用户备注
- //添加好友分组的ajax
- //对方发送添加好友信息给你,同意后把用户直接加到好友分组里
- if (typename == "0") {
- U.A.Request(US.FRIEND, ["AgreeAddFriend", US.userInfo.UserId, userinfo.UserId, _friendid, _groupid, (userinfo.UserNickName || userinfo.UserName), userinfo.MessageContent.toUpperCase()],
- U.MD.F.M.asynAddFriendToDb, [loadingel, _groupid, userinfo, _friendgroupinfo, cb, _friendid]); //添加好友到默认分组
- }
- //添加用户为好友
- else {
- U.A.Request(US.CD, ([US.DB, "UseStudio_Friends", "AddFriend", US.userInfo.UserId, _friendid, userinfo.UserId, _groupid, _messageid, (userinfo.UserNickName || userinfo.UserName), ("" || _descript)]), U.MD.F.M.asynAddFriendToDb, [loadingel, _groupid, userinfo, _friendgroupinfo, cb, _friendid]); //添加好友到默认分组
- }
- //提示
- //U.alert("正在添加中...");
- return false;
- }
- /**
- * 添加好友到分组异步
- *
- * @param {object} 添加成功后的信息
- */
- U.MD.F.M.asynAddFriendToDb = function (r) {
- var _context = r.context,
- _loadingel = _context[0], //loading元素
- _groupid = _context[1], //群id
- _userinfo = _context[2], //用户的信息
- _friendgroupinfo = _context[3], //
- _cb = _context[4],
- _friendid = _context[5];
- r = r.value;
- //同意添加对方为好友的时候处理
- if (r) {
- //设置添加好友
- U.MD.F.M.displayAddFriend(_userinfo, _friendid, _groupid, _friendgroupinfo, r);
- //添加好友的回调处理
- if (_cb) {
- _cb();
- }
- U.alert('添加好友成功,快和他发起聊天吧');
- }
- //添加对方为好友,给对方发送消息处理
- else {
- U.alert("您的请求已经发送,请等待对方的同意。");
- }
- //关闭loading的弹窗
- U.selectEl(_loadingel).Parent({ usform: "true" }).remove();
- }
- /**
- * 添加好友成功后的处理
- *
- * @param {object} 添加成功后的信息
- */
- U.MD.F.M.displayAddFriend = function (userinfo, friendid, classid, friendgroupinfo, r) {
- var _childs,
- _groupel,
- //好友分组的信息
- _friendinfo = new U.MD.F.T.friendEntity(userinfo.UserIndividualitysignature, userinfo.UserId, userinfo.UserImageHead,
- userinfo.UserThumbnailImageHead, userinfo.UserNickName || userinfo.UserName,
- userinfo.UserName, friendid, userinfo.UserNickName || userinfo.UserName, classid, 0);
- _friendinfo["IsLogin"] = r[1] == "True" ? 1 : 0; //设置用户在线
- US.friend.friends.unshift(_friendinfo); //添加好友到好友列表里
- //打印聊天显示窗体
- _groupel = U.selectEl("#g" + classid);
- if (_groupel[0]) {
- _childs = U.selectEl(_groupel).Child(); //0 好友分组信息 1好友信息
- //如果是第一次添加好友,那么提示好友的信息删除
- if (US.friend.friends.length == 1) {
- U.selectEl("#U_MD_F_H_ZR")[0].innerText = "";
- };
- //打印添加的好友信息
- U.MD.F.printFriendOrGroup(_childs[1], [_friendinfo], true); //打印好友
- //好友分组信息
- _childs[0].innerText = friendgroupinfo["FriendsGroupName"] + "(" + (U.Json.select(US.friend.friends, { "FriendsGroupID": classid }).length) + ")";
- };
- //添加成功后打开好友聊天对话
- U.MD.F.W.popupFriendsForm(_friendinfo);
- //右边的好友窗体也重新打印
- if (!US.friend.recentcontacts.length) {
- U.MD.F.printRightFormFriend(US.friend.friends, U.selectEl("#U_MD_F_H_RC")[0]);
- }
- }
- //#endregion
- ;
- ///<jscompress sourcefile="Message.js" />
- Namespace.register("U.MD.F.N"); //好友消息命名空间
- U.MD.F.N.news = []; //用户所有的消息数组
- /**
- * 好友消息服务
- *
- * @param {string} 用户id
- */
- U.MD.F.N.messageService = function (userid) {
- if (US.friend.allclass && userid && userid.length == 36) {
- //获取好友未读消息
- U.A.Request(US.USER, ["GetAllUnreadMessage", userid], U.MD.F.N.asynMessageService);
- }
- }
- /**
- * 这个是消息的异步处理
- *
- * @param {object} 后台返回数据的ajax对象
- * 0 好友未读消息 1 用户在服务器的状态
- */
- U.MD.F.N.asynMessageService = function (r) {
- r = r.value;
- if (r) { //如果后台有返回数据的处理
- var i,
- _userinfo = US.userInfo, //登录用户的信息
- _statenew = r[1];
- //如果状态服务器里返回的数据在前端最终生成是字符串,那么就是用户的登录状态的变化
- if (typeof _statenew == "string") {
- U.MD.F.N.inlineNotice(_statenew);
- }
- //否则就是用户获取到自己的好友和其他的信息
- else {
- U.MD.F.N.friendOnlineAndOffline(_statenew); //用户上下线设置
- U.MD.F.N.messageHandle(r); //聊天消息的处理
- }
- }
- }
- /**
- * 好友的上下线处理
- *
- * @param {object} 后台返回数据的ajax对象
- * 0 好友未读消息 1 用户在服务器的状态
- */
- U.MD.F.N.friendOnlineAndOffline = function (statenew) {
- var i,
- j,
- k,
- _num,
- _el,
- _idarr,
- _friendform = U.selectEl("#U_MD_F_H_ZLZ")[0], //好友窗体
- _userid = US.userInfo.UserId, //登录用户id
- _friendinfo = US.friend; //好友信息数组
- //循环上下线通知 0是下线的用户,1是上线的用户
- for (i = 0; i < statenew.length; i++) {
- //如果有上线或者下线的用户
- if (statenew[i].length) {
- //获取所有上下线的数组
- _idarr = statenew[i].join(",");
- //循环好友的数组 0 好友分组 1 所有的好友 2 好友群 3 群好友 4 在线用户 中的 1 、 3 、4
- for (j = 0; j < 3; j++) {
- _num = j = 0 ? 1 : j + 2; //1、3、4的规律算法
- for (k = 0; k < _friendinfo[_num].length; k++) {
- //如果用户在上下线操作里面
- if (_idarr.indexOf(_friendinfo[_num][k].UserId) > -1) {
- _friendinfo[_num][k].IsLogin = i; //设置是否登录的处理
- }
- }
- U.Json.sort(US.friend[_num], "IsLogin", 1); //上下线后重新排序
- }
- //把上线的用户置顶,下线的用户放在下面
- for (j = 0; j < statenew[i].length; j++) {
- _el = U.selectEl("[tid='" + statenew[i][j] + "']", _friendform); //找到指定的元素
- if (_el[0]) {
- U.selectEl(_el[0].Parent()).append(_el, null, i ? _el[0].Parent().firstChild : null);
- }
- }
- }
- }
- }
- /**
- * 下线通知区域
- *
- * @param {object} 后台返回数据的ajax对象
- * 0 好友未读消息 1 用户在服务器的状态
- */
- U.MD.F.N.inlineNotice = function (userstate) {
- //其它地方登录
- if (userstate == "upline") {
- return; //前期允许多点登录
- //其他地方登录弹出提示框
- U.UF.UI.confirm($$("div", {
- "style": {
- "textAlign": "center",
- "marginTop": "25px",
- "padding": "10px 0",
- "fontSize": "14px",
- "color": "red"
- },
- "innerHTML": "您好, 您的账号在别处有登录!"
- }));
- U.MD.U.LO.logout(); //注销账号信息
- }
- //超时重新连接
- else {
- U.A.Request(US.FRIEND, ["UserStateLogin", US.userInfo.UserName, US.userInfo.UserPassword], function () { });
- }
- }
- /**
- * 消息查看
- *
- * @param {object} 0 好友和群消息 1 交互消息
- */
- U.MD.F.N.messageHandle = function (arr) {
- //好友消息和群消息的处理
- if (arr[0]) {
- U.MD.F.N.friendMessageHandle(arr[0]);
- }
- if (arr[1]) {
- U.MD.F.N.otherNews(arr[1]);
- }
- }
- //点击查看消息
- /**
- * 消息查看
- *
- * @param {object} 0 好友和群消息 1 交互消息
- */
- U.MD.F.N.friendMessageHandle = function (newsarr) {
- var i, j, k,
- _issound,
- _isnews,
- _obj,
- _form,
- _news,
- _isgroup, //是否是群消息
- _verify, //消息类型
- _allnews = U.MD.F.N.news //还有消息数组
- ;
- //循环消息数组 0 好友消息, 1群消息
- for (j = 0; j < newsarr.length; j++) {
- _news = newsarr[j]; //得到好友或者群消息
- //判断是否存在
- if (_news) {
- //好友消息或者群消息循环处理 由于好友或者群消息有多种消息 如添加还有消息、好友聊天消息,进入群消息,群聊天消息等,
- for (i = 0; i < _news.length; i++) {
- _obj = null; //清空obj
- _isgroup = _news[i].UserId == null; //判断消息是什么消息
- _verify = _news[i].MessageIsVerify || 0; //如果没有消息的类型,暂时只有群消息的时候才会触发
- _allnews[_verify] = _allnews[_verify] || []; //设置功能
- // _verify = _verify == 6 ? 0 : _verify;
- switch (_verify) {
- //好友或者群聊天消息
- case 0: case 6:
- _news[i].MessageSendTime = U.UF.D.getYearMonthDay(_news[i].MessageSendTime) || U.UF.D.getYearMonthDay(_news[i].GroupMessageSendTime); //发送消息的时间
- _form = U.MD.F.W.isCreateForm(_news[i].UserId || _news[i].GroupManageID); //判断好友消息窗口是否打开
- //如果窗体存在的处理
- if (_form && _form[1] && U.selectEl('#U_MD_F_H_ZA')[0].style.display == 'block' && _form[1].style.display != "none") {
- //如果没有显示
- U.MD.F.N.canelMarkMessage(_news[i]); //移除消息提示
- //获取消息打印
- U.MD.F.H.getFriendOrGroupNews(_news[i].UserId || _news[i].GroupManageID, function (r) {
- U.MD.F.N.asynReceiveMessages(_isgroup, _form[1], r.value); //输出消息
- }, _isgroup);
- _issound = true;
- continue;
- }
- U.MD.F.H.recentContacts(_news[i]); //生成最近联系人
- break;
- //1、对方添加我为好友的请求, 2、对方请求加入群, 3、用户给拉入群处理 这里不做处理下面统一处理, 4、请求对方进入群处理, 5、确认对方进入群处理
- case 1: case 2: case 3: case 4: case 5:
- //_allnews[_verify].push(_news[i]);
- break;
- }
- //判断消息是否存在过
- for (k = 0; k < _allnews[_verify].length; k++) {
- //判断两个用户之间或者用户和群之间是否存在消息
- if ((_allnews[_verify][k].GroupManageID != null && _allnews[_verify][k].GroupManageID == _news[i].GroupManageID) ||
- (_allnews[_verify][k].UserId != null && _allnews[_verify][k].UserId == _news[i].UserId)) {
- _obj = _allnews[_verify][k];
- break;
- }
- }
- //如果是聊天消息,存在的情况下,那么就直接添加消息总数
- if ((_verify == 0 || _verify == 6) && _obj) {
- //由于群的信息获取的时候都是有总数,所以不需要用叠加的方法
- if (_news[i].GroupManageID) {
- if (_news[i].count > _obj.count) {
- _issound = true;
- }
- _obj.count = _news[i].count;
- }
- //消息的数量叠加
- else {
- _issound = true;
- _obj.count += _news[i].count;
- }
- }
- //添加好友消息等直接添加 if (!_obj || _verify != 2)
- else {
- _issound = true;
- _allnews[_verify].push(_news[i]);
- }
- _isnews = true; //设置有消息提醒
- }
- }
- }
- //判断是否有新消息
- if (_issound) {
- U.MD.F.N.addNewsSound($('.U_MD_D_NewsTipsIcon')[0], _allnews);
- }
- //如果有消息的处理
- if (_isnews) {
- //弹出消息提醒
- U.MD.F.N.tipsForm();
- //消息提醒次数
- U.MD.F.N.markUnreadMessage(newsarr);
- //上面处理好信息后,重新的打印显示消息
- for (i = 0; i <= 6; i++) { //消息处理
- if (_allnews[i] && _allnews[i].length) { //消息存在的处理
- U.MD.F.N.displayFriendMessage(_allnews[i], i); //弹出消息框
- }
- }
- }
- }
- /**
- * 消息提醒窗体
- *
- * @param {string} 时间字符串
- */
- U.MD.F.N.tipsForm = function () {
- var _friendel = U.selectEl("#U_MD_D_MG_AFT")[0];
- _friendel.innerText = "";
- if (!$('.U_MD_F_N_IconAnimation')[0]) {
- U.selectEl('.U_MD_D_NewsTipsIcon')[0].className += ' U_MD_F_N_IconAnimation';
- }
- U.selectEl('.U_MD_D_NewsTipsIcon')[0].onmouseover = function () {
- U.selectEl('.U_MD_D_NewsTipsIcon')[0].className = 'U_MD_D_NewsTipsIcon';
- if (!$("#U_MD_F_N_Message")[0]) {
- //弹出消息的处理
- new U.UF.UI.form(US.userInfo.UserNickName, _friendel,
- {
- "id": "U_MD_F_N_Message",
- "style": { 'position': 'absolute', "width": "233px", "height": "343px", "left": "-100px", "bottom": "52px", "background": "#ffffff", "padding": "0", "border": "0", "maxWidth": "300px" }
- },
- {
- "istop": true,
- "isdrag": false,
- "isstretching": false,
- "isenlarge": false,
- "isnarrow": false,
- "isclose": false,
- "closecallback": function () {
- U.MD.F.N.clearAllNews();
- }
- }, { 'id': 'U_MD_F_N_MessageHead', 'style': { 'text-indent': '10px', 'height': '30px', 'line-height': '30px', 'background-color': '#fff', 'color': '#000', 'font-size': '14px', 'overflow': 'hidden', 'padding-top': '5px', 'margin-bottom': '5px' } },
- '', '', U.selectEl('.U_MD_D_NewsTipsIcon')[0]);
- if (!$('.U_MD_F_N_MessageTop')[0]) {
- $$('div', {
- 'innerHTML': '全部忽略', 'className': 'U_MD_F_N_MessageTop', 'onclick': function () {
- U.UF.EV.stopBubble();
- U.MD.F.N.clearAllNews();
- U.MD.F.N.delAllNewsTips();
- U.MD.F.N.canelAllMarkMessage();
- }
- }, U.selectEl('#U_MD_F_N_MessageHead')[0]);
- }
- }
- else {
- U.selectEl("#U_MD_F_N_Message")[0].style.display = "block";
- U.MD.F.N.noNewsTips();
- }
- }
- U.selectEl('.U_MD_D_NewsTipsIcon')[0].onmouseout = function () {
- if ($("#U_MD_D_MG_AFT").Child().length != 0) {
- U.selectEl('.U_MD_D_NewsTipsIcon')[0].className += ' U_MD_F_N_IconAnimation';
- };
- U.selectEl("#U_MD_F_N_Message")[0].style.display = "none";
- }
- }
- /**
- * 发送消息时间处理
- *
- * @param {string} 时间字符串
- */
- U.MD.F.N.messagesendTime = function (time) {
- var _reg = RegExp(/Date/); //检查字符串是不是时间戳
- if (time.match(_reg)) {
- time = time.replace(/[^0-9]/ig, ""); //提取数字
- var _date = new Date(parseInt(time));
- var _year = _date.getFullYear();
- var _month = _date.getMonth() + 1;
- var _day = _date.getDate();
- return _year + '-' + _month + '-' + _day;
- }
- return time;
- }
- /**
- * 发送消息时间处理
- *
- * @param {string} 时间字符串
- */
- U.MD.F.N.getHoursMinutesSeconds = function (time) {
- var _reg = RegExp(/Date/); //检查字符串是不是时间戳
- if (time && time.match(_reg)) {
- time = time.replace(/[^0-9]/ig, ""); //提取数字
- var _date = new Date(parseInt(time)),
- _hours = _date.getHours().toString()[1] ? _date.getHours() : '0' + _date.getHours(), //判断时间是否是两位数不是则在前面加0
- _minutes = _date.getMinutes().toString()[1] ? _date.getMinutes() : '0' + _date.getMinutes(),
- _seconds = _date.getSeconds().toString()[1] ? _date.getSeconds() : '0' + _date.getSeconds();
- return _hours + ':' + _minutes + ':' + _seconds;
- }
- return time;
- }
- /**
- * 消息提示打印处理
- *
- * @param {array} 需要打印的消息数组
- */
- U.MD.F.N.displayFriendMessage = function (news, verify) {
- var i,
- _username,
- _descript,
- _newel,
- _newael,
- _cb,
- _newcontent,
- _frag = $$("frag");
- //循环消息的处理
- for (i = 0; i < news.length; i++) {
- //创建消息元素
- _newel = $$("div", { "className": "U_MD_D_MG_OO", "title": "消息", "tid": "O" + news[i].MessageID }, _frag);
- _username = news[i].FriendsDescript || news[i].GroupManageName || news[i].UserNickName;
- _newsenttime = U.MD.F.N.messagesendTime(news[i].MessageSendTime);
- //消息类型的处理,设置消息的内容显示
- switch (verify) {
- //聊天消息处理
- case 0:
- _descript = news[i].count;
- _newcontent = news[i].MessageContent || news[i].GroupMessageContent;
- //添加好友点击的回调
- _cb = U.UF.P.apply(function (news, newsinfo, _newel) {
- U.MD.F.N.chatMessage(newsinfo, news, _newel); //聊天消息设置
- U.UF.EV.stopBubble();
- }, [news, news[i], _newel]);
- break;
- //添加好友消息的处理
- case 1:
- _username = news[i].UserNickName; //消息名字
- _newcontent = "添加您为好友"; //消息描述
- //添加好友点击的回调
- _cb = U.UF.P.apply(function (news, newsinfo, _newel) {
- U.MD.F.N.addFriendNewsHandle(newsinfo, news, _newel);
- U.UF.EV.stopBubble();
- }, [news, news[i], _newel]);
- break;
- //请求加入群消息处理
- case 2:
- _username = news[i].UserNickName; //消息名字
- _newcontent = "请求加入该群"; //消息描述
- //添加好友点击的回调
- _cb = U.UF.P.apply(function (news, newsinfo, _newel) {
- U.MD.F.N.entryGroup(newsinfo, news, _newel);
- }, [news, news[i], _newel]);
- break;
- //邀请加入群处理
- case 3:
- _username = news[i].UserNickName; //消息名字
- _newcontent = "邀请您加入讨论组"; //消息描述
- //添加好友点击的回调
- _cb = U.UF.P.apply(function (news, newsinfo, _newel) {
- U.MD.F.N.pulledIntoGroups(newsinfo, news, _newel);
- U.UF.EV.stopBubble();
- }, [news, news[i], _newel])
- break;
- //对方同意添加好友
- case 4:
- _username = news[i].UserNickName; //消息名字
- _newcontent = "同意添加你为好友"; //消息描述
- //添加好友点击的回调
- _cb = U.UF.P.apply(function (news, newsinfo, _newel) {
- U.MD.F.N.confirmAddFriend(newsinfo, news, _newel);
- }, [news, news[i], _newel]);
- break;
- //对方确认我加入群的处理
- case 5:
- _username = news[i].UserNickName; //消息名字
- _newcontent = "加入讨论组"; //消息描述
- //添加好友点击的回调
- _cb = U.UF.P.apply(function (news, newsinfo, _newel) {
- U.MD.F.N.pulledIntoGroups(newsinfo, news, _newel);
- }, [news, news[i], _newel]);
- break;
- case 6:
- _newcontent = "你的文件到了!!!"; //发送文件描述
- _cb = U.UF.P.apply(function (news, newsinfo, _newel) {
- U.MD.F.N.chatMessage(newsinfo, news, _newel); //聊天消息设置
- U.UF.EV.stopBubble();
- }, [news, news[i], _newel]);
- break;
- }
- //点击处理
- _newel.onclick = _cb;
- _newael = $$("div", { "className": "U_MD_D_MG_OOI" }, _newel);
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": U.MD.C.imgError, "alt": news[i].FriendsDescript || news[i].UserNickName || news[i].GroupManageName,
- "src": U.MD.C.getHeadImage(news[i].UserThumbnailImageHead || "/img/UserHead/UseHead.jpg")
- }, _newael);
- $$("div", { "className": "U_MD_D_MG_OON U_MD_D_Text_Abbreviation", "innerHTML": _username }, _newel);
- $$('div', { 'style': { 'float': 'none', 'text-align': 'end', 'color': '#737373', 'height': '15px', 'margin-right': '5px' }, 'innerHTML': _newsenttime }, _newel);
- $$('div', { className: 'U_MD_D_MG_OONC', 'innerHTML': _newcontent, 'style': { 'margin-left': '10px', 'font-size': '14px', 'margin-top': '8px' } }, _newel);
- if (verify != 0) {
- _newel.children[3].style.color = '#2683f5';
- }
- if (verify == 0) {
- $$("div", { "style": { "float": "right", 'margin-top': '9px', 'margin-right': '5px' }, "className": " U_MD_D_MG_Count", "innerHTML": _descript }, _newel);
- }
- }
- U.selectEl("#U_MD_D_MG_AFT")[0].appendChild(_frag);
- }
- /**
- * 提供好友和群统一接口实现信息回调
- *
- *
- * @param {object} 当前的消息
- * @param {array} 所有的消息
- * @param {element} 消息元素
- */
- U.MD.F.N.chatMessage = function (newsinfo, news, el) {
- var _chatinfo;
- //如果是群聊天的处理
- if (newsinfo.GroupManageID) {
- _chatinfo = U.Json.select(US.friend.group, { "GroupManageID": newsinfo.GroupManageID })[0];
- }
- //如果是好友聊天的处理
- else {
- _chatinfo = U.Json.select(US.friend.friends, { "UserId": newsinfo.UserId })[0]
- }
- U.MD.F.W.viewFriend(_chatinfo); //查看消息
- U.MD.F.N.clearNews(newsinfo, news, el); //清除
- U.MD.F.N.delNewsTips(); //清除消息提示
- }
- /**
- * 提供好友和群统一接口实现信息回调
- *
- * @param {bool} 接收的消息类型
- * true 群消息
- * false 好友消息
- * @param {string} 好友或者群消息
- * @param {object} 获取查看的好友消息
- */
- U.MD.F.N.asynReceiveMessages = function (isgroup, chatform, r) {
- //如果是群消息查看
- if (isgroup) {
- U.MD.F.W.printGroupChatMessage($("div.U_MD_F_C", chatform)[0], r); //打印群消息
- }
- //好友消息的查看
- else {
- U.MD.F.W.printFriendChatMessage($("div.U_MD_F_C", chatform)[0], r); //打印好友消息
- }
- }
- /**
- * 添加好友的处理
- *
- * @param {object} 当前的消息
- * @param {array} 所有的消息
- * @param {element} 消息元素
- */
- U.MD.F.N.addFriendNewsHandle = function (newsinfo, news, el) {
- var _friendinfo = U.Json.select(US.friend.friends, { "UserId": newsinfo.UserId }, null, 1)[0]; //判断用户是否在好友分组里
- //好友不存在自己的列表
- if (!_friendinfo) {
- U.MD.F.M.addFriend(newsinfo, null, "0"); //添加他人进入群
- }
- //用户已经是自己的好友,那么直接弹出聊天
- else {
- U.MD.F.W.popupFriendsForm(_friendinfo);
- }
- U.MD.F.N.clearNews(newsinfo, news, el); //清除
- }
- /**
- * 添加好友的处理
- *
- * @param {object} 当前的消息
- * @param {array} 所有的消息
- * @param {element} 消息元素
- */
- U.MD.F.N.entryGroup = function (newsinfo, news, el) {
- var _groupuserid = Guid.newGuid(), //群用户id
- _friendinfo = U.Json.select(US.friend.groupusers, { "GroupManageID": news.MessageContent, "UserId": news.UserId }, null, 1)[0]; //查找群
- //如果群已经加载处理的处理
- if (_friendinfo) {
- U.alert("添加成功");
- }
- //添加用户进入群主
- else {
- U.A.Request(US.FRIEND, ["AddUsrsToGroup", US.userInfo.UserId, news.MessageID, news.UserId, news.MessageContent.toUpperCase(), _groupuserid, news.MessageDescript], U.MD.F.N.asynEntryGroup, ["", news, _groupuserid]);
- }
- U.MD.F.N.clearNews(newsinfo, news, el); //清除
- }
- /**
- * 添加群进入
- *
- * @param {object} 服务器返回的信息
- */
- U.MD.F.N.asynEntryGroup = function (r) {
- var _groupuserinfo,
- _context = r.context,
- _news = _context[1],
- _groupuserid = _context[2];
- //实例化用户
- _groupuserinfo = U.MD.F.T.groupUserEntity(_news.UserId, _news.UserImageHead, _news.UserNickName, _news.UserNickName, _news.UserThumbnailImageHead, _news.MessageContent.toUpperCase(), _news.MessageID, 1)
- //添加用户进入群
- US.friend.groupusers.push(_groupuserinfo);
- }
- /**
- * 被用户进入群处理
- *
- * @param {object} 消息信息
- */
- U.MD.F.N.pulledIntoGroups = function (newsinfo, news, el) {
- var _groupinfo = U.Json.select(US.friend.group, { "GroupManageID": newsinfo.MessageContent.toLowerCase() })[0];
- //判断群是否已经加载过,如果加载过那么就不重新加载
- if (!_groupinfo) {
- U.A.Request(US.FRIEND, ["GetJoinGroupNews", US.userInfo.UserId, newsinfo.MessageID, newsinfo.MessageContent], U.MD.F.N.asynPulledIntoGroups, ["", newsinfo]); //拉用户进入群组
- }
- else {
- U.MD.F.W.viewFriend(_groupinfo); //查看消息
- //如果是群的文件消息的处理
- if (newsinfo.MessageContent.length == 36) {
- }
- }
- U.MD.F.N.clearNews(newsinfo, news, el); //清除用户消息
- U.MD.F.W.addChecked(newsinfo); //添加聚焦效果
- U.MD.F.N.delNewsTips();
- }
- /**
- * 拉用户进入群组异步
- *
- * @param {object} 小新信息
- */
- U.MD.F.N.asynPulledIntoGroups = function (r) {
- //服务器返回成功
- if (r.value) {
- var _groupfriend,
- _groupfriends,
- _groupdiskarr,
- _context = r.context,
- _newinfo = _context[1],
- _userid = US.userInfo.UserId, //用户id
- _diskinfo = US.disk.Disks[_userid], //用户群信息
- _groupinfo = new U.MD.F.T.groupEntity(_newinfo.MessageContent.toLocaleLowerCase(), _newinfo.MessageDescript, U.UF.D.toTimeStamp(new Date()), _newinfo.UserId, "", null) //群信息
- ;
- r = r.value; //服务器响应后返回的值
- _groupfriends = r[0];
- US.friend.group.unshift(_groupinfo); //插入新群
- //添加群友
- for (i = 0; i < _groupfriends.length; i++) {
- //判断用户是否在群里,不重复添加
- if (!U.Json.select(US.friend.groupusers, { "GroupManageID": _groupfriends[i].GroupManageID, "UserId": _groupfriends[i].UserId })[0]) {
- //初始化生成群用户
- _groupfriend = new U.MD.F.T.groupUserEntity(_groupfriends[i].UserId, U.MD.C.getHeadImage(_groupfriends[i].UserImageHead), _groupfriends[i].UserNickName || _groupfriends[i].UserName, _groupfriends[i].UserName, U.MD.C.getHeadImage(_groupfriends[i].UserThumbnailImageHead), _groupfriends[i].GroupUsersDescript || _groupfriends[i].UserNickName, _groupfriends[i].GroupManageID, 1);
- //添加群用户到群里
- US.friend.groupusers.push(_groupfriend);
- }
- }
- _groupdiskarr = [new U.MD.DK.M.entity(_groupinfo.GroupManageID, 0, US.EMPTYGUID, _groupinfo.GroupManageName,
- _groupinfo.GroupManageName, "folder", null, U.UF.D.toTimeStamp(new Date()), U.MD.DK.C.getIcon("folder")[1],
- 1, null, null, 0, "", _groupinfo.GroupManageID)];
- _diskinfo && U.MD.DK.RE.addFileOrFolder(_groupdiskarr, _diskinfo, _diskinfo.directoryOrFiles[2]) //添加文件或者文件夹
- // _diskinfo && U.MD.DK.RE.addFileOrFolder(r[1], _diskinfo, _groupinfo) //群里的文件或者文件夹
- //直接显示到群里
- U.MD.F.W.viewFriend(_groupinfo); //查看消息
- U.selectEl($("#U_MD_F_H_ZLTA").Child()[2]).Child()[0].onclick(); //刷新群组列表
- //返回添加的群
- return US.friend.group[0];
- }
- }
- /**
- * 确认添加对方为好友
- *
- * @param {object} 确定添加对方为好友
- */
- U.MD.F.N.confirmAddFriend = function (newsinfo, news, el) {
- var _friendid = Guid.newGuid(), //好友id
- _friendinfo = U.Json.select(US.friend.friends, { "UserId": news.UserId })[0] //用户是否已经在好友列表
- ;
- //如果好友没有添加处理
- if (!_friendinfo) {
- U.A.Request(US.FRIEND, ["AddFriend", US.userInfo.UserId, news.UserId, _friendid, news.MessageContent, news.MessageDescript], U.MD.F.N.asynAddFriend, [null, news, news.MessageContent, _friendid]); //添加好友到默认分组
- }
- //如果用户在好友列表,那么直接弹出
- else {
- U.MD.F.W.popupFriendsForm(_friendinfo);
- }
- U.MD.F.N.clearNews(newsinfo, news, el); //清除消息
- }
- /**
- * 异步处理确定添加好友
- *
- * @param {object} 确定添加对方为好友
- */
- U.MD.F.N.asynAddFriend = function (r) {
- var _context = r.context,
- _new = _context[1],
- _groupid = _context[2],
- _friendid = _context[3];
- r = r.value;
- U.MD.F.M.displayAddFriend(r[0][0], _friendid, _groupid, r); //确定添加好友到好友分组里
- }
- /**
- * 清除所有的消息
- *
- * @param {array} 所有的消息
- */
- U.MD.F.N.clearAllNews = function () {
- var i, j,
- _allids = "",
- _allnews = U.MD.F.N.news
- ;
- //循环获取消息的id
- for (i = 0; i < _allnews.length; i++) {
- if (_allnews[i]) {
- for (j = 0; j < _allnews[i].length; j++) {
- _allids += (_allnews[i][j].GroupManageID || _allnews[i][j].MessageID) + ",";
- }
- _allnews[i].splice(0);
- }
- }
- _allids = _allids.substring(0, _allids.length - 1); //去除最后一位的,
- //数据库删除消息处理
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "DeleteMessageById", _allids, US.userInfo.UserId], function () { }, []);
- U.selectEl("#U_MD_D_MG_AFT")[0].innerText = "";
- }
- /**
- * 清除所有的的添加好友信息
- *
- * @param {array} 所有的消息
- * @param {object} 当前的消息
- * @param {element} 消息元素
- * @param {number} 消息类型
- */
- U.MD.F.N.clearNews = function (newsinfo, news, el) {
- var _pel = U.selectEl(el).Parent(),
- _messageid = (newsinfo.MessageID || newsinfo.GroupMessageID); //元素的上级元素
- //移除单挑消息
- U.Json.del(news, { "MessageID": newsinfo.MessageID });
- //清理消息
- U.MD.F.N.canelMarkMessage(newsinfo);
- U.selectEl(el).remove(); //移除消息
- //如果消息已经全部点击完毕的处理
- if ($(_pel).Child().length == 0 && U.selectEl("#U_MD_F_N_Message")[0]) {
- U.selectEl("#U_MD_F_N_Message")[0].close(); //关闭的处理
- }
- //数据库删除消息处理
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "DeleteMessageById", _messageid, US.userInfo.UserId], function () { }, []);
- }
- /**
- * 学习系统消息处理
- *
- * @param {array} 除了好友聊天消息,其他消息的处理
- */
- U.MD.F.N.otherNews = function (news) {
- }
- /*
- 标记未读信息
- @param {array} newsarr消息信息数组
- */
- U.MD.F.N.markUnreadMessage = function (newsarr) {
- var i, j, _id, _el, _parentel;
- for (i = 0; i < newsarr.length; i++) { //循环消息数组
- for (j = 0; j < newsarr[i].length; j++) {
- _id = newsarr[i][j].UserId || newsarr[i][j].GroupManageID; //获取消息id
- if (_id) {
- _el = U.selectEl("[tid='M" + _id + "']")[0]; //获取聊天次数元素
- _parentel = U.selectEl("[tid='" + _id + "']")[0]; //获取添加到哪个父亲的元素
- //如果可以添加
- if (_parentel) {
- if (_el) {
- _el.innerHTML = newsarr[i][j].count;
- }
- else {
- $$("div", { className: "U_Mark", innerHTML: newsarr[i][j].count, tid: "M" + _id, "style": { "cssText": "margin:0;position:absolute;left:48px" } }, _parentel); //生成红点
- }
- }
- }
- }
- }
- }
- /*
- 消除标记信息
- @param {json} friendindo 好友信息
- */
- U.MD.F.N.canelMarkMessage = function (friendInfo) {
- if (friendInfo) {
- if (friendInfo.GroupManageID) {
- U.selectEl("[tid='M" + friendInfo.GroupManageID + "']").remove(); //删除左边标记
- }
- else if (friendInfo.UserId) {
- U.selectEl("[tid='M" + friendInfo.UserId + "']").remove(); //删除左边标记
- }
- else if (friendInfo.MessageSendUserID) {
- U.selectEl("[tid='M" + friendInfo.MessageSendUserID + "']").remove(); //删除左边标记
- }
- }
- }
- /*
- 消除所有标记信息
- @param {json} friendindo 好友信息
- */
- U.MD.F.N.canelAllMarkMessage = function () {
- U.selectEl(".U_Mark").remove();
- }
- /*
- 移除单个消息提示动画
- */
- U.MD.F.N.delNewsTips = function () {
- //删除消息提示
- if ($("#U_MD_D_MG_AFT").Child().length == 0) {
- U.selectEl('.U_MD_D_NewsTipsIcon')[0].className = 'U_MD_D_NewsTipsIcon';
- }
- }
- /*
- 移除所有消息提示动画
- */
- U.MD.F.N.delAllNewsTips = function () {
- //删除消息提示
- U.selectEl('.U_MD_D_NewsTipsIcon')[0].className = 'U_MD_D_NewsTipsIcon';
- }
- //#endregion
- /*
- 新消息提示图标沒有新消息的处理
- */
- U.MD.F.N.noNewsTips = function () {
- //判断是否有新消息
- if ($("#U_MD_D_MG_AFT").Child().length == 0) {
- if (!$('.U_MD_F_N_NoNewsTips')[0]) {
- $$('div', { 'className': 'U_MD_F_N_NoNewsTips', 'style': {}, 'innerHTML': '暂无消息' }, U.selectEl("#U_MD_F_N_Message")[0]);
- } else {
- U.selectEl('.U_MD_F_N_NoNewsTips')[0].style.display = "block";
- }
- U.MD.F.N.delAllNewsTips();
- }
- else {
- if ($('.U_MD_F_N_NoNewsTips')[0]) {
- U.selectEl('.U_MD_F_N_NoNewsTips')[0].style.display = "none";
- }
- }
- }
- /**
- *添加消息提示音
- *parentele {element} 添加到父亲元素
- *allnews {array} 消息数组
- */
- U.MD.F.N.addNewsSound = function (parentele, allnews) {
- //判断是否创建音频
- if (!$('#U_MD_F_N_NewsAudio')[0]) {
- $$('audio', { "id": "U_MD_F_N_NewsAudio", "src": "http://gddx.sc.chinaz.com/Files/DownLoad/sound1/201703/8407.wav", "autoplay": 'autoplay' }, parentele);
- }
- //创建了,则播放音频
- else {
- U.selectEl('#U_MD_F_N_NewsAudio')[0].play();
- }
- }
- /**
- *点击查看好友聊天移除企鹅图标新消息提示
- *parentele {element} 添加到父亲元素
- *allnews {array} 消息数组
- */
- U.MD.F.N.cancelNewsMessage = function (friendInfo) {
- var i,
- _news, //消息
- _id = friendInfo.GroupManageID ? "GroupManageID" : "UserId",
- _obj = {}, //查找条件
- _child = U.selectEl("#U_MD_D_MG_AFT").Child(); //消息元素
- _obj[_id] = friendInfo[_id]; //设置条件
- _news = U.Json.select(U.MD.F.N.news[0], _obj)[0]; //查找消息
- if (_news) {
- //循环
- for (i = 0; i < _child.length; i++) {
- if (_child[i].tid == "O" + _news.MessageID) {
- U.MD.F.N.chatMessage(_news, U.MD.F.N.news[0], _child[i]);
- return;
- }
- }
- }
- };
- ///<jscompress sourcefile="RightClick.js" />
- Namespace.register("U.MD.F.R"); //好友和群窗口区域命名空间
- //#region 右键菜单
- /**
- * 右键功能 显示[移动至][删除]窗体
- * 参数说明 0 当前元素 1 用户信息
- * @param {element} 右键好友的区域
- * @param {object} 好友信息
- */
- U.MD.F.R.friendsRightClickMenu = function (el, friendinfo) {
- var _friendmenuel = U.selectEl('#U_MD_F_G_Div')[0], //右键的菜单
- _child = U.selectEl(_friendmenuel).Child(); //子菜单
- //显示菜单,定位
- U.selectEl(_friendmenuel).css({ "display": "block", "zIndex": "999" });
- U.UF.C.rightClickMenuLocation(_friendmenuel); //右键菜单定位
- //按钮功能赋值
- _child[0].onclick = function () { U.MD.F.W.popupFriendsForm(friendinfo); }; //发送消息
- _child[1].onclick = function () { U.MD.U.V.ViewOtherUserInfo(friendinfo.UserId); }; //查看个人资料
- _child[2].onmouseover = function () { U.MD.F.R.moveFriendForm(friendinfo, el, _child[2]); }; //移动联系人至
- _child[3].onclick = function () { U.MD.F.R.deleteFriendForm(friendinfo); }; //删除
- //点击其它区域隐藏右键菜单
- U.selectEl(document).bind("click", function () {
- U.selectEl(_friendmenuel)[0].style.display = "none";
- })
- }
- /**
- * 鼠标移动到 联系人移动至制定的好友分组弹框
- * @param {object} 好友信息
- * @param {element} 右键好友的区域
- * @param {element} onmouseover出发的按钮
- */
- U.MD.F.R.moveFriendForm = function (friendinfo, el, menubootom) {
- var i,
- _friendclassel = U.selectEl(menubootom).parentElement().Child()[4], //获取好友分组打印的元素
- _friendclassinfo = US.friend.allclass; //获取用户所有的好友分组
- _friendclassel.innerText = ""; //清空之前打印的好友分组
- if (!friendinfo.FriendsGroupID) {//判断好友信息是否有好友分组id
- friendinfo.FriendsGroupID = U.Json.select(US.friend.friends, { "UserId": friendinfo.UserId })[0].FriendsGroupID; //给好友信息添加好友分组id
- }
- //如果有好友分组可以移动的情况
- if (_friendclassinfo.length > 1) {
- //循环打印好友分组
- for (i = 0; i < _friendclassinfo.length; i++) {
- //如果是当前用户所在的好友分组不打印,否则都打印
- if (_friendclassinfo[i].FriendsGroupID != friendinfo.FriendsGroupID) {
- //创建好友分组元素
- $$("div", {
- "class": "U_MD_F_G_Div_Children_A", "innerText": _friendclassinfo[i]["FriendsGroupName"],
- "onclick": U.UF.C.closure(function (i) {
- U.MD.F.R.assignMoveFriend(friendinfo, _friendclassinfo[i], el);
- }, [i])
- }, _friendclassel);
- }
- }
- _friendclassel.style.display = "block";
- }
- }
- /**
- * 触发移动好友
- *
- * @param {object} 好友信息
- * @param {object} 群信息
- * @param {element} 好友元素
- */
- U.MD.F.R.assignMoveFriend = function (friendinfo, groupinfo, el) {
- var _friendsid;
- //只有选择移动了触发
- if (friendinfo) {
- U.selectEl('#U_MD_F_G_Div')[0].style.display = "none"; //点击后隐藏右键
- U.selectEl(".U_MD_F_G_Div_Children")[0].style.display = "none"; //隐藏右键后好友分组选择的菜单
- if (friendinfo.FriendsID) {
- _friendsid = friendinfo.FriendsID;
- } else {
- friendinfo.FriendsID = U.Json.select(US.friend.friends, { "UserId": friendinfo.UserId })[0].FriendsID;
- friendinfo.FriendsGroupID = U.Json.select(US.friend.friends, { "UserId": friendinfo.UserId })[0].FriendsGroupID;
- }
- //数据库设置移动好友信息
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "MoveFriendToOtherClass", friendinfo.FriendsID, groupinfo["FriendsGroupID"]],
- U.MD.F.R.asynAssignMoveFriend, ["", friendinfo, groupinfo, el]);
- U.alert('修改成功');
- }
- }
- /**
- * 把相应的好友移动到指定的群组里
- */
- U.MD.F.R.asynAssignMoveFriend = function (r) {
- var _child, //好友分组元素
- _context = r.context, //异步传参
- _friendinfo = _context[1], //移动好友实体
- _groupinfo = _context[2], //好友分组字体
- _el = _context[3], //移动的元素
- _friendgroupel = U.selectEl("#g" + _groupinfo.FriendsGroupID)[0], //移动到的好友分组
- _previousgroupinfo = U.Json.select(US.friend.allclass, { "FriendsGroupID": _friendinfo.FriendsGroupID })[0], //修改前的好友分组
- _friendnum = U.Json.select(US.friend.friends, { "FriendsGroupID": _friendinfo.FriendsGroupID }).length - 1 //好友分组的数量
- ;
- //设置好友原本所在的分组信息
- //判断是否处于好友聊天功能下
- if ($('.U_MD_F_H_ZLTOO')[0]) {
- U.selectEl(_el).parentElement(2).Child()[0].innerHTML = _previousgroupinfo.FriendsGroupName + "(" + _friendnum + ")"; //移动好友出去后需改数量显示
- U.MD.F.R.assignNoFriendTips(_previousgroupinfo, _friendnum, U.selectEl(_el).parentElement(2).Child()[1], U.selectEl(_friendgroupel).Child()[1]);
- }
- //好友实体的id变化FriendsGroupID
- _friendinfo.FriendsGroupID = _groupinfo.FriendsGroupID;
- U.Json.select(US.friend.friends, { "UserId": _friendinfo.UserId })[0].FriendsGroupID = _groupinfo.FriendsGroupID;
- //判断分组是否显示
- if (_friendgroupel) {
- _child = U.selectEl(_friendgroupel).Child();
- _friendnum = U.Json.select(US.friend.friends, { "FriendsGroupID": _friendinfo.FriendsGroupID }).length;
- _child[0].innerHTML = _groupinfo["FriendsGroupName"] + "(" + _friendnum + ")"; //新好友分组
- _child[1].appendChild(_el); //添加移动的元素
- }
- }
- /**
- * 移动好友后,分组内是否显示没有好友跟随提示的异步
- * previousgroupinfo {object} 好友移动后的前分组
- * nowfriendnum {string} 好友移动后的现在好友分组的好友数量
- * previousel {elementy} 前分组的元素
- * nowel {element} 现分组的元素
- */
- U.MD.F.R.assignNoFriendTips = function (previousgroupinfo, nowfriendnum, previousel, nowel) {
- var _previousfriendnum = U.Json.select(US.friend.friends, { "FriendsGroupID": previousgroupinfo.FriendsGroupID }).length;
- if (_previousfriendnum == 0 && previousel.parentNode) {
- $$("div", { "class": "U_MD_F_H_ZLZOCO_under", "style": { "margin": "9px 0 0 10px" }, "innerHTML": "该分组暂无好友" }, previousel);
- }
- if (nowel.parentNode && nowel.getElementsByClassName("U_MD_F_H_ZLZOCO_under")[0]) {
- nowel.removeChild($('.U_MD_F_H_ZLZOCO_under')[0]);
- }
- }
- /**
- * 鼠标从 联系人移动至 移开
- * 隐藏现有的好友分组 Jude
- */
- U.MD.F.R.moveFriendOver = function (isdisplay, friendgroupmenu, el) {
- //判断是否是冒泡上来的,如果是冒泡的则不处理
- if (!U.UF.EV.stopBubbleMouseOutOrOver(el)) {
- //根据传参设置是否显示隐藏
- friendgroupmenu.style.display = isdisplay ? "none" : "block";
- }
- }
- /**
- * 弹出移动好友分组
- * 参数说明 0 要移动的对象的信息集合 1 右键区域
- * @param {element} 点击移动至区域
- */
- U.MD.F.R.topMoveFriendForm = function (el, friendinfo) {
- var _chooseGroupInfon = null;
- //未创建
- //if (!$(".U_MD_F_G_Y_D")[0]) {
- var i, //循环
- _tempel,
- _friendclassel = $$("div", { "className": "U_MD_F_G_Y_D" }), //弹出框内容区域
- _friendclassinfo = US.friend.allclass, //好友分组信息
- _friendclassform = U.UF.UI.confirm(_friendclassel, function () { U.MD.F.R.assignMoveFriend(friendinfo, _chooseGroupInfon, el) }); //好友分组弹框
- $$("div", { "innerText": "选择好友移动至", "className": "U_MD_F_G_Y_DT" }, _friendclassel);
- _tempel = $$("div", { "className": "U_MD_F_G_Y_DS" }, _friendclassel);
- //循环所有可以移动的分组
- for (i = 0; i < _friendclassinfo.length; i++) {
- $$("div", {
- "innerHTML": _friendclassinfo[i].FriendsGroupName,
- "className": "U_MD_F_G_Div_Q" + (friendinfo.FriendsGroupID == _friendclassinfo[i].FriendsGroupID ? " U_MD_F_G_Div_QO" : ""),
- "onclick": U.UF.C.closure(function (i) {
- _chooseGroupInfon = _friendclassinfo[i];
- U.MD.F.R.topMoveFriendFormSwitch(this, friendinfo, _friendclassinfo[i], _friendclassform, el);
- }, [i])
- }, _tempel);
- }
- //自适应宽度
- U.selectEl($(_friendclassform.content)[0]).Parent().style.height = "100%";
- U.selectEl($($($($($(".U_MD_F_G_Y_D")[0]).Parent()).Parent()).Parent()).Parent()).Parent().style.zIndex = 100; //置顶好友分组弹窗
- // } else {//已经创建
- // var _formparent = U.selectEl($($($($($(".U_MD_F_G_Y_D")[0]).Parent()).Parent()).Parent()).Parent()).Parent(); //获取父级窗体元素
- // if (_formparent.style.display == "none") {
- // _formparent.style.display = "block";
- // } else {
- // _formparent.style.display = "none"
- // }
- // }
- }
- /**
- * 右键功能 显示[移动至][删除]窗体
- *
- * @param {element} 选中变化的元素
- * @param {object} 好友信息
- * @param {object} 群信息
- * @param {array} 对话框
- ------------[0] 对话框
- * @param {element} 好友元素
- */
- U.MD.F.R.topMoveFriendFormSwitch = function (groupel, friendinfo, friendclassinfo, friendclassform, el) {
- var i, //用于循环
- _child = U.selectEl(el).parentElement().Child(); //获取
- //_group = U.selectEl(".U_MD_F_G_Y_DS").Child();
- _group = groupel.parentNode.children;
- for (i = 0; i < _group.length; i++) {
- _group[i].className = U.selectEl(".U_MD_F_G_Y_DS").Child()[i].className == "U_MD_F_G_Div_Q U_MD_F_G_Div_QO" ? "U_MD_F_G_Div_Q" : "U_MD_F_G_Div_Q";
- groupel.className = "U_MD_F_G_Div_Q U_MD_F_G_Div_QO";
- }
- //设置点击的效果
- for (i = 0; i < _child.length; i++) {
- _child[i].className = "U_MD_F_H_ZLZOCO" + (el == _child[i] ? " U_MD_F_G_Div_QQ" : "");
- }
- //设置确定按钮的事件,这里要结合窗体的api
- // friendclassform.AddEvent({ Yes: [U.MD.F.R.assignMoveFriend, [friendinfo, friendclassinfo, el]] });
- }
- //#endregion
- //#region 好友分组
- /**
- * 右键群显示
- * @param object 右键元素的信息集合
- */
- U.MD.F.R.friendClassRightClickMenu = function (friendgroupinfo, el) {
- var _el = U.selectEl('#U_MD_F_G_Qun')[0], //右键的菜单
- _child = U.selectEl(_el).Child(); //子菜单
- U.selectEl(_el).css({ "display": "block", "zIndex": "999" }); //显示右键菜单
- U.UF.C.rightClickMenuLocation(_el); //右键菜单定位
- //修改分组名字的点击处理
- _child[0].onclick = function () { U.MD.F.R.popupUpdateFriendsClassForm(friendgroupinfo, el); };
- _child[1].onclick = function () { U.MD.F.R.popupDeleteFriendsClassForm(friendgroupinfo, el); };
- U.selectEl(document).bind("click", function () {
- U.selectEl('#U_MD_F_G_Qun')[0].style.display = "none";
- })
- }
- /**
- * 修改分组昵称 弹框
- * @param object 分组信息集合
- * @param object 当前的el
- */
- U.MD.F.R.popupUpdateFriendsClassForm = function (friendgroupinfo, el) {
- var _tempel,
- _temponeel,
- _temptwoel;
- var _el = U.selectEl('#U_MD_F_G_Qun')[0]; //右键的菜单
- U.selectEl(_el).css({ "display": "none" }); //显示右键菜单
- if (friendgroupinfo) {
- //创建好友分组的样式
- _tempel = $$("div", { "className": "U_MD_U_L_Box_I U_MD_F_Add_TNL U_MD_F_G" });
- _temponeel = $$("div", {}, _tempel)
- _temptwoel = $$("input", {
- "value": friendgroupinfo.FriendsGroupName, "onfocus": function () { U.UF.MR.inputPlaceholder(this, friendgroupinfo.FriendsGroupName, ""); },
- "onblur": function () { U.UF.MR.inputPlaceholder(this, "", friendgroupinfo.FriendsGroupName); }
- }, _temponeel);
- //弹出好友对话框
- U.UF.UI.confirm(_tempel, function () { U.MD.F.R.assignUpdateFriendsClass(friendgroupinfo, _temptwoel, el); }); //创建一个对话框
- }
- else {
- U.alert("暂无群信息");
- }
- }
- /**
- *
- * 参数说明 0 群消息集合 1 更改的分组名称 3对应修改的el
- * @param {object} 群信息
- * @param {element} 输入框
- * @param {object} 对应的el
- */
- U.MD.F.R.assignUpdateFriendsClass = function (friendgroupinfo, formel, el) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "UpdateClassNameAndDescription", friendgroupinfo["FriendsGroupID"], formel.value, ""],
- function () {
- U.selectEl(el)[0].innerText = formel.value;
- U.alert("修改成功");
- }, []);
- U.alert("正在修改中");
- }
- /*
- * 删除好友分组弹框
- * @param object 分组信息集合
- * @param object 当前的el
- */
- U.MD.F.R.popupDeleteFriendsClassForm = function (friendgroupinfo, el) {
- var _content;
- var _el = U.selectEl('#U_MD_F_G_Qun')[0]; //右键的菜单
- U.selectEl(_el).css({ "display": "none" }); //显示右键菜单
- if (friendgroupinfo) {
- _content = "是否确定删除(" + friendgroupinfo.FriendsGroupName + ")该分组";
- U.UF.UI.confirm(_content, function () { U.MD.F.R.assignDeleteFriendsClass(friendgroupinfo, el); });
- }
- }
- /*
- * 确定删除好友分组
- * @param object 分组信息集合
- * @param object 当前的el
- */
- U.MD.F.R.assignDeleteFriendsClass = function (friendgroupinfo, el) {
- var _friendGroupLength = U.Json.select(US.friend.friends, { "FriendsGroupID": friendgroupinfo.FriendsGroupID }).length;
- if (friendgroupinfo.FriendsGroupDescript != "自动创建") {
- if (_friendGroupLength == 0) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "DeleteFriendClass", friendgroupinfo.FriendsGroupID],
- function () {
- U.selectEl(el).Parent().remove()
- U.alert("删除成功");
- //在好友数组的全局变量中删除好友分组的信息
- for (i = 0; i < US.friend.allclass.length; i++) {
- if (US.friend.allclass[i].FriendsGroupID == friendgroupinfo.FriendsGroupID) {
- US.friend.allclass.splice(i, 1);
- }
- }
- }, []);
- U.alert("正在删除中");
- } else {
- U.alert(friendgroupinfo.FriendsGroupName + "该分组下有好友,无法删除");
- }
- } else {
- U.alert("自动创建的分组不可删除");
- }
- }
- //#endregion
- /**
- * 删除确定
- * 参数说明 0 要删除的对象ID 1右键的区域
- * @param {element} 右键好友的区域
- */
- U.MD.F.R.deleteFriendForm = function (friendinfo, callback) {
- var _el;
- U.MD.F.R.addFriendsId(friendinfo); //添加FriendsID
- //创建删除好友的信息样式
- _el = $$("div", { "class": "U_MD_F_G_D" });
- $$("div", { "class": "U_MD_F_G_DelSpan", "innerText": "删除后对方将从好友列表中消失,无法进行发送以及接收消息。" }, _el);
- //弹出删除好友的框
- U.UF.UI.confirm(_el, function () {
- U.MD.F.M.deleteFriend(friendinfo);
- U.UF.C.isFunction(callback) && callback();
- });
- }
- /**
- * 右上角设置
- * 参数说明 friendinfo对应的好友信息集合
- * @param object 好友信息
- *
- */
- U.MD.F.R.popupRightCornerMenu = function (friendinfo, el) {
- var _tempel,
- _friendclassinfo,
- _isaddfriend,
- _menuel = U.selectEl(el).Child()[0];
- //如果菜单存在则删除
- if (_menuel) {
- U.selectEl(_menuel).remove();
- }
- else {
- //好友查看
- if (friendinfo.UserId) {
- _isaddfriend = U.Json.selectOne(US.friend.friends, { "UserId": friendinfo.UserId }); //判断用户是否在好友列表里
- //判断用户是否是自己的好友,是的话则操作好友信息
- _tempel = $$("div", { "class": "U_MD_F_T_B", style: {} }, el);
- if (_isaddfriend) {
- //获取好友分组信息
- _friendclassinfo = U.selectEl($("#g" + _isaddfriend.FriendsGroupID + " div")[1]).find('[tid="' + _isaddfriend["UserId"] + '"]')[0]; //好友分组信息
- //创建菜单
- //_tempel = $$("div", { "class": "U_MD_F_T_B", style: {} }, el);
- $$("div",
- {
- "innerText": "修改备注姓名",
- "onclick": function () {
- U.MD.F.R.updateFriendDescriptForm(_isaddfriend);
- }
- },
- _tempel);
- $$("div",
- {
- "innerText": "修改好友分组",
- "onclick": function () {
- U.MD.F.R.topMoveFriendForm(_friendclassinfo, _isaddfriend);
- }
- },
- _tempel);
- $$("div",
- {
- "innerText": "删除好友",
- "onclick": function () {
- U.MD.F.R.deleteFriendForm(_isaddfriend);
- }
- },
- _tempel);
- U.UF.EV.stopBubble();
- U.selectEl(document).bind("click", function (e) {
- U.selectEl(".U_MD_F_T_B").remove();
- })
- }
- //如果好友不是自己的好友,则菜单为添加好友
- else {
- $$("div", {
- "innerText": "添加该好友", 'onclick': function () {
- U.MD.F.M.addFriend(friendinfo);
- }
- }, _tempel);
- }
- }
- //群菜单查看
- else {
- U.MD.F.J.groupInfoForm(friendinfo); //查看群 操作
- }
- }
- }
- /**
- * 修改好友备注
- * 参数说明 UGE对应的好友信息集合
- * @param object
- */
- U.MD.F.R.updateFriendDescriptForm = function (_friendinfo) {
- var _tempel,
- _temponeel,
- _temptwoel,
- _descript;
- _descript = _friendinfo.FriendsDescript || _friendinfo.UserNickName; //修改的好友昵称
- //创建好友分组的样式
- _tempel = $$("div", { "className": "U_MD_U_L_Box_I U_MD_F_Add_TNL U_MD_F_G" });
- _temponeel = $$("div", {}, _tempel)
- _temptwoel = $$("input",
- {
- "value": _descript,
- "onfocus": function () {
- U.UF.MR.inputPlaceholder(this, _descript, "");
- },
- "onblur": function () {
- U.UF.MR.inputPlaceholder(this, "", _descript);
- }
- }, _temponeel);
- //弹出好友对话框
- U.UF.UI.confirm(_tempel, function () {
- U.MD.F.R.updateFriendDescript(_friendinfo, _temptwoel);
- }); //创建一个对话框
- }
- /**
- * 确认修改备注
- * 参数说明 0 对应好友信息集合 1对应的el 用于静态改变当前的备注
- * @param{object}群信息
- * @{element}对应el
- */
- U.MD.F.R.updateFriendDescript = function (friendinfo, el) {
- U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "UpdateFriendDescription", friendinfo['FriendsID'], el.value],
- U.MD.F.R.asynUpdateFriendDescript, [null, friendinfo, el.value]);
- }
- /**
- * 好友备注修改异步
- * @param{object} 异步服务器返回的信息
- */
- U.MD.F.R.asynUpdateFriendDescript = function (r) {
- var _context = r.context,
- _friendinfo = _context[1],
- _descript = _context[2],
- _el = U.selectEl($("#g" + _friendinfo.FriendsGroupID + " div")[1]).find('[tid="' + _friendinfo["UserId"] + '"]')[0];
- _friendinfo.FriendsDescript = _descript; //在好友信息集合里修改用户描述
- //在好友列表中修改好友
- if (_el) {
- U.selectEl("div", _el)[2].innerText = _context[2];
- }
- //在聊天窗口修改好友
- U.selectEl("div", U.selectEl('.U_MD_F_TO.U_MD_F_TOT')[0])[1].innerText = _context[2];
- var _obj = U.selectEl('.U_MD_F_TO.U_MD_F_TOT')[0],
- _tags = U.selectEl(".U_MD_F_TA")[0].children;
- for (var i = 0, len = _tags.length; i < len; i++) {
- // 找到节点,返回下标
- if (_tags[i] == _obj) {
- U.selectEl("div", U.selectEl('.U_MD_F_H')[i])[2].innerText = _context[2];
- }
- }
- }
- //#region 群聊
- /**
- * 右键群聊显示
- * @param object 右键元素的信息集合
- */
- U.MD.F.R.GroupRightClickMenu = function (el, friendgroupinfo) {
- var _el = U.selectEl('#U_MD_F_G_Group')[0], //右键的菜单
- _groupuserinfo = U.Json.select(US.friend.groupusers, { "GroupManageID": friendgroupinfo.GroupManageID }),
- _child = U.selectEl(_el).Child(); //子菜单
- U.selectEl(_el).css({ "display": "block", "zIndex": "999" }); //显示右键菜单
- U.UF.C.rightClickMenuLocation(_el); //右键菜单定位
- //修改分组名字的点击处理
- _child[0].onclick = function () { U.MD.F.J.groupInfoForm(friendgroupinfo, el) };
- _child[1].onclick = function () { U.MD.F.J.groupExit(friendgroupinfo, U.Json.selectOne(_groupuserinfo, { "UserId": US.userInfo.UserId })); };
- U.selectEl(document).bind("click", function () {
- U.selectEl('#U_MD_F_G_Group')[0].style.display = "none";
- })
- }
- /**
- *添加FriendsID
- *friendinfo {object} 好友信息
- */
- U.MD.F.R.addFriendsId = function (friendinfo) {
- var _userfriends = US.friend.friends;
- if (!friendinfo.FriendsID) {//判断FriendsID是否存在
- for (var i = 0; i < _userfriends.length; i++) {
- if (friendinfo.UserId == _userfriends[i].UserId) {//对比好友的UserID
- friendinfo.FriendsID = _userfriends[i].FriendsID; //给好友信息添加FriendsID
- }
- }
- } else {
- for (var i = 0; i < _userfriends.length; i++) {
- if (friendinfo.UserId == _userfriends[i].UserId && friendinfo.FriendsID != _userfriends[i].FriendsID) {//对比好友的UserID
- friendinfo.FriendsID = _userfriends[i].FriendsID; //给好友信息添加FriendsID
- }
- }
- }
- }
- ;
- ;
- ///<jscompress sourcefile="User.js" />
- ///<jscompress sourcefile="CityData.js" />
- Namespace.register("U.MD.U.C"); //好友国家城市的命名空间
- //国家省份城市的地址选择
- U.MD.U.C.J = { "citylist": [{ "co": "中国", "cp": [{ "p": "北京市", "c": [{ "n": "东城" }, { "n": "西城" }, { "n": "崇文" }, { "n": "宣武" }, { "n": "朝阳" }, { "n": "丰台" }, { "n": "石景山" }, { "n": "海淀" }, { "n": "门头沟" }, { "n": "房山" }, { "n": "通州" }, { "n": "顺义" }, { "n": "昌平" }, { "n": "大兴" }, { "n": "怀柔" }, { "n": "平谷" }, { "n": "密云" }, { "n": "延庆" }] }, { "p": "天津市", "c": [{ "n": "和平" }, { "n": "河东" }, { "n": "河西" }, { "n": "南开" }, { "n": "河北" }, { "n": "红挢" }, { "n": "塘沽" }, { "n": "汉沽" }, { "n": "大港" }, { "n": "东丽" }, { "n": "西青" }, { "n": "津南" }, { "n": "北辰" }, { "n": "武清" }, { "n": "宝坻" }, { "n": "宁河" }, { "n": "静海" }, { "n": "蓟县" }] }, { "p": "河北省", "c": [{ "n": "石家庄" }, { "n": "唐山" }, { "n": "秦皇岛" }, { "n": "邯郸" }, { "n": "邢台" }, { "n": "保定" }, { "n": "张家口" }, { "n": "承德" }, { "n": "沧州" }, { "n": "廊坊" }, { "n": "衡水" }] }, { "p": "山西省", "c": [{ "n": "太原" }, { "n": "大同" }, { "n": "阳泉" }, { "n": "长治" }, { "n": "晋城" }, { "n": "朔州" }, { "n": "晋中" }, { "n": "运城" }, { "n": "忻州" }, { "n": "临汾" }, { "n": "吕梁" }] }, { "p": "内蒙古", "c": [{ "n": "呼和浩特" }, { "n": "包头" }, { "n": "乌海" }, { "n": "赤峰" }, { "n": "通辽" }, { "n": "鄂尔多斯" }, { "n": "呼伦贝尔" }, { "n": "巴彦淖尔" }, { "n": "乌兰察布" }, { "n": "兴安" }, { "n": "锡林郭勒" }, { "n": "阿拉善" }] }, { "p": "辽宁省", "c": [{ "n": "沈阳" }, { "n": "大连" }, { "n": "鞍山" }, { "n": "抚顺" }, { "n": "本溪" }, { "n": "丹东" }, { "n": "锦州" }, { "n": "营口" }, { "n": "阜新" }, { "n": "辽阳" }, { "n": "盘锦" }, { "n": "铁岭" }, { "n": "朝阳" }, { "n": "葫芦岛" }] }, { "p": "吉林省", "c": [{ "n": "长春" }, { "n": "吉林" }, { "n": "四平" }, { "n": "辽源" }, { "n": "通化" }, { "n": "白山" }, { "n": "松原" }, { "n": "白城" }, { "n": "延边" }] }, { "p": "黑龙江", "c": [{ "n": "哈尔滨" }, { "n": "齐齐哈尔" }, { "n": "鸡西" }, { "n": "鹤岗" }, { "n": "双鸭山" }, { "n": "大庆" }, { "n": "伊春" }, { "n": "佳木斯" }, { "n": "七台河" }, { "n": "牡丹江" }, { "n": "黑河" }, { "n": "绥化" }, { "n": "大兴安岭" }] }, { "p": "上海市", "c": [{ "n": "黄浦" }, { "n": "卢湾" }, { "n": "徐汇" }, { "n": "长宁" }, { "n": "静安" }, { "n": "普陀" }, { "n": "闸北" }, { "n": "虹口" }, { "n": "杨浦" }, { "n": "闵行" }, { "n": "宝山" }, { "n": "嘉定" }, { "n": "浦东新" }, { "n": "金山" }, { "n": "松江" }, { "n": "南汇" }, { "n": "奉贤" }, { "n": "青浦" }, { "n": "崇明" }] }, { "p": "江苏省", "c": [{ "n": "南京" }, { "n": "无锡" }, { "n": "徐州" }, { "n": "常州" }, { "n": "苏州" }, { "n": "南通" }, { "n": "连云港" }, { "n": "淮安" }, { "n": "盐城" }, { "n": "扬州" }, { "n": "镇江" }, { "n": "泰州" }, { "n": "宿迁" }] }, { "p": "浙江省", "c": [{ "n": "杭州" }, { "n": "宁波" }, { "n": "温州" }, { "n": "嘉兴" }, { "n": "湖州" }, { "n": "绍兴" }, { "n": "金华" }, { "n": "衢州" }, { "n": "舟山" }, { "n": "台州" }, { "n": "丽水" }] }, { "p": "安徽省", "c": [{ "n": "合肥" }, { "n": "芜湖" }, { "n": "蚌埠" }, { "n": "淮南" }, { "n": "马鞍山" }, { "n": "淮北" }, { "n": "铜陵" }, { "n": "安庆" }, { "n": "黄山" }, { "n": "滁州" }, { "n": "阜阳" }, { "n": "宿州" }, { "n": "巢湖" }, { "n": "六安" }, { "n": "亳州" }, { "n": "池州" }, { "n": "宣城" }] }, { "p": "福建省", "c": [{ "n": "福州" }, { "n": "厦门" }, { "n": "莆田" }, { "n": "三明" }, { "n": "泉州" }, { "n": "漳州" }, { "n": "南平" }, { "n": "龙岩" }, { "n": "宁德" }] }, { "p": "江西省", "c": [{ "n": "南昌" }, { "n": "景德镇" }, { "n": "萍乡" }, { "n": "九江" }, { "n": "新余" }, { "n": "鹰潭" }, { "n": "赣州" }, { "n": "宜春" }, { "n": "吉安" }, { "n": "抚州" }, { "n": "上饶" }] }, { "p": "山东省", "c": [{ "n": "济南" }, { "n": "青岛" }, { "n": "淄博" }, { "n": "枣庄" }, { "n": "东营" }, { "n": "烟台" }, { "n": "潍坊" }, { "n": "济宁" }, { "n": "泰安" }, { "n": "威海" }, { "n": "日照" }, { "n": "莱芜" }, { "n": "临沂" }, { "n": "德州" }, { "n": "聊城" }, { "n": "滨州" }, { "n": "菏泽" }] }, { "p": "河南省", "c": [{ "n": "郑州" }, { "n": "开封" }, { "n": "洛阳" }, { "n": "平顶山" }, { "n": "安阳" }, { "n": "鹤壁" }, { "n": "新乡" }, { "n": "焦作" }, { "n": "濮阳" }, { "n": "许昌" }, { "n": "漯河" }, { "n": "三门峡" }, { "n": "南阳" }, { "n": "商丘" }, { "n": "信阳" }, { "n": "周口" }, { "n": "驻马店" }, { "n": "济源" }] }, { "p": "湖北省", "c": [{ "n": "武汉" }, { "n": "黄石" }, { "n": "十堰" }, { "n": "宜昌" }, { "n": "襄樊" }, { "n": "鄂州" }, { "n": "荆门" }, { "n": "孝感" }, { "n": "荆州" }, { "n": "黄冈" }, { "n": "咸宁" }, { "n": "随州" }, { "n": "恩施" }, { "n": "仙桃" }, { "n": "潜江" }, { "n": "天门" }, { "n": "神农架" }] }, { "p": "湖南省", "c": [{ "n": "长沙" }, { "n": "株洲" }, { "n": "湘潭" }, { "n": "衡阳" }, { "n": "邵阳" }, { "n": "岳阳" }, { "n": "常德" }, { "n": "张家界" }, { "n": "益阳" }, { "n": "郴州" }, { "n": "永州" }, { "n": "怀化" }, { "n": "娄底" }, { "n": "湘西" }] }, { "p": "广东省", "c": [{ "n": "广州" }, { "n": "韶关" }, { "n": "深圳" }, { "n": "珠海" }, { "n": "汕头" }, { "n": "佛山" }, { "n": "江门" }, { "n": "湛江" }, { "n": "茂名" }, { "n": "肇庆" }, { "n": "惠州" }, { "n": "梅州" }, { "n": "汕尾" }, { "n": "河源" }, { "n": "阳江" }, { "n": "清远" }, { "n": "东莞" }, { "n": "中山" }, { "n": "潮州" }, { "n": "揭阳" }, { "n": "云浮" }] }, { "p": "广西省", "c": [{ "n": "南宁" }, { "n": "柳州" }, { "n": "桂林" }, { "n": "梧州" }, { "n": "北海" }, { "n": "防城港" }, { "n": "钦州" }, { "n": "贵港" }, { "n": "玉林" }, { "n": "百色" }, { "n": "贺州" }, { "n": "河池" }, { "n": "来宾" }, { "n": "崇左" }] }, { "p": "海南省", "c": [{ "n": "海口" }, { "n": "三亚" }, { "n": "五指山" }, { "n": "琼海" }, { "n": "儋州" }, { "n": "文昌" }, { "n": "万宁" }, { "n": "东方" }, { "n": "定安" }, { "n": "屯昌" }, { "n": "澄迈" }, { "n": "临高" }, { "n": "白沙" }, { "n": "昌江" }, { "n": "乐东" }, { "n": "陵水" }, { "n": "保亭" }, { "n": "琼中" }, { "n": "西沙" }, { "n": "南沙" }, { "n": "中沙" }] }, { "p": "重庆市", "c": [{ "n": "渝中" }, { "n": "大渡口" }, { "n": "江北" }, { "n": "沙坪坝" }, { "n": "九龙坡" }, { "n": "南岸" }, { "n": "北碚" }, { "n": "万盛" }, { "n": "双挢" }, { "n": "渝北" }, { "n": "巴南" }, { "n": "万州" }, { "n": "涪陵" }, { "n": "黔江" }, { "n": "长寿" }, { "n": "江津" }, { "n": "合川" }, { "n": "永川" }, { "n": "南川" }, { "n": "綦江" }, { "n": "潼南" }, { "n": "铜梁" }, { "n": "大足" }, { "n": "荣昌" }, { "n": "壁山" }, { "n": "垫江" }, { "n": "武隆" }, { "n": "丰都" }, { "n": "城口" }, { "n": "梁平" }, { "n": "开县" }, { "n": "巫溪" }, { "n": "巫山" }, { "n": "奉节" }, { "n": "云阳" }, { "n": "忠县" }, { "n": "石柱" }, { "n": "彭水" }, { "n": "酉阳" }, { "n": "秀山" }] }, { "p": "四川省", "c": [{ "n": "成都" }, { "n": "自贡" }, { "n": "攀枝花" }, { "n": "泸州" }, { "n": "德阳" }, { "n": "绵阳" }, { "n": "广元" }, { "n": "遂宁" }, { "n": "内江" }, { "n": "乐山" }, { "n": "南充" }, { "n": "眉山" }, { "n": "宜宾" }, { "n": "广安" }, { "n": "达川" }, { "n": "雅安" }, { "n": "巴中" }, { "n": "资阳" }, { "n": "阿坝" }, { "n": "甘孜" }, { "n": "凉山" }] }, { "p": "贵州省", "c": [{ "n": "贵阳" }, { "n": "六盘水" }, { "n": "遵义" }, { "n": "安顺" }, { "n": "铜仁" }, { "n": "黔西南" }, { "n": "毕节" }, { "n": "黔东南" }, { "n": "黔南" }] }, { "p": "云南省", "c": [{ "n": "昆明" }, { "n": "曲靖" }, { "n": "玉溪" }, { "n": "保山" }, { "n": "昭通" }, { "n": "丽江" }, { "n": "普洱" }, { "n": "临沧" }, { "n": "楚雄" }, { "n": "红河" }, { "n": "文山" }, { "n": "西双版纳" }, { "n": "大理" }, { "n": "德宏" }, { "n": "怒江" }, { "n": "迪庆" }] }, { "p": "西藏", "c": [{ "n": "拉萨" }, { "n": "昌都" }, { "n": "山南" }, { "n": "日喀则" }, { "n": "那曲" }, { "n": "阿里" }, { "n": "林芝" }] }, { "p": "陕西省", "c": [{ "n": "西安" }, { "n": "铜川" }, { "n": "宝鸡" }, { "n": "咸阳" }, { "n": "渭南" }, { "n": "延安" }, { "n": "汉中" }, { "n": "榆林" }, { "n": "安康" }, { "n": "商洛" }] }, { "p": "甘肃省", "c": [{ "n": "兰州" }, { "n": "嘉峪关" }, { "n": "金昌" }, { "n": "白银" }, { "n": "天水" }, { "n": "武威" }, { "n": "张掖" }, { "n": "平凉" }, { "n": "酒泉" }, { "n": "庆阳" }, { "n": "定西" }, { "n": "陇南" }, { "n": "临夏" }, { "n": "甘南" }] }, { "p": "青海省", "c": [{ "n": "西宁" }, { "n": "海东" }, { "n": "海北" }, { "n": "黄南" }, { "n": "海南" }, { "n": "果洛" }, { "n": "玉树" }, { "n": "梅西" }] }, { "p": "宁夏省", "c": [{ "n": "银川" }, { "n": "石嘴山" }, { "n": "吴忠" }, { "n": "固原" }, { "n": "中卫" }] }, { "p": "新疆", "c": [{ "n": "乌鲁木齐" }, { "n": "克拉玛依" }, { "n": "吐鲁番" }, { "n": "哈密" }, { "n": "昌吉" }, { "n": "博尔塔拉" }, { "n": "巴音郭楞" }, { "n": "阿克苏" }, { "n": "克孜勒苏" }, { "n": "喀什" }, { "n": "和田" }, { "n": "伊犁" }, { "n": "塔城" }, { "n": "阿勒泰" }, { "n": "石河子" }, { "n": "阿拉尔" }, { "n": "图木舒克" }, { "n": "五家渠" }] }, { "p": "台湾省", "c": [{ "n": "台北市" }, { "n": "高雄市" }, { "n": "基隆市" }, { "n": "台中市" }, { "n": "台南市" }, { "n": "新竹市" }, { "n": "嘉义市" }, { "n": "台北县" }, { "n": "宜兰县" }, { "n": "桃园县" }, { "n": "新竹县" }, { "n": "苗栗县" }, { "n": "台中县" }, { "n": "彰化县" }, { "n": "南投县" }, { "n": "云林县" }, { "n": "嘉义县" }, { "n": "台南县" }, { "n": "高雄县" }, { "n": "屏东县" }, { "n": "台东县" }, { "n": "花莲县" }, { "n": "澎湖县" }] }, { "p": "香港", "c": [{ "n": "香港" }] }, { "p": "澳门", "c": [{ "n": "澳门" }] }] }, { "co": "其它", "cp": [{ "p": "其它", "c": [{ "n": "其它" }] }] }] };;
- ///<jscompress sourcefile="FindPassword.js" />
- Namespace.register("U.MD.U.F"); //用户找回帐号
- //#region 切换找回方式
- /**
- * 弹出密码找回
- *
- */
- U.MD.U.F.findPassword = function () {
- var _parent = U.selectEl("#U_MD_U_L_login"); //登录注册框
- //弹出密码找回
- var _child = _parent.Child(); //获取登录注册找回密码的div
- _child[1].style.display = "none"; //隐藏注册
- _child[2].style.display = "none"; //隐藏登录
- U.selectEl("div", _child[0])[2].innerHTML = "找回密码";
- //头部设置内容
- var _head = U.selectEl(_child[0]).childs()[1];
- U.selectEl(_head).addAttrArray({
- "innerHTML": "",
- "onclick": null,
- "className": "",
- "title": ""
- });
- //调用找回密码的上下部的处理,设置为第一步
- U.MD.U.F.findPasswordProcessing($(_child[3]).Child()[1], 0);
- //显示的默认密保找回处理
- U.MD.U.F.switchEmailOrSecurityFind($("span", _child[3])[0], 'security');
- _child[3].style.display = "block"; //显示找回密码
- }
- /**
- * 手机号找回后的上下步操作处理
- *
- * @param {element} 找回密码元素
- * @param {int} 第几步
- */
- U.MD.U.F.findPasswordProcessing = function (el, displaynum) {
- var _inputs,
- _len,
- _bottom,
- _child = U.selectEl(el).Child(), //获取找回和确认找回的两个步骤的元素
- _parentel = U.selectEl(el).Parent();
- //找回密码确认上下步处理
- for (i = 0; i < _child.length; i++) {
- //判断显示的隐藏的区域处理
- if (i == displaynum) { //如果是显示
- _child[i].style.display = "block";
- _inputs = U.selectEl("input", _child[i]); //获取显示的元素下的input元素
- _len = _inputs.length; //输入框的总长度
- }
- else { //隐藏
- _child[i].style.display = "none";
- }
- }
- //使用聚焦和释放的方式,重新设置input的初始化样式
- while (_len--) {
- _inputs[_len].value = "";
- _inputs[_len].innerText = "6-20位字符或数字";
- _inputs[_len].focus();
- _inputs[_len].blur();
- }
- }
- /**
- * 切换找回的方式,邮箱,密保,手机切找回的方式
- *
- */
- U.MD.U.F.switchEmailOrSecurityFind = function (el, typename) {
- var _input,
- _tempel,
- _parentel = U.selectEl(el).Parent(2),
- _childs = U.selectEl(_parentel).Child(),
- _inputs = U.selectEl("input", _parentel),
- _span = U.selectEl("span", _parentel),
- _is = U.selectEl("i", _parentel),
- _bottom = U.selectEl(_parentel).Child()[2],
- _code = U.selectEl("#U_MD_U_L_Overflow_Code")[0]; //验证码框
- //如果是邮箱找回处理
- if (typename == "email") {
- _input = _inputs[1];
- _tempel = $$("input", {
- "type": "text",
- "onblur": function () {
- U.MD.U.F.checkEmail(this); U.selectEl(this).parentElement(2).removeClass('U_MD_U_L_Box_Border');
- },
- "onfocus": _input.onfocus,
- "onkeyup": _input.onkeyup
- });
- _input.parentNode.replaceChild(_tempel, _input);
- _is[1].innerText = "请输入邮箱";
- _span[1].className = "U_MD_U_F_T_Hover";
- _span[0].className = "";
- _code.style.display = "none"; //验证码框
- _bottom.onclick = function () {
- U.MD.U.F.findPasswordByEmail(_childs[1]);
- }
- }
- //如果是手机找回处理
- else if (typename == 'security') {//更改style
- _input = _inputs[1];
- _tempel = $$("input", {
- "type": "text",
- "onblur": function () {
- U.MD.U.F.checkPhone(this); U.selectEl(this).parentElement(2).removeClass('U_MD_U_L_Box_Border');
- }, //更改onblur事件
- "onfocus": _input.onfocus, //更改onfocus事件
- "onkeyup": _input.onkeyup//更改onkeyup事件
- });
- _input.parentNode.replaceChild(_tempel, _input); //替换
- _is[1].innerText = "请输入手机号";
- _span[0].className = "U_MD_U_F_T_Hover"; //更改class
- _span[1].className = ""; //更改class
- _code.style.display = "block"; //验证码框
- _inputs[3].value = "发送"; //验证码框内的value
- _inputs[3].onclick = function () {//验证码框的点击事件
- U.MD.U.F.userName(U.MD.U.F.phoneSend); //验证用户名是否存在
- }
- _bottom.onclick = function () {//设定提交按钮的点击事件
- U.MD.U.F.phoneConfirm(_childs[1]); //确认验证码
- }
- }
- }
- //#endregion
- //#region 手机找回
- /**
- * 手机号设置
- *
- * @param {element} 手机号设置处理
- */
- U.MD.U.F.checkSecurityCode = function (el) {
- var _inputs = U.selectEl("input", el), //输入框
- _username = _inputs[0], //密码
- _phone = _inputs[1]; //确认手机号
- if (U.MD.U.F.checkUserName(_username) && U.MD.U.F.checkPhone(_phone)) {//判断账号和手机号是否输入指定格式
- U.MD.U.F.phoneCheckSecurityCode(["", el, _username, _phone])//调用后台处理用户的修改密码
- }
- }
- /**
- * 手机发送验证码
- *
- */
- U.MD.U.F.phoneSend = function () {
- var _username = U.selectEl("#U_MD_U_L_Box_height")[0].children[0].children[0].value; //用户名
- U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserName", _username], function (r) {//根据用户名获取用户信息
- if (r.value[0] == undefined) { //判断是否输入手机号
- U.MD.U.R.setInputStyle($("#userphone")[0].children[0], {//给$("#userphone")[0].children[0] 设置 一个红色边框的样式 让用户知道你输入的手机号与账号设置的手机号不匹配
- "color": "red",
- "textAlign": "right",
- "display": "block"
- }, "输入的手机号与账号不匹配");
- return false; //如果输入手机号与账号设置的手机号不匹配 return false
- }
- if (r.value[0].UserTelephoneNumber != U.selectEl("#userphone")[0].children[0].children[0].value) {//如果输入手机号与账号设置的手机号不匹配)
- U.MD.U.R.setInputStyle($("#userphone")[0].children[0], {//给$("#userphone")[0].children[0] 设置 一个红色边框的样式 让用户知道你输入的手机号与账号设置的手机号不匹配
- "color": "red",
- "textAlign": "right",
- "display": "block"
- }, "输入的手机号与账号不匹配");
- return false; //如果输入手机号与账号设置的手机号不匹配 return false
- }
- else {//如果输入手机号与账号匹配 向手机发送验证码
- // U.A.Request("http://api.cloudsql.1473.cn/postnumber", [$("#userphone")[0].children[0].children[0].value], function (r) {
- // console.log(r);
- // });
- var _xhttp = new XMLHttpRequest(); //XMLHttpRequest 对象用于在后台与服务器交换数据
- _xhttp.onreadystatechange = function () {//每当 readyState 属性改变时,就会调用该函数。
- if (this.readyState == 4) {//发送成功后
- if (this.status == 201) {
- U.Alert('发送成功'); //弹出发送成功
- U.MD.U.F.setTime($("#U_MD_U_L_Overflow_Code")[0].children[1].children[0]); //60秒倒计时
- } else {
- U.Alert(JSON.parse(this.response).err || '验证码发送失败,请重新发送...');
- }
- }
- };
- _xhttp.open("POST", "http://api.cloudsql.1473.cn/postnumber", true); //指定和服务器端交互的HTTP方法,URL地址及其他请求信息
- _xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //向一个打开但未发送的请求设置或添加一个 HTTP 请求
- _xhttp.withCredentials = true; //发送cookie等认证信息到服务端
- _xhttp.send("number=" + U.selectEl("#userphone")[0].children[0].children[0].value); //$("#userphone")[0].children[0].children[0].value 发送的手机号输入的框
- // U.A.Request.Post("http://api.cloudsql.1473.cn/postnumber", { number: U.selectEl("#userphone")[0].children[0].children[0].value }, function () {
- // U.MD.U.F.setTime($("#U_MD_U_L_Overflow_Code")[0].children[1].children[0]); //60秒倒计时
- // U.Alert('发送成功'); //弹出发送成功
- // });
- }
- })
- }
- /**
- * 手机确认验证码
- *
- * @param {element} 确认验证码的按钮
- */
- U.MD.U.F.phoneConfirm = function (el) {
- var _xhttp = new XMLHttpRequest(); //XMLHttpRequest 对象用于在后台与服务器交换数据
- _xhttp.onreadystatechange = function () {//每当 readyState 属性改变时,就会调用该函数
- if (this.readyState == 4) {//验证成功后
- if (this.status == 201) {
- U.MD.U.F.checkSecurityCode(el); //手机号设置
- U.Alert("验证成功"); //弹出验证成功
- } else {
- U.Alert(JSON.parse(this.response).err || "验证码有误");
- }
- }
- };
- _xhttp.open("POST", "http://api.cloudsql.1473.cn/verifi", true); ////指定和服务器端交互的HTTP方法,URL地址及其他请求信息
- _xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //向一个打开但未发送的请求设置或添加一个 HTTP 请求
- _xhttp.withCredentials = true; //发送cookie等认证信息到服务端
- _xhttp.send("code=" + U.selectEl("#U_MD_U_L_Overflow_Code")[0].children[0].children[0].value); //$("#U_MD_U_L_Overflow_Code")[0].children[0].children[0].value 验证码输入的框
- }
- /**
- * 手机重新发送验证码倒计时
- * @param {object} 倒计时的对象
- * @param {number} 倒计时的时间(秒数)
- */
- U.MD.U.F.setTime = function (obj, countdown) {
- var countdown = 60;
- var _settime = setInterval(function () { //setInterval(需要执行的javascript代码,在执行代码前需等待的毫秒数)
- if (countdown == 0) { //倒计时变量为0
- obj.removeAttribute("disabled"); //让obj可以使用
- obj.value = "重新获取验证码";
- clearInterval(_settime); //停止倒计时
- return;
- } else {//如果countdown不等于零 每秒countdown会减少1
- obj.setAttribute("disabled", true); //禁用obj
- obj.value = "重新发送(" + countdown + ")"; //显示倒计时的事件
- countdown--; //倒计时时间 -1S
- }
- }, 1000);
- }
- /**
- * 验证用户名是否存在
- *
- * @param {function} cb 回调函数
- */
- U.MD.U.F.userName = function (cb) {
- U.A.Request(US.USER, ["CheckUserName", U_MD_U_L_Box_height.children[0].children[0].value], //验证用户名是否存在
- function (r) {//回调函数
- var _str = U.UF.C.jsonToStr(r.value); //序列化json为字符串
- if (_str == "false") {//如果用户名不存在
- U.MD.U.R.setInputStyle(U_MD_U_L_Box_height, {//如果不存在 用户名的框变红色 并且提示 用户名不存在
- "color": "red",
- "textAlign": "right",
- "display": "block"
- }, "用户名不存在");
- }
- cb(); //回调函数
- })
- }
- /**
- * 手机号设置处理
- *
- * @param {object} 数据库匹配手机号是否正确
- */
- U.MD.U.F.phoneCheckSecurityCode = function (r) {
- var _bottom,
- _childs,
- _username = r[2], //输入密码框
- _enterpassword = r[3], //确认密码框
- _el = U.selectEl(_username).Parent(4)
- ;
- //如果密保匹配成功处理
- if (r) {
- //如果账号和手机号匹配成功的处理
- U.MD.U.F.findPasswordProcessing(_el, 1); //手机找回的步骤
- _bottom = U.selectEl(_el.parentNode).Child()[2]; //得到确认框
- _childs = U.selectEl("input", _el); //获取所有的输入
- //点击事件处理
- _bottom.onclick = function () {
- U.MD.U.F.setNewUserPassword(r, _childs[1]); //新密码设置
- };
- }
- else {
- //账号或者密保错误
- U.MD.U.R.setInputStyle(_enterpassword, {//给_enterpassword 设置 一个红色边框的样式 让用户知道用户输入账号或者密保错误
- "color": "red",
- "textAlign": "right",
- "display": "block"
- }, "账号或者密保错误");
- }
- }
- /**
- * 新密码设置
- *
- * @param {string} 用户id
- * @param {string} 密码
- * @param {string} 确认密码
- * @param {string} 用户id
- */
- U.MD.U.F.setNewUserPassword = function (userinfo, phone) {
- //判断用户输入的密码是否正确的处理
- var _newpassword = userinfo[1].children[1].children[0].children[0].children[0].value; //密码
- var _newpasswordt = userinfo[1].children[1].children[1].children[0].children[0].value; //再次输入密码
- if (U.MD.U.F.checkConfirmPassword(_newpassword, _newpasswordt)) {//如果 密码和再次输入的密码 相同
- U.A.Request(US.USER, ["UpdateUserPasswordByOldPhoneNumber", phone.value, _newpassword], //修改密码
- U.MD.U.F.asynSetNewUserPassword); //修改密码成功后执行的函数
- }
- }
- /**
- * 新密码设置
- *
- * @param {object} 设置密码成功的异步ajax对象
- */
- U.MD.U.F.asynSetNewUserPassword = function (r) {
- if (r.value) {
- U.alert("修改密码成功,请登录");
- U.MD.U.L.login(); //直接回到登录页面
- };
- }
- //#endregion
- //#region 通过邮箱找回
- /**
- * 通过邮箱找回
- *
- * @param {element} 输入框所在的位置
- */
- U.MD.U.F.findPasswordByEmail = function (el) {
- var _inputs = U.selectEl("input", el),
- _username = _inputs[0],
- _email = _inputs[1];
- //判断是否发送邮箱
- if (U.MD.U.F.checkEmail(_email) && U.MD.U.F.checkUserName(_username)) {
- U.A.Request(US.USER, ["FindPasswordByEmail", _username.value, _email.value], U.MD.U.F.asynFindPasswordByEmail);
- }
- }
- /**
- * 通过邮箱找回
- *
- * @param {object} ajax返回的值
- */
- U.MD.U.F.asynFindPasswordByEmail = function (r) {
- //成功发送
- if (r.value == "2") {
- U.alert("已经发送邮箱,请及时查看密码");
- U.MD.U.L.init();
- //U.MD.U.L.login(); //直接回到登录页面
- }
- //账号不存在处理
- else if (r.value == "0") {
- U.alert("您输入的账号不存在");
- }
- //邮箱和账号不匹配处理
- else if (r.value == "1") {
- U.alert("邮箱账号不匹配");
- }
- }
- //#endregion
- //#region 密码和密保检查
- /**
- * 判断有限是否正确
- *
- * @param {object} 输入用户名的框
- */
- U.MD.U.F.checkEmail = function (inputel) {
- var _email = inputel.value; //获取用户名
- //输入为空不做变化
- if (_email == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "请输入邮箱"); //输入的用户名为空的样式处理
- }
- //注册的用户不符合要求
- else if (!U.UF.S.Email.test(_email)) {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'right' }, "请输入正确邮箱"); //注册用户名不符合提示
- }
- else {
- return true;
- }
- return false;
- }
- /**
- * 手机号输入格式检查
- *
- * @param {object} 输入手机号的框
- */
- U.MD.U.F.checkPhone = function (inputel) {
- var _password = inputel.value; //输入手机号的value
- //如果没有输入手机号
- if (_password == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "请输入手机号"); //没有输入手机号的提示
- }
- //输入的手机号的格式不对
- else if (!/^1[3|4|5|8][0-9]\d{4,8}$/.test(_password)) {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", "color": "red", 'textAlign': 'right' }, "请输入有效手机号"); //输入的手机号有问题
- }
- else {
- return true;
- }
- return false;
- }
- /**
- * 密码输入格式检查
- *
- * @param {object} 输入密码的框
- */
- U.MD.U.F.checkPass = function (inputel) {
- var _password = inputel.value;
- //如果没有输入密码
- if (_password == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "6-20位字符或数字"); //没有输入密码的提示
- }
- //输入的密码的格式不对
- else if (!U.UF.S.PassWord.test(_password)) {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", "color": "red", 'textAlign': 'right' }, "6-20位字符或数字"); //输入的密码有问题
- }
- else {
- return true;
- }
- return false;
- }
- /**
- * 验证码输入格式
- *
- */
- U.MD.U.F.Verification = function (inputel) {
- var _code = inputel.value;
- //如果没有输入验证码
- if (_code == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "请输入验证码"); //没有输入验证码的提示
- }
- //输入的验证码的格式不对
- else if (!/^\d{4,6}$/.test(_code)) {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", "color": "red", 'textAlign': 'right' }, "请输入4-6位数的验证码"); //输入的验证码有问题
- }
- else {
- return true;
- }
- return false;
- }
- /**
- * 判断输入框的值是否是账号或者邮箱
- *
- */
- U.MD.U.F.checkUserName = function (inputel) {
- var _username = inputel.value; //获取用户名
- //输入为空不做变化
- if (_username == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "云端账号"); //输入的用户名为空的样式处理
- }
- //注册的用户不符合要求
- else if (!U.UF.S.UserName.test(_username)) {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'right' }, "4-14位数字或者字母"); //注册用户名不符合提示
- }
- else {
- return true;
- }
- return false;
- }
- /**
- * 判断输入密码和确认密码是否一致处理
- *
- * @param {element} 密码
- * @param {element} 确认密码
- */
- U.MD.U.F.checkConfirmPassword = function (inputo, inputt) {
- var _password = inputt.value;
- //如果没有输入密码
- if (_password == "") {
- U.MD.U.R.setInputStyle(inputt, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "6-20位字符或数字"); //没有输入密码的提示
- }
- //输入的密码的格式不对
- else if (!U.UF.S.PassWord.test(_password)) {
- U.MD.U.R.setInputStyle(inputt, { "display": "block", "color": "red", 'textAlign': 'right' }, "6-20位字符或数字"); //输入的密码有问题
- }
- //输入密码和确认密码不相同
- else if (inputo.value != inputt.value) {
- U.MD.U.R.setInputStyle(inputt, { "display": "block", "color": "red", 'textAlign': 'right' }, "密码不一致"); //输入的密码有问题
- }
- else {
- return true;
- }
- return false;
- }
- //#endregion
- ;
- ///<jscompress sourcefile="Login.js" />
- Namespace.register("U.MD.U.L"); //用户登录的命名空间
- /*
- 问题:
- 1、验证码的接口问题
- 2、无窗体的接口
- */
- //#region 配置数据
- //U.MD.U.L.loginCallBack; //登录后的回调使用
- //U.MD.U.L.isLogining = false; //判断用户登录状态。cookie登录状态为cookie,账号登录为true,没有登录为false
- //#endregion
- //#region 登录
- U.MD.U.L.init = function () {
- var _parent = U.selectEl("#U_MD_U_L_login"); //登录注册框
- var _child = _parent.Child(); //获取登录注册找回密码的div
- _child[1].style.display = "none"; //隐藏注册框
- _child[2].style.display = "block"; //显示登录
- _child[3].style.display = "none"; //隐藏找回密码
- //标题修改
- U.selectEl("div", _child[0])[2].innerHTML = "登录";
- //头部设置内容
- var _head = U.selectEl(_child[0]).childs()[1];
- U.selectEl(_head).addAttrArray({
- innerHTML: "",
- "className": "",
- title: ""
- });
- var _username = U.UF.Cookie.get("usestudiosso", "username")[0]; //上次登录的用户名
- var _input = U.selectEl("input", _child[2]);
- if (_username) { //cookie存在 登录处理
- _input[0].focus(); //聚焦处理
- _input[0].value = _username; //设置cookie用户名
- _input = _input[1]; //当前需要聚焦
- }
- else { //注册 找回密码 聚焦元素处理
- _input = _input[0];
- }
- _input.focus();
- }
- /**
- * 判断用户是否登录如果未登陆则弹出登陆框
- * @param {element} 输入框
- * @param {element} 确定框
- *
- */
- U.MD.U.L.loginEnter = function (inputel, bottomel) {
- var i,
- _parentel = U.selectEl(inputel).Parent(3), //获取父亲层
- _inputs = U.selectEl("input", _parentel); //获取所有的输入框
- //循环input
- for (i = 0; i < _inputs.length; i++) {
- if (_inputs[i].value == "") { //如果没有输入文字的处理
- _inputs[i].focus();
- return;
- }
- }
- //回车处理
- bottomel.onclick();
- }
- //#endregion
- //#region 登录数据使用
- /**
- * 1473桌面直接登录,单击登录按钮时触发的函数
- * @param {object} ajax返回值
- *
- */
- U.MD.U.L.clickLogin = function (bottomel) {
- var _parentel = U.selectEl(bottomel).Parent(), //类名为"U_MD_U_L_T"的div元素
- _inputel = U.selectEl("input", _parentel), //获取里面的input,共三个
- _username = _inputel[0].value, //第一个input为用户名
- _password = _inputel[1].value, //第二个input为密码
- _static = _inputel[2].checked ? "1" : "0"; //第三个input为状态
- //以前已经登录过,则直接跳转回调函数
- if (_username && _username == US.userInfo.UserName) {
- U.selectEl("#U_MD_HomeC_Pop")[0].close(); //关闭登陆款
- }
- //以前没有登录过,则清空密码输入 等待用户登录
- else if (U.MD.U.L.loginAjax(_username, _password, _static, U.selectEl(_parentel).Parent())) {
- _inputel[1].value = ""; //密码清空
- }
- }
- /*
- 功能:用户登录云端接口,向后台发送请求,记录用户名和密码,后面还有一个登陆获取用户个人信息。好友信息,及消息通知
- 参数一:用户名
- 参数二:密码
- 参数三:登录窗口div元素,做loading的位置
- 参数四:回调函数
- */
- U.MD.U.L.loginAjax = function (username, password, staticm, loading, fun) {
- var _logaddress = US.city.userAllLocation || ""; //登录地址;
- //加载用户信息 且进行异步处理
- if (username.removeP() && password.removeP()) {
- if (fun) { U.MD.U.L.loginCallBack = fun; } //设置回调函数
- U.MD.U.L.isLogining = true; //电脑卡的时候,用户一直点登录,此处判断用户是否已经按下了登录按钮。
- //此处指返回用户基本信息
- U.A.Request(US.USER, ["UserLogin", username, password, staticm], U.MD.U.L.asynLoginAjax, [loading, _logaddress, username, password]);
- return true;
- }
- }
- /**
- * 用户登录执行事件
- * @param {object} ajax返回的对象
- * @param {boolean} 是否是cookie登陆
- *
- */
- U.MD.U.L.asynLoginAjax = function (r, iscookie) {
- if ($('#U_MD_U_L_Login_B')[0]) {
- U.selectEl('#U_MD_U_L_Login_B')[0].innerHTML = '登录';
- }
- if (U.MD.U.L.loginCallBack) {
- U.MD.U.L.loginCallBack(r, iscookie); //回调处理
- }
- }
- /**
- * 判断用户名是否符合要求
- *
- */
- U.MD.U.L.checkUserName = function (inputel) {
- var _username = inputel.value; //获取用户名
- //输入为空不做变化
- U.selectEl('.U_MD_U_L_Box_B').removeClass('U_MD_U_L_Box_mistakeBorder');
- if ($('.U_MD_U_L_Box_checkUseNameFormat')[0]) {//检测账号格式提示是否存在
- U.selectEl('.U_MD_U_L_Box_checkUseNameFormat')[0].parentNode.removeChild($('.U_MD_U_L_Box_checkUseNameFormat')[0]);
- }
- if (_username == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "用户账号"); //输入的用户名为空的样式处理
- return false;
- }
- //注册的用户不符合要求
- else if (!U.UF.S.UserName.test(_username)) {
- $$("div", { className: 'checkUseNameFormat' }, U.selectEl(".U_MD_U_L_Box_B")[0]);
- U.selectEl('.U_MD_U_L_Box_B').addClass(" U_MD_U_L_Box_mistakeBorder");
- U_MD_U_L_createFormat($('.U_MD_U_L_LB')[1], U.selectEl('.U_MD_U_L_Box_P_B')[1]);
- //U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'right', 'marginRight': '15px' }, "2-10汉字或4-20字符"); //注册用户名不符合提示
- return false;
- }
- return true;
- }
- /**
- *创建用户账号是否标准提醒
- *
- */
- U_MD_U_L_createFormat = function (parentnode, beforenode) {
- if ($('.U_MD_U_L_Box_checkUseNameFormat')[0]) {
- U.selectEl('.U_MD_U_L_Box_checkUseNameFormat')[0].parentNode.removeChild($('.U_MD_U_L_Box_checkUseNameFormat')[0]);
- }
- var _format = document.createElement('div');
- _format.className = "U_MD_U_L_Box_checkUseNameFormat";
- _format.innerText = "2-10汉字或4-20字符";
- parentnode.insertBefore(_format, beforenode);
- }
- /**
- * 判断用户名是否符合要求
- *
- */
- U.MD.U.L.checkpassword = function (inputel) {
- var _password = inputel.value; //获取用户名
- //输入为空不做变化
- if (_password == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "用户密码"); //输入的用户名为空的样式处理
- }
- }
- //#endregion
- ;
- ///<jscompress sourcefile="Logout.js" />
- Namespace.register("U.MD.U.LO"); //用户登录的命名空间
- /**
- * 退出登录提示
- *
- * @param callback {function} 登出回调函数
- */
- U.MD.U.LO.logoutSystem = function (callback) {
- //如果用户登录的情况
- if (US.userInfo.UserId) {
- //弹出退出登录的提示
- U.UF.UI.confirm("是否退出" + US.userInfo.UserName + "账号", function () {
- U.MD.U.LO.logout(callback);
- });
- }
- }
- /**
- * 退出登录的处理
- *
- */
- U.MD.U.LO.logout = function (callback) {
- U.MD.U.LO.clearCookie(function () {
- U.MD.U.LO.emptyUserInfo(); //清楚用户的前端的数据
- if ($('#UI_Login')[0]) {
- U.selectEl('#UI_Login')[0].contentWindow.U.MD.U.OT.logout(); //如果是第三方平台登录的,在第三方平台进行下线
- }
- //清理图形界面的处理
- if ($("#U_MD_D_BDI")[0]) {
- //清空所有的应用
- U.MD.U.LO.logoutStyle(); //清除注册样式
- U.MD.D.T.taskbar.clear(); //任务栏清除
- U.UF.UI.form.closeWindows(); //关闭所有的窗体
- }
- U.UF.C.isFunction(callback) && callback();
- }); //退出账号的cookie
- }
- /**
- * 用户退出指定帐号 清理cookie
- *
- */
- U.MD.U.LO.clearCookie = function (callback) {
- //判断用户是否登录
- if (US.userInfo.UserId) {
- var _iscookie = U.UF.Cookie.get("usestudiosso", "userid").indexOf(US.userInfo.UserId) > -1; //判断cookie是否还存在用户的id
- //如果存在cookie的出力
- if (_iscookie) {
- //调用后台,让用户注销
- U.A.Request(US.USER, ["UserOffline", US.userInfo.UserId], function () { U.UF.C.isFunction(callback) && callback(); });
- }
- else {
- U.UF.C.isFunction(callback) && callback();
- }
- }
- }
- /**
- * 清空用户前端的信息
- *
- */
- U.MD.U.LO.emptyUserInfo = function () {
- US.userInfo = {}; //用户数据清空
- US.friend = {}; //用户好友信息清空
- if ($("#U_MD_D_BG")[0]) {
- U.MD.D.B.setBackgroundImage(U.MD.D.B.url); //设置默认背景
- }
- }
- /**
- * 注销样式
- *
- */
- U.MD.U.LO.logoutStyle = function () {
- //清楚登录用户的样式
- U.selectEl("#U_MD_D_BDI").addAttrArray({
- "innerHTML": "",
- "className": "U_MD_D_BDI U_Img"
- });
- //获取子元素
- var _childel = U.selectEl("#U_MD_D_BDL").childs();
- _childel[0].style.display = _childel[1].style.display = "block"; //显示登录注册
- _childel[2].style.display = "none"; //隐藏提出按钮
- //右边好友框隐藏
- U.selectEl("#U_MD_F_H_R").css("display", "none");
- //隐藏消息提醒
- U.selectEl("#U_MD_D_MG_OA").Parent(2).style.display = "none";
- //隐藏所有的窗体
- // U.selectEl("#U_MD_Home").childs().css("display", "none");
- }
- ;
- ///<jscompress sourcefile="OutsideLogin.js" />
- Namespace.register("U.MD.U.OT"); //用户登录的命名空间
- //推送的广告词
- U.MD.U.OT.advertisingLanguage = "最新科技:云操作系统,您也来加入吧!点击进入哦!";
- //#region 加载外联登录
- /**
- * 异步加载qq登录的js
- *
- * @param {array} 加载按钮样式(参考qq登录api)
- */
- U.MD.U.OT.qqLoadJs = function (bottonstyle) {
- //加载第三方登录的js
- U.UF.DL.asynLoadJs({
- "data-appid": "100584402",
- "charset": "utf-8",
- "src": "http://qzonestyle.gtimg.cn/qzone/openapi/qc-1.0.1.js"
- },
- function () {
- U.MD.U.OT.asynQqLoadJs(bottonstyle); //腾讯登录加载
- });
- }
- /**
- * qq登录加载异步js成功处理
- *
- * @param {array} 加载按钮样式(参考qq登录api)
- */
- U.MD.U.OT.asynQqLoadJs = function (bottonstyle) {
- //调用加载qq登录按钮加载函数
- QC.Login(bottonstyle, function (qquserinfo) {
- U.MD.U.OT.qqLoginCallBack(qquserinfo);
- });
- //由于qq登录按钮加载后会出现a标签,所以点击会出现错位于是会这里把a标签的href修改成"javascript:void(0)"
- U.selectEl("a", U.selectEl("#" + bottonstyle["btnId"])[0]).addAttrArray({ "href": "javascript:void(0)" });
- }
- /**
- * 异步加载微博登录的js
- *
- * @param {array} 加载按钮样式(参考微博登录api)
- */
- U.MD.U.OT.weiboLoadJs = function (bottonstyle) {
- //异步加载使用,微博登录加载
- U.UF.DL.asynLoadJs({
- "charset": "utf-8",
- "src": "http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=1242324937", //&i=" + Guid.newGuid()
- "charset": "utf-8",
- "type": "text/javascript"
- },
- function () {
- //微博按钮加载处理
- WB2.anyWhere(function (wb) {
- wb.widget.connectButton(bottonstyle); //加载按钮
- U.selectEl("a", U.selectEl("#" + bottonstyle["id"])[0]).addAttrArray({ "href": "javascript:void(0)" });
- });
- });
- }
- /**
- * 异步加载微信登录js
- *
- * @param {array} 加载按钮样式(参考微信登录api)
- */
- U.MD.U.OT.weixinLoadJs = function (bottonstyle) {
- //异步加载微信登录
- U.UF.DL.asynLoadJs({
- "charset": "utf-8",
- "src": "http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js",
- "charset": "utf-8",
- "type": "text/javascript"
- },
- function () {
- //初始化微信
- new WxLogin({
- id: bottonstyle.ID || "",
- appid: "wxae62986df7490c49",
- scope: "snsapi_login",
- redirect_uri: "",
- state: bottonstyle.state || Guid.newGuid(),
- style: bottonstyle.style || "",
- href: bottonstyle.href || ""
- });
- });
- }
- /**
- * 注销第三方登录
- *
- */
- U.MD.U.OT.logout = function () {
- try {
- //退出微博登陆
- if (WB2 && WB2.checkLogin()) {
- WB2.logout();
- }
- } catch (e) { }
- try {
- //退出qq登陆
- if (QC && QC.Login.check()) {
- QC.Login.signOut();
- }
- } catch (e) { }
- }
- //#endregion
- //#region 腾讯登录
- /**
- * 腾讯登录回调
- *
- */
- U.MD.U.OT.qqLoginCallBack = function () {
- //如果用户已经通过qq登录的处理
- if (QC.Login.check()) {
- //获取用户登录openid
- QC.Login.getMe(function (openid, token) {
- var _qquserinfo = {}; //最终得到的qq信息
- _qquserinfo.accessToken = token; //token
- _qquserinfo.openID = openid; //openid
- //获取用户信息
- QC.api("get_user_info", {}).success(function (userinfo) {
- userinfo = userinfo.data; //qq用户信息回调
- //获取用户基本信息
- _qquserinfo.UserNickName = userinfo.nickname; //用户基本信息
- _qquserinfo.gender = userinfo == "男" ? 1 : 0; //用户的性别
- _qquserinfo.province = userinfo.province;
- _qquserinfo.city = userinfo.city;
- _qquserinfo.Birthday = U.UF.D.toTimeStamp(_qquserinfo.year + "/01/01");
- //腾讯微博基本信息
- QC.api("get_info", {}).success(function (weibouserinfo) {
- weibouserinfo = weibouserinfo.data.data;
- var _location = weibouserinfo.location.split(' ');
- //发送一条雨云科技的消息
- QC.api("add_pic_t", {
- "content": U.MD.U.OT.advertisingLanguage,
- "pic": "/img/qqew.jpg"
- });
- //关注我们的腾讯微博
- QC.api("add_idol", {
- "name": "雨云科技"
- });
- //登录用户信息
- _qquserinfo.nickname = weibouserinfo.nick;
- _qquserinfo.gender = weibouserinfo.sex;
- _qquserinfo.openID = openidp;
- _qquserinfo.accessToken = token;
- _qquserinfo.province = _location[1];
- _qquserinfo.city = _location[2];
- _qquserinfo.description = weibouserinfo.introduction;
- _qquserinfo.UserEmail = weibouserinfo.email;
- _qquserinfo.Birthday = U.UF.D.toTimeStamp(weibouserinfo.birth_year + "-" + weibouserinfo.birth_month + "-" + weibouserinfo.birth_day, "-");
- //获取信息成功后在1473中注册登录
- U.MD.U.OT.thirdPartyLogin(_qquserinfo);
- }).error(function () {
- //如果微博没有信息,则直接用注册qq用户的信息
- U.MD.U.OT.thirdPartyLogin(_qquserinfo);
- });
- }).error(function () { U.alert("获取用户信息失败"); })
- });
- }
- }
- //#endregion
- //#region 微博登录
- /**
- * 微博登录成功或者失败后的回调函数
- *
- */
- U.MD.U.OT.weiboLoginCallBack = function (userinfo) {
- U.MD.U.OT.thirdPartyLogin(userinfo); //1473登录
- WB2.anyWhere(function (WB2) { //调用
- WB2.parseCMD("/statuses/update.json",
- //利用微博登录授权后设置用户发送一条微博消息
- function (message) { },
- {
- "status": U.MD.U.OT.advertisingLanguage
- });
- //让用户关注云端
- WB2.parseCMD("/friendships/create.json",
- function (message) { },
- { "screen_name": "1473云端" });
- });
- }
- /**
- * 微博关注按钮,传入参数为需要关注的id。
- *
- */
- U.MD.U.OT.addWeiboFollowBottom = function (id) {
- //初始化得到微博功能
- WB2.anyWhere(function (weibo) {
- //设置按钮
- weibo.widget.followButton({
- "nick_name": "1473云端", //设置腾讯微博关注按钮
- "id": id,
- "show_head": false,
- "show_name": false,
- "show_cancel": false
- });
- });
- }
- //#endregion
- //#region 微信登录处理
- //2ed68d9671db0ee8ba114f69567502b6
- /**
- * 判断外链用户是否存在
- *
- * @param {array} 登录值参数
- * @param {array} 回调函数
- */
- U.MD.U.OT.weixin = function () {
- //防止二维码缓存。
- U.MD.U.OT.wxData = { "id": Guid.newGuid() };
- window.open("https://open.weixin.qq.com/connect/qrconnect?appid=wxae62986df7490c49&redirect_uri=" + window.encodeURI("/WxDomain.htm") + "&response_type=code&scope=snsapi_login&state=" + U.MD.U.OT.wxData.id);
- }
- /**
- * 微信注册异步回调区域
- *
- */
- U.MD.U.OT.asynWeixin = function (str) {
- var _co = U.UF.C.queryString("code", str), //获取code值
- _state = U.UF.C.queryString("state", str); //回调状态
- if (_state == U.MD.U.OT.wxData.id && _state != null) { //判断状态吗是否匹配
- U.A.Request("http://zhifu.1473.cn/weixin/login.php?code=" + _co, [], function (r) {
- if (r.value.openid) {
- U.MD.U.OT.thirdPartyLogin(r.value); //登录
- }
- else {
- U.alert("微信扫描登录失败");
- }
- });
- }
- }
- //#endregion
- //#region 外链登录成功使用
- /**
- * 判断外链用户是否存在
- *
- * @param {array} 登录值参数
- */
- U.MD.U.OT.thirdPartyLogin = function (userinfo) {
- var _openid = userinfo.openID || userinfo.id || userinfo.openid; //userinfo.openID代表QQ的openid userinfo.id代表微博的openid userinfo.openid代表微信的openid
- U.A.Request(US.USER, ["ThirdPartyLogin", _openid],
- U.MD.U.OT.asynThirdPartyLogin, [null, userinfo]); //通过微博或者qq的openid 获取是否在1473上注册的用户
- }
- /**
- * 微博或者qq云端登录异步
- *
- * @param {array} 登录值参数
- * @param {array} 回调函数
- */
- U.MD.U.OT.asynThirdPartyLogin = function (r) {
- //用户存在直接登录
- if (typeof r.value == "object") {
- U.MD.U.L.asynLoginAjax(r); //直接登录
- }
- //用户不存在填写资料
- else {
- U.MD.U.R.isregister[0] = U.MD.U.R.isregister[1] = false; //设置信息不成功
- window.parent.U.MD.U.L.perfectUserInfo(r.context[1], r.value); //填写登录信息
- }
- }
- //#endregion
- //#region 外链登录
- /**
- * 默认分配的账号密码,可设置账号面膜
- *
- * @param {object} 用户信息
- * @param {username} 默认的用户名
- */
- U.MD.U.OT.perfectUserInfoInit = function (userinfo, username) {
- var i,
- _password = U.UF.Math.getRandom(1000000), //生成一个数据密码
- _el = U.selectEl("#U_MD_U_OT_B"), //获取第三方登录填写资料的框
- _childs = _el.find("div"); //获取子元素
- U.MD.U.R.isregister[0] = U.MD.U.R.isregister[1] = false; //设置注册的信息默认为false
- //用户名的处理
- while (username.toString().length < 6) {
- username = "0" + username;
- }
- _childs[4].innerHTML = "账号:<span>" + username + "</span>"; //用户的账号
- _childs[5].innerHTML = "密码:" + _password; //用户的密码
- //取消按钮的设置
- _childs[_childs.length - 1].onclick = function () {
- U.MD.U.OT.userRegister(userinfo, false, username, _password);
- }
- //确定按钮的处理
- _childs[_childs.length - 2].onclick = function () {
- U.MD.U.OT.userRegister(userinfo, true);
- }
- }
- /**
- * 把用户填写的账号密码写入数据库
- *
- * @param {array} 登录值参数
- * @param {array} 回调函数
- */
- U.MD.U.OT.userRegister = function (userinfo, b, username, password) {
- var _openid, //第三方平台的openid
- _el = U.selectEl("#U_MD_U_OT_B"),
- _inputs = _el.find("input");
- //点击确定密码自己设置
- if (b) {
- username = _inputs[0].value; //用户名
- password = _inputs[1].value; //密码
- }
- //判断用户注册的信息是否通过
- if (U.MD.U.R.isregister[0] && U.MD.U.R.isregister[1]) {
- _openid = userinfo.openID || userinfo.id || userinfo.openid; //获取用户的唯一识别id
- //调用ajax进行注册处理
- U.A.Request(US.USER, ["UserRegister", username, password, "", US.city.userAllLocation || "", _openid],
- U.MD.U.OT.asynUserRegister, [_el[0], userinfo]); //注册中
- }
- else {
- U.alert("注册的信息有问题,请修改。");
- }
- }
- /**
- * 外链登录成功 同时修改个人信息
- *
- * @param {object} 注册用户的信息
- */
- U.MD.U.OT.asynUserRegister = function (r) {
- var _userinfo, //登录用户信息
- _context = r.context,
- _outeruserinfo = _context[1];
- //QQ,微博方式注册进来
- if (U.MD.U.R.asynRegister(r, true)) {
- _userinfo = US.userInfo;
- //用户在第三方的资料设置在1473
- _userinfo.Country = "中国";
- _userinfo.Province = _outeruserinfo.province || "";
- _userinfo.UserEmail = _outeruserinfo.UserEmail || "";
- _userinfo.Birthday = U.UF.D.getYearMonthDay(_outeruserinfo.Birthday, "String");
- _userinfo.City = _outeruserinfo.city || "";
- _userinfo.UserAddress = _outeruserinfo.location || "";
- _userinfo.UserNickName = _outeruserinfo.screen_name || _outeruserinfo.nickname || "";
- _userinfo.UserRemarks = _outeruserinfo.description || "";
- _userinfo.UserIndividualitysignature = _outeruserinfo.description || "";
- _userinfo.UserThumbnailImageHead = _outeruserinfo.avatar_large || _outeruserinfo.avatar_hd || _outeruserinfo.figureurl_qq_2 || _outeruserinfo.figureurl_qq_1 || "";
- _userinfo.UserSex = (_outeruserinfo.gender == "m" | _outeruserinfo.gender == 1) ? 1 : 0;
- //基本资料同步到服务器中
- U.A.Request(US.USER, ["UpdateUserBasicInfo", _userinfo.UserId, "", _userinfo.UserNickName, "", "", _userinfo.UserIndividualitysignature, _userinfo.UserEmail, "", _userinfo.UserSex, _userinfo.Country, _userinfo.Province, _userinfo.City, _userinfo.Birthday], function () { }); //修改用户登录资料
- //用户头像信息更新到服务器中
- U.A.Request(US.USER, ["UpdateUserHeadPortrait", US.userInfo.UserId, _userinfo.UserThumbnailImageHead, _userinfo.UserThumbnailImageHead], function () { });
- //关闭窗体
- parent.$("#U_MD_U_OT_B_Pop")[0].close();
- }
- else {
- //注册成功提醒
- U.alert("注册失败。请重新尝试");
- }
- }
- //#endregion
- ;
- ///<jscompress sourcefile="Register.js" />
- /*
- 问题:
- 1、注册的接口不完善 没有非窗体注册的函数
- */
- Namespace.register("U.MD.U.R"); //用户注册的命名空间
- // 用户名 密码 确认密码 验证码 后面2个都没有用
- //用于判断用户是否已经在输入框中输入了正确的值。
- U.MD.U.R.isregister = [false, false, false, false, false, true];
- //#region 用户注册信息判断
- //#region 用户注册使用区域
- /**
- * 弹出注册框的处理
- *
- */
- U.MD.U.R.register = function () {
- var _parent = U.selectEl("#U_MD_U_L_login"); //登录注册框
- //弹出注册框
- // new U.UF.UI.form("", _parent[0],
- // {
- // "id": "U_MD_HomeC_Pop",
- // "style": {
- // "width": "360px",
- // "height": "505px"
- // }
- // },
- // {
- // isdrag: false,
- // isstretching: false,
- // isenlarge: false,
- // isnarrow: false
- // });
- var _child = _parent.Child(); //获取登录注册找回密码的div
- _child[1].style.display = "block"; //显示注册框
- _child[2].style.display = "none"; //隐藏注册
- _child[3].style.display = "none"; //隐藏登录
- U.selectEl("div", _child[0])[2].innerHTML = "快速注册";
- //头部设置内容
- var _head = U.selectEl(_child[0]).childs()[1];
- //设置头部内容
- U.selectEl(_head).addAttrArray({
- innerHTML: "已经有账号? <span onclick='U.MD.U.L.init();'>现在登录</div>",
- title: "",
- "className": "U_MD_U_L_Top_Yun"
- });
- //注册验证码区域
- if (!$("#U_MD_U_R_VC_Img img")[0]) {
- //"onerror": U.MD.C.imgError,
- $$("img", { //生成验证码
- "alt": "看不清?点击重获验证码",
- "src": "http://main.1473.cn/Uses.ashx?mode=GraphicVerificationCode&n=" + Math.random(),
- "onclick": function () {
- U.MD.U.R.regenerateVerificaCode(this);
- }
- }, U.selectEl("#U_MD_U_R_VC_Img")[0]);
- }
- //输入框聚焦
- var _input = U.selectEl("input", _child[1])[0];
- _input.focus();
- }
- /**
- * 重新生成验证码
- * @param {element} 生成验证码的图片
- *
- */
- U.MD.U.R.regenerateVerificaCode = function (image) {
- image.src = "http://main.1473.cn/Uses.ashx?mode=GraphicVerificationCode&n=" + Math.random();
- }
- /**
- * 单击注册按钮后,首先判断是否已经阅读了云端协议,然后检查是否用户输入的信息是否全部合法。
- * @param {element} 按钮
- *
- */
- U.MD.U.R.clickRegister = function (button) {
- var _inputs = U.selectEl("#U_MD_U_R_I").find("input");
- //是否已经阅读了云端协议。
- if (_inputs[3].checked) {
- //判断注册的信息是否通过,都通过直接注册处理
- if (U.MD.U.R.isRegister(_inputs, button) && _inputs[2].value != "") {
- U.MD.U.R.ajaxRegister(_inputs[0].value, _inputs[1].value, "", U.selectEl("#U_MD_U_L_login")[0]); //调用ajax的注册
- _inputs.addAttrArray({ "value": "" }); //注册可以通过,那么所有填写的信息都删除
- //调用这个复原输入框的样式
- for (i = 0; i < _inputs.length; i++) {
- if (_inputs[i].offsetWidth && _inputs[i].onblur) { //如果input没有隐藏的情况
- _inputs[i].onblur();
- }
- }
- button.innerText = "注册中..."; //注册按钮提示处理
- }
- //弹出提示框
- else if (_inputs[0].value != "" && _inputs[1].value == "") {
- U.alert("请填写密码");
- } else if (_inputs[1].value != "" && _inputs[2].value == "") {
- U.alert("请正确填写信息");
- }
- else {
- U.alert("请正确的填写信息");
- }
- }
- //如果没有勾选云端协议处理
- else {
- U.alert("请阅读云端协议");
- }
- }
- /**
- * 注册判断设置
- * @param {element} 输入的框
- * @param {element} 按钮
- *
- */
- U.MD.U.R.isRegister = function (inputs, button) {
- var _checked = U.MD.U.R.isregister.indexOf(false); //判断注册的信息里是否有没有填写或者填写有问题的
- //如果所有的填写数据都是成功的处理
- if (_checked == -1) {
- return true;
- }
- //如果错误只是验证码错误
- else if (_checked == 4) {
- //验证码获取
- U.MD.U.R.verificationCode(inputs[2], function () {
- U.MD.U.R.clickRegister(button); //验证码获取成功后的回调处理
- });
- return true;
- }
- return false;
- }
- //用户注册Ajax函数。
- /**
- //外面用户可以直接调用U.MD.U.R.register(username,password),调用之前必须设置全局变量US.systemId,测试用户U.MD.U.R.register=0.开发者账号需要进入授权系统进行授权
- 返回值:
- */
- U.MD.U.R.ajaxRegister = U.MD.U.R.UR = function (username, password, email, loading) {
- U.MD.U.R.isregister = [false, false, false, false, false, true]; //注册成功响应后,允许注册的值改成false
- //注册处理,调用后台注册
- U.A.Request(US.USER, ["UserRegister", username, password, email, US.city.userAllLocation, ""],
- U.MD.U.R.asynRegister, [loading, US.city.userAllLocation]); //注册的同时执行登录
- }
- /**
- * 用户注册异步
- * @param {element} 输入的框
- * @param {element} 按钮
- *
- */
- U.MD.U.R.asynRegister = function (r, outsite) {
- var value = r.value;
- //账号重复注册的处理
- if (value == "notregister") {
- U.alert("已经存在该账号!");
- }
- //注册失败
- else if (value == "false") {
- U.alert("系统繁忙,请稍后。");
- }
- //注册成功,直接登录处理
- else {
- //注册成功直接登录
- U.MD.U.L.asynLoginAjax(r);
- //写入用户来源信息,根据链接统计是哪一个推广人员推广的。
- //U.MD.U.NP.extension();
- return r;
- }
- }
- /**
- * 验证码javascript
- * @param {element} 输入的框
- * @param {element} 按钮
- *
- */
- U.MD.U.R.verificationCode = function (input, cb) {
- var _code = input.value, //输入的验证码值
- _isnumber = U.UF.S.Number.test(_code); //判断输入的验证码是否符合格式
- if (_isnumber) {
- //发送ajax判断是否注册成功
- U.A.Request(US.USER, ["ConfirmGraphicVerificationCode", _code],
- U.MD.U.R.asynVerificationCode, ["", input, cb]);
- //验证码样式设置
- U.MD.U.R.setInputStyle(input, { 'textAlign': 'right', 'color': 'red', "display": "block" }, "验证中...");
- }
- else if (_code) {
- //验证码样式设置
- U.MD.U.R.setInputStyle(input, { 'textAlign': 'right', 'color': 'red', "display": "block" }, "格式错误");
- }
- else {
- //验证码样式设置
- U.MD.U.R.setInputStyle(input, { 'textAlign': 'right', 'color': '#00aa99', "display": "block" }, "验证码");
- }
- }
- /**
- * 验证码异步
- *
- */
- U.MD.U.R.asynVerificationCode = function (r) {
- var _context = r.context, //参数
- _input = _context[1], //验证码输入框
- _cb = _context[2] //回调函数
- ;
- r = r.value; //得到后台数据库返回的值
- //如果验证码正确的处理
- if (r == "True") {
- U.MD.U.R.setInputStyle(_input, { 'textAlign': 'right', 'marginRight': '0px', 'color': '#00aa99', "display": "block" }, "成功"); //设置提示说明样式
- U.MD.U.R.isregister[4] = true; //设置验证码成功
- if (U.UF.C.isFunction(_cb)) {
- _cb(); //成功后的回调
- }
- }
- //验证码正确
- else if (r == "False") {
- U.MD.U.R.setInputStyle(_input, { 'textAlign': 'right', 'marginRight': '15px', 'color': 'red', "display": "block" }, "错误"); //设置提示说明样式
- return false;
- }
- //重新生成验证码
- else {
- _input.value = ""; //清空验证码输入
- _input.blur(); //调用blur复原输入框值
- U.MD.U.R.setInputStyle(_input, { 'textAlign': 'center', 'marginRight': '0px', 'color': '#00aa99', "display": "block" }, "验证码"); //设置提示说明样式
- U.selectEl("img", U.selectEl(_input).Parent(3))[0].src = "http://main.1473.cn/Uses.ashx?mode=GraphicVerificationCode&n=" + Math.random(); //重新生成验证码
- _input.focus(); //验证码聚焦
- U.alert("验证码错误或者服务器繁忙"); //弹出服务器繁忙
- }
- }
- //#endregion
- /*
- 判断用户名 这里包括登录所有的用户名的审核 是否通过等。此函数在cookie登录中不会调用。
- 参数一:
- 参数二:UDE为数组,
- 参数三:
- 返回值:
- */
- U.MD.U.R.checkUserName = function (inputel) {
- var _username = inputel.value; //获取用户名
- //输入为空不做变化
- U.selectEl('.U_MD_U_L_Box_U_B').removeClass(" U_MD_U_L_Box_mistakeBorder");
- if ($('.U_MD_U_L_Box_checkUseNameFormat')[0]) {//检测账号格式提示是否存在
- U.selectEl('.U_MD_U_L_Box_checkUseNameFormat')[0].parentNode.removeChild($('.U_MD_U_L_Box_checkUseNameFormat')[0]);
- }
- if (_username == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left' }, "用户账号"); //输入的用户名为空的样式处理
- }
- //注册的用户不符合要求
- else if (!U.UF.S.UserName.test(_username)) {
- U.selectEl('.U_MD_U_L_Box_U_B').addClass(" U_MD_U_L_Box_mistakeBorder");
- U_MD_U_L_createFormat($('.U_MD_U_L_LB')[0], U.selectEl('.U_MD_U_L_Box_P_B')[0]);
- //U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'right' }, "2-10汉字或4-20字符"); //注册用户名不符合提示
- }
- //用户注册 需要判断用户是否有重复的用户名
- else {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'right' }, "等待认证,请稍后..."); //设置注册的提示
- U.A.Request(US.USER, ["CheckUserName", _username], U.MD.U.R.asynCheckUserName, ["", inputel]);
- }
- }
- /**
- *创建用户账号是否标准提醒
- *
- */
- U_MD_U_L_createFormat = function (parentnode, beforenode) {
- if (beforenode == U.selectEl('.U_MD_U_L_Box_P_B')[0] && U.selectEl('.U_MD_U_L_Box_checkUseNameFormat')[0]) {
- U.selectEl('.U_MD_U_L_Box_checkUseNameFormat')[0].parentNode.removeChild($('.U_MD_U_L_Box_checkUseNameFormat')[0]);
- }
- var _format = document.createElement('div');
- _format.className = "U_MD_U_L_Box_checkUseNameFormat";
- _format.innerText = "2-10汉字或4-20字符";
- parentnode.insertBefore(_format, beforenode);
- }
- /**
- * 判断用户名是否存在
- * @param {object} ajax对象
- *
- */
- U.MD.U.R.asynCheckUserName = function (r) {
- var _context = r.context,
- _inputel = _context[1];
- r = r.value;
- //无法注册
- if (r == true) {
- U.MD.U.R.setInputStyle(_inputel, { "color": "red" }, "已被注册!");
- }
- //成功注册
- else {
- U.MD.U.R.setInputStyle(_inputel, { "display": "none" });
- U.MD.U.R.isregister[0] = true;
- }
- }
- /**
- * 判断密码输入是否有问题
- * @param {object} ajax对象
- *
- */
- U.MD.U.R.checkPassword = function (inputel) {
- var _password = inputel.value;
- U.selectEl('.U_MD_U_L_Box_P_B').removeClass(" U_MD_U_L_Box_mistakeBorder");
- if ($('.U_MD_U_L_Box_checkPWFormat')[0]) {
- U.selectEl('.U_MD_U_L_Box_checkPWFormat')[0].parentNode.removeChild($('.U_MD_U_L_Box_checkPWFormat')[0]);
- }
- //如果没有输入密码
- if (_password == "") {
- U.MD.U.R.setInputStyle(inputel, { "display": "block", 'textAlign': 'left', 'marginRight': '0px' }, "6-20位字符或数字"); //没有输入密码的提示
- }
- //输入的密码的格式不对
- else if (!U.UF.S.PassWord.test(_password)) {
- U.selectEl('.U_MD_U_L_Box_P_B').addClass(" U_MD_U_L_Box_mistakeBorder");
- U_MD_U_L_checkPWFormat($('.U_MD_U_L_LB')[0], U.selectEl('.U_MD_U_R_VC')[0]);
- //U.MD.U.R.setInputStyle(inputel, { "display": "block", "color": "red", 'textAlign': 'right', 'marginRight': '15px' }, "6-20位字符或数字"); //输入的密码有问题
- }
- //输入
- else {
- U.MD.U.R.passwordStrength(inputel); //判断输入的密码强度
- U.MD.U.R.isregister[1] = true; //设置已经成功通过密码审核
- return true;
- }
- return false;
- }
- /**
- *创建用户账号是否标准提醒
- *
- */
- U_MD_U_L_checkPWFormat = function (parentnode, beforenode) {
- if (beforenode == U.selectEl('.U_MD_U_R_VC')[0] && U.selectEl('.U_MD_U_L_Box_checkPWFormat')[0]) {
- U.selectEl('.U_MD_U_L_Box_checkPWFormat')[0].parentNode.removeChild($('.U_MD_U_L_Box_checkPWFormat')[0]);
- }
- var _format = document.createElement('div');
- _format.className = "U_MD_U_L_Box_checkPWFormat";
- _format.innerText = "2-10汉字或4-20字符";
- parentnode.insertBefore(_format, beforenode);
- }
- /**
- * 隐藏提示框,隐藏提示框,一般都在在点击重新输入,或者是点击取消提示框的时候使用
- * @param {object} ajax对象
- *
- */
- U.MD.U.R.hidePromptBox = function (el) {
- var _parentel = U.selectEl(el).Parent(); //上级父亲层;
- U.selectEl("i", _parentel)[0].style.display = "none"; //提示框隐藏
- try {
- U.selectEl("input", _parentel)[0].focus();
- }
- catch (e) { }
- }
- /**
- * 设置样式
- * @param {element} 输入的框
- * @param {element} 样式
- *
- */
- U.MD.U.R.setInputStyle = function (input, styles, text) {
- //找input输入框的父亲元素
- var _parent = U.selectEl(input).Parent();
- //指定的元素里面找孩子元素为i的元素
- var _el = U.selectEl("i", _parent);
- styles.display = "block";
- _el.addAttrArray({ "style": styles, "innerHTML": text || "" }, 0)[0];
- }
- /**
- * 设置样式
- * @param {element} 输入的框+
- *
- */
- U.MD.U.R.passwordStrength = function (input) {
- var i = 0,
- _value = input.value,
- _arr = [
- ["弱", "#e64141"],
- ["中", "#0a8cd2"],
- ["强", "#4bb900"]];
- //如果输入的内容大于10,那么加一
- if (_value.length > 10) {
- i++;
- }
- //如果输入的内容含数字,那么加一
- if (_value.match(/[0-9]/ig)) {
- i++;
- }
- //如果输入的内容含字符,那么加一
- if (_value.match(/[a-z]/ig)) {
- i++;
- }
- //选择输入的强度数字
- i = i > 0 ? i - 1 : i;
- //找input输入框的父亲元素
- var _parent = U.selectEl(input).Parent();
- //指定的元素里面找孩子元素为i的元素
- var _el = U.selectEl("i", _parent);
- //设置样式
- _el.addAttrArray({
- "style": {
- "textAlign": "right",
- "display": "block",
- "color": _arr[i][1]
- },
- "innerHTML": _arr[i][0]
- }, 0); //设置密码样式
- }
- //#endregion
- ;
- ///<jscompress sourcefile="Score.js" />
- Namespace.register("U.MD.U.S"); //积分
- //类型
- U.MD.U.S.TF = { "Contribute": "找出漏洞", "Introduce": "推广本网站", "Upload": "上传文件", "PostArticle": "发表文章", "Online": "在线时间", "Reply": "回复文章", "SignIn": "登陆签到", "Download": "下载文件", "DiskAddition": "硬盘增加", "IllegalImage": "发布违规图片" }
- U.MD.U.S.FTF = { "Upload": "UseStudioUserDiskDiv", "Download": "UseStudioUserDiskDiv", "PostArticle": "UseStudioStudyControlDiv", "Reply": "UseStudioStudyControlDiv" };
- //用户数据分页
- U.MD.U.S.E = {};
- //点击积分图标
- U.MD.U.S.LoginIC = function () {
- var _UICD = U.selectEl("#UU_IC")[0], _UDGG = U.selectEl("#UU_ICBG_GG")[0]; //积分的显示区域
- U.UF.F.windowTopCenter(_UICD); //居中弹框
- U.MD.U.S.GetIC($("div#UU_IC_Pay", _UICD)[0]); //获取积分统计
- U.MD.D.T.WindowRestore(_UICD, '', '积分中心'); //创建任务栏
- }
- //切换
- U.MD.U.S.SIC = function (TF) {
- U.MD.U.S.YXICD["none", "block"]; //切换到显示的div
- if (TF == 1) { U.MD.U.S.GetIC($("#UU_IC_Pay")[0]); }
- else { U.MD.U.S.ICSS(1); }
- }
- //切换的显示和隐藏
- U.MD.U.S.YXICD = function (TF) {
- U.selectEl('#UU_IC_HB')[0].style.display = TF[0];
- U.selectEl('#UU_IC_Info')[0].style.display = TF[1];
- }
- //------------------------------------------------------------------------用户个人
- //用户积分资料
- U.MD.U.S.SUIC = function (UICD) {
- var i, TF = 0, _UDAD = U.selectEl("#UU_IC_Avatar", UICD)[0], _UET = U.MD.U.S.E[US.userInfo.UserId]["ICCSV"][0]; _UDAD.innerHTML = "";
- for (i = 0; i < _UET.length; i++) { TF += _UET[i].VCSumValue; } //获取用户显示的积分
- //显示用户积分资料
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": U.MD.C.imgError,
- "id": "UU_IC_Avatar_img", "src": U.MD.C.getHeadImage(US.userInfo.UserThumbnailImageHead)
- }, _UDAD);
- U.selectEl("#UU_IC_VCSum", UICD)[0].innerHTML = TF; //用户积分
- }
- //------------------------------------------------------------------------用户积分消耗查询(分)
- //用户积分查询分页
- U.MD.U.S.ICSS = function (P) {
- var SP = Math.ceil(P * 7 / 70),
- _E = SP * 70,
- _S = _E - 69,
- UPDL = U.MD.U.S.E[US.userInfo.UserId];
- if (UPDL && (UPDL = UPDL["Page"]) && (UPDL = UPDL[SP])) {
- var _TP = P % 10;
- _TP = _TP == 0 ? 10 : _TP;
- _E = _TP * 7; _S = _E - 7; //分页算法
- var _UICL = UPDL.slice(_S, _E); //获取打印的数据
- U.MD.U.S.SetICSS(_UICL, P);
- }
- else { U.A.Request("UseStudioPay.UserGetSomeVC", [_S, _E], U.MD.U.S.AsynICSS, ["", P, SP, US.userInfo.UserId]); } //获取积分明细记录
- }
- //异步用户资料查询
- U.MD.U.S.AsynICSS = function (r) {
- var _context = r.context;
- r = r.value;
- if (U.MD.U.S.E[_context[3]] == null) {
- U.MD.U.S.E[_context[3]] = { "Page": [] };
- }
- else if (U.MD.U.S.E[_context[3]]["Page"] == null) {
- U.MD.U.S.E[_context[3]]["Page"] = [];
- }
- U.MD.U.S.E[_context[3]]["Page"][_context[2]] = r[0]; //添加用户数据
- U.MD.U.S.ICTT(r[1], U.selectEl("#UU_ICM_UU_IC_Heroes")[0]); //打印英雄榜
- U.MD.U.S.ICSS(_context[1]); //用户积分查询分页
- }
- //设置分页
- U.MD.U.S.SetICSS = function (UICL, P) {
- if (UICL.length > 0) {
- U.MD.U.S.ICPL(UICL, ["时间", "来源", "来源", "积分"], U.selectEl("#UU_IC_Info")[0]); //打印数据
- new U.UF.P.page($("#UU_IC_Pag")[0], UICL[0].AllCount, 7, P, function (P) { U.MD.U.S.ICSS(P); }); //分页
- }
- }
- //-------------------------------------------------------------------获取用户积分消耗情况(总)
- //获取积分
- U.MD.U.S.GetIC = function (UICD) {
- if (U.MD.U.S.E[US.userInfo.UserId] && U.MD.U.S.E[US.userInfo.UserId]["ICCSV"]) {
- U.MD.U.S.SetIC(U.MD.U.S.E[US.userInfo.UserId]["ICCSV"], UICD);
- }
- else {
- U.A.Request("UseStudioPay.UserCountVC", [], U.MD.U.S.AsynGetIC, [UICD, 1, US.userInfo.UserId]);
- } //获取积分统计
- }
- //获取积分异步
- U.MD.U.S.AsynGetIC = function (r) {
- var _context = r.context;
- r = r.value;
- if (U.MD.U.S.E[_context[2]] == null) {
- U.MD.U.S.E[_context[2]] = {};
- }
- U.MD.U.S.E[_context[2]]["ICCSV"] = r; //积分消耗统计
- U.MD.U.S.GetIC(_context[0], r); //显示积分
- }
- //打印积分详情(总)
- U.MD.U.S.SetIC = function (UIC, UICD) {
- U.MD.U.S.ICTT(UIC[1], U.selectEl("div#UU_ICM_UU_IC_Heroes", UICD)[0]); //打印排名
- U.MD.U.S.ICPL(UIC[0], ["时间", "来源", "积分", "次数"], U.selectEl("div#UU_IC_Info", UICD)[0]); //积分使用获得的变化
- U.MD.U.S.SUIC(UICD); //设置用户积分信息
- }
- //打印积分排名
- U.MD.U.S.ICTT = function (UICL, UOD) {
- var i, _UCL, _el, _UDTD,
- _UDFD = $$("frag");
- UOD.innerText = "";
- for (i = 0; i < UICL.length; i++) {
- _UCL = UICL[i]; //获取积分名次
- _el = $$("div", {
- "style":
- {
- "marginTop": "8px"
- },
- "onclick": function () {
- U.UF.EV.stopBubble();
- U.MD.U.V.POUW(_UCL.UserId);
- }
- }, _UDFD);
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": U.MD.C.imgError,
- "src": U.MD.C.getHeadImage(_UCL.UserThumbnailImageHead),
- "className": "UU_IC_Heroes_img"
- }, _el);
- $$("div", { "className": "UU_IC_HSOne", "innerHTML": _UCL.UserNickName }, _el);
- _UDTD = $$("div", { "className": "UU_IC_HSTwo" }, _el);
- $$("span", { "innerHTML": "积分:" }, _UDTD);
- $$("span", { "style": { "color": "#3081fe" }, "innerHTML": _UCL.VCSumValue }, _UDTD);
- }
- UOD.appendChild(_UDFD);
- }
- //打印用户积分来源
- U.MD.U.S.ICPL = function (UICL, UDTF, UOD) {
- UOD.innerText = U.selectEl("#UU_IC_Pag")[0].innerText = "";
- var i, j, _UCI, _UDSD,
- _el = $$("div", { "className": "UU_IC_Values" }),
- _UDTD = $$("div", { "className": "UU_IC_VP" });
- for (i = 0; i < UDTF.length; i++) {
- $$("div", {
- "innerHTML": UDTF[i],
- "style": { "width": (i == 3 ? "50px " : (i == 1 ? "100px" : i == 2 ? "200px" : "")) }
- }, _el);
- };
- for (j = 0; j < UICL.length; j++) {
- _UCI = UICL[j];
- _UDSD = $$("div", { "className": "UU_IC_SG" }, _UDTD);
- $$("div", { "innerHTML": U.UF.D.getDateInterval(_UCI.VCDateTime) }, _UDSD);
- $$("div", { "innerHTML": U.MD.U.S.TF[_UCI.VCType], "style": { "width": "100px" } }, _UDSD);
- $$("div", {
- "onclick": _UCI.VCCountValue ? "" : U.MD.U.S.FTF[_UCI.VCType] ? function () {
- U.UF.EV.stopBubble(); U.UF.C.divdoubleClick(U.MD.U.S.FTF[_UCI.VCType],
- _UCI.VCDetailsDataID, null, null, "ART" + _UCI.VCDetailsDataID);
- } : "", "className": ("U_MD_D_Text_Abbreviation" + (_UCI.VCCountValue ? "" : " UU_IC_FS")),
- "style":
- {
- "color": _UCI.VCCountValue ? "" : "#3081fe", "width": "200px"
- },
- "innerHTML": _UCI.VCCountValue ? _UCI.VCSumValue : _UCI.VCDetailsDataValue
- }, _UDSD);
- $$("div", { "innerHTML": _UCI.VCCountValue || _UCI.VCValue, "style": { "width": "50px" } }, _UDSD);
- }
- UOD.appendChild(_el); UOD.appendChild(_UDTD);
- }
- //--------------------------------------------------------------------------------汇换空间----------------------------------------------------------------------------
- //弹出
- U.MD.U.S.ICEXC = function (TF) {
- var _UIED = U.selectEl("#UU_IC_EXC")[0];
- if (TF == "block") { U.UF.F.topWindow(_UIED); } //解决层次的问题
- _UIED.style.display = TF; //显示或者隐藏
- }
- //用户换去空间
- U.MD.U.S.ICGK = function (UICD) {
- var i, _TF = 0,
- _UICE = U.MD.U.S.E[US.userInfo.UserId]["ICCSV"][0];
- UICV = UICD.value;
- for (i = 0; i < _UICE.length; i++) {
- _TF += _UICE[i].VCSumValue;
- } //获取用户所有的积分
- if (parseFloat(UICV) < 0) {
- U.alert("请输入正整数");
- } //换取有效网盘空间
- else if (!U.UF.S.Number.test(UICV)) {
- U.alert("您的输入有误,请输入数字!");
- } //输入的是无效数据
- else if (UICV > _TF) {
- U.alert("您的积分不足");
- } //积分不足无法汇换
- else {
- U.UF.UI.confirm("确定确定要兑换" + UICV + "M的空间吗?", function () {
- // U.A.Request(US.USER,"UseStudioManage.UserDiskAddition", [UICV], U.MD.U.S.AsynICGK, ["", UICD, UICV]);
- UICD.parentNode.parentNode.parentNode.style.display = "none"; UICD.value = "";
- })
- } //于服务器同步增加用户的网盘
- }
- //汇换空间异步
- U.MD.U.S.AsynICGK = function (r) {
- var _context = r.context;
- r = r.value;
- if (r) {
- var i, _TF = true,
- ICDE = U.MD.U.S.E[US.userInfo.UserId]["ICCSV"][0];
- for (i = 0; i < ICDE.length; i++) {
- if (ICDE[i]["VCType"] == "DiskAddition") {
- _TF = false; ICDE[i].VCSumValue -= _context[2];
- ICDE[i].VCCountValue += 1;
- }
- } //修改用户积分消耗信息
- if (_TF) {
- var _E = new U.MD.U.S.PICE[1, new Date(), -_context[2], "DiskAddition"],
- _UICE = U.MD.U.S.E[US.userInfo.UserId]["Page"];
- ICDE.push(_E);
- if (_UICE && _UICE.length > 0) {
- var _ICE = U.MD.U.S.ICE(_UICE[1][0].AllCount, "0", US.userInfo.UserId, new Date(), Guid.newGuid(), "硬盘增加", Guid.newGuid(), "DiskAddition", -_context[2]); _UICE[1].unshift(_ICE);
- }
- } //添加用户积分消耗信息
- U.MD.U.S.SUIC();
- U.MD.U.S.ICPL(ICDE, ["时间", "来源", "积分", "次数"], U.selectEl("#UU_IC_Info")[0]);
- US.userInfo.UserDiskSpace += 1; //积分使用获得的变化 //用户信息
- }
- }
- //-----------------------------------------------------------------------------数据结构-------------------------------------------------------------------------------
- //积分的结构
- U.MD.U.S.PICE = function (E) {
- this.VCCountValue = E[0];
- this.VCDateTime = E[1];
- this.VCSumValue = E[2];
- this.VCType = E[3];
- }
- //积分的消耗
- U.MD.U.S.ICE = function (E) {
- this.AllCount = E[0];
- this.PageNum = E[1];
- this.UserID = E[2];
- this.VCDateTime = E[3];
- this.VCDetailsDataID = E[4];
- this.VCDetailsDataValue = E[5];
- this.VCID = E[6];
- this.VCType = E[7];
- this.VCValue = E[8];
- }
- ;
- ///<jscompress sourcefile="UserInfo.js" />
- Namespace.register("U.MD.U.P"); //个人资料设置
- U.MD.U.P.inpEl = {}
- //#region 用户登录个人资料
- //打开个人资料
- U.MD.U.P.userDataSet = function () {
- U.MD.U.P.init()
- }
- /**
- * 个人设置初始化函数
- */
- U.MD.U.P.init = function () {
- if (!U.MD.U.L.isLogin()) { //判断是否有登录
- var _form = U.selectEl('#U_MD_U_P_Set'), _personal = U.selectEl("#U_MD_U_P_Uc_B")[0]; //个人资料元素
- if (!_form.length) { //窗体是否存在
- new U.UF.UI.form("<div class='U_MD_F_S_TI'>个人设置</div>", _personal, { "id": "U_MD_U_P_Set", "style": { "width": "664px", "height": "549px" } }, { isenlarge: false, isstretching: false }).form; //打开个人资料函数实例化
- U.MD.U.P.eventBind(); //绑定事件
- _personal.style.display = 'block'; //显示打印内容
- } else {
- U.selectEl('#U_MD_U_P_tab_lable_info')[0].checked = 'checked'; //让第一个选项选中
- _form[0].style.display = 'block'; //显示出来
- }
- }
- }
- /**
- * 事件绑定,打印页面
- */
- U.MD.U.P.eventBind = function () {
- U.MD.U.P.EL = { //元素集合
- "headImage": U.selectEl('#U_MD_U_P_simpleInfo_img')[0], //用户头像 左侧
- "name": U.selectEl('.U_MD_U_P_simpleInfo_name')[0], //用户昵称 左侧
- "nickName": U.selectEl('#U_MD_U_P_tab_userNickName')[0], //用户昵称 基本信息
- "selfIntroduction": U.selectEl('#U_MD_U_P_tab_selfIntroduction')[0], // 个人介绍 基本信息
- "email": U.selectEl('#U_MD_U_P_tab_email')[0], //邮箱 基本信息
- "phoneNumber": U.selectEl('#U_MD_U_P_tab_phoneNumber')[0], //手机号码 基本信息
- "address": U.selectEl('#U_MD_U_P_tab_address')[0], //地址 基本信息
- "trueName": U.selectEl('#U_MD_U_P_tab_trueName')[0], //真实姓名 个人隐私
- "birthday": U.selectEl('#U_MD_U_P_tab_birthday')[0], //出生日期 个人隐私
- "loginName": U.selectEl('#U_MD_U_P_tab_loginName')[0], //用户名 账号安全
- "oldPW": U.selectEl('#U_MD_U_P_tab_oldPW')[0], //旧密码 账号安全-修改密码
- "newPW": U.selectEl('#U_MD_U_P_tab_newPW')[0], //新密码 账号安全-修改密码
- "confirmPW": U.selectEl('#U_MD_U_P_tab_confirmPW')[0], //确认密码 账号安全-修改密码
- "phone": U.selectEl('#U_MD_U_P_tab_phone')[0], //手机号码 账号安全-手机找回
- "accountNPW": U.selectEl('#U_MD_U_P_tab_lable_accountNext_n')[0], //新密码 账号安全-手机找回
- "accountCPW": U.selectEl('#U_MD_U_P_tab_lable_accountNext_c')[0] //确认密码 账号安全-手机找回
- };
- var _bindEl = ["nickName", "email", "phoneNumber", "newPW", "confirmPW,newPW", "phone", "accountNPW", "accountCPW,accountNPW"], //元素数组
- _bindString = ["NickName", "Email", "TelephoneNumber", "PassWord", "contrastPW", "TelephoneNumber", "PassWord", "contrastPW"], //绑定验证类型
- _lastPage = U.selectEl('.U_MD_U_P_tab_inp')[0], //上一个停留的位置
- _isDataChanged = false, //用户是否修改过数据
- _changeDataNum = "", //序号
- _isNextStep = false; //是否可点击下一步
- U.UF.DL.asynLoadJs({ type: "text/javascript", src: "/js/Controls/Basic/City.js" }, function () { new U.MD.UI.city(); }); //加载城市控件js
- U.UF.DL.asynLoadCss({ "href": "/css/Controls/Basic/City.css", type: "text/css", rel: "stylesheet" }); //加载城市控件css
- U.selectEl('#U_MD_U_P_tab_address').bind({
- click: function () {
- U.MD.UI.city(this);
- U.selectEl("#U_MD_UI_city_cityBox")[0].style.display = "block";
- U.selectEl("#U_MD_UI_city_cityBox")[0].style.zIndex = "999";
- }
- });
- U.selectEl('#U_MD_U_P_tab_birthday').bind({ //绑定生日的日历控件
- click: function () {
- U.MD.UI.calendar(this, U.selectEl('#U_MD_U_P_tab_calendar')[0], false);
- }
- })
- U.selectEl('#U_MD_U_P_save').bind({ //绑定保存点击事件
- click: function () {
- switch (_lastPage.value) { //判断停留在那一页上
- case "0": case "1":
- U.MD.U.P.updateUserBasicInfo(_lastPage.value); break;
- case "2":
- if ($('.U_MD_U_P_tab_accountRadio:checked')[0].value == 0) {
- U.MD.U.P.setPassword(_bindEl, _bindString);
- } else if ($('.U_MD_U_P_tab_accountRadio:checked')[0].value == 1) {
- U.MD.U.P.updatePassword();
- }
- break;
- }
- U.selectEl('.U_MD_U_P_simpleInfo_address')[0].innerText = U.selectEl("#U_MD_U_P_tab_address")[0].value;
- }
- })
- U.selectEl('.U_MD_U_P_tab_inp').bind({ //绑定事件
- change: function () {
- U.MD.U.P.reset(_changeDataNum, _isDataChanged);
- _lastPage = this;
- _isDataChanged = false;
- }
- })
- U.selectEl('.U_MD_U_P_tab_lable_content input').bind({ //判断某一页用户是否修改了数据
- change: function () {
- if (!_isDataChanged) {
- _changeDataNum = _lastPage.value;
- _isDataChanged = true;
- }
- }
- })
- U.selectEl('.U_MD_U_P_tab_accountRadio').bind({ //账号安全的‘下一步’与“保存设置”按钮的显示隐藏
- change: function () {
- if (this.value == 0) {
- U.selectEl('#U_MD_U_P_save')[0].style.display = "inline-block";
- U.selectEl('#U_MD_U_P_next')[0].style.display = "none";
- } else {
- U.selectEl('#U_MD_U_P_save')[0].style.display = "none";
- U.selectEl('#U_MD_U_P_next')[0].style.display = "inline-block";
- }
- }
- })
- U.selectEl('#U_MD_U_P_authCodeBtn').bind({
- click: function () { //发送验证码
- _isNextStep = U.MD.U.P.sendAuthCode(_isNextStep);
- }
- })
- U.selectEl('#U_MD_U_P_next').bind({
- click: function () { //下一步
- U.MD.U.P.phoneConfirm();
- }
- })
- U.selectEl('#U_MD_U_P_authCodeInp').bind({
- change: function () { //验证码文本框的不为空清除错误
- if (this.value.trim().length > 0) {
- U.selectEl(this).removeClass('U_MD_U_P_tab_user_emptyInp')
- }
- }
- })
- U.selectEl('#U_MD_U_P_cancel').bind({
- click: function () { //关闭
- U.selectEl('#U_MD_U_P_Set')[0].style.display = 'none';
- }
- })
- U.selectEl('#U_MD_U_P_tab_oldPW').bind({
- change: function () {
- var _bool = U.MD.U.P.checkEmpty(this);
- !_bool && U.selectEl(this).removeClass('U_MD_U_P_tab_user_emptyInp');
- }
- })
- U.MD.U.P.dataPrint(); //数据打印
- U.MD.U.P.bindCheckFormat(_bindEl, _bindString); //绑定文本框的格式
- }
- /**
- * 绑定事件
- * @param elarr {Array} 元素数组
- * @param eventarr {Array} 绑定验证类型
- */
- U.MD.U.P.bindCheckFormat = function (elarr, eventarr) {
- var _len = elarr.length;
- for (var i = 0; i < _len; i++) {
- var _el = U.MD.U.P.EL[elarr[i].split(',')[0]];
- _el.i = i;
- U.selectEl(_el).bind({
- change: function () {
- U.MD.U.P.inpFormatCheck(this, elarr, eventarr);
- }
- })
- }
- }
- /**
- * 数据重置
- * @param that {string} 标记
- * @param elarr {Array} 是否更改数据
- * @param eventarr {Array} 是否更改数据
- */
- U.MD.U.P.inpFormatCheck = function (that, elarr, eventarr) {
- var _bool = false;
- if (U.UF.S[eventarr[that.i]]) {
- _bool = U.UF.S[eventarr[that.i]].test(that.value.trim());
- } else if (eventarr[that.i] == 'contrastPW') {
- _bool = (U.MD.U.P.EL[elarr[that.i].split(',')[0]].value === U.MD.U.P.EL[elarr[that.i].split(',')[1]].value);
- }
- if (!_bool) {
- if (!that.value.trim().length) {
- U.selectEl(that).removeClass('U_MD_U_P_tab_user_errorInp');
- U.selectEl(that).addClass('U_MD_U_P_tab_user_emptyInp');
- U.selectEl(that).next().removeClass('U_MD_U_P_tab_errorAlear');
- } else {
- U.selectEl(that).removeClass('U_MD_U_P_tab_user_emptyInp');
- U.selectEl(that).addClass('U_MD_U_P_tab_user_errorInp');
- U.selectEl(that).next().addClass('U_MD_U_P_tab_errorAlear');
- }
- } else {
- U.selectEl(that).removeClass('U_MD_U_P_tab_user_errorInp');
- U.selectEl(that).removeClass('U_MD_U_P_tab_user_emptyInp');
- U.selectEl(that).next().removeClass('U_MD_U_P_tab_errorAlear');
- }
- }
- /**
- * 数据重置
- * @param mark {string} 标记
- * @param flag {boolean} 是否更改数据
- */
- U.MD.U.P.reset = function (mark, flag) {
- if (!flag)
- return;
- var _info = US.userInfo, _elObj = U.MD.U.P.EL;
- switch (mark) {
- case "0":
- U.MD.U.P.dataPrint.simpleInfo(_info, _elObj);
- break;
- case "1":
- U.MD.U.P.dataPrint.privacy(_info, _elObj);
- break;
- case "2":
- U.MD.U.P.dataPrint.account(_info, _elObj);
- break;
- }
- }
- /**
- * 打印数据
- */
- U.MD.U.P.dataPrint = function () {
- var _info = US.userInfo, _elObj = U.MD.U.P.EL;
- U.MD.U.P.dataPrint.privacy(_info, _elObj);
- U.MD.U.P.dataPrint.simpleInfo(_info, _elObj);
- U.MD.U.P.dataPrint.account(_info, _elObj);
- U.MD.U.P.dataPrint.left(_info, _elObj);
- }
- /**
- * 初始化左侧栏数据
- * @param info {Array} 元素数组
- * @param elobj {Array} 绑定验证类型
- */
- U.MD.U.P.dataPrint.left = function (info, elobj) {
- elobj["headImage"].src = U.MD.C.getHeadImage(info.UserImageHead);
- /*$('.U_MD_U_P_simpleInfo_address')[0].innerText = info.LoginAddress.slice(2, 6);*/
- U.selectEl('.U_MD_U_P_simpleInfo_address')[0].innerText = elobj["address"].value;
- elobj["name"].innerText = info.UserNickName || "";
- elobj["name"].title = info.UserNickName || "";
- }
- /**
- * 初始化个人隐私数据
- * @param info {Array} 元素数组
- * @param elobj {Array} 绑定验证类型
- */
- U.MD.U.P.dataPrint.privacy = function (info, elobj) {
- elobj["trueName"].value = info.TrueName;
- elobj["birthday"].value = U.UF.D.getYearMonthDay(info.Birthday);
- }
- /**
- * 初始化基本信息数据
- * @param info {Array} 元素数组
- * @param elobj {Array} 绑定验证类型
- */
- U.MD.U.P.dataPrint.simpleInfo = function (info, elobj) {
- U.selectEl(".U_MD_U_P_tab_user_radio[value$=" + (info.UserSex ? "'1'" : "'0'") + "]")[0].checked = true;
- elobj["selfIntroduction"].value = info.UserIndividualitysignature;
- elobj["address"].innerText = info.Province || "";
- elobj["nickName"].value = info.UserNickName || "";
- elobj["email"].value = info.UserEmail;
- elobj["phoneNumber"].value = info.UserTelephoneNumber;
- elobj["address"].value = info.City;
- elobj["loginName"].innerText = info.UserName;
- }
- /**
- * 初始化账号安全数据
- * @param info {Array} 元素数组
- * @param elobj {Array} 绑定验证类型
- */
- U.MD.U.P.dataPrint.account = function (info, elobj) {
- U.selectEl('#U_MD_U_P_tab_lable_accountNext_t')[0].innerText = info.UserName;
- U.selectEl('.U_MD_U_P_tab_lable_account').css('display', 'block');
- U.selectEl('.U_MD_U_P_tab_lable_accountNext').css('display', 'none');
- U.selectEl('.U_MD_U_P_tab_accountRadio')[0].checked = "checked";
- var _arr = Array.prototype.slice.call($('.U_MD_U_P_tab_item')[2].querySelectorAll('[type="text"]')).concat(Array.prototype.slice.call($('.U_MD_U_P_tab_item')[2].querySelectorAll('[type="password"]')));
- for (var i = 0; i < _arr.length; i++) {
- _arr[i].value = "";
- U.selectEl(_arr[i]).removeClass('U_MD_U_P_tab_user_errorInp');
- U.selectEl(_arr[i]).removeClass('U_MD_U_P_tab_user_emptyInp');
- U.selectEl(_arr[i]).next().removeClass('U_MD_U_P_tab_errorAlear');
- }
- U.selectEl('#U_MD_U_P_save').css('display', 'inline-block');
- U.selectEl('#U_MD_U_P_next').css('display', 'none');
- }
- /**
- * 更新用户基本信息
- */
- U.MD.U.P.updateUserBasicInfo = function (type) {
- var _info = US.userInfo, _elObj = U.MD.U.P.EL, _sex = parseInt($('.U_MD_U_P_tab_user_radio:checked')[0].value);
- if (!parseInt(type)) {
- var _bool = U.MD.U.P.checkEmpty(_elObj['nickName']) || U.MD.U.P.checkEmpty(_elObj['email']) || U.MD.U.P.checkEmpty(_elObj['phoneNumber']) || U.MD.U.P.checkEmpty(_elObj['address']);
- if ($('.U_MD_U_P_tab_user_errorInp').length || U.selectEl('.U_MD_U_P_tab_user_emptyInp').length || _bool) {
- if ($(".U_MD_U_P_tab_user_errorInp")[0].id == "U_MD_U_P_tab_email" && U.selectEl(".U_MD_U_P_tab_user_errorInp").length == 1) {
- U.Alert("邮箱填写错误!");
- return;
- } else if ($(".U_MD_U_P_tab_user_errorInp")[0].id == "U_MD_U_P_tab_phoneNumber" && U.selectEl(".U_MD_U_P_tab_user_errorInp").length == 1) {
- U.Alert("手机号码填写错误!");
- return;
- } else {
- U.Alert("信息录入错误!");
- return;
- }
- }
- }
- U.A.Request(US.USER, ["UpdateUserBasicInfo", _info.UserId, _elObj["trueName"].value, _elObj["nickName"].value, _elObj["phoneNumber"].value, '', '', _elObj["selfIntroduction"].value, _sex, _elObj["email"].value,
- "中国", _elObj["address"].textContent, _elObj["address"].value || "", _elObj["birthday"].value],
- function (r) {
- if (r.value) {//判断是否更改成功
- US.userInfo.UserSex = _sex ? true : false;
- US.userInfo.TrueName = _elObj["trueName"].value;
- US.userInfo.UserNickName = _elObj["nickName"].value;
- US.userInfo.UserTelephoneNumber = _elObj["phoneNumber"].value;
- US.userInfo.UserIndividualitysignature = _elObj["selfIntroduction"].value;
- US.userInfo.UserEmail = _elObj["email"];
- US.userInfo.Province = _elObj["address"].value;
- US.userInfo.City = _elObj["address"].value;
- U.Alert("更改个人资料成功");
- }
- else {
- U.alert("更改个人资料失败");
- }
- })
- }
- /**
- * 设置密码
- * @param elarr {Array} 元素数组
- * @param eventarr {Array} 绑定验证类型
- */
- U.MD.U.P.setPassword = function (elarr, eventarr) {
- var _elObj = U.MD.U.P.EL,
- _emptyEl = U.selectEl($('.U_MD_U_P_tab_lable_content')[2]).find('.U_MD_U_P_tab_user_emptyInp'),
- _errorEl = U.selectEl($('.U_MD_U_P_tab_lable_content')[2]).find('.U_MD_U_P_tab_user_errorInp');
- if (!_emptyEl.length && !_errorEl.length) {
- if (_elObj["oldPW"].value == "") {
- U.MD.U.P.inpFormatCheck(_elObj["oldPW"], elarr, eventarr);
- return;
- } else if (_elObj["newPW"].value == "") {
- U.MD.U.P.inpFormatCheck(_elObj["newPW"], elarr, eventarr);
- return;
- } else if (_elObj["confirmPW"].value == "") {
- U.MD.U.P.inpFormatCheck(_elObj["confirmPW"], elarr, eventarr);
- return;
- }
- U.A.Request(US.USER, ["UpdateUserPasswordByOldPassword", US.userInfo.UserId, _elObj["oldPW"].value, _elObj["confirmPW"].value], function (r) {
- if (r.value) {
- U.Alert("更改密码成功,请重新登录");
- U.MD.U.LO.logout();
- U.MD.U.L.login();
- } else {
- U.Alert("原密码错误");
- U.selectEl(_elObj["oldPW"]).addClass("U_MD_U_P_tab_user_emptyInp");
- }
- });
- }
- }
- /**
- * 通过手机号码修改账户密码
- */
- U.MD.U.P.updatePassword = function () {
- var _pw = U.selectEl('#U_MD_U_P_tab_lable_accountNext_n')[0];
- var _pwconfirm = U.selectEl('#U_MD_U_P_tab_lable_accountNext_c')[0];
- //判断用户密码是否正确
- if (U.MD.U.F.checkConfirmPassword(_pw, _pwconfirm)) {
- U.A.Request(US.USER, ["UpdateUserPassword", US.userInfo.UserId, _pw.value], function (r) {//更改密码存储过程
- if (r.value) {//判断是否更改成功
- U.Alert('更改密码成功');
- }
- else {
- U.Alert('更改密码失败');
- }
- });
- }
- }
- /**
- * 发送验证码
- * @param flag {boolean} 是否已发送
- */
- U.MD.U.P.sendAuthCode = function (flag) {
- if (flag) {
- U.Aleart('请在60秒后重试');
- return;
- }
- var _phoneInp = U.MD.U.P.EL["phone"],
- _bool = U.MD.U.P.checkEmpty(_phoneInp) || U.MD.U.P.isCanUse(_phoneInp);
- if (_bool) {
- U.Alert('信息录入错误!');
- return;
- }
- U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserName", US.userInfo.UserName], function (r) {//根据用户名获取用户信息
- if (r.value[0].UserTelephoneNumber != _phoneInp.value) {//如果输入手机号与账号设置的手机号不匹配)
- U.Alert('输入的手机号与账号不匹配');
- } else {
- var _xhttp = new XMLHttpRequest(); //XMLHttpRequest 对象用于在后台与服务器交换数据
- _xhttp.onreadystatechange = function () {//每当 readyState 属性改变时,就会调用该函数。
- if (this.readyState == 4) {//发送成功后
- if (this.status == 201) {
- U.Alert('发送成功'); //弹出发送成功
- U.MD.U.P.setTime($('#U_MD_U_P_authCodeBtn')[0]);
- return true;
- } else {
- U.Alert(JSON.parse(this.response).err || '验证码发送失败,请重新发送...');
- }
- }
- };
- _xhttp.open("POST", "http://api.cloudsql.1473.cn/postnumber", true); //指定和服务器端交互的HTTP方法,URL地址及其他请求信息
- _xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //向一个打开但未发送的请求设置或添加一个 HTTP 请求
- _xhttp.withCredentials = true; //发送cookie等认证信息到服务端
- _xhttp.send("number=" + _phoneInp.value); //$("#userphone")[0].children[0].children[0].value 发送的手机号输入的框
- }
- });
- }
- /**
- * 验证手机验证码
- */
- U.MD.U.P.phoneConfirm = function () {
- var _input = U.selectEl('#U_MD_U_P_authCodeInp')[0];
- if (U.MD.U.P.checkEmpty(_input)) {
- U.Alert('验证码不为空');
- return;
- }
- var _xhttp = new XMLHttpRequest(); //XMLHttpRequest 对象用于在后台与服务器交换数据
- _xhttp.onreadystatechange = function (r) {//每当 readyState 属性改变时,就会调用该函数
- if (this.readyState == 4) {//验证成功后
- if (this.status == 201) {
- U.selectEl('#U_MD_U_P_save').css('display', 'inline-block');
- U.selectEl('#U_MD_U_P_next').css('display', 'none');
- U.selectEl('.U_MD_U_P_tab_lable_account').css('display', 'none');
- U.selectEl('.U_MD_U_P_tab_lable_accountNext').css('display', 'block');
- U.Alert("验证成功"); //弹出验证成功
- } else {
- U.Alert(JSON.parse(this.response).err || "验证码有误");
- }
- }
- };
- _xhttp.open("POST", "http://api.cloudsql.1473.cn/verifi", true); ////指定和服务器端交互的HTTP方法,URL地址及其他请求信息
- _xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //向一个打开但未发送的请求设置或添加一个 HTTP 请求
- _xhttp.withCredentials = true; //发送cookie等认证信息到服务端
- _xhttp.send("code=" + _input.value);
- }
- /**
- * 设置验证码时间
- * @param inp {elenemt} 元素
- */
- U.MD.U.P.setTime = function (inp) {
- if (this._timer) {
- U.Alert('请在60后重试!');
- return;
- }
- var _second = 60,
- _this = this;
- this._timer = setInterval(function () {
- inp.innerText = --_second + 's';
- if (!_second) {
- inp.innerText = '发送验证码';
- clearInterval(_this._timer);
- _this._timer = null;
- }
- }, 1000);
- }
- /**
- * 重置文本框
- * @param inp {elenemt} 元素
- */
- U.MD.U.P.restoreInp = function (el) {
- el.value = "";
- U.selectEl(el).removeClass('U_MD_U_P_tab_user_errorInp');
- U.selectEl(el).removeClass('U_MD_U_P_tab_user_emptyInp');
- }
- /**
- * 判断元素是否有错误
- * @param inp {elenemt} 元素
- */
- U.MD.U.P.isCanUse = function (el) {
- return U.selectEl(el).hasClass('U_MD_U_P_tab_user_emptyInp') || U.selectEl(el).hasClass('U_MD_U_P_tab_user_errorInp');
- }
- /**
- * 判断元素是否为空
- * @param inp {elenemt} 元素
- */
- U.MD.U.P.checkEmpty = function (el) {
- if (el.value.trim() == "" || !!!el.value) {
- U.selectEl(el).addClass('U_MD_U_P_tab_user_emptyInp');
- return true;
- }
- return false;
- }
- /**
- * 上传头像到服务器处理
- * @param input {ele} 上传图片的input
- */
- U.MD.U.P.uploadUserHeadImg = function (input) {
- //判断是否支持FileReader
- //头像预览
- if (window.FileReader) {
- var reader = new FileReader();
- } else {
- U.alert("您的设备不支持图片预览功能,如需该功能请升级您的设备!");
- }
- //获取文件
- var file = input.files[0];
- var imageType = /^image\//;
- //是否是图片
- if (!imageType.test(file.type)) {
- U.alert("请选择图片!");
- return;
- }
- var img = U.selectEl('#U_MD_U_P_simpleInfo_img')[0];
- //读取完成
- reader.onload = function (e) {
- //获取图片dom
- //图片路径设置为读取的图片
- img.src = e.target.result;
- };
- reader.readAsDataURL(file);
- //上传图片
- U.UF.UP.inputUpload([input], "http://disk.1473.cn/USUpfile.ashx?typename=UploadHeadImage", function (url) {
- //console.log(url.value);
- //修改头像
- U.A.Request(US.USER, ["UpdateUserHeaderImage", US.userInfo.UserId, url.value.UserFilesServerName, url.value.UseFilesServerThumbnailName], function (r) {
- if (r.value) {
- //动态修改全局属性
- US.userInfo.UserImageHead = url.value.UserFilesServerName;
- US.userInfo.UserThumbnailImageHead = url.value.UseFilesServerThumbnailName;
- U.Alert('头像修改成功!');
- } else {
- U.Alert('头像修改失败!');
- }
- });
- }, []);
- }
- ;
- ///<jscompress sourcefile="View.js" />
- Namespace.register("U.MD.U.V"); //查看用户信息弹框
- //#region 用户信息查看
- //------------------------------------------------------------------------------用户个人信息
- //个人信息
- U.MD.U.V.UIFZX = U.MD.U.V.ViewOtherUserInfo = function (userid) {
- var _userinfoel = U.selectEl("#U_MD_U_UV").clone(true), // 用户信息元素
- _childs = U.selectEl(_userinfoel[0]).Child(),
- _head = _childs[0],
- _middle = _childs[1],
- _aboutMe = _childs[2];
- var _div = $$('div');
- _div.appendChild(_head); //个人信息的头部
- _div.appendChild(_middle); //个人信息的中间部分
- _div.appendChild(_aboutMe); //个人信息的底部
- //弹出好友信息弹框
- if ($('#U_MD_F_S_TI_Info')[0])
- document.body.removeChild($('#U_MD_F_S_TI_Info')[0])
- var _form = new U.UF.UI.form("<div class='U_MD_F_S_TI'>个人信息</div>",
- _div,
- {
- "style": {
- "min-width": "460px",
- "width": "480px",
- "height": "400px"
- },
- id: "U_MD_F_S_TI_Info"
- },
- {
- isenlarge: false,
- isnarrow: false
- }).form;
- //信息加载
- U.A.Request(US.USER, ["ViewOtherUserInfo", userid],
- U.MD.U.V.ViewOtherUserInfoAsyn, ['', _head, _middle, _aboutMe, _form])
- // U.MD.U.V.ViewUserBlogInfo(_bloginfoel, userid, 1, true); //查看用户最新表表的博客
- }
- //打印用户信息 function(){U.MD.U.L.setLoginCallBack(function(){();});}
- U.MD.U.V.ViewOtherUserInfoAsyn = function (r) {
- var _userinfo = r.value[0],
- _context = r.context,
- _form = _context[4],
- TN = _userinfo.UserTelephoneNumber; //用户电话号码
- U.selectEl(_context[1]).find('.U_MD_U_UV_Head_Left')[0].firstElementChild.src = U.MD.C.getHeadImage(_userinfo.UserImageHead || _userinfo.UserThumbnailImageHead); //打印用户头像
- U.selectEl(_context[1]).find('.U_MD_U_UV_Name')[0].innerText = _userinfo.TrueName || _userinfo.UserName || "不详"; //打印用户名字
- U.selectEl(_context[1]).find('.U_MD_U_UV_Desc')[0].innerText = _userinfo.UserIndividualitysignature || "不详"; //打印用户介绍
- U.selectEl(_context[3]).find('.U_MD_U_UV_Place')[0].innerText = _userinfo.City || "不详"; //打印用户地址
- U.selectEl(_context[3]).find('.U_MD_U_UV_MailBox')[0].innerText = _userinfo.UserEmail != "null" ? _userinfo.UserEmail : "不详"; //打印用户邮箱
- U.selectEl(_context[3]).find('.U_MD_U_UV_PhoneNum')[0].innerText = TN ? (TN.substring(0, 3) + "****" + TN.substring(7, TN.length)) : "不详"; //打印用户的电话号码
- U.selectEl(_context[3]).find('.U_MD_U_UV_Birthday')[0].innerText = _userinfo.Birthday ? U.UF.D.formatDateToArray(_userinfo.Birthday).slice(0, 3).join('-') : "不详"; //打印用户的出生日期
- //获取文件统计数据
- U.A.Request(US.CD, [US.DB, 'UseStudio_Users', 'GetStatisticData', _userinfo.UserId], function (data) {
- U.selectEl('.U_MD_U_UV_Friend', _context[1])[0].innerText = data.value[0].friendCount;
- U.selectEl('.U_MD_U_UV_Word', _context[1])[0].innerText = data.value[0].wrodCount;
- U.selectEl('.U_MD_U_UV_Excel', _context[1])[0].innerText = data.value[0].excelCount;
- U.selectEl('.U_MD_U_UV_Cloud', _context[1])[0].innerText = data.value[0].diskFileCount;
- });
- //添加好友事件处理
- var _friendinfo,
- _addbutton = U.selectEl('.U_MD_U_UV_Head_Right_Btn', _context[1])[0],
- _functionbtn = U.selectEl(_context[2]).find('.U_MD_U_UV_FuncArea_MarginBox_Btn'); //获取三个按钮
- _functionbtn[1].style.display = '';
- if (_userinfo.UserId == US.userInfo.UserId) {
- _addbutton.onclick = function () {
- U.Alert("不可以添加自己为好友哟!");
- };
- _functionbtn[1].style.display = 'none';
- }
- else if (US.friend.friends && (_friendinfo = U.Json.select(US.friend.friends, { UserId: _userinfo.UserId })[0])) {
- _addbutton.onclick = function () {
- U.MD.F.R.deleteFriendForm(_friendinfo, function () {
- U.UF.F.closeWindow(_form);
- });
- //U.MD.F.M.deleteFriend(_friendinfo);
- //U.UF.F.closeWindow(_form); //关闭窗口函数
- };
- _addbutton.style.backgroundColor = '#e20f0f';
- _addbutton.innerText = '删除好友';
- } else {
- _addbutton.style.backgroundColor = '';
- _addbutton.onclick = function () {
- U.MD.F.M.addFriend(_userinfo, function () {
- U.UF.F.closeWindow(_form); //关闭窗口函数
- });
- }
- }
- //协同文档事件绑定
- _functionbtn[0].onclick = function () {
- U.MD.D.I.openApplication("disk", { "userid": _userinfo.UserId, "directoryid": US.disk.initTree[4][0] });
- }
- //协同他人文档事件绑定
- // _functionbtn[1].onclick = function () {
- // U.MD.D.I.openApplication("disk", { "userid": _userinfo.UserId, "directoryid": US.disk.initTree[2][0] });
- // }
- //发起对话事件绑定
- _functionbtn[1].onclick = function () {
- if (!U.MD.U.L.isLogin()) {
- var _friendinfo = U.Json.select(US.friend.friends, { UserId: _userinfo.UserId })[0];
- if (_friendinfo) {
- U.MD.F.W.popupFriendsForm(_friendinfo);
- U.UF.F.closeWindow(_form); //关闭窗口函数
- } else {
- U.UF.UI.confirm((_userinfo.UserNickName || _userinfo.UserName) + "还不是你的好友哟!是否添加" + (_userinfo.UserNickName || _userinfo.UserName) + "为好友呢。", function () {
- U.MD.F.M.addFriend(_userinfo, function () {
- U.UF.F.closeWindow(_form); //关闭窗口函数
- });
- });
- }
- }
- }
- }
- /**
- * 添加好友状态切换 暂无使用
- * @param {element} button 点击元素
- * @param {element} userinfo 用户信息
- */
- U.MD.U.V.AddFriend = function (button, userinfo) {
- U.MD.F.M.addFriend(userinfo, function () {
- button.innerText = '删除好友';
- button.style.backgroundColor = '#e20f0f';
- button.onclick = function () {
- _friendinfo = U.Json.select(US.friend.friends, { UserId: userinfo.UserId })[0];
- U.MD.F.M.deleteFriend(_friendinfo);
- button.innerText = '+好友';
- button.style.backgroundColor = '';
- button.onclick = function () {
- U.MD.U.V.AddFriend(button, userinfo);
- }
- };
- });
- }
- //滚动加载
- U.MD.U.V.GDCKYHDT = function (UDOD, userid) {
- _UDFE = U.MD.D.H.ET["UIF"][userid][1];
- U.MD.U.V.ViewUserBlogInfo(UDOD, _UDFE, userid, this.P + 2); //分页打印
- }
- //获取用户最新发表
- U.MD.U.V.ViewUserBlogInfo = function (UDOD, UDPE, userid, P, TF) {
- var _userinfoel = U.selectEl(UDOD).Child();
- UDPE = U.MD.D.D.FYGBL(UDPE, P); //U.UF.EL.getChildrenNoText()
- if (UDPE[0]) {
- if (TF) { _userinfoel[1].innerText = ""; }
- if (UDPE[0].length) { U.MD.D.Blog.PGBL(_userinfoel[1], UDPE[0], true); }
- else if (P === 1) { U.MD.U.V.PCKYHDT(_userinfoel[1]); }
- } //打印文章
- else { U.A.Request(US.USER, ["GFA", US.EMPTYGUID, (UDPE[1] - 1) * 100, UDPE[1] * 100, userid, US.EMPTYGUID], U.MD.U.V.AsynCKYHDT, [(P == 1 ? [_userinfoel[1], true] : [$("#U_MD_U_UV_PL")[0], 1]), UDOD, userid, P, UDPE[1], _userinfoel]); }
- //$("div#U_MD_U_UV_PC", _userinfoel[0])[0].onscroll = U.UF.EV.scrollLoad({ "AF": function () { U.MD.U.V.GDCKYHDT(_bloginfoel, userid); } }).SCH(); //滚动加载
- U.UF.EV.scrollLoad($("div#U_MD_U_UV_PC", _userinfoel[0])[0], function () { U.MD.U.V.GDCKYHDT(_bloginfoel, userid); }); //滚动加载
- }
- //异步获取最新的文章
- U.MD.U.V.AsynCKYHDT = function (r) {
- var _context = r.context,
- UPXD = U.MD.D.H.ET["UIF"][_context[2]];
- r = r.value;
- if (!UPXD) { UPXD = U.MD.D.H.ET["UIF"][_context[2]] = [], UPXD[1] = [] };
- UPXD[1] = UPXD[1] || [];
- UPXD[1][_context[4]] = U.MD.D.Blog.ZFSGBL(r);
- _context[5][1].innerText = "";
- _context[5][0].innerText = r[0] > 0 ? "动静..(" + r[0].SumNumber + ")" : "动静";
- U.MD.U.V.ViewUserBlogInfo(_context[1], UPXD[1], _context[2], _context[3]); //打印用户的文章
- }
- //用户资料没有发表文章
- U.MD.U.V.PCKYHDT = function (UDOD) {
- var _userinfoel = $$("div", { "className": "U_MD_U_UV_T" }, UDOD);
- $$("div", { "className": "U_MD_U_UV_TS", "innerHTML": "他暂时没有相关的消息呢!!稍后再来试试吧~" }, _userinfoel);
- $$("div", { "className": "U_MD_U_UV_TX", "innerHTML": "Noting!!" }, _userinfoel);
- }
- //群介绍
- U.MD.U.V.GroupInfo = function (groupinfo) {
- var _userinfoel = U.selectEl("#U_MD_U_GV").clone(true), // 用户信息元素
- _childs = U.selectEl(_userinfoel[0]).Child(),
- _content = _childs[0];
- U.MD.U.V.syncData(_content, groupinfo);
- var _form = new U.UF.UI.form("<div class='U_MD_F_S_TI'>群信息</div>",
- _content,
- {
- "style": {
- "min-width": "480px",
- "width": "480px",
- "height": "340px"
- },
- id: "U_MD_G_Info"
- },
- {
- isenlarge: false,
- isnarrow: false
- }).form;
- }
- //同步群介绍的数据
- U.MD.U.V.syncData = function (el, groupinfo) {
- var _head = el.children[0], //群介绍的头部
- _middle = el.children[1], //群介绍的中间部分
- _bottom = el.children[2], //群介绍的底部
- _groupId = groupinfo.GroupManageID, //群的ID
- _groupCreaterId = groupinfo.GroupManageCreateUserID, //群主的ID
- _groupCreaterEl = U.selectEl(_bottom).find('.U_MD_U_GV_GroupInfo_ImgArea_Creater')[0], //群主显示的元素
- _groupMember = U.Json.select(US.friend.groupusers, { GroupManageID: _groupId }), //群人数
- _cloneEl = $$('img'), //创建图片
- _createrImg = _cloneEl.cloneNode(), //克隆图片元素
- _groupMemberEl = U.selectEl(_bottom).find('.U_MD_U_GV_GroupInfo_ImgArea_MemberImg')[0], //群人数显示的元素
- _groupBtn = U.selectEl(_middle).find('.U_MD_U_GV_FuncArea_MarginBox_Btn'); //群的三个按钮
- U.selectEl(_head).find('.U_MD_U_GV_HeadInfo_Name')[0].innerText = groupinfo.GroupManageName; //群的名字
- U.selectEl(_head).find('.U_MD_U_GV_HeadInfo_Desc')[0].innerText = groupinfo.GroupManageDescript; //群的介绍
- U.selectEl(_bottom).find('.U_MD_U_GV_GroupInfo_Img_TextNum')[0].innerText = _groupMember.length; //群的人数
- _createrImg.src = U.MD.C.getHeadImage(U.Json.selectOne(US.friend.groupusers, { UserId: _groupCreaterId }).UserThumbnailImageHead) || "/img/UserHead/UseHead.jpg"; //群头像
- _groupCreaterEl.appendChild(_createrImg) //把群头像添加到元素里
- _groupCreaterEl.onclick = function () {
- U.MD.U.V.ViewOtherUserInfo(_groupCreaterId);
- }
- _groupBtn[2].onclick = function () {
- top.U.MD.F.W.popupFriendsForm(groupinfo);
- }
- for (var i = 0; i < _groupMember.length; i++) {
- if (i < 6) {
- var _cloneImg = _cloneEl.cloneNode();
- _cloneImg.src = U.MD.C.getHeadImage(_groupMember[i].UserThumbnailImageHead) || "/img/UserHead/UseHead.jpg";
- _cloneImg.onclick = U.UF.C.closure(function (i) {
- U.MD.U.V.ViewOtherUserInfo(_groupMember[i].UserId);
- }, [i])
- _groupMemberEl.appendChild(_cloneImg);
- } else {
- $$('span', {
- className: "U_MD_U_GV_GroupInfo_ImgArea_MemberMore", innerText: "···", onclick: function () {
- U.MD.U.V.showAllGroupMember(_groupMember, this, _cloneEl, _groupMemberEl);
- }
- }, _groupMemberEl);
- return;
- }
- }
- }
- U.MD.U.V.showAllGroupMember = function (groupmember, el, cloneel, addel) {
- addel.style.display = "none";
- addel.style.height = "82px";
- for (var i = 6; i < groupmember.length; i++) {
- var _cloneImg = cloneel.cloneNode();
- _cloneImg.src = U.MD.C.getHeadImage(groupmember[i].UserThumbnailImageHead) || "/img/UserHead/UseHead.jpg";
- _cloneImg.onclick = U.UF.C.closure(function (i) {
- U.MD.U.V.ViewOtherUserInfo(groupmember[i].UserId);
- }, [i]);
- addel.appendChild(_cloneImg);
- }
- addel.style.display = "block";
- U.selectEl(el).remove();
- }
- //#endregion;
- ///<jscompress sourcefile="ViewLogin.js" />
- Namespace.register("U.MD.U.L"); //用户登录的命名空间
- Namespace.register("U.MD.U.OT"); //用户登录的命名空间
- //#region 登录
- /*
- 问题:
- 1、验证码的接口问题
- 2、无窗体的接口
- */
- //#region 配置数据
- U.MD.U.L.loginCallBack; //登录后的回调使用
- U.MD.U.L.isLogining = false; //判断用户登录状态。cookie登录状态为cookie,账号登录为true,没有登录为false
- //#endregion
- /**
- * 弹出登录注册
- *
- * @param {int} type==3:登录页面,type==1:注册页面,type==2:找回密码页面
- * @param {function} cb为回调函数
- * @returns {boolean} 是否登录
- */
- U.MD.U.L.login = U.MD.U.L.DLTC = function (fun) {
- var _iframe = U.selectEl("#U_MD_HomeC_Pop iframe")[0];
- if ($("#U_MD_HomeC_Pop")[0]) {
- U.UF.F.windowTopCenter($("#U_MD_HomeC_Pop")[0]);
- try {
- //登录有的其他回调,如,登陆后直接打开好友聊天等
- if (U.UF.C.isFunction(fun)) {
- U.MD.U.L.loginCallBack = fun; //回调处理
- }
- U.selectEl("input", _iframe.contentWindow.document)[0].focus();
- _iframe.contentWindow.U.MD.U.L.init();
- }
- catch (e) { }
- }
- else {
- var _iframe = $$("iframe", { "style": { "border": "0", "float": "left" }, "id": "UI_Login", "name": "UI_Login", "frameborder": "no", "border": "0", "scrolling ": "no", "width": "360px", "height": "480px", "src": "//user.1473.cn/Login.htm" });
- new U.UF.UI.form("", _iframe,
- {
- "id": "U_MD_HomeC_Pop",
- "style": {
- "width": "360px",
- "height": "510px"
- }
- },
- {
- isdrag: false,
- isstretching: false,
- isenlarge: false,
- isnarrow: false
- });
- //跨域回调设置
- U.UF.DL.iframeLoad(_iframe, function () {
- //登录有的其他回调,如,登陆后直接打开好友聊天等
- if (U.UF.C.isFunction(fun)) {
- U.MD.U.L.loginCallBack = fun; //回调处理
- }
- _iframe.contentWindow.U.MD.U.L.loginCallBack = U.MD.U.L.defaultCallBack; //设置登录回调
- });
- }
- return _iframe;
- }
- /**
- * 打开注册窗体
- */
- U.MD.U.L.register = function (fun) {
- var _iframe = U.MD.U.L.login();
- try {
- _iframe.contentWindow.U.MD.U.R.register();
- }
- catch (e) {
- U.UF.DL.iframeLoad(_iframe, function () {
- //登录有的其他回调,如,登陆后直接打开好友聊天等
- if (U.UF.C.isFunction(fun)) {
- U.MD.U.L.loginCallBack = fun; //回调处理
- }
- _iframe.contentWindow.U.MD.U.L.loginCallBack = U.MD.U.L.defaultCallBack; //设置登录回调
- _iframe.contentWindow.U.UF.N.addHash('register'); //添加hash的处理
- });
- }
- }
- /**
- * 打开找回密码窗体
- */
- U.MD.U.L.retrieve = function () {
- var _iframe = U.MD.U.L.login();
- try {
- _iframe.contentWindow.U.MD.U.F.findPassword();
- }
- catch (e) {
- U.UF.DL.iframeLoad(_iframe, function () {
- _iframe.contentWindow.U.UF.N.addHash('findPassword'); //添加hash的处理
- });
- }
- }
- /**
- * 登录异步
- *
- * @param {object} 服务器返回的值
- * @param {boolean} 是否是cookie登录
- */
- U.MD.U.L.defaultCallBack = function (r, iscookie) {
- var _userinfo, //用户个人信息
- _backgroudimage, //背景图片
- _str, //输出的提示
- _context = r.context, //回调参数
- _address = _context[1], //触发函数的地址
- _username = _context[2], //用户名
- _password = _context[3]; //密码
- //登录后台返回的数据
- r = r.value;
- //判断登录状态
- switch (r) {
- case null:
- _str = "系统繁忙!请重试";
- break; //系统繁忙
- case 0:
- _str = "帐号不存在!";
- break;
- case 1:
- _str = "密码错误!";
- break; //帐号密码错误
- case 2:
- _str = "该用户不允许被访问!请联系管理员";
- break; //用户给禁用
- default:
- if (r) {
- //登录有的其他回调,如,登陆后直接打开好友聊天等
- U.MD.U.LO.emptyUserInfo(); //登陆的时候先清空用户信息,防止前面登陆用户的信息有冲突
- //如果刚刚登陆的时候没有用户的地址,这里重新获取,然后向后台发送
- if (!_address) {
- U.UF.CI.getUserLocation(U.MD.U.L.addUserAccess); //客户端信息加载,好像只加载了新浪ip地址?
- }
- _userinfo = U.MD.U.L.setUserInfo(r); //设置用户基本信息,包括用户信息,好友信息
- U.MD.U.L.getLoginUserInfo(_username || US.userInfo.UserName); //去获取用户详细信息
- if ($("#U_MD_D_BDI")[0] && U.selectEl('#U_MD_D_BG')[0]) {
- //登录有用户的信息展示到页面中,包括背景图片、用户头像等
- U.MD.U.L.printUserInfo(); //用户头部头像个人信息
- _backgroudimage = U.MD.D.B.split(US.userInfo.UserBackGroundImage); //拆分用户的背景图片,里面包含了图片地址和展示的格式
- U.MD.D.B.setBackgroundImage(_backgroudimage[0], _backgroudimage[1]); //设置用户背景图,以后需修改为设置用户桌面信息
- }
- //Cookie登录,即使密码错误也不弹出错误信息。
- if (_str && iscookie !== true) {
- U.alert(_str); //登录提示处理
- }
- //如果弹出了登录框,那么给登录框进行处理
- if ($("#U_MD_HomeC_Pop")[0]) {
- //登录框的样式还原
- U.selectEl("#U_MD_HomeC_Pop")[0].close(); //关闭登陆款
- }
- U.MD.O && U.MD.O.P.connect();
- }
- // _str = "登录成功";
- }
- if (_str) {
- U.alert(_str);
- }
- }
- /**
- * 判断用户是否登录如果未登陆则弹出登陆框
- *
- */
- U.MD.U.L.isLogin = function (fun) {
- if (!US.userInfo.UserId) { //判断用户id是否存在
- U.MD.U.L.login(fun); //用户登录函数
- return true; //用户未登录返回false
- }
- return false; //用户登录返回true
- }
- /**
- * 登录调用回调使用
- * @param {function} 回调函数
- *
- */
- U.MD.U.L.setLoginCallBack = function (fun) {
- //未登录要求登录
- if (U.MD.U.L.isLogin()) {
- U.MD.U.L.loginCallBack = fun;
- }
- //登录直接转发
- else {
- fun();
- return true;
- }
- }
- //#endregion
- //#region cookie登录
- /*
- 功能:1473.cn域下各个应用的用户通过Cookie自动登录,Cookie登录入口。支持跨域
- */
- U.MD.U.L.cookieLogin = function () {
- var _cookie = U.MD.U.L.getCookieByUserId(), //获取用户的云端Cookie,选取最后一个账号进行登录。
- _address = US.city.userAllLocation || ""; //找到自己登陆用户的地址
- //如果获取到cookie的值,那么就进行cookie登陆
- if (_cookie && _cookie.userid && _cookie.userid.length == 36) {
- U.MD.U.L.isLogining = "cookie"; //设置cookie登陆状态
- U.A.Request(US.USER, ["LoginByCookie", _cookie.userid, _cookie.username], U.MD.U.L.defaultCallBack, ["", _address]); //调用cookie登陆处理
- }
- }
- /*
- 功能:获取用户cookie,云端cookie关键字为usestudiosso,格式为
- Loginid:登录id
- userstamp:账号13928417148的值为"1364812396"?奇怪?
- userid:云端用户id
- username:云端用户名
- 如果不传入参数,默认获取最后一个,否则获取传入userid的账号进行登录。
- 参数一:userid代表用户id。传入用户id,则判断cookie中是否有该账号,并使用该账号登录。
- */
- U.MD.U.L.getCookieByUserId = function (userid) {
- var i, _cookiearr = U.MD.U.L.cookieToArray("usestudiosso"); //获取保存的cookie值。
- //如果传入参数userid并且cookie中有userid。则判断是否是自己的账号登录。
- if (_cookiearr.userid) {
- //如果传了userid,那么就根据userid找
- if (userid) {
- //数组里匹配
- for (i = 0; i < _cookiearr.userid.length; i++) {
- if (_cookiearr.userid[i] == userid) {
- break;
- }
- }
- }
- //否则找到最后一个登陆用户的信息
- else {
- //允许多用户登录,则用户id减少一?
- i = _cookiearr.userid.length - 1;
- }
- //循环所有Cookie。
- for (var c in _cookiearr) {
- //对中文进行解密。_cookiearr[c]中可能有多个userid,只获取最后选中的第i个。返回的数据在这里做了处理。
- _cookiearr[c] = decodeURIComponent(_cookiearr[c][i]);
- }
- }
- //返回的集合包括了Loginid:登录iduserstamp:账号13928417148的值为"1364812396"?奇怪?userid:云端用户idusername:云端用户名
- return _cookiearr;
- }
- /**
- *1473cookie格式专用
- * 把形如:"userid=72854d28-f45c-48d7-92b7-3cd933e03022&username=13928417148&Loginid=fd02976d-993b-4437-bbd9-5efa99802c8f&userstamp=1364812396"的cookie转换为json对象。函数名有问题。
- 得到的形式为:_UAE.Loginid可得到用户id。
- *
- * @param {string} 获取cookie的key对应的值 如usestudio=aa=ff&ss=aa 的usestudio里的 aa=ff&ss=aa
- * @return {object} {key:[value1,value2]}
- */
- U.MD.U.L.cookieToArray = function (key) { //获取cookie
- var i, //循环初始化
- _cookieobj = {}, //初始化对象 作为返回值
- _cookie = U.UF.Cookie.get("usestudiosso"); //获取用户指定的Cookie值
- if (_cookie) { //是否存在
- _cookie = _cookie.split("&");
- for (i = 0; i < _cookie.length; i++) { //循环对应的值
- _cookie[i] = _cookie[i].split("="); //切分key和value
- //如果定义了cookie值的接受数组,则不再重复定义。_cookie[i][0]相当于key,例如userid
- if (!_cookieobj[_cookie[i][0]]) {
- _cookieobj[_cookie[i][0]] = [];
- }
- _cookieobj[_cookie[i][0]].push(decodeURIComponent(_cookie[i][1])); //生成{key:[value1,value2]}
- }
- }
- return _cookieobj;
- }
- //#endregion
- //#region 登录数据使用
- /**
- * 为了以后的扩展,给其他系统获取完整的用户信息,获取用户登录数据,后面还有一个登陆获取用户个人信息。好友信息,及消息通知,逻辑有问题。
- * @param {string} 用户名
- *
- */
- U.MD.U.L.getLoginUserInfo = function (username) {
- U.A.Request(US.USER, ["GetUserLoginData", username], U.MD.U.L.asynGetLoginUserInfo);
- }
- /**
- * 异步获取数据
- * @param {object} ajax返回的数据值
- *
- */
- U.MD.U.L.asynGetLoginUserInfo = function (r) {
- r = r.value; //得到登录用户的数据
- US.friend = r; //返回的r里面是用户的好友信息 包括 {"className":好友分组信息,friends:好友信息,group:好友群,groupusers:群好友,recentcontacts:最近联系人,unreadfirendmessage:未读好友消息,unreadgroupmessage:未读群消息,commonfriend:推荐好友}
- U.MD.U.L.initUserLogin(US.userInfo); //登录初始化应用
- if (U.MD.D && U.MD.D.IsUseStudio || U.selectEl("#usestudio_server")[0]) {
- U.MD.F && U.MD.F.N.friendMessageHandle([r.unreadfirendmessage, r.unreadgroupmessage]); //用户消息区域
- }
- }
- /**
- * 添加用户初始化资料信息
- * @param {array} 登录用户的数据
- *
- */
- U.MD.U.L.setUserInfo = function (userinfo) {
- US.userInfo = userinfo[0]; //给用户信息全局变量赋值。
- US.userInfo.LoginId = userinfo[2]; //用户前后台更新数据唯一识别id
- US.friend.onlinefirendinfo = userinfo[1]; //添加在线信息。
- return US.userInfo;
- }
- //登录成功执行事件
- U.MD.U.L.initUserLogin = function () {
- var _userinfo = US.userInfo; //初始化用户资料
- U.MD.UI && U.MD.UI.flashEmptyUpload && U.MD.UI.flashEmptyUpload(); //清理上传文件
- //登录有的其他回调,如,登陆后直接打开好友聊天等
- if (U.UF.C.isFunction(U.MD.U.L.loginCallBack)) {
- U.MD.U.L.loginCallBack(_userinfo); //回调处理
- }
- U.MD.F && U.MD.F.initFriend(); //初始化好友
- //如果没有用url指引,同时又是1473的项目,那么弹出云盘,否则只是加载数据
- if (U.MD.D && U.MD.D.IsUseStudio) {
- U.MD.D.I.openApplication("disk", { "userid": _userinfo.UserId, "directoryid": US.FTPFOLDERID }); //弹出云盘的数据。
- }
- //外部加载1473框架的都会带有usestudio_server 这个元素,当用户没有填写邮箱信息的时候,同时是在1473主站点的,那么就弹出用户
- if (!US.userInfo.UserEmail && !$("#usestudio_server")[0]) {
- U.MD.U.P.userDataSet(); //用户数据加载
- }
- }
- /**
- * 添加用户登录信息
- *
- */
- U.MD.U.L.addUserAccess = function () {
- //如果用户的城市信息不存在,则添加用户用户城市信息,应该不只是单单判断地址,此处逻辑还需要整理!
- if (US.city.userAllLocation) {
- U.A.Request(US.USER, ["RecordUserClientInfo", US.userInfo.UserName, "", "", US.city.userAllLocation, ""],
- function () { }); //异步添加地址信息
- }
- }
- /**
- * 打印用户的信息
- *
- */
- U.MD.U.L.printUserInfo = function () {
- var _childel,
- _userinfo = US.userInfo, //用户的信息
- _userimage = U.MD.C.getHeadImage(_userinfo.UserThumbnailImageHead), //获取用户头像
- _el = U.selectEl("#U_MD_D_BDI"); //头像打印的区域
- if (_el[0]) {
- //设置头部的样式变化
- _el.addAttrArray({
- "className": "U_MD_D_BDI"
- })[0];
- //如果已经有头像了,那么直接修改头像
- if (_el.find("img")[0]) {
- //设置头像处理
- _el.find("img").addAttrArray({
- "onerror": U.MD.C.imgError,
- "title": _userinfo.UserNickName,
- "onclick": function () {
- U.MD.D.I.openApplication("set");
- },
- "src": U.MD.C.getHeadImage(_userinfo.UserThumbnailImageHead)
- });
- }
- //创建头像的处理
- else {
- $$("img", {
- "onerror": U.MD.C.imgError,
- "onerror": U.MD.C.imgError,
- "title": _userinfo.UserNickName,
- "onclick": function () {
- U.MD.D.I.openApplication("set");
- },
- "src": U.MD.C.getHeadImage(_userinfo.UserThumbnailImageHead)
- }, _el[0])
- }
- _childel = U.selectEl("#U_MD_D_BDL").Child();
- _childel[0].style.display = _childel[1].style.display = "none";
- _childel[2].style.display = "block";
- }
- }
- //#endregion
- //#region 外链登录
- /**
- * 填写登录信息
- *
- * @param {array} 登录值参数
- * @param {array} 回调函数
- */
- U.MD.U.L.perfectUserInfo = function (userinfo, username) {
- if ($("#U_MD_U_OT_B_Pop")[0]) {
- U.UF.F.windowTopCenter($("#U_MD_U_OT_B_Pop")[0]);
- }
- else {
- var _iframe = $$("iframe", { "style": { "border": "0", "float": "left" }, "id": "U_MD_U_OT_B_Iframe", "name": "UI_Login", "frameborder": "0", "width": "400px", "height": "290px", "src": "//user.1473.cn/CompleteInformation.htm" });
- new U.UF.UI.form("", _iframe,
- {
- "id": "U_MD_U_OT_B_Pop",
- "style": {
- "width": "400px",
- "height": "340px"
- }
- },
- {
- isdrag: false,
- isstretching: false,
- isenlarge: false,
- isnarrow: false
- });
- //跨域回调设置
- U.UF.DL.iframeLoad(_iframe, function () {
- if ($("#U_MD_HomeC_Pop")[0]) {
- U.selectEl("#U_MD_HomeC_Pop")[0].close();
- }
- _iframe.contentWindow.U.MD.U.L.loginCallBack = U.MD.U.L.defaultCallBack; //设置登录回调
- _iframe.contentWindow.U.MD.U.OT.perfectUserInfoInit(userinfo, username); //设置登录回调
- });
- }
- }
- //#endregion
- ;
- ;
- ///<jscompress sourcefile="Advertisement.js" />
- /*
- 广告使用区域
- */
- Namespace.register("U.UF.DL.C.AD"); //桌面广告命名空间
- //#region 百度广告
- /*
- * 百度异步加载
- *
- * @param {string} 广告id
- */
- U.UF.DL.C.AD.onloadBaiduJs = function (baiduid) {
- U.UF.DL.asynLoadJs({ "src": "//hm.baidu.com/hm.js?" + baiduid }); //加载广告
- }
- /*
- * 百度异步加载
- *
- * @param {string} 广告位置id
- * @param {string} 广告id
- */
- U.UF.DL.C.AD.baidu = function (elementid, baiduid) {
- if (baiduid) { //异步加载
- U.UF.DL.asynLoadJs({ type: "text/javascript", src: "http://cbjs.baidu.com/js/m.js" },
- function () {
- U.UF.DL.C.AD.asynBaidu(elementid, baiduid);
- }); //异步加载
- }
- }
- /*
- * 异步广告
- *
- * @param {string} 广告位置id
- * @param {string} 广告id
- */
- U.UF.DL.C.AD.asynBaidu = function (elementid, code) {
- BAIDU_CLB_fillSlotAsync(code, elementid);
- }
- //#endregion
- //#region
- /*
- * 异步阿里妈妈广告
- *
- * @param {string} 广告位置id
- */
- U.UF.DL.C.AD.alimama = function (obj) {
- //阿里巴巴官网实例
- var i,
- _aliobj = window.alimamatk_onload = window.alimamatk_onload || [];
- if (Array.isArray(obj)) {
- for (i = 0; i < obj.length; i++) {
- U.UF.DL.C.AD.alimama(obj[i]);
- }
- }
- else {
- _aliobj.push(U.UF.C.isObject(obj) ? obj : (obj = { pid: obj, appkey: "", unid: "", type: "click" }));
- } //加载广告
- if (!window.alimamatk_show) {
- U.UF.DL.asynLoadJs({ type: "text/javascript", id: obj.pid, charset: "gbk", async: true, src: "http://a.alimama.cn/tkapi.js" });
- }
- }
- /*
- * 阿里妈妈广告异步
- *
- * @param {string} 广告位置id
- */
- U.UF.DL.C.AD.asynAlimama = function (el, id) {
- $$("a", { style: { "display": "none!important" }, id: "tanx-a-" + id }, el); //显示元素
- U.UF.DL.asynLoadJs({
- type: "text/javascript", id: "tanx-s-" + id, async: true,
- charset: "gbk", async: true, src: "http://p.tanx.com/ex?i=" + id
- }); //加载广告
- }
- //#endregion
- ;
- ///<jscompress sourcefile="Common.js" />
- Namespace.register("U.MD.C");
- /**
- * 图片错误处理
- *
- * @param {element} 图片元素
- * @param {number} 判断的类型
- */
- U.MD.C.imgError = function (imgel, type) {
- var _number, //存放参数
- _url; //存放图片的src
- //获取出错的对象
- imgel = imgel && !imgel.srcElement ? imgel : (event ? event.srcElement || this : this);
- //如果是错误图片就不执行
- if (imgel.src != "/img/error.png") {
- if (type == 2) { //重复请求图片 用于初始上传的图片
- _url = imgel.src; //图片的路径
- _number = _url.indexOf("?&n="); //判断是否添加获取
- //允许文件同时获取10次
- if (_number < 0 || _url.length - _number < 10) {
- imgel.src += (_number == -1 ? "?&n=" : "") + 1; //添加缓存过滤
- return
- }
- else {
- type = 1;
- }
- }
- if (type == 1) { //错误图像处理
- U.selectEl(imgel).addAttrArray({ "src": "/img/error.png" });
- }
- else { //错误头像处理
- imgel.src = type || "/img/UserHead/UseHead.jpg";
- }
- }
- }
- /**
- * 获取头像图片的正确地址
- *
- * @param {string} 需要生成正常地址的 由于1473的地址 需要带上 http://fs.1473.cn 无需 这里同时处理了 1473和外链地址
- * @return {string} 过滤过的
- */
- U.MD.C.getHeadImage = function (url) {
- return (!url ? "/img/UserHead/UseHead.jpg" : !url.indexOf("http") ? url : ((url.indexOf("www.1473.cn") > -1 ? url : US.FILESYSTEMURL + url.replace(new RegExp(US.FILESYSTEMURL, "gm"), ""))));
- };
- ///<jscompress sourcefile="DataCrossdomain.js" />
- Namespace.register("U.MD.CD"); //完全跨域的解决方案
- //是否加载完成
- U.MD.CD.isLoad;
- //跨域传输的数据
- U.MD.CD.data;
- //如果不是1473的域名访问的处理
- if (!window.location.host.indexOf("www.1473.cn")) {
- //错误处理,前端错误需要在控制台输出,同时提交到错误数据库
- //window.onerror = function(sMessage,sUrl,sLine,columnNumber,errorObj){};
- //onerror函数的五个参数用于确定错误确切的信息,代表的意思依次为:
- //* @param {String} errorMessage errorMessage 错误信息
- //* @param {String} scriptURI 出错的文件
- //* @param {Long} lineNumber 出错代码的行号
- //* @param {Long} columnNumber 出错代码的列号
- //* @param {Object} errorObj 错误的详细信息,Anything
- window.onerror = function (errorMessage, scripturi, linenumber, columnnumber, errorobj) {
- errorobj = errorobj || {}; //屏蔽js错误
- U.A.Request(US.USER, ["SetError", 0, (event.errorMessage || event || errorMessage), (scripturi || event.filename || event.errorUr) + "。行号:" + (linenumber || event.lineno || event.errorLine)], function () { }, []); //错误消息发送到数据库
- U.UF.C.console(event.errorMessage || event || errorobj); //console 输出错误信息
- return true; //不让浏览器弹出错误报告,浏览器会弹出一个comfirm的错误。
- }
- //加载所有的跨域
- U.UF.CD.loadAjaxCrossDomain(function () {
- U.MD.CD.isLoad = true; //设置跨域加载成功处理
- U.MD.CD.load(); //加载成功后的处理
- });
- //跨域执行ajax处理 fun, issender, iframeid, url, id
- U.MD.CD.me = new U.UF.EV.message(function (data, id, cookie) {
- U.MD.CD.data = [data, id]; //跨域传输的数据
- U.MD.CD.load(); //加载的处理
- }, false, "domain");
- //发送请求获取数据
- U.MD.CD.load = function () {
- //如果加载完,同时有传输数据的处理
- if (U.MD.CD.isLoad && U.MD.CD.data) {
- var _data = U.MD.CD.data[0], //传参的值
- _url = _data[0], //需要请求的url
- _params = _data[1]; //需要请求的参数
- try {
- //做www.1473.cn的用户安全的。以后再扩展
- US.userInfo = US.userInfo.UserId ? US.userInfo : {
- "LoginId": U.UF.Cookie.get("usestudiosso", "loginid")[0],
- "UserId": U.UF.Cookie.get("usestudiosso", "userid")[0]
- };
- }
- catch (e) { }
- //当a.com要调用b.com的时候,把a.com的ajax转向到b.com中去访问。boomyun是用到这里的.
- U.A.Request(_url, _params, function (r) {
- var _cookie = U.UF.Cookie.get("usestudiosso");
- //设置登录信息
- if ("LoginByCookie,uploadUserinfo".indexOf(_params[0]) > -1 && r.value && r.value[0]) {
- US.userInfo = r.value[0];
- US.userInfo.LoginId = r.value[2];
- }
- //数据发送获取
- U.MD.CD.me.post(r.value, U.MD.CD.data[1], "usestudiosso=" + (_cookie || ""));
- });
- }
- }
- }
- ;
- ///<jscompress sourcefile="PageCrossdomain.js" />
- Namespace.register("U.MD.CD");
- //ui页面跨域处理 data[0] = 1473删除的data数据 [1] = 1473传输过来的函数唯一识别id [2] = cookie
- U.MD.CD.me = new U.UF.EV.message(function (data, id) {
- //获取加载1473 index.aspx里面的内容
- U.UF.CD.loadPageCrossDomain(function () {
- //把数据发送到发送者页面
- U.MD.CD.me.post(document.body.innerHTML, id, "usestudiosso=" + (U.UF.Cookie.get("usestudiosso") || ""));
- });
- }, false, "pagedomain");
- ;
- ///<jscompress sourcefile="Switch.js" />
- //#region 切换效果区域
- Namespace.register("U.UF.MR");
- /**
- * input搜索框变化
- *
- * @param {element} 变化的input元素
- * @param {array} 变化的数组 实现数组 0 、 1 切换
- -----------[0] 变化前的值 如 "请输入内容"
- -----------[1] 变化后的值 如 ""
- */
- U.UF.MR.inputPlaceholder = function (el, str, changestr) {
- if (typeof str == "string") {
- str = { color: "#999", value: str };
- }
- if (typeof changestr == "string") {
- changestr = { color: "#000", value: changestr };
- }
- //聚焦操作
- if (str.value == "") {
- //当前value为默认提醒内容
- if (el.value == "") {
- el.value = changestr.value;
- el.style.color = str.color;
- }
- }
- //失焦操作
- if (changestr.value == "") {
- el.style.color = changestr.color;
- if (el.value == str.value) {
- el.value = "";
- }
- }
- }
- //#endregion
- ;
- ///<jscompress sourcefile="Permission.js" />
- US.permission = {}; //所有的权限列表
- //网盘所有的权限
- US.permission.disk = {
- "isopen": true, //是否允许打开, 现在所有的文件都有打开权限
- "isupadte": true, //是否允许修改, 只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- "isdelete": true, //是否允许删除, 只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- "iscopy": true, //是否允许复制,现在所有的文件都有复制权限
- "isshear": true, //是否允许剪切,只有自己的文件,他人添加文件或者文件夹到我的ftp中,或者是我作为群主的群文件
- "isencryption": false, //是否允许加密,展示取消这个功能。
- "isreply": true, //是否允许加密,展示取消这个功能。
- "isdownload": true, //是否允许下载,只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- "isnew": true, //是否允许新建, 只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- "ispaste": true, //是否允许粘贴,只有自己的文件夹,或者是任何人的ftp文件夹下及下的文件夹,或者是群里
- "isrefresh": true, //是否允许刷新, 现在所有的文件都有刷新权限
- "isupload": true, //是否允许上传,文件夹设置了不允许下载的文件夹和文件夹下的所有文件都不允许下载,其他都有权限
- "isview": true, //是否允许视图切换,所有的文件夹都支持
- "isedit": true //是否允许编辑,只有拥有可修改权限的文本文件才能修改
- };
- //网盘权限获取方法
- US.permission.getDiskPermission = function () {
- var i, _obj = {}, _p = US.permission.disk;//定义变量i,返回值对象_obj,获取全局的初始权限对象
- for (i in _p) {//定义循环,将全局权限对象克隆给_obj
- _obj[i] = _p[i]
- }
- return _obj;//返回_obj对象
- };
- ///<jscompress sourcefile="Timer.js" />
- Namespace.register("U.MD.C.T"); //桌面计时器命名空间
- U.MD.C.T.timer = null; //计时器
- /*
- * 计时器使用
- *
- */
- U.MD.C.T.onesetInterval = function () {
- var _num = 0; //定义一个时间计数变量
- clearInterval(U.MD.C.T.timer); //防止多次启动计时器,这里是清除可能的计时器
- //初始化计时器处理
- U.MD.C.T.timer = setInterval(function () {
- var _userid = US.userInfo.UserId; //登录用户的id
- if (!(_num % 60)) { //每一分钟计数清空,防止页面运行太久计数太大,导致超过了js最大数
- _num = 0;
- }
- //执行每隔五秒与服务器通讯一次
- if (_userid) { //已经登录用户获取聊天消息
- U.MD.F.N.messageService(_userid); //执行与服务器通讯函数
- }
- }, 5000); //执行计时消息
- };
- ///<jscompress sourcefile="Upload.js" />
- Namespace.register("U.MD.UI"); //Disk上传的命名空间
- //#region 上传区域 Html5 Flash html
- //整个控件的名字规范函数名字
- /**
- * 上传带界面的函数
- * @param {string} url为服务器地址
- * @param {function} 回调函数
- * @param {function} 判断hash值回调函数
- * 回调函数返回结果:url为服务器地址返回的值。
- */
- U.MD.UI.upload = function (url, cb, hashcallback) {
- //如果有flash,则走flash。
- var _str = U.UF.CI.isSupportFlash(); //得到客户端支持html还是flash的处理
- //_str = "Flash";
- //html5的处理和html的处理,如果html,不能断点续传,不能解析md5.
- if (_str == "HTML5") {
- U.MD.UI.upload.html5(url, cb, hashcallback);
- }
- //flash的处理
- else if (_str == "Flash") {
- U.MD.UI.upload.flash(url, cb, hashcallback);
- }
- //只能通过input上传的处理
- else {
- U.MD.UI.upload.input(url, cb, hashcallback);
- }
- }
- //所有的上传框选择的文件处理
- U.MD.UI.upload.uploadFileInfo = [];
- /**
- * HTML5上传
- * @param {string} url为服务器地址
- * @param {function} 回调函数
- * @param {function} 判断hash值回调函数
- * 回调函数返回结果:url为服务器地址返回的值。
- */
- U.MD.UI.upload.html5 = function (url, cb, hashcallback) {
- //如果是html5,走html5
- U.MD.UI.create(); //创建传出上传框
- var _clickuploadel = U.selectEl("#U_MD_UI_UP_DRT")[0]; //获取上传按钮的处理
- _clickuploadel.innerText = "";
- //创建一个input file
- $$("input", {
- "multiple": "true", "type": "file", "accept": "*/*", "onchange": function () {
- U.MD.UI.inputSelect({
- //错误处理
- error: function (r) {
- console.log("上传错误:" + r);
- },
- //获取hash回调
- getHashCallBack: function (filehash, fileinfo, callback) {
- //判断获取hash
- hashcallback(filehash, fileinfo, function (isupload) {
- //判断是否上传的处理
- if (isupload) { //如果md5匹配后还是要求上传,那么这里就处理上传
- //判断数据库是否有该文件hash值 回调参数(文件服务器名,服务器文件大小)
- U.UF.UP.html5Upload.select(fileinfo, filehash, function (fileservername, filesize) {
- //上传处理
- U.UF.UP.html5Upload.loop(fileinfo, filehash, fileservername, filesize, function (value) {
- //上传成功的处理
- if (value == true) {
- callback.getData(filehash, fileservername, fileinfo); //得到返回值处理
- var _nextuploadfile = U.MD.UI.delUploadFile(fileinfo.fileel, fileinfo); //删除上传成功后的文件,得到下一个需要上传的文件
- // 如果有下一个文件要上传的处理
- if (_nextuploadfile) {
- U.MD.UI.inputUpload(_nextuploadfile, callback);
- }
- }
- //上传中的处理
- else {
- callback.progress(value, fileinfo.fileid, "上传中"); //生成进度条
- }
- });
- });
- }
- else {
- var _nextuploadfile = U.MD.UI.delUploadFile(fileinfo.fileel, fileinfo); //删除上传成功后的文件,得到下一个需要上传的文件
- // 如果有下一个文件要上传的处理
- if (_nextuploadfile) {
- U.MD.UI.inputUpload(_nextuploadfile, callback);
- }
- }
- });
- },
- //获取进度条
- progress: U.MD.UI.progress, //上传文件的进度条处理
- //得到服务器返回值的处理
- getData: function (filehash, fileservername, file) {
- var _type = file.name.substring(file.name.lastIndexOf('.') + 1, file.name.length), //获取文件后缀名
- _thumbnailname = 'gif|jpg|jpeg|png'.indexOf(_type.toLowerCase()) > -1 ? (Guid.newGuid() + "." + _type) : null; //判断是否为图片
- //如果是图片则创建缩略图
- if (_thumbnailname) {
- U.A.Request(US.DISK, ['CreateThumbnail', fileservername, _thumbnailname], function (r) { });
- }
- //添加文件到数据库
- U.A.Request(US.CD, [US.DB, 'UseStudio_Disk', 'CreateUploadFile', U.UF.C.queryString("UserId", url), file.fileid, U.UF.C.queryString("DirectoryId", url), file.name, fileservername, _thumbnailname, filehash, file.size, 1, file.name, _type, U.UF.C.queryString("Encrypt", url)],
- function (request) {
- cb({ data: [fileservername, fileservername, file.fileid, file.size, U.UF.C.queryString("Encrypt", url), U.UF.C.queryString("DirectoryId", url)] }, file);
- });
- }
- });
- this.value = "";
- }, "style": { "cssText": "display: block; position: relative; width: 100%; height: 100%; cursor: pointer; border: 0; color: #666; background: #eee; -moz-user-select: -moz-none; -webkit-user-select: none; opacity: 0; filter: alpha(opacity=0); -moz-opacity: 0;" }
- }, _clickuploadel);
- }
- /**
- * Flash上传
- * @param {string} url为服务器地址
- * @param {function} 回调函数
- * @param {function} 判断hash值回调函数
- * 回调函数返回结果:url为服务器地址返回的值。
- */
- U.MD.UI.upload.flash = function (url, cb, hashcallback) {
- U.MD.UI.create(); //创建传出上传框
- var _url = url,
- _cb = cb,
- _hashcallback = hashcallback,
- _clickuploadel = U.selectEl("#U_MD_UI_UP_DRT")[0]; //获取上传按钮的处理
- _clickuploadel.innerText = "";
- //添加flash按钮
- U.UF.UP.addFlashUploadBottom(_clickuploadel, "flashupload", { "width": _clickuploadel.clientWidth, "height": _clickuploadel.offsetHeight }, {
- error: U.MD.UI.flashError, //错误处理回调函数
- /**
- * 选择文件回调函数
- * @param {array} filesinfo
- */
- select: function (filesinfo) {
- U.MD.UI.flashSelect(filesinfo, _url, U.UF.C.isFunction(_hashcallback)); //选择文件的处理
- },
- /**
- * 上传文件获取文件流后的处理
- * @param {string} 文件的md5值
- * @param {string} 需要上传的文件的唯一识别id
- */
- getHashCallBack: function (md5, fileid) {
- var _fileinfo = U.MD.UI.getFileInfoById(fileid)[0];
- //判断获取hash
- _hashcallback(md5, _fileinfo, function (isupload) {
- //判断是否上传的处理
- if (isupload) { //如果md5匹配后还是要求上传,那么这里就处理上传
- //直接执行文件的上传处理
- U.UF.UP.flashUpload($("*flashupload")[0], fileid, _url);
- }
- else { //否则执行下一个上传的处理
- U.MD.UI.flashContinueUpload(fileid, _url, U.UF.C.isFunction(_hashcallback));
- }
- });
- },
- progress: U.MD.UI.progress, //上传文件的进度条处理
- uploadComplete: U.MD.UI.flashUploadComplete, //单个文件上传成功的回调函数
- //单个文件上传成功后,得到服务器的响应值处理,和CP不一样的是这里是得到了返回值,上面的只是文件已经传输到服务器了。
- /**
- * 上传文件成功返回上传文件值
- * @param {object} 获取服务器返回值
- * @param {string} 上传文件的唯一识别id
- */
- getData: function (r, fileid) {
- if (U.UF.C.isFunction(_cb)) {
- _cb(r, U.MD.UI.getFileInfoById(fileid)[0]);
- }
- //否则执行下一个上传的处理
- U.MD.UI.flashContinueUpload(fileid, _url, U.UF.C.isFunction(_hashcallback));
- },
- endUpload: U.MD.UI.deleteUploadAllFile //结束上传后释放资源
- }, "*");
- }
- /**
- * input上传
- * @param {string} url为服务器地址
- * @param {function} 回调函数
- * @param {function} 判断hash值回调函数
- * 回调函数返回结果:url为服务器地址返回的值。
- */
- U.MD.UI.upload.input = function (url, cb, hashcallback) {
- U.MD.UI.create(); //创建传出上传框
- var _clickuploadel = U.selectEl("#U_MD_UI_UP_DRT")[0]; //获取上传按钮的处理
- _clickuploadel.innerText = "";
- //创建一个input file
- $$("input", {
- "multiple": "true", "type": "file", "accept": "*/*", "onchange": U.MD.UI.inputSelect,
- "style": { "cssText": "display: block; position: relative; width: 100%; height: 100%; cursor: pointer; border: 0; color: #666; background: #eee; -moz-user-select: -moz-none; -webkit-user-select: none; opacity: 0; filter: alpha(opacity=0); -moz-opacity: 0;" }
- }, _clickuploadel);
- }
- /**
- * 初始化创建上传弹框
- */
- U.MD.UI.create = function () {
- var _flashtop = U.selectEl("#U_MD_UI_UP_O")[0];
- if (_flashtop) {
- U.UF.F.windowTopCenter(_flashtop); //居中弹出
- }
- else {
- var _uploadel,
- _topel,
- _titleel,
- _bottom,
- _switchel;
- _uploadel = $$("div", { "id": "U_MD_UI_UP", "className": "U_MD_UI_UP" });
- _topel = $$("div", { "className": "U_MD_UI_UP_O" }, _uploadel);
- //头部
- _titleel = $$("div", { "className": "U_MD_UI_UP_T" }, _topel);
- $$("div", { "className": "U_MD_UI_UP_TO", "innerHTML": "普通上传" }, _titleel);
- $$("div", { "className": "U_MD_UI_UP_Z", "innerHTML": "提示声明: 严谨上传包括反动、暴力、色情、违法及侵权内容的文件;严格遵守保密法律法规,任何危害用户或犯法的行为,都必须受到法律追究。" }, _topel);
- //文件上传区域
- $$("div", { "id": "U_MD_UI_UP_C", "className": "U_MD_UI_UP_C" }, _topel);
- //底部
- _bottom = $$("div", { "className": "U_MD_UI_UP_D" }, _topel);
- _switchel = $$("div", { "className": "U_MD_UI_UP_DR" }, _bottom);
- $$("div", { "className": "U_MD_UI_UP_DRO", "innerHTML": "点击上传" }, _switchel);
- $$("div", { "className": "U_MD_UI_UP_DRO U_MD_UI_UP_DRT", "id": "U_MD_UI_UP_DRT" }, _switchel);
- //弹出上传框
- return new U.UF.UI.form("<div class='U_MD_F_S_TI'>上传</div>", _uploadel, {
- "id": "U_MD_UI_UP_O",
- "style": { "width": "700px", "height": "560px" }
- }, { isnarrow: false, isenlarge: false }).form;
- }
- }
- /**
- * 获取上传文件所在的位置
- * @param {string} 上传文件的id
- * @return {array} 上传文件的位置及信息
- * 0 找到上传文件的信息
- * 1 上传文件在一个flashfiles的位置
- * 2 上传文件在多个flashfiles中其中一个flashfiles的位置
- */
- U.MD.UI.getFileInfoById = function (fileid) {
- var i, j,
- _allfiles = U.MD.UI.upload.uploadFileInfo; //用户需要上传的所有文件
- for (i = 0; i < _allfiles.length; i++) {
- j = _allfiles[i].objIndexOf({ "fileid": fileid }); //根据fileid在_allfiles[i]数组的查找获取fileid = fileid的上传文件信息
- //找到该上传文件
- if (j > -1) {
- /*
- * 0 找到上传文件的信息
- * 1 上传文件在一个flashfiles的位置
- * 2 上传文件在多个flashfiles中其中一个flashfiles的位置
- */
- return [_allfiles[i][j], j, i];
- }
- }
- return [null, -1, -1]; //返回未找到的信息
- }
- //#endregion
- //#region html5- input上传
- U.MD.UI.inputSelect = function () {
- }
- //#endregion
- //#region html5 input上传处理
- /**
- * 生成上传的点击框
- * @param event 当input内容改变时触发函数
- */
- U.MD.UI.inputSelect = function (callback) {
- //获取input控件
- var event = window.event || arguments.callee.caller.arguments[0];
- var _fileinfo,
- _fileinfos = [],
- _files = event.target.files; //所有上传的文件
- //遍历input的文件
- for (var i = 0; i < _files.length; i++) {
- _fileinfos.push(_files[i]); //加入待上传文件信息
- }
- U.MD.UI.upload.uploadFileInfo.push(_fileinfos); //添加上传的处理
- U.MD.UI.printUploadFiles(_fileinfos); //生成前台UI
- U.MD.UI.inputUpload(_fileinfos[0], callback); //调用上传
- }
- /*
- 生成文件信息
- * @param {file} file文件
- */
- //U.MD.UI.inputFileInfo = function (input) {
- // var _return = {
- // "creationDate": input.lastModifiedDate,
- // "creator": null,
- // "data": null,
- // "modificationData": input.lastModifiedDate,
- // "name": input.name,
- // "size": input.size,
- // "type": U.UF.UP.getFileNameAndExtension(input.name)[1]
- // }
- // return _return;
- //}
- /**
- * input上传处理的全过程
- * @param event 当input内容改变时触发函数
- */
- U.MD.UI.inputUpload = function (file, callback) {
- file.isupload = true; //设置上传状态为true
- //进行文件加密 回调参数(进度,完成,文件hash)
- U.UF.UP.html5Upload.fileMd5(file, function (progress, finish, filehash) {
- //发生错误的处理
- if (!progress) {
- //错误处理
- if (U.UF.C.isFunction(callback.error)) {
- callback.error(finish);
- }
- }
- //判断是否解析完成
- else if (finish) {
- callback.progress({ "Loaded": 1, "Total": 1 }, file.fileid, ""); //生成进度条
- //获取hash后的回调处理
- if (U.UF.C.isFunction(callback.getHashCallBack)) {
- callback.getHashCallBack(filehash, file, callback);
- }
- }
- //未解析完毕进度条处理
- else {
- if (U.UF.C.isFunction(callback.progress)) {
- callback.progress(progress, file.fileid, "解析中"); //生成进度条
- }
- }
- });
- }
- //#endregion
- //#region flash上传处理的过程
- /**
- * 上传框用户选择完文件的处理
- * @param {array} 需要加载上传框的元素
- */
- U.MD.UI.flashSelect = function (uploadfiles, url, isgethash) {
- U.MD.UI.printUploadFiles(uploadfiles, true); //打印上传的内容
- U.MD.UI.upload.uploadFileInfo.push(uploadfiles); //添加上传的信息处理
- U.MD.UI.flashUpload(uploadfiles[0], url, isgethash); //上传处理
- }
- /**
- * 上传的处理,如果有处理hash的那么就调用hash的回调
- * @param {array} 需要加载上传框的元素
- */
- U.MD.UI.flashUpload = function (uploadfile, url, isgethash) {
- var _flashbottom = U.selectEl("*flashupload")[0], //上传按钮
- _fileid = uploadfile.fileid //上传文件的唯一识别id
- ;
- uploadfile.isupload = true; //设置上传状态为true
- //如果需要处理获取hash值的处理
- if (isgethash) {
- //上传前,先得到hash的值,进行判断是否文件已经存在
- U.UF.UP.generateFileHash($("*flashupload")[0], _fileid); //获取hash
- }
- //文件直接上传的处理
- else {
- //直接执行文件的上传处理
- U.UF.UP.flashUpload(_flashbottom, _fileid, url);
- }
- }
- /**
- * 文件单个上传完毕
- * @param {string} 上传文件的唯一识别id
- */
- U.MD.UI.flashUploadComplete = function (fileid) {
- // U.alert("传输完成,等待返回。");
- }
- /**
- * 所有文件上传完的处理
- */
- U.UF.UP.deleteUploadAllFile = function () {
- }
- /**
- * 清空上传框处理
- */
- U.MD.UI.flashEmptyUpload = function (el) {
- var _flashbottom = U.selectEl("*flashupload")[0];
- if (_flashbottom) {
- U.UF.UP.deleteUploadAllFile(_flashbottom); //清理flash上传的资源
- }
- }
- /**
- * 获取上传文件所在的位置
- * @param {object} 错误消息
- * @return {array} 上传文件的位置及信息
- * 0 上传文件在一个flashfiles的位置
- * 1 上传文件在多个flashfiles中其中一个flashfiles的位置
- * 2 找到上传文件的信息
- */
- U.MD.UI.flashError = function (errorinfo) {
- if (errorinfo.message) { //有错误消息
- var _meeage = "上传处理失败:" + errorinfo.message; //上传错误信息
- if (UE.errorID == 1502) { //当错误编码是1502时候我们弹出用户可理解的错误
- _meeage = "文件太大,电脑内存不足";
- }
- U.alert(_meeage); //弹出错误
- U.UF.C.console(errorinfo); //控制台输出错误
- }
- }
- //#endregion
- //#region 统一处理
- /**
- * 打印上传的信息
- * @param {array} 上传的文件数组
- */
- U.MD.UI.printUploadFiles = function (uploadfiles, isflash) {
- var _type,
- _info,
- _uploaddiv,
- _panel,
- _panel_one,
- _progressel,
- _uploadcontent = U.selectEl("#U_MD_UI_UP_C"),
- _frag = $$("frag");
- //循环打印上传的文件信息
- for (i = 0; i < uploadfiles.length; i++) {
- uploadfiles[i].fileid = Guid.newGuid(); //设置上传文件的id
- _type = U.UF.UP.getFileNameAndExtension(uploadfiles[i]["name"])[1]; //获取上传文件的后缀
- //创建上传文件的信息
- _uploaddiv = $$("div", { "className": "U_MD_UI_UP_CO" }, _frag);
- _panel = $$("div", { "className": "U_MD_UI_UP_COO" }, _uploaddiv);
- _panel_one = $$("div", { "className": "U_MD_UI_UP_COI U_Img ", "style": { "cssText": "background-position:-12px 1px" } }, _panel);
- $$("div", { "className": "U_MD_UI_UP_COION", "innerHTML": _type }, _panel_one);
- _panel_one = $$("div", { "className": "U_MD_UI_UP_COT" }, _panel);
- $$("div", { "className": "U_MD_UI_UP_COTS U_MD_D_Text_Abbreviation", "innerHTML": uploadfiles[i].name }, _panel_one);
- $$("div", { "className": "U_MD_UI_UP_COTX", "innerHTML": "容量大小:" + U.UF.UP.minUnitToMaxUnit(uploadfiles[i]["size"]) }, _panel);
- _panel_one = $$("div", { "className": "U_MD_UI_UP_COS U_MD_D_Text_Abbreviation" }, _panel);
- $$("div", { "className": "U_MD_UI_UP_COSN", "innerHTML": "准备上传" }, _panel_one);
- $$("div", { "className": "U_MD_UI_UP_COSI U_Img" }, _panel_one);
- _panel_one = $$("div", { "className": "U_MD_UI_UP_COC U_MD_UI_UP_COX", "title": "等待响应..." }, _panel_one);
- $$("img", { "onerror": U.MD.C.imgError, "src": US.DOMAIN + "img/ULG.gif" }, _panel_one);
- $$("div", {
- "className": "U_MD_UI_UP_COX", "titlle": "点击撤销删除上传", "innerHTML": "撤销",
- "onclick": function () {
- U.MD.UI.delUploadFile(_uploaddiv, uploadfiles[0], isflash); // 移除当前上传元素,排队向下上传处理
- }
- }, _panel);
- _progressel = $$("div", { "className": "U_MD_UI_UP_COU" }, _uploaddiv);
- uploadfiles[i].fileel = _uploaddiv; //记录上传元素的框
- uploadfiles[i].progressel = _progressel; //进度条元素
- }
- //添加上传的文件信息在中间上传区域
- _uploadcontent.append(_frag);
- }
- /**
- * 移除当前上传元素,排队向下上传处理
- * @param {element} 需要移除的元素
- * @param {object} 上传文件的信息
- */
- U.MD.UI.delUploadFile = function (uploadel, uploadfile, isflash) {
- var i, j,
- _allfiles = U.MD.UI.upload.uploadFileInfo,
- _fileinfo = U.MD.UI.getFileInfoById(uploadfile.fileid), //根据文件的id获取在U.MD.UI.FTF["FL"]中的位置及在U.MD.UI.FTF["FL"][i]中的位置
- _allfilesnum = _fileinfo[2], //文件在U.MD.UI.FTF["FL"]中的位置
- _filesnum = _fileinfo[1]; //文件在U.MD.UI.FTF["FL"][i]中的位置
- U.selectEl(uploadel).remove(); //上传成功后删除上传的元素
- if (_filesnum != -1) { //实体存在
- //移除一个上传文件
- _allfiles[_allfilesnum].splice(_filesnum, 1)[0];
- //如果在移除的文件是该多个flash上传中的其中一个的最后一个上传,那么直接删除上传数组
- if (!_allfiles[_allfilesnum].length) {
- _allfiles.splice(_allfilesnum, 1);
- }
- //flash清楚上传处理
- if (isflash) {
- U.UF.UP.deleteUploadFile($("*flashupload")[0], _filesnum, _allfilesnum); //flash中删除上传。
- }
- //html5清除上传处理
- else {
- U.UF.UP.html5Upload.deleteUploadFile(uploadfile);
- }
- //判断上传文件的上传状态,如果是正在上传的文件删除,那么需要向下执行上传文件
- if (uploadfile.isupload) {
- //如果还有文件需要上传
- if (_allfiles.length) {
- //利用排队的方式执行文件上传
- for (i = 0; i < _allfiles.length; i++) { //从所有的上传文件数组里排队
- for (j = 0; j < _allfiles[i].length; j++) { //在fileslist中排队筛选
- if (!_allfiles[i][j].isupload) { //如果该文件的状态没有在上传中,那么就直接上传
- return _allfiles[i][j];
- }
- }
- }
- }
- else {
- //flash清理上传处理
- if (isflash) {
- U.MD.UI.flashEmptyUpload(); //清空上传框
- }
- else {
- U.UF.UP.html5Upload.deleteUploadAllFile();
- }
- }
- }
- }
- }
- /**
- * 上传文件进度条处理
- * @param {object} 进度条的值 Loaded 现在的进度 Total 中进度
- * @param {object} 上传文件的唯一识别id
- * @param {object} 用md5去判断上传的文件是否需要上传
- */
- U.MD.UI.progress = function (progress, fileid, msg) {
- var _fileinfo = U.MD.UI.getFileInfoById(fileid)[0], //根据上传文件唯一识别的id获取上传文件的信息
- _progresschilds = U.selectEl($(_fileinfo.fileel).childs(0).childs(0)[3]).Child(), //获取上传文件进度条元素
- _progress = Math.floor((progress.Loaded / progress.Total) * 100); //获取进度的百分比
- _fileinfo.progressel.style.width = _progress + "%"; //上传的进度样式
- _progresschilds[0].innerText = msg; //上传信息提醒,包括准备上传、正在解析、上传中
- _progresschilds[1].style.display = "none"; //上传成功后的
- _progresschilds[2].style.display = "block"; //loading
- }
- /**
- * 接续上传的处理
- * @param {string} 上传文件的唯一识别id
- */
- U.MD.UI.flashContinueUpload = function (fileid, url, isgethash) {
- var _fileinfo = U.MD.UI.getFileInfoById(fileid)[0], //获取上传完的文件
- _nextuploadfile = U.MD.UI.delUploadFile(_fileinfo.fileel, _fileinfo, true); //删除上传成功后的文件,得到下一个需要上传的文件
- // 如果有下一个文件要上传的处理
- if (_nextuploadfile) {
- U.MD.UI.flashUpload(_nextuploadfile, url, isgethash); //调用上传,如果有hash的获取这里支持自动获取hash
- }
- }
- //#endregion;
- ///<jscompress sourcefile="Url.js" />
- /*用户使用www.1473.cn时,我们需要设置成: /#!/word/guid
- 用于推广运营时的链接如下:
- 电脑端
- word可编辑模式跳转 /word/guid。。
- word不可编辑模式 http://guid.1473.cn 或者短域名访问 http://123.1473.cn
- file的访问模式 /disk/guid
- 手机端
- word可编辑模式跳转: http://m.1473.cn/word/guid
- */
- Namespace.register("U.MD.N"); //Url执行区域
- /**
- * url指引函数
- * 此函数需要修改。。参数urlinfo的类型需要固定。
- */
- U.MD.N.urlGuide = function () {
- var _hash = U.UF.C.getUrlHash(), //获取传参
- _type; //类型
- //如果链接类型是 /#!/disk/13928417148/f6d7a4b6-e34c-4964-beed-24187b2cb1ba 的处理
- if (_hash[0] == "#!") {
- _hash.shift()
- }
- //链接类型是 /#disk/13928417148/f6d7a4b6-e34c-4964-beed-24187b2cb1ba 的处理
- else {
- _hash[0] = _hash[0].substr(1);
- }
- _type = _hash[0];
- switch (_type) {
- case "disk":
- //打开网盘的处理
- U.MD.D.I.openApplication(_type, { "userid": _hash[1], "directoryid": _hash[2] });
- break;
- case "file":
- U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", _hash[1]]), function (r) {
- var _fileinfo = r.value[0];
- _fileinfo = new U.MD.DK.M.entity(_fileinfo.UserFilesID, _fileinfo.UserFilesSize, _fileinfo.UserDirectoryID, _fileinfo.UserFilesName, _fileinfo.UserFilesName, //创建US.disk.Disks里面的内容的数据结构
- _fileinfo.UserFilesExtendName, _fileinfo.UserFilesServerName, _fileinfo.UserFilesAddTime, null, 999, _fileinfo.UserFilesModifyTime, _fileinfo.UserDirectoryEncrypt,
- 1, _fileinfo.UserFilesExtendName, _fileinfo.GroupID, _fileinfo.UsOffice, _fileinfo.UserID, US.userInfo.UserNikeName, _fileinfo.UserName, _fileinfo.UserThumbnailImageHead);
- U.MD.DK.LE.openFileDirectory(_fileinfo);
- });
- break;
- case "excel":
- if (_hash[1] == 'join') { //如果地址栏有join进入加群流程
- U.MD.N.joinGuide(_hash, _type);
- }
- else if (_hash[1].length == 36) { //正常调用
- U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", _hash[1]]), function (r) {
- if (r.value[0]) {
- //拼接word
- var _fileinfo = {
- UserDirectoryExtendType: r.value[0].UserFilesExtendName,
- UsOffice: r.value[0].UsOffice ? r.value[0].UsOffice.unEscapeQuotes() : null,
- UserId: r.value[0].UserID,
- UserallDirectoryName: r.value[0].UserFilesName,
- UserDirectoryID: r.value[0].UserFilesID,
- GroupID: r.value[0].UserDirectoryEncrypt
- };
- //获取word内容
- if (r.value && r.value.UsOffice !== undefined && r.value.UsOffice != null) {
- U.MD.D.I.openApplication(_type, _fileinfo);
- }
- }
- });
- }
- break
- case "word":
- if (_hash[1] == 'join') { //如果地址栏有join进入加群流程
- U.MD.N.joinGuide(_hash, _type);
- }
- else if (_hash[1].length == 36) { //正常调用
- U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", _hash[1]]), function (r) {
- if (r.value[0]) {
- r = r.value[0];
- //拼接word
- var _fileinfo = {
- UserFilesServerName: r.UserFilesServerName,
- UserDirectoryExtendType: r.UserFilesExtendName,
- UsOffice: r.UsOffice ? r.UsOffice.unEscapeQuotes() : null,
- UserId: r.UserID,
- UserallDirectoryName: r.UserFilesName,
- UserDirectoryID: r.UserFilesID,
- GroupID: r.UserDirectoryEncrypt
- };
- //获取word内容
- if (r && r.UsOffice !== undefined && r.UsOffice != null) {
- U.MD.D.I.openApplication(_type, _fileinfo);
- }
- //如果内容不存在则去office系统中获取
- else {
- U.A.Request("http://office.1473.cn/Officetohtml.ashx", ["Open", _fileinfo.UserDirectoryExtendType, _fileinfo.UserFilesServerName], function (r) {
- if (r.value.value != undefined) {
- r = r.value;
- _fileinfo.UsOffice = r.value.getBodyHtml().replace(/src=[\'\"]?([^\'\"]*)[\'\"]?/ig, function (str1, str2) {
- return "src=\"http://office.1473.cn/usoffice/" + str2 + "\"";
- });
- U.MD.D.I.openApplication(_type, _fileinfo);
- } else {
- U.Alert('文档已丢失。。。');
- }
- });
- }
- }
- });
- }
- break;
- case "boomYun": case "txt": case "friend": case "lookupfriend": case "set": case "systemset":
- U.MD.D.I.openApplication(_type, { "directoryid": _hash[1] });
- if (_hash[1] == "template") {
- //打开模板函数
- if (_hash[2] != "undefined") {
- U.Boom.I.GetHomeTemp.particulars(_hash[2]);
- U.MD.N.urlWrite("boomYun/template/" + _hash[2], "互联办公"); //boomyun的url重写
- }
- }
- break;
- default: break;
- }
- }
- /**
- * 分享邀请链接加入群组
- * @param {hash} hash值
- * @param {type} 文件类型
- */
- U.MD.N.joinGuide = function (hash, type) {
- var _fileId = hash[2]; //获取文件id
- U.MD.U.L.setLoginCallBack(function () { //当用户登录后
- U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileById", _fileId]), function (r) { //获取文档对的信息
- var _docinfo = r.value[0]; //文档信息
- if (!_docinfo) { //是否有文档信息
- return U.Alert('添加协同链接有误,请联系群主获取最新协同链接。。。');
- }
- if (US.friend.group) { //判断是否有群
- var _groupId = _docinfo.UserDirectoryEncrypt || _docinfo.UserDirectoryID, //获取群id
- _groupinfo = U.Json.select(US.friend.group, { "GroupManageID": _groupId })[0], //判断用户是否加入了群
- _docId = _docinfo.UserFilesID; //文档ID
- if (!_groupinfo) { //如果没有加群
- U.A.Request(US.CD, ([US.DB, "UseStudio_Friends", "GetGroupInfo", _groupId]), function (r) { //取数据库获取群的信息
- U.MD.F.J.selectUserInfo.NeedUser = [US.userInfo]; //得到个人信息名并赋值NeeUser全局
- US.friend.group.push(r.value[0]); //添加到用户的群
- top.U.MD.F.J.determineCreateGroupAndAddGroupUser(r.value[0].GroupManageID, null, null, false, "", "", function (groupid, groupdata) { //添加群
- U.Json.del(groupdata[0], { UserId: US.userInfo.UserId });
- US.friend.groupusers.push.apply(US.friend.groupusers, groupdata[0]);
- // US.disk.Disks[US.userInfo.UserId].directoryOrFiles.push.apply(US.disk.Disks[US.userInfo.UserId].directoryOrFiles, _groupuserinfo);
- U.MD.D.I.openApplication(type, U.Json.select(groupdata[1], { UserDirectoryID: _docId })[0], function (contentwindow) { contentwindow.U.MD.O.W.Panel.addUser(US.userInfo.UserId); }); //打开应用
- });
- }); //获取群资料
- } else { //加入了群
- var _docdiskinfo = new U.MD.DK.M.entity(_docinfo.UserFilesID, _docinfo.UserFilesSize, _docinfo.UserDirectoryID, _docinfo.UserFilesName, _docinfo.UserFilesName, //创建US.disk.Disks里面的内容的数据结构
- _docinfo.UserFilesExtendName, _docinfo.UserFilesServerName, _docinfo.UserFilesAddTime, null, 999, _docinfo.UserFilesModifyTime, _docinfo.UserDirectoryEncrypt,
- 0, _docinfo.UserFilesExtendName, _groupId, _docinfo.UsOffice, _docinfo.UserID, US.userInfo.UserNikeName, _docinfo.UserName, _docinfo.UserThumbnailImageHead);
- U.Alert("你已经在该文档的群里了!");
- U.MD.D.I.openApplication(type, _docdiskinfo); //打开应用
- }
- }
- })
- });
- }
- //添加页面导航
- /*
- * @param {string} hash值
- * @param {string} document.title变化
- */
- U.MD.N.urlWrite = function (hash, title) {
- setTimeout(function () {
- U.UF.N.addHash(hash); //添加hash的处理
- document.title = title; //title的处理
- }, 0);
- }
- //seo模块.现有访问网址。/
- //论坛
- // 目录: /#!/pb/afa8621d-de5a-44db-8338-7d36168e7446
- // 文章:外网:/#!/pbt/e80c57a0-1c82-4f43-931d-b7c8fab982a8
- //硬盘
- // 目录: /#!/disk/13928417148/f6d7a4b6-e34c-4964-beed-24187b2cb1ba
- // txt文件:/#!/txt/63e6b0c9-aa72-1ef5-a9c0-a9d19b2b4c39
- // word文件:/#!/word/efb4be75-696b-27fe-f125-25eff5d2716f
- // img文件:/#!/img/efb4be75-696b-27fe-f125-25eff5d2716f
- //现有word直接查看形式。
- //http://disk.1473.cn/efb4be75-696b-27fe-f125-25eff5d2716f/Word
- //http://disk.1473.cn/efb4be75-696b-27fe-f125-25eff5d2716f/Txt
- //http://disk.1473.cn/efb4be75-696b-27fe-f125-25eff5d2716f/Excel
- //从这些网址派生短链接。
- //10001.1473.cn
- //网盘文件直接打开查看
- ///#!/file/38807b15-e721-4820-88b2-5f88da69813b;
- ///<jscompress sourcefile="NetworkPromotion.js" />
- Namespace.register("U.MD.U.NP");
- U.MD.U.NP.GN = { "2d9c5d2d-e6e5-4a40-8064-f93a98d0e647": { "Url": "http://pay.1473.cn/?f=hbt&=hbt", "TT": ["U_MD_U_NP_XI U_MD_U_NP_XIH", "", "好笔头", "云笔记产品", "好笔头业务云笔记专为企业团队量身打造,致力为企业团队提供最好、最适合的云笔记产品,记客户,记工作,记知识,重要工作备忘提醒,专为改善企业团队工作效率而生,同时团队围绕笔记交流协作,提高团队执行和分享效率。", "U_MD_U_NP_XWCB U_MD_U_NP_XWCBB"] }, "7bc6d08c-7db3-4ef4-8a39-595a4967a189": { "Url": "http://pay.1473.cn/?f=zh&zh=", "TT": ["U_MD_U_NP_XI U_MD_U_NP_XIZ", "", "中恒科技", "兼容生产CD", "深圳市中恒科技实业有限公司坐落于具有中国光盘生产基地之誉称的广东省深圳市,是一家兼容生产CD-R,DVD-R可录入式空白光盘的中外合资企业,总投资3千万美元。第一期拥有10条具有国际先进水平的生产线,年产量可达6千万元。", "U_MD_U_NP_XWCB U_MD_U_NP_XWCBD"] }, "ea0efe2e-9167-4698-b9b5-31c27ad5eb73": { "Url": "http://pay.1473.cn/?f=sp&sp=", "TT": ["U_MD_U_NP_XI U_MD_U_NP_XIB", "", "声博配音公司", "各个语种的深圳配音", "声博配音公司拥有全新数字专业录音棚,资深音频工程师、录音师、音乐制作人等。 成立以来,公司在一直致力于中文及各个语种的深圳配音业务、音乐制作等。 为国内外客户录制了大量影视动画、广告、专题等。在深圳配音行业内树立了良好的口碑。", "U_MD_U_NP_XWCB U_MD_U_NP_XWCBB"] }, "fd01dd1b-9c87-4e4f-a3fb-af1b91bf56f8": { "Url": "/#!/tg/", "TT": ["U_MD_U_NP_XI U_MD_U_NP_XIY", "", "云端桌面", "体验崭新的云服务", "云端桌面远离单机,基于互联网。提供免费存储,让你远离U盘,排除U盘丢失和携带的麻烦。云端的资源都是共享的,你可以随时获取好友共享的资源。", "U_MD_U_NP_XWCB U_MD_U_NP_XWCBY"] }, "ea0efe2e-9167-4698-b9b5-31c27ad5eb73": { "Url": "http://pay.1473.cn/?f=sp&sp=", "TT": ["U_MD_U_NP_XI U_MD_U_NP_XIB", "", "声博配音公司", "各个语种的深圳配音", "声博配音公司拥有全新数字专业录音棚,资深音频工程师、录音师、音乐制作人等。 成立以来,公司在一直致力于中文及各个语种的深圳配音业务、音乐制作等。 为国内外客户录制了大量影视动画、广告、专题等。在深圳配音行业内树立了良好的口碑。", "U_MD_U_NP_XWCB U_MD_U_NP_XWCBB"] }, "90f7c5ca-f7ab-4f31-8869-7275b8e8955c": { "Url": "http://pay.1473.cn/?f=bz&bz=", "TT": ["U_MD_U_NP_XI U_MD_U_NP_XID", "", "北京邮电大学", "高新技术产业发展", "北京邮电大学深圳研究院(简称深圳研究院)是依照国家有关法律、行政法规和深圳市人民政府深府办[2000]39号文件以及关于进一步扶持高新技术产业发展的若干规定成立的北京邮电大学全资事业法人机构。", "U_MD_U_NP_XWCB U_MD_U_NP_XWCBD"] } }
- U.MD.U.NP.TF; //
- //---------------------------------------------------------------------------用户数据加载----------------------------------------------------------------------------
- //-------------------------------------------------------加载数据
- U.MD.U.NP.DTG = function () {
- var _UDPD = U.selectEl("#U_MD_U_NP")[0]; //推广框
- U.UF.F.windowTopCenter(_UDPD); //居中
- // U.MD.D.T.WindowRestore(_UDPD, null, "推广"); //创建任务栏链接
- }
- //-----------------------------------------------------推广介绍
- U.MD.U.NP.DTGOD = function (TGID) {
- var _UDTD = U.selectEl("#U_MD_U_NP_XW")[0],
- _UDAD = U.selectEl("div", _UDTD),
- _UGN = U.MD.U.NP.GN[TGID]["TT"];
- for (var i = 0; i < _UGN.length; i++) {
- if (i == 1) {
- continue;
- }
- if (i > 0 && i < _UGN.length - 1) {
- _UDAD[i].innerHTML = _UGN[i];
- }
- else {
- _UDAD[i].className = _UGN[i] + " U_MD_U_NP_I";
- }
- }
- _UDAD[_UDAD.length - 2].onclick = function () {
- U.MD.U.NP.GTGURL(TGID);
- }; //点击获取推广地址
- }
- //-----------------------------------------------------------------------------有效点击
- //加载该用户已有的推广数据
- U.MD.U.NP.NTG = function (T) {
- if (!U.MD.U.L.isLogin()) {
- if (US.userInfo.TGD && US.userInfo.TGD["NTG"] && T == null) {
- U.MD.U.NP.PLTG(US.userInfo.TGD["NTG"]);
- U.MD.U.NP.LTTG(US.userInfo.TGD["YXT"]);
- U.selectEl("#U_MD_U_NP_DPI")[0].innerText = "";
- U.MD.U.NP.GTGFW(0);
- }
- else {
- U.A.Request("UseStudioPay.GetUserAllTG", [US.userInfo.UserId], U.MD.U.NP.AsynNTG, [$("#U_MD_U_NP_A")[0]]);
- // U.selectEl("#U_MD_U_NP_A")[0].onscroll = U.UF.EV.scrollLoad({ 'AF': U.MD.U.NP.GFWTG }).SCH();
- U.UF.EV.scrollLoad($("#U_MD_U_NP_A")[0], function () {
- U.MD.U.NP.GFWTG
- });
- } //异步获取
- }
- }
- //异步获取推广数据
- U.MD.U.NP.AsynNTG = function (r) {
- var _context = r.context;
- r = r.value;
- if (US.userInfo.TGD == null) { US.userInfo.TGD = {} };
- US.userInfo.TGD["NTG"] = r[0];
- US.userInfo.TGD["YXT"] = U.MD.U.NP.DT(r[1]); //区分有效统计和注册
- US.userInfo.TGD["YXD"] = [r[2]];
- U.MD.U.NP.NTG();
- }
- //区分有效统计 点击和注册
- U.MD.U.NP.DT = function (UTL) {
- var i, j, _TF = [];
- for (i = 0; i < UTL.length; i++) {
- _TF[i] = []; _TF[i].push(UTL[i]);
- for (j = i + 1; j < UTL.length; j++) {
- if (UTL[j]["TGUserInfoID"] == UTL[i]["TGUserInfoID"]) {
- _TF[i].push(UTL[j]); UTL.splice(j, 1);
- }
- }
- }
- return _TF;
- }
- //用户已有的推广数据
- U.MD.U.NP.PLTG = function (UTL) {
- var i, j, k,
- _UDPD = U.selectEl("#U_MD_U_NP_DTD")[0],
- _el, _UDTD, _UDI,
- _UDFD = $$("frag"),
- _UAFD = [],
- _UAT = ["disk", "photo", "music", "video", "blog"];
- _UDPD.innerText = "";
- if (UTL.length > 0) {
- U.selectEl("#U_MD_U_NP_DUN")[0].innerHTML = US.userInfo.TrueName || US.userInfo.UserNickName; //用户推广名
- for (i = 0; i < UTL.length; i++) {
- _UAFD.push(UTL[i]["TY"] + UTL[i]["TGUserInfoID"]); //基础推广地址
- if (UTL[i]["TGID"] == "fd01dd1b-9c87-4e4f-a3fb-af1b91bf56f8") {
- for (j = 0; j < _UAT.length; j++) {
- _UAFD.push(US.DOMAIN + "#!/" + _UAT[j] + "/" + US.userInfo.UserName);
- }
- }
- _el = $$("div", { "className": "U_MD_U_NP_DTDD" }, _UDFD);
- $$("div", { "className": "U_MD_U_NP_DTDDN", "innerHTML": U.MD.U.NP.GN[UTL[i]["TGID"]]["TT"][2] + ':' }, _el);
- for (k = 0; k < _UAFD.length; k++) {
- _UDTD = $$("div", { "className": "U_MD_U_NP_DTDDA" }, _el);
- _UDI = $$("input",
- {
- "className": "U_MD_U_NP_DTDDS",
- "readOnly": "true",
- "value": _UAFD[k],
- "oncopy": function () {
- U.UF.EV.stopBubble();
- U.UF.C.copy("retElement.value");
- }
- }, _UDTD);
- $$("div",
- {
- "innerHTML": "复制",
- "className": "U_MD_U_NP_DTDDF",
- "style":
- {
- "cssText": "float:right"
- },
- "onclick": function () {
- U.UF.EV.stopBubble();
- U.UF.C.copy(_UDI.value);
- }
- }, _UDTD); //复制按钮
- }
- _UAFD.splice(0, _UAFD.length);
- }
- _UDPD.appendChild(_UDFD);
- }
- else { _UDPD.innerText = "没有推广分类文类"; }
- }
- //打印有效统计
- U.MD.U.NP.LTTG = function (UTL) {
- var _UDPD = U.selectEl("#U_MD_U_NP_DWP")[0],
- _el, _UDTD, _UDSD,
- _UDFD = $$("frag");
- _UDPD.innerText = "";
- for (var i = 0; i < UTL.length; i++) {
- _el = $$("div", { "className": "U_MD_U_NP_DWP" }, _UDFD);
- _UDTD = $$("div", { "className": "U_MD_U_NP_DWY" }, _el);
- $$("div", { "className": "U_MD_U_NP_DWYN", "innerHTML": U.MD.U.NP.GN[UTL[i][0]["TGID"]]["TT"][2] + "点击次数" }, _UDTD);
- $$("div", { "className": "U_MD_U_NP_DWYS", "innerHTML": UTL[i][0]["C"] }, _UDTD);
- _UDSD = $$("div", { "className": "U_MD_U_NP_DWY" }, _el);
- $$("div", { "className": "U_MD_U_NP_DWYN", "innerHTML": U.MD.U.NP.GN[UTL[i][0]["TGID"]]["TT"][2] + "成功注册" }, _UDSD);
- $$("div", { "className": "U_MD_U_NP_DWYS", "innerHTML": UTL[i][1] ? UTL[i][1]["C"] : "0" }, _UDSD);
- }
- _UDPD.appendChild(_UDFD);
- }
- //---------------------------------------------------------------------有效地址
- //滚动加载访问地址
- U.MD.U.NP.GFWTG = function () {
- if (U.MD.U.NP.GTGFW.call(this, (this.P + 1)).length == 0) {
- this.P -= 1;
- this.TF = false;
- return false;
- }
- }
- //获取打印有效数据
- U.MD.U.NP.GTGFW = function (P) {
- var _UTL = U.MD.U.NP.GYXFW(P);
- if (_UTL) { U.MD.U.NP.FWTG(_UTL); }
- else {
- var _FP = Math.floor(P / 5);
- U.A.Request("UseStudioPay.GetTGYXSL", [US.userInfo.UserId, _FP * 50, (_FP + 1) * 50 - 1], U.MD.U.NP.AsynGTGFW, ["", P, this]);
- return [];
- }
- return _UTL;
- }
- //异步获取
- U.MD.U.NP.AsynGTGFW = function (r) {
- var _context = r.context;
- r = r.value;
- US.userInfo.TGD["YXD"].push(r);
- U.MD.U.NP.GTGFW(_context[1]);
- _context[2].TF = true;
- }
- //获取有效数据
- U.MD.U.NP.GYXFW = function (P) {
- if (US.userInfo.TGD) {
- var _UTGP = US.userInfo.TGD["YXD"],
- TP = Math.floor(P / 5), FP = (P - TP * 5);
- if (_UTGP[TP]) {
- return _UTGP[TP].slice(FP * 10, (FP + 1) * 10);
- }
- }
- }
- //访问地址打印
- U.MD.U.NP.FWTG = function (UTL) {
- if (UTL.length > 0) {
- var _UDPD = U.selectEl("#U_MD_U_NP_DPI")[0],
- _el,
- _UTD,
- _UDFD = $$("frag");
- for (var i = 0; i < UTL.length; i++) {
- eval("0,_UTD =" + UTL[i]["TGAdress"]);
- _el = $$("div", { "className": "U_MD_U_NP_DPH U_MD_U_NP_DPIF", "style": { "backgroundColor": "White" } }, _UDPD);
- $$("div", { "className": "U_MD_D_Text_Abbreviation", "style": { "marginLeft": "0px" }, "innerHTML": UTL[i]["UserIp"] }, _el);
- $$("div", { "className": "U_MD_D_Text_Abbreviation", "innerHTML": _UTD["province"] + " " + _UTD["city"] }, _el);
- $$("div", { "className": "U_MD_D_Text_Abbreviation", "innerHTML": U.UF.D.getYearMonthDay(UTL[i]["Time"], "String") }, _el);
- $$("div", { "className": "U_MD_D_Text_Abbreviation", "innerHTML": U.MD.U.NP.GN[UTL[i]["TGID"]]["TT"][2] }, _el);
- $$("div", { "className": "U_MD_D_Text_Abbreviation", "innerHTML": UTL[i]["IsRegistration"] ? "成功" : "失败", "style": { "color": UTL[i]["IsRegistration"] ? "Red" : "" } }, _el);
- }
- _UDPD.appendChild(_UDFD);
- }
- }
- //-----------------------------------------------------------------排名
- //获取排名
- U.MD.U.NP.GPMTG = function (TF) {
- if (US.userInfo.TGD && US.userInfo.TGD["TGP"] && TF == null) {
- U.MD.U.NP.PMTG(US.userInfo.TGD["TGP"]);
- }
- else {
- U.A.Request("UseStudioPay.GetTGPM", [], U.MD.U.NP.AsynGPMTG, [$("#U_MD_U_NP_A")[0]]);
- }
- }
- //异步获取排名
- U.MD.U.NP.AsynGPMTG = function (r) {
- r = r.value;
- if (US.userInfo.TGD == null) { US.userInfo.TGD = {} };
- US.userInfo.TGD["TGP"] = r;
- U.MD.U.NP.GPMTG(); //打印排名
- }
- //打印用户排名
- U.MD.U.NP.PMTG = function (UTL) {
- var _UDPD = U.selectEl("#U_MD_U_NP_PG")[0],
- _el, _UDTD,
- _UDFD = $$("frag");
- _UDPD.innerText = "";
- for (var i = 0; i < UTL.length; i++) {
- _el = $$("div", { "className": "U_MD_U_NP_PH" + (i < 3 ? "" : " U_MD_U_NP_PHV") }, _UDFD);
- $$("div", { "className": "U_MD_U_NP_PHM", "innerHTML": (i + 1 < 10 ? "0" : "") + (i + 1) + ".", "style": { "color": i == 0 ? "#e06767" : "" } }, _el);
- _UDTD = $$("div", { "className": (i < 3 ? "U_MD_U_NP_PHH" : "U_MD_U_NP_PHHM") }, _el);
- $$("img",
- {
- "className": (i < 3 ? "U_MD_U_NP_PHHI" : "U_MD_U_NP_PHHIO"),
- "alt": UTL[i]["TrueName"] || UTL[i]["UserName"],
- "src": U.MD.C.getHeadImage(UTL[i].UserThumbnailImageHead),
- "onclick": [U.MD.U.V.POUW, [UTL[i]["UserID"]]]
- }, _UDTD);
- $$("div", { "className": "U_MD_U_NP_PHHS U_MD_D_Text_Abbreviation" + (i < 3 ? "" : " U_MD_U_NP_PHHSM"), "innerHTML": UTL[i]["TrueName"] || UTL[i]["UserName"] }, _UDTD);
- $$("div", { "className": "U_MD_U_NP_PHHS U_MD_D_Text_Abbreviation" + (i < 3 ? "" : " U_MD_U_NP_PHHSM"), "innerHTML": U.MD.U.NP.GN[UTL[i]["TGID"]]["TT"][2] }, _UDTD);
- }
- _UDPD.appendChild(_UDFD);
- }
- //----------------------------------------------------------------------辅助功能
- //添加用户访问地址
- //例子:2013年的推广,暂时没有使用
- U.MD.U.NP.AddUr = function (TGID) {
- U.A.Request("UseStudioPay.SetYXTG", [TGID, U.UF.C.jsonToStr(US.city)], U.MD.U.NP.AsynAddUr, [""]);
- }
- //通过用户id添加用户访问地址
- //例:
- U.MD.U.NP.AddUrID = function (userid) {
- U.A.Request("UseStudioPay.SetYXTGBYUID", [userid, U.UF.C.jsonToStr(US.city)], U.MD.U.NP.AsynAddUr, [""]);
- }
- //获取用户访问地址
- U.MD.U.NP.AsynAddUr = function (r) {
- r = r.value;
- U.MD.U.NP.TF = r;
- U.MD.U.NP.TGR(); //发送注册信息
- }
- //添加推广地址
- U.MD.U.NP.GTGURL = function (TGID) {
- if (!U.MD.U.L.isLogin()) {//必须登录获取用户信息
- if (US.userInfo.TGD && US.userInfo.TGD["NTG"] && U.MD.U.NP.GISTGURL(TGID)) {
- U.MD.U.NP.STG(1, U.selectEl("#U_MD_U_NP_A")[0]);
- return false;
- } //查看地址
- U.alert("正在获取中..."); //提示用户等待
- U.A.Request("UseStudioPay.SetUserTG", [US.userInfo.UserId, TGID], U.MD.U.NP.AsynGTGURL, ["", TGID]); //添加用户注册信息
- }
- }
- //异步添加推广地址
- U.MD.U.NP.AsynGTGURL = function (r) {
- _context = r.context;
- r = r.value
- if (r) {
- if (US.userInfo.TGD && US.userInfo.TGD["NTG"]) {
- r = r.toLocaleLowerCase();
- var _ET = new U.MD.U.NP.TGE[_context[1], r, U.MD.U.NP.GN[_context[1]]["Url"]];
- };
- US.userInfo.TGD["NTG"].push(_ET);
- }
- U.MD.U.NP.STG(1, U.selectEl("#U_MD_U_NP_A")[0]); //查看地址
- }
- //获取推广地址是否存在
- U.MD.U.NP.GISTGURL = function (TGID) {
- var _UNTG = US.userInfo.TGD["NTG"];
- for (var i = 0; i < _UNTG.length; i++) {
- if (_UNTG[i]["TGID"] == TGID) {
- return _UNTG[i];
- }
- }
- return false;
- }
- //成功注册,添加推广信息,
- U.MD.U.NP.TGR = function () {
- if (U.MD.U.NP.TF && US.userInfo.UserId) {//添加用户注册信息
- U.A.Request("UseStudioPay.UpAddR", [U.MD.U.NP.TF], function () { }, []);
- U.MD.U.NP.TF = false; //取消重复
- }
- }
- //推广切换
- U.MD.U.NP.STG = function (TF, UTFD) {
- TF = TF + 1; //显示的div
- var _UTAD = U.UF.EL.getChildrenNoText(UTFD.childNodes); //获取所有的子元素
- for (var i = 1; i < _UTAD.length; i++) {
- if (TF == 2 && US.userInfo.UserId == null) {
- break;
- };
- if (TF == i) {
- _UTAD[i].style.display = "block";
- }
- else {
- _UTAD[i].style.display = "none";
- }
- }
- if (TF == 3) {
- U.MD.U.NP.GPMTG();
- } //查看排名
- else if (TF > 1) {
- if (!U.MD.U.L.isLogin()) {
- U.MD.U.NP.NTG();
- }
- } //用户推广资料
- }
- //-------------------------------------------------------------------辅助函数--------------------------------------------------------------
- //用户推广的实体
- U.MD.U.NP.TGE = function (E) {
- this.TGID = E[0];
- this.TGUserInfoID = E[1];
- this.TY = E[2];
- }
- ;
|