NotFunction.js 174 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284
  1. 
  2. //判断是否为函数
  3. U.MS.IsYX = function (UCB) {
  4. if (this == null) { throw new Error("this is null or not defined"); } //不允许为空
  5. else if ({}.toString.call(UCB) != "[object Function]") { throw new Error(UCB + " is not a function"); } //没有回调不成立
  6. else { return true; }; return false;
  7. }
  8. //下一个节点
  9. U.M.nextSibling = function (obj) {
  10. while (obj.nextSibling.nodeType != 1) {
  11. obj = obj.nextSibling;
  12. }
  13. return obj.nextSibling;
  14. }
  15. //前一个节点
  16. U.M.previousSibling = function (obj) {
  17. while (obj.previousSibling.nodeType != 1) {
  18. obj = obj.previousSibling;
  19. }
  20. return obj.previousSibling;
  21. }
  22. //Error具有下面一些主要属性:
  23. //description: 错误描述 (仅IE可用).
  24. //fileName: 出错的文件名 (仅Mozilla可用).
  25. //lineNumber: 出错的行数 (仅Mozilla可用).
  26. //message: 错误信息 (在IE下同description)
  27. //name: 错误类型.
  28. //number: 错误代码 (仅IE可用).
  29. //stack: 像Java中的Stack Trace一样的错误堆栈信息 (仅Mozilla可用).
  30. //--------------------------------------统一try cache---------------------------------
  31. U.MC.TC = {}; //保存前台错误的集合,暂时显示在前台,以后存入后台
  32. U.MC.TCatch = function (f) {
  33. try { (typeof (f) == "string") ? eval(f) : f; }
  34. catch (e) { Add(U.MC.TC, { "类型": e.name, "错误信息": e.message, "时间": U.MT.formatDateToArray(new Date()) }); }
  35. }
  36. //兼容SetCapture函数
  37. U.M.SetCapture = function (obj) {
  38. return document.all ? obj.setCapture() : window.captureEvents(Event.MOUSEMOVE);
  39. }
  40. //兼容releaseCapture函数
  41. U.M.releaseCapture = function (obj) {
  42. document.all ? obj.releaseCapture() : window.releaseEvents(Event.MOUSEUP);
  43. }
  44. //兼容加载事件与脚本 func为函数
  45. U.M.LoadEvent = function (func) {
  46. var oldonload = window.onload;
  47. //判断对象是否为一个事件,是则直接执行
  48. if (typeof window.onload != 'function') {
  49. window.onload = func;
  50. }
  51. else {
  52. window.onload = function () {
  53. oldonload();
  54. func();
  55. }
  56. }
  57. }
  58. //函数功能:获取键盘码,兼容Onkeydown事件
  59. U.M.getKeyCode = function (e) {
  60. e = e || window.event;
  61. keynum = e.keyCode ? e.keyCode : e.which;
  62. return keynum;
  63. }
  64. //事件代理机制,避免频繁添加事件操作。浪费代码,加大复杂度。
  65. U.M.GetEventTarget = function (e) {//判断浏览器类型以兼容事件
  66. e = e || window.event;
  67. return e.target || e.srcElement;
  68. }
  69. //Click()事件调用兼容
  70. U.M.invokeClick = function (element) {
  71. if (element.click) element.click(); //判断是否支持click() 事件
  72. else if (element.fireEvent) element.fireEvent('onclick'); //触发click() 事件
  73. else if (document.createEvent) {
  74. var evt = document.createEvent("MouseEvents"); //创建click() 事件
  75. evt.initEvent("click", true, true); //初始化click() 事件
  76. element.dispatchEvent(evt); //分发click() 事件
  77. }
  78. }
  79. //dblClick()事件调用兼容
  80. U.M.dblClick = function (element) {
  81. if (element.ondblclick) element.ondblclick(); //判断是否支持dblClick() 事件
  82. else if (element.fireEvent) element.fireEvent('ondblclick'); //触发dblClick() 事件
  83. else if (document.createEvent) {
  84. var evt = document.createEvent("MouseEvents"); //创建ondblclick() 事件
  85. evt.initEvent("dblclick", true, true); //初始化ondblclick() 事件
  86. element.dispatchEvent(evt); //分发ondblclick() 事件
  87. }
  88. }
  89. //------------------------------------------------------------------监听事件注册和取消区域---------------------------------------------------------------
  90. //注意:只有被addEventListener方法添加的事件才可以使用removeEventListener来注销.
  91. //如果你直接使用onclick或onkeyup直接写在元素内的事件.将无法使用removeEventListener来删除.
  92. U.M.removeEvent = function (oTarget, sEventType, funName) {
  93. if (oTarget.removeEventListener) {//for DOM;
  94. oTarget.removeEventListener(sEventType, funName, false);
  95. } else if (oTarget.detachEvent) {
  96. oTarget.detachEvent("on" + sEventType, funName);
  97. } else {
  98. oTarget["on" + sEventType] = null;
  99. }
  100. }
  101. //函数作用:为元素添加事件
  102. //oTarget:元素对象;sEventType:事件类型,例如点击则为click;funName:事件触发的函数名;
  103. U.AFB.AddEvent = function (oTarget, sEventType, funName) {
  104. if (oTarget.addEventListener) {//Dom浏览器触发
  105. oTarget.addEventListener(sEventType, funName, false);
  106. } else if (oTarget.attachEvent) { //IE
  107. oTarget.attachEvent("on" + sEventType, funName);
  108. } else {
  109. oTarget["on" + sEventType] = funName;
  110. }
  111. }
  112. //屏蔽错误
  113. U.M.killErrors = function (sMsg, sUrl, sLine) {
  114. //onerror函数的三个参数用于确定错误确切的信息,代表的意思依次为:错误信息;发生错误的文件;发生错误的行号。
  115. // var oErrorLog = document.createElement("div");
  116. // oErrorLog.innerHTML = "<b>An error was thrown and caught.</b><p>";
  117. // oErrorLog.innerHTML += "Error: " + sMsg + "<br>";
  118. // oErrorLog.innerHTML += "Line: " + sLine + "<br>";
  119. // oErrorLog.innerHTML += "URL: " + sUrl + "<br>";
  120. return true;
  121. }
  122. //屏蔽按键操作。
  123. U.M.forbiddenKey = function () {
  124. if (event.keyCode == 116) { event.keyCode = 0; event.returnValue = false; } //屏蔽f5刷新
  125. }
  126. //屏蔽div右键
  127. U.M.ForbiddenDivRightMouseClick = function (obj) {
  128. obj.oncontextmenu = function () { return false; }
  129. }
  130. //规范插入的图片大小--杨嘉城
  131. U.M.norm_img = function (SO) {
  132. var _ISO = $("img", SO);
  133. for (var i = 0; i < _ISO.length; i++) {
  134. if (_ISO[i].clientWidth >= 1024) { _ISO[i].width = "900px"; }
  135. }
  136. }
  137. //设置字体
  138. U.M.setuserbackgroundfont = function (obj) {
  139. if (obj != null) {
  140. var allelments = parent.document.getElementsByTagName('*');
  141. var i;
  142. for (i = 0; i < allelments.length; i++) {
  143. allelments[i].style.fontSize = obj + "px";
  144. }
  145. }
  146. }
  147. //去掉所有空格和标点符号
  148. U.MS.dropSpaceAndDot = function (obj) {
  149. str = obj.value;
  150. var pattern = new RegExp("[`~!#$^&*()=|{}':;',\\[\\].<>/?~#……&*()&;—|{}‘;:”“'。,、]");
  151. var newstr = "";
  152. for (i = 0; i < str.length; i++) {
  153. if (str.substr(i, 1) == " ") {
  154. continue;
  155. }
  156. newstr += str.substr(i, 1).replace(pattern, "");
  157. }
  158. obj.innerText = newstr;
  159. //U.M.textCompatibleandStr(obj, newstr)
  160. }
  161. //判断字符串类型是是否带有' '这样的字符
  162. U.M.isBlank = function (szStr) {
  163. for (i = 0; i < szStr.length; i++) {
  164. if (szStr.substring(i, i + 1) == ' ') {
  165. return false;
  166. }
  167. break;
  168. }
  169. return true;
  170. }
  171. // 检查序列号格式 目前的格式类似 GUID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
  172. U.MS.Checkguid = function (object_value) {
  173. if (object_value.length == 0)
  174. return false;
  175. if (object_value.length != 38)
  176. return false;
  177. if (object_value.charAt(0) != "{")
  178. return false;
  179. if (object_value.charAt(37) != "}")
  180. return false;
  181. var hex_format = "0123456789abcdefABCDEF";
  182. var check_char;
  183. for (var i = 1; i < 37; i++) {
  184. if ((i == 9) || (i == 14) || (i == 19) || (i == 24)) {
  185. if (object_value.charAt(i) != "-")
  186. return false;
  187. } else {
  188. check_char = hex_format.indexOf(object_value.charAt(i));
  189. if (check_char < 0)
  190. return false;
  191. }
  192. }
  193. return true;
  194. }
  195. //跟进时间判定早中午时间,此函数未被使用
  196. U.MT.GetNowTime = function () {
  197. var time = new Date();
  198. var TimePart = document.getElementById("TimePart");
  199. var DataTime = time.getHours();
  200. if (DataTime >= 0 && DataTime < 12) {
  201. TimePart.innerHTML = "早上好!";
  202. }
  203. else if (DataTime >= 12 && DataTime < 18) {
  204. TimePart.innerHTML = "下午好!";
  205. }
  206. else {
  207. TimePart.innerHTML = "晚上好!";
  208. }
  209. }
  210. //使用U.MT.currenttime函数时转换UTC() 方法可根据世界时返回 1970 年 1 月 1 日 到指定日期的毫秒数。
  211. //Date.UTC(year,month,day,hours,minutes,seconds,ms)
  212. U.MT.DateUTC = function (STime) {
  213. STime = STime.split(" ");
  214. var MY = STime[0].split("/");
  215. var MS = STime[STime.length - 1].split(":");
  216. return "/Date(" + Date.UTC(MY[0], MY[1], MY[2], MS[0], MS[1], MS[2], 0) + ")/";
  217. }
  218. ////把json时间戳转为日期格式
  219. U.MT.getLocalTime = function (nS) {
  220. var _timeS = new Date(parseInt(nS.substring(6, nS.length - 2))).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
  221. if (!top.browser.msie) _timeS = _timeS.substring(10, 25);
  222. return _timeS;
  223. }
  224. //js获取当前的时间
  225. U.MT.currenttime = function () {
  226. var _currenttime = new Date();
  227. var _year = U.MT.getYear()//获取当前的年数
  228. var _month = _currenttime.getMonth() + 1; //获取当前的月份
  229. var _date = _currenttime.getDate(); //获取当前的日期
  230. var _houst = _currenttime.getHours(); //获取当前的小时
  231. var _Minutes = _currenttime.getMinutes(); //获取当前的分钟
  232. var _Seconds = _currenttime.getSeconds(); //获取当前的秒数
  233. return _year + '/' + _month + '/' + _date + ' ' + _houst + ':' + _Minutes + ':' + _Seconds; //返回用户现在的时间段 且样式复合项目的需求
  234. }
  235. U.MT.getDate = function (D) {
  236. if (D == null) { D = new Date(); }
  237. // if (date == null || date == "" || date == "undefined") date = new Date();
  238. // var yyyy = date.getFullYear();
  239. // var m = date.getMonth() + 1;
  240. // var mm = (m < 10) ? '0' + m : m;
  241. // var d = date.getDate();
  242. // var dd = (d < 10) ? '0' + d : d;
  243. // var h = date.getHours();
  244. // var hh = (h < 10) ? '0' + h : h;
  245. // var n = date.getMinutes();
  246. // var nn = (n < 10) ? '0' + n : n;
  247. // var s = date.getSeconds();
  248. // var ss = (s < 10) ? '0' + s : s;
  249. // return yyyy + "-" + mm + "-" + dd + " " + hh + ":" + nn + ":" + ss;
  250. }
  251. //返回月份的方法
  252. U.MT.GetMonth = function (month) {
  253. switch (month) {
  254. case "Jan":
  255. return "1";
  256. break;
  257. case "Feb":
  258. return "2";
  259. break;
  260. case "Mar":
  261. return "3";
  262. break;
  263. case "Apr":
  264. return "4";
  265. break;
  266. case "May":
  267. return "5";
  268. break;
  269. case "Jun":
  270. return "6";
  271. break;
  272. case "Jul":
  273. return "7";
  274. break;
  275. case "Aug":
  276. return "8";
  277. break;
  278. case "Sep":
  279. return "9";
  280. break;
  281. case "Oct":
  282. return "10";
  283. break;
  284. case "Nov":
  285. return "11";
  286. break;
  287. case "Dec":
  288. return "12";
  289. break;
  290. }
  291. }
  292. //转化星期
  293. U.MT.Getweek = function (week) {
  294. switch (week) {
  295. case "Mon":
  296. return "一";
  297. break;
  298. case "Tue":
  299. return "二";
  300. break;
  301. case "Wed":
  302. return "三";
  303. break;
  304. case "Thu":
  305. return "四";
  306. break;
  307. case "Fri":
  308. return "五";
  309. break;
  310. case "Sat":
  311. return "六";
  312. break;
  313. case "Sun":
  314. return "七";
  315. break;
  316. }
  317. }
  318. U.MT.DataTime = function (time) {
  319. time = eval('new ' + eval(time).source) + "";
  320. var strtime;
  321. _strtime = time.split(" ");
  322. _strtime[1] = U.MT.GetMonth(_strtime[1]); // 转化月份
  323. _strtime[0] = U.MT.Getweek(_strtime[0]); //转化星期
  324. return _strtime;
  325. }
  326. //用于blog的时间转换...转入2013-2-2 10:28:00 ...返回2013 2 2 10:28:00
  327. U.MT.DateAnalyze = function (TD) {
  328. TD = TD.split(" ");
  329. var MT = TD[0].split("/");
  330. MT = MT[0].split("-")
  331. MT[3] = TD[TD.length - 1];
  332. return MT;
  333. }
  334. //转换普通时间为Unix时间戳,返回的是US.userinfo中相同的类型-曾冠悦
  335. U.MT.getUnixTime = function (str_time) {
  336. var new_str = str_time.replace(/:/g, '-'); //替换冒号
  337. new_str = new_str.replace(/ /g, '-'); //替换空格
  338. var arr = new_str.split("-"); //转换成数组
  339. arr.length = 5;
  340. for (var i = 0; i < 6; i++) {
  341. if (arr[i] == undefined) {
  342. arr[i] = 0;
  343. }
  344. }
  345. return "/Date(" + Date.UTC(arr[0], arr[1] - 1, arr[2], arr[3] - 8, arr[4], arr[5]) + ")/";
  346. }
  347. //闰年
  348. U.MT.IsLeapYear = function (Y) {
  349. if ((Y % 400 == 0 && Y % 100 == 0) || (Y % 4 == 0 && Y % 100 != 0)) { return true; }
  350. else { return false; }
  351. }
  352. //函数作用,获取年份
  353. //在IE中得到的日期是"2011",在Firefox中看到的日期是"111",主要是因为在 Firefox 里面 getYear 返回的是 "当前年份-1900" 的值。
  354. U.MT.getYear = function () {
  355. var year = new Date().getYear();
  356. year = (year < 1900 ? (1900 + year) : year);
  357. return year;
  358. }
  359. //获取当前月份
  360. U.MT.getNowMonth = function () {
  361. var month = new Date().getMonth() + 1;
  362. return month;
  363. }
  364. //获取日期
  365. U.MT.getNowDate = function () {
  366. var date = new Date().getDate();
  367. return date;
  368. }
  369. //获取月份的天数,2月需要年参数
  370. U.MT.getDayOfMonth = function (month, year) {
  371. if (month == 4 || month == 6 || month == 9 || month == 11) {
  372. return 30;
  373. }
  374. if (month == 2) {
  375. if (U.MT.IsLeapYear(year)) {
  376. return 29;
  377. }
  378. else return 28;
  379. }
  380. return 31;
  381. }
  382. U.MS.PY = { 0xB0A1: "a", 0xB0A3: "ai", 0xB0B0: "an", 0xB0B9: "ang", 0xB0BC: "ao", 0xB0C5: "ba", 0xB0D7: "bai", 0xB0DF: "ban", 0xB0EE: "bang", 0xB0FA: "bao", 0xB1AD: "bei", 0xB1BC: "ben", 0xB1C0: "beng", 0xB1C6: "bi", 0xB1DE: "bian", 0xB1EA: "biao", 0xB1EE: "bie", 0xB1F2: "bin", 0xB1F8: "bing", 0xB2A3: "bo", 0xB2B8: "bu", 0xB2C1: "ca", 0xB2C2: "cai", 0xB2CD: "can", 0xB2D4: "cang", 0xB2D9: "cao", 0xB2DE: "ce", 0xB2E3: "ceng", 0xB2E5: "cha", 0xB2F0: "chai", 0xB2F3: "chan", 0xB2FD: "chang", 0xB3AC: "chao", 0xB3B5: "che", 0xB3BB: "chen", 0xB3C5: "cheng", 0xB3D4: "chi", 0xB3E4: "chong", 0xB3E9: "chou", 0xB3F5: "chu", 0xB4A7: "chuai", 0xB4A8: "chuan", 0xB4AF: "chuang", 0xB4B5: "chui", 0xB4BA: "chun", 0xB4C1: "chuo", 0xB4C3: "ci", 0xB4CF: "cong", 0xB4D5: "cou", 0xB4D6: "cu", 0xB4DA: "cuan", 0xB4DD: "cui", 0xB4E5: "cun", 0xB4E8: "cuo", 0xB4EE: "da", 0xB4F4: "dai", 0xB5A2: "dan", 0xB5B1: "dang", 0xB5B6: "dao", 0xB5C2: "de", 0xB5C5: "deng", 0xB5CC: "di", 0xB5DF: "dian", 0xB5EF: "diao", 0xB5F8: "die", 0xB6A1: "ding", 0xB6AA: "diu", 0xB6AB: "dong", 0xB6B5: "dou", 0xB6BC: "du", 0xB6CB: "duan", 0xB6D1: "dui", 0xB6D5: "dun", 0xB6DE: "duo", 0xB6EA: "e", 0xB6F7: "en", 0xB6F8: "er", 0xB7A2: "fa", 0xB7AA: "fan", 0xB7BB: "fang", 0xB7C6: "fei", 0xB7D2: "fen", 0xB7E1: "feng", 0xB7F0: "fo", 0xB7F1: "fou", 0xB7F2: "fu", 0xB8C1: "ga", 0xB8C3: "gai", 0xB8C9: "gan", 0xB8D4: "gang", 0xB8DD: "gao", 0xB8E7: "ge", 0xB8F8: "gei", 0xB8F9: "gen", 0xB8FB: "geng", 0xB9A4: "gong", 0xB9B3: "gou", 0xB9BC: "gu", 0xB9CE: "gua", 0xB9D4: "guai", 0xB9D7: "guan", 0xB9E2: "guang", 0xB9E5: "gui", 0xB9F5: "gun", 0xB9F8: "guo", 0xB9FE: "ha", 0xBAA1: "hai", 0xBAA8: "han", 0xBABB: "hang", 0xBABE: "hao", 0xBAC7: "he", 0xBAD9: "hei", 0xBADB: "hen", 0xBADF: "heng", 0xBAE4: "hong", 0xBAED: "hou", 0xBAF4: "hu", 0xBBA8: "hua", 0xBBB1: "huai", 0xBBB6: "huan", 0xBBC4: "huang", 0xBBD2: "hui", 0xBBE7: "hun", 0xBBED: "huo", 0xBBF7: "ji", 0xBCCE: "jia", 0xBCDF: "jian", 0xBDA9: "jiang", 0xBDB6: "jiao", 0xBDD2: "jie", 0xBDED: "jin", 0xBEA3: "jing", 0xBEBC: "jiong", 0xBEBE: "jiu", 0xBECF: "ju", 0xBEE8: "juan", 0xBEEF: "jue", 0xBEF9: "jun", 0xBFA6: "ka", 0xBFAA: "kai", 0xBFAF: "kan", 0xBFB5: "kang", 0xBFBC: "kao", 0xBFC0: "ke", 0xBFCF: "ken", 0xBFD3: "keng", 0xBFD5: "kong", 0xBFD9: "kou", 0xBFDD: "ku", 0xBFE4: "kua", 0xBFE9: "kuai", 0xBFED: "kuan", 0xBFEF: "kuang", 0xBFF7: "kui", 0xC0A4: "kun", 0xC0A8: "kuo", 0xC0AC: "la", 0xC0B3: "lai", 0xC0B6: "lan", 0xC0C5: "lang", 0xC0CC: "lao", 0xC0D5: "le", 0xC0D7: "lei", 0xC0E2: "leng", 0xC0E5: "li", 0xC1A9: "lia", 0xC1AA: "lian", 0xC1B8: "liang", 0xC1C3: "liao", 0xC1D0: "lie", 0xC1D5: "lin", 0xC1E1: "ling", 0xC1EF: "liu", 0xC1FA: "long", 0xC2A5: "lou", 0xC2AB: "lu", 0xC2BF: "lv", 0xC2CD: "luan", 0xC2D3: "lue", 0xC2D5: "lun", 0xC2DC: "luo", 0xC2E8: "ma", 0xC2F1: "mai", 0xC2F7: "man", 0xC3A2: "mang", 0xC3A8: "mao", 0xC3B4: "me", 0xC3B5: "mei", 0xC3C5: "men", 0xC3C8: "meng", 0xC3D0: "mi", 0xC3DE: "mian", 0xC3E7: "miao", 0xC3EF: "mie", 0xC3F1: "min", 0xC3F7: "ming", 0xC3FD: "miu", 0xC3FE: "mo", 0xC4B1: "mou", 0xC4B4: "mu", 0xC4C3: "na", 0xC4CA: "nai", 0xC4CF: "nan", 0xC4D2: "nang", 0xC4D3: "nao", 0xC4D8: "ne", 0xC4D9: "nei", 0xC4DB: "nen", 0xC4DC: "neng", 0xC4DD: "ni", 0xC4E8: "nian", 0xC4EF: "niang", 0xC4F1: "niao", 0xC4F3: "nie", 0xC4FA: "nin", 0xC4FB: "ning", 0xC5A3: "niu", 0xC5A7: "nong", 0xC5AB: "nu", 0xC5AE: "nv", 0xC5AF: "nuan", 0xC5B0: "nue", 0xC5B2: "nuo", 0xC5B6: "o", 0xC5B7: "ou", 0xC5BE: "pa", 0xC5C4: "pai", 0xC5CA: "pan", 0xC5D2: "pang", 0xC5D7: "pao", 0xC5DE: "pei", 0xC5E7: "pen", 0xC5E9: "peng", 0xC5F7: "pi", 0xC6AA: "pian", 0xC6AE: "piao", 0xC6B2: "pie", 0xC6B4: "pin", 0xC6B9: "ping", 0xC6C2: "po", 0xC6CB: "pu", 0xC6DA: "qi", 0xC6FE: "qia", 0xC7A3: "qian", 0xC7B9: "qiang", 0xC7C1: "qiao", 0xC7D0: "qie", 0xC7D5: "qin", 0xC7E0: "qing", 0xC7ED: "qiong", 0xC7EF: "qiu", 0xC7F7: "qu", 0xC8A6: "quan", 0xC8B1: "que", 0xC8B9: "qun", 0xC8BB: "ran", 0xC8BF: "rang", 0xC8C4: "rao", 0xC8C7: "re", 0xC8C9: "ren", 0xC8D3: "reng", 0xC8D5: "ri", 0xC8D6: "rong", 0xC8E0: "rou", 0xC8E3: "ru", 0xC8ED: "ruan", 0xC8EF: "rui", 0xC8F2: "run", 0xC8F4: "ruo", 0xC8F6: "sa", 0xC8F9: "sai", 0xC8FD: "san", 0xC9A3: "sang", 0xC9A6: "sao", 0xC9AA: "se", 0xC9AD: "sen", 0xC9AE: "seng", 0xC9AF: "sha", 0xC9B8: "shai", 0xC9BA: "shan", 0xC9CA: "shang", 0xC9D2: "shao", 0xC9DD: "she", 0xC9E9: "shen", 0xC9F9: "sheng", 0xCAA6: "shi", 0xCAD5: "shou", 0xCADF: "shu", 0xCBA2: "shua", 0xCBA4: "shuai", 0xCBA8: "shuan", 0xCBAA: "shuang", 0xCBAD: "shui", 0xCBB1: "shun", 0xCBB5: "shuo", 0xCBB9: "si", 0xCBC9: "song", 0xCBD1: "sou", 0xCBD4: "su", 0xCBE1: "suan", 0xCBE4: "sui", 0xCBEF: "sun", 0xCBF2: "suo", 0xCBFA: "ta", 0xCCA5: "tai", 0xCCAE: "tan", 0xCCC0: "tang", 0xCCCD: "tao", 0xCCD8: "te", 0xCCD9: "teng", 0xCCDD: "ti", 0xCCEC: "tian", 0xCCF4: "tiao", 0xCCF9: "tie", 0xCCFC: "ting", 0xCDA8: "tong", 0xCDB5: "tou", 0xCDB9: "tu", 0xCDC4: "tuan", 0xCDC6: "tui", 0xCDCC: "tun", 0xCDCF: "tuo", 0xCDDA: "wa", 0xCDE1: "wai", 0xCDE3: "wan", 0xCDF4: "wang", 0xCDFE: "wei", 0xCEC1: "wen", 0xCECB: "weng", 0xCECE: "wo", 0xCED7: "wu", 0xCEF4: "xi", 0xCFB9: "xia", 0xCFC6: "xian", 0xCFE0: "xiang", 0xCFF4: "xiao", 0xD0A8: "xie", 0xD0BD: "xin", 0xD0C7: "xing", 0xD0D6: "xiong", 0xD0DD: "xiu", 0xD0E6: "xu", 0xD0F9: "xuan", 0xD1A5: "xue", 0xD1AB: "xun", 0xD1B9: "ya", 0xD1C9: "yan", 0xD1EA: "yang", 0xD1FB: "yao", 0xD2AC: "ye", 0xD2BB: "yi", 0xD2F0: "yin", 0xD3A2: "ying", 0xD3B4: "yo", 0xD3B5: "yong", 0xD3C4: "you", 0xD3D9: "yu", 0xD4A7: "yuan", 0xD4BB: "yue", 0xD4C5: "yun", 0xD4D1: "za", 0xD4D4: "zai", 0xD4DB: "zan", 0xD4DF: "zang", 0xD4E2: "zao", 0xD4F0: "ze", 0xD4F4: "zei", 0xD4F5: "zen", 0xD4F6: "zeng", 0xD4FA: "zha", 0xD5AA: "zhai", 0xD5B0: "zhan", 0xD5C1: "zhang", 0xD5D0: "zhao", 0xD5DA: "zhe", 0xD5E4: "zhen", 0xD5F4: "zheng", 0xD6A5: "zhi", 0xD6D0: "zhong", 0xD6DB: "zhou", 0xD6E9: "zhu", 0xD7A5: "zhua", 0xD7A7: "zhuai", 0xD7A8: "zhuan", 0xD7AE: "zhuang", 0xD7B5: "zhui", 0xD7BB: "zhun", 0xD7BD: "zhuo", 0xD7C8: "zi", 0xD7D7: "zong", 0xD7DE: "zou", 0xD7E2: "zu", 0xD7EA: "zuan", 0xD7EC: "zui", 0xD7F0: "zun", 0xD7F2: "zuo" }
  383. //获取中文拼音
  384. U.MS.PYS = function (UST) {//U.MS.PY
  385. var i, _UCT = UST.charCodeAt(0); //拼音编码
  386. if (_UCT && (_UCT > 0xB0A0 && _UCT < 0xD7FC)) { for (i = _UCT; (!(_UCT = U.MS.PY[i]) && i > 0xB0A1); ) { i--; } } //如果为拼音
  387. return _UCT;
  388. }
  389. U.MS.PYS("你");
  390. Namespace.register("U.Imges"); //久的图片浏览器
  391. USPhotoImgJson = null;
  392. //图片预加载(摘自:http://www.planeart.cn/demo/imgReady/ )=========================================================================================================================
  393. //使用方法ImgReady(图片URL,加载头文件成功执行函数(即获得图片长宽),加载图片成功执行函数,加载图片失败执行函数);
  394. //imgReady('images/logo_cn.png', function () {alert('size ready: width=' + this.width + '; height=' + this.height);},function(){alert("加载成功")},function(){alert("加载失败")});
  395. U.Imges.ImgReady = (function () {
  396. var list = [], intervalId = null,
  397. // 用来执行队列
  398. tick = function () {
  399. var i = 0;
  400. for (; i < list.length; i++) {
  401. list[i].end ? list.splice(i--, 1) : list[i]();
  402. };
  403. !list.length && stop();
  404. },
  405. //停止所有定时器队列
  406. stop = function () {
  407. clearInterval(intervalId);
  408. intervalId = null;
  409. };
  410. return function (url, ready, load, error) {
  411. var onready, width, height, newWidth, newHeight,
  412. img = new Image();
  413. img.src = url;
  414. // 如果图片被缓存,则直接返回缓存数据
  415. if (img.complete) {
  416. ready.call(img);
  417. load && load.call(img);
  418. return;
  419. };
  420. width = img.width;
  421. height = img.height;
  422. // 加载错误后的事件
  423. img.onerror = function () {
  424. error && error.call(img);
  425. //onready.end = true;
  426. img = img.onload = img.onerror = null;
  427. };
  428. // 图片尺寸就绪
  429. img.onreadystatechange = function () {
  430. if (document.readyState == "complete") {
  431. newWidth = img.width;
  432. newHeight = img.height;
  433. // 如果图片已经在其他地方加载可使用面积检测
  434. if (newWidth !== width || newHeight !== height || newWidth * newHeight > 1024) {
  435. ready.call(img);
  436. //onready.end = true;
  437. };
  438. };
  439. };
  440. // onready = function () {
  441. // newWidth = img.width;
  442. // newHeight = img.height;
  443. // // 如果图片已经在其他地方加载可使用面积检测
  444. // if (newWidth !== width || newHeight !== height || newWidth * newHeight > 1024) {
  445. // ready.call(img);
  446. // onready.end = true;
  447. // };
  448. // };
  449. // onready();
  450. // 完全加载完毕的事件
  451. img.onload = function () {
  452. // onload在定时器时间差范围内可能比onready快
  453. // 这里进行检查并保证onready优先执行
  454. //!onready.end && onready();
  455. load && load.call(img);
  456. // IE gif动画会循环执行onload,置空onload即可
  457. img = img.onload = img.onerror = null;
  458. };
  459. // 加入队列中定期执行
  460. // if (!onready.end) {
  461. // list.push(onready);
  462. // // 无论何时只允许出现一个定时器,减少浏览器性能损耗
  463. // if (intervalId === null) intervalId = setInterval(tick, 40);
  464. // };
  465. };
  466. })();
  467. //图片预加载(摘自:http://www.planeart.cn/demo/imgReady/ )=========================================================================================================================
  468. //图片居中旋转(编写:郭仁)========================================================================================================================================================
  469. //传入图片对象,与旋转方向(值:'left' or 'right')
  470. //使用方法imgRoll(document.getElementById("ImgObj"),"left");
  471. U.Imges.imgRoll = function (imgObj, SX, ArcSizeInt) {
  472. var ArcSize = imgObj.alt == null ? 0 : parseInt(imgObj.alt); //通过图片对象中的alt属性进行储存现行角度(1=90度;2=180度;3=270度;4=360度=0度)
  473. //判断SX进行角度增减
  474. if (SX == "left") {
  475. ArcSize += 1;
  476. ArcSize = ArcSize > 4 ? 0 : ArcSize;
  477. } else if (SX == "right") {
  478. ArcSize -= 1;
  479. ArcSize = ArcSize < 0 ? 3 : ArcSize;
  480. } else if (SX == "int") {
  481. ArcSize = ArcSizeInt;
  482. }
  483. //因为CSS旋转滤镜的实现方式不同~~需要进行不同的浏览判断给予定位
  484. imgObj.parentNode.style.width = ArcSize % 2 == 0 ? imgObj.width + (2 * 7) + "px" : imgObj.height + (2 * 7) + "px";
  485. imgObj.parentNode.style.height = ArcSize % 2 == 0 ? imgObj.height + (2 * 7) + "px" : imgObj.width + (2 * 7) + "px";
  486. if (!browser.msie) {
  487. if (ArcSize % 2 != 0) {
  488. imgObj.style.left = Math.ceil((parseInt(imgObj.parentNode.style.width) - parseInt(imgObj.parentNode.style.height)) / 2) + "px";
  489. imgObj.style.top = Math.ceil((parseInt(imgObj.parentNode.style.height) - parseInt(imgObj.parentNode.style.width)) / 2) + "px";
  490. imgObj.parentNode.style.left = parseInt(imgObj.parentNode.style.left) - parseInt(imgObj.style.left) + "px";
  491. imgObj.parentNode.style.top = parseInt(imgObj.parentNode.style.top) - parseInt(imgObj.style.top) + "px";
  492. } else {
  493. imgObj.parentNode.style.left = parseInt(imgObj.parentNode.style.left) + parseInt(imgObj.style.left) + "px";
  494. imgObj.parentNode.style.top = parseInt(imgObj.parentNode.style.top) + parseInt(imgObj.style.top) + "px";
  495. imgObj.style.left = "0px";
  496. imgObj.style.top = "0px";
  497. }
  498. }
  499. // else {
  500. // imgObj.parentNode.style.left = parseInt(imgObj.parentNode.getBoundingClientRect().left) - Math.ceil((parseInt(imgObj.parentNode.style.width) - parseInt(imgObj.parentNode.style.height)) / 2) + "px";
  501. // imgObj.parentNode.style.top = parseInt(imgObj.parentNode.getBoundingClientRect().top) - Math.ceil((parseInt(imgObj.parentNode.style.height) - parseInt(imgObj.parentNode.style.width)) / 2) + "px";
  502. // }
  503. imgObj.alt = ArcSize; //将角度值置于图片对象alt属性中
  504. //css旋转滤镜兼容
  505. imgObj.style.filter = 'Progid:DXImageTransform.Microsoft.BasicImage(Rotation=' + ArcSize + ')';
  506. imgObj.style.WebkitTransform = 'rotate(' + ArcSize * 90 + 'deg)';
  507. imgObj.style.MozTransform = 'rotate(' + ArcSize * 90 + 'deg)';
  508. imgObj.style.OTransform = 'rotate(' + ArcSize * 90 + 'deg)';
  509. }
  510. //图片居中旋转(编写:郭仁)========================================================================================================================================================
  511. //放大缩小【不影响于旋转后放大缩小的BUG~~】(编写:郭仁)============================================================================================================================
  512. //传入(图片对象,原始宽,原始高)~~
  513. U.Imges.Scale = function (ImgObj, nwidth, nheight) {
  514. var event = arguments.callee.caller.arguments[0] || window.event; //消除浏览器差异
  515. //滑动条位置
  516. var x = event.clientX - 80;
  517. var y = event.clientY - 20;
  518. //缩放比例~~
  519. var Scale = nwidth / nheight;
  520. //现行角度
  521. var ArcSize = ImgObj.alt == null ? 0 : parseInt(ImgObj.alt);
  522. if (document.getElementById("SlideCase_" + ImgObj.id) == null) {//判断滑动条是否已存在
  523. //创建滑动条
  524. var SlideCase = new U.Imges.SliderContorl(ImgObj.id, 200, 50, x, y, function (percentage) {
  525. ImgObj.style.width = nwidth * (percentage / 100) + "px";
  526. ImgObj.style.height = parseInt(ImgObj.style.width) / Scale + "px";
  527. if (ArcSize % 2 != 0) {
  528. ImgObj.parentNode.style.width = parseInt(ImgObj.style.height) + (2 * 7) + "px";
  529. ImgObj.parentNode.style.height = parseInt(ImgObj.style.width) + (2 * 7) + "px";
  530. if (browser.chrome || browser.firefox) {
  531. ImgObj.style.left = Math.ceil((parseInt(ImgObj.parentNode.style.width) - parseInt(ImgObj.parentNode.style.height)) / 2) + "px";
  532. ImgObj.style.top = Math.ceil((parseInt(ImgObj.parentNode.style.height) - parseInt(ImgObj.parentNode.style.width)) / 2) + "px";
  533. }
  534. } else {
  535. ImgObj.parentNode.style.width = parseInt(ImgObj.style.width) + (2 * 7) + "px";
  536. ImgObj.parentNode.style.height = parseInt(ImgObj.style.height) + (2 * 7) + "px";
  537. }
  538. });
  539. document.body.appendChild(SlideCase);
  540. }
  541. }
  542. //放大缩小【不影响于旋转后放大缩小的BUG~~】(编写:郭仁)============================================================================================================================
  543. //stackBlurImage(ImgStr, CanvasStr, percentage, false);
  544. //滑动条创建(编写:郭仁)==========================================================================================================================================================
  545. //通过传入[ID(为了避免多次创建同样功能滑动条);最大值;最小值;x;y;滑动块left改变后执行函数]
  546. //使用方法
  547. // if(document.getElementById("SlideCase_20")==null){
  548. // var DemoSlider = SliderContorl("20",200, 50, x, y, function (percentage) {
  549. // alert(percentage);
  550. // });
  551. // document.body.appendChild(DemoSlider);
  552. // }
  553. U.Imges.SliderContorl = function (id, max, min, left, top, callback) {
  554. var fadeOut = null; //淡出计时器Interval
  555. var removealertBar = null; //移除提示框计时器Timeout
  556. var percentage = 0; //滑动所在百分比
  557. //动态创建滑动框=====================================================================
  558. var SlideCase = document.createElement("div");
  559. SlideCase.id = "SlideCase_" + id; //每个滑动条都有自己的ID
  560. SlideCase.className = "ImgViewer SlideCase";
  561. SlideCase.style.left = left + "px";
  562. SlideCase.style.top = top + "px";
  563. //禁止选取
  564. SlideCase.onmousedown = function () { return false; } //IE;
  565. SlideCase.onselectstart = function () { return false; } //FireFox;Chorme
  566. //滑动条--------------------------------------------------
  567. var SlideBar = document.createElement("div");
  568. SlideBar.id = "SlideBar"
  569. SlideBar.className = "SlideBar";
  570. //滑动块--------------------------------------------------
  571. var SlidhingShoe = document.createElement("a");
  572. SlidhingShoe.id = "SlidhingShoe";
  573. SlidhingShoe.className = "ImgViewer SlidhingShoe";
  574. //移除按钮------------------------------------------------
  575. var CloseSlideButton = document.createElement("div");
  576. CloseSlideButton.id = "Slidhing_CloseSlideButton"
  577. CloseSlideButton.className = "Slidhing_CloseSlideButton";
  578. CloseSlideButton.onclick = function () { SlideCase.parentNode.removeChild(SlideCase); }
  579. //提示框--------------------------------------------------
  580. var alertBar = document.createElement("div");
  581. alertBar.id = "Slidhing_alertBar";
  582. alertBar.style.display = "none";
  583. alertBar.className = "ImgViewer Slidhing_alertBar";
  584. //添加到各各节点-------------------------------------------
  585. SlideBar.appendChild(SlidhingShoe);
  586. SlideCase.appendChild(SlideBar);
  587. SlideCase.appendChild(CloseSlideButton);
  588. SlideCase.appendChild(alertBar);
  589. //两个主要事件=====================================================================
  590. //提示框淡出消失函数
  591. var AlertFadeIn = function () {
  592. //提示框样式重置
  593. alertBar.style.filter = "alpha(opacity=100)";
  594. alertBar.style.MozOpacity = "1";
  595. alertBar.style.opacity = "1";
  596. alertBar.style.display = "inline-block";
  597. //再次清扫计时器防止内存溢出
  598. clearInterval(fadeOut);
  599. clearTimeout(removealertBar);
  600. //特效开始
  601. removealertBar = setTimeout(function () {
  602. i = 100;
  603. fadeOut = setInterval(function () {
  604. alertBar.style.filter = "alpha(opacity=" + i + ")";
  605. alertBar.style.MozOpacity = i * 0.01;
  606. alertBar.style.opacity = i * 0.01;
  607. i -= 2;
  608. if (i == 0) {
  609. alertBar.style.display = "none";
  610. //清扫计时器防止内存溢出
  611. clearInterval(fadeOut);
  612. clearTimeout(removealertBar);
  613. }
  614. }, 1);
  615. }, 800);
  616. }
  617. //滑动块移动或滑动条被点击后执行函数
  618. var mouse_down_or_move = function () {
  619. var pole = event.clientX - parseInt(SlideCase.style.left) - 25; //计算滑动块left
  620. //限制最小left与最大left
  621. pole = pole < 0 ? 0 : pole;
  622. pole = pole > 120 ? 120 : pole;
  623. SlidhingShoe.style.left = pole + "px";
  624. //给提示框赋予left值;使提示框跟着滑动块移动
  625. alertBar.style.left = pole - 20 + "px";
  626. percentage = pole * ((max - min) / 120) + min; //计算滑动条现行百分比
  627. alertBar.innerHTML = Math.round(percentage) + "%";
  628. callback(percentage); //回调传入函数
  629. }
  630. //给滑动条与滑动块进行事件处理==========================================
  631. SlideBar.onmousedown = function () {
  632. mouse_down_or_move();
  633. alertBar.style.display = "inline-block";
  634. }
  635. SlideBar.onmouseup = function () {
  636. if (!browser.msie) {
  637. AlertFadeIn();
  638. } else {
  639. clearTimeout(removealertBar);
  640. removealertBar = setTimeout(function () {
  641. alertBar.style.display = "none";
  642. clearTimeout(removealertBar);
  643. }, 800);
  644. }
  645. }
  646. SlidhingShoe.onmousedown = function () {
  647. var ismoveSlide = true;
  648. document.body.onmousemove = function () {
  649. if (ismoveSlide == true) {
  650. mouse_down_or_move();
  651. alertBar.style.display = "inline-block";
  652. if (!browser.msie) {
  653. alertBar.style.filter = "alpha(opacity=" + i + ")";
  654. alertBar.style.MozOpacity = i * 0.01;
  655. alertBar.style.opacity = i * 0.01;
  656. }
  657. }
  658. }
  659. document.body.onmouseup = function () {
  660. if (document.all != undefined) SlidhingShoe.releaseCapture(); //鼠标事件制焦
  661. ismoveSlide = false;
  662. if (!browser.msie) {
  663. AlertFadeIn();
  664. } else {
  665. clearTimeout(removealertBar);
  666. removealertBar = setTimeout(function () {
  667. alertBar.style.display = "none";
  668. clearTimeout(removealertBar);
  669. }, 800);
  670. }
  671. document.body.onmouseup = function () { return false; }
  672. }
  673. }
  674. return SlideCase; //返回滑动条
  675. }
  676. //滑动条创建(编写:郭仁)==========================================================================================================================================================
  677. //恢复1:1实际比例===================================================================================================================================================================
  678. //传入图片对象,原宽,原高
  679. U.Imges.ActuleScale = function (ImgObj, width, height) {
  680. ImgObj.style.width = width + "px";
  681. ImgObj.style.height = height + "px";
  682. ImgObj.parentNode.style.width = parseInt(ImgObj.style.width) + (2 * 7) + "px";
  683. ImgObj.parentNode.style.height = parseInt(ImgObj.style.height) + (2 * 7) + "px";
  684. }
  685. //创建图片框========================================================================================================================================================================
  686. //传入图片ID(防止同时出现多个同ID导致网页出错),图片地址,JSON【KEY】(你懂的~~可为空~~)
  687. U.Imges.CreatePhotoCase = function (imgid, url, key) {
  688. var nwidth = 0; //原宽
  689. var nheight = 0; //原高
  690. // if (window.top.document.getElementById("ImgViewer_Div" + imgid) != null) {//如果已创建此相框则返回此相框
  691. // return window.top.document.getElementById("ImgViewer_Div" + imgid);
  692. // }
  693. //var IV_Div = window.top.document.getElementById("ImgViewer_Div");
  694. var IV_Div = window.top.$('#ImgViewer_Div')[0];
  695. if (IV_Div != null) {//如果已创建过相框则只在更改图片及管理框 ——简炜杰
  696. var img = $("Img", IV_Div)[0];
  697. //更换图片ID
  698. img.id = "ImgViewer_Img" + imgid;
  699. //图片大小处理以及重新加载管理框
  700. var _ready = function () {
  701. return function () {
  702. var nImg = new Image();
  703. nImg.src = url;
  704. var nwidth = nImg.width;
  705. var nheight = nImg.height;
  706. if (nImg.width > 800 || nImg.height > 600) {
  707. if (nImg.width > nImg.height) {
  708. nwidth = 800;
  709. nheight = nwidth / (nImg.width / nImg.height);
  710. } else {
  711. nheight = 600;
  712. nwidth = nheight * (nImg.width / nImg.height);
  713. }
  714. } else if (nImg.height < 200) {
  715. nheight = 200;
  716. nwidth = nheight * (nImg.width / nImg.height);
  717. } else {
  718. nwidth = nImg.width;
  719. nheight = nImg.height;
  720. }
  721. img.style.height = nheight + "px";
  722. img.style.width = nwidth + "px";
  723. IV_Div.style.height = nheight + 14 + "px";
  724. IV_Div.style.width = nwidth + 14 + "px";
  725. var strCode = '<a class="samllRadius ImgViewer ImgViewer_CloseIcon" href="javascript:void(0)" onclick="this.parentNode.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode.parentNode); if (top.document.getElementById(\'SlideCase_' + img.id + '\')!=null){ top.document.getElementById(\'SlideCase_' + img.id + '\').parentNode.removeChild(top.document.getElementById(\'SlideCase_' + img.id + '\'));}"></a>';
  726. strCode += '<a class="samllRadius ImgViewer ImgViewer_ImgRollLeftIcon" href="javascript:void(0)" onclick="U.Imges.imgRoll(document.getElementById(\'ImgViewer_Img' + imgid + '\'),\'left\')" ></a>';
  727. strCode += '<a class="samllRadius ImgViewer ImgViewer_ImgRollRightIcon" href="javascript:void(0)" onclick="U.Imges.imgRoll(document.getElementById(\'ImgViewer_Img' + imgid + '\'),\'right\')"></a>';
  728. strCode += '<a class="samllRadius ImgViewer ImgViewer_ScaleIcon" href="javascript:void(0)" onclick="U.Imges.Scale(document.getElementById(\'ImgViewer_Img' + imgid + '\'),' + nwidth + ',' + nheight + ')"></a>';
  729. strCode += '<a class="samllRadius ImgViewer ImgViewer_ActuleIcon" href="javascript:void(0)" onclick="U.Imges.ActuleScale(document.getElementById(\'ImgViewer_Img' + imgid + '\'),' + nwidth + ',' + nheight + ')"></a>';
  730. strCode += '<a class="samllRadius ImgViewer ImgViewer_ThumbnailsIcon" href="javascript:void(0)" onclick="if(USPhotoImgJson!=null) document.getElementById(\'ImgViewer_ThumbnailsCase\').style.display=\'inline-block\';"></a>';
  731. $('#ImgViewer_manager')[0].innerHTML = strCode;
  732. U.Imges.ActuleScale(img, nwidth, nheight);
  733. }
  734. }
  735. _ready = _ready();
  736. //加载图片
  737. U.Imges.ImgReady(url, _ready, function () { img.src = url; }, function () { alert("加载失败"); ImgDiv.parentNode.removeChild(ImgDiv); });
  738. return;
  739. }
  740. //创建相框==============================================================
  741. var ImgDiv = document.createElement("div");
  742. //ImgDiv.id = "ImgViewer_Div" + imgid;
  743. //相框只生成一次,ID改为唯一 ——简炜杰
  744. ImgDiv.id = "ImgViewer_Div";
  745. ImgDiv.className = "ImgViewer_Div ImgViewer_shadow";
  746. //禁止选取
  747. ImgDiv.onmousedown = function () { return false; } //IE;
  748. ImgDiv.onselectstart = function () { return false; } //FireFox;Chorme
  749. //创建管理框============================================================
  750. var managerBar = document.createElement("div");
  751. managerBar.id = "ImgViewer_managerBar";
  752. managerBar.className = "ImgViewer ImgViewer_managerBar";
  753. //创建管理对齐DIV=======================================================
  754. var manager = document.createElement("div");
  755. manager.id = "ImgViewer_manager";
  756. manager.className = "ImgViewer_manager";
  757. //创建图片元素==========================================================
  758. var USPhotoImg = document.createElement("img");
  759. USPhotoImg.id = "ImgViewer_Img" + imgid;
  760. USPhotoImg.className = "ImgViewer_Img";
  761. USPhotoImg.alt = "0";
  762. USPhotoImg.src = "img/loading.png";
  763. USPhotoImg.onmousedown = function () { U.D.DragMouseDown(ImgDiv, "ImgViewer"); }
  764. if (key != null && key != "") {//如果KEY值为空则不显示上一张与下一张
  765. //创建对齐框==========================================================
  766. var gobackdiv = document.createElement("div");
  767. gobackdiv.id = "ImgViewer_gobackdiv";
  768. gobackdiv.className = "ImgViewer_gobackdiv";
  769. //创建上一张按钮======================================================
  770. var go = document.createElement("i");
  771. go.id = "ImgViewer_go";
  772. go.className = "ImgViewer ImgViewer_go";
  773. go.onclick = function () {
  774. goorback("g");
  775. }
  776. go.onmouseover = function () {
  777. gobackdiv.style.display = "inline-block";
  778. }
  779. go.onmouseout = function () {
  780. gobackdiv.style.display = "none";
  781. }
  782. //创建下一张按钮======================================================
  783. var back = document.createElement("i");
  784. back.id = "ImgViewer_back";
  785. back.className = "ImgViewer ImgViewer_back";
  786. back.onclick = function () {
  787. goorback("b");
  788. }
  789. back.onmouseover = function () {
  790. gobackdiv.style.display = "inline-block";
  791. }
  792. back.onmouseout = function () {
  793. gobackdiv.style.display = "none";
  794. }
  795. USPhotoImg.onmouseover = function () {
  796. gobackdiv.style.display = "inline-block";
  797. }
  798. USPhotoImg.onmouseout = function () {
  799. gobackdiv.style.display = "none";
  800. }
  801. gobackdiv.appendChild(go);
  802. gobackdiv.appendChild(back);
  803. ImgDiv.appendChild(gobackdiv);
  804. var goorback = function (gb) {
  805. //如果滑动条存在为以防出错而将原图滑动条隐藏
  806. if (document.getElementById("SlideCase_" + USPhotoImg.id) != null) document.getElementById("SlideCase_" + USPhotoImg.id).parentNode.removeChild(document.getElementById("SlideCase_" + USPhotoImg.id));
  807. U.Imges.imgRoll(USPhotoImg, "int", 0); //恢复旋转角度
  808. if (gb == "g") {
  809. key--;
  810. } else if (gb == "b") {
  811. key++;
  812. }
  813. key = key < 0 ? USPhotoImgJson.length - 1 : key;
  814. key = key > USPhotoImgJson.length - 1 ? 0 : key;
  815. var Img = USPhotoImgJson[key]; //选择JSON
  816. //更换ID
  817. //相框只生成一次,ID改为唯一,无需更换 ——简炜杰
  818. //ImgDiv.id = "ImgViewer_Div" + Img.imgid;
  819. USPhotoImg.id = "ImgViewer_Img" + Img.imgid;
  820. //执行图片预加载~~
  821. var _e = function () {
  822. return function () {
  823. var nwidth = this.width;
  824. var nheight = this.height;
  825. if (this.width > 800 || this.height > 600) {
  826. if (this.width > this.height) {
  827. nwidth = 800;
  828. nheight = nwidth / (this.width / this.height);
  829. } else {
  830. nheight = 600;
  831. nwidth = nheight * (this.width / this.height);
  832. }
  833. } else if (this.height < 200) {
  834. nheight = 200;
  835. nwidth = nheight * (this.width / this.height);
  836. } else {
  837. nwidth = this.width;
  838. nheight = this.height;
  839. }
  840. ImageReady(Img.imgid, nwidth, nheight);
  841. gobackdiv.style.bottom = (nheight + (2 * 7)) / 2 - 15 + "px";
  842. }
  843. }
  844. _e = _e();
  845. U.Imges.ImgReady(Img.imgurl, _e, function () { USPhotoImg.src = this.src; }, function () { alert("加载失败"); ImgDiv.parentNode.removeChild(ImgDiv); });
  846. }
  847. }
  848. managerBar.appendChild(manager);
  849. ImgDiv.appendChild(USPhotoImg);
  850. ImgDiv.appendChild(managerBar);
  851. //图片加载成功后执行事件
  852. var ImageReady = function (Imgid, width, height) {
  853. var strCode = '<a class="samllRadius ImgViewer ImgViewer_CloseIcon" href="javascript:void(0)" onclick="this.parentNode.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode.parentNode); if (top.document.getElementById(\'SlideCase_' + USPhotoImg.id + '\')!=null){ top.document.getElementById(\'SlideCase_' + USPhotoImg.id + '\').parentNode.removeChild(top.document.getElementById(\'SlideCase_' + USPhotoImg.id + '\'));}"></a>';
  854. strCode += '<a class="samllRadius ImgViewer ImgViewer_ImgRollLeftIcon" href="javascript:void(0)" onclick="U.Imges.imgRoll(document.getElementById(\'ImgViewer_Img' + Imgid + '\'),\'left\')" ></a>';
  855. strCode += '<a class="samllRadius ImgViewer ImgViewer_ImgRollRightIcon" href="javascript:void(0)" onclick="U.Imges.imgRoll(document.getElementById(\'ImgViewer_Img' + Imgid + '\'),\'right\')"></a>';
  856. strCode += '<a class="samllRadius ImgViewer ImgViewer_ScaleIcon" href="javascript:void(0)" onclick="U.Imges.Scale(document.getElementById(\'ImgViewer_Img' + Imgid + '\'),' + width + ',' + height + ')"></a>';
  857. strCode += '<a class="samllRadius ImgViewer ImgViewer_ActuleIcon" href="javascript:void(0)" onclick="U.Imges.ActuleScale(document.getElementById(\'ImgViewer_Img' + Imgid + '\'),' + width + ',' + height + ')"></a>';
  858. strCode += '<a class="samllRadius ImgViewer ImgViewer_ThumbnailsIcon" href="javascript:void(0)" onclick="if(USPhotoImgJson!=null) document.getElementById(\'ImgViewer_ThumbnailsCase\').style.display=\'inline-block\';"></a>';
  859. manager.innerHTML = strCode;
  860. U.Imges.ActuleScale(USPhotoImg, width, height);
  861. }
  862. var _e = function () {
  863. return function () {
  864. var nwidth = this.width;
  865. var nheight = this.height;
  866. if (this.width > 800 || this.height > 600) {
  867. if (this.width > this.height) {
  868. nwidth = 800;
  869. nheight = nwidth / (this.width / this.height);
  870. } else {
  871. nheight = 600;
  872. nwidth = nheight * (this.width / this.height);
  873. }
  874. } else if (this.height < 200) {
  875. nheight = 200;
  876. nwidth = nheight * (this.width / this.height);
  877. } else {
  878. nwidth = this.width;
  879. nheight = this.height;
  880. }
  881. ImageReady(imgid, nwidth, nheight);
  882. if (key != null & key != "") gobackdiv.style.bottom = (nheight + (2 * 7)) / 2 - 15 + "px";
  883. }
  884. }
  885. _e = _e();
  886. U.Imges.ImgReady(url, _e, function () { USPhotoImg.src = this.src; }, function () { alert("加载失败"); ImgDiv.parentNode.removeChild(ImgDiv); });
  887. document.body.appendChild(ImgDiv);
  888. }
  889. U.Imges.ThumbnailsCase = function (ImgJson) {
  890. var fadeOut = null; //淡出计时器Interval
  891. var removealertBar = null; //移除提示框计时器Timeout
  892. var ThumbnailsArray = document.getElementById("ImgViewer_ThumbnailsArray");
  893. var ThumbnailsSlideShoe = document.getElementById("ImgViewer_ThumbnailsSlideShoe");
  894. var ThumbnailsSlideBar = document.getElementById("ImgViewer_ThumbnailsSlideBar");
  895. var ThumbnailsAlertBar = document.getElementById("ImgViewer_ThumbnailsAlertBar");
  896. var strCode = "";
  897. var Json = eval('(' + ImgJson + ')');
  898. USPhotoImgJson = Json;
  899. for (var i in Json) {
  900. var Img = Json[i]
  901. strCode += '<img onclick="U.Imges.CreatePhotoCase(\'' + Img.imgid + '\',\'' + Img.imgurl + '\',\'' + i + '\')" class="ImgViewer_ThumbnailsImg" src="' + Img.imgThumbnails + '"/>';
  902. }
  903. ThumbnailsArray.innerHTML = strCode;
  904. ThumbnailsArray.style.width = (Json.length / 2) * 68 + "px";
  905. ThumbnailsArray.parentNode.parentNode.style.display = "inline-block";
  906. var mousemoveOrdown = function () {
  907. pole = event.clientX - parseInt(ThumbnailsSlideShoe.parentNode.parentNode.getBoundingClientRect().left) - 35;
  908. pole = pole < 0 ? 0 : pole;
  909. pole = pole > 235 ? 235 : pole;
  910. ThumbnailsSlideShoe.style.left = pole + "px";
  911. ThumbnailsAlertBar.style.left = pole - 10 + "px";
  912. var ThumbnailsArrayleft = Math.ceil(pole) * ((parseInt(ThumbnailsArray.style.width) - 278) / 235);
  913. if (ThumbnailsArrayleft > 0) {
  914. ThumbnailsAlertBar.innerHTML = Math.round(ThumbnailsArrayleft) + 35 + "%";
  915. ThumbnailsArray.style.marginLeft = "-" + ThumbnailsArrayleft + "px";
  916. } else {
  917. ThumbnailsAlertBar.innerHTML = "小于范围值~~";
  918. ThumbnailsArray.style.marginLeft = "0px";
  919. }
  920. }
  921. var AlertFadeIn = function () {
  922. //提示框样式重置
  923. ThumbnailsAlertBar.style.filter = "alpha(opacity=100)";
  924. ThumbnailsAlertBar.style.MozOpacity = "1";
  925. ThumbnailsAlertBar.style.opacity = "1";
  926. ThumbnailsAlertBar.style.display = "inline-block";
  927. //再次清扫计时器防止内存溢出
  928. clearInterval(fadeOut);
  929. clearTimeout(removealertBar);
  930. //特效开始
  931. removealertBar = setTimeout(function () {
  932. i = 100;
  933. fadeOut = setInterval(function () {
  934. ThumbnailsAlertBar.style.filter = "alpha(opacity=" + i + ")";
  935. ThumbnailsAlertBar.style.MozOpacity = i * 0.01;
  936. ThumbnailsAlertBar.style.opacity = i * 0.01;
  937. i -= 2;
  938. if (i == 0) {
  939. ThumbnailsAlertBar.style.display = "none";
  940. //清扫计时器防止内存溢出
  941. clearInterval(fadeOut);
  942. clearTimeout(removealertBar);
  943. }
  944. }, 1);
  945. }, 800);
  946. }
  947. //事件控制
  948. ThumbnailsSlideBar.onmousedown = function () {
  949. mousemoveOrdown();
  950. ThumbnailsAlertBar.style.display = "inline-block";
  951. }
  952. ThumbnailsSlideBar.onmouseup = function () {
  953. if (!browser.msie) {
  954. AlertFadeIn();
  955. } else {
  956. clearTimeout(removealertBar);
  957. removealertBar = setTimeout(function () {
  958. ThumbnailsAlertBar.style.display = "none";
  959. clearTimeout(removealertBar);
  960. }, 800);
  961. }
  962. }
  963. ThumbnailsSlideShoe.onmousedown = function () {
  964. var ismoveSlide = true;
  965. document.body.onmousemove = function () {
  966. if (ismoveSlide == true) {
  967. mousemoveOrdown();
  968. ThumbnailsAlertBar.style.display = "inline-block";
  969. if (!browser.msie) {
  970. ThumbnailsAlertBar.style.filter = "alpha(opacity=" + i + ")";
  971. ThumbnailsAlertBar.style.MozOpacity = i * 0.01;
  972. ThumbnailsAlertBar.style.opacity = i * 0.01;
  973. }
  974. }
  975. }
  976. document.body.onmouseup = function () {
  977. if (document.all != undefined) ThumbnailsSlideShoe.releaseCapture();
  978. ismoveSlide = false;
  979. if (!browser.msie) {
  980. AlertFadeIn();
  981. } else {
  982. clearTimeout(removealertBar);
  983. removealertBar = setTimeout(function () {
  984. ThumbnailsAlertBar.style.display = "none";
  985. clearTimeout(removealertBar);
  986. }, 800);
  987. }
  988. document.body.onmouseup = function () { return false; }
  989. }
  990. }
  991. }
  992. //设置换行
  993. U.M.SEKP = function (IF, CB, TF) {
  994. IF.onkeypress = function () { if (event.keyCode == 10 || event.keyCode == 13) { if (TF) { U.M.StopDefault(); } if (CB) { CB(); } } }
  995. }
  996. //由于需要大Div,小Div的loading,而现有的Loading函数有些复杂。需要逻辑再清晰,所以先独立,最后合并到一个loading中。
  997. //加载Gif动画效果,小加载,区别于博客,论坛的大加载。
  998. //此处需要异步装载,先装载文章(需要有加载动画),文章加载完毕再异步加载评论(需要有加载动画),否则会很慢。
  999. //参数load为true,则为显示图片,参数load为false,则为卸载。因为每个项目都要用所以放在了主项目中。
  1000. U.MD.SMGif = function (_div, _load) {
  1001. if (_load == false) _div.removeChild(U.M.GetCById(_div, "U_SMLD"));
  1002. else $$("img", { "id": "U_SMLD", "className": "U_SMLDGif", "src": "/img/us_smlding.gif" }, _div); //追加loading
  1003. }
  1004. //设置text自适应
  1005. U.M.TeSize = function (UDOD, UMH) {
  1006. var i; //循环初始化
  1007. var _UDE = ["propertychange", "input", "focus"]; //定义需要用到的字符串
  1008. var _ = function () {
  1009. var _USH = UDOD.scrollHeight, _UDTD = $(UDOD);
  1010. if (_USH != UDOD.clientHeight && _USH != UDOD.currHeight) {
  1011. if (!UMH || _USH < UMH) { _UDTD.addAttrArray({ currHeight: _USH, style: { overflowY: "hidden", height: _USH + "px"} }); } //最小大小
  1012. else { _UDTD.addAttrArray({ style: { overflowY: "auto"} }); } //最大大小
  1013. }
  1014. }
  1015. for (i = 0; i < _UDE.length; i++) { U.M.AddEvent(_UDE[i], UDOD, _); }
  1016. }
  1017. //设置禁止刷新------------------没有任何地方用到
  1018. U.M.stopRefresh = function () {
  1019. U.M.keyfun = U.M.keyfun || function () { if (event.keyCode == 116) { event.keyCode = 0; U.M.StopBubble(); U.M.StopDefault(); return false; } }
  1020. var _UDE = { keydown: U.M.keyfun, keyup: U.M.keyfun }; $(document).unbind(_UDE).bind(_UDE);
  1021. }
  1022. //异步处理函数
  1023. U.M.AsynApply = function (UTE, UDE) {
  1024. var _ = U.M.apply(UTE, UDE); return function () { setTimeout(_, 0); } //异步加载处理
  1025. }
  1026. //js forEach循环
  1027. U.M.forEach = function (UDE, UFN, UC) {
  1028. for (var i in UDE) {
  1029. if (UDE.hasOwnProperty(i) && UFN.call(UC, UDE[i], i, UDE) === false) { break; }
  1030. }
  1031. }
  1032. //等比例缩放
  1033. U.M.ImageZoom = function (UI, UZ) {
  1034. var _TF, _UH, _UW; UI = UI || this;
  1035. if (UI.height != 0 && UI.width != 0) {
  1036. if (UZ["height"]) { if (UZ["height"] < UI.height) { _TF = UZ["height"] / UI.height; _UH = UZ["height"]; } else { _TF = 1; _UH = UI.height; }; _UW = UI.width * _TF; }
  1037. else if (UZ["width"]) { if (UZ["width"] < UI.width) { _TF = UZ["width"] / UI.width; _UW = UZ["width"]; } else { _TF = 1; _UW = UI.width; }; _UH = UI.height * _TF; }
  1038. $(UI).addAttrArray({ "style": { "width": _UW + "px", "height": _UH + "px"} });
  1039. }
  1040. }
  1041. //窗体是否可见
  1042. U.M.visi = function (UOE, UTE) {
  1043. var _, cb, i, j, _UTP, _UTF, _UCE = ["", "webkit", "moz", "ms", "o"], _UME = ["hidden", "visibilityState", "visibilitychange"];
  1044. for (i = 0; i < _UCE.length; i++) { for (j = 0; j < _UME.length; j++) { if ((_UTP = _UCE[i] + (_UCE[i] ? _UME[j].substr(0, 1).toUpperCase() + _UME[j].substr(1) : _UME[j])) in document) { _UME[j] = _UTP; _UTF = true; } } if (_UTF) { break; } }
  1045. if (_UTF) { U.M.AddEvent(_UME[2], U.M.apply(null, [[U.M.visi.cb, [UOE, UTE, _UME[1]]]])); }
  1046. else { U.M.IsActivity(UOE, UTE); }
  1047. }
  1048. U.M.visi.cb = function (UOE, UTE, UTP) {
  1049. (document[UTP] ? UOE : UTE)();
  1050. }
  1051. //是否启用cookie
  1052. U.M.Cookies.is = function () { return navigator.cookieEnabled; }
  1053. //新窗口写入数据
  1054. U.M.WOP = function (UHT) {
  1055. var _UDD, _UDW = window.open("javascript:void((function(){document.open();document.domain='" + document.domain + "';document.close()})())"); //"about:blank"
  1056. (UHT) && (_UDD = _UDW.document.open(), _UDD.write(UHT), _UDD.close());
  1057. return _UDW;
  1058. }
  1059. //异步添加元素
  1060. U.M.asyncInnerHTML = function (UH, UCB) {
  1061. var _UOD = $$("div", { "innerHTML": UH }), UOF = $$("frag");
  1062. if (_UOD.firstChild) { UOF.appendChild(_UOD.firstChild); setTimeout(arguments.callee, 0); } //然后一点点挪到文档碎片 //然后把插入内容的操作作为异步调用放到一个独立的堆栈中
  1063. else { UCB[UOF]; } //这里才是真正执行插入节点的操作
  1064. // (function () { })();
  1065. }
  1066. //设置浏览器首页 必须有按钮触发
  1067. U.M.setHome = function (UDOD, URL) {
  1068. UDOD = UDOD || event.srcElement;
  1069. try { UDOD.style.behavior = "url(#default#homepage)"; UDOD.setHomePage(URL); return true; }
  1070. catch (e) {
  1071. if (window.netscape) {
  1072. try {
  1073. if (netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")) { //判断是否开启设置首页功能
  1074. Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch).setCharPref('browser.startup.homepage', URL); return true;
  1075. }
  1076. }
  1077. catch (e) { }
  1078. }
  1079. }
  1080. return false;
  1081. }
  1082. //加入收藏夹
  1083. U.M.Collec = function (UTI, URL) {
  1084. try { window.external.addFavorite(URL, UTI); return true; }
  1085. catch (e) { try { window.sidebar.addpanel(UTI, URL, ""); return true; } catch (e) { } }
  1086. return false;
  1087. }
  1088. //获取js路径
  1089. U.M.GetJsUrl = function (UDID) {
  1090. var i, _UIE, _UPE, _USE, _UDE = document.scripts;
  1091. if ((_UPE = document.currentScript)) { _UPE = _UPE.src; } else { try { throw Error(); } catch (e) { _UPE = e.stack || e.sourceURL || e.stacktrace; } } //获取链接
  1092. if (!_UPE) { for (i = _UDE.length; i > -1; i--) { _USE = _UDE[i].src.split("/"); _UPE = _USE[_USE.length - 1]; if ((_UDE[i].src == UDID) || (_UPE.indexOf(UDID) == 0 && ((_UPE = _UPE.substr(0, UDID.length).chatAt(0)) == "") || _UPE == "?")) { return [_USE.slice(-1), _USE[_USE.length - 1]]; } } } //非兼容全屏搜索
  1093. _UPE = [_UPE, _UPE.split("/")]; _UPE[1] = _UPE[1][_UPE[1].length - 1]; return _UPE;
  1094. }
  1095. //U.OU.TF = { "TF": "Excel" }
  1096. //U.OU.DivisionExcelWord = function (Judge) { U.OU.JudgeEW = Judge; } //判断是Excel还是Wrod
  1097. ////----------------------------------------------菜单功能----------------------------------------------------------//
  1098. ////文件下拉菜单功能
  1099. //U.OU.OpenFileMenu = function () {
  1100. // U.M.StopBubble(); //阻止冒泡
  1101. // var FileMenu = document.getElementById("U_E_OC");
  1102. // FileMenu.style.display = FileMenu.style.display == "none" ? "block" : "none";
  1103. //}
  1104. ////切换菜单选项
  1105. //U.OU.SwitchOption = function (Option, Judge) {
  1106. // var OptionList = document.getElementById("U_E_MenuBar").getElementsByTagName("li");
  1107. // for (var i = 1; i < OptionList.length; i++) { OptionList[i].className = ""; }
  1108. // Option.className = "U_E_MenuButton";
  1109. // document.getElementById(Judge).style.display = "block";
  1110. // document.getElementById(Judge == "U_E_Tool" ? "U_OU_Nav" : "U_E_Tool").style.display = "none";
  1111. //}
  1112. ////-----------------------------------------------工具-----------------------------------------------------------//
  1113. ////显示或隐藏颜色框
  1114. //U.OU.DisplayColorFrame = function (FrameID) {
  1115. // var ColorFrame = document.getElementById(FrameID);
  1116. // ColorFrame.style.display = ColorFrame.style.display == "none" ? "block" : "none";
  1117. // var OtherID = FrameID == "U_E_TColorFrame" ? "U_E_BColorFrame" : "U_E_TColorFrame"; //隐藏另一个颜色框
  1118. // document.getElementById(OtherID).style.display = "none";
  1119. //}
  1120. ////点击颜色Li
  1121. //U.OU.ColorLiOnClick = function (Li) {
  1122. // var Color = Li.style.backgroundColor; var Father = Li.parentNode;
  1123. // var BorderID = Father.id == "U_E_BColorFrame" ? "U_E_BColorBorder" : "U_E_TColorBorder";
  1124. // var StyleName = Father.id == "U_E_BColorFrame" ? "BackColor" : "ForeColor";
  1125. // document.getElementById(BorderID).style.backgroundColor = Color;
  1126. // U.OU.ChangeStyle(StyleName, Color);
  1127. // Father.style.display = "none"; //隐藏颜色框
  1128. //}
  1129. ////-----------------------------------------------插入-----------------------------------------------------------//
  1130. //U.OU.InsertNowTime = function () {
  1131. // var NowTime = US.Admin.TimeNow["年", "月", "日"];
  1132. // if (U.OU.JudgeEW == "Word" || U.Excel.KeepEditblur()) { U.D.E.GetSelectionRange(window, $$("span")).Replace(NowTime); }
  1133. // else {
  1134. // var Compare = U.Excel.ComparePickOn(); var Small = Compare[0]; var Big = Compare[1];
  1135. // for (var i = Small[0]; i <= Big[0]; i++) {
  1136. // for (var j = Small[1]; j <= Big[1]; j++) { U.Excel.Cell[i][j].innerHTML = NowTime; }
  1137. // }
  1138. // }
  1139. //}
  1140. ////-----------------------------------------------文本编辑器-----------------------------------------------------------//
  1141. //U.OU.ChangeStyle = function (SN, V, TF) {
  1142. // if (U.OU.TF["TF"] == "Excel") {
  1143. // var _UDFD = $("#U_E_EditFrame")[0], _UDED = $("div", _UDFD)[0];
  1144. // if (_UDFD.ondblclick == null) { U.D.E.FontSizeType(_UDED, SN, [V, V]); } //修改文字样式
  1145. // else {
  1146. // U.D.E.GetSelectionRange(window, U.Excel.SY["SEO"][0]).SetYPS(SN, V);
  1147. // U.Excel.SY["CE"]["Cell"][U.Excel.SY["SEO"][1]].style[SN] = V;
  1148. // }
  1149. // }
  1150. //}
  1151. //////改变单元格或选中文本的样式(Style)
  1152. ////U.OU.ChangeStyle = function (StyleName, Param) {
  1153. //// var EJudge = U.OU.JudgeEW == "Word" || (U.Excel.KeepEditblur() && StyleName != "BackColor" && StyleName != "JustifyLeft" && StyleName != "JustifyCenter" && StyleName != "JustifyRight");
  1154. //// if (EJudge) {//判断是否处于编辑状态中,或者是否是Word
  1155. //// if (Param == null) { document.execCommand(StyleName) }
  1156. //// else { document.execCommand(StyleName, false, Param); }
  1157. //// }
  1158. //// else {
  1159. //// // var StyleList = { "Bold": "fontWeight", "Italic": "fontStyle", "Underline": "textDecoration", "StrikeThrough": "textDecoration", "": "backgroundColor", "": "", "": "", "": "", "": "", "": "", "": "", "": "", "": "", "": "" };
  1160. //// switch (StyleName) {
  1161. //// case "Bold": StyleName = "fontWeight"; Param = ['bold', 'normal']; break;
  1162. //// case "Italic": StyleName = "fontStyle"; Param = ['italic', 'normal']; break;
  1163. //// case "Underline": StyleName = "textDecoration"; Param = ['underline', 'none']; break;
  1164. //// case "StrikeThrough": StyleName = "textDecoration"; Param = ['line-through', 'none']; break;
  1165. //// case "BackColor": StyleName = "backgroundColor"; break;
  1166. //// case "ForeColor": StyleName = "color"; break;
  1167. //// case "JustifyLeft": StyleName = "textAlign"; Param = "left"; break;
  1168. //// case "JustifyCenter": StyleName = "textAlign"; Param = "center"; break;
  1169. //// case "JustifyRight": StyleName = "textAlign"; Param = "right"; break;
  1170. //// case "FontSize": StyleName = "fontSize"; Param = Param + "px"; break;
  1171. //// case "FontName": StyleName = "fontFamily"; break;
  1172. //// }
  1173. //// var TempParam = Param.concat();
  1174. //// var Compare = U.Excel.ComparePickOn(); var Small = Compare[0]; var Big = Compare[1]; var Cell;
  1175. //// for (var i = Small[0]; i <= Big[0]; i++) {
  1176. //// for (var j = Small[1]; j <= Big[1]; j++) {
  1177. //// Cell = U.Excel.Cell[i][j];
  1178. //// if (StyleName == "textDecoration") {//让删除线和下划线共存
  1179. //// var Decoration = Param[0] == "underline" ? "line-through" : "underline";
  1180. //// if (Cell.style[StyleName].indexOf(Decoration) > -1) { Param[0] = "underline line-through"; Param[1] = Decoration; }
  1181. //// }
  1182. //// if ((typeof (Param) == "string")) { Cell.style[StyleName] = Param; }
  1183. //// else { Cell.style[StyleName] = Cell.style[StyleName] == Param[0] ? Param[1] : Param[0]; }
  1184. //// if (StyleName == "textDecoration") { Param = TempParam.concat(); }
  1185. //// }
  1186. //// }
  1187. //// }
  1188. //// if (U.OU.JudgeEW == "Excel") { U.Excel.EditTextEdit("Cell"); }
  1189. ////}
  1190. ////获取选中文本在整篇文章内的位置
  1191. //U.OU.SelectedLocation = function () {
  1192. // //Chorme
  1193. // // var range = window.getSelection().getRangeAt(0);
  1194. // // var startRangeOffset = range.startOffset;
  1195. // // range.collapse(true);
  1196. // // range.setStart(range.startContainer, startRangeOffset - 1);
  1197. // // range.setEnd(range.startContainer, startRangeOffset - 1 + plenght);
  1198. // //IE
  1199. // // var EditFrame = document.getElementById("U_E_EditFrame");
  1200. // // var EditContent = EditFrame.getElementsByTagName("div")[0];
  1201. // var EditContent = document.getElementById("U_W_WordEdit");
  1202. // var range = document.selection.createRange();
  1203. // var stored_range = range.duplicate();
  1204. // stored_range.moveToElementText(EditContent);
  1205. // stored_range.setEndPoint('EndToEnd', range);
  1206. // EditContent.selectionStart = stored_range.text.length - range.text.length;
  1207. // EditContent.selectionEnd = EditContent.selectionStart + range.text.length;
  1208. // //U.Excel.setSelectText(EditContent, EditContent.selectionStart, EditContent.selectionEnd);
  1209. //}
  1210. ////将InnerHTML拆分成数组
  1211. //U.OU.SpiltInnerHTML = function (InnerHTML) {
  1212. // var InnerFrame = $$("span", { "innerHTML": InnerHTML });
  1213. // InnerHTML = InnerFrame.innerHTML;
  1214. // var ElementList = U.M.GTCN(InnerFrame.childNodes); var SubStr = "";
  1215. // var NewArray = []; var Local; var ElementInner;
  1216. // for (var i = 0; i < ElementList.length; i++) {
  1217. // ElementInner = U.OU.OuterHTML(ElementList[i]);
  1218. // Local = InnerHTML.toLowerCase().indexOf(ElementInner.toLowerCase());
  1219. // SubStr = InnerHTML.substring(0, Local);
  1220. // if (SubStr.replace(/(^\s*)|(\s*$)/g, "") != "") { NewArray.push(SubStr); } //如果为空就不加入到数组中
  1221. // NewArray.push(ElementList[i]);
  1222. // InnerHTML = InnerHTML.substring(Local + ElementInner.length, InnerHTML.length);
  1223. // }
  1224. // if (InnerHTML.replace(/(^\s*)|(\s*$)/g, "") != "") { NewArray.push(InnerHTML); }
  1225. // return NewArray;
  1226. //}
  1227. //U.OU.OuterHTML = function (Element) {
  1228. // var HTMLFrame = $$("span", {}); HTMLFrame.appendChild(Element);
  1229. // return HTMLFrame.innerHTML;
  1230. //}
  1231. ////文本编辑器(兼容IE,Chroem)Firefox未测试
  1232. //U.OU.Editplus = function (StyleName, Param) {
  1233. // var BrowserJudge = !(document.selection); //判断是哪个浏览器
  1234. // var range = BrowserJudge ? window.getSelection().getRangeAt(0) : document.selection.createRange();
  1235. // var TextFather = BrowserJudge ? range.commonAncestorContainer.parentNode : range.parentElement(); //获取文本的父窗口
  1236. // var InnerHTML = BrowserJudge ? document.createElement('span') : range.htmlText; //返回选中的InnerHTML
  1237. // if (BrowserJudge) { SpanFrame.appendChild(range.cloneContents()).innerHTML; }
  1238. // var ElementList = U.OU.SpiltInnerHTML(InnerHTML); //将InnerHTML分割成数组(根据标签进行分割)
  1239. // var NewStyle = TextFather.style[StyleName] == Param[0] ? Param[1] : Param[0]; var NextSpan;
  1240. // if (ElementList[0].nodeName) {//如果开头是标签就取标签相反的,如果是文本就取第一种样式
  1241. // for (var i = 0; i < ElementList.length; i++) {
  1242. // NewStyle = ElementList[i].style[StyleName]; NextSpan = ElementList[i + 1];
  1243. // if (NextSpan == null || NextSpan.nodeName == null || NextSpan.style[StyleName] == NewStyle) { NewStyle = NewStyle == Param[0] ? Param[1] : Param[0]; break; }
  1244. // }
  1245. // }
  1246. // var HTMLFrameB = $$("span", {}); var HTMLFrameS = $$("span", {}, HTMLFrameB);
  1247. // var str = ChildList = ""; HTMLFrameS.style[StyleName] = NewStyle; var ElementName = "";
  1248. // for (var i = 0; i < ElementList.length; i++) {
  1249. // ElementName = ElementList[i].nodeName;
  1250. // if (ElementName) {
  1251. // if (ElementList[i].innerHTML == "" && ElementName == "SPAN") { continue; }
  1252. // ChildList = ElementList[i].getElementsByTagName("*");
  1253. // for (var j = 0; j < ChildList.length; j++) { if (ChildList[j].nodeName != "BR") { ChildList[j].style[StyleName] = NewStyle; } }
  1254. // if (ElementName != "BR") {
  1255. // if (ElementName == "P" && (i == 0 || i == ElementList.length - 1)) {
  1256. // // if (i == ElementList.length - 1) { str += "<p>"; }
  1257. // HTMLFrameS.innerHTML = ElementList[i].innerHTML;
  1258. // str += HTMLFrameB.innerHTML;
  1259. // if (i == 0) { str += "<br />"; }
  1260. // continue;
  1261. // }
  1262. // ElementList[i].style[StyleName] = NewStyle;
  1263. // }
  1264. // str += U.OU.OuterHTML(ElementList[i]);
  1265. // }
  1266. // else { HTMLFrameS.innerHTML = ElementList[i]; str += HTMLFrameB.innerHTML; }
  1267. // }
  1268. // if (BrowserJudge) { var NewFrame = $$("span", { "innerHTML": str }); range.deleteContents(); range.insertNode(HTMLFrameS); }
  1269. // else { range.pasteHTML(str); }
  1270. //}
  1271. ////文本编辑器(兼容IE,Chroem)Firefox未测试
  1272. ////U.OU.Editplus = function (StyleName, Param) {
  1273. //// var BrowserJudge = !(document.selection); //判断是哪个浏览器
  1274. //// var range = BrowserJudge ? window.getSelection().getRangeAt(0) : document.selection.createRange();
  1275. //// var TextFather = BrowserJudge ? range.commonAncestorContainer.parentNode : range.parentElement(); //获取文本的父窗口
  1276. //// var SpanFrame = BrowserJudge ? document.createElement('span') : $$("span", { "innerHTML": range.htmlText }); //返回innerHTML为选中内容的span
  1277. //// if (BrowserJudge) { SpanFrame.appendChild(range.cloneContents()); } var SpanList = SpanFrame.getElementsByTagName("*");
  1278. //// var NewStyle = Param[0]; var NextSpan;
  1279. //// //如果开头是标签就取标签相反的,如果是文本就取第一种样式
  1280. //// if (!(SpanFrame.firstChild.nodeValue)) {
  1281. //// for (var i = 0; i < SpanList.length; i++) {
  1282. //// NewStyle = SpanList[i].style[StyleName]; NextSpan = SpanList[i + 1];
  1283. //// if (NextSpan == null || NextSpan.style[StyleName] == NewStyle) { NewStyle = NewStyle == Param[0] ? Param[1] : Param[0]; break; }
  1284. //// }
  1285. //// }
  1286. //// else { NewStyle = TextFather.style[StyleName] == Param[0] ? Param[1] : Param[0]; }
  1287. //// for (var i = 0; i < SpanList.length; i++) { SpanList[i].style[StyleName] = NewStyle }; //让内部所有标签都为该css
  1288. //// SpanFrame.style[StyleName] = NewStyle;
  1289. //// if (BrowserJudge) { range.deleteContents(); range.insertNode(SpanFrame); return; }
  1290. //// if (TextFather.contentEditable == "true" || U.OU.DivisionEW == "Word") { range.pasteHTML(SpanFrame.outerHTML); }
  1291. //// else {
  1292. //// TextFather.style[StyleName] = NewStyle; SpanList = TextFather.getElementsByTagName("*");
  1293. //// for (var i = 0; i < SpanList.length; i++) { SpanList[i].style[StyleName] = NewStyle };
  1294. //// }
  1295. ////}
  1296. ////让回车生成的<p></p>变成<br />
  1297. //U.OU.EditOnkey = function () {
  1298. // var BrowserJudge = !(document.selection); //判断是哪个浏览器
  1299. // var range = BrowserJudge ? window.getSelection().getRangeAt(0) : document.selection.createRange();
  1300. // if (event.keyCode == 13 || event.keyCode == 108) {
  1301. // U.M.StopDefault(); //阻止系统事件
  1302. // var dd = document.createElement("br");
  1303. // if (BrowserJudge) { range.deleteContents(); range.insertNode(dd); }
  1304. // else { range.pasteHTML("<br />"); }
  1305. // }
  1306. // U.M.StopBubble(); //阻止冒泡
  1307. //}
  1308. ////md5加密区域
  1309. //U.M.apply(Namespace.register("U.E"), function () {
  1310. // _$(this).Add({
  1311. // hex_md5: function (s) { return binl2hex(core_md5(str2binl(s), s.length * chrsz)); }, //hash加密
  1312. // b64_md5: function (s) { return binl2b64(core_md5(str2binl(s), s.length * chrsz)); }, //base64加密
  1313. // hex_hmac_md5: function (key, data) { return binl2hex(core_hmac_md5(key, data)); }, //hashkey加密
  1314. // b64_hmac_md5: function (key, data) { return binl2b64(core_hmac_md5(key, data)); }, //base64key加密
  1315. // calcMD5: function (s) { return binl2hex(core_md5(str2binl(s), s.length * chrsz)); }, //md5加密
  1316. // md5_vm_test: function md5_vm_test() {
  1317. // return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  1318. // },
  1319. // core_md5: function (x, len) {
  1320. // x[len >> 5] |= 0x80 << ((len) % 32);
  1321. // x[(((len + 64) >>> 9) << 4) + 14] = len;
  1322. // var a = 1732584193;
  1323. // var b = -271733879;
  1324. // var c = -1732584194;
  1325. // var d = 271733878;
  1326. // for (var i = 0; i < x.length; i += 16) {
  1327. // var olda = a;
  1328. // var oldb = b;
  1329. // var oldc = c;
  1330. // var oldd = d;
  1331. // a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
  1332. // d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
  1333. // c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
  1334. // b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
  1335. // a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
  1336. // d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
  1337. // c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
  1338. // b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
  1339. // a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
  1340. // d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
  1341. // c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
  1342. // b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
  1343. // a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
  1344. // d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
  1345. // c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
  1346. // b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
  1347. // a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
  1348. // d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
  1349. // c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
  1350. // b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
  1351. // a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
  1352. // d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
  1353. // c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
  1354. // b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
  1355. // a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
  1356. // d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
  1357. // c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
  1358. // b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
  1359. // a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
  1360. // d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
  1361. // c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
  1362. // b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
  1363. // a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
  1364. // d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
  1365. // c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
  1366. // b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
  1367. // a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
  1368. // d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
  1369. // c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
  1370. // b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
  1371. // a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
  1372. // d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
  1373. // c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
  1374. // b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
  1375. // a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
  1376. // d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
  1377. // c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
  1378. // b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
  1379. // a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
  1380. // d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
  1381. // c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
  1382. // b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
  1383. // a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
  1384. // d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
  1385. // c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
  1386. // b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
  1387. // a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
  1388. // d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
  1389. // c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
  1390. // b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
  1391. // a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
  1392. // d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
  1393. // c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
  1394. // b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
  1395. // a = safe_add(a, olda);
  1396. // b = safe_add(b, oldb);
  1397. // c = safe_add(c, oldc);
  1398. // d = safe_add(d, oldd);
  1399. // }
  1400. // return Array(a, b, c, d);
  1401. // },
  1402. // md5_cmn: function (q, a, b, x, s, t) {
  1403. // return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
  1404. // },
  1405. // md5_ff: function (a, b, c, d, x, s, t) {
  1406. // return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  1407. // },
  1408. // md5_gg: function (a, b, c, d, x, s, t) {
  1409. // return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  1410. // },
  1411. // md5_hh: function (a, b, c, d, x, s, t) {
  1412. // return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  1413. // },
  1414. // md5_ii: function (a, b, c, d, x, s, t) {
  1415. // return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  1416. // },
  1417. // core_hmac_md5: function (key, data) {
  1418. // var bkey = str2binl(key);
  1419. // if (bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  1420. // var ipad = Array(16), opad = Array(16);
  1421. // for (var i = 0; i < 16; i++) {
  1422. // ipad[i] = bkey[i] ^ 0x36363636;
  1423. // opad[i] = bkey[i] ^ 0x5C5C5C5C;
  1424. // }
  1425. // var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  1426. // return core_md5(opad.concat(hash), 512 + 128);
  1427. // },
  1428. // safe_add: function (x, y) {
  1429. // var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  1430. // var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  1431. // return (msw << 16) | (lsw & 0xFFFF);
  1432. // },
  1433. // bit_rol: function (num, cnt) {
  1434. // return (num << cnt) | (num >>> (32 - cnt));
  1435. // },
  1436. // str2binl: function (str) {
  1437. // var bin = Array();
  1438. // var mask = (1 << chrsz) - 1;
  1439. // for (var i = 0; i < str.length * chrsz; i += chrsz)
  1440. // bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32);
  1441. // return bin;
  1442. // },
  1443. // binl2hex: function (binarray) {
  1444. // var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  1445. // var str = "";
  1446. // for (var i = 0; i < binarray.length * 4; i++) {
  1447. // str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) +
  1448. // hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF);
  1449. // }
  1450. // return str;
  1451. // },
  1452. // binl2b64: function (binarray) {
  1453. // var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  1454. // var str = "";
  1455. // for (var i = 0; i < binarray.length * 4; i += 3) {
  1456. // var triplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16)
  1457. // | (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8)
  1458. // | ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF);
  1459. // for (var j = 0; j < 4; j++) {
  1460. // if (i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  1461. // else str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);
  1462. // }
  1463. // }
  1464. // return str;
  1465. // }
  1466. // });
  1467. //})();
  1468. //U.UP.uploading = function () {
  1469. // var _ = function (UDE, UCB, UCT, UAC, UTF, UFID) {//执行上传
  1470. // this.contentWindow.name = UFID; UDE = U.Ut.isArray(UDE) ? UDE : Array.prototype.slice.apply(UDE); UAC = UAC + (UAC.indexOf("?") > -1 ? "" : "?") + ((US && US.userInfo && US.userInfo.userid) || US.userInfo.userid ? "&UserId=" + (US.userInfo.userid || US.userInfo.userid) : "");
  1471. // var i = 0, _UL = UDE.length, _UCE = [], _UCB = UCB, _UDBD = document.body, _URE = { "UpObj": UDE, "context": UCT, "value": "" }, _UDFD = $$("form", { "action": UAC, "target": UFID, "encoding": "multipart/form-data", "enctype": "multipart/form-data", "method": "post", "name": "loading", "style": { "display": "none"} }, _UDBD);
  1472. // (UTF) && (_UL = 1, _URE["UpObj"] = UDE.splice(0, 1), _UCB = U.M.apply(this, [[UCB, [_URE]], [U.UP.uploading, [UDE, UCB, UCT, UAC, UTF]]])); UDE = _URE["UpObj"];
  1473. // for (i; i < _UL; i++) { UDE[i].name = UDE[i].name || UDE[i].id || Guid.newGuid(); _UCE.push($(UDE[i]).replaceC($$("div"))[0]); _UDFD.appendChild(UDE[i]); }
  1474. // _UDFD.submit(); this.complete = ""; U.MD.IframeLoad(this, [[AsynF, [this, _UCB, _URE]]]); $(_UDFD).remove(); for (i = 0; i < _UL; i++) { $(_UCE[i]).replaceC(UDE[i]); };
  1475. // //if (document.selection) { UDE[i].select(); document.selection.clear(); } else { UDE[i].outerHTML += ""; UDE[i].value = ""; } //清空内容
  1476. // },
  1477. // AsynF = function (UDOD, UCB, UDE) { //传输回调
  1478. // try {
  1479. // var _UTH = UDOD.contentWindow.document.body.innerHTML; _UTH = _UTH || (UDOD.contentWindow.name != UDOD.id ? UDOD.contentWindow.name : _UTH);
  1480. // if (_UTH == null) { U.Alert("服务器处理繁忙,上传失败"); } //上传失败
  1481. // try { UDE.value = eval("0,(" + _UTH + ")"); } catch (e) { UDE.value = _UTH; } //返回的值
  1482. // $(UDOD).remove(); UCB(UDE); //回调
  1483. // }
  1484. // catch (e) { U.Alert("文件传输错误!"); }
  1485. // }
  1486. // return function (UDE, UCB, UCT, UAC, UTF) { //生成传输的iframe
  1487. // if (UDE.length > 0) {
  1488. // var _UDBD = document.body, _UFID = Guid.guidNoDash();
  1489. // U.M.IFO($$("iframe", { "id": _UFID, "name": _UFID, "width": 0, "height": 0, "style": { "display": "none" }, "frameBorder": 0 }, _UDBD), "", [[_, [UDE, UCB, UCT, UAC, UTF, _UFID]]]); //生成可访问的iframe
  1490. // }
  1491. // }
  1492. //}
  1493. /*
  1494. 这里说明1473的命名空间 通用函数的命名空间为U(U里面有自己写的系统控件 如Alert) U是总体的 这个命名空间不可以冲突到 U.Dk硬盘的命名空间 U.D桌面的命名空间 U.F好友的命名空间 U.PB学习系统的命名空间 U.B博客的命名空间 U.AP站外应用的命名空间 U.U用户的命名空间
  1495. 然后每个项目例如 U.Dk硬盘 U.Dk作为主的命名空间 U.Dk为onload加载的 辅助命名空间请看该项目下解说
  1496. UC项目
  1497. 全局应用的命名空间U U.A命名空间是1473Ajax U.AFB命名空间是前进后退 U.CI命名空间是客户端的信息 U.D命名空间是放大缩小 弹框 置顶 拉伸 拖动区域的命名空间 U.E命名空间是JSON对象的处理 U.Extend命名空间是选择器 U.Img是图片阅览器 U.M命名空间是自定义属性和有思通用方法 U.MD命名空间是有思加载项 U.CD命名空间是有思开发 U.ME命名空间是自定义元素 U.MPlayer命名空间是播放器 U.MR命名空间是切换效果 U.MS命名空间是字符串处理 U.MT命名空间是时间处理 U.P命名空间是算法 U.PG命名空间是分页 U.UI命名空间是有思窗体 U.UP有思上传封装
  1498. UD项目
  1499. U.D为桌面的全局命名这个命名函数为桌面总控函数 U.D.AD桌面广告命名空间 U.D.B桌面背景设置命名空间 U.D.BC桌面聊天室 U.D.BR桌面浏览器 U.D.E编辑器区域(这个考虑要不要放在UC里作为全局) U.D.MF桌面好友 U.D.MS计时器统一区域 U.D.N桌面便签 U.D.R桌面左右键 U.D.T右键数据源操作 U.D.Tb桌面任务进程 U.D.G桌面url重写 U.D.GG桌面新闻区域
  1500. U.DK项目
  1501. U.Dk为Disk全局命名空间这个命名空间为Disk总控系统函数 U.Dk.DI为Disk数据共享区域命名空间 U.Dk.HP为Disk辅助函数的命名空间 U.DK.LE为Disk为左键事件的命名空间 U.DK.LL为Disk导航命名空间 U.DK.M为Disk数据源操作 U.DK.RE为Disk右键功能命名空间 U.DK.RM为Disk右键菜单命名空间 U.DK.S为disk搜索命名空间 U.DK.UP为disk上传命名空间 U.DK.VW为disk视图命名空间
  1502. UF项目
  1503. U.F为UF项目的命名空间这个命名空间为UF总控系统函数 U.F.A为好友的辅助函数命名空间 U.F.T为好友树操作的命名空间 U.F.FM为好友聊天和群聊天信息区域 U.F.J为加好友和加好友群的命名空间 U.F.M为好友管理器的命名空间 U.F.N为好友信息处理 U.F.R好友右键处理的命名空间 U.F.S好友搜索的命名空间 U.F.W好友窗体的命名空间
  1504. UU项目
  1505. U.U为UU项目的命名空间这个命名空间为用户信息函数 U.U.C为用户城市JSON U.U.F为用户找回信息区域 U.U.I为用户弹窗信息区域 U.U.L为用户登录区域 U.U.R为用户注册区域
  1506. 项目暴露后,其他非1473的用户不能使用U US两个变量做命名空间。
  1507. 下面的要专门独立 这个js要干净的 专门放项目的全局变量 这样就好管理。具体要经过实践才能确定。
  1508. var US = {//用户数据树
  1509. userinfo: {}, //用户
  1510. Disk: {}, //网盘
  1511. Blog: {}, //博客
  1512. PB: {}, //论坛
  1513. Friend: {}, //好友
  1514. NLInfo: {}//未登录信息
  1515. */
  1516. //"cp": "28d8089d-ee85-4f9b-b1b6-8c1d8ccff719",
  1517. //"ns": "8b19f836-b2b6-4551-9ca5-72cdfce78364",
  1518. //"pe": "e1c047a7-6896-474c-8424-de64a24fcd78",
  1519. //"ie": "ceec8965-79bf-4670-b80b-27de1eba6288",
  1520. //"li": "1346e7d2-afee-4f40-a17f-1abd86e3d77f",
  1521. //"tr": "72f1cec4-cea5-49f5-bd62-2afac391f586",
  1522. //"sc": "15d04a6c-ab10-44cd-ac8a-850624244a1b",
  1523. //"zh": ""
  1524. // "TZGG": {
  1525. // "all": "099a06fe-073b-4426-aa20-7703aa94322e",
  1526. // "oper": "37590de6-e3df-4272-bff6-39414f7141d8",
  1527. // "deve": "57dac622-1570-4269-89ed-d4e7b9d9ca4a"
  1528. // },
  1529. //US代表了整个数据,US.userinfo代表了用户数据,US.Disk代表了硬盘数据,以此类推。NLInfo 这个是外联加载的用户数据, 比如用户城市ip等,G暂时未用到 //注册用户变量使用
  1530. //"Category": [US.PB.cp, US.PB.ns, US.PB.pe, US.PB.ie, US.PB.tr, US.PB.sc],
  1531. ////注册命名空间
  1532. //window.Namespace = {
  1533. // Entity: function () { }, //命名空间启动
  1534. // //参数一:UDE为形如:U.D.E的命名空间,参数二:UCE为形如:["userinfo", "Disk", "Blog", "PB", "Friend", "NLInfo", "G"]的集合。
  1535. // register: function (UDE, UCE, UCB) {
  1536. // var i, _UCE, _UWE = window;
  1537. // UDE = UDE.split(".");
  1538. // for (i = 0; i < UDE.length; i++) {
  1539. // _UWE[UDE[i]] = ((i == UDE.length - 1 && UCB) && UCB.call(_UWE)) || _UWE[UDE[i]] || (new Namespace.Entity);
  1540. // _UWE = _UWE[UDE[i]];
  1541. // } //生成命名控件
  1542. // if (UCE) {
  1543. // for (i = 0; i < UCE.length; i++) {
  1544. // _UWE[UCE[i]] = (new Namespace.Entity);
  1545. // }
  1546. // }
  1547. // return _UWE; //生成变量
  1548. // },
  1549. // //参数一:形如:U.CD的自定义变量或者Array,Object等系统变量,UAE为需要添加的属性的集合,形如:{ "domain": "1473.cn", "SystemId": 0}
  1550. // Add: function (UDE, UAE) {
  1551. // for (var i in UAE) {
  1552. // if (UAE.hasOwnProperty(i)) {
  1553. // UDE[i] = UAE[i];
  1554. // }
  1555. // }
  1556. // } //添加
  1557. //};
  1558. /*---------------------------------------- 全局变量注册区域---------------------------------------------------------------------------------------------------- */
  1559. ////主项目的全局变量
  1560. /*
  1561. US.domain 暂时未用到
  1562. US.SystemId 登录系统的id 1是1473系统 0是未知系统 2是手机端
  1563. US.PageId 新Guid,用途为何?
  1564. US.ofs 暂时未用到
  1565. US.fs 文件系统地址
  1566. US.afs 站外应用文件地址
  1567. US.PID 文章根id?
  1568. US.ms 常量
  1569. US.OG 私密文件夹id
  1570. US.SG 上传文件的类型 我的电脑(US.DG) 我的音乐(US.PG) 我的视频(US.SG) 我的图片(US.MG)
  1571. US.FG 我的FTP区域
  1572. US.DG 我的文件
  1573. US.PG 我的图片
  1574. US.MG 我的音乐
  1575. US.VG 我的视频
  1576. US.ER 错误图标地址
  1577. US.Height 屏幕可用高度
  1578. US.Width 屏幕可用宽度
  1579. US.NU 全0的Guid "00000000-0000-0000-0000-000000000000".
  1580. US.ZV 层次z-index属性,默认为20
  1581. 以下为PB的全局变量,好像都没有使用。
  1582. US.PB 为集合
  1583. US.PB.Category
  1584. US.PB.TZGG
  1585. US.PB.News 默认为null,这个变量有使用
  1586. US.PB.YJF
  1587. US.PB.cp
  1588. US.PB.ns
  1589. US.PB.pe
  1590. US.PB.ie
  1591. US.PB.li
  1592. US.PB.tr
  1593. US.PB.sc
  1594. US.PB.zh
  1595. "ns": "8b19f836-b2b6-4551-9ca5-72cdfce78364", "pe": "e1c047a7-6896-474c-8424-de64a24fcd78", "ie": "ceec8965-79bf-4670-b80b-27de1eba6288", "li": "1346e7d2-afee-4f40-a17f-1abd86e3d77f", "tr": "72f1cec4-cea5-49f5-bd62-2afac391f586", "sc": "15d04a6c-ab10-44cd-ac8a-850624244a1b", "zh": ""
  1596. */
  1597. /*.............................全局兼容及全局立即执行函数-------------------------------------------------------------------*/
  1598. /*
  1599. 需要在window.onload中执行的函数如下:
  1600. 全局兼容在U.MB.js里面。
  1601. U.CI里面的获取浏览器信息window.browser
  1602. 全局函数还需要另外建立文件以便处理。
  1603. */
  1604. /*----------------------1473的命名空间的说明------------------------------*/
  1605. /*
  1606. };
  1607. */
  1608. /**
  1609. * 获取cookie
  1610. *
  1611. * @param {string} 获取cookie的key对应的值 如usestudio=aa=ff&ss=aa 的usestudio里的 aa=ff&ss=aa
  1612. * @param {string} aa=ff&ss=aa里面的aa对应的值 ff
  1613. * @return {string}
  1614. */
  1615. U.M.Cookies.get = function (UKY, UKN) {
  1616. return U.M.GetCookie(UKY, UKN);
  1617. }
  1618. /*-------------------------------暂时未使用函数----------------------*/
  1619. //html编辑器
  1620. U.UI.HtmlEditor = function () {
  1621. var _UFE, _ = function () {
  1622. new _UFE.init();
  1623. }
  1624. _UFE = _.prototype = {
  1625. init: function () { }
  1626. }
  1627. _UFE.init = _UFE;
  1628. return _;
  1629. }
  1630. //#region 拉伸菜单
  1631. U.Menu = function () {
  1632. var _USE, _ = function () { }
  1633. _USE = _.prototype = {
  1634. init: function () { }
  1635. }
  1636. return _;
  1637. };
  1638. U.UI.MenuNA = function (UDE, UDOD) { }
  1639. //#endregion
  1640. /*
  1641. * 非1473跨域获取1473桌面内容。。。。。。。。。。。。。。。。,示例在www.boom.com。。。。。。。。。。。。测试代码,暂时没有用。
  1642. *
  1643. * @param {array} 成功回调
  1644. */
  1645. U.CD.CGQB = function (_cb, _bool) {
  1646. U.MD.IframeLoad($$("iframe", {
  1647. "id": "U_CDomain",
  1648. "name": "U_CDomain",
  1649. "width": 0,
  1650. "height": 0,
  1651. "style": { "display": "none" },
  1652. "src": U.CD.cdom
  1653. }, document.body), [
  1654. [U.CD.AsynCGQB, [_cb, _bool]]
  1655. ]); //初始化1473
  1656. }
  1657. /*
  1658. * 非1473获取桌面
  1659. *
  1660. * @param {function} 回调函数
  1661. */
  1662. U.CD.AsynCGQB = function (_cb, _bool) {
  1663. var _el = this; //当前iframe
  1664. U.MN.message({
  1665. obj: "#U_CDomain",
  1666. url: U.CD.cdom,
  1667. Sender: true,
  1668. me: function (UDE) { //发送获取1473桌面的消息
  1669. var _USE = UDE[2].split("=");
  1670. if (_USE[1] == "") { U.M.Cookies.del(_USE[0]); } //后台设置了cookie 前台同时响应
  1671. else { U.M.Cookies.set(UDE[2]); } //设置新的cookie
  1672. document.wincookie = UDE[2]; //记录cookie
  1673. //1473跨域形式
  1674. if (window["U_Domain"]) {
  1675. if (window["U_Domain"].location.href == U.CD.dom) {
  1676. U.CD.AsynDomain(U.M.apply(null, [
  1677. [U.CD.AsynGQB, [UDE[0], null, _cb]]
  1678. ]));
  1679. return;
  1680. }
  1681. } else { //跨域已经加载成功
  1682. U.CD.Introduce(U.M.apply(null, [
  1683. [U.CD.AsynGQB, [UDE[0], null, _cb]]
  1684. ])); //初始化1473
  1685. }
  1686. $(_el).remove(); //移除多余元素
  1687. },
  1688. url: "http://www.143.cn/Crossdomain.htm"
  1689. }).post("", "cdomain", _bool);
  1690. }
  1691. //#endregion
  1692. //#endregion
  1693. /**
  1694. * 硬盘上传的文件类型判断,所有类型,非病毒文件类型
  1695. *
  1696. * @param {string} 文件类型
  1697. * @param {string} 自定义类型判断 如 "exe,jj" 这两种类型的判断
  1698. * @return {boolean} 类型是否满足
  1699. */
  1700. U.UP.UploadFileType = function (UTP, UTF) {
  1701. var _UFT,
  1702. _UIE = UTF;
  1703. UTP = UTP.substr(UTP.lastIndexOf(".") + 1); //获取文件类型
  1704. (UTF == null) && (UTF = U.UP.SFT("B")); //没有自定义类型 获取病毒类型
  1705. _UFT = UTF.indexOf(UTP) != -1; //判断文件类型
  1706. ((_UIE == null) && (_UFT = (!_UFT))); //病毒类型返回true 否则返回flase
  1707. return _UFT;
  1708. }
  1709. /**
  1710. * 类型选择
  1711. *
  1712. * @param {string} 上传成功回调函数
  1713. */
  1714. //U.UP.SFT = function (UTP) {
  1715. // switch (UTP) {
  1716. // case "A": return "rar,zip,txt,doc,docx,ppt,pptx,xls,xlsx,mht,iso,chm,gz,msi,dll,html,htm,pdf,xlsx,pptx,css,js,psd,cad,dwt,dwg,dws,dwf"; //我的电脑区域
  1717. // case "P": return "jpg,gif,png,bmp,jpeg,JPG,GIF,BMP,PNG,JPEG"; //相册文件
  1718. // case "M": return "mp3"; //音乐区域
  1719. // case "V": return "wmv,video,ogg,webm,mp4"; //视频区域
  1720. // case "B": return "exe,vbs,vbe,js,jse,wsh,wsf"; //病毒类型
  1721. // case "UP": return ".gif,.GIF,.jpg,.JPG,.jpeg,.JPEG,.png,.PNG,.bmp,.BMP,.rar,.zip"; break; //聊天编辑器允许上传
  1722. // case "CA": return U.UP.SFT("P") + "," + U.UP.SFT("M") + "," + U.UP.SFT("V"); //获取我的电脑除外类型
  1723. // case "Office": return "rtf,mht,txt,htm,html,doc,docx,xls,xlsx,ppt,pptx,wsh,wsf,cpp,c,css,txt,php,cs,java,log,sql,jsp"; //office文件
  1724. // case "UsestudioOffice": "uw,ue"; //云端office类型
  1725. // case "ComF": return "zip,rar,7z,cab"; //压缩文件类型
  1726. // case "Txt": return "txt,htm,html,css,js"; //文本编辑类型
  1727. // default: return "";
  1728. // }
  1729. //}
  1730. /**
  1731. * 获取上传的样式
  1732. *
  1733. * @param {string} 上传成功回调函数
  1734. */
  1735. //U.UP.XWPGYS = function (UTP) {
  1736. // UTP = UTP.substr(1);
  1737. // var i, _UTF = U.UP.IsDF(UTP),
  1738. // _UDE = {
  1739. // "folder,folderencrypt": ["", "文件夹", "UD_SYWRZOW", null, "UD_SYWLCW"],
  1740. // "docx,doc,uw": ["UD_SYVCOIW", "文档", "UD_SYWRZOD", null, "UD_SYWLCD"],
  1741. // "xls,ue": ["UD_SYVCOIE", "表格", "UD_SYWRZOE", null, "UD_SYWLCE"],
  1742. // "M": ["UD_SYVCOIY", "音乐", "UD_SYWRZOY", null, "UD_SYWLCY"],
  1743. // "V": ["UD_SYVCOIS", "视频", "UD_SYWRZOP", null, "UD_SYWLCP"],
  1744. // "A": ["UD_SYVCOIN", "文件", "UD_SYWRZON", UTP, "UD_SYWLCB"],
  1745. // "P": ["UD_SYVCOIT", "图片", null, UTP]
  1746. // };
  1747. // for (i in _UDE) {
  1748. // if (i.split(",").indexOf(UTP) > -1 || _UTF[0] == i) {
  1749. // return _UDE[i];
  1750. // };
  1751. // }
  1752. //}
  1753. /**
  1754. * 获取网盘中可以上传的文件类型。结构如下:A为网盘,US.DG为目录id,U.UP.SFT('A')为网盘可以上传的文件类型。
  1755. *
  1756. * @param {string} 文件扩展名
  1757. */
  1758. //U.UP.IsDF = function (UTF) {
  1759. // UTF = UTF.toLowerCase(); //全部转换为小写。
  1760. // /*文件分类的类型对应的id 这个在U.M.js 有做说明 这里为4种类型
  1761. // ------[0] 我的网盘类型
  1762. // ------[1] 我的相册类型
  1763. // ------[2] 我的音乐类型
  1764. // ------[3] 我的视频类型
  1765. // */
  1766. // var i, _UDE = [
  1767. // ["A", US.DG, U.UP.SFT("A")], //A为网盘,US.DG为目录id,U.UP.SFT('A')为网盘可以上传的文件类型。
  1768. // ["P", US.PG, U.UP.SFT("P")],
  1769. // ["M", US.MG, U.UP.SFT("M")],
  1770. // ["V", US.VG, U.UP.SFT("V")]
  1771. // ];
  1772. // //筛选使用
  1773. // for (i = 0; i < _UDE.length; i++) {
  1774. // if (_UDE[i][2].indexOf(UTF) > -1) {
  1775. // return _UDE[i];
  1776. // }
  1777. // }
  1778. // return _UDE[0];
  1779. //}
  1780. //#region Ajax上传
  1781. /**
  1782. * ajax上传
  1783. *
  1784. * @param {object} 绕过ajax流程 传参
  1785. * @return {object} ajax上传对象
  1786. */
  1787. U.A.Upload = $.Upload = function (UDE) {
  1788. if ("FormData" in window) { new U.A.Upload.init(UDE); } //允许ajax上传
  1789. else { throw new Error("Browser version is too low"); } //错误处理
  1790. }
  1791. /**
  1792. * ajax上传
  1793. *
  1794. * @param {object} 绕过ajax流程 传参
  1795. ----------[file] 需要上传的文件
  1796. ----------[parameter] 上传传参
  1797. ----------[config] 上传配置
  1798. */
  1799. U.A.Upload.init = function (UDE) { //初始化Jsonp对象
  1800. U.Ut.AddObj(this, UDE);
  1801. }
  1802. U.A.Upload.init.prototype = {
  1803. //创建Ajax上传对象
  1804. create: function () {
  1805. var i = 0,
  1806. _URL = this.url, //请求地址
  1807. _UAE = this.systemAjax = this.CA(), //创建ajax对象
  1808. _UCE = ["progress", "load", "error", "abort"], //事件
  1809. _UDE = this.file, //文件
  1810. _UFE = new FormData(), //生成上传容器
  1811. _UPE = this.parameter, //参数
  1812. _USE = this.config || {},
  1813. _UKE = { "CONTENT-TYPE": "multipart/form-data" }; //默认文件格式配置
  1814. //添加需要上传
  1815. if ((this.tf)) { _UDE = [_UDE]; } else { _UDE = _UDE.files; }
  1816. for (; i < 1; i++) { _UFE.append(Guid.newGuid(), _UDE); } //文件添加
  1817. for (i in _UPE) { _UFE.append(i, _UPE[i]); } //参数添加
  1818. //配置
  1819. (_UAE.overrideMimeType) && (_UAE.overrideMimeType("text/html"));
  1820. _UAE.open("POST", _URL, true); //打开连接
  1821. for (i in _UKE) {
  1822. if (_UKE.hasOwnProperty(i)) { _USE[i] = _USE[i] || _UKE[i] }
  1823. }
  1824. //头部信息添加
  1825. for (i in _USE) {
  1826. try {
  1827. if (i in _UAE) { _UAE[i] = _USE[i]; } else { _UAE.setRequestHeader(i, _USE[i]); }
  1828. } catch (e) { }
  1829. }
  1830. //事件配置
  1831. for (i = 0; i < _UCE.length; i++) { _UAE["on" + _UCE[i]] = U.M.apply(this, _UCE[i]) }
  1832. //发送
  1833. _UAE.send(_UFE);
  1834. },
  1835. //获取或者创建Ajax对象
  1836. CA: function () {
  1837. var i, _UAE, _UDE = U.A.ASet; //获取已停止的Ajax对象
  1838. for (i = 0; i < _UDE.length; i++) {
  1839. if ((_UAE = _UDE[i]).readyState == 4) {
  1840. _UAE.onreadystatechange = U.M.apply();
  1841. _UAE.abort();
  1842. return _UAE;
  1843. }
  1844. }
  1845. _UDE.push((_UAE = new XMLHttpRequest()));
  1846. return _UAE;
  1847. },
  1848. close: function () { //上传取消
  1849. this.systemAjax.abort();
  1850. },
  1851. /**
  1852. * ajax上传
  1853. *
  1854. * @param {event} 进度默认传参
  1855. */
  1856. progress: function (UE) { //Ajax上传进度条
  1857. (this.pro) && (this.pro(UE));
  1858. },
  1859. //上传成功
  1860. load: function () {
  1861. var _USE, _UE = new U.A.Error(),
  1862. _UDE = this.systemAjax;
  1863. //文件上传成功返回值
  1864. if (_UDE.status === 200) {
  1865. _USE = U.M.toList(_UDE.responseText); //生成内容
  1866. if (!_UE.isError(_USE)) {
  1867. (this.lo) && (this.lo({
  1868. r: _UDE, //请求对象
  1869. context: this.context, //回调传参
  1870. error: null, //错误
  1871. value: _USE //返回参数
  1872. }));
  1873. }
  1874. }
  1875. //错误处理
  1876. else { this.error(_USE); }
  1877. },
  1878. /**
  1879. * 错误处理
  1880. *
  1881. * @param {event} 进度默认传参
  1882. */
  1883. error: function (UDE) { //上传错误处理
  1884. (this.err) && (this.err(UDE || {
  1885. State: "500", //错误状态
  1886. LogID: Guid.newGuid(), //错误识别id
  1887. Value: "502 Bad Gateway", //错误内容
  1888. Dt: new Date(), //错误发生时间
  1889. Type: "Ajax" //错误类型
  1890. }));
  1891. },
  1892. /**
  1893. * 错误处理
  1894. *
  1895. * @param {event} 取消上传默认事件
  1896. */
  1897. abort: function (UE) { //中断上传的时候使用
  1898. (this.ab) && (this.ab(UE));
  1899. }
  1900. }
  1901. Namespace.register("U.CV");
  1902. //#region socket消息区域
  1903. //设置文件读取
  1904. U.CV.UL = function (URL, UOE, UEE, UME) {
  1905. return new U.CV.ULinit(URL, UOE, UME).create(UME);
  1906. }
  1907. //获取文件设置
  1908. U.CV.ULinit = function (URL, UOE, UME) {
  1909. this.USK; this.URL = URL || window.location.protocol + "//" + window.location.host; this.UOE = UOE;
  1910. }
  1911. //文件使用方法
  1912. U.CV.ULinit.prototype = {
  1913. sockets: {},
  1914. events: ["connect", "connect_failed", "error", "reconnecting", "reconnect", "disconnect"], //事件源
  1915. create: function (UME) { //创建socketio
  1916. if (this.sockets[this.URL]) { return this.sockets[this.URL]; }
  1917. else {
  1918. U.MD.DynamicLoad("http://socketio.1473.cn/socket.io/socket.io.js", "js", U.M.apply(this, [[this.Asyncreate, [UME]]])); //创建socketio文件
  1919. return this;
  1920. }
  1921. },
  1922. Asyncreate: function (UME) { //创建连接socket连接
  1923. var i, j, _UOE = this.UOE, _UEE = this.UEE, _UDE = this.events, _USE = this.USK = io.connect(this.URL, UME || { "reopen delay": 3000, "connect timeout": 5000, "try multiple transports": true, "reconnect": true, "max reconnection attempts": 10 }); //生成socket通道
  1924. for (i = 0; i < _UDE.length; i++) { _USE.on(_UDE[i], this[_UDE[i]]); } //事件监视
  1925. for (i in _UOE) { if (_UOE.hasOwnProperty(i)) { _USE.on(i, U.M.apply(this, [[this.asyn, [_UOE[i]]]])); } } //添加消息接收设置
  1926. for (i = 0; i < _UEE.length; i++) { this.emit.apply(this, U.Ut.isArguments(_UEE[i]) ? _UEE[i] : [_UEE[i]]); } this.UEE = []; //设置socket连接
  1927. },
  1928. abort: function () { //关闭连接
  1929. this.USK.disconnect();
  1930. },
  1931. asyn: function (UDE) { //获取消息接收
  1932. var _UAE = Array.prototype.slice.call(arguments); _UAE.splice(0, 1);
  1933. (UDE) && (UDE.apply(null, _UAE)); //接收消息回调
  1934. },
  1935. on: function () { //绑定值
  1936. var _UDE = arguments, _USE = this.USK;
  1937. if (_UDE.length > 1) { _USE.on(_UDE[0], U.M.apply(this, [[this.on, [_UDE[1]]]])); } //设置
  1938. else if (U.Ut.isObject(_UDE)) { _UDE.Each(function (UVE, UIE) { _USE.on(_UIE, U.M.apply(this, [[this.on, [asyn]]])); }) }
  1939. },
  1940. emit: function (UME) { //发送消息
  1941. var i, _USE = this.USK;
  1942. if (_USE) { if (U.Ut.isString(UME)) { _USE.emit.apply(_USE, arguments); } else { _$(UME).Each(function (UDE, UIE) { _USE.emit(UIE, UDE[UIE]); }); } } //发送消息
  1943. else { (!this.UEE) && (this.UEE = []); this.UEE.push(U.Ut.isString(UME) ? arguments : UME); } return this; //等待消息发送
  1944. },
  1945. connect: function (UE) { //连接成功
  1946. },
  1947. "connect_failed": function (UE) { //无法连接到服务器
  1948. },
  1949. error: function () { //连接失败
  1950. },
  1951. reconnecting: function () { //不断的连接服务器
  1952. },
  1953. reconnect: function () { //重连成功
  1954. },
  1955. disconnect: function () { //退出连接
  1956. }
  1957. };
  1958. //文件使用方法
  1959. //U.M.Setprototype(U.CV.ULinit, {
  1960. // sockets: {},
  1961. // events: ["connect", "connect_failed", "error", "reconnecting", "reconnect", "disconnect"], //事件源
  1962. // create: function (UME) { //创建socketio
  1963. // if (this.sockets[this.URL]) { return this.sockets[this.URL]; }
  1964. // else {
  1965. // U.MD.DynamicLoad("http://socketio.1473.cn/socket.io/socket.io.js", "js", U.M.apply(this, [[this.Asyncreate, [UME]]])); //创建socketio文件
  1966. // return this;
  1967. // }
  1968. // },
  1969. // Asyncreate: function (UME) { //创建连接socket连接
  1970. // var i, j, _UOE = this.UOE, _UEE = this.UEE, _UDE = this.events, _USE = this.USK = io.connect(this.URL, UME || { "reopen delay": 3000, "connect timeout": 5000, "try multiple transports": true, "reconnect": true, "max reconnection attempts": 10 }); //生成socket通道
  1971. // for (i = 0; i < _UDE.length; i++) { _USE.on(_UDE[i], this[_UDE[i]]); } //事件监视
  1972. // for (i in _UOE) { if (_UOE.hasOwnProperty(i)) { _USE.on(i, U.M.apply(this, [[this.asyn, [_UOE[i]]]])); } } //添加消息接收设置
  1973. // for (i = 0; i < _UEE.length; i++) { this.emit.apply(this, U.Ut.isArguments(_UEE[i]) ? _UEE[i] : [_UEE[i]]); } this.UEE = []; //设置socket连接
  1974. // },
  1975. // abort: function () { //关闭连接
  1976. // this.USK.disconnect();
  1977. // },
  1978. // asyn: function (UDE) { //获取消息接收
  1979. // var _UAE = Array.prototype.slice.call(arguments); _UAE.splice(0, 1);
  1980. // (UDE) && (UDE.apply(null, _UAE)); //接收消息回调
  1981. // },
  1982. // on: function () { //绑定值
  1983. // var _UDE = arguments, _USE = this.USK;
  1984. // if (_UDE.length > 1) { _USE.on(_UDE[0], U.M.apply(this, [[this.on, [_UDE[1]]]])); } //设置
  1985. // else if (U.Ut.isObject(_UDE)) { _UDE.Each(function (UVE, UIE) { _USE.on(_UIE, U.M.apply(this, [[this.on, [asyn]]])); }) }
  1986. // },
  1987. // emit: function (UME) { //发送消息
  1988. // var i, _USE = this.USK;
  1989. // if (_USE) { if (U.Ut.isString(UME)) { _USE.emit.apply(_USE, arguments); } else { _$(UME).Each(function (UDE, UIE) { _USE.emit(UIE, UDE[UIE]); }); } } //发送消息
  1990. // else { (!this.UEE) && (this.UEE = []); this.UEE.push(U.Ut.isString(UME) ? arguments : UME); } return this; //等待消息发送
  1991. // },
  1992. // connect: function (UE) { //连接成功
  1993. // },
  1994. // "connect_failed": function (UE) { //无法连接到服务器
  1995. // },
  1996. // error: function () { //连接失败
  1997. // },
  1998. // reconnecting: function () { //不断的连接服务器
  1999. // },
  2000. // reconnect: function () { //重连成功
  2001. // },
  2002. // disconnect: function () { //退出连接
  2003. // }
  2004. //});
  2005. //#endregion
  2006. //#region 本地存储
  2007. Namespace.register("U.DW");
  2008. /**
  2009. * 异步加载跨域
  2010. *
  2011. * @param {boolean} 是否存储永不过期
  2012. * @param {object} 存储传参对象
  2013. * @return {object} 本地存储使用对象
  2014. */
  2015. U.DW.local = function (UTP, UDE) {
  2016. if ((!browser.msie || Number(browser.ver[2]) > 6)) {
  2017. try {
  2018. var _UDE = new Date(); //当前时间
  2019. (!UTP) && (_UDE.setTime(_UDE.getTime() + (9999 * 24 * 60 * 60 * 1000)), _UBE.expires = _UDE.toUTCString()); //设置永不过期
  2020. } catch (e) { }
  2021. }
  2022. return new U.DW.local.init(UTP); //初始化
  2023. }
  2024. /**
  2025. * 初始化本地存储查看
  2026. *
  2027. * @param {boolean} 是否存储永不过期
  2028. * @param {boolean} 存储传参对象
  2029. * @return {object} 本地存储使用对象
  2030. */
  2031. U.DW.local.init = function (UTP, UDE) {
  2032. U.Ut.AddObj(this, {
  2033. UTP: UTP, //是否永不过期
  2034. UTF: (this.UJE = (UTP ? window.sessionStorage : window.localStorage)), //存储对象
  2035. UJE: this.UJE || $$("input", { "type": "hidden", "style": { "behavior": "url(#default#userdata)"} }, document.body), //ie存储对象
  2036. UDE: UDE || {}, //传参使用
  2037. UGE: null,
  2038. scb: null,
  2039. date: {}
  2040. }); //变量
  2041. //事件绑定
  2042. (UDE && UDE.event) && (this.on(UDE.event));
  2043. return this;
  2044. }
  2045. /**
  2046. * 兼容storage事件触发 ie8-
  2047. *
  2048. * @param {object} U.DW.local实例对象
  2049. */
  2050. U.DW.local._cb = function (UTH) {
  2051. clearInterval(UTH.UTI); //计时器取消
  2052. UTH.UTI = setInterval(function () { //计时器消息
  2053. var _UDE = U.DW.local.iep(UTH); //ie兼容处理
  2054. (_UDE && UTH.UDE.event) && (UTH.UDE.event(_UDE));
  2055. }, 5000);
  2056. };
  2057. /**
  2058. * ie兼容属性设置
  2059. *
  2060. * @param {object} U.DW.local实例对象
  2061. * @param {event} 上storage事件
  2062. * @return {event} storage事件
  2063. */
  2064. U.DW.local.iep = function (UTH, UE) {
  2065. var i,
  2066. _UOE = UTH.date, //变化前的值
  2067. _UNE = UTH.UJE; //变化的对象
  2068. UTH.date = U.DW.local.get(UTH), //获取所有的变化内容
  2069. _UKE = UTH.getAllKey(); //获取所有的key
  2070. for (i = 0; i < _UKE.length; i++) {
  2071. if (_UOE[_UKE[i]] != _UNE[_UKE[i]]) { //判断是否key产生了变化
  2072. return { //返回最新的 ie storgeevent
  2073. Property: null,
  2074. key: _UKE[i], //变化的key值
  2075. oldValue: _UOE[_UKE[i]], //上一次的值
  2076. newValue: _UNE[_UKE[i]], //最新的值
  2077. url: UE ? (UE.url || UE.uri) : document.location.host //链接处理
  2078. };
  2079. }
  2080. }
  2081. }
  2082. /**
  2083. * ie获取变化内容
  2084. *
  2085. * @param {object} U.DW.local实例对象
  2086. * @return {object} event值
  2087. */
  2088. U.DW.local.get = function (UTH) {
  2089. var i, _UKE; UTH.date = [];
  2090. if (browser.ver[1] == "msie" && browser.ver[2].toInt() < 9) { //ie9- 处理
  2091. _UKE = UTH.getAllKey(); //获取所有的key
  2092. for (i = 0; i < _UKE.length; i++) { //获取所有的值 同时设置到 date里
  2093. UTH.date[_UKE[i]] = UTH.UJE[_UKE[i]];
  2094. }
  2095. }
  2096. return UTH.date;
  2097. }
  2098. U.DW.local.init.prototype = {
  2099. /**
  2100. * 事件绑定
  2101. *
  2102. * @param {object} U.DW.local实例对象
  2103. */
  2104. on: function (UDE) {
  2105. this.off(); //事件取消
  2106. this.UDE.event = UDE;
  2107. this.scb = U.M.apply(this, this["storage"]); //事件
  2108. U.DW.local.get(this); //
  2109. this.UTF ? (U.M.AddEvent("storage", window, this.scb), U.M.AddEvent("storage", document, this.scb)) : U.DW.local._cb(this, this.getAll()); //
  2110. },
  2111. //事件绑定取消
  2112. off: function () {
  2113. this.UTF ? (U.M.ReEvent("storage", window, this.scb), U.M.ReEvent("storage", document, this.scb)) : clearInterval(this.UTI); //移除storage绑定 去除计时
  2114. },
  2115. /**
  2116. * 设置值
  2117. *
  2118. * @param {object}需要存储的值 如
  2119. -----------{id:"aaa"}
  2120. * @param {string} 值
  2121. ----------当这个参数存在的使用 参数一是 string的key 这个参数为值
  2122. * @return {object} 对象
  2123. */
  2124. set: function (UDE, USE) { //
  2125. if (this.UJE) {
  2126. var i, _UME = this.UJE;
  2127. (USE != null) && (i = UDE, UDE = {}, UDE[i] = USE);
  2128. //设置存储的值
  2129. for (i in UDE) {
  2130. (UDE.hasOwnProperty(i)) && (this.UTF ? _UME.setItem(i, UDE[i]) : (_UME.setAttribute(i, UDE[i]), _UME.save("us")));
  2131. }
  2132. }
  2133. return this;
  2134. },
  2135. /**
  2136. * storage事件回调
  2137. * @param {number} U.DW.local实例对象
  2138. */
  2139. storage: function (UE) {
  2140. if (this.UDE.event) {
  2141. var _UCB = this.UDE.event; //storage 事件回调函数
  2142. if (UE.newValue == null) { //storage是新值改变
  2143. UE = U.DW.local.iep(this); //生成 storgeevent事件
  2144. }
  2145. (_UCB && UE) && (_UCB(UE)); //回到到指定
  2146. U.M.StopBubble(); //
  2147. }
  2148. },
  2149. /**
  2150. * 事件绑定
  2151. * @param {number} U.DW.local实例对象
  2152. * @param {number} U.DW.local实例对象
  2153. */
  2154. get: function (UIE) { //获取值
  2155. if (this.UJE) {
  2156. var i, _UME = this.UJE,
  2157. _USE = {},
  2158. _UTP = this.UTF ? "getItem" : (_UME.load("us"), "getAttribute");
  2159. if (U.Ut.isString(UIE)) { //普通字符串获取
  2160. return _UME[_UTP](UIE);
  2161. }
  2162. if (U.Ut.isArray(UIE)) { //数组获取
  2163. for (i = 0; i < UIE.length; i++) {
  2164. _USE[UIE[i]] = _UME[_UTP](UIE[i]);
  2165. }
  2166. }
  2167. else if (U.Ut.isObject(UIE)) { //对象获取
  2168. for (i in UIE) { (UIE.hasOwnProperty(i)) && (_USE[i] = _UME[_UTP](i)); }
  2169. }
  2170. return _USE;
  2171. }
  2172. },
  2173. /**
  2174. * 获取所有的值
  2175. * @return {number} U.DW.local实例对象
  2176. */
  2177. getAll: function () {
  2178. var i, _UKE, _USE = {},
  2179. _UME = this.UJE;
  2180. if (this.UTF) { //h5处理
  2181. for (i = 0; i < _UME.length; i++) {
  2182. _UKE = this.key(i); //获取指定的位置的key
  2183. _USE[_UKE] = this.get(_UKE); //根据key获取值
  2184. }
  2185. }
  2186. else { //ie处理
  2187. _UME = _UME.XMLDocument.documentElement.attributes;
  2188. for (i = 0; i < _UME.length; i++) {
  2189. _USE[_UME[i].name] = _UME[i].nodeValue;
  2190. }
  2191. }
  2192. return _USE;
  2193. },
  2194. //获取所有的键
  2195. getAllKey: function () {
  2196. if (this.UJE) {
  2197. var _UME = this.UJE,
  2198. _USE = [];
  2199. if (this.UTF) {
  2200. for (i = 0; i < _UME.length; i++) {
  2201. _USE.push(this.key(i));
  2202. }
  2203. }
  2204. else {
  2205. _UME = _UME.XMLDocument.documentElement.attributes;
  2206. for (i = 0; i < _UME.length; i++) { _USE.push(_UME[i].name); }
  2207. }
  2208. return _USE;
  2209. }
  2210. },
  2211. /**
  2212. * 移除值
  2213. * @param {string 、 object} 移除的键值
  2214. * @return {object} 本地存储类
  2215. */
  2216. remove: function (UIE) {
  2217. if (this.UJE) {
  2218. var i,
  2219. _UME = this.UJE,
  2220. _UTP = this.UTF ? "removeItem" : "removeAttribute"; //兼容删除的内容
  2221. if (U.Ut.isString(UIE)) { //普通删除
  2222. _UME[_UTP](UIE);
  2223. }
  2224. else if (U.Ut.isArray(UIE)) { //普通的通过key删除
  2225. for (i = 0; i < UIE.length; i++) {
  2226. _UME[_UTP](UIE[i]);
  2227. }
  2228. }
  2229. else { //对象删除
  2230. for (i in UIE) {
  2231. (UIE.hasOwnProperty(i)) && (_UME[_UTP](i));
  2232. }
  2233. }
  2234. (!this.UTF) && (_UME.save("us")); //ie还需要保存操作
  2235. } return this;
  2236. },
  2237. //移除所有的存储
  2238. clear: function () {
  2239. if (this.UJE) {
  2240. if (this.UTF) { this.UJE.clear(); } //HTML5
  2241. else { //ie处理删除
  2242. var i, _UME = this.UJE;
  2243. _UME.load("us");
  2244. _UME = _UME.XMLDocument.documentElement.attributes; //所有的本地存储属性
  2245. for (i = 0; i < _UME.length; i++) { _UME.remove(_UME[i].name); } //循环删除
  2246. }
  2247. }
  2248. },
  2249. /**
  2250. * 索引值
  2251. * @param {string} 键值
  2252. * @return {string} 键值对应值
  2253. */
  2254. key: function (UI) {
  2255. if (this.UJE) {
  2256. if (this.UTF) { //html5获取值
  2257. return this.UJE.key(UI);
  2258. }
  2259. else { //ie获取
  2260. var _UME = this.UJE;
  2261. _UME.load("us"), //获取所有存储的值
  2262. _UDM = _UME.XMLDocument.documentElement.attrbutes;
  2263. if (_UDM[UI]) { //判断是否存在该键值的值
  2264. return _UDM[UI].name;
  2265. }
  2266. }
  2267. }
  2268. },
  2269. //获取长度
  2270. length: function () {
  2271. if (this.UJE) {
  2272. if (this.UTF) { return this.UJE.length; } //html5获取值
  2273. else { //ie获取
  2274. var _UL, _UDM,
  2275. _UME = this.UJE;
  2276. _UME.load("us");
  2277. _UDM = _UME.XMLDocument; //获取所有存储的值
  2278. ((_UDM = _UDM.childNodes[0]) && (_UL = _UDM.attributes.length));
  2279. return _UL;
  2280. }
  2281. }
  2282. }
  2283. }
  2284. //#endregion
  2285. //#region 加密区域
  2286. Namespace.register("U.E"); //加密
  2287. /*
  2288. 功能:前端加密函数,暂未使用
  2289. */
  2290. U.E.CryptoJS = function (s, p) {
  2291. var m = {}, l = m.lib = {}, n = function () {
  2292. }, r = l.Base = { extend: function (b) {
  2293. n.prototype = this;
  2294. var h = new n;
  2295. b && h.mixIn(b);
  2296. h.hasOwnProperty("init") || (h.init = function () {
  2297. h.$super.init.apply(this, arguments)
  2298. });
  2299. h.init.prototype = h;
  2300. h.$super = this;
  2301. return h
  2302. }, create: function () {
  2303. var b = this.extend();
  2304. b.init.apply(b, arguments);
  2305. return b
  2306. }, init: function () {
  2307. }, mixIn: function (b) {
  2308. for (var h in b)
  2309. b.hasOwnProperty(h) && (this[h] = b[h]);
  2310. b.hasOwnProperty("toString") && (this.toString = b.toString)
  2311. }, clone: function () {
  2312. return this.init.prototype.extend(this)
  2313. }
  2314. },
  2315. q = l.WordArray = r.extend({ init: function (b, h) {
  2316. b = this.words = b || [];
  2317. this.sigBytes = h != p ? h : 4 * b.length
  2318. }, toString: function (b) {
  2319. return (b || t).stringify(this)
  2320. }, concat: function (b) {
  2321. var h = this.words, a = b.words, j = this.sigBytes;
  2322. b = b.sigBytes;
  2323. this.clamp();
  2324. if (j % 4)
  2325. for (var g = 0; g < b; g++)
  2326. h[j + g >>> 2] |= (a[g >>> 2] >>> 24 - 8 * (g % 4) & 255) << 24 - 8 * ((j + g) % 4);
  2327. else if (65535 < a.length)
  2328. for (g = 0; g < b; g += 4)
  2329. h[j + g >>> 2] = a[g >>> 2];
  2330. else
  2331. h.push.apply(h, a);
  2332. this.sigBytes += b;
  2333. return this
  2334. }, clamp: function () {
  2335. var b = this.words, h = this.sigBytes;
  2336. b[h >>> 2] &= 4294967295 <<
  2337. 32 - 8 * (h % 4);
  2338. b.length = s.ceil(h / 4)
  2339. }, clone: function () {
  2340. var b = r.clone.call(this);
  2341. b.words = this.words.slice(0);
  2342. return b
  2343. }, random: function (b) {
  2344. for (var h = [], a = 0; a < b; a += 4)
  2345. h.push(4294967296 * s.random() | 0);
  2346. return new q.init(h, b)
  2347. }
  2348. }), v = m.enc = {}, t = v.Hex = { stringify: function (b) {
  2349. var a = b.words;
  2350. b = b.sigBytes;
  2351. for (var g = [], j = 0; j < b; j++) {
  2352. var k = a[j >>> 2] >>> 24 - 8 * (j % 4) & 255;
  2353. g.push((k >>> 4).toString(16));
  2354. g.push((k & 15).toString(16))
  2355. }
  2356. return g.join("")
  2357. }, parse: function (b) {
  2358. for (var a = b.length, g = [], j = 0; j < a; j += 2)
  2359. g[j >>> 3] |= parseInt(b.substr(j,
  2360. 2), 16) << 24 - 4 * (j % 8);
  2361. return new q.init(g, a / 2)
  2362. }
  2363. }, a = v.Latin1 = { stringify: function (b) {
  2364. var a = b.words;
  2365. b = b.sigBytes;
  2366. for (var g = [], j = 0; j < b; j++)
  2367. g.push(String.fromCharCode(a[j >>> 2] >>> 24 - 8 * (j % 4) & 255));
  2368. return g.join("")
  2369. }, parse: function (b) {
  2370. for (var a = b.length, g = [], j = 0; j < a; j++)
  2371. g[j >>> 2] |= (b.charCodeAt(j) & 255) << 24 - 8 * (j % 4);
  2372. return new q.init(g, a)
  2373. }
  2374. }, u = v.Utf8 = { stringify: function (b) {
  2375. try {
  2376. return decodeURIComponent(escape(a.stringify(b)))
  2377. } catch (g) {
  2378. throw Error("Malformed UTF-8 data");
  2379. }
  2380. }, parse: function (b) {
  2381. return a.parse(unescape(encodeURIComponent(b)))
  2382. }
  2383. },
  2384. g = l.BufferedBlockAlgorithm = r.extend({ reset: function () {
  2385. this._data = new q.init;
  2386. this._nDataBytes = 0
  2387. }, _append: function (b) {
  2388. "string" == typeof b && (b = u.parse(b));
  2389. this._data.concat(b);
  2390. this._nDataBytes += b.sigBytes
  2391. }, _process: function (b) {
  2392. var a = this._data, g = a.words, j = a.sigBytes, k = this.blockSize, m = j / (4 * k), m = b ? s.ceil(m) : s.max((m | 0) - this._minBufferSize, 0);
  2393. b = m * k;
  2394. j = s.min(4 * b, j);
  2395. if (b) {
  2396. for (var l = 0; l < b; l += k)
  2397. this._doProcessBlock(g, l);
  2398. l = g.splice(0, b);
  2399. a.sigBytes -= j
  2400. }
  2401. return new q.init(l, j)
  2402. }, clone: function () {
  2403. var b = r.clone.call(this);
  2404. b._data = this._data.clone();
  2405. return b
  2406. }, _minBufferSize: 0
  2407. });
  2408. l.Hasher = g.extend({ cfg: r.extend(), init: function (b) {
  2409. this.cfg = this.cfg.extend(b);
  2410. this.reset()
  2411. }, reset: function () {
  2412. g.reset.call(this);
  2413. this._doReset()
  2414. }, update: function (b) {
  2415. this._append(b);
  2416. this._process();
  2417. return this
  2418. }, finalize: function (b) {
  2419. b && this._append(b);
  2420. return this._doFinalize()
  2421. }, blockSize: 16, _createHelper: function (b) {
  2422. return function (a, g) {
  2423. return (new b.init(g)).finalize(a)
  2424. }
  2425. }, _createHmacHelper: function (b) {
  2426. return function (a, g) {
  2427. return (new k.HMAC.init(b,
  2428. g)).finalize(a)
  2429. }
  2430. }
  2431. });
  2432. var k = m.algo = {};
  2433. return m
  2434. } (Math);
  2435. (function (s) {
  2436. function p(a, k, b, h, l, j, m) {
  2437. a = a + (k & b | ~k & h) + l + m;
  2438. return (a << j | a >>> 32 - j) + k
  2439. }
  2440. function m(a, k, b, h, l, j, m) {
  2441. a = a + (k & h | b & ~h) + l + m;
  2442. return (a << j | a >>> 32 - j) + k
  2443. }
  2444. function l(a, k, b, h, l, j, m) {
  2445. a = a + (k ^ b ^ h) + l + m;
  2446. return (a << j | a >>> 32 - j) + k
  2447. }
  2448. function n(a, k, b, h, l, j, m) {
  2449. a = a + (b ^ (k | ~h)) + l + m;
  2450. return (a << j | a >>> 32 - j) + k
  2451. }
  2452. for (var r = U.E.CryptoJS, q = r.lib, v = q.WordArray, t = q.Hasher, q = r.algo, a = [], u = 0; 64 > u; u++)
  2453. a[u] = 4294967296 * s.abs(s.sin(u + 1)) | 0;
  2454. q = q.MD5 = t.extend({ _doReset: function () {
  2455. this._hash = new v.init[1732584193, 4023233417, 2562383102, 271733878]
  2456. },
  2457. _doProcessBlock: function (g, k) {
  2458. for (var b = 0; 16 > b; b++) {
  2459. var h = k + b, w = g[h];
  2460. g[h] = (w << 8 | w >>> 24) & 16711935 | (w << 24 | w >>> 8) & 4278255360
  2461. }
  2462. var b = this._hash.words, h = g[k + 0], w = g[k + 1], j = g[k + 2], q = g[k + 3], r = g[k + 4], s = g[k + 5], t = g[k + 6], u = g[k + 7], v = g[k + 8], x = g[k + 9], y = g[k + 10], z = g[k + 11], A = g[k + 12], B = g[k + 13], C = g[k + 14], D = g[k + 15], c = b[0], d = b[1], e = b[2], f = b[3], c = p(c, d, e, f, h, 7, a[0]), f = p(f, c, d, e, w, 12, a[1]), e = p(e, f, c, d, j, 17, a[2]), d = p(d, e, f, c, q, 22, a[3]), c = p(c, d, e, f, r, 7, a[4]), f = p(f, c, d, e, s, 12, a[5]), e = p(e, f, c, d, t, 17, a[6]), d = p(d, e, f, c, u, 22, a[7]),
  2463. c = p(c, d, e, f, v, 7, a[8]), f = p(f, c, d, e, x, 12, a[9]), e = p(e, f, c, d, y, 17, a[10]), d = p(d, e, f, c, z, 22, a[11]), c = p(c, d, e, f, A, 7, a[12]), f = p(f, c, d, e, B, 12, a[13]), e = p(e, f, c, d, C, 17, a[14]), d = p(d, e, f, c, D, 22, a[15]), c = m(c, d, e, f, w, 5, a[16]), f = m(f, c, d, e, t, 9, a[17]), e = m(e, f, c, d, z, 14, a[18]), d = m(d, e, f, c, h, 20, a[19]), c = m(c, d, e, f, s, 5, a[20]), f = m(f, c, d, e, y, 9, a[21]), e = m(e, f, c, d, D, 14, a[22]), d = m(d, e, f, c, r, 20, a[23]), c = m(c, d, e, f, x, 5, a[24]), f = m(f, c, d, e, C, 9, a[25]), e = m(e, f, c, d, q, 14, a[26]), d = m(d, e, f, c, v, 20, a[27]), c = m(c, d, e, f, B, 5, a[28]), f = m(f, c,
  2464. d, e, j, 9, a[29]), e = m(e, f, c, d, u, 14, a[30]), d = m(d, e, f, c, A, 20, a[31]), c = l(c, d, e, f, s, 4, a[32]), f = l(f, c, d, e, v, 11, a[33]), e = l(e, f, c, d, z, 16, a[34]), d = l(d, e, f, c, C, 23, a[35]), c = l(c, d, e, f, w, 4, a[36]), f = l(f, c, d, e, r, 11, a[37]), e = l(e, f, c, d, u, 16, a[38]), d = l(d, e, f, c, y, 23, a[39]), c = l(c, d, e, f, B, 4, a[40]), f = l(f, c, d, e, h, 11, a[41]), e = l(e, f, c, d, q, 16, a[42]), d = l(d, e, f, c, t, 23, a[43]), c = l(c, d, e, f, x, 4, a[44]), f = l(f, c, d, e, A, 11, a[45]), e = l(e, f, c, d, D, 16, a[46]), d = l(d, e, f, c, j, 23, a[47]), c = n(c, d, e, f, h, 6, a[48]), f = n(f, c, d, e, u, 10, a[49]), e = n(e, f, c, d,
  2465. C, 15, a[50]), d = n(d, e, f, c, s, 21, a[51]), c = n(c, d, e, f, A, 6, a[52]), f = n(f, c, d, e, q, 10, a[53]), e = n(e, f, c, d, y, 15, a[54]), d = n(d, e, f, c, w, 21, a[55]), c = n(c, d, e, f, v, 6, a[56]), f = n(f, c, d, e, D, 10, a[57]), e = n(e, f, c, d, t, 15, a[58]), d = n(d, e, f, c, B, 21, a[59]), c = n(c, d, e, f, r, 6, a[60]), f = n(f, c, d, e, z, 10, a[61]), e = n(e, f, c, d, j, 15, a[62]), d = n(d, e, f, c, x, 21, a[63]);
  2466. b[0] = b[0] + c | 0;
  2467. b[1] = b[1] + d | 0;
  2468. b[2] = b[2] + e | 0;
  2469. b[3] = b[3] + f | 0
  2470. }, _doFinalize: function () {
  2471. var a = this._data, k = a.words, b = 8 * this._nDataBytes, h = 8 * a.sigBytes;
  2472. k[h >>> 5] |= 128 << 24 - h % 32;
  2473. var l = s.floor(b /
  2474. 4294967296);
  2475. k[(h + 64 >>> 9 << 4) + 15] = (l << 8 | l >>> 24) & 16711935 | (l << 24 | l >>> 8) & 4278255360;
  2476. k[(h + 64 >>> 9 << 4) + 14] = (b << 8 | b >>> 24) & 16711935 | (b << 24 | b >>> 8) & 4278255360;
  2477. a.sigBytes = 4 * (k.length + 1);
  2478. this._process();
  2479. a = this._hash;
  2480. k = a.words;
  2481. for (b = 0; 4 > b; b++)
  2482. h = k[b], k[b] = (h << 8 | h >>> 24) & 16711935 | (h << 24 | h >>> 8) & 4278255360;
  2483. return a
  2484. }, clone: function () {
  2485. var a = t.clone.call(this);
  2486. a._hash = this._hash.clone();
  2487. return a
  2488. }
  2489. });
  2490. r.MD5 = t._createHelper(q);
  2491. r.HmacMD5 = t._createHmacHelper(q)
  2492. })(Math);
  2493. //#endregion
  2494. //------------------键盘处理类
  2495. Namespace.register("U.K");
  2496. //#region 全局变量区域
  2497. //变量来存储_MAP的翻转版从上面
  2498. U.K._REVERSE_MAP;
  2499. //特殊键码的映射到其对应的键
  2500. U.K._MAP = {
  2501. 8: 'backspace',
  2502. 9: 'tab',
  2503. 13: 'enter',
  2504. 16: 'shift',
  2505. 17: 'ctrl',
  2506. 18: 'alt',
  2507. 20: 'capslock',
  2508. 27: 'esc',
  2509. 32: 'space',
  2510. 33: 'pageup',
  2511. 34: 'pagedown',
  2512. 35: 'end',
  2513. 36: 'home',
  2514. 37: 'left',
  2515. 38: 'up',
  2516. 39: 'right',
  2517. 40: 'down',
  2518. 45: 'ins',
  2519. 46: 'del',
  2520. 91: 'meta',
  2521. 93: 'meta',
  2522. 224: 'meta'
  2523. };
  2524. //特殊字符,使他们能够支持映射
  2525. U.K._KEYCODE_MAP = {
  2526. 106: '*',
  2527. 107: '+',
  2528. 109: '-',
  2529. 110: '.',
  2530. 111: '/',
  2531. 186: ';',
  2532. 187: '=',
  2533. 188: ',',
  2534. 189: '-',
  2535. 190: '.',
  2536. 191: '/',
  2537. 192: '`',
  2538. 219: '[',
  2539. 220: '\\',
  2540. 221: ']',
  2541. 222: '\''
  2542. };
  2543. //这是需要一个美国小键盘上的shift键的映射
  2544. U.K._SHIFT_MAP = {
  2545. '~': '`',
  2546. '!': '1',
  2547. '@': '2',
  2548. '#': '3',
  2549. '$': '4',
  2550. '%': '5',
  2551. '^': '6',
  2552. '&': '7',
  2553. '*': '8',
  2554. '(': '9',
  2555. ')': '0',
  2556. '_': '-',
  2557. '+': '=',
  2558. ':': ';',
  2559. '\"': '\'',
  2560. '<': ',',
  2561. '>': '.',
  2562. '?': '/',
  2563. '|': '\\'
  2564. };
  2565. //这是你可以用它来绘制特殊字符串列表
  2566. U.K._SPECIAL_ALIASES = {
  2567. 'option': 'alt',
  2568. 'command': 'meta',
  2569. 'return': 'enter',
  2570. 'escape': 'esc',
  2571. 'plus': '+',
  2572. 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'
  2573. };
  2574. U.K.start = function () {
  2575. //遍历F键,F1至F19,并把它们添加到地图
  2576. for (var i = 1; i < 20; ++i) {
  2577. U.K._MAP[111 + i] = 'f' + i;
  2578. }
  2579. //数字键盘的数字添加
  2580. for (i = 0; i <= 9; ++i) {
  2581. U.K._MAP[i + 96] = i.toString();
  2582. }
  2583. }
  2584. //#endregion
  2585. //#region 方法使用区域
  2586. //取事件,并返回的键值
  2587. U.K._characterFromEvent = function (e) {
  2588. //为按键事件,我们应该回到该字符是
  2589. if (e.type == 'keypress') {
  2590. var character = String.fromCharCode(e.which);
  2591. // 如果没有然后按下Shift键它是安全的假设
  2592. // 我们想要的字符是小写。这意味着,如果
  2593. // 你不小心有大写锁定,然后键绑定
  2594. // 将继续工作
  2595. //
  2596. // 可能是不希望的唯一副作用是,如果你
  2597. // 绑定类似'A',因为你要触发
  2598. // 事件被按下大写字母A时,大写锁定将不再
  2599. // 触发事件。尽管绑定了shift+a。
  2600. if (!e.shiftKey) {
  2601. character = character.toLowerCase();
  2602. }
  2603. return character;
  2604. }
  2605. // 非按键事件所需的专用地图
  2606. if (U.K._MAP[e.which]) {
  2607. return U.K._MAP[e.which];
  2608. }
  2609. if (U.K._KEYCODE_MAP[e.which]) {
  2610. return U.K._KEYCODE_MAP[e.which];
  2611. }
  2612. // 如果它不是在特殊的地图
  2613. // 与KEYDOWN和KeyUp事件的性质似乎总
  2614. // 进来作为一个大写字符无论您是按住Shift
  2615. // 或不。我们应该确保它始终是小写的比较
  2616. return String.fromCharCode(e.which).toLowerCase();
  2617. }
  2618. /**
  2619. * 检查,如果两个数组相等,
  2620. *
  2621. * @param {Array} modifiers1
  2622. * @param {Array} modifiers2
  2623. * @returns {boolean}
  2624. */
  2625. U.K._modifiersMatch = function (modifiers1, modifiers2) {
  2626. return modifiers1.sort().join(',') === modifiers2.sort().join(',');
  2627. }
  2628. /**
  2629. * 需要一个关键事件,并计算出的修饰符是什么
  2630. *
  2631. * @param {Event} e
  2632. * @returns {Array}
  2633. */
  2634. U.K._eventModifiers = function (e) {
  2635. var modifiers = [];
  2636. if (e.shiftKey) {
  2637. modifiers.push('shift');
  2638. }
  2639. if (e.altKey) {
  2640. modifiers.push('alt');
  2641. }
  2642. if (e.ctrlKey) {
  2643. modifiers.push('ctrl');
  2644. }
  2645. if (e.metaKey) {
  2646. modifiers.push('meta');
  2647. }
  2648. return modifiers;
  2649. }
  2650. /**
  2651. * 确定指定的键码是一个修改键或不
  2652. *
  2653. * @param {string} key
  2654. * @returns {boolean}
  2655. */
  2656. U.K._isModifier = function (key) {
  2657. return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';
  2658. }
  2659. /**
  2660. * 颠倒了地图查找,这样我们可以寻找特定键
  2661. *看看有什么可以和不能使用的按键
  2662. *
  2663. * @return {Object}
  2664. */
  2665. U.K._getReverseMap = function () {
  2666. if (!_REVERSE_MAP) {
  2667. _REVERSE_MAP = {};
  2668. for (var key in U.K._MAP) {
  2669. //从这里拉出数字小键盘按键的事业宜
  2670. //能够从字符检测的按键
  2671. if (key > 95 && key < 112) {
  2672. continue;
  2673. }
  2674. if (U.K._MAP.hasOwnProperty(key)) {
  2675. _REVERSE_MAP[U.K._MAP[key]] = key;
  2676. }
  2677. }
  2678. }
  2679. return _REVERSE_MAP;
  2680. }
  2681. /**
  2682. * 挑选基础上,组合键最佳动作
  2683. *
  2684. * @param {string} key - character for key
  2685. * @param {Array} modifiers
  2686. * @param {string=} action passed in
  2687. */
  2688. U.K._pickBestAction = function (key, modifiers, action) {
  2689. //如果没有动作,拿起我们应该尽量挑选一个
  2690. //我们认为将工作最适合这一关键
  2691. if (!action) {
  2692. action = U.K._getReverseMap()[key] ? 'keydown' : 'keypress';
  2693. }
  2694. //与预期的按键组合键不起作用,
  2695. //切换到KEYDOWN
  2696. if (action == 'keypress' && modifiers.length) {
  2697. action = 'keydown';
  2698. }
  2699. return action;
  2700. }
  2701. /**
  2702. * *从一个字符串组合键转换到一个数组
  2703. *
  2704. * @param {string} 的组合,如 "command+shift+l"
  2705. * @return {Array}
  2706. */
  2707. U.K._keysFromString = function (combination) {
  2708. if (combination === '+') {
  2709. return ['+'];
  2710. }
  2711. combination = combination.replace(/\+{2}/g, '+plus');
  2712. return combination.split('+');
  2713. }
  2714. /**
  2715. * Gets 获取信息的特定的组合键
  2716. *
  2717. * @param {string} combination key combination ("command+s" or "a" or "*")
  2718. * @param {string=} action
  2719. * @returns {Object}
  2720. */
  2721. U.K._getKeyInfo = function (combination, action) {
  2722. var keys;
  2723. var key;
  2724. var i;
  2725. var modifiers = [];
  2726. // 从这种模式带钥匙,弄清实际
  2727. // 模式是所有
  2728. keys = U.K._keysFromString(combination);
  2729. for (i = 0; i < keys.length; ++i) {
  2730. key = keys[i];
  2731. // normalize key names
  2732. if (U.K._SPECIAL_ALIASES[key]) {
  2733. key = U.K._SPECIAL_ALIASES[key];
  2734. }
  2735. //如果这不是一个按键事件那么我们应该
  2736. //聪明地使用shift键
  2737. //这只会为我们工作不过键盘
  2738. if (action && action != 'keypress' && U.K._SHIFT_MAP[key]) {
  2739. key = U.K._SHIFT_MAP[key];
  2740. modifiers.push('shift');
  2741. }
  2742. //如果该键是一个修改,然后将其添加到修改器列表
  2743. if (U.K._isModifier(key)) {
  2744. modifiers.push(key);
  2745. }
  2746. }
  2747. //根据密钥的组合是什么
  2748. //我们会尽力挑选最好的事件它
  2749. action = U.K._pickBestAction(key, modifiers, action);
  2750. return {
  2751. key: key,
  2752. modifiers: modifiers,
  2753. action: action
  2754. };
  2755. }
  2756. //判断监听来源
  2757. U.K._belongsTo = function (element, ancestor) {
  2758. if (element === null || element === document) {
  2759. return false;
  2760. }
  2761. if (element === ancestor) {
  2762. return true;
  2763. }
  2764. return U.K._getReverseMap(element.parentNode, ancestor);
  2765. }
  2766. //#endregion
  2767. //#region 对外接口区域
  2768. //对外公布函数
  2769. U.K.Mousetrap = function (targetElement) {
  2770. var self = this;
  2771. targetElement = targetElement || document;
  2772. if (!(self instanceof U.K.Mousetrap)) {
  2773. return new U.K.Mousetrap(targetElement);
  2774. }
  2775. /**
  2776. * 元素附加关键事件
  2777. *
  2778. * @type {Element}
  2779. */
  2780. self.target = targetElement;
  2781. /**
  2782. * 通过Mousetrap.bind所有的回调设置列表()
  2783. *
  2784. * @type {Object}
  2785. */
  2786. self._callbacks = {};
  2787. /**
  2788. * 字符串组合的直接映射到用于触发回调()
  2789. *
  2790. * @type {Object}
  2791. */
  2792. self._directMap = {};
  2793. /**
  2794. * 跟踪什么级别的每个序列是因为多个
  2795. *序列可以开始时具有相同的序列
  2796. *
  2797. * @type {Object}
  2798. */
  2799. var _sequenceLevels = {};
  2800. /**
  2801. * 变量来存储方法setTimeout
  2802. *
  2803. * @type {null|number}
  2804. */
  2805. var _resetTimer;
  2806. /**
  2807. * 临时的状态,我们会忽略下一个KEYUP
  2808. *
  2809. * @type {boolean|string}
  2810. */
  2811. var _ignoreNextKeyup = false;
  2812. /**
  2813. * 临时的状态,我们会忽略下一个按键
  2814. *
  2815. * @type {boolean}
  2816. */
  2817. var _ignoreNextKeypress = false;
  2818. /**
  2819. * 是我们目前的序列里面?
  2820. * acticon(“KEYUP”或“的keydown”或“keypress”)或flase的类型
  2821. *
  2822. * @type {boolean|string}
  2823. */
  2824. var _nextExpectedAction = false;
  2825. /**
  2826. * 重置所有序列柜台,除了传递的那些
  2827. *
  2828. * @param {Object} doNotReset
  2829. * @returns void
  2830. */
  2831. function _resetSequences(doNotReset) {
  2832. doNotReset = doNotReset || {};
  2833. var activeSequences = false,
  2834. key;
  2835. for (key in _sequenceLevels) {
  2836. if (doNotReset[key]) {
  2837. activeSequences = true;
  2838. continue;
  2839. }
  2840. _sequenceLevels[key] = 0;
  2841. }
  2842. if (!activeSequences) {
  2843. _nextExpectedAction = false;
  2844. }
  2845. }
  2846. /**
  2847. * *查找匹配基础上的keyCode,所有的callback,modifiers,action
  2848. *
  2849. * @param {string} character
  2850. * @param {Array} modifiers
  2851. * @param {Event|Object} e
  2852. * @param {string=} sequenceName - name of the sequence we are looking for
  2853. * @param {string=} combination
  2854. * @param {number=} level
  2855. * @returns {Array}
  2856. */
  2857. function _getMatches(character, modifiers, e, sequenceName, combination, level) {
  2858. var i;
  2859. var callback;
  2860. var matches = [];
  2861. var action = e.type;
  2862. // 如果没有与此相关的键码的事件
  2863. if (!self._callbacks[character]) {
  2864. return [];
  2865. }
  2866. // 如果修改键快到了自身,我们应该允许它
  2867. if (action == 'keyup' && U.K._isModifier(character)) {
  2868. modifiers = [character];
  2869. }
  2870. // 通过被按下该键所有的回调循环
  2871. //,看看其中是否匹配
  2872. for (i = 0; i < self._callbacks[character].length; ++i) {
  2873. callback = self._callbacks[character][i];
  2874. //如果一个序列名未指定,但是这是一个序列的
  2875. //错误的水平,那么移动到下一个match
  2876. if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {
  2877. continue;
  2878. }
  2879. // //如果我们正在寻找的action不符合我们的action
  2880. //那么我们就应该继续执行
  2881. if (action != callback.action) {
  2882. continue;
  2883. }
  2884. //如果这是一个keypress event和meta和control key
  2885. //没有按下这意味着我们只需要看
  2886. //字符,否则检查改性剂以及
  2887. //
  2888. // Chrome浏览器不会触发一个keypress如果meta or control is down
  2889. // Safari会触发一个 keypress 如果 meta or meta+shift is down
  2890. // Firefox会触发一个keypress 如果 meta or control is down
  2891. if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || U.K._modifiersMatch(modifiers, callback.modifiers)) {
  2892. //当你绑定的组合或序列的第二次它
  2893. //应该覆盖的第一个。如果sequenceName或
  2894. //组合在这个指定的调用它做到了这一点
  2895. //
  2896. //@todo使删除它自己的方法?
  2897. var deleteCombo = !sequenceName && callback.combo == combination;
  2898. var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;
  2899. if (deleteCombo || deleteSequence) {
  2900. self._callbacks[character].splice(i, 1);
  2901. }
  2902. matches.push(callback);
  2903. }
  2904. }
  2905. return matches;
  2906. }
  2907. /**
  2908. * 实际调用回调函数
  2909. *
  2910. *
  2911. *
  2912. *如果您的回调函数返回false,这将使用jQuery的
  2913. * convention - 防止违约和对事件停止传播史
  2914. *
  2915. * @param {Function} callback
  2916. * @param {Event} e
  2917. * @returns void
  2918. */
  2919. function _fireCallback(callback, e, combo, sequence) {
  2920. // //如果此事件不应该发生到此为止
  2921. if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
  2922. return;
  2923. }
  2924. if (callback(e, combo) === false) {
  2925. U.M.StopDefault(e);
  2926. U.M.StopBubble(e);
  2927. }
  2928. }
  2929. /**
  2930. * 处理一个字符键事件
  2931. *
  2932. * @param {string} character
  2933. * @param {Array} modifiers
  2934. * @param {Event} e
  2935. * @returns void
  2936. */
  2937. self._handleKey = function (character, modifiers, e) {
  2938. var callbacks = _getMatches(character, modifiers, e);
  2939. var i;
  2940. var doNotReset = {};
  2941. var maxLevel = 0;
  2942. var processedSequenceCallback = false;
  2943. // 计算maxLevel的序列,所以我们只能执行时间最长的回调序列
  2944. for (i = 0; i < callbacks.length; ++i) {
  2945. if (callbacks[i].seq) {
  2946. maxLevel = Math.max(maxLevel, callbacks[i].level);
  2947. }
  2948. }
  2949. //通过匹配回调回路这一关键事件
  2950. for (i = 0; i < callbacks.length; ++i) {
  2951. // 触发有序回调
  2952. // 这是因为例如,如果您有多个序列
  2953. // 结合诸如“G i”和“G t”,他们都需要触发
  2954. // 回调匹配摹原因,否则你永远只能
  2955. // 匹配到第一个
  2956. if (callbacks[i].seq) {
  2957. //只触发回调的maxLevel防止
  2958. //
  2959. //
  2960. //例如 “a option b' 应该不会造成'option b' 触发
  2961. //即使'option b'为其它序列的一部分
  2962. //
  2963. //这里不匹配任何序列都将被丢弃
  2964. //下面的_resetSequences通话
  2965. if (callbacks[i].level != maxLevel) {
  2966. continue;
  2967. }
  2968. processedSequenceCallback = true;
  2969. // //保留其中的序列是匹配为以后列表
  2970. doNotReset[callbacks[i].seq] = 1;
  2971. _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);
  2972. continue;
  2973. }
  2974. // 如果没有序列相匹配,但我们还在这里
  2975. // 这意味着这是一个普通的匹配,所以我们应该触发了
  2976. if (!processedSequenceCallback) {
  2977. _fireCallback(callbacks[i].callback, e, callbacks[i].combo);
  2978. }
  2979. }
  2980. // if the key you pressed matches the type of sequence without
  2981. // being a modifier (ie "keyup" or "keypress") then we should
  2982. // reset all sequences that were not matched by this event
  2983. //
  2984. // this is so, for example, if you have the sequence "h a t" and you
  2985. // type "h e a r t" it does not match. in this case the "e" will
  2986. // cause the sequence to reset
  2987. //
  2988. // modifier keys are ignored because you can have a sequence
  2989. // that contains modifiers such as "enter ctrl+space" and in most
  2990. // cases the modifier key will be pressed before the next key
  2991. //
  2992. // also if you have a sequence such as "ctrl+b a" then pressing the
  2993. // "b" key will trigger a "keypress" and a "keydown"
  2994. //
  2995. // the "keydown" is expected when there is a modifier, but the
  2996. // "keypress" ends up matching the _nextExpectedAction since it occurs
  2997. // after and that causes the sequence to reset
  2998. //
  2999. // we ignore keypresses in a sequence that directly follow a keydown
  3000. // for the same character
  3001. //如果你按下键序列无类型相匹配
  3002. //是一个修改(即“KEYUP”或“按键”),那么,我们应该
  3003. //重新设置那些没有此事件相匹配的所有序列
  3004. //
  3005. //是这样,例如,如果你有序列“哈t”和你
  3006. //型“听到T”不匹配。在这种情况下,将“e”的意愿
  3007. //导致序列复位
  3008. //
  3009. //修饰键被忽略,因为你可以有一个序列
  3010. //包含修饰,如“输入Ctrl +空格”,并在最
  3011. //情况下,修改键将在下键之前按下
  3012. //
  3013. //此外,如果你有一个序列,例如“CTRL + B A”,然后按
  3014. //“b”的键将触发一个“按键”和一个“的keydown”
  3015. //
  3016. //在“的keydown”时,有一个改性剂预期,但
  3017. //“按键”结束了,因为它发生_nextExpectedAction匹配
  3018. //之后和使该序列重新设置
  3019. //
  3020. //我们忽略了一个顺序按键直接遵循的keydown
  3021. //对于相同的字符
  3022. var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;
  3023. if (e.type == _nextExpectedAction && !U.K._isModifier(character) && !ignoreThisKeypress) {
  3024. _resetSequences(doNotReset);
  3025. }
  3026. _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';
  3027. };
  3028. /**
  3029. *处理一个keydown事件
  3030. *
  3031. * @param {Event} e
  3032. * @returns void
  3033. */
  3034. function _handleKeyEvent(e) {
  3035. // 为正常化的关键事件e.which
  3036. if (typeof e.which !== 'number') {
  3037. e.which = e.keyCode;
  3038. }
  3039. var character = U.K._characterFromEvent(e);
  3040. //没有字符发现后停止
  3041. if (!character) {
  3042. return;
  3043. }
  3044. //需要使用===用于字符检查,因为该字符可以是0
  3045. if (e.type == 'keyup' && _ignoreNextKeyup === character) {
  3046. _ignoreNextKeyup = false;
  3047. return;
  3048. }
  3049. self.handleKey(character, U.K._eventModifiers(e), e);
  3050. }
  3051. /**
  3052. * 称为设置1秒超时指定的顺序
  3053. *
  3054. *这是为了让序列中的每个按键后,你长为1秒
  3055. *按下一个键,你必须重新开始之前
  3056. *
  3057. * @returns void
  3058. */
  3059. function _resetSequenceTimer() {
  3060. clearTimeout(_resetTimer);
  3061. _resetTimer = setTimeout(_resetSequences, 1000);
  3062. }
  3063. /**
  3064. * 绑定一个键序列事件
  3065. *
  3066. * @param {string} combo - combo specified in bind call
  3067. * @param {Array} keys
  3068. * @param {Function} callback
  3069. * @param {string=} action
  3070. * @returns void
  3071. */
  3072. function _bindSequence(combo, keys, callback, action) {
  3073. // 通过增加一个序列水平记录这个组合开始
  3074. // 和level设定为0
  3075. _sequenceLevels[combo] = 0;
  3076. /**
  3077. * *回调,以增加该序列的序列水平和复位
  3078. * 处于活动状态的所有其他序列
  3079. *
  3080. * @param {string} nextAction
  3081. * @returns {Function}
  3082. */
  3083. function _increaseSequence(nextAction) {
  3084. return function () {
  3085. _nextExpectedAction = nextAction;
  3086. ++_sequenceLevels[combo];
  3087. _resetSequenceTimer();
  3088. };
  3089. }
  3090. /**
  3091. * 包装指定的回调另一个函数内,以便
  3092. *尽快此序列完成后重置所有序列计数器
  3093. *
  3094. * @param {Event} e
  3095. * @returns void
  3096. */
  3097. function _callbackAndReset(e) {
  3098. _fireCallback(callback, e, combo);
  3099. //我们应该忽略下一个关键了,如果动作键不放
  3100. //或按键。这是如此,如果你完成一个序列
  3101. //松开按键的最后一个关键不会触发KEYUP
  3102. if (action !== 'keyup') {
  3103. _ignoreNextKeyup = U.K._characterFromEvent(e);
  3104. }
  3105. //怪异的竞争条件,如果一个序列与该键结束
  3106. //另一序列始于
  3107. setTimeout(_resetSequences, 10);
  3108. }
  3109. //通过按键一次,并结合适当的回调循环
  3110. //功能。任何关键领导到最后,就应
  3111. //增加的顺序。决赛之后,应该重置所有序列
  3112. //
  3113. //如果在原来的绑定调用指定的操作那么就会
  3114. //在整个使用。否则,我们将通过动作的
  3115. //下一个关键应该匹配。这允许顺序
  3116. //混搭按键和KEYDOWN事件,这取决于
  3117. //的是更好地适合于提供的密钥
  3118. for (var i = 0; i < keys.length; ++i) {
  3119. var isFinal = i + 1 === keys.length;
  3120. var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || U.K._getKeyInfo(keys[i + 1]).action);
  3121. _bindSingle(keys[i], wrappedCallback, action, combo, i);
  3122. }
  3123. }
  3124. /**
  3125. * 绑定一个键盘组合
  3126. *
  3127. * @param {string} combination
  3128. * @param {Function} callback
  3129. * @param {string=} action
  3130. * @param {string=} sequenceName - name of sequence if part of sequence
  3131. * @param {number=} level - what part of the sequence the command is
  3132. * @returns void
  3133. */
  3134. function _bindSingle(combination, callback, action, sequenceName, level) {
  3135. // //存储与Mousetrap.trigger使用直接映射参考
  3136. self._directMap[combination + ':' + action] = callback;
  3137. // 使连续务必多个空格成为一个空格
  3138. combination = combination.replace(/\s+/g, ' ');
  3139. var sequence = combination.split(' ');
  3140. var info;
  3141. //如果该模式是键的序列然后通过此方法运行
  3142. //重新处理每个模式一键在同一时间
  3143. if (sequence.length > 1) {
  3144. _bindSequence(combination, sequence, callback, action);
  3145. return;
  3146. }
  3147. info = U.K._getKeyInfo(combination, action);
  3148. //确保初始化数组,如果这是第一次
  3149. //回调增加了对这一关键
  3150. self._callbacks[info.key] = self._callbacks[info.key] || [];
  3151. //删除现有的比赛,如果有一个
  3152. _getMatches(info.key, info.modifiers, { type: info.action }, sequenceName, combination, level);
  3153. //后面添加此调用数组
  3154. //如果它是一个序列把它在开始时
  3155. //如果不把它在最后
  3156. //
  3157. //这是重要的,因为这些方式处理预期
  3158. //序列的人是第一位的
  3159. self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({
  3160. callback: callback,
  3161. modifiers: info.modifiers,
  3162. action: info.action,
  3163. seq: sequenceName,
  3164. level: level,
  3165. combo: combination
  3166. });
  3167. }
  3168. /**
  3169. * 结合多种组合到同一个回调
  3170. *
  3171. * @param {Array} combinations
  3172. * @param {Function} callback
  3173. * @param {string|undefined} action
  3174. * @returns void
  3175. */
  3176. self._bindMultiple = function (combinations, callback, action) {
  3177. for (var i = 0; i < combinations.length; ++i) {
  3178. _bindSingle(combinations[i], callback, action);
  3179. }
  3180. };
  3181. // start!
  3182. U.M.AddEvent(targetElement, 'keypress', _handleKeyEvent);
  3183. U.M.AddEvent(targetElement, 'keydown', _handleKeyEvent);
  3184. U.M.AddEvent(targetElement, 'keyup', _handleKeyEvent);
  3185. }
  3186. U.K.Mousetrap = function () { };
  3187. /**
  3188. * / **
  3189. *绑定的事件捕鼠器
  3190. *
  3191. *可以是单一的键,以+分离键的组合,
  3192. *键的阵列,或由空格分隔键序列
  3193. *
  3194. *请务必先列出的组合键,以确保
  3195. *正确的密钥最终得到的约束(在模式的最后一个键)
  3196. *
  3197. * @param {string|Array} keys
  3198. * @param {Function} callback
  3199. * @param {string=} action - 'keypress', 'keydown', or 'keyup'
  3200. * @returns void
  3201. */
  3202. U.K.Mousetrap.prototype.bind = function (keys, callback, action) {
  3203. var self = this;
  3204. keys = keys instanceof Array ? keys : [keys];
  3205. self._bindMultiple.call(self, keys, callback, action);
  3206. return self;
  3207. };
  3208. /**
  3209. **
  3210. *解除绑定的事件捕鼠器
  3211. *
  3212. *在解除绑定设置指定组合键的回调函数
  3213. *到一个空的功能,并在删除相应的键
  3214. * _directMap字典。
  3215. *
  3216. * TODO:其实从_callbacks词典中删除这个代替
  3217. 结合一个空函数*
  3218. *
  3219. *在keycombo +操作必须是完全一样
  3220. *它在绑定方法定义
  3221. *
  3222. * @param {string|Array} keys
  3223. * @param {string} action
  3224. * @returns void
  3225. */
  3226. U.K.Mousetrap.prototype.unbind = function (keys, action) {
  3227. var self = this;
  3228. return self.bind.call(self, keys, function () { }, action);
  3229. };
  3230. /**
  3231. * *触发器已被绑定的事件
  3232. *
  3233. * @param {string} keys
  3234. * @param {string=} action
  3235. * @returns void
  3236. */
  3237. U.K.Mousetrap.prototype.trigger = function (keys, action) {
  3238. var self = this;
  3239. if (self._directMap[keys + ':' + action]) {
  3240. self._directMap[keys + ':' + action]({}, keys);
  3241. }
  3242. return self;
  3243. };
  3244. /**
  3245. * *重置库恢复到初始状态。这是非常有用的
  3246. *如果您想清除出当前的键盘快捷键和绑定
  3247. *新的 - 例如,如果您切换到另一页
  3248. * @returns void
  3249. */
  3250. U.K.Mousetrap.prototype.reset = function () {
  3251. var self = this;
  3252. self._callbacks = {};
  3253. self._directMap = {};
  3254. return self;
  3255. };
  3256. /**
  3257. * *我们应该发射了回调之前停止该事件
  3258. *
  3259. * @param {Event} e
  3260. * @param {Element} element
  3261. * @return {boolean}
  3262. */
  3263. U.K.Mousetrap.prototype.stopCallback = function (e, element) {
  3264. var self = this;
  3265. // if the element has the class "mousetrap" then no need to stop
  3266. if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
  3267. return false;
  3268. }
  3269. if (U.K._getReverseMap(element, self.target)) {
  3270. return false;
  3271. }
  3272. // stop for input, select, and textarea
  3273. return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;
  3274. };
  3275. /**
  3276. * 公开暴露_handleKey,因此它可以通过扩展覆盖
  3277. */
  3278. U.K.Mousetrap.prototype.handleKey = function () {
  3279. var self = this;
  3280. return self._handleKey.apply(self, arguments);
  3281. };
  3282. /**
  3283. * 允许自定义键映射
  3284. */
  3285. U.K.Mousetrap.addKeycodes = function (object) {
  3286. for (var key in object) {
  3287. if (object.hasOwnProperty(key)) {
  3288. U.K._MAP[key] = object[key];
  3289. }
  3290. }
  3291. _REVERSE_MAP = null;
  3292. };
  3293. /**
  3294. * *初始化全球捕鼠器功能
  3295. *
  3296. *需要使用此方法来允许在全球捕鼠器职能工作
  3297. *现在的捕鼠器是一个构造函数。
  3298. */
  3299. U.K.Mousetrap.init = function () {
  3300. var documentMousetrap = Mousetrap(document);
  3301. for (var method in documentMousetrap) {
  3302. if (method.charAt(0) !== '_') {
  3303. Mousetrap[method] = (function (method) {
  3304. return function () {
  3305. return documentMousetrap[method].apply(documentMousetrap, arguments);
  3306. };
  3307. } (method));
  3308. }
  3309. }
  3310. };
  3311. //#endregion
  3312. //----------------------------------------此js用来做特殊效果,例如弹出窗体缓动效果,关闭窗体缓动效果等-----------------------------
  3313. Namespace.register("U.ME"); //js特效库
  3314. //----到时全部都要合在Extend里
  3315. //--------------------------------------------------------------------------动画区域---------------------------------------------------------------
  3316. //动画
  3317. U.ME.DH = function (UDOD, UTM, UTF, UDTD) {
  3318. if (UDOD) {
  3319. var i; //定义变量i
  3320. var _UDE = UTM ? setInterval(U.M.apply(UDOD, [[U.ME.DHGDAMXG, [UTF, 0]]]), UTM) : null; //动画效果
  3321. UDOD.onmouseout = UDOD.onmouseover = U.M.apply(UDOD, [[U.ME.DHGDAM, [arguments, _UDE]]]); //停止开始动画
  3322. if (UDTD) {//功能未知,变量没试用过 一直为空 不会进if
  3323. for (i = 0; i < UDTD.length; i++) {
  3324. (UDTD[i]) && (UDTD[i].onclick = U.M.apply(UDTD[i], [[U.ME.DHQH, [i, arguments, _UDE]]])); //上下页切换
  3325. };
  3326. };
  3327. }
  3328. }
  3329. //快速切换
  3330. U.ME.DHQH = function (ITF, UAE, UDE) {
  3331. clearInterval(UDE); //停止动画
  3332. U.ME.DHGDAMXG.apply(UAE[0], [UAE[2], ITF]); //切换效果展示
  3333. U.ME.DH.apply(window, UAE); //设置动画
  3334. }
  3335. //滚动动画开始停止
  3336. U.ME.DHGDAM = function (USC, UDE) {
  3337. if (!U.M.onmouseout(this)) { //取消动画
  3338. var _UTP = event.type; //获取事件类型
  3339. clearInterval(UDE); //关闭计时器
  3340. if (_UTP == "mouseout") {//鼠标离开的时候
  3341. U.ME.DH.apply(window, USC); //重新滚动
  3342. }
  3343. }
  3344. }
  3345. //动画效果
  3346. U.ME.DHGDAMXG = function (UTF, ITF) {
  3347. UTF = UTF == "L" ? "width" : "height"; //判断是不是L 是就改变宽度
  3348. var _UFT = ITF === 0, //判断是否存在计时器
  3349. _UDOD = $(this), //获取ul
  3350. _UDAD = _UDOD.Child(), //获取ul下面的子元素
  3351. _UDSD = _UDAD[_UFT ? 0 : _UDAD.length - 1],
  3352. _UWH = "client" + (UTF.charAt(0).toUpperCase() + UTF.substr(1)),
  3353. _UTP = [{ "overflow": "hidden" }, {}]; //设置样式
  3354. if (_UDSD[_UWH]) { //这里是判断是否是否符合变化
  3355. _UTP[0][UTF] = "0px"; _UTP[1][UTF] = _UDSD[_UWH] + "px"; //改变样式
  3356. (_UFT) && (_UTP.reverse());
  3357. $(_UDSD).addAttrArray({ "style": _UTP[0] }).animate(_UTP[1], 500, _UFT ? U.M.apply(null, [[U.M.apply(_UDOD, [[_UDOD.append, [_UDSD, 0]]])], [U.M.apply($(_UDSD), [[$(_UDSD).addAttrArray, [{ "style": _UTP[0]}]]])]]) : null); //执行动画?
  3358. (!_UFT) && (this.insertBefore(_UDSD, _UDAD[0])); //插入元素
  3359. }
  3360. }
  3361. //----------------------------------------------------------------------------切换图片------------------------------------------------------------
  3362. //切换图片效果
  3363. U.ME.YHT = function (UDOD, UDTD, UCL, ITF, UAT, ITM, UTF) {
  3364. if (UDOD) {//变量是否定义
  3365. var i, _UDCD = $(UDTD).Child(), //获取圆点的子元素
  3366. _UDE = [], //初始化
  3367. _UKE = [ITF || 0], //0?
  3368. _UTM = null; //计时器
  3369. if (ITM > 0) {
  3370. _UTM = setInterval(U.M.apply(null, [[U.ME.YHTXZ, [UDOD, UDTD, _UKE, UCL]]]), ITM || 1000); //开始计时器 并且赋值
  3371. } //图片选择
  3372. _UKE[1] = _UTM; //存储计时器?
  3373. if (!UTF) {//如果没值
  3374. U.ME.YHTXZ(UDOD, UDTD, _UKE, UCL);
  3375. } else if (_UKE[0] >= _UDCD.length) {//超过图片数量时
  3376. _UKE[0] = 0; //?换成第一张
  3377. };
  3378. UTF = null; //参数变化
  3379. UDOD.onmouseover = UDOD.onmouseout = U.M.apply(UDOD, [[U.M.StopBubble], [U.ME.YHTQX, [arguments, _UTM, _UKE]]]); //切换停止
  3380. for (i = 0; i < _UDCD.length; i++) {
  3381. _UDCD[i].onmouseover = _UDCD[i].onmouseout = U.M.apply(_UDCD[i], [[U.M.StopBubble], [U.ME.YHTQX, [arguments, _UTM, _UKE, i]]]); //切换查看
  3382. }
  3383. if (UAT) {//UAT 一直为0 不进入
  3384. for (i = 0; i < 2; i++) {
  3385. (UAT[i]) && (UAT[i].onclick = U.M.apply(UAT[i], [[U.ME.SXYHT, [(i - 1) * 2, _UKE, _UTM, arguments]]])); //上下页
  3386. }
  3387. }
  3388. return _UTM; //返回计时器
  3389. }
  3390. }
  3391. //计时器变化区域
  3392. U.ME.YHTXZ = function (UDOD, UDTD, UDE, UCL) {
  3393. var _UDAD = $(UDOD).Child();
  3394. if ((!UDOD || UDOD) == (document || !_UDAD)) {
  3395. clearInterval(UDE[1]); //移除
  3396. }
  3397. else {
  3398. U.ME.ZSYHTXZ(UDOD, UDTD, UDE, UCL);
  3399. UDE[0]++; (UDE[0] >= _UDAD.length) && (UDE[0] = 0); //变化切换
  3400. }
  3401. }
  3402. //上下张
  3403. U.ME.SXYHT = function (UTF, ITF, UTM, UCS) {
  3404. var _UDCD = $(UCS[0]).Child();
  3405. clearInterval(UTM); UCS[3] = (ITF[0] += UTF); //删除计时器
  3406. if (ITF[0] < 0) {
  3407. UCS[3] = _UDCD.length + UCS[3];
  3408. }
  3409. else if (ITF[0] >= _UDCD.length) {
  3410. UCS[3] = 0;
  3411. }
  3412. U.ME.YHT.apply(this, UCS); //上下张查看
  3413. }
  3414. //开始或者取消图片选择查看
  3415. U.ME.YHTQX = function (UCS, UTM, UKE, ITF) {
  3416. if (!U.M.onmouseout(this)) {//是否在图片上取消
  3417. var _UTP = event.type, //事件类型
  3418. i = UKE[0] - 1;
  3419. clearInterval(UTM); //关闭计时器
  3420. i = i < 0 ? $(UCS[0]).Child().length - 1 : i;
  3421. UCS[3] = UKE[0] = ITF != null ? ITF : UKE[0]; //清除计时器
  3422. if (_UTP == "mouseout") {//鼠标离开
  3423. UCS[3] = ITF != null ? ITF : i;
  3424. UCS = Array.prototype.slice.call(UCS);
  3425. UCS[6] = true; UCS[3]++;
  3426. U.ME.YHT.apply(this, UCS); //重启计时器
  3427. } //切换图片效果
  3428. else if ((ITF != null && (i != ITF))) {
  3429. U.ME.ZSYHTXZ(UCS[0], UCS[1], UKE, UCS[2]); //停止在该图片上
  3430. }
  3431. }
  3432. }
  3433. //图片展示
  3434. U.ME.ZSYHTXZ = function (UDOD, UDTD, UDE, UCL) {
  3435. var i, _UST,
  3436. _UDAD = $(UDOD).Child(), //获取图片子元素
  3437. _UDCD = UDTD ? $(UDTD).Child() : null;
  3438. for (i = 0; i < _UDAD.length; i++) {//切换样式
  3439. $(_UDAD).addAttrArray({ "style": i == UDE[0] ? { "filter": "alpha(opacity=0)", "-moz-opacity": "0", "opacity": "0", "display": "block"} : { "display": "none"} }, i); //图片切换样式
  3440. if (UDTD) {//如果有圆点
  3441. _UST = _UDCD[i].className; //class
  3442. _UDCD[i].className = _UST.replace(" " + UCL, "").replace(UCL, "") + (i == UDE[0] ? ((_UST ? " " : "") + UCL) : ""); //按钮样式
  3443. }
  3444. }
  3445. $(_UDAD[UDE[0]]).animate({ "-moz-opacity": "1", "opacity": "1", "filter": "alpha(opacity=100)" }, 500); //透明度动画?
  3446. }
  3447. //图片轮播:通过滚动调轮播图片
  3448. U.ME.LBTP = function (UDE) {
  3449. var _UIE = UDE.i || 0,
  3450. _UDOD = $(UDE.e),
  3451. UDAD = _UDOD.Child(); //子元素
  3452. if (UDAD.length && UDE["s"]) {
  3453. $(UDAD[_UIE]).addAttrArray(UDE["s"]); //默认点
  3454. U.Ut.AddObj(UDE, { a: UDAD, i: UDE.i || 0, p: UDE.p || _UDOD.Parent(), w: UDE.w || 1 });
  3455. return new U.ME.LBTPF(UDE);
  3456. }
  3457. }
  3458. //开始轮播效果
  3459. U.ME.LBTPF = function (UDE) {
  3460. U.Ut.AddObj(this, UDE);
  3461. this.init();
  3462. $(UDE.a).bind("click", U.M.apply(this, this.click));
  3463. }
  3464. //轮播使用
  3465. U.ME.LBTPF.prototype = {
  3466. init: function () {//初始化
  3467. (this.UTI) && (clearInterval(this.UTI)); //清除原有的计时器
  3468. this.UTI = setInterval(U.M.apply(this, this.time), this.t || 5000); //计时开始
  3469. },
  3470. click: function (UIE) {//点击使用
  3471. var _UDOD, _UDPD,
  3472. _UIE = (UIE != null && !isNaN(Number(UIE))); //判断是否不为空
  3473. if (_UIE) {
  3474. _UIE = this.i + UIE;
  3475. } else {
  3476. _UDOD = event.srcElement; //获取时间对象
  3477. while (_UDOD && (_UDPD = _UDOD.parentNode) != this.e) {
  3478. _UDOD = _UDPD;
  3479. }
  3480. _UIE = this.a.indexOf(_UDOD); //判断是否是数组
  3481. }
  3482. if (_UIE != -1 && _UIE != null) { this.time(_UIE); this.init(); }
  3483. },
  3484. time: function (UIE) {//轮换
  3485. if (this.a[0] && this.a[0].parentNode == this.e) {
  3486. var i, _ULT, _UAE, _UDOD,
  3487. _UDPD = this.p,
  3488. _UDAD = this.a,
  3489. _UL = _UDAD.length,
  3490. _UIE = this.i;
  3491. if (UIE == null) {
  3492. this.i += this.w;
  3493. if (_UIE == _UL - 1) {
  3494. this.w = -1; this.i = _UL - 2;
  3495. } else if (!_UIE) {
  3496. this.i = this.w = 1;
  3497. }
  3498. } else {
  3499. this.i = UIE;
  3500. }
  3501. $(_UDAD[_UIE]).addAttrArray(this.h);
  3502. $((_UDOD = _UDAD[this.i])).addAttrArray(this.s); //添加或者删除
  3503. if (this.af) {
  3504. this.af(this);
  3505. }
  3506. else {
  3507. _UAE = [_UDPD.scrollLeft, _UDPD.offsetWidth, _UDOD.offsetLeft - this.e.offsetLeft, _UDOD.offsetWidth];
  3508. if (_UAE[0] + _UAE[1] < _UAE[2]) {
  3509. _ULT = _UAE[2] + _UAE[3] * 2 - _UAE[1];
  3510. } else if (_UAE[2] < _UAE[0]) {
  3511. _ULT = _UAE[2] - _UAE[3] * 2;
  3512. }
  3513. (_ULT != null) && ($(_UDPD).animate({ "scrollLeft": _ULT }, 100));
  3514. };
  3515. (this.cb) && (this.cb());
  3516. }
  3517. else {
  3518. clearInterval(this.UTI);
  3519. } //取消
  3520. }
  3521. }
  3522. /*函数使用方法
  3523. 函数:U.ME.DH(obj, speed, direction)
  3524. 参数一 obj : <ul>标签对象
  3525. 参数二 speed : 速度 单位为毫秒
  3526. 参数三 direction : 图片滑动的方向 “T”,”B”,”L”,”R”分别为上下左右
  3527. 实例 :
  3528. <html>
  3529. <head>
  3530. <meta charset="UTF-8" />
  3531. <script type="text/javascript" src="/uform.js"></script>
  3532. <style>
  3533. li{list-style-type:none;}
  3534. #UJ_Banner_ul{}
  3535. #UJ_Banner_ul li{ height:100px;width:100px;margin:0 10;font-size:50px;float:left;border:1px #000 solid;}
  3536. </style>
  3537. <script type="text/javascript" >
  3538. window.onload = function(){
  3539. U.ME.DH($("#UJ_Banner_ul")[0], 1000, "L");
  3540. }
  3541. </script>
  3542. </head>
  3543. <body>
  3544. <ul id="UJ_Banner_ul">
  3545. <li>1</li>
  3546. <li>2</li>
  3547. <li>3</li>
  3548. <li>4</li>
  3549. <li>5</li>
  3550. </ul>
  3551. </body>
  3552. </html>
  3553. 函数: U.ME.YHT(obj, point, pointclass,0,button,speed)
  3554. 参数一 obj : <ul>标签对象
  3555. 参数二 point: 圆点动画 没有可不传
  3556. 参数三 pointclass: 圆点执行样式,没有可不传
  3557. 参数四 0 : 功能未知
  3558. 参数五 button : 左右点击的按钮 是数组形式的 没有可不传
  3559. 参数六 speed : 速度
  3560. 实例 :
  3561. <html>
  3562. <head>
  3563. <meta charset="UTF-8" />
  3564. <script type="text/javascript" src="/uform.js"></script>
  3565. <style>
  3566. li{list-style-type:none;}
  3567. #UJ_Banner_ul{height:100px;}
  3568. #UJ_Banner_ul li{ height:100px;width:100px;margin:0 10;font-size:50px;float:left;border:1px #000 solid;}
  3569. #UJ_Banner_L{width:20px;height:20px;border:1px #000 solid;display:inline-block;}
  3570. #UJ_Banner_R{width:20px;height:20px;border:1px #000 solid;display:inline-block;}
  3571. #fround div{height:20px; width:20px;display:inline-block;border:1px #000 solid;border-radius:50%;}
  3572. .red{background:red;}
  3573. </style>
  3574. <script type="text/javascript" >
  3575. window.onload = function(){
  3576. U.ME.YHT($("#UJ_Banner_ul")[0], $("#fround")[0], 'red', 0, [$("#UJ_Banner_L")[0], $("#UJ_Banner_R")[0]], 1000);
  3577. }
  3578. </script>
  3579. </head>
  3580. <body>
  3581. <ul id="UJ_Banner_ul">
  3582. <li>1</li>
  3583. <li>2</li>
  3584. <li>3</li>
  3585. <li>4</li>
  3586. <li>5</li>
  3587. </ul>
  3588. <div id="UJ_Banner_L">左Á¨®</div>
  3589. <div id="UJ_Banner_R">右®¨°</div>
  3590. <div id="fround">
  3591. <div class="red"></div>
  3592. <div ></div>
  3593. <div ></div>
  3594. <div ></div>
  3595. <div ></div>
  3596. </div>
  3597. </html>
  3598. */
  3599. //#region 桌面消息区域
  3600. //w3c 消息区域 还在草案中
  3601. Namespace.register("U.MN");
  3602. U.MN.nif = window.notificationInstance; //消息总控
  3603. //#region
  3604. if (window.webkitNotifications) {
  3605. //消息使用
  3606. U.MN._UPS = window.webkitNotifications;
  3607. //函数初始化使用
  3608. U.M.HEPropert(U.MN._UPS, "onshow", function () {
  3609. return this.ondisplay;
  3610. },
  3611. function (UVE) { this.ondisplay = UVE; });
  3612. U.MN.UFN = function (UMT, UDE) {
  3613. var _UCE = U.MN._UPS.createNotification(UDE.icon, UMT, UDE.body);
  3614. _UCE.show(); return _UCE;
  3615. }
  3616. //继承消息
  3617. U.MN.UFN.prototype = window.webkitNotifications;
  3618. U.M.Setprototype(U.MN.UFN, {
  3619. requestPermission: function (UCB) { U.MN._UPS.requestPermission(UCB); },
  3620. permission: function () {
  3621. return { 0: "granted", 1: "denied", 2: "default"}[U.MN._UPS.checkPermission()];
  3622. },
  3623. close: function () { this.cancel(); }
  3624. });
  3625. }
  3626. //消息初始化
  3627. U.MN.Notis = window.Notification = window.Notification || window.webkitNotifications;
  3628. //#endregion
  3629. //#region
  3630. //添加消息提示
  3631. U.MN.Noti = function (UDE) {
  3632. return U.MN.Noti.get(UDE);
  3633. }
  3634. //初始化
  3635. U.MN.Noti.get = function (UDE) {
  3636. var _UDE = U.MN.Notis;
  3637. if (_UDE) {
  3638. if (_UDE.permission == "granted") {
  3639. if (UDE) {
  3640. return new U.MN.Noti.init(UDE);
  3641. }
  3642. } //初始化消息
  3643. if (_UDE.permissi0on != "denied") {
  3644. _UDE.requestPermission(function (UTF) {
  3645. if (UTF == "granted") { U.MN.Noti.get(UDE); }
  3646. });
  3647. } //消息
  3648. }
  3649. }
  3650. //初始化消息
  3651. U.MN.Noti.init = function (UDE) {
  3652. this.UNM; this.UT = UDE; this.UE = UDE.e; this.time = UDE.t || 0;
  3653. }
  3654. U.MN.Noti.checkPermission = function () {
  3655. }
  3656. //显示所有消息
  3657. U.MN.Noti.show = function () {
  3658. try { U.MN.nif.show() }
  3659. catch (e) { return e; }
  3660. }
  3661. //清除消息
  3662. U.MN.Noti.cancel = function () {
  3663. try { U.MN.nif.cancel() }
  3664. catch (e) { return e; }
  3665. }
  3666. //消息功能区域
  3667. U.MN.Noti.init.prototype = {
  3668. create: function (UMT, UDE, USE) { //创建消息 body dir icon lang onlcick onclose onerrer onshow slient tag title data noscreen renotify sound vibrate
  3669. var _UME, _UME, _UTF = UDE == "string", Noti = U.MN.Notis; this.UE = USE = USE ? USE : this.UE;
  3670. if (Noti.permission == "granted") {
  3671. _UME = this.UNM = new Noti(UMT, UDE);
  3672. (USE) && (this.event(USE)); (this.time) && (this.timerc(this.time));
  3673. } //允许消息传递
  3674. else if (Noti.permission != "denied") { Noti.requestPermission(U.M.apply(this, [[this.Permission, [UMT, UDE]]])); } //认证允许
  3675. else { U.Alert("请启动消息推送!"); }
  3676. },
  3677. Permission: function (UMT, UDE, UTF) {//认证成功后
  3678. if (UTF == "granted") { this.create(UMT, UDE); }
  3679. },
  3680. set: function (UDE) { //消息设置
  3681. U.Ut.AddObj(this.UNM, UDE);
  3682. },
  3683. bind: function (UDE, UAE) { //事件绑定
  3684. $(this.UNM).bind(UDE, UAE);
  3685. },
  3686. unbind: function () {//取消事件绑定
  3687. $(this.UNM).unbind(UDE, UAE);
  3688. },
  3689. event: function (UDE) { //初始化消息
  3690. var i, _UND = this.UNM, _UDE = { oc: "onclick", ocl: "onclose", oe: "onerror", os: "onshow" };
  3691. for (i in UDE) { _UND[i] = _UND[_UDE[i]] = U.M.apply(this, [[this.aevent, [i, _UDE[i]]]]); }
  3692. },
  3693. aevent: function (UTF, UTP) {//事件统一出口
  3694. var _UDE = this.UE;
  3695. if (_UDE && _UDE[UTF]) {
  3696. if (U.Ut.isFunction(_UDE[UTF])) {
  3697. _UDE[UTF]();
  3698. }
  3699. else { U.M.apply(this, _UDE[UTF])(); }
  3700. if (UTF == "oc" || UTF == "onclick") {//执行函数
  3701. this.close();
  3702. }
  3703. }
  3704. },
  3705. close: function () {//关闭
  3706. if (this.UNM) {
  3707. this.UNM.close();
  3708. this.dispose();
  3709. }
  3710. },
  3711. dispose: function () { this.UT = this.UE = this.UNM = null; },
  3712. timerc: function (UT, UFE) { //指定事件关闭消息
  3713. setTimeout(U.M.apply(this, [[UFE], [this.close]]), UT);
  3714. },
  3715. show: function () { U.MN.show(); },
  3716. cancel: function () { U.MN.cancel(); }
  3717. }
  3718. //#endregion
  3719. //#region
  3720. //IFrame之间的消息通知。全兼容解决方案,太复杂,需要精简版本。
  3721. // 页面消息传递,解决跨域问题。
  3722. U.MN.message = function (UDE) {
  3723. return new U.MN.message.get.init(UDE);
  3724. }
  3725. U.MN.message._UTF = ("onmessage" in window);
  3726. U.MN.message._UFS = function (UDE) {
  3727. try {
  3728. var _UME, _USE = "";
  3729. if (U.MN.message._UTF) { _USE = UDE.data; }
  3730. else { _USE = UDE || window.name; } //设置
  3731. _USE = _USE.parseJSON();
  3732. _UME = U.MN.message.get.func[_USE[1]];
  3733. (_UME) && (_UME.message[_USE[0], _USE[2], _USE[3]]);
  3734. } catch (e) { }
  3735. };
  3736. if (U.MN.message._UTF) {
  3737. U.M.AddEvent("message", window, U.MN.message._UFS);
  3738. }
  3739. U.MN.message.get = U.MN.message.prototype = {
  3740. func: {},
  3741. ZS: 1,
  3742. init: function (UDE) { //初始化消息
  3743. U.Ut.AddObj(this, UDE);
  3744. this.id = this.id || Guid.guidNoDash();
  3745. this.func[this.id] = this;
  3746. if (!U.MN.message._UTF) {
  3747. if (this.Sender) {
  3748. var _USE = this.obj;
  3749. (U.Ut.isString(_USE)) && (_USE = $(_USE)[0]);
  3750. this.url = U.M.getUrl(_USE.src).host;
  3751. this.obj = $$("iframe", { style: { display: "none" }, width: "0", height: "0" }, document.body);
  3752. }
  3753. else { $().ready(U.M.apply(this, U.MN.message._UFS)); }
  3754. }
  3755. },
  3756. message: function (UDE) {//接收消息
  3757. (U.Ut.isFunction(this.me)) && (this.me(UDE));
  3758. if (this.Sender && !U.MN.message._UTF) {
  3759. var _UD = this.obj.contentWindow.document;
  3760. _UD.open();
  3761. _UD.write("");
  3762. _UD.close();
  3763. $(this.obj).remove();
  3764. } //释放
  3765. },
  3766. post: function (UDE, UDID, UCE) {//提交消息
  3767. var _UKE, _USE = this.obj;
  3768. UDE = U.MS.jsonToStr[UDE, UDID || "", this.id, UCE];
  3769. (U.Ut.isString(_USE)) && (_USE = $(_USE)[0]);
  3770. if (U.MN.message._UTF) {
  3771. try { _USE = _USE.contentWindow || _USE; }
  3772. catch (e) { _USE = this.obj; } _USE.postMessage(UDE, "*");
  3773. }
  3774. else {
  3775. if (this.url) {
  3776. _USE.src = "about:blank";
  3777. U.MD.IframeLoad(_USE, [[U.M.apply(this, [[this.ie, [_USE, UDE]]])]]);
  3778. }
  3779. else { window.name = UDE; window.location = this.lurl; }
  3780. } //消息提示
  3781. },
  3782. ie: function (USE, UDE) { USE.contentWindow.name = UDE; USE.contentWindow.location.href = this.url; }
  3783. }
  3784. U.MN.message.get.init.prototype = U.MN.message.get;
  3785. U.MN.message.cb = U.MN.message._UFS;
  3786. //#endregion
  3787. Namespace.register("U.PL");
  3788. //#region 变量处理
  3789. U.PL._er = {};
  3790. U.PL._ev = ["loadstart", "ended", "progress", "suspend", "abort", "error", "stalled", "play", "pause", "loadedmetadata", "loadeddata", "waiting", "playing", "canplay", "readystatechange", "canplaythrough", "seeking", "seeked", "timeupdate", "ended", "ratechange", "durationchange", "volumechange"]; //vedio所有的事件
  3791. //#endregoin
  3792. //视频初始化
  3793. U.PL.vi = function (UDE, UDPD, UCE) {
  3794. if ($$("video").canPlayType) {
  3795. return new U.PL.vi.init(UDE, UDPD, UCE);
  3796. }
  3797. else { return false; }
  3798. }
  3799. //初始化视屏播放器
  3800. U.PL.vi.init = function (UDE, UDPD, UCE) {
  3801. this.obj = UDE || {}; //
  3802. this.pa = UDPD; //
  3803. this.vi = null; //
  3804. this.config(UCE);
  3805. return this;
  3806. }
  3807. U.PL.vi.init.prototype = {
  3808. type: { "ogg": 'video/ogg; codecs="theora, vorbis"', "mp4": 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', "webm": 'audio/webm; codecs="vorbis"' },
  3809. attr: { at: "audioTracks", ap: "autoPlay", bf: "buffered", cl: "controller", cr: "controls", co: "crossOrigin", cs: "currentSrc", cTime: "currentTime", dm: "defaultMuted", dp: "defaultPlaybackRate", dt: "duration", ed: "ended", er: "error", lt: "initialTime", lp: "loop", mg: "mediaGroup", mt: "muted", ns: "networkState", pe: "paused", pr: "playbackRate", sTime: "startTime", pr: "playbackRate", py: "played", pl: "preload", rd: "readyState", si: "seeking", sk: "seekable", st: "startOffsetTime", tt: "textTracks", vt: "videoTracks", vl: "volume" }, // video属性
  3810. config: function (UDE) { //配置文件
  3811. U.Ut.AddObj((this.cf = this.cf || {}), UDE); U.Ut.AddObj(this.cf, { l: this.cf.l || 0, urls: this.cf.urls || [] }); //配置视频
  3812. },
  3813. init: function (UDE, UDPD, UCE) { //初始化视屏播放器
  3814. U.Ut.AddObj(this, { obj: UDE || {}, pa: UDPD, vi: null }); this.config(UCE); return this;
  3815. },
  3816. create: function (URL, UDPD) { //src poster preload autoplay loop controls width height viode属性
  3817. var _UCE = this.cf, _UVE = _UCE.html || { "style": { "cssText": "margin:auto;display:block;height:100%;width:auto;" }, "autoplay": "autoplay", "controls": "controls", "accesskey": true, "poster": "" };
  3818. if ((URL = ((this.cf.urls.push(URL), URL) || this.cf.urls[this.l]))) {
  3819. if (!this.vi) { this.vi = $$("video", _UVE, UDPD || this.pa || document.body); this.event(); } if (!U.Ut.isString(URL) && this.vi.srcObject) { this.vi.srcObject = URL } else { this.vi.src = U.Ut.isString(URL) ? URL : (window.URL || window.webkitURL).createObjectURL(URL); } this.set(this.obj); //if (this.isPaly(U.UP.GetUpName(URL)[1])) { };
  3820. }
  3821. else { U.Alert("链接无效"); }
  3822. return this;
  3823. },
  3824. load: function (URL) { //重新加载
  3825. URL = URL || this.cf.urls[this.cf.l]; if (this.vi) { this.vi.url = URL; } else { this.create(); }
  3826. },
  3827. event: function () { //事件监听
  3828. var i, _UDOD = this.vi; //监听所有的事件
  3829. if (U.PL._ev) { for (i = 0; i < U.PL._ev.length; i++) { U.M.AddEvent(U.PL._ev[i], _UDOD, U.M.apply(this, [[this.cb, [U.PL._ev[i]]]])); } }
  3830. },
  3831. cb: function (UTP) { //所有事件监听回调
  3832. (this.cf[UTP]) && (this.cf[UTP])(); //回调函数
  3833. return true;
  3834. },
  3835. getType: function (UTF) { //获取属性
  3836. return this.vi[this.attr[UTF] || UTF];
  3837. },
  3838. set: function (UTP, UV) { //设置值
  3839. var i, _UAE = this.attr, _USE = UTP; (U.Ut.isString(UTP)) && (_USE = {}, _USE[UTP] = UV);
  3840. for (i in _USE) { this.vi[(_UAE[i] || i)] = _USE[i]; }
  3841. },
  3842. exec: function (UTF) { //执行获取
  3843. return this[UTF] ? this[UTF]() : this.vi[UTF];
  3844. },
  3845. next: function () { //上一片
  3846. var _URL; this.cf.l = this.cf.l - 1 < 0 ? this.cf.urls.length - 1 : this.cf.l - 1; if ((_URL = this.cf.urls[this.cf.l])) { this.load(_URL); }
  3847. },
  3848. lower: function () { //下一篇片
  3849. var _URL; this.cf.l = this.cf.l + 1 >= this.cf.urls.length ? 0 : this.cf.l - 1; if ((_URL = this.cf.urls[this.cf.l])) { this.load(_URL); }
  3850. },
  3851. isPlay: function (UTF, UDOD) { //判断是否允许播放该格式
  3852. return (UDOD || this.vi).canPlayType(this.type[UTF.toLowerCase()]);
  3853. },
  3854. play: function (UTF) { //播放和暂停
  3855. this.vi[UTF ? "play" : "pause"]();
  3856. },
  3857. backRate: function (UVE) { //播放速度
  3858. this.vi.playbackRate = UVE;
  3859. },
  3860. error: function (UE) { //发生错误
  3861. var _UDE = ["", "网络异常", "解码失败", "URL无效"];
  3862. (!UE.code) && (U.Alert(_UDE[UE.code]));
  3863. },
  3864. fullScreen: function () {//视频全屏
  3865. var _funcname = U.M.GetFullSreeenName("requestFullScreen"); //全屏函数名
  3866. if (_funcname != null)
  3867. this.vi[_funcname](); //执行全屏函数
  3868. },
  3869. fullScreen: function () {//取消视频全屏
  3870. U.M.cancelfullScreen();
  3871. }
  3872. }