123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284 |
-
- //判断是否为函数
- U.MS.IsYX = function (UCB) {
- if (this == null) { throw new Error("this is null or not defined"); } //不允许为空
- else if ({}.toString.call(UCB) != "[object Function]") { throw new Error(UCB + " is not a function"); } //没有回调不成立
- else { return true; }; return false;
- }
- //下一个节点
- U.M.nextSibling = function (obj) {
- while (obj.nextSibling.nodeType != 1) {
- obj = obj.nextSibling;
- }
- return obj.nextSibling;
- }
- //前一个节点
- U.M.previousSibling = function (obj) {
- while (obj.previousSibling.nodeType != 1) {
- obj = obj.previousSibling;
- }
- return obj.previousSibling;
- }
- //Error具有下面一些主要属性:
- //description: 错误描述 (仅IE可用).
- //fileName: 出错的文件名 (仅Mozilla可用).
- //lineNumber: 出错的行数 (仅Mozilla可用).
- //message: 错误信息 (在IE下同description)
- //name: 错误类型.
- //number: 错误代码 (仅IE可用).
- //stack: 像Java中的Stack Trace一样的错误堆栈信息 (仅Mozilla可用).
- //--------------------------------------统一try cache---------------------------------
- U.MC.TC = {}; //保存前台错误的集合,暂时显示在前台,以后存入后台
- U.MC.TCatch = function (f) {
- try { (typeof (f) == "string") ? eval(f) : f; }
- catch (e) { Add(U.MC.TC, { "类型": e.name, "错误信息": e.message, "时间": U.MT.formatDateToArray(new Date()) }); }
- }
- //兼容SetCapture函数
- U.M.SetCapture = function (obj) {
- return document.all ? obj.setCapture() : window.captureEvents(Event.MOUSEMOVE);
- }
- //兼容releaseCapture函数
- U.M.releaseCapture = function (obj) {
- document.all ? obj.releaseCapture() : window.releaseEvents(Event.MOUSEUP);
- }
- //兼容加载事件与脚本 func为函数
- U.M.LoadEvent = function (func) {
- var oldonload = window.onload;
- //判断对象是否为一个事件,是则直接执行
- if (typeof window.onload != 'function') {
- window.onload = func;
- }
- else {
- window.onload = function () {
- oldonload();
- func();
- }
- }
- }
- //函数功能:获取键盘码,兼容Onkeydown事件
- U.M.getKeyCode = function (e) {
- e = e || window.event;
- keynum = e.keyCode ? e.keyCode : e.which;
- return keynum;
- }
- //事件代理机制,避免频繁添加事件操作。浪费代码,加大复杂度。
- U.M.GetEventTarget = function (e) {//判断浏览器类型以兼容事件
- e = e || window.event;
- return e.target || e.srcElement;
- }
- //Click()事件调用兼容
- U.M.invokeClick = function (element) {
- if (element.click) element.click(); //判断是否支持click() 事件
- else if (element.fireEvent) element.fireEvent('onclick'); //触发click() 事件
- else if (document.createEvent) {
- var evt = document.createEvent("MouseEvents"); //创建click() 事件
- evt.initEvent("click", true, true); //初始化click() 事件
- element.dispatchEvent(evt); //分发click() 事件
- }
- }
- //dblClick()事件调用兼容
- U.M.dblClick = function (element) {
- if (element.ondblclick) element.ondblclick(); //判断是否支持dblClick() 事件
- else if (element.fireEvent) element.fireEvent('ondblclick'); //触发dblClick() 事件
- else if (document.createEvent) {
- var evt = document.createEvent("MouseEvents"); //创建ondblclick() 事件
- evt.initEvent("dblclick", true, true); //初始化ondblclick() 事件
- element.dispatchEvent(evt); //分发ondblclick() 事件
- }
- }
- //------------------------------------------------------------------监听事件注册和取消区域---------------------------------------------------------------
- //注意:只有被addEventListener方法添加的事件才可以使用removeEventListener来注销.
- //如果你直接使用onclick或onkeyup直接写在元素内的事件.将无法使用removeEventListener来删除.
- U.M.removeEvent = function (oTarget, sEventType, funName) {
- if (oTarget.removeEventListener) {//for DOM;
- oTarget.removeEventListener(sEventType, funName, false);
- } else if (oTarget.detachEvent) {
- oTarget.detachEvent("on" + sEventType, funName);
- } else {
- oTarget["on" + sEventType] = null;
- }
- }
- //函数作用:为元素添加事件
- //oTarget:元素对象;sEventType:事件类型,例如点击则为click;funName:事件触发的函数名;
- U.AFB.AddEvent = function (oTarget, sEventType, funName) {
- if (oTarget.addEventListener) {//Dom浏览器触发
- oTarget.addEventListener(sEventType, funName, false);
- } else if (oTarget.attachEvent) { //IE
- oTarget.attachEvent("on" + sEventType, funName);
- } else {
- oTarget["on" + sEventType] = funName;
- }
- }
- //屏蔽错误
- U.M.killErrors = function (sMsg, sUrl, sLine) {
- //onerror函数的三个参数用于确定错误确切的信息,代表的意思依次为:错误信息;发生错误的文件;发生错误的行号。
- // var oErrorLog = document.createElement("div");
- // oErrorLog.innerHTML = "<b>An error was thrown and caught.</b><p>";
- // oErrorLog.innerHTML += "Error: " + sMsg + "<br>";
- // oErrorLog.innerHTML += "Line: " + sLine + "<br>";
- // oErrorLog.innerHTML += "URL: " + sUrl + "<br>";
- return true;
- }
- //屏蔽按键操作。
- U.M.forbiddenKey = function () {
- if (event.keyCode == 116) { event.keyCode = 0; event.returnValue = false; } //屏蔽f5刷新
- }
- //屏蔽div右键
- U.M.ForbiddenDivRightMouseClick = function (obj) {
- obj.oncontextmenu = function () { return false; }
- }
- //规范插入的图片大小--杨嘉城
- U.M.norm_img = function (SO) {
- var _ISO = $("img", SO);
- for (var i = 0; i < _ISO.length; i++) {
- if (_ISO[i].clientWidth >= 1024) { _ISO[i].width = "900px"; }
- }
- }
- //设置字体
- U.M.setuserbackgroundfont = function (obj) {
- if (obj != null) {
- var allelments = parent.document.getElementsByTagName('*');
- var i;
- for (i = 0; i < allelments.length; i++) {
- allelments[i].style.fontSize = obj + "px";
- }
- }
- }
- //去掉所有空格和标点符号
- U.MS.dropSpaceAndDot = function (obj) {
- str = obj.value;
- var pattern = new RegExp("[`~!#$^&*()=|{}':;',\\[\\].<>/?~#……&*()&;—|{}‘;:”“'。,、]");
- var newstr = "";
- for (i = 0; i < str.length; i++) {
- if (str.substr(i, 1) == " ") {
- continue;
- }
- newstr += str.substr(i, 1).replace(pattern, "");
- }
- obj.innerText = newstr;
- //U.M.textCompatibleandStr(obj, newstr)
- }
- //判断字符串类型是是否带有' '这样的字符
- U.M.isBlank = function (szStr) {
- for (i = 0; i < szStr.length; i++) {
- if (szStr.substring(i, i + 1) == ' ') {
- return false;
- }
- break;
- }
- return true;
- }
- // 检查序列号格式 目前的格式类似 GUID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
- U.MS.Checkguid = function (object_value) {
- if (object_value.length == 0)
- return false;
- if (object_value.length != 38)
- return false;
- if (object_value.charAt(0) != "{")
- return false;
- if (object_value.charAt(37) != "}")
- return false;
- var hex_format = "0123456789abcdefABCDEF";
- var check_char;
- for (var i = 1; i < 37; i++) {
- if ((i == 9) || (i == 14) || (i == 19) || (i == 24)) {
- if (object_value.charAt(i) != "-")
- return false;
- } else {
- check_char = hex_format.indexOf(object_value.charAt(i));
- if (check_char < 0)
- return false;
- }
- }
- return true;
- }
- //跟进时间判定早中午时间,此函数未被使用
- U.MT.GetNowTime = function () {
- var time = new Date();
- var TimePart = document.getElementById("TimePart");
- var DataTime = time.getHours();
- if (DataTime >= 0 && DataTime < 12) {
- TimePart.innerHTML = "早上好!";
- }
- else if (DataTime >= 12 && DataTime < 18) {
- TimePart.innerHTML = "下午好!";
- }
- else {
- TimePart.innerHTML = "晚上好!";
- }
- }
- //使用U.MT.currenttime函数时转换UTC() 方法可根据世界时返回 1970 年 1 月 1 日 到指定日期的毫秒数。
- //Date.UTC(year,month,day,hours,minutes,seconds,ms)
- U.MT.DateUTC = function (STime) {
- STime = STime.split(" ");
- var MY = STime[0].split("/");
- var MS = STime[STime.length - 1].split(":");
- return "/Date(" + Date.UTC(MY[0], MY[1], MY[2], MS[0], MS[1], MS[2], 0) + ")/";
- }
- ////把json时间戳转为日期格式
- U.MT.getLocalTime = function (nS) {
- var _timeS = new Date(parseInt(nS.substring(6, nS.length - 2))).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
- if (!top.browser.msie) _timeS = _timeS.substring(10, 25);
- return _timeS;
- }
- //js获取当前的时间
- U.MT.currenttime = function () {
- var _currenttime = new Date();
- var _year = U.MT.getYear()//获取当前的年数
- var _month = _currenttime.getMonth() + 1; //获取当前的月份
- var _date = _currenttime.getDate(); //获取当前的日期
- var _houst = _currenttime.getHours(); //获取当前的小时
- var _Minutes = _currenttime.getMinutes(); //获取当前的分钟
- var _Seconds = _currenttime.getSeconds(); //获取当前的秒数
- return _year + '/' + _month + '/' + _date + ' ' + _houst + ':' + _Minutes + ':' + _Seconds; //返回用户现在的时间段 且样式复合项目的需求
- }
- U.MT.getDate = function (D) {
- if (D == null) { D = new Date(); }
- // if (date == null || date == "" || date == "undefined") date = new Date();
- // var yyyy = date.getFullYear();
- // var m = date.getMonth() + 1;
- // var mm = (m < 10) ? '0' + m : m;
- // var d = date.getDate();
- // var dd = (d < 10) ? '0' + d : d;
- // var h = date.getHours();
- // var hh = (h < 10) ? '0' + h : h;
- // var n = date.getMinutes();
- // var nn = (n < 10) ? '0' + n : n;
- // var s = date.getSeconds();
- // var ss = (s < 10) ? '0' + s : s;
- // return yyyy + "-" + mm + "-" + dd + " " + hh + ":" + nn + ":" + ss;
- }
- //返回月份的方法
- U.MT.GetMonth = function (month) {
- switch (month) {
- case "Jan":
- return "1";
- break;
- case "Feb":
- return "2";
- break;
- case "Mar":
- return "3";
- break;
- case "Apr":
- return "4";
- break;
- case "May":
- return "5";
- break;
- case "Jun":
- return "6";
- break;
- case "Jul":
- return "7";
- break;
- case "Aug":
- return "8";
- break;
- case "Sep":
- return "9";
- break;
- case "Oct":
- return "10";
- break;
- case "Nov":
- return "11";
- break;
- case "Dec":
- return "12";
- break;
- }
- }
- //转化星期
- U.MT.Getweek = function (week) {
- switch (week) {
- case "Mon":
- return "一";
- break;
- case "Tue":
- return "二";
- break;
- case "Wed":
- return "三";
- break;
- case "Thu":
- return "四";
- break;
- case "Fri":
- return "五";
- break;
- case "Sat":
- return "六";
- break;
- case "Sun":
- return "七";
- break;
- }
- }
- U.MT.DataTime = function (time) {
- time = eval('new ' + eval(time).source) + "";
- var strtime;
- _strtime = time.split(" ");
- _strtime[1] = U.MT.GetMonth(_strtime[1]); // 转化月份
- _strtime[0] = U.MT.Getweek(_strtime[0]); //转化星期
- return _strtime;
- }
- //用于blog的时间转换...转入2013-2-2 10:28:00 ...返回2013 2 2 10:28:00
- U.MT.DateAnalyze = function (TD) {
- TD = TD.split(" ");
- var MT = TD[0].split("/");
- MT = MT[0].split("-")
- MT[3] = TD[TD.length - 1];
- return MT;
- }
- //转换普通时间为Unix时间戳,返回的是US.userinfo中相同的类型-曾冠悦
- U.MT.getUnixTime = function (str_time) {
- var new_str = str_time.replace(/:/g, '-'); //替换冒号
- new_str = new_str.replace(/ /g, '-'); //替换空格
- var arr = new_str.split("-"); //转换成数组
- arr.length = 5;
- for (var i = 0; i < 6; i++) {
- if (arr[i] == undefined) {
- arr[i] = 0;
- }
- }
- return "/Date(" + Date.UTC(arr[0], arr[1] - 1, arr[2], arr[3] - 8, arr[4], arr[5]) + ")/";
- }
- //闰年
- U.MT.IsLeapYear = function (Y) {
- if ((Y % 400 == 0 && Y % 100 == 0) || (Y % 4 == 0 && Y % 100 != 0)) { return true; }
- else { return false; }
- }
- //函数作用,获取年份
- //在IE中得到的日期是"2011",在Firefox中看到的日期是"111",主要是因为在 Firefox 里面 getYear 返回的是 "当前年份-1900" 的值。
- U.MT.getYear = function () {
- var year = new Date().getYear();
- year = (year < 1900 ? (1900 + year) : year);
- return year;
- }
- //获取当前月份
- U.MT.getNowMonth = function () {
- var month = new Date().getMonth() + 1;
- return month;
- }
- //获取日期
- U.MT.getNowDate = function () {
- var date = new Date().getDate();
- return date;
- }
- //获取月份的天数,2月需要年参数
- U.MT.getDayOfMonth = function (month, year) {
- if (month == 4 || month == 6 || month == 9 || month == 11) {
- return 30;
- }
- if (month == 2) {
- if (U.MT.IsLeapYear(year)) {
- return 29;
- }
- else return 28;
- }
- return 31;
- }
- 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" }
- //获取中文拼音
- U.MS.PYS = function (UST) {//U.MS.PY
- var i, _UCT = UST.charCodeAt(0); //拼音编码
- if (_UCT && (_UCT > 0xB0A0 && _UCT < 0xD7FC)) { for (i = _UCT; (!(_UCT = U.MS.PY[i]) && i > 0xB0A1); ) { i--; } } //如果为拼音
- return _UCT;
- }
- U.MS.PYS("你");
- Namespace.register("U.Imges"); //久的图片浏览器
- USPhotoImgJson = null;
- //图片预加载(摘自:http://www.planeart.cn/demo/imgReady/ )=========================================================================================================================
- //使用方法ImgReady(图片URL,加载头文件成功执行函数(即获得图片长宽),加载图片成功执行函数,加载图片失败执行函数);
- //imgReady('images/logo_cn.png', function () {alert('size ready: width=' + this.width + '; height=' + this.height);},function(){alert("加载成功")},function(){alert("加载失败")});
- U.Imges.ImgReady = (function () {
- var list = [], intervalId = null,
- // 用来执行队列
- tick = function () {
- var i = 0;
- for (; i < list.length; i++) {
- list[i].end ? list.splice(i--, 1) : list[i]();
- };
- !list.length && stop();
- },
- //停止所有定时器队列
- stop = function () {
- clearInterval(intervalId);
- intervalId = null;
- };
- return function (url, ready, load, error) {
- var onready, width, height, newWidth, newHeight,
- img = new Image();
- img.src = url;
- // 如果图片被缓存,则直接返回缓存数据
- if (img.complete) {
- ready.call(img);
- load && load.call(img);
- return;
- };
- width = img.width;
- height = img.height;
- // 加载错误后的事件
- img.onerror = function () {
- error && error.call(img);
- //onready.end = true;
- img = img.onload = img.onerror = null;
- };
- // 图片尺寸就绪
- img.onreadystatechange = function () {
- if (document.readyState == "complete") {
- newWidth = img.width;
- newHeight = img.height;
- // 如果图片已经在其他地方加载可使用面积检测
- if (newWidth !== width || newHeight !== height || newWidth * newHeight > 1024) {
- ready.call(img);
- //onready.end = true;
- };
- };
- };
- // onready = function () {
- // newWidth = img.width;
- // newHeight = img.height;
- // // 如果图片已经在其他地方加载可使用面积检测
- // if (newWidth !== width || newHeight !== height || newWidth * newHeight > 1024) {
- // ready.call(img);
- // onready.end = true;
- // };
- // };
- // onready();
- // 完全加载完毕的事件
- img.onload = function () {
- // onload在定时器时间差范围内可能比onready快
- // 这里进行检查并保证onready优先执行
- //!onready.end && onready();
- load && load.call(img);
- // IE gif动画会循环执行onload,置空onload即可
- img = img.onload = img.onerror = null;
- };
- // 加入队列中定期执行
- // if (!onready.end) {
- // list.push(onready);
- // // 无论何时只允许出现一个定时器,减少浏览器性能损耗
- // if (intervalId === null) intervalId = setInterval(tick, 40);
- // };
- };
- })();
- //图片预加载(摘自:http://www.planeart.cn/demo/imgReady/ )=========================================================================================================================
- //图片居中旋转(编写:郭仁)========================================================================================================================================================
- //传入图片对象,与旋转方向(值:'left' or 'right')
- //使用方法imgRoll(document.getElementById("ImgObj"),"left");
- U.Imges.imgRoll = function (imgObj, SX, ArcSizeInt) {
- var ArcSize = imgObj.alt == null ? 0 : parseInt(imgObj.alt); //通过图片对象中的alt属性进行储存现行角度(1=90度;2=180度;3=270度;4=360度=0度)
- //判断SX进行角度增减
- if (SX == "left") {
- ArcSize += 1;
- ArcSize = ArcSize > 4 ? 0 : ArcSize;
- } else if (SX == "right") {
- ArcSize -= 1;
- ArcSize = ArcSize < 0 ? 3 : ArcSize;
- } else if (SX == "int") {
- ArcSize = ArcSizeInt;
- }
- //因为CSS旋转滤镜的实现方式不同~~需要进行不同的浏览判断给予定位
- imgObj.parentNode.style.width = ArcSize % 2 == 0 ? imgObj.width + (2 * 7) + "px" : imgObj.height + (2 * 7) + "px";
- imgObj.parentNode.style.height = ArcSize % 2 == 0 ? imgObj.height + (2 * 7) + "px" : imgObj.width + (2 * 7) + "px";
- if (!browser.msie) {
- if (ArcSize % 2 != 0) {
- imgObj.style.left = Math.ceil((parseInt(imgObj.parentNode.style.width) - parseInt(imgObj.parentNode.style.height)) / 2) + "px";
- imgObj.style.top = Math.ceil((parseInt(imgObj.parentNode.style.height) - parseInt(imgObj.parentNode.style.width)) / 2) + "px";
- imgObj.parentNode.style.left = parseInt(imgObj.parentNode.style.left) - parseInt(imgObj.style.left) + "px";
- imgObj.parentNode.style.top = parseInt(imgObj.parentNode.style.top) - parseInt(imgObj.style.top) + "px";
- } else {
- imgObj.parentNode.style.left = parseInt(imgObj.parentNode.style.left) + parseInt(imgObj.style.left) + "px";
- imgObj.parentNode.style.top = parseInt(imgObj.parentNode.style.top) + parseInt(imgObj.style.top) + "px";
- imgObj.style.left = "0px";
- imgObj.style.top = "0px";
- }
- }
- // else {
- // imgObj.parentNode.style.left = parseInt(imgObj.parentNode.getBoundingClientRect().left) - Math.ceil((parseInt(imgObj.parentNode.style.width) - parseInt(imgObj.parentNode.style.height)) / 2) + "px";
- // imgObj.parentNode.style.top = parseInt(imgObj.parentNode.getBoundingClientRect().top) - Math.ceil((parseInt(imgObj.parentNode.style.height) - parseInt(imgObj.parentNode.style.width)) / 2) + "px";
- // }
- imgObj.alt = ArcSize; //将角度值置于图片对象alt属性中
- //css旋转滤镜兼容
- imgObj.style.filter = 'Progid:DXImageTransform.Microsoft.BasicImage(Rotation=' + ArcSize + ')';
- imgObj.style.WebkitTransform = 'rotate(' + ArcSize * 90 + 'deg)';
- imgObj.style.MozTransform = 'rotate(' + ArcSize * 90 + 'deg)';
- imgObj.style.OTransform = 'rotate(' + ArcSize * 90 + 'deg)';
- }
- //图片居中旋转(编写:郭仁)========================================================================================================================================================
- //放大缩小【不影响于旋转后放大缩小的BUG~~】(编写:郭仁)============================================================================================================================
- //传入(图片对象,原始宽,原始高)~~
- U.Imges.Scale = function (ImgObj, nwidth, nheight) {
- var event = arguments.callee.caller.arguments[0] || window.event; //消除浏览器差异
- //滑动条位置
- var x = event.clientX - 80;
- var y = event.clientY - 20;
- //缩放比例~~
- var Scale = nwidth / nheight;
- //现行角度
- var ArcSize = ImgObj.alt == null ? 0 : parseInt(ImgObj.alt);
- if (document.getElementById("SlideCase_" + ImgObj.id) == null) {//判断滑动条是否已存在
- //创建滑动条
- var SlideCase = new U.Imges.SliderContorl(ImgObj.id, 200, 50, x, y, function (percentage) {
- ImgObj.style.width = nwidth * (percentage / 100) + "px";
- ImgObj.style.height = parseInt(ImgObj.style.width) / Scale + "px";
- if (ArcSize % 2 != 0) {
- ImgObj.parentNode.style.width = parseInt(ImgObj.style.height) + (2 * 7) + "px";
- ImgObj.parentNode.style.height = parseInt(ImgObj.style.width) + (2 * 7) + "px";
- if (browser.chrome || browser.firefox) {
- ImgObj.style.left = Math.ceil((parseInt(ImgObj.parentNode.style.width) - parseInt(ImgObj.parentNode.style.height)) / 2) + "px";
- ImgObj.style.top = Math.ceil((parseInt(ImgObj.parentNode.style.height) - parseInt(ImgObj.parentNode.style.width)) / 2) + "px";
- }
- } else {
- ImgObj.parentNode.style.width = parseInt(ImgObj.style.width) + (2 * 7) + "px";
- ImgObj.parentNode.style.height = parseInt(ImgObj.style.height) + (2 * 7) + "px";
- }
- });
- document.body.appendChild(SlideCase);
- }
- }
- //放大缩小【不影响于旋转后放大缩小的BUG~~】(编写:郭仁)============================================================================================================================
- //stackBlurImage(ImgStr, CanvasStr, percentage, false);
- //滑动条创建(编写:郭仁)==========================================================================================================================================================
- //通过传入[ID(为了避免多次创建同样功能滑动条);最大值;最小值;x;y;滑动块left改变后执行函数]
- //使用方法
- // if(document.getElementById("SlideCase_20")==null){
- // var DemoSlider = SliderContorl("20",200, 50, x, y, function (percentage) {
- // alert(percentage);
- // });
- // document.body.appendChild(DemoSlider);
- // }
- U.Imges.SliderContorl = function (id, max, min, left, top, callback) {
- var fadeOut = null; //淡出计时器Interval
- var removealertBar = null; //移除提示框计时器Timeout
- var percentage = 0; //滑动所在百分比
- //动态创建滑动框=====================================================================
- var SlideCase = document.createElement("div");
- SlideCase.id = "SlideCase_" + id; //每个滑动条都有自己的ID
- SlideCase.className = "ImgViewer SlideCase";
- SlideCase.style.left = left + "px";
- SlideCase.style.top = top + "px";
- //禁止选取
- SlideCase.onmousedown = function () { return false; } //IE;
- SlideCase.onselectstart = function () { return false; } //FireFox;Chorme
- //滑动条--------------------------------------------------
- var SlideBar = document.createElement("div");
- SlideBar.id = "SlideBar"
- SlideBar.className = "SlideBar";
- //滑动块--------------------------------------------------
- var SlidhingShoe = document.createElement("a");
- SlidhingShoe.id = "SlidhingShoe";
- SlidhingShoe.className = "ImgViewer SlidhingShoe";
- //移除按钮------------------------------------------------
- var CloseSlideButton = document.createElement("div");
- CloseSlideButton.id = "Slidhing_CloseSlideButton"
- CloseSlideButton.className = "Slidhing_CloseSlideButton";
- CloseSlideButton.onclick = function () { SlideCase.parentNode.removeChild(SlideCase); }
- //提示框--------------------------------------------------
- var alertBar = document.createElement("div");
- alertBar.id = "Slidhing_alertBar";
- alertBar.style.display = "none";
- alertBar.className = "ImgViewer Slidhing_alertBar";
- //添加到各各节点-------------------------------------------
- SlideBar.appendChild(SlidhingShoe);
- SlideCase.appendChild(SlideBar);
- SlideCase.appendChild(CloseSlideButton);
- SlideCase.appendChild(alertBar);
- //两个主要事件=====================================================================
- //提示框淡出消失函数
- var AlertFadeIn = function () {
- //提示框样式重置
- alertBar.style.filter = "alpha(opacity=100)";
- alertBar.style.MozOpacity = "1";
- alertBar.style.opacity = "1";
- alertBar.style.display = "inline-block";
- //再次清扫计时器防止内存溢出
- clearInterval(fadeOut);
- clearTimeout(removealertBar);
- //特效开始
- removealertBar = setTimeout(function () {
- i = 100;
- fadeOut = setInterval(function () {
- alertBar.style.filter = "alpha(opacity=" + i + ")";
- alertBar.style.MozOpacity = i * 0.01;
- alertBar.style.opacity = i * 0.01;
- i -= 2;
- if (i == 0) {
- alertBar.style.display = "none";
- //清扫计时器防止内存溢出
- clearInterval(fadeOut);
- clearTimeout(removealertBar);
- }
- }, 1);
- }, 800);
- }
- //滑动块移动或滑动条被点击后执行函数
- var mouse_down_or_move = function () {
- var pole = event.clientX - parseInt(SlideCase.style.left) - 25; //计算滑动块left
- //限制最小left与最大left
- pole = pole < 0 ? 0 : pole;
- pole = pole > 120 ? 120 : pole;
- SlidhingShoe.style.left = pole + "px";
- //给提示框赋予left值;使提示框跟着滑动块移动
- alertBar.style.left = pole - 20 + "px";
- percentage = pole * ((max - min) / 120) + min; //计算滑动条现行百分比
- alertBar.innerHTML = Math.round(percentage) + "%";
- callback(percentage); //回调传入函数
- }
- //给滑动条与滑动块进行事件处理==========================================
- SlideBar.onmousedown = function () {
- mouse_down_or_move();
- alertBar.style.display = "inline-block";
- }
- SlideBar.onmouseup = function () {
- if (!browser.msie) {
- AlertFadeIn();
- } else {
- clearTimeout(removealertBar);
- removealertBar = setTimeout(function () {
- alertBar.style.display = "none";
- clearTimeout(removealertBar);
- }, 800);
- }
- }
- SlidhingShoe.onmousedown = function () {
- var ismoveSlide = true;
- document.body.onmousemove = function () {
- if (ismoveSlide == true) {
- mouse_down_or_move();
- alertBar.style.display = "inline-block";
- if (!browser.msie) {
- alertBar.style.filter = "alpha(opacity=" + i + ")";
- alertBar.style.MozOpacity = i * 0.01;
- alertBar.style.opacity = i * 0.01;
- }
- }
- }
- document.body.onmouseup = function () {
- if (document.all != undefined) SlidhingShoe.releaseCapture(); //鼠标事件制焦
- ismoveSlide = false;
- if (!browser.msie) {
- AlertFadeIn();
- } else {
- clearTimeout(removealertBar);
- removealertBar = setTimeout(function () {
- alertBar.style.display = "none";
- clearTimeout(removealertBar);
- }, 800);
- }
- document.body.onmouseup = function () { return false; }
- }
- }
- return SlideCase; //返回滑动条
- }
- //滑动条创建(编写:郭仁)==========================================================================================================================================================
- //恢复1:1实际比例===================================================================================================================================================================
- //传入图片对象,原宽,原高
- U.Imges.ActuleScale = function (ImgObj, width, height) {
- ImgObj.style.width = width + "px";
- ImgObj.style.height = height + "px";
- ImgObj.parentNode.style.width = parseInt(ImgObj.style.width) + (2 * 7) + "px";
- ImgObj.parentNode.style.height = parseInt(ImgObj.style.height) + (2 * 7) + "px";
- }
- //创建图片框========================================================================================================================================================================
- //传入图片ID(防止同时出现多个同ID导致网页出错),图片地址,JSON【KEY】(你懂的~~可为空~~)
- U.Imges.CreatePhotoCase = function (imgid, url, key) {
- var nwidth = 0; //原宽
- var nheight = 0; //原高
- // if (window.top.document.getElementById("ImgViewer_Div" + imgid) != null) {//如果已创建此相框则返回此相框
- // return window.top.document.getElementById("ImgViewer_Div" + imgid);
- // }
- //var IV_Div = window.top.document.getElementById("ImgViewer_Div");
- var IV_Div = window.top.$('#ImgViewer_Div')[0];
- if (IV_Div != null) {//如果已创建过相框则只在更改图片及管理框 ——简炜杰
- var img = $("Img", IV_Div)[0];
- //更换图片ID
- img.id = "ImgViewer_Img" + imgid;
- //图片大小处理以及重新加载管理框
- var _ready = function () {
- return function () {
- var nImg = new Image();
- nImg.src = url;
- var nwidth = nImg.width;
- var nheight = nImg.height;
- if (nImg.width > 800 || nImg.height > 600) {
- if (nImg.width > nImg.height) {
- nwidth = 800;
- nheight = nwidth / (nImg.width / nImg.height);
- } else {
- nheight = 600;
- nwidth = nheight * (nImg.width / nImg.height);
- }
- } else if (nImg.height < 200) {
- nheight = 200;
- nwidth = nheight * (nImg.width / nImg.height);
- } else {
- nwidth = nImg.width;
- nheight = nImg.height;
- }
- img.style.height = nheight + "px";
- img.style.width = nwidth + "px";
- IV_Div.style.height = nheight + 14 + "px";
- IV_Div.style.width = nwidth + 14 + "px";
- 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>';
- strCode += '<a class="samllRadius ImgViewer ImgViewer_ImgRollLeftIcon" href="javascript:void(0)" onclick="U.Imges.imgRoll(document.getElementById(\'ImgViewer_Img' + imgid + '\'),\'left\')" ></a>';
- strCode += '<a class="samllRadius ImgViewer ImgViewer_ImgRollRightIcon" href="javascript:void(0)" onclick="U.Imges.imgRoll(document.getElementById(\'ImgViewer_Img' + imgid + '\'),\'right\')"></a>';
- strCode += '<a class="samllRadius ImgViewer ImgViewer_ScaleIcon" href="javascript:void(0)" onclick="U.Imges.Scale(document.getElementById(\'ImgViewer_Img' + imgid + '\'),' + nwidth + ',' + nheight + ')"></a>';
- strCode += '<a class="samllRadius ImgViewer ImgViewer_ActuleIcon" href="javascript:void(0)" onclick="U.Imges.ActuleScale(document.getElementById(\'ImgViewer_Img' + imgid + '\'),' + nwidth + ',' + nheight + ')"></a>';
- strCode += '<a class="samllRadius ImgViewer ImgViewer_ThumbnailsIcon" href="javascript:void(0)" onclick="if(USPhotoImgJson!=null) document.getElementById(\'ImgViewer_ThumbnailsCase\').style.display=\'inline-block\';"></a>';
- $('#ImgViewer_manager')[0].innerHTML = strCode;
- U.Imges.ActuleScale(img, nwidth, nheight);
- }
- }
- _ready = _ready();
- //加载图片
- U.Imges.ImgReady(url, _ready, function () { img.src = url; }, function () { alert("加载失败"); ImgDiv.parentNode.removeChild(ImgDiv); });
- return;
- }
- //创建相框==============================================================
- var ImgDiv = document.createElement("div");
- //ImgDiv.id = "ImgViewer_Div" + imgid;
- //相框只生成一次,ID改为唯一 ——简炜杰
- ImgDiv.id = "ImgViewer_Div";
- ImgDiv.className = "ImgViewer_Div ImgViewer_shadow";
- //禁止选取
- ImgDiv.onmousedown = function () { return false; } //IE;
- ImgDiv.onselectstart = function () { return false; } //FireFox;Chorme
- //创建管理框============================================================
- var managerBar = document.createElement("div");
- managerBar.id = "ImgViewer_managerBar";
- managerBar.className = "ImgViewer ImgViewer_managerBar";
- //创建管理对齐DIV=======================================================
- var manager = document.createElement("div");
- manager.id = "ImgViewer_manager";
- manager.className = "ImgViewer_manager";
- //创建图片元素==========================================================
- var USPhotoImg = document.createElement("img");
- USPhotoImg.id = "ImgViewer_Img" + imgid;
- USPhotoImg.className = "ImgViewer_Img";
- USPhotoImg.alt = "0";
- USPhotoImg.src = "img/loading.png";
- USPhotoImg.onmousedown = function () { U.D.DragMouseDown(ImgDiv, "ImgViewer"); }
- if (key != null && key != "") {//如果KEY值为空则不显示上一张与下一张
- //创建对齐框==========================================================
- var gobackdiv = document.createElement("div");
- gobackdiv.id = "ImgViewer_gobackdiv";
- gobackdiv.className = "ImgViewer_gobackdiv";
- //创建上一张按钮======================================================
- var go = document.createElement("i");
- go.id = "ImgViewer_go";
- go.className = "ImgViewer ImgViewer_go";
- go.onclick = function () {
- goorback("g");
- }
- go.onmouseover = function () {
- gobackdiv.style.display = "inline-block";
- }
- go.onmouseout = function () {
- gobackdiv.style.display = "none";
- }
- //创建下一张按钮======================================================
- var back = document.createElement("i");
- back.id = "ImgViewer_back";
- back.className = "ImgViewer ImgViewer_back";
- back.onclick = function () {
- goorback("b");
- }
- back.onmouseover = function () {
- gobackdiv.style.display = "inline-block";
- }
- back.onmouseout = function () {
- gobackdiv.style.display = "none";
- }
- USPhotoImg.onmouseover = function () {
- gobackdiv.style.display = "inline-block";
- }
- USPhotoImg.onmouseout = function () {
- gobackdiv.style.display = "none";
- }
- gobackdiv.appendChild(go);
- gobackdiv.appendChild(back);
- ImgDiv.appendChild(gobackdiv);
- var goorback = function (gb) {
- //如果滑动条存在为以防出错而将原图滑动条隐藏
- if (document.getElementById("SlideCase_" + USPhotoImg.id) != null) document.getElementById("SlideCase_" + USPhotoImg.id).parentNode.removeChild(document.getElementById("SlideCase_" + USPhotoImg.id));
- U.Imges.imgRoll(USPhotoImg, "int", 0); //恢复旋转角度
- if (gb == "g") {
- key--;
- } else if (gb == "b") {
- key++;
- }
- key = key < 0 ? USPhotoImgJson.length - 1 : key;
- key = key > USPhotoImgJson.length - 1 ? 0 : key;
- var Img = USPhotoImgJson[key]; //选择JSON
- //更换ID
- //相框只生成一次,ID改为唯一,无需更换 ——简炜杰
- //ImgDiv.id = "ImgViewer_Div" + Img.imgid;
- USPhotoImg.id = "ImgViewer_Img" + Img.imgid;
- //执行图片预加载~~
- var _e = function () {
- return function () {
- var nwidth = this.width;
- var nheight = this.height;
- if (this.width > 800 || this.height > 600) {
- if (this.width > this.height) {
- nwidth = 800;
- nheight = nwidth / (this.width / this.height);
- } else {
- nheight = 600;
- nwidth = nheight * (this.width / this.height);
- }
- } else if (this.height < 200) {
- nheight = 200;
- nwidth = nheight * (this.width / this.height);
- } else {
- nwidth = this.width;
- nheight = this.height;
- }
- ImageReady(Img.imgid, nwidth, nheight);
- gobackdiv.style.bottom = (nheight + (2 * 7)) / 2 - 15 + "px";
- }
- }
- _e = _e();
- U.Imges.ImgReady(Img.imgurl, _e, function () { USPhotoImg.src = this.src; }, function () { alert("加载失败"); ImgDiv.parentNode.removeChild(ImgDiv); });
- }
- }
- managerBar.appendChild(manager);
- ImgDiv.appendChild(USPhotoImg);
- ImgDiv.appendChild(managerBar);
- //图片加载成功后执行事件
- var ImageReady = function (Imgid, width, height) {
- 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>';
- strCode += '<a class="samllRadius ImgViewer ImgViewer_ImgRollLeftIcon" href="javascript:void(0)" onclick="U.Imges.imgRoll(document.getElementById(\'ImgViewer_Img' + Imgid + '\'),\'left\')" ></a>';
- strCode += '<a class="samllRadius ImgViewer ImgViewer_ImgRollRightIcon" href="javascript:void(0)" onclick="U.Imges.imgRoll(document.getElementById(\'ImgViewer_Img' + Imgid + '\'),\'right\')"></a>';
- strCode += '<a class="samllRadius ImgViewer ImgViewer_ScaleIcon" href="javascript:void(0)" onclick="U.Imges.Scale(document.getElementById(\'ImgViewer_Img' + Imgid + '\'),' + width + ',' + height + ')"></a>';
- strCode += '<a class="samllRadius ImgViewer ImgViewer_ActuleIcon" href="javascript:void(0)" onclick="U.Imges.ActuleScale(document.getElementById(\'ImgViewer_Img' + Imgid + '\'),' + width + ',' + height + ')"></a>';
- strCode += '<a class="samllRadius ImgViewer ImgViewer_ThumbnailsIcon" href="javascript:void(0)" onclick="if(USPhotoImgJson!=null) document.getElementById(\'ImgViewer_ThumbnailsCase\').style.display=\'inline-block\';"></a>';
- manager.innerHTML = strCode;
- U.Imges.ActuleScale(USPhotoImg, width, height);
- }
- var _e = function () {
- return function () {
- var nwidth = this.width;
- var nheight = this.height;
- if (this.width > 800 || this.height > 600) {
- if (this.width > this.height) {
- nwidth = 800;
- nheight = nwidth / (this.width / this.height);
- } else {
- nheight = 600;
- nwidth = nheight * (this.width / this.height);
- }
- } else if (this.height < 200) {
- nheight = 200;
- nwidth = nheight * (this.width / this.height);
- } else {
- nwidth = this.width;
- nheight = this.height;
- }
- ImageReady(imgid, nwidth, nheight);
- if (key != null & key != "") gobackdiv.style.bottom = (nheight + (2 * 7)) / 2 - 15 + "px";
- }
- }
- _e = _e();
- U.Imges.ImgReady(url, _e, function () { USPhotoImg.src = this.src; }, function () { alert("加载失败"); ImgDiv.parentNode.removeChild(ImgDiv); });
- document.body.appendChild(ImgDiv);
- }
- U.Imges.ThumbnailsCase = function (ImgJson) {
- var fadeOut = null; //淡出计时器Interval
- var removealertBar = null; //移除提示框计时器Timeout
- var ThumbnailsArray = document.getElementById("ImgViewer_ThumbnailsArray");
- var ThumbnailsSlideShoe = document.getElementById("ImgViewer_ThumbnailsSlideShoe");
- var ThumbnailsSlideBar = document.getElementById("ImgViewer_ThumbnailsSlideBar");
- var ThumbnailsAlertBar = document.getElementById("ImgViewer_ThumbnailsAlertBar");
- var strCode = "";
- var Json = eval('(' + ImgJson + ')');
- USPhotoImgJson = Json;
- for (var i in Json) {
- var Img = Json[i]
- strCode += '<img onclick="U.Imges.CreatePhotoCase(\'' + Img.imgid + '\',\'' + Img.imgurl + '\',\'' + i + '\')" class="ImgViewer_ThumbnailsImg" src="' + Img.imgThumbnails + '"/>';
- }
- ThumbnailsArray.innerHTML = strCode;
- ThumbnailsArray.style.width = (Json.length / 2) * 68 + "px";
- ThumbnailsArray.parentNode.parentNode.style.display = "inline-block";
- var mousemoveOrdown = function () {
- pole = event.clientX - parseInt(ThumbnailsSlideShoe.parentNode.parentNode.getBoundingClientRect().left) - 35;
- pole = pole < 0 ? 0 : pole;
- pole = pole > 235 ? 235 : pole;
- ThumbnailsSlideShoe.style.left = pole + "px";
- ThumbnailsAlertBar.style.left = pole - 10 + "px";
- var ThumbnailsArrayleft = Math.ceil(pole) * ((parseInt(ThumbnailsArray.style.width) - 278) / 235);
- if (ThumbnailsArrayleft > 0) {
- ThumbnailsAlertBar.innerHTML = Math.round(ThumbnailsArrayleft) + 35 + "%";
- ThumbnailsArray.style.marginLeft = "-" + ThumbnailsArrayleft + "px";
- } else {
- ThumbnailsAlertBar.innerHTML = "小于范围值~~";
- ThumbnailsArray.style.marginLeft = "0px";
- }
- }
- var AlertFadeIn = function () {
- //提示框样式重置
- ThumbnailsAlertBar.style.filter = "alpha(opacity=100)";
- ThumbnailsAlertBar.style.MozOpacity = "1";
- ThumbnailsAlertBar.style.opacity = "1";
- ThumbnailsAlertBar.style.display = "inline-block";
- //再次清扫计时器防止内存溢出
- clearInterval(fadeOut);
- clearTimeout(removealertBar);
- //特效开始
- removealertBar = setTimeout(function () {
- i = 100;
- fadeOut = setInterval(function () {
- ThumbnailsAlertBar.style.filter = "alpha(opacity=" + i + ")";
- ThumbnailsAlertBar.style.MozOpacity = i * 0.01;
- ThumbnailsAlertBar.style.opacity = i * 0.01;
- i -= 2;
- if (i == 0) {
- ThumbnailsAlertBar.style.display = "none";
- //清扫计时器防止内存溢出
- clearInterval(fadeOut);
- clearTimeout(removealertBar);
- }
- }, 1);
- }, 800);
- }
- //事件控制
- ThumbnailsSlideBar.onmousedown = function () {
- mousemoveOrdown();
- ThumbnailsAlertBar.style.display = "inline-block";
- }
- ThumbnailsSlideBar.onmouseup = function () {
- if (!browser.msie) {
- AlertFadeIn();
- } else {
- clearTimeout(removealertBar);
- removealertBar = setTimeout(function () {
- ThumbnailsAlertBar.style.display = "none";
- clearTimeout(removealertBar);
- }, 800);
- }
- }
- ThumbnailsSlideShoe.onmousedown = function () {
- var ismoveSlide = true;
- document.body.onmousemove = function () {
- if (ismoveSlide == true) {
- mousemoveOrdown();
- ThumbnailsAlertBar.style.display = "inline-block";
- if (!browser.msie) {
- ThumbnailsAlertBar.style.filter = "alpha(opacity=" + i + ")";
- ThumbnailsAlertBar.style.MozOpacity = i * 0.01;
- ThumbnailsAlertBar.style.opacity = i * 0.01;
- }
- }
- }
- document.body.onmouseup = function () {
- if (document.all != undefined) ThumbnailsSlideShoe.releaseCapture();
- ismoveSlide = false;
- if (!browser.msie) {
- AlertFadeIn();
- } else {
- clearTimeout(removealertBar);
- removealertBar = setTimeout(function () {
- ThumbnailsAlertBar.style.display = "none";
- clearTimeout(removealertBar);
- }, 800);
- }
- document.body.onmouseup = function () { return false; }
- }
- }
- }
- //设置换行
- U.M.SEKP = function (IF, CB, TF) {
- IF.onkeypress = function () { if (event.keyCode == 10 || event.keyCode == 13) { if (TF) { U.M.StopDefault(); } if (CB) { CB(); } } }
- }
- //由于需要大Div,小Div的loading,而现有的Loading函数有些复杂。需要逻辑再清晰,所以先独立,最后合并到一个loading中。
- //加载Gif动画效果,小加载,区别于博客,论坛的大加载。
- //此处需要异步装载,先装载文章(需要有加载动画),文章加载完毕再异步加载评论(需要有加载动画),否则会很慢。
- //参数load为true,则为显示图片,参数load为false,则为卸载。因为每个项目都要用所以放在了主项目中。
- U.MD.SMGif = function (_div, _load) {
- if (_load == false) _div.removeChild(U.M.GetCById(_div, "U_SMLD"));
- else $$("img", { "id": "U_SMLD", "className": "U_SMLDGif", "src": "/img/us_smlding.gif" }, _div); //追加loading
- }
- //设置text自适应
- U.M.TeSize = function (UDOD, UMH) {
- var i; //循环初始化
- var _UDE = ["propertychange", "input", "focus"]; //定义需要用到的字符串
- var _ = function () {
- var _USH = UDOD.scrollHeight, _UDTD = $(UDOD);
- if (_USH != UDOD.clientHeight && _USH != UDOD.currHeight) {
- if (!UMH || _USH < UMH) { _UDTD.addAttrArray({ currHeight: _USH, style: { overflowY: "hidden", height: _USH + "px"} }); } //最小大小
- else { _UDTD.addAttrArray({ style: { overflowY: "auto"} }); } //最大大小
- }
- }
- for (i = 0; i < _UDE.length; i++) { U.M.AddEvent(_UDE[i], UDOD, _); }
- }
- //设置禁止刷新------------------没有任何地方用到
- U.M.stopRefresh = function () {
- U.M.keyfun = U.M.keyfun || function () { if (event.keyCode == 116) { event.keyCode = 0; U.M.StopBubble(); U.M.StopDefault(); return false; } }
- var _UDE = { keydown: U.M.keyfun, keyup: U.M.keyfun }; $(document).unbind(_UDE).bind(_UDE);
- }
- //异步处理函数
- U.M.AsynApply = function (UTE, UDE) {
- var _ = U.M.apply(UTE, UDE); return function () { setTimeout(_, 0); } //异步加载处理
- }
- //js forEach循环
- U.M.forEach = function (UDE, UFN, UC) {
- for (var i in UDE) {
- if (UDE.hasOwnProperty(i) && UFN.call(UC, UDE[i], i, UDE) === false) { break; }
- }
- }
- //等比例缩放
- U.M.ImageZoom = function (UI, UZ) {
- var _TF, _UH, _UW; UI = UI || this;
- if (UI.height != 0 && UI.width != 0) {
- 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; }
- 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; }
- $(UI).addAttrArray({ "style": { "width": _UW + "px", "height": _UH + "px"} });
- }
- }
- //窗体是否可见
- U.M.visi = function (UOE, UTE) {
- var _, cb, i, j, _UTP, _UTF, _UCE = ["", "webkit", "moz", "ms", "o"], _UME = ["hidden", "visibilityState", "visibilitychange"];
- 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; } }
- if (_UTF) { U.M.AddEvent(_UME[2], U.M.apply(null, [[U.M.visi.cb, [UOE, UTE, _UME[1]]]])); }
- else { U.M.IsActivity(UOE, UTE); }
- }
- U.M.visi.cb = function (UOE, UTE, UTP) {
- (document[UTP] ? UOE : UTE)();
- }
- //是否启用cookie
- U.M.Cookies.is = function () { return navigator.cookieEnabled; }
- //新窗口写入数据
- U.M.WOP = function (UHT) {
- var _UDD, _UDW = window.open("javascript:void((function(){document.open();document.domain='" + document.domain + "';document.close()})())"); //"about:blank"
- (UHT) && (_UDD = _UDW.document.open(), _UDD.write(UHT), _UDD.close());
- return _UDW;
- }
- //异步添加元素
- U.M.asyncInnerHTML = function (UH, UCB) {
- var _UOD = $$("div", { "innerHTML": UH }), UOF = $$("frag");
- if (_UOD.firstChild) { UOF.appendChild(_UOD.firstChild); setTimeout(arguments.callee, 0); } //然后一点点挪到文档碎片 //然后把插入内容的操作作为异步调用放到一个独立的堆栈中
- else { UCB[UOF]; } //这里才是真正执行插入节点的操作
- // (function () { })();
- }
- //设置浏览器首页 必须有按钮触发
- U.M.setHome = function (UDOD, URL) {
- UDOD = UDOD || event.srcElement;
- try { UDOD.style.behavior = "url(#default#homepage)"; UDOD.setHomePage(URL); return true; }
- catch (e) {
- if (window.netscape) {
- try {
- if (netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")) { //判断是否开启设置首页功能
- Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch).setCharPref('browser.startup.homepage', URL); return true;
- }
- }
- catch (e) { }
- }
- }
- return false;
- }
- //加入收藏夹
- U.M.Collec = function (UTI, URL) {
- try { window.external.addFavorite(URL, UTI); return true; }
- catch (e) { try { window.sidebar.addpanel(UTI, URL, ""); return true; } catch (e) { } }
- return false;
- }
- //获取js路径
- U.M.GetJsUrl = function (UDID) {
- var i, _UIE, _UPE, _USE, _UDE = document.scripts;
- if ((_UPE = document.currentScript)) { _UPE = _UPE.src; } else { try { throw Error(); } catch (e) { _UPE = e.stack || e.sourceURL || e.stacktrace; } } //获取链接
- 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]]; } } } //非兼容全屏搜索
- _UPE = [_UPE, _UPE.split("/")]; _UPE[1] = _UPE[1][_UPE[1].length - 1]; return _UPE;
- }
- //U.OU.TF = { "TF": "Excel" }
- //U.OU.DivisionExcelWord = function (Judge) { U.OU.JudgeEW = Judge; } //判断是Excel还是Wrod
- ////----------------------------------------------菜单功能----------------------------------------------------------//
- ////文件下拉菜单功能
- //U.OU.OpenFileMenu = function () {
- // U.M.StopBubble(); //阻止冒泡
- // var FileMenu = document.getElementById("U_E_OC");
- // FileMenu.style.display = FileMenu.style.display == "none" ? "block" : "none";
- //}
- ////切换菜单选项
- //U.OU.SwitchOption = function (Option, Judge) {
- // var OptionList = document.getElementById("U_E_MenuBar").getElementsByTagName("li");
- // for (var i = 1; i < OptionList.length; i++) { OptionList[i].className = ""; }
- // Option.className = "U_E_MenuButton";
- // document.getElementById(Judge).style.display = "block";
- // document.getElementById(Judge == "U_E_Tool" ? "U_OU_Nav" : "U_E_Tool").style.display = "none";
- //}
- ////-----------------------------------------------工具-----------------------------------------------------------//
- ////显示或隐藏颜色框
- //U.OU.DisplayColorFrame = function (FrameID) {
- // var ColorFrame = document.getElementById(FrameID);
- // ColorFrame.style.display = ColorFrame.style.display == "none" ? "block" : "none";
- // var OtherID = FrameID == "U_E_TColorFrame" ? "U_E_BColorFrame" : "U_E_TColorFrame"; //隐藏另一个颜色框
- // document.getElementById(OtherID).style.display = "none";
- //}
- ////点击颜色Li
- //U.OU.ColorLiOnClick = function (Li) {
- // var Color = Li.style.backgroundColor; var Father = Li.parentNode;
- // var BorderID = Father.id == "U_E_BColorFrame" ? "U_E_BColorBorder" : "U_E_TColorBorder";
- // var StyleName = Father.id == "U_E_BColorFrame" ? "BackColor" : "ForeColor";
- // document.getElementById(BorderID).style.backgroundColor = Color;
- // U.OU.ChangeStyle(StyleName, Color);
- // Father.style.display = "none"; //隐藏颜色框
- //}
- ////-----------------------------------------------插入-----------------------------------------------------------//
- //U.OU.InsertNowTime = function () {
- // var NowTime = US.Admin.TimeNow["年", "月", "日"];
- // if (U.OU.JudgeEW == "Word" || U.Excel.KeepEditblur()) { U.D.E.GetSelectionRange(window, $$("span")).Replace(NowTime); }
- // else {
- // var Compare = U.Excel.ComparePickOn(); var Small = Compare[0]; var Big = Compare[1];
- // for (var i = Small[0]; i <= Big[0]; i++) {
- // for (var j = Small[1]; j <= Big[1]; j++) { U.Excel.Cell[i][j].innerHTML = NowTime; }
- // }
- // }
- //}
- ////-----------------------------------------------文本编辑器-----------------------------------------------------------//
- //U.OU.ChangeStyle = function (SN, V, TF) {
- // if (U.OU.TF["TF"] == "Excel") {
- // var _UDFD = $("#U_E_EditFrame")[0], _UDED = $("div", _UDFD)[0];
- // if (_UDFD.ondblclick == null) { U.D.E.FontSizeType(_UDED, SN, [V, V]); } //修改文字样式
- // else {
- // U.D.E.GetSelectionRange(window, U.Excel.SY["SEO"][0]).SetYPS(SN, V);
- // U.Excel.SY["CE"]["Cell"][U.Excel.SY["SEO"][1]].style[SN] = V;
- // }
- // }
- //}
- //////改变单元格或选中文本的样式(Style)
- ////U.OU.ChangeStyle = function (StyleName, Param) {
- //// var EJudge = U.OU.JudgeEW == "Word" || (U.Excel.KeepEditblur() && StyleName != "BackColor" && StyleName != "JustifyLeft" && StyleName != "JustifyCenter" && StyleName != "JustifyRight");
- //// if (EJudge) {//判断是否处于编辑状态中,或者是否是Word
- //// if (Param == null) { document.execCommand(StyleName) }
- //// else { document.execCommand(StyleName, false, Param); }
- //// }
- //// else {
- //// // var StyleList = { "Bold": "fontWeight", "Italic": "fontStyle", "Underline": "textDecoration", "StrikeThrough": "textDecoration", "": "backgroundColor", "": "", "": "", "": "", "": "", "": "", "": "", "": "", "": "", "": "" };
- //// switch (StyleName) {
- //// case "Bold": StyleName = "fontWeight"; Param = ['bold', 'normal']; break;
- //// case "Italic": StyleName = "fontStyle"; Param = ['italic', 'normal']; break;
- //// case "Underline": StyleName = "textDecoration"; Param = ['underline', 'none']; break;
- //// case "StrikeThrough": StyleName = "textDecoration"; Param = ['line-through', 'none']; break;
- //// case "BackColor": StyleName = "backgroundColor"; break;
- //// case "ForeColor": StyleName = "color"; break;
- //// case "JustifyLeft": StyleName = "textAlign"; Param = "left"; break;
- //// case "JustifyCenter": StyleName = "textAlign"; Param = "center"; break;
- //// case "JustifyRight": StyleName = "textAlign"; Param = "right"; break;
- //// case "FontSize": StyleName = "fontSize"; Param = Param + "px"; break;
- //// case "FontName": StyleName = "fontFamily"; break;
- //// }
- //// var TempParam = Param.concat();
- //// var Compare = U.Excel.ComparePickOn(); var Small = Compare[0]; var Big = Compare[1]; var Cell;
- //// for (var i = Small[0]; i <= Big[0]; i++) {
- //// for (var j = Small[1]; j <= Big[1]; j++) {
- //// Cell = U.Excel.Cell[i][j];
- //// if (StyleName == "textDecoration") {//让删除线和下划线共存
- //// var Decoration = Param[0] == "underline" ? "line-through" : "underline";
- //// if (Cell.style[StyleName].indexOf(Decoration) > -1) { Param[0] = "underline line-through"; Param[1] = Decoration; }
- //// }
- //// if ((typeof (Param) == "string")) { Cell.style[StyleName] = Param; }
- //// else { Cell.style[StyleName] = Cell.style[StyleName] == Param[0] ? Param[1] : Param[0]; }
- //// if (StyleName == "textDecoration") { Param = TempParam.concat(); }
- //// }
- //// }
- //// }
- //// if (U.OU.JudgeEW == "Excel") { U.Excel.EditTextEdit("Cell"); }
- ////}
- ////获取选中文本在整篇文章内的位置
- //U.OU.SelectedLocation = function () {
- // //Chorme
- // // var range = window.getSelection().getRangeAt(0);
- // // var startRangeOffset = range.startOffset;
- // // range.collapse(true);
- // // range.setStart(range.startContainer, startRangeOffset - 1);
- // // range.setEnd(range.startContainer, startRangeOffset - 1 + plenght);
- // //IE
- // // var EditFrame = document.getElementById("U_E_EditFrame");
- // // var EditContent = EditFrame.getElementsByTagName("div")[0];
- // var EditContent = document.getElementById("U_W_WordEdit");
- // var range = document.selection.createRange();
- // var stored_range = range.duplicate();
- // stored_range.moveToElementText(EditContent);
- // stored_range.setEndPoint('EndToEnd', range);
- // EditContent.selectionStart = stored_range.text.length - range.text.length;
- // EditContent.selectionEnd = EditContent.selectionStart + range.text.length;
- // //U.Excel.setSelectText(EditContent, EditContent.selectionStart, EditContent.selectionEnd);
- //}
- ////将InnerHTML拆分成数组
- //U.OU.SpiltInnerHTML = function (InnerHTML) {
- // var InnerFrame = $$("span", { "innerHTML": InnerHTML });
- // InnerHTML = InnerFrame.innerHTML;
- // var ElementList = U.M.GTCN(InnerFrame.childNodes); var SubStr = "";
- // var NewArray = []; var Local; var ElementInner;
- // for (var i = 0; i < ElementList.length; i++) {
- // ElementInner = U.OU.OuterHTML(ElementList[i]);
- // Local = InnerHTML.toLowerCase().indexOf(ElementInner.toLowerCase());
- // SubStr = InnerHTML.substring(0, Local);
- // if (SubStr.replace(/(^\s*)|(\s*$)/g, "") != "") { NewArray.push(SubStr); } //如果为空就不加入到数组中
- // NewArray.push(ElementList[i]);
- // InnerHTML = InnerHTML.substring(Local + ElementInner.length, InnerHTML.length);
- // }
- // if (InnerHTML.replace(/(^\s*)|(\s*$)/g, "") != "") { NewArray.push(InnerHTML); }
- // return NewArray;
- //}
- //U.OU.OuterHTML = function (Element) {
- // var HTMLFrame = $$("span", {}); HTMLFrame.appendChild(Element);
- // return HTMLFrame.innerHTML;
- //}
- ////文本编辑器(兼容IE,Chroem)Firefox未测试
- //U.OU.Editplus = function (StyleName, Param) {
- // var BrowserJudge = !(document.selection); //判断是哪个浏览器
- // var range = BrowserJudge ? window.getSelection().getRangeAt(0) : document.selection.createRange();
- // var TextFather = BrowserJudge ? range.commonAncestorContainer.parentNode : range.parentElement(); //获取文本的父窗口
- // var InnerHTML = BrowserJudge ? document.createElement('span') : range.htmlText; //返回选中的InnerHTML
- // if (BrowserJudge) { SpanFrame.appendChild(range.cloneContents()).innerHTML; }
- // var ElementList = U.OU.SpiltInnerHTML(InnerHTML); //将InnerHTML分割成数组(根据标签进行分割)
- // var NewStyle = TextFather.style[StyleName] == Param[0] ? Param[1] : Param[0]; var NextSpan;
- // if (ElementList[0].nodeName) {//如果开头是标签就取标签相反的,如果是文本就取第一种样式
- // for (var i = 0; i < ElementList.length; i++) {
- // NewStyle = ElementList[i].style[StyleName]; NextSpan = ElementList[i + 1];
- // if (NextSpan == null || NextSpan.nodeName == null || NextSpan.style[StyleName] == NewStyle) { NewStyle = NewStyle == Param[0] ? Param[1] : Param[0]; break; }
- // }
- // }
- // var HTMLFrameB = $$("span", {}); var HTMLFrameS = $$("span", {}, HTMLFrameB);
- // var str = ChildList = ""; HTMLFrameS.style[StyleName] = NewStyle; var ElementName = "";
- // for (var i = 0; i < ElementList.length; i++) {
- // ElementName = ElementList[i].nodeName;
- // if (ElementName) {
- // if (ElementList[i].innerHTML == "" && ElementName == "SPAN") { continue; }
- // ChildList = ElementList[i].getElementsByTagName("*");
- // for (var j = 0; j < ChildList.length; j++) { if (ChildList[j].nodeName != "BR") { ChildList[j].style[StyleName] = NewStyle; } }
- // if (ElementName != "BR") {
- // if (ElementName == "P" && (i == 0 || i == ElementList.length - 1)) {
- // // if (i == ElementList.length - 1) { str += "<p>"; }
- // HTMLFrameS.innerHTML = ElementList[i].innerHTML;
- // str += HTMLFrameB.innerHTML;
- // if (i == 0) { str += "<br />"; }
- // continue;
- // }
- // ElementList[i].style[StyleName] = NewStyle;
- // }
- // str += U.OU.OuterHTML(ElementList[i]);
- // }
- // else { HTMLFrameS.innerHTML = ElementList[i]; str += HTMLFrameB.innerHTML; }
- // }
- // if (BrowserJudge) { var NewFrame = $$("span", { "innerHTML": str }); range.deleteContents(); range.insertNode(HTMLFrameS); }
- // else { range.pasteHTML(str); }
- //}
- ////文本编辑器(兼容IE,Chroem)Firefox未测试
- ////U.OU.Editplus = function (StyleName, Param) {
- //// var BrowserJudge = !(document.selection); //判断是哪个浏览器
- //// var range = BrowserJudge ? window.getSelection().getRangeAt(0) : document.selection.createRange();
- //// var TextFather = BrowserJudge ? range.commonAncestorContainer.parentNode : range.parentElement(); //获取文本的父窗口
- //// var SpanFrame = BrowserJudge ? document.createElement('span') : $$("span", { "innerHTML": range.htmlText }); //返回innerHTML为选中内容的span
- //// if (BrowserJudge) { SpanFrame.appendChild(range.cloneContents()); } var SpanList = SpanFrame.getElementsByTagName("*");
- //// var NewStyle = Param[0]; var NextSpan;
- //// //如果开头是标签就取标签相反的,如果是文本就取第一种样式
- //// if (!(SpanFrame.firstChild.nodeValue)) {
- //// for (var i = 0; i < SpanList.length; i++) {
- //// NewStyle = SpanList[i].style[StyleName]; NextSpan = SpanList[i + 1];
- //// if (NextSpan == null || NextSpan.style[StyleName] == NewStyle) { NewStyle = NewStyle == Param[0] ? Param[1] : Param[0]; break; }
- //// }
- //// }
- //// else { NewStyle = TextFather.style[StyleName] == Param[0] ? Param[1] : Param[0]; }
- //// for (var i = 0; i < SpanList.length; i++) { SpanList[i].style[StyleName] = NewStyle }; //让内部所有标签都为该css
- //// SpanFrame.style[StyleName] = NewStyle;
- //// if (BrowserJudge) { range.deleteContents(); range.insertNode(SpanFrame); return; }
- //// if (TextFather.contentEditable == "true" || U.OU.DivisionEW == "Word") { range.pasteHTML(SpanFrame.outerHTML); }
- //// else {
- //// TextFather.style[StyleName] = NewStyle; SpanList = TextFather.getElementsByTagName("*");
- //// for (var i = 0; i < SpanList.length; i++) { SpanList[i].style[StyleName] = NewStyle };
- //// }
- ////}
- ////让回车生成的<p></p>变成<br />
- //U.OU.EditOnkey = function () {
- // var BrowserJudge = !(document.selection); //判断是哪个浏览器
- // var range = BrowserJudge ? window.getSelection().getRangeAt(0) : document.selection.createRange();
- // if (event.keyCode == 13 || event.keyCode == 108) {
- // U.M.StopDefault(); //阻止系统事件
- // var dd = document.createElement("br");
- // if (BrowserJudge) { range.deleteContents(); range.insertNode(dd); }
- // else { range.pasteHTML("<br />"); }
- // }
- // U.M.StopBubble(); //阻止冒泡
- //}
- ////md5加密区域
- //U.M.apply(Namespace.register("U.E"), function () {
- // _$(this).Add({
- // hex_md5: function (s) { return binl2hex(core_md5(str2binl(s), s.length * chrsz)); }, //hash加密
- // b64_md5: function (s) { return binl2b64(core_md5(str2binl(s), s.length * chrsz)); }, //base64加密
- // hex_hmac_md5: function (key, data) { return binl2hex(core_hmac_md5(key, data)); }, //hashkey加密
- // b64_hmac_md5: function (key, data) { return binl2b64(core_hmac_md5(key, data)); }, //base64key加密
- // calcMD5: function (s) { return binl2hex(core_md5(str2binl(s), s.length * chrsz)); }, //md5加密
- // md5_vm_test: function md5_vm_test() {
- // return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
- // },
- // core_md5: function (x, len) {
- // x[len >> 5] |= 0x80 << ((len) % 32);
- // x[(((len + 64) >>> 9) << 4) + 14] = len;
- // var a = 1732584193;
- // var b = -271733879;
- // var c = -1732584194;
- // var d = 271733878;
- // for (var i = 0; i < x.length; i += 16) {
- // var olda = a;
- // var oldb = b;
- // var oldc = c;
- // var oldd = d;
- // a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
- // d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
- // c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
- // b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
- // a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
- // d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
- // c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
- // b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
- // a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
- // d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
- // c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
- // b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
- // a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
- // d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
- // c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
- // b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
- // a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
- // d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
- // c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
- // b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
- // a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
- // d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
- // c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
- // b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
- // a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
- // d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
- // c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
- // b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
- // a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
- // d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
- // c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
- // b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
- // a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
- // d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
- // c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
- // b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
- // a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
- // d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
- // c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
- // b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
- // a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
- // d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
- // c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
- // b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
- // a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
- // d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
- // c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
- // b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
- // a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
- // d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
- // c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
- // b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
- // a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
- // d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
- // c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
- // b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
- // a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
- // d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
- // c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
- // b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
- // a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
- // d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
- // c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
- // b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
- // a = safe_add(a, olda);
- // b = safe_add(b, oldb);
- // c = safe_add(c, oldc);
- // d = safe_add(d, oldd);
- // }
- // return Array(a, b, c, d);
- // },
- // md5_cmn: function (q, a, b, x, s, t) {
- // return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
- // },
- // md5_ff: function (a, b, c, d, x, s, t) {
- // return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
- // },
- // md5_gg: function (a, b, c, d, x, s, t) {
- // return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
- // },
- // md5_hh: function (a, b, c, d, x, s, t) {
- // return md5_cmn(b ^ c ^ d, a, b, x, s, t);
- // },
- // md5_ii: function (a, b, c, d, x, s, t) {
- // return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
- // },
- // core_hmac_md5: function (key, data) {
- // var bkey = str2binl(key);
- // if (bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
- // var ipad = Array(16), opad = Array(16);
- // for (var i = 0; i < 16; i++) {
- // ipad[i] = bkey[i] ^ 0x36363636;
- // opad[i] = bkey[i] ^ 0x5C5C5C5C;
- // }
- // var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
- // return core_md5(opad.concat(hash), 512 + 128);
- // },
- // safe_add: function (x, y) {
- // var lsw = (x & 0xFFFF) + (y & 0xFFFF);
- // var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
- // return (msw << 16) | (lsw & 0xFFFF);
- // },
- // bit_rol: function (num, cnt) {
- // return (num << cnt) | (num >>> (32 - cnt));
- // },
- // str2binl: function (str) {
- // var bin = Array();
- // var mask = (1 << chrsz) - 1;
- // for (var i = 0; i < str.length * chrsz; i += chrsz)
- // bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32);
- // return bin;
- // },
- // binl2hex: function (binarray) {
- // var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
- // var str = "";
- // for (var i = 0; i < binarray.length * 4; i++) {
- // str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) +
- // hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF);
- // }
- // return str;
- // },
- // binl2b64: function (binarray) {
- // var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- // var str = "";
- // for (var i = 0; i < binarray.length * 4; i += 3) {
- // var triplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16)
- // | (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8)
- // | ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF);
- // for (var j = 0; j < 4; j++) {
- // if (i * 8 + j * 6 > binarray.length * 32) str += b64pad;
- // else str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);
- // }
- // }
- // return str;
- // }
- // });
- //})();
- //U.UP.uploading = function () {
- // var _ = function (UDE, UCB, UCT, UAC, UTF, UFID) {//执行上传
- // 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) : "");
- // 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);
- // (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"];
- // 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]); }
- // _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]); };
- // //if (document.selection) { UDE[i].select(); document.selection.clear(); } else { UDE[i].outerHTML += ""; UDE[i].value = ""; } //清空内容
- // },
- // AsynF = function (UDOD, UCB, UDE) { //传输回调
- // try {
- // var _UTH = UDOD.contentWindow.document.body.innerHTML; _UTH = _UTH || (UDOD.contentWindow.name != UDOD.id ? UDOD.contentWindow.name : _UTH);
- // if (_UTH == null) { U.Alert("服务器处理繁忙,上传失败"); } //上传失败
- // try { UDE.value = eval("0,(" + _UTH + ")"); } catch (e) { UDE.value = _UTH; } //返回的值
- // $(UDOD).remove(); UCB(UDE); //回调
- // }
- // catch (e) { U.Alert("文件传输错误!"); }
- // }
- // return function (UDE, UCB, UCT, UAC, UTF) { //生成传输的iframe
- // if (UDE.length > 0) {
- // var _UDBD = document.body, _UFID = Guid.guidNoDash();
- // 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
- // }
- // }
- //}
- /*
- 这里说明1473的命名空间 通用函数的命名空间为U(U里面有自己写的系统控件 如Alert) U是总体的 这个命名空间不可以冲突到 U.Dk硬盘的命名空间 U.D桌面的命名空间 U.F好友的命名空间 U.PB学习系统的命名空间 U.B博客的命名空间 U.AP站外应用的命名空间 U.U用户的命名空间
- 然后每个项目例如 U.Dk硬盘 U.Dk作为主的命名空间 U.Dk为onload加载的 辅助命名空间请看该项目下解说
- UC项目
- 全局应用的命名空间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有思上传封装
- UD项目
- 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桌面新闻区域
- U.DK项目
- 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视图命名空间
- UF项目
- 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好友窗体的命名空间
- UU项目
- U.U为UU项目的命名空间这个命名空间为用户信息函数 U.U.C为用户城市JSON U.U.F为用户找回信息区域 U.U.I为用户弹窗信息区域 U.U.L为用户登录区域 U.U.R为用户注册区域
- 项目暴露后,其他非1473的用户不能使用U US两个变量做命名空间。
- 下面的要专门独立 这个js要干净的 专门放项目的全局变量 这样就好管理。具体要经过实践才能确定。
- var US = {//用户数据树
- userinfo: {}, //用户
- Disk: {}, //网盘
- Blog: {}, //博客
- PB: {}, //论坛
- Friend: {}, //好友
- NLInfo: {}//未登录信息
- */
- //"cp": "28d8089d-ee85-4f9b-b1b6-8c1d8ccff719",
- //"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": ""
- // "TZGG": {
- // "all": "099a06fe-073b-4426-aa20-7703aa94322e",
- // "oper": "37590de6-e3df-4272-bff6-39414f7141d8",
- // "deve": "57dac622-1570-4269-89ed-d4e7b9d9ca4a"
- // },
- //US代表了整个数据,US.userinfo代表了用户数据,US.Disk代表了硬盘数据,以此类推。NLInfo 这个是外联加载的用户数据, 比如用户城市ip等,G暂时未用到 //注册用户变量使用
- //"Category": [US.PB.cp, US.PB.ns, US.PB.pe, US.PB.ie, US.PB.tr, US.PB.sc],
- ////注册命名空间
- //window.Namespace = {
- // Entity: function () { }, //命名空间启动
- // //参数一:UDE为形如:U.D.E的命名空间,参数二:UCE为形如:["userinfo", "Disk", "Blog", "PB", "Friend", "NLInfo", "G"]的集合。
- // register: function (UDE, UCE, UCB) {
- // var i, _UCE, _UWE = window;
- // UDE = UDE.split(".");
- // for (i = 0; i < UDE.length; i++) {
- // _UWE[UDE[i]] = ((i == UDE.length - 1 && UCB) && UCB.call(_UWE)) || _UWE[UDE[i]] || (new Namespace.Entity);
- // _UWE = _UWE[UDE[i]];
- // } //生成命名控件
- // if (UCE) {
- // for (i = 0; i < UCE.length; i++) {
- // _UWE[UCE[i]] = (new Namespace.Entity);
- // }
- // }
- // return _UWE; //生成变量
- // },
- // //参数一:形如:U.CD的自定义变量或者Array,Object等系统变量,UAE为需要添加的属性的集合,形如:{ "domain": "1473.cn", "SystemId": 0}
- // Add: function (UDE, UAE) {
- // for (var i in UAE) {
- // if (UAE.hasOwnProperty(i)) {
- // UDE[i] = UAE[i];
- // }
- // }
- // } //添加
- //};
- /*---------------------------------------- 全局变量注册区域---------------------------------------------------------------------------------------------------- */
- ////主项目的全局变量
- /*
- US.domain 暂时未用到
- US.SystemId 登录系统的id 1是1473系统 0是未知系统 2是手机端
- US.PageId 新Guid,用途为何?
- US.ofs 暂时未用到
- US.fs 文件系统地址
- US.afs 站外应用文件地址
- US.PID 文章根id?
- US.ms 常量
- US.OG 私密文件夹id
- US.SG 上传文件的类型 我的电脑(US.DG) 我的音乐(US.PG) 我的视频(US.SG) 我的图片(US.MG)
- US.FG 我的FTP区域
- US.DG 我的文件
- US.PG 我的图片
- US.MG 我的音乐
- US.VG 我的视频
- US.ER 错误图标地址
- US.Height 屏幕可用高度
- US.Width 屏幕可用宽度
- US.NU 全0的Guid "00000000-0000-0000-0000-000000000000".
- US.ZV 层次z-index属性,默认为20
- 以下为PB的全局变量,好像都没有使用。
- US.PB 为集合
- US.PB.Category
- US.PB.TZGG
- US.PB.News 默认为null,这个变量有使用
- US.PB.YJF
- US.PB.cp
- US.PB.ns
- US.PB.pe
- US.PB.ie
- US.PB.li
- US.PB.tr
- US.PB.sc
- US.PB.zh
- "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": ""
- */
- /*.............................全局兼容及全局立即执行函数-------------------------------------------------------------------*/
- /*
- 需要在window.onload中执行的函数如下:
- 全局兼容在U.MB.js里面。
- U.CI里面的获取浏览器信息window.browser
- 全局函数还需要另外建立文件以便处理。
- */
- /*----------------------1473的命名空间的说明------------------------------*/
- /*
- };
- */
- /**
- * 获取cookie
- *
- * @param {string} 获取cookie的key对应的值 如usestudio=aa=ff&ss=aa 的usestudio里的 aa=ff&ss=aa
- * @param {string} aa=ff&ss=aa里面的aa对应的值 ff
- * @return {string}
- */
- U.M.Cookies.get = function (UKY, UKN) {
- return U.M.GetCookie(UKY, UKN);
- }
- /*-------------------------------暂时未使用函数----------------------*/
- //html编辑器
- U.UI.HtmlEditor = function () {
- var _UFE, _ = function () {
- new _UFE.init();
- }
- _UFE = _.prototype = {
- init: function () { }
- }
- _UFE.init = _UFE;
- return _;
- }
- //#region 拉伸菜单
- U.Menu = function () {
- var _USE, _ = function () { }
- _USE = _.prototype = {
- init: function () { }
- }
- return _;
- };
- U.UI.MenuNA = function (UDE, UDOD) { }
- //#endregion
- /*
- * 非1473跨域获取1473桌面内容。。。。。。。。。。。。。。。。,示例在www.boom.com。。。。。。。。。。。。测试代码,暂时没有用。
- *
- * @param {array} 成功回调
- */
- U.CD.CGQB = function (_cb, _bool) {
- U.MD.IframeLoad($$("iframe", {
- "id": "U_CDomain",
- "name": "U_CDomain",
- "width": 0,
- "height": 0,
- "style": { "display": "none" },
- "src": U.CD.cdom
- }, document.body), [
- [U.CD.AsynCGQB, [_cb, _bool]]
- ]); //初始化1473
- }
- /*
- * 非1473获取桌面
- *
- * @param {function} 回调函数
- */
- U.CD.AsynCGQB = function (_cb, _bool) {
- var _el = this; //当前iframe
- U.MN.message({
- obj: "#U_CDomain",
- url: U.CD.cdom,
- Sender: true,
- me: function (UDE) { //发送获取1473桌面的消息
- var _USE = UDE[2].split("=");
- if (_USE[1] == "") { U.M.Cookies.del(_USE[0]); } //后台设置了cookie 前台同时响应
- else { U.M.Cookies.set(UDE[2]); } //设置新的cookie
- document.wincookie = UDE[2]; //记录cookie
- //1473跨域形式
- if (window["U_Domain"]) {
- if (window["U_Domain"].location.href == U.CD.dom) {
- U.CD.AsynDomain(U.M.apply(null, [
- [U.CD.AsynGQB, [UDE[0], null, _cb]]
- ]));
- return;
- }
- } else { //跨域已经加载成功
- U.CD.Introduce(U.M.apply(null, [
- [U.CD.AsynGQB, [UDE[0], null, _cb]]
- ])); //初始化1473
- }
- $(_el).remove(); //移除多余元素
- },
- url: "http://www.143.cn/Crossdomain.htm"
- }).post("", "cdomain", _bool);
- }
- //#endregion
- //#endregion
- /**
- * 硬盘上传的文件类型判断,所有类型,非病毒文件类型
- *
- * @param {string} 文件类型
- * @param {string} 自定义类型判断 如 "exe,jj" 这两种类型的判断
- * @return {boolean} 类型是否满足
- */
- U.UP.UploadFileType = function (UTP, UTF) {
- var _UFT,
- _UIE = UTF;
- UTP = UTP.substr(UTP.lastIndexOf(".") + 1); //获取文件类型
- (UTF == null) && (UTF = U.UP.SFT("B")); //没有自定义类型 获取病毒类型
- _UFT = UTF.indexOf(UTP) != -1; //判断文件类型
- ((_UIE == null) && (_UFT = (!_UFT))); //病毒类型返回true 否则返回flase
- return _UFT;
- }
- /**
- * 类型选择
- *
- * @param {string} 上传成功回调函数
- */
- //U.UP.SFT = function (UTP) {
- // switch (UTP) {
- // 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"; //我的电脑区域
- // case "P": return "jpg,gif,png,bmp,jpeg,JPG,GIF,BMP,PNG,JPEG"; //相册文件
- // case "M": return "mp3"; //音乐区域
- // case "V": return "wmv,video,ogg,webm,mp4"; //视频区域
- // case "B": return "exe,vbs,vbe,js,jse,wsh,wsf"; //病毒类型
- // case "UP": return ".gif,.GIF,.jpg,.JPG,.jpeg,.JPEG,.png,.PNG,.bmp,.BMP,.rar,.zip"; break; //聊天编辑器允许上传
- // case "CA": return U.UP.SFT("P") + "," + U.UP.SFT("M") + "," + U.UP.SFT("V"); //获取我的电脑除外类型
- // 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文件
- // case "UsestudioOffice": "uw,ue"; //云端office类型
- // case "ComF": return "zip,rar,7z,cab"; //压缩文件类型
- // case "Txt": return "txt,htm,html,css,js"; //文本编辑类型
- // default: return "";
- // }
- //}
- /**
- * 获取上传的样式
- *
- * @param {string} 上传成功回调函数
- */
- //U.UP.XWPGYS = function (UTP) {
- // UTP = UTP.substr(1);
- // var i, _UTF = U.UP.IsDF(UTP),
- // _UDE = {
- // "folder,folderencrypt": ["", "文件夹", "UD_SYWRZOW", null, "UD_SYWLCW"],
- // "docx,doc,uw": ["UD_SYVCOIW", "文档", "UD_SYWRZOD", null, "UD_SYWLCD"],
- // "xls,ue": ["UD_SYVCOIE", "表格", "UD_SYWRZOE", null, "UD_SYWLCE"],
- // "M": ["UD_SYVCOIY", "音乐", "UD_SYWRZOY", null, "UD_SYWLCY"],
- // "V": ["UD_SYVCOIS", "视频", "UD_SYWRZOP", null, "UD_SYWLCP"],
- // "A": ["UD_SYVCOIN", "文件", "UD_SYWRZON", UTP, "UD_SYWLCB"],
- // "P": ["UD_SYVCOIT", "图片", null, UTP]
- // };
- // for (i in _UDE) {
- // if (i.split(",").indexOf(UTP) > -1 || _UTF[0] == i) {
- // return _UDE[i];
- // };
- // }
- //}
- /**
- * 获取网盘中可以上传的文件类型。结构如下:A为网盘,US.DG为目录id,U.UP.SFT('A')为网盘可以上传的文件类型。
- *
- * @param {string} 文件扩展名
- */
- //U.UP.IsDF = function (UTF) {
- // UTF = UTF.toLowerCase(); //全部转换为小写。
- // /*文件分类的类型对应的id 这个在U.M.js 有做说明 这里为4种类型
- // ------[0] 我的网盘类型
- // ------[1] 我的相册类型
- // ------[2] 我的音乐类型
- // ------[3] 我的视频类型
- // */
- // var i, _UDE = [
- // ["A", US.DG, U.UP.SFT("A")], //A为网盘,US.DG为目录id,U.UP.SFT('A')为网盘可以上传的文件类型。
- // ["P", US.PG, U.UP.SFT("P")],
- // ["M", US.MG, U.UP.SFT("M")],
- // ["V", US.VG, U.UP.SFT("V")]
- // ];
- // //筛选使用
- // for (i = 0; i < _UDE.length; i++) {
- // if (_UDE[i][2].indexOf(UTF) > -1) {
- // return _UDE[i];
- // }
- // }
- // return _UDE[0];
- //}
- //#region Ajax上传
- /**
- * ajax上传
- *
- * @param {object} 绕过ajax流程 传参
- * @return {object} ajax上传对象
- */
- U.A.Upload = $.Upload = function (UDE) {
- if ("FormData" in window) { new U.A.Upload.init(UDE); } //允许ajax上传
- else { throw new Error("Browser version is too low"); } //错误处理
- }
- /**
- * ajax上传
- *
- * @param {object} 绕过ajax流程 传参
- ----------[file] 需要上传的文件
- ----------[parameter] 上传传参
- ----------[config] 上传配置
- */
- U.A.Upload.init = function (UDE) { //初始化Jsonp对象
- U.Ut.AddObj(this, UDE);
- }
- U.A.Upload.init.prototype = {
- //创建Ajax上传对象
- create: function () {
- var i = 0,
- _URL = this.url, //请求地址
- _UAE = this.systemAjax = this.CA(), //创建ajax对象
- _UCE = ["progress", "load", "error", "abort"], //事件
- _UDE = this.file, //文件
- _UFE = new FormData(), //生成上传容器
- _UPE = this.parameter, //参数
- _USE = this.config || {},
- _UKE = { "CONTENT-TYPE": "multipart/form-data" }; //默认文件格式配置
- //添加需要上传
- if ((this.tf)) { _UDE = [_UDE]; } else { _UDE = _UDE.files; }
- for (; i < 1; i++) { _UFE.append(Guid.newGuid(), _UDE); } //文件添加
- for (i in _UPE) { _UFE.append(i, _UPE[i]); } //参数添加
- //配置
- (_UAE.overrideMimeType) && (_UAE.overrideMimeType("text/html"));
- _UAE.open("POST", _URL, true); //打开连接
- for (i in _UKE) {
- if (_UKE.hasOwnProperty(i)) { _USE[i] = _USE[i] || _UKE[i] }
- }
- //头部信息添加
- for (i in _USE) {
- try {
- if (i in _UAE) { _UAE[i] = _USE[i]; } else { _UAE.setRequestHeader(i, _USE[i]); }
- } catch (e) { }
- }
- //事件配置
- for (i = 0; i < _UCE.length; i++) { _UAE["on" + _UCE[i]] = U.M.apply(this, _UCE[i]) }
- //发送
- _UAE.send(_UFE);
- },
- //获取或者创建Ajax对象
- CA: function () {
- var i, _UAE, _UDE = U.A.ASet; //获取已停止的Ajax对象
- for (i = 0; i < _UDE.length; i++) {
- if ((_UAE = _UDE[i]).readyState == 4) {
- _UAE.onreadystatechange = U.M.apply();
- _UAE.abort();
- return _UAE;
- }
- }
- _UDE.push((_UAE = new XMLHttpRequest()));
- return _UAE;
- },
- close: function () { //上传取消
- this.systemAjax.abort();
- },
- /**
- * ajax上传
- *
- * @param {event} 进度默认传参
- */
- progress: function (UE) { //Ajax上传进度条
- (this.pro) && (this.pro(UE));
- },
- //上传成功
- load: function () {
- var _USE, _UE = new U.A.Error(),
- _UDE = this.systemAjax;
- //文件上传成功返回值
- if (_UDE.status === 200) {
- _USE = U.M.toList(_UDE.responseText); //生成内容
- if (!_UE.isError(_USE)) {
- (this.lo) && (this.lo({
- r: _UDE, //请求对象
- context: this.context, //回调传参
- error: null, //错误
- value: _USE //返回参数
- }));
- }
- }
- //错误处理
- else { this.error(_USE); }
- },
- /**
- * 错误处理
- *
- * @param {event} 进度默认传参
- */
- error: function (UDE) { //上传错误处理
- (this.err) && (this.err(UDE || {
- State: "500", //错误状态
- LogID: Guid.newGuid(), //错误识别id
- Value: "502 Bad Gateway", //错误内容
- Dt: new Date(), //错误发生时间
- Type: "Ajax" //错误类型
- }));
- },
- /**
- * 错误处理
- *
- * @param {event} 取消上传默认事件
- */
- abort: function (UE) { //中断上传的时候使用
- (this.ab) && (this.ab(UE));
- }
- }
- Namespace.register("U.CV");
- //#region socket消息区域
- //设置文件读取
- U.CV.UL = function (URL, UOE, UEE, UME) {
- return new U.CV.ULinit(URL, UOE, UME).create(UME);
- }
- //获取文件设置
- U.CV.ULinit = function (URL, UOE, UME) {
- this.USK; this.URL = URL || window.location.protocol + "//" + window.location.host; this.UOE = UOE;
- }
- //文件使用方法
- U.CV.ULinit.prototype = {
- sockets: {},
- events: ["connect", "connect_failed", "error", "reconnecting", "reconnect", "disconnect"], //事件源
- create: function (UME) { //创建socketio
- if (this.sockets[this.URL]) { return this.sockets[this.URL]; }
- else {
- U.MD.DynamicLoad("http://socketio.1473.cn/socket.io/socket.io.js", "js", U.M.apply(this, [[this.Asyncreate, [UME]]])); //创建socketio文件
- return this;
- }
- },
- Asyncreate: function (UME) { //创建连接socket连接
- 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通道
- for (i = 0; i < _UDE.length; i++) { _USE.on(_UDE[i], this[_UDE[i]]); } //事件监视
- for (i in _UOE) { if (_UOE.hasOwnProperty(i)) { _USE.on(i, U.M.apply(this, [[this.asyn, [_UOE[i]]]])); } } //添加消息接收设置
- for (i = 0; i < _UEE.length; i++) { this.emit.apply(this, U.Ut.isArguments(_UEE[i]) ? _UEE[i] : [_UEE[i]]); } this.UEE = []; //设置socket连接
- },
- abort: function () { //关闭连接
- this.USK.disconnect();
- },
- asyn: function (UDE) { //获取消息接收
- var _UAE = Array.prototype.slice.call(arguments); _UAE.splice(0, 1);
- (UDE) && (UDE.apply(null, _UAE)); //接收消息回调
- },
- on: function () { //绑定值
- var _UDE = arguments, _USE = this.USK;
- if (_UDE.length > 1) { _USE.on(_UDE[0], U.M.apply(this, [[this.on, [_UDE[1]]]])); } //设置
- else if (U.Ut.isObject(_UDE)) { _UDE.Each(function (UVE, UIE) { _USE.on(_UIE, U.M.apply(this, [[this.on, [asyn]]])); }) }
- },
- emit: function (UME) { //发送消息
- var i, _USE = this.USK;
- if (_USE) { if (U.Ut.isString(UME)) { _USE.emit.apply(_USE, arguments); } else { _$(UME).Each(function (UDE, UIE) { _USE.emit(UIE, UDE[UIE]); }); } } //发送消息
- else { (!this.UEE) && (this.UEE = []); this.UEE.push(U.Ut.isString(UME) ? arguments : UME); } return this; //等待消息发送
- },
- connect: function (UE) { //连接成功
- },
- "connect_failed": function (UE) { //无法连接到服务器
- },
- error: function () { //连接失败
- },
- reconnecting: function () { //不断的连接服务器
- },
- reconnect: function () { //重连成功
- },
- disconnect: function () { //退出连接
- }
- };
- //文件使用方法
- //U.M.Setprototype(U.CV.ULinit, {
- // sockets: {},
- // events: ["connect", "connect_failed", "error", "reconnecting", "reconnect", "disconnect"], //事件源
- // create: function (UME) { //创建socketio
- // if (this.sockets[this.URL]) { return this.sockets[this.URL]; }
- // else {
- // U.MD.DynamicLoad("http://socketio.1473.cn/socket.io/socket.io.js", "js", U.M.apply(this, [[this.Asyncreate, [UME]]])); //创建socketio文件
- // return this;
- // }
- // },
- // Asyncreate: function (UME) { //创建连接socket连接
- // 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通道
- // for (i = 0; i < _UDE.length; i++) { _USE.on(_UDE[i], this[_UDE[i]]); } //事件监视
- // for (i in _UOE) { if (_UOE.hasOwnProperty(i)) { _USE.on(i, U.M.apply(this, [[this.asyn, [_UOE[i]]]])); } } //添加消息接收设置
- // for (i = 0; i < _UEE.length; i++) { this.emit.apply(this, U.Ut.isArguments(_UEE[i]) ? _UEE[i] : [_UEE[i]]); } this.UEE = []; //设置socket连接
- // },
- // abort: function () { //关闭连接
- // this.USK.disconnect();
- // },
- // asyn: function (UDE) { //获取消息接收
- // var _UAE = Array.prototype.slice.call(arguments); _UAE.splice(0, 1);
- // (UDE) && (UDE.apply(null, _UAE)); //接收消息回调
- // },
- // on: function () { //绑定值
- // var _UDE = arguments, _USE = this.USK;
- // if (_UDE.length > 1) { _USE.on(_UDE[0], U.M.apply(this, [[this.on, [_UDE[1]]]])); } //设置
- // else if (U.Ut.isObject(_UDE)) { _UDE.Each(function (UVE, UIE) { _USE.on(_UIE, U.M.apply(this, [[this.on, [asyn]]])); }) }
- // },
- // emit: function (UME) { //发送消息
- // var i, _USE = this.USK;
- // if (_USE) { if (U.Ut.isString(UME)) { _USE.emit.apply(_USE, arguments); } else { _$(UME).Each(function (UDE, UIE) { _USE.emit(UIE, UDE[UIE]); }); } } //发送消息
- // else { (!this.UEE) && (this.UEE = []); this.UEE.push(U.Ut.isString(UME) ? arguments : UME); } return this; //等待消息发送
- // },
- // connect: function (UE) { //连接成功
- // },
- // "connect_failed": function (UE) { //无法连接到服务器
- // },
- // error: function () { //连接失败
- // },
- // reconnecting: function () { //不断的连接服务器
- // },
- // reconnect: function () { //重连成功
- // },
- // disconnect: function () { //退出连接
- // }
- //});
- //#endregion
- //#region 本地存储
- Namespace.register("U.DW");
- /**
- * 异步加载跨域
- *
- * @param {boolean} 是否存储永不过期
- * @param {object} 存储传参对象
- * @return {object} 本地存储使用对象
- */
- U.DW.local = function (UTP, UDE) {
- if ((!browser.msie || Number(browser.ver[2]) > 6)) {
- try {
- var _UDE = new Date(); //当前时间
- (!UTP) && (_UDE.setTime(_UDE.getTime() + (9999 * 24 * 60 * 60 * 1000)), _UBE.expires = _UDE.toUTCString()); //设置永不过期
- } catch (e) { }
- }
- return new U.DW.local.init(UTP); //初始化
- }
- /**
- * 初始化本地存储查看
- *
- * @param {boolean} 是否存储永不过期
- * @param {boolean} 存储传参对象
- * @return {object} 本地存储使用对象
- */
- U.DW.local.init = function (UTP, UDE) {
- U.Ut.AddObj(this, {
- UTP: UTP, //是否永不过期
- UTF: (this.UJE = (UTP ? window.sessionStorage : window.localStorage)), //存储对象
- UJE: this.UJE || $$("input", { "type": "hidden", "style": { "behavior": "url(#default#userdata)"} }, document.body), //ie存储对象
- UDE: UDE || {}, //传参使用
- UGE: null,
- scb: null,
- date: {}
- }); //变量
- //事件绑定
- (UDE && UDE.event) && (this.on(UDE.event));
- return this;
- }
- /**
- * 兼容storage事件触发 ie8-
- *
- * @param {object} U.DW.local实例对象
- */
- U.DW.local._cb = function (UTH) {
- clearInterval(UTH.UTI); //计时器取消
- UTH.UTI = setInterval(function () { //计时器消息
- var _UDE = U.DW.local.iep(UTH); //ie兼容处理
- (_UDE && UTH.UDE.event) && (UTH.UDE.event(_UDE));
- }, 5000);
- };
- /**
- * ie兼容属性设置
- *
- * @param {object} U.DW.local实例对象
- * @param {event} 上storage事件
- * @return {event} storage事件
- */
- U.DW.local.iep = function (UTH, UE) {
- var i,
- _UOE = UTH.date, //变化前的值
- _UNE = UTH.UJE; //变化的对象
- UTH.date = U.DW.local.get(UTH), //获取所有的变化内容
- _UKE = UTH.getAllKey(); //获取所有的key
- for (i = 0; i < _UKE.length; i++) {
- if (_UOE[_UKE[i]] != _UNE[_UKE[i]]) { //判断是否key产生了变化
- return { //返回最新的 ie storgeevent
- Property: null,
- key: _UKE[i], //变化的key值
- oldValue: _UOE[_UKE[i]], //上一次的值
- newValue: _UNE[_UKE[i]], //最新的值
- url: UE ? (UE.url || UE.uri) : document.location.host //链接处理
- };
- }
- }
- }
- /**
- * ie获取变化内容
- *
- * @param {object} U.DW.local实例对象
- * @return {object} event值
- */
- U.DW.local.get = function (UTH) {
- var i, _UKE; UTH.date = [];
- if (browser.ver[1] == "msie" && browser.ver[2].toInt() < 9) { //ie9- 处理
- _UKE = UTH.getAllKey(); //获取所有的key
- for (i = 0; i < _UKE.length; i++) { //获取所有的值 同时设置到 date里
- UTH.date[_UKE[i]] = UTH.UJE[_UKE[i]];
- }
- }
- return UTH.date;
- }
- U.DW.local.init.prototype = {
- /**
- * 事件绑定
- *
- * @param {object} U.DW.local实例对象
- */
- on: function (UDE) {
- this.off(); //事件取消
- this.UDE.event = UDE;
- this.scb = U.M.apply(this, this["storage"]); //事件
- U.DW.local.get(this); //
- this.UTF ? (U.M.AddEvent("storage", window, this.scb), U.M.AddEvent("storage", document, this.scb)) : U.DW.local._cb(this, this.getAll()); //
- },
- //事件绑定取消
- off: function () {
- this.UTF ? (U.M.ReEvent("storage", window, this.scb), U.M.ReEvent("storage", document, this.scb)) : clearInterval(this.UTI); //移除storage绑定 去除计时
- },
- /**
- * 设置值
- *
- * @param {object}需要存储的值 如
- -----------{id:"aaa"}
- * @param {string} 值
- ----------当这个参数存在的使用 参数一是 string的key 这个参数为值
- * @return {object} 对象
- */
- set: function (UDE, USE) { //
- if (this.UJE) {
- var i, _UME = this.UJE;
- (USE != null) && (i = UDE, UDE = {}, UDE[i] = USE);
- //设置存储的值
- for (i in UDE) {
- (UDE.hasOwnProperty(i)) && (this.UTF ? _UME.setItem(i, UDE[i]) : (_UME.setAttribute(i, UDE[i]), _UME.save("us")));
- }
- }
- return this;
- },
- /**
- * storage事件回调
- * @param {number} U.DW.local实例对象
- */
- storage: function (UE) {
- if (this.UDE.event) {
- var _UCB = this.UDE.event; //storage 事件回调函数
- if (UE.newValue == null) { //storage是新值改变
- UE = U.DW.local.iep(this); //生成 storgeevent事件
- }
- (_UCB && UE) && (_UCB(UE)); //回到到指定
- U.M.StopBubble(); //
- }
- },
- /**
- * 事件绑定
- * @param {number} U.DW.local实例对象
- * @param {number} U.DW.local实例对象
- */
- get: function (UIE) { //获取值
- if (this.UJE) {
- var i, _UME = this.UJE,
- _USE = {},
- _UTP = this.UTF ? "getItem" : (_UME.load("us"), "getAttribute");
- if (U.Ut.isString(UIE)) { //普通字符串获取
- return _UME[_UTP](UIE);
- }
- if (U.Ut.isArray(UIE)) { //数组获取
- for (i = 0; i < UIE.length; i++) {
- _USE[UIE[i]] = _UME[_UTP](UIE[i]);
- }
- }
- else if (U.Ut.isObject(UIE)) { //对象获取
- for (i in UIE) { (UIE.hasOwnProperty(i)) && (_USE[i] = _UME[_UTP](i)); }
- }
- return _USE;
- }
- },
- /**
- * 获取所有的值
- * @return {number} U.DW.local实例对象
- */
- getAll: function () {
- var i, _UKE, _USE = {},
- _UME = this.UJE;
- if (this.UTF) { //h5处理
- for (i = 0; i < _UME.length; i++) {
- _UKE = this.key(i); //获取指定的位置的key
- _USE[_UKE] = this.get(_UKE); //根据key获取值
- }
- }
- else { //ie处理
- _UME = _UME.XMLDocument.documentElement.attributes;
- for (i = 0; i < _UME.length; i++) {
- _USE[_UME[i].name] = _UME[i].nodeValue;
- }
- }
- return _USE;
- },
- //获取所有的键
- getAllKey: function () {
- if (this.UJE) {
- var _UME = this.UJE,
- _USE = [];
- if (this.UTF) {
- for (i = 0; i < _UME.length; i++) {
- _USE.push(this.key(i));
- }
- }
- else {
- _UME = _UME.XMLDocument.documentElement.attributes;
- for (i = 0; i < _UME.length; i++) { _USE.push(_UME[i].name); }
- }
- return _USE;
- }
- },
- /**
- * 移除值
- * @param {string 、 object} 移除的键值
- * @return {object} 本地存储类
- */
- remove: function (UIE) {
- if (this.UJE) {
- var i,
- _UME = this.UJE,
- _UTP = this.UTF ? "removeItem" : "removeAttribute"; //兼容删除的内容
- if (U.Ut.isString(UIE)) { //普通删除
- _UME[_UTP](UIE);
- }
- else if (U.Ut.isArray(UIE)) { //普通的通过key删除
- for (i = 0; i < UIE.length; i++) {
- _UME[_UTP](UIE[i]);
- }
- }
- else { //对象删除
- for (i in UIE) {
- (UIE.hasOwnProperty(i)) && (_UME[_UTP](i));
- }
- }
- (!this.UTF) && (_UME.save("us")); //ie还需要保存操作
- } return this;
- },
- //移除所有的存储
- clear: function () {
- if (this.UJE) {
- if (this.UTF) { this.UJE.clear(); } //HTML5
- else { //ie处理删除
- var i, _UME = this.UJE;
- _UME.load("us");
- _UME = _UME.XMLDocument.documentElement.attributes; //所有的本地存储属性
- for (i = 0; i < _UME.length; i++) { _UME.remove(_UME[i].name); } //循环删除
- }
- }
- },
- /**
- * 索引值
- * @param {string} 键值
- * @return {string} 键值对应值
- */
- key: function (UI) {
- if (this.UJE) {
- if (this.UTF) { //html5获取值
- return this.UJE.key(UI);
- }
- else { //ie获取
- var _UME = this.UJE;
- _UME.load("us"), //获取所有存储的值
- _UDM = _UME.XMLDocument.documentElement.attrbutes;
- if (_UDM[UI]) { //判断是否存在该键值的值
- return _UDM[UI].name;
- }
- }
- }
- },
- //获取长度
- length: function () {
- if (this.UJE) {
- if (this.UTF) { return this.UJE.length; } //html5获取值
- else { //ie获取
- var _UL, _UDM,
- _UME = this.UJE;
- _UME.load("us");
- _UDM = _UME.XMLDocument; //获取所有存储的值
- ((_UDM = _UDM.childNodes[0]) && (_UL = _UDM.attributes.length));
- return _UL;
- }
- }
- }
- }
- //#endregion
- //#region 加密区域
- Namespace.register("U.E"); //加密
- /*
- 功能:前端加密函数,暂未使用
- */
- U.E.CryptoJS = function (s, p) {
- var m = {}, l = m.lib = {}, n = function () {
- }, r = l.Base = { extend: function (b) {
- n.prototype = this;
- var h = new n;
- b && h.mixIn(b);
- h.hasOwnProperty("init") || (h.init = function () {
- h.$super.init.apply(this, arguments)
- });
- h.init.prototype = h;
- h.$super = this;
- return h
- }, create: function () {
- var b = this.extend();
- b.init.apply(b, arguments);
- return b
- }, init: function () {
- }, mixIn: function (b) {
- for (var h in b)
- b.hasOwnProperty(h) && (this[h] = b[h]);
- b.hasOwnProperty("toString") && (this.toString = b.toString)
- }, clone: function () {
- return this.init.prototype.extend(this)
- }
- },
- q = l.WordArray = r.extend({ init: function (b, h) {
- b = this.words = b || [];
- this.sigBytes = h != p ? h : 4 * b.length
- }, toString: function (b) {
- return (b || t).stringify(this)
- }, concat: function (b) {
- var h = this.words, a = b.words, j = this.sigBytes;
- b = b.sigBytes;
- this.clamp();
- if (j % 4)
- for (var g = 0; g < b; g++)
- h[j + g >>> 2] |= (a[g >>> 2] >>> 24 - 8 * (g % 4) & 255) << 24 - 8 * ((j + g) % 4);
- else if (65535 < a.length)
- for (g = 0; g < b; g += 4)
- h[j + g >>> 2] = a[g >>> 2];
- else
- h.push.apply(h, a);
- this.sigBytes += b;
- return this
- }, clamp: function () {
- var b = this.words, h = this.sigBytes;
- b[h >>> 2] &= 4294967295 <<
- 32 - 8 * (h % 4);
- b.length = s.ceil(h / 4)
- }, clone: function () {
- var b = r.clone.call(this);
- b.words = this.words.slice(0);
- return b
- }, random: function (b) {
- for (var h = [], a = 0; a < b; a += 4)
- h.push(4294967296 * s.random() | 0);
- return new q.init(h, b)
- }
- }), v = m.enc = {}, t = v.Hex = { stringify: function (b) {
- var a = b.words;
- b = b.sigBytes;
- for (var g = [], j = 0; j < b; j++) {
- var k = a[j >>> 2] >>> 24 - 8 * (j % 4) & 255;
- g.push((k >>> 4).toString(16));
- g.push((k & 15).toString(16))
- }
- return g.join("")
- }, parse: function (b) {
- for (var a = b.length, g = [], j = 0; j < a; j += 2)
- g[j >>> 3] |= parseInt(b.substr(j,
- 2), 16) << 24 - 4 * (j % 8);
- return new q.init(g, a / 2)
- }
- }, a = v.Latin1 = { stringify: function (b) {
- var a = b.words;
- b = b.sigBytes;
- for (var g = [], j = 0; j < b; j++)
- g.push(String.fromCharCode(a[j >>> 2] >>> 24 - 8 * (j % 4) & 255));
- return g.join("")
- }, parse: function (b) {
- for (var a = b.length, g = [], j = 0; j < a; j++)
- g[j >>> 2] |= (b.charCodeAt(j) & 255) << 24 - 8 * (j % 4);
- return new q.init(g, a)
- }
- }, u = v.Utf8 = { stringify: function (b) {
- try {
- return decodeURIComponent(escape(a.stringify(b)))
- } catch (g) {
- throw Error("Malformed UTF-8 data");
- }
- }, parse: function (b) {
- return a.parse(unescape(encodeURIComponent(b)))
- }
- },
- g = l.BufferedBlockAlgorithm = r.extend({ reset: function () {
- this._data = new q.init;
- this._nDataBytes = 0
- }, _append: function (b) {
- "string" == typeof b && (b = u.parse(b));
- this._data.concat(b);
- this._nDataBytes += b.sigBytes
- }, _process: function (b) {
- 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);
- b = m * k;
- j = s.min(4 * b, j);
- if (b) {
- for (var l = 0; l < b; l += k)
- this._doProcessBlock(g, l);
- l = g.splice(0, b);
- a.sigBytes -= j
- }
- return new q.init(l, j)
- }, clone: function () {
- var b = r.clone.call(this);
- b._data = this._data.clone();
- return b
- }, _minBufferSize: 0
- });
- l.Hasher = g.extend({ cfg: r.extend(), init: function (b) {
- this.cfg = this.cfg.extend(b);
- this.reset()
- }, reset: function () {
- g.reset.call(this);
- this._doReset()
- }, update: function (b) {
- this._append(b);
- this._process();
- return this
- }, finalize: function (b) {
- b && this._append(b);
- return this._doFinalize()
- }, blockSize: 16, _createHelper: function (b) {
- return function (a, g) {
- return (new b.init(g)).finalize(a)
- }
- }, _createHmacHelper: function (b) {
- return function (a, g) {
- return (new k.HMAC.init(b,
- g)).finalize(a)
- }
- }
- });
- var k = m.algo = {};
- return m
- } (Math);
- (function (s) {
- function p(a, k, b, h, l, j, m) {
- a = a + (k & b | ~k & h) + l + m;
- return (a << j | a >>> 32 - j) + k
- }
- function m(a, k, b, h, l, j, m) {
- a = a + (k & h | b & ~h) + l + m;
- return (a << j | a >>> 32 - j) + k
- }
- function l(a, k, b, h, l, j, m) {
- a = a + (k ^ b ^ h) + l + m;
- return (a << j | a >>> 32 - j) + k
- }
- function n(a, k, b, h, l, j, m) {
- a = a + (b ^ (k | ~h)) + l + m;
- return (a << j | a >>> 32 - j) + k
- }
- for (var r = U.E.CryptoJS, q = r.lib, v = q.WordArray, t = q.Hasher, q = r.algo, a = [], u = 0; 64 > u; u++)
- a[u] = 4294967296 * s.abs(s.sin(u + 1)) | 0;
- q = q.MD5 = t.extend({ _doReset: function () {
- this._hash = new v.init[1732584193, 4023233417, 2562383102, 271733878]
- },
- _doProcessBlock: function (g, k) {
- for (var b = 0; 16 > b; b++) {
- var h = k + b, w = g[h];
- g[h] = (w << 8 | w >>> 24) & 16711935 | (w << 24 | w >>> 8) & 4278255360
- }
- 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]),
- 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,
- 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,
- 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]);
- b[0] = b[0] + c | 0;
- b[1] = b[1] + d | 0;
- b[2] = b[2] + e | 0;
- b[3] = b[3] + f | 0
- }, _doFinalize: function () {
- var a = this._data, k = a.words, b = 8 * this._nDataBytes, h = 8 * a.sigBytes;
- k[h >>> 5] |= 128 << 24 - h % 32;
- var l = s.floor(b /
- 4294967296);
- k[(h + 64 >>> 9 << 4) + 15] = (l << 8 | l >>> 24) & 16711935 | (l << 24 | l >>> 8) & 4278255360;
- k[(h + 64 >>> 9 << 4) + 14] = (b << 8 | b >>> 24) & 16711935 | (b << 24 | b >>> 8) & 4278255360;
- a.sigBytes = 4 * (k.length + 1);
- this._process();
- a = this._hash;
- k = a.words;
- for (b = 0; 4 > b; b++)
- h = k[b], k[b] = (h << 8 | h >>> 24) & 16711935 | (h << 24 | h >>> 8) & 4278255360;
- return a
- }, clone: function () {
- var a = t.clone.call(this);
- a._hash = this._hash.clone();
- return a
- }
- });
- r.MD5 = t._createHelper(q);
- r.HmacMD5 = t._createHmacHelper(q)
- })(Math);
- //#endregion
- //------------------键盘处理类
- Namespace.register("U.K");
- //#region 全局变量区域
- //变量来存储_MAP的翻转版从上面
- U.K._REVERSE_MAP;
- //特殊键码的映射到其对应的键
- U.K._MAP = {
- 8: 'backspace',
- 9: 'tab',
- 13: 'enter',
- 16: 'shift',
- 17: 'ctrl',
- 18: 'alt',
- 20: 'capslock',
- 27: 'esc',
- 32: 'space',
- 33: 'pageup',
- 34: 'pagedown',
- 35: 'end',
- 36: 'home',
- 37: 'left',
- 38: 'up',
- 39: 'right',
- 40: 'down',
- 45: 'ins',
- 46: 'del',
- 91: 'meta',
- 93: 'meta',
- 224: 'meta'
- };
- //特殊字符,使他们能够支持映射
- U.K._KEYCODE_MAP = {
- 106: '*',
- 107: '+',
- 109: '-',
- 110: '.',
- 111: '/',
- 186: ';',
- 187: '=',
- 188: ',',
- 189: '-',
- 190: '.',
- 191: '/',
- 192: '`',
- 219: '[',
- 220: '\\',
- 221: ']',
- 222: '\''
- };
- //这是需要一个美国小键盘上的shift键的映射
- U.K._SHIFT_MAP = {
- '~': '`',
- '!': '1',
- '@': '2',
- '#': '3',
- '$': '4',
- '%': '5',
- '^': '6',
- '&': '7',
- '*': '8',
- '(': '9',
- ')': '0',
- '_': '-',
- '+': '=',
- ':': ';',
- '\"': '\'',
- '<': ',',
- '>': '.',
- '?': '/',
- '|': '\\'
- };
- //这是你可以用它来绘制特殊字符串列表
- U.K._SPECIAL_ALIASES = {
- 'option': 'alt',
- 'command': 'meta',
- 'return': 'enter',
- 'escape': 'esc',
- 'plus': '+',
- 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'
- };
- U.K.start = function () {
- //遍历F键,F1至F19,并把它们添加到地图
- for (var i = 1; i < 20; ++i) {
- U.K._MAP[111 + i] = 'f' + i;
- }
- //数字键盘的数字添加
- for (i = 0; i <= 9; ++i) {
- U.K._MAP[i + 96] = i.toString();
- }
- }
- //#endregion
- //#region 方法使用区域
- //取事件,并返回的键值
- U.K._characterFromEvent = function (e) {
- //为按键事件,我们应该回到该字符是
- if (e.type == 'keypress') {
- var character = String.fromCharCode(e.which);
- // 如果没有然后按下Shift键它是安全的假设
- // 我们想要的字符是小写。这意味着,如果
- // 你不小心有大写锁定,然后键绑定
- // 将继续工作
- //
- // 可能是不希望的唯一副作用是,如果你
- // 绑定类似'A',因为你要触发
- // 事件被按下大写字母A时,大写锁定将不再
- // 触发事件。尽管绑定了shift+a。
- if (!e.shiftKey) {
- character = character.toLowerCase();
- }
- return character;
- }
- // 非按键事件所需的专用地图
- if (U.K._MAP[e.which]) {
- return U.K._MAP[e.which];
- }
- if (U.K._KEYCODE_MAP[e.which]) {
- return U.K._KEYCODE_MAP[e.which];
- }
- // 如果它不是在特殊的地图
- // 与KEYDOWN和KeyUp事件的性质似乎总
- // 进来作为一个大写字符无论您是按住Shift
- // 或不。我们应该确保它始终是小写的比较
- return String.fromCharCode(e.which).toLowerCase();
- }
- /**
- * 检查,如果两个数组相等,
- *
- * @param {Array} modifiers1
- * @param {Array} modifiers2
- * @returns {boolean}
- */
- U.K._modifiersMatch = function (modifiers1, modifiers2) {
- return modifiers1.sort().join(',') === modifiers2.sort().join(',');
- }
- /**
- * 需要一个关键事件,并计算出的修饰符是什么
- *
- * @param {Event} e
- * @returns {Array}
- */
- U.K._eventModifiers = function (e) {
- var modifiers = [];
- if (e.shiftKey) {
- modifiers.push('shift');
- }
- if (e.altKey) {
- modifiers.push('alt');
- }
- if (e.ctrlKey) {
- modifiers.push('ctrl');
- }
- if (e.metaKey) {
- modifiers.push('meta');
- }
- return modifiers;
- }
- /**
- * 确定指定的键码是一个修改键或不
- *
- * @param {string} key
- * @returns {boolean}
- */
- U.K._isModifier = function (key) {
- return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';
- }
- /**
- * 颠倒了地图查找,这样我们可以寻找特定键
- *看看有什么可以和不能使用的按键
- *
- * @return {Object}
- */
- U.K._getReverseMap = function () {
- if (!_REVERSE_MAP) {
- _REVERSE_MAP = {};
- for (var key in U.K._MAP) {
- //从这里拉出数字小键盘按键的事业宜
- //能够从字符检测的按键
- if (key > 95 && key < 112) {
- continue;
- }
- if (U.K._MAP.hasOwnProperty(key)) {
- _REVERSE_MAP[U.K._MAP[key]] = key;
- }
- }
- }
- return _REVERSE_MAP;
- }
- /**
- * 挑选基础上,组合键最佳动作
- *
- * @param {string} key - character for key
- * @param {Array} modifiers
- * @param {string=} action passed in
- */
- U.K._pickBestAction = function (key, modifiers, action) {
- //如果没有动作,拿起我们应该尽量挑选一个
- //我们认为将工作最适合这一关键
- if (!action) {
- action = U.K._getReverseMap()[key] ? 'keydown' : 'keypress';
- }
- //与预期的按键组合键不起作用,
- //切换到KEYDOWN
- if (action == 'keypress' && modifiers.length) {
- action = 'keydown';
- }
- return action;
- }
- /**
- * *从一个字符串组合键转换到一个数组
- *
- * @param {string} 的组合,如 "command+shift+l"
- * @return {Array}
- */
- U.K._keysFromString = function (combination) {
- if (combination === '+') {
- return ['+'];
- }
- combination = combination.replace(/\+{2}/g, '+plus');
- return combination.split('+');
- }
- /**
- * Gets 获取信息的特定的组合键
- *
- * @param {string} combination key combination ("command+s" or "a" or "*")
- * @param {string=} action
- * @returns {Object}
- */
- U.K._getKeyInfo = function (combination, action) {
- var keys;
- var key;
- var i;
- var modifiers = [];
- // 从这种模式带钥匙,弄清实际
- // 模式是所有
- keys = U.K._keysFromString(combination);
- for (i = 0; i < keys.length; ++i) {
- key = keys[i];
- // normalize key names
- if (U.K._SPECIAL_ALIASES[key]) {
- key = U.K._SPECIAL_ALIASES[key];
- }
- //如果这不是一个按键事件那么我们应该
- //聪明地使用shift键
- //这只会为我们工作不过键盘
- if (action && action != 'keypress' && U.K._SHIFT_MAP[key]) {
- key = U.K._SHIFT_MAP[key];
- modifiers.push('shift');
- }
- //如果该键是一个修改,然后将其添加到修改器列表
- if (U.K._isModifier(key)) {
- modifiers.push(key);
- }
- }
- //根据密钥的组合是什么
- //我们会尽力挑选最好的事件它
- action = U.K._pickBestAction(key, modifiers, action);
- return {
- key: key,
- modifiers: modifiers,
- action: action
- };
- }
- //判断监听来源
- U.K._belongsTo = function (element, ancestor) {
- if (element === null || element === document) {
- return false;
- }
- if (element === ancestor) {
- return true;
- }
- return U.K._getReverseMap(element.parentNode, ancestor);
- }
- //#endregion
- //#region 对外接口区域
- //对外公布函数
- U.K.Mousetrap = function (targetElement) {
- var self = this;
- targetElement = targetElement || document;
- if (!(self instanceof U.K.Mousetrap)) {
- return new U.K.Mousetrap(targetElement);
- }
- /**
- * 元素附加关键事件
- *
- * @type {Element}
- */
- self.target = targetElement;
- /**
- * 通过Mousetrap.bind所有的回调设置列表()
- *
- * @type {Object}
- */
- self._callbacks = {};
- /**
- * 字符串组合的直接映射到用于触发回调()
- *
- * @type {Object}
- */
- self._directMap = {};
- /**
- * 跟踪什么级别的每个序列是因为多个
- *序列可以开始时具有相同的序列
- *
- * @type {Object}
- */
- var _sequenceLevels = {};
- /**
- * 变量来存储方法setTimeout
- *
- * @type {null|number}
- */
- var _resetTimer;
- /**
- * 临时的状态,我们会忽略下一个KEYUP
- *
- * @type {boolean|string}
- */
- var _ignoreNextKeyup = false;
- /**
- * 临时的状态,我们会忽略下一个按键
- *
- * @type {boolean}
- */
- var _ignoreNextKeypress = false;
- /**
- * 是我们目前的序列里面?
- * acticon(“KEYUP”或“的keydown”或“keypress”)或flase的类型
- *
- * @type {boolean|string}
- */
- var _nextExpectedAction = false;
- /**
- * 重置所有序列柜台,除了传递的那些
- *
- * @param {Object} doNotReset
- * @returns void
- */
- function _resetSequences(doNotReset) {
- doNotReset = doNotReset || {};
- var activeSequences = false,
- key;
- for (key in _sequenceLevels) {
- if (doNotReset[key]) {
- activeSequences = true;
- continue;
- }
- _sequenceLevels[key] = 0;
- }
- if (!activeSequences) {
- _nextExpectedAction = false;
- }
- }
- /**
- * *查找匹配基础上的keyCode,所有的callback,modifiers,action
- *
- * @param {string} character
- * @param {Array} modifiers
- * @param {Event|Object} e
- * @param {string=} sequenceName - name of the sequence we are looking for
- * @param {string=} combination
- * @param {number=} level
- * @returns {Array}
- */
- function _getMatches(character, modifiers, e, sequenceName, combination, level) {
- var i;
- var callback;
- var matches = [];
- var action = e.type;
- // 如果没有与此相关的键码的事件
- if (!self._callbacks[character]) {
- return [];
- }
- // 如果修改键快到了自身,我们应该允许它
- if (action == 'keyup' && U.K._isModifier(character)) {
- modifiers = [character];
- }
- // 通过被按下该键所有的回调循环
- //,看看其中是否匹配
- for (i = 0; i < self._callbacks[character].length; ++i) {
- callback = self._callbacks[character][i];
- //如果一个序列名未指定,但是这是一个序列的
- //错误的水平,那么移动到下一个match
- if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {
- continue;
- }
- // //如果我们正在寻找的action不符合我们的action
- //那么我们就应该继续执行
- if (action != callback.action) {
- continue;
- }
- //如果这是一个keypress event和meta和control key
- //没有按下这意味着我们只需要看
- //字符,否则检查改性剂以及
- //
- // Chrome浏览器不会触发一个keypress如果meta or control is down
- // Safari会触发一个 keypress 如果 meta or meta+shift is down
- // Firefox会触发一个keypress 如果 meta or control is down
- if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || U.K._modifiersMatch(modifiers, callback.modifiers)) {
- //当你绑定的组合或序列的第二次它
- //应该覆盖的第一个。如果sequenceName或
- //组合在这个指定的调用它做到了这一点
- //
- //@todo使删除它自己的方法?
- var deleteCombo = !sequenceName && callback.combo == combination;
- var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;
- if (deleteCombo || deleteSequence) {
- self._callbacks[character].splice(i, 1);
- }
- matches.push(callback);
- }
- }
- return matches;
- }
- /**
- * 实际调用回调函数
- *
- *
- *
- *如果您的回调函数返回false,这将使用jQuery的
- * convention - 防止违约和对事件停止传播史
- *
- * @param {Function} callback
- * @param {Event} e
- * @returns void
- */
- function _fireCallback(callback, e, combo, sequence) {
- // //如果此事件不应该发生到此为止
- if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
- return;
- }
- if (callback(e, combo) === false) {
- U.M.StopDefault(e);
- U.M.StopBubble(e);
- }
- }
- /**
- * 处理一个字符键事件
- *
- * @param {string} character
- * @param {Array} modifiers
- * @param {Event} e
- * @returns void
- */
- self._handleKey = function (character, modifiers, e) {
- var callbacks = _getMatches(character, modifiers, e);
- var i;
- var doNotReset = {};
- var maxLevel = 0;
- var processedSequenceCallback = false;
- // 计算maxLevel的序列,所以我们只能执行时间最长的回调序列
- for (i = 0; i < callbacks.length; ++i) {
- if (callbacks[i].seq) {
- maxLevel = Math.max(maxLevel, callbacks[i].level);
- }
- }
- //通过匹配回调回路这一关键事件
- for (i = 0; i < callbacks.length; ++i) {
- // 触发有序回调
- // 这是因为例如,如果您有多个序列
- // 结合诸如“G i”和“G t”,他们都需要触发
- // 回调匹配摹原因,否则你永远只能
- // 匹配到第一个
- if (callbacks[i].seq) {
- //只触发回调的maxLevel防止
- //
- //
- //例如 “a option b' 应该不会造成'option b' 触发
- //即使'option b'为其它序列的一部分
- //
- //这里不匹配任何序列都将被丢弃
- //下面的_resetSequences通话
- if (callbacks[i].level != maxLevel) {
- continue;
- }
- processedSequenceCallback = true;
- // //保留其中的序列是匹配为以后列表
- doNotReset[callbacks[i].seq] = 1;
- _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);
- continue;
- }
- // 如果没有序列相匹配,但我们还在这里
- // 这意味着这是一个普通的匹配,所以我们应该触发了
- if (!processedSequenceCallback) {
- _fireCallback(callbacks[i].callback, e, callbacks[i].combo);
- }
- }
- // if the key you pressed matches the type of sequence without
- // being a modifier (ie "keyup" or "keypress") then we should
- // reset all sequences that were not matched by this event
- //
- // this is so, for example, if you have the sequence "h a t" and you
- // type "h e a r t" it does not match. in this case the "e" will
- // cause the sequence to reset
- //
- // modifier keys are ignored because you can have a sequence
- // that contains modifiers such as "enter ctrl+space" and in most
- // cases the modifier key will be pressed before the next key
- //
- // also if you have a sequence such as "ctrl+b a" then pressing the
- // "b" key will trigger a "keypress" and a "keydown"
- //
- // the "keydown" is expected when there is a modifier, but the
- // "keypress" ends up matching the _nextExpectedAction since it occurs
- // after and that causes the sequence to reset
- //
- // we ignore keypresses in a sequence that directly follow a keydown
- // for the same character
- //如果你按下键序列无类型相匹配
- //是一个修改(即“KEYUP”或“按键”),那么,我们应该
- //重新设置那些没有此事件相匹配的所有序列
- //
- //是这样,例如,如果你有序列“哈t”和你
- //型“听到T”不匹配。在这种情况下,将“e”的意愿
- //导致序列复位
- //
- //修饰键被忽略,因为你可以有一个序列
- //包含修饰,如“输入Ctrl +空格”,并在最
- //情况下,修改键将在下键之前按下
- //
- //此外,如果你有一个序列,例如“CTRL + B A”,然后按
- //“b”的键将触发一个“按键”和一个“的keydown”
- //
- //在“的keydown”时,有一个改性剂预期,但
- //“按键”结束了,因为它发生_nextExpectedAction匹配
- //之后和使该序列重新设置
- //
- //我们忽略了一个顺序按键直接遵循的keydown
- //对于相同的字符
- var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;
- if (e.type == _nextExpectedAction && !U.K._isModifier(character) && !ignoreThisKeypress) {
- _resetSequences(doNotReset);
- }
- _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';
- };
- /**
- *处理一个keydown事件
- *
- * @param {Event} e
- * @returns void
- */
- function _handleKeyEvent(e) {
- // 为正常化的关键事件e.which
- if (typeof e.which !== 'number') {
- e.which = e.keyCode;
- }
- var character = U.K._characterFromEvent(e);
- //没有字符发现后停止
- if (!character) {
- return;
- }
- //需要使用===用于字符检查,因为该字符可以是0
- if (e.type == 'keyup' && _ignoreNextKeyup === character) {
- _ignoreNextKeyup = false;
- return;
- }
- self.handleKey(character, U.K._eventModifiers(e), e);
- }
- /**
- * 称为设置1秒超时指定的顺序
- *
- *这是为了让序列中的每个按键后,你长为1秒
- *按下一个键,你必须重新开始之前
- *
- * @returns void
- */
- function _resetSequenceTimer() {
- clearTimeout(_resetTimer);
- _resetTimer = setTimeout(_resetSequences, 1000);
- }
- /**
- * 绑定一个键序列事件
- *
- * @param {string} combo - combo specified in bind call
- * @param {Array} keys
- * @param {Function} callback
- * @param {string=} action
- * @returns void
- */
- function _bindSequence(combo, keys, callback, action) {
- // 通过增加一个序列水平记录这个组合开始
- // 和level设定为0
- _sequenceLevels[combo] = 0;
- /**
- * *回调,以增加该序列的序列水平和复位
- * 处于活动状态的所有其他序列
- *
- * @param {string} nextAction
- * @returns {Function}
- */
- function _increaseSequence(nextAction) {
- return function () {
- _nextExpectedAction = nextAction;
- ++_sequenceLevels[combo];
- _resetSequenceTimer();
- };
- }
- /**
- * 包装指定的回调另一个函数内,以便
- *尽快此序列完成后重置所有序列计数器
- *
- * @param {Event} e
- * @returns void
- */
- function _callbackAndReset(e) {
- _fireCallback(callback, e, combo);
- //我们应该忽略下一个关键了,如果动作键不放
- //或按键。这是如此,如果你完成一个序列
- //松开按键的最后一个关键不会触发KEYUP
- if (action !== 'keyup') {
- _ignoreNextKeyup = U.K._characterFromEvent(e);
- }
- //怪异的竞争条件,如果一个序列与该键结束
- //另一序列始于
- setTimeout(_resetSequences, 10);
- }
- //通过按键一次,并结合适当的回调循环
- //功能。任何关键领导到最后,就应
- //增加的顺序。决赛之后,应该重置所有序列
- //
- //如果在原来的绑定调用指定的操作那么就会
- //在整个使用。否则,我们将通过动作的
- //下一个关键应该匹配。这允许顺序
- //混搭按键和KEYDOWN事件,这取决于
- //的是更好地适合于提供的密钥
- for (var i = 0; i < keys.length; ++i) {
- var isFinal = i + 1 === keys.length;
- var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || U.K._getKeyInfo(keys[i + 1]).action);
- _bindSingle(keys[i], wrappedCallback, action, combo, i);
- }
- }
- /**
- * 绑定一个键盘组合
- *
- * @param {string} combination
- * @param {Function} callback
- * @param {string=} action
- * @param {string=} sequenceName - name of sequence if part of sequence
- * @param {number=} level - what part of the sequence the command is
- * @returns void
- */
- function _bindSingle(combination, callback, action, sequenceName, level) {
- // //存储与Mousetrap.trigger使用直接映射参考
- self._directMap[combination + ':' + action] = callback;
- // 使连续务必多个空格成为一个空格
- combination = combination.replace(/\s+/g, ' ');
- var sequence = combination.split(' ');
- var info;
- //如果该模式是键的序列然后通过此方法运行
- //重新处理每个模式一键在同一时间
- if (sequence.length > 1) {
- _bindSequence(combination, sequence, callback, action);
- return;
- }
- info = U.K._getKeyInfo(combination, action);
- //确保初始化数组,如果这是第一次
- //回调增加了对这一关键
- self._callbacks[info.key] = self._callbacks[info.key] || [];
- //删除现有的比赛,如果有一个
- _getMatches(info.key, info.modifiers, { type: info.action }, sequenceName, combination, level);
- //后面添加此调用数组
- //如果它是一个序列把它在开始时
- //如果不把它在最后
- //
- //这是重要的,因为这些方式处理预期
- //序列的人是第一位的
- self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({
- callback: callback,
- modifiers: info.modifiers,
- action: info.action,
- seq: sequenceName,
- level: level,
- combo: combination
- });
- }
- /**
- * 结合多种组合到同一个回调
- *
- * @param {Array} combinations
- * @param {Function} callback
- * @param {string|undefined} action
- * @returns void
- */
- self._bindMultiple = function (combinations, callback, action) {
- for (var i = 0; i < combinations.length; ++i) {
- _bindSingle(combinations[i], callback, action);
- }
- };
- // start!
- U.M.AddEvent(targetElement, 'keypress', _handleKeyEvent);
- U.M.AddEvent(targetElement, 'keydown', _handleKeyEvent);
- U.M.AddEvent(targetElement, 'keyup', _handleKeyEvent);
- }
- U.K.Mousetrap = function () { };
- /**
- * / **
- *绑定的事件捕鼠器
- *
- *可以是单一的键,以+分离键的组合,
- *键的阵列,或由空格分隔键序列
- *
- *请务必先列出的组合键,以确保
- *正确的密钥最终得到的约束(在模式的最后一个键)
- *
- * @param {string|Array} keys
- * @param {Function} callback
- * @param {string=} action - 'keypress', 'keydown', or 'keyup'
- * @returns void
- */
- U.K.Mousetrap.prototype.bind = function (keys, callback, action) {
- var self = this;
- keys = keys instanceof Array ? keys : [keys];
- self._bindMultiple.call(self, keys, callback, action);
- return self;
- };
- /**
- **
- *解除绑定的事件捕鼠器
- *
- *在解除绑定设置指定组合键的回调函数
- *到一个空的功能,并在删除相应的键
- * _directMap字典。
- *
- * TODO:其实从_callbacks词典中删除这个代替
- 结合一个空函数*
- *
- *在keycombo +操作必须是完全一样
- *它在绑定方法定义
- *
- * @param {string|Array} keys
- * @param {string} action
- * @returns void
- */
- U.K.Mousetrap.prototype.unbind = function (keys, action) {
- var self = this;
- return self.bind.call(self, keys, function () { }, action);
- };
- /**
- * *触发器已被绑定的事件
- *
- * @param {string} keys
- * @param {string=} action
- * @returns void
- */
- U.K.Mousetrap.prototype.trigger = function (keys, action) {
- var self = this;
- if (self._directMap[keys + ':' + action]) {
- self._directMap[keys + ':' + action]({}, keys);
- }
- return self;
- };
- /**
- * *重置库恢复到初始状态。这是非常有用的
- *如果您想清除出当前的键盘快捷键和绑定
- *新的 - 例如,如果您切换到另一页
- * @returns void
- */
- U.K.Mousetrap.prototype.reset = function () {
- var self = this;
- self._callbacks = {};
- self._directMap = {};
- return self;
- };
- /**
- * *我们应该发射了回调之前停止该事件
- *
- * @param {Event} e
- * @param {Element} element
- * @return {boolean}
- */
- U.K.Mousetrap.prototype.stopCallback = function (e, element) {
- var self = this;
- // if the element has the class "mousetrap" then no need to stop
- if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
- return false;
- }
- if (U.K._getReverseMap(element, self.target)) {
- return false;
- }
- // stop for input, select, and textarea
- return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;
- };
- /**
- * 公开暴露_handleKey,因此它可以通过扩展覆盖
- */
- U.K.Mousetrap.prototype.handleKey = function () {
- var self = this;
- return self._handleKey.apply(self, arguments);
- };
- /**
- * 允许自定义键映射
- */
- U.K.Mousetrap.addKeycodes = function (object) {
- for (var key in object) {
- if (object.hasOwnProperty(key)) {
- U.K._MAP[key] = object[key];
- }
- }
- _REVERSE_MAP = null;
- };
- /**
- * *初始化全球捕鼠器功能
- *
- *需要使用此方法来允许在全球捕鼠器职能工作
- *现在的捕鼠器是一个构造函数。
- */
- U.K.Mousetrap.init = function () {
- var documentMousetrap = Mousetrap(document);
- for (var method in documentMousetrap) {
- if (method.charAt(0) !== '_') {
- Mousetrap[method] = (function (method) {
- return function () {
- return documentMousetrap[method].apply(documentMousetrap, arguments);
- };
- } (method));
- }
- }
- };
- //#endregion
- //----------------------------------------此js用来做特殊效果,例如弹出窗体缓动效果,关闭窗体缓动效果等-----------------------------
- Namespace.register("U.ME"); //js特效库
- //----到时全部都要合在Extend里
- //--------------------------------------------------------------------------动画区域---------------------------------------------------------------
- //动画
- U.ME.DH = function (UDOD, UTM, UTF, UDTD) {
- if (UDOD) {
- var i; //定义变量i
- var _UDE = UTM ? setInterval(U.M.apply(UDOD, [[U.ME.DHGDAMXG, [UTF, 0]]]), UTM) : null; //动画效果
- UDOD.onmouseout = UDOD.onmouseover = U.M.apply(UDOD, [[U.ME.DHGDAM, [arguments, _UDE]]]); //停止开始动画
- if (UDTD) {//功能未知,变量没试用过 一直为空 不会进if
- for (i = 0; i < UDTD.length; i++) {
- (UDTD[i]) && (UDTD[i].onclick = U.M.apply(UDTD[i], [[U.ME.DHQH, [i, arguments, _UDE]]])); //上下页切换
- };
- };
- }
- }
- //快速切换
- U.ME.DHQH = function (ITF, UAE, UDE) {
- clearInterval(UDE); //停止动画
- U.ME.DHGDAMXG.apply(UAE[0], [UAE[2], ITF]); //切换效果展示
- U.ME.DH.apply(window, UAE); //设置动画
- }
- //滚动动画开始停止
- U.ME.DHGDAM = function (USC, UDE) {
- if (!U.M.onmouseout(this)) { //取消动画
- var _UTP = event.type; //获取事件类型
- clearInterval(UDE); //关闭计时器
- if (_UTP == "mouseout") {//鼠标离开的时候
- U.ME.DH.apply(window, USC); //重新滚动
- }
- }
- }
- //动画效果
- U.ME.DHGDAMXG = function (UTF, ITF) {
- UTF = UTF == "L" ? "width" : "height"; //判断是不是L 是就改变宽度
- var _UFT = ITF === 0, //判断是否存在计时器
- _UDOD = $(this), //获取ul
- _UDAD = _UDOD.Child(), //获取ul下面的子元素
- _UDSD = _UDAD[_UFT ? 0 : _UDAD.length - 1],
- _UWH = "client" + (UTF.charAt(0).toUpperCase() + UTF.substr(1)),
- _UTP = [{ "overflow": "hidden" }, {}]; //设置样式
- if (_UDSD[_UWH]) { //这里是判断是否是否符合变化
- _UTP[0][UTF] = "0px"; _UTP[1][UTF] = _UDSD[_UWH] + "px"; //改变样式
- (_UFT) && (_UTP.reverse());
- $(_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); //执行动画?
- (!_UFT) && (this.insertBefore(_UDSD, _UDAD[0])); //插入元素
- }
- }
- //----------------------------------------------------------------------------切换图片------------------------------------------------------------
- //切换图片效果
- U.ME.YHT = function (UDOD, UDTD, UCL, ITF, UAT, ITM, UTF) {
- if (UDOD) {//变量是否定义
- var i, _UDCD = $(UDTD).Child(), //获取圆点的子元素
- _UDE = [], //初始化
- _UKE = [ITF || 0], //0?
- _UTM = null; //计时器
- if (ITM > 0) {
- _UTM = setInterval(U.M.apply(null, [[U.ME.YHTXZ, [UDOD, UDTD, _UKE, UCL]]]), ITM || 1000); //开始计时器 并且赋值
- } //图片选择
- _UKE[1] = _UTM; //存储计时器?
- if (!UTF) {//如果没值
- U.ME.YHTXZ(UDOD, UDTD, _UKE, UCL);
- } else if (_UKE[0] >= _UDCD.length) {//超过图片数量时
- _UKE[0] = 0; //?换成第一张
- };
- UTF = null; //参数变化
- UDOD.onmouseover = UDOD.onmouseout = U.M.apply(UDOD, [[U.M.StopBubble], [U.ME.YHTQX, [arguments, _UTM, _UKE]]]); //切换停止
- for (i = 0; i < _UDCD.length; i++) {
- _UDCD[i].onmouseover = _UDCD[i].onmouseout = U.M.apply(_UDCD[i], [[U.M.StopBubble], [U.ME.YHTQX, [arguments, _UTM, _UKE, i]]]); //切换查看
- }
- if (UAT) {//UAT 一直为0 不进入
- for (i = 0; i < 2; i++) {
- (UAT[i]) && (UAT[i].onclick = U.M.apply(UAT[i], [[U.ME.SXYHT, [(i - 1) * 2, _UKE, _UTM, arguments]]])); //上下页
- }
- }
- return _UTM; //返回计时器
- }
- }
- //计时器变化区域
- U.ME.YHTXZ = function (UDOD, UDTD, UDE, UCL) {
- var _UDAD = $(UDOD).Child();
- if ((!UDOD || UDOD) == (document || !_UDAD)) {
- clearInterval(UDE[1]); //移除
- }
- else {
- U.ME.ZSYHTXZ(UDOD, UDTD, UDE, UCL);
- UDE[0]++; (UDE[0] >= _UDAD.length) && (UDE[0] = 0); //变化切换
- }
- }
- //上下张
- U.ME.SXYHT = function (UTF, ITF, UTM, UCS) {
- var _UDCD = $(UCS[0]).Child();
- clearInterval(UTM); UCS[3] = (ITF[0] += UTF); //删除计时器
- if (ITF[0] < 0) {
- UCS[3] = _UDCD.length + UCS[3];
- }
- else if (ITF[0] >= _UDCD.length) {
- UCS[3] = 0;
- }
- U.ME.YHT.apply(this, UCS); //上下张查看
- }
- //开始或者取消图片选择查看
- U.ME.YHTQX = function (UCS, UTM, UKE, ITF) {
- if (!U.M.onmouseout(this)) {//是否在图片上取消
- var _UTP = event.type, //事件类型
- i = UKE[0] - 1;
- clearInterval(UTM); //关闭计时器
- i = i < 0 ? $(UCS[0]).Child().length - 1 : i;
- UCS[3] = UKE[0] = ITF != null ? ITF : UKE[0]; //清除计时器
- if (_UTP == "mouseout") {//鼠标离开
- UCS[3] = ITF != null ? ITF : i;
- UCS = Array.prototype.slice.call(UCS);
- UCS[6] = true; UCS[3]++;
- U.ME.YHT.apply(this, UCS); //重启计时器
- } //切换图片效果
- else if ((ITF != null && (i != ITF))) {
- U.ME.ZSYHTXZ(UCS[0], UCS[1], UKE, UCS[2]); //停止在该图片上
- }
- }
- }
- //图片展示
- U.ME.ZSYHTXZ = function (UDOD, UDTD, UDE, UCL) {
- var i, _UST,
- _UDAD = $(UDOD).Child(), //获取图片子元素
- _UDCD = UDTD ? $(UDTD).Child() : null;
- for (i = 0; i < _UDAD.length; i++) {//切换样式
- $(_UDAD).addAttrArray({ "style": i == UDE[0] ? { "filter": "alpha(opacity=0)", "-moz-opacity": "0", "opacity": "0", "display": "block"} : { "display": "none"} }, i); //图片切换样式
- if (UDTD) {//如果有圆点
- _UST = _UDCD[i].className; //class
- _UDCD[i].className = _UST.replace(" " + UCL, "").replace(UCL, "") + (i == UDE[0] ? ((_UST ? " " : "") + UCL) : ""); //按钮样式
- }
- }
- $(_UDAD[UDE[0]]).animate({ "-moz-opacity": "1", "opacity": "1", "filter": "alpha(opacity=100)" }, 500); //透明度动画?
- }
- //图片轮播:通过滚动调轮播图片
- U.ME.LBTP = function (UDE) {
- var _UIE = UDE.i || 0,
- _UDOD = $(UDE.e),
- UDAD = _UDOD.Child(); //子元素
- if (UDAD.length && UDE["s"]) {
- $(UDAD[_UIE]).addAttrArray(UDE["s"]); //默认点
- U.Ut.AddObj(UDE, { a: UDAD, i: UDE.i || 0, p: UDE.p || _UDOD.Parent(), w: UDE.w || 1 });
- return new U.ME.LBTPF(UDE);
- }
- }
- //开始轮播效果
- U.ME.LBTPF = function (UDE) {
- U.Ut.AddObj(this, UDE);
- this.init();
- $(UDE.a).bind("click", U.M.apply(this, this.click));
- }
- //轮播使用
- U.ME.LBTPF.prototype = {
- init: function () {//初始化
- (this.UTI) && (clearInterval(this.UTI)); //清除原有的计时器
- this.UTI = setInterval(U.M.apply(this, this.time), this.t || 5000); //计时开始
- },
- click: function (UIE) {//点击使用
- var _UDOD, _UDPD,
- _UIE = (UIE != null && !isNaN(Number(UIE))); //判断是否不为空
- if (_UIE) {
- _UIE = this.i + UIE;
- } else {
- _UDOD = event.srcElement; //获取时间对象
- while (_UDOD && (_UDPD = _UDOD.parentNode) != this.e) {
- _UDOD = _UDPD;
- }
- _UIE = this.a.indexOf(_UDOD); //判断是否是数组
- }
- if (_UIE != -1 && _UIE != null) { this.time(_UIE); this.init(); }
- },
- time: function (UIE) {//轮换
- if (this.a[0] && this.a[0].parentNode == this.e) {
- var i, _ULT, _UAE, _UDOD,
- _UDPD = this.p,
- _UDAD = this.a,
- _UL = _UDAD.length,
- _UIE = this.i;
- if (UIE == null) {
- this.i += this.w;
- if (_UIE == _UL - 1) {
- this.w = -1; this.i = _UL - 2;
- } else if (!_UIE) {
- this.i = this.w = 1;
- }
- } else {
- this.i = UIE;
- }
- $(_UDAD[_UIE]).addAttrArray(this.h);
- $((_UDOD = _UDAD[this.i])).addAttrArray(this.s); //添加或者删除
- if (this.af) {
- this.af(this);
- }
- else {
- _UAE = [_UDPD.scrollLeft, _UDPD.offsetWidth, _UDOD.offsetLeft - this.e.offsetLeft, _UDOD.offsetWidth];
- if (_UAE[0] + _UAE[1] < _UAE[2]) {
- _ULT = _UAE[2] + _UAE[3] * 2 - _UAE[1];
- } else if (_UAE[2] < _UAE[0]) {
- _ULT = _UAE[2] - _UAE[3] * 2;
- }
- (_ULT != null) && ($(_UDPD).animate({ "scrollLeft": _ULT }, 100));
- };
- (this.cb) && (this.cb());
- }
- else {
- clearInterval(this.UTI);
- } //取消
- }
- }
- /*函数使用方法
- 函数:U.ME.DH(obj, speed, direction)
- 参数一 obj : <ul>标签对象
- 参数二 speed : 速度 单位为毫秒
- 参数三 direction : 图片滑动的方向 “T”,”B”,”L”,”R”分别为上下左右
- 实例 :
- <html>
- <head>
- <meta charset="UTF-8" />
- <script type="text/javascript" src="/uform.js"></script>
- <style>
- li{list-style-type:none;}
- #UJ_Banner_ul{}
- #UJ_Banner_ul li{ height:100px;width:100px;margin:0 10;font-size:50px;float:left;border:1px #000 solid;}
- </style>
- <script type="text/javascript" >
- window.onload = function(){
- U.ME.DH($("#UJ_Banner_ul")[0], 1000, "L");
- }
- </script>
- </head>
- <body>
- <ul id="UJ_Banner_ul">
- <li>1</li>
- <li>2</li>
- <li>3</li>
- <li>4</li>
- <li>5</li>
- </ul>
- </body>
- </html>
- 函数: U.ME.YHT(obj, point, pointclass,0,button,speed)
- 参数一 obj : <ul>标签对象
- 参数二 point: 圆点动画 没有可不传
- 参数三 pointclass: 圆点执行样式,没有可不传
- 参数四 0 : 功能未知
- 参数五 button : 左右点击的按钮 是数组形式的 没有可不传
- 参数六 speed : 速度
- 实例 :
- <html>
- <head>
- <meta charset="UTF-8" />
- <script type="text/javascript" src="/uform.js"></script>
- <style>
- li{list-style-type:none;}
- #UJ_Banner_ul{height:100px;}
- #UJ_Banner_ul li{ height:100px;width:100px;margin:0 10;font-size:50px;float:left;border:1px #000 solid;}
- #UJ_Banner_L{width:20px;height:20px;border:1px #000 solid;display:inline-block;}
- #UJ_Banner_R{width:20px;height:20px;border:1px #000 solid;display:inline-block;}
- #fround div{height:20px; width:20px;display:inline-block;border:1px #000 solid;border-radius:50%;}
- .red{background:red;}
- </style>
- <script type="text/javascript" >
- window.onload = function(){
- U.ME.YHT($("#UJ_Banner_ul")[0], $("#fround")[0], 'red', 0, [$("#UJ_Banner_L")[0], $("#UJ_Banner_R")[0]], 1000);
- }
- </script>
- </head>
- <body>
- <ul id="UJ_Banner_ul">
- <li>1</li>
- <li>2</li>
- <li>3</li>
- <li>4</li>
- <li>5</li>
- </ul>
- <div id="UJ_Banner_L">左Á¨®</div>
- <div id="UJ_Banner_R">右®¨°</div>
- <div id="fround">
- <div class="red"></div>
- <div ></div>
- <div ></div>
- <div ></div>
- <div ></div>
- </div>
- </html>
- */
- //#region 桌面消息区域
- //w3c 消息区域 还在草案中
- Namespace.register("U.MN");
- U.MN.nif = window.notificationInstance; //消息总控
- //#region
- if (window.webkitNotifications) {
- //消息使用
- U.MN._UPS = window.webkitNotifications;
- //函数初始化使用
- U.M.HEPropert(U.MN._UPS, "onshow", function () {
- return this.ondisplay;
- },
- function (UVE) { this.ondisplay = UVE; });
- U.MN.UFN = function (UMT, UDE) {
- var _UCE = U.MN._UPS.createNotification(UDE.icon, UMT, UDE.body);
- _UCE.show(); return _UCE;
- }
- //继承消息
- U.MN.UFN.prototype = window.webkitNotifications;
- U.M.Setprototype(U.MN.UFN, {
- requestPermission: function (UCB) { U.MN._UPS.requestPermission(UCB); },
- permission: function () {
- return { 0: "granted", 1: "denied", 2: "default"}[U.MN._UPS.checkPermission()];
- },
- close: function () { this.cancel(); }
- });
- }
- //消息初始化
- U.MN.Notis = window.Notification = window.Notification || window.webkitNotifications;
- //#endregion
- //#region
- //添加消息提示
- U.MN.Noti = function (UDE) {
- return U.MN.Noti.get(UDE);
- }
- //初始化
- U.MN.Noti.get = function (UDE) {
- var _UDE = U.MN.Notis;
- if (_UDE) {
- if (_UDE.permission == "granted") {
- if (UDE) {
- return new U.MN.Noti.init(UDE);
- }
- } //初始化消息
- if (_UDE.permissi0on != "denied") {
- _UDE.requestPermission(function (UTF) {
- if (UTF == "granted") { U.MN.Noti.get(UDE); }
- });
- } //消息
- }
- }
- //初始化消息
- U.MN.Noti.init = function (UDE) {
- this.UNM; this.UT = UDE; this.UE = UDE.e; this.time = UDE.t || 0;
- }
- U.MN.Noti.checkPermission = function () {
- }
- //显示所有消息
- U.MN.Noti.show = function () {
- try { U.MN.nif.show() }
- catch (e) { return e; }
- }
- //清除消息
- U.MN.Noti.cancel = function () {
- try { U.MN.nif.cancel() }
- catch (e) { return e; }
- }
- //消息功能区域
- U.MN.Noti.init.prototype = {
- create: function (UMT, UDE, USE) { //创建消息 body dir icon lang onlcick onclose onerrer onshow slient tag title data noscreen renotify sound vibrate
- var _UME, _UME, _UTF = UDE == "string", Noti = U.MN.Notis; this.UE = USE = USE ? USE : this.UE;
- if (Noti.permission == "granted") {
- _UME = this.UNM = new Noti(UMT, UDE);
- (USE) && (this.event(USE)); (this.time) && (this.timerc(this.time));
- } //允许消息传递
- else if (Noti.permission != "denied") { Noti.requestPermission(U.M.apply(this, [[this.Permission, [UMT, UDE]]])); } //认证允许
- else { U.Alert("请启动消息推送!"); }
- },
- Permission: function (UMT, UDE, UTF) {//认证成功后
- if (UTF == "granted") { this.create(UMT, UDE); }
- },
- set: function (UDE) { //消息设置
- U.Ut.AddObj(this.UNM, UDE);
- },
- bind: function (UDE, UAE) { //事件绑定
- $(this.UNM).bind(UDE, UAE);
- },
- unbind: function () {//取消事件绑定
- $(this.UNM).unbind(UDE, UAE);
- },
- event: function (UDE) { //初始化消息
- var i, _UND = this.UNM, _UDE = { oc: "onclick", ocl: "onclose", oe: "onerror", os: "onshow" };
- for (i in UDE) { _UND[i] = _UND[_UDE[i]] = U.M.apply(this, [[this.aevent, [i, _UDE[i]]]]); }
- },
- aevent: function (UTF, UTP) {//事件统一出口
- var _UDE = this.UE;
- if (_UDE && _UDE[UTF]) {
- if (U.Ut.isFunction(_UDE[UTF])) {
- _UDE[UTF]();
- }
- else { U.M.apply(this, _UDE[UTF])(); }
- if (UTF == "oc" || UTF == "onclick") {//执行函数
- this.close();
- }
- }
- },
- close: function () {//关闭
- if (this.UNM) {
- this.UNM.close();
- this.dispose();
- }
- },
- dispose: function () { this.UT = this.UE = this.UNM = null; },
- timerc: function (UT, UFE) { //指定事件关闭消息
- setTimeout(U.M.apply(this, [[UFE], [this.close]]), UT);
- },
- show: function () { U.MN.show(); },
- cancel: function () { U.MN.cancel(); }
- }
- //#endregion
- //#region
- //IFrame之间的消息通知。全兼容解决方案,太复杂,需要精简版本。
- // 页面消息传递,解决跨域问题。
- U.MN.message = function (UDE) {
- return new U.MN.message.get.init(UDE);
- }
- U.MN.message._UTF = ("onmessage" in window);
- U.MN.message._UFS = function (UDE) {
- try {
- var _UME, _USE = "";
- if (U.MN.message._UTF) { _USE = UDE.data; }
- else { _USE = UDE || window.name; } //设置
- _USE = _USE.parseJSON();
- _UME = U.MN.message.get.func[_USE[1]];
- (_UME) && (_UME.message[_USE[0], _USE[2], _USE[3]]);
- } catch (e) { }
- };
- if (U.MN.message._UTF) {
- U.M.AddEvent("message", window, U.MN.message._UFS);
- }
- U.MN.message.get = U.MN.message.prototype = {
- func: {},
- ZS: 1,
- init: function (UDE) { //初始化消息
- U.Ut.AddObj(this, UDE);
- this.id = this.id || Guid.guidNoDash();
- this.func[this.id] = this;
- if (!U.MN.message._UTF) {
- if (this.Sender) {
- var _USE = this.obj;
- (U.Ut.isString(_USE)) && (_USE = $(_USE)[0]);
- this.url = U.M.getUrl(_USE.src).host;
- this.obj = $$("iframe", { style: { display: "none" }, width: "0", height: "0" }, document.body);
- }
- else { $().ready(U.M.apply(this, U.MN.message._UFS)); }
- }
- },
- message: function (UDE) {//接收消息
- (U.Ut.isFunction(this.me)) && (this.me(UDE));
- if (this.Sender && !U.MN.message._UTF) {
- var _UD = this.obj.contentWindow.document;
- _UD.open();
- _UD.write("");
- _UD.close();
- $(this.obj).remove();
- } //释放
- },
- post: function (UDE, UDID, UCE) {//提交消息
- var _UKE, _USE = this.obj;
- UDE = U.MS.jsonToStr[UDE, UDID || "", this.id, UCE];
- (U.Ut.isString(_USE)) && (_USE = $(_USE)[0]);
- if (U.MN.message._UTF) {
- try { _USE = _USE.contentWindow || _USE; }
- catch (e) { _USE = this.obj; } _USE.postMessage(UDE, "*");
- }
- else {
- if (this.url) {
- _USE.src = "about:blank";
- U.MD.IframeLoad(_USE, [[U.M.apply(this, [[this.ie, [_USE, UDE]]])]]);
- }
- else { window.name = UDE; window.location = this.lurl; }
- } //消息提示
- },
- ie: function (USE, UDE) { USE.contentWindow.name = UDE; USE.contentWindow.location.href = this.url; }
- }
- U.MN.message.get.init.prototype = U.MN.message.get;
- U.MN.message.cb = U.MN.message._UFS;
- //#endregion
- Namespace.register("U.PL");
- //#region 变量处理
- U.PL._er = {};
- 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所有的事件
- //#endregoin
- //视频初始化
- U.PL.vi = function (UDE, UDPD, UCE) {
- if ($$("video").canPlayType) {
- return new U.PL.vi.init(UDE, UDPD, UCE);
- }
- else { return false; }
- }
- //初始化视屏播放器
- U.PL.vi.init = function (UDE, UDPD, UCE) {
- this.obj = UDE || {}; //
- this.pa = UDPD; //
- this.vi = null; //
- this.config(UCE);
- return this;
- }
- U.PL.vi.init.prototype = {
- type: { "ogg": 'video/ogg; codecs="theora, vorbis"', "mp4": 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', "webm": 'audio/webm; codecs="vorbis"' },
- 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属性
- config: function (UDE) { //配置文件
- U.Ut.AddObj((this.cf = this.cf || {}), UDE); U.Ut.AddObj(this.cf, { l: this.cf.l || 0, urls: this.cf.urls || [] }); //配置视频
- },
- init: function (UDE, UDPD, UCE) { //初始化视屏播放器
- U.Ut.AddObj(this, { obj: UDE || {}, pa: UDPD, vi: null }); this.config(UCE); return this;
- },
- create: function (URL, UDPD) { //src poster preload autoplay loop controls width height viode属性
- var _UCE = this.cf, _UVE = _UCE.html || { "style": { "cssText": "margin:auto;display:block;height:100%;width:auto;" }, "autoplay": "autoplay", "controls": "controls", "accesskey": true, "poster": "" };
- if ((URL = ((this.cf.urls.push(URL), URL) || this.cf.urls[this.l]))) {
- 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])) { };
- }
- else { U.Alert("链接无效"); }
- return this;
- },
- load: function (URL) { //重新加载
- URL = URL || this.cf.urls[this.cf.l]; if (this.vi) { this.vi.url = URL; } else { this.create(); }
- },
- event: function () { //事件监听
- var i, _UDOD = this.vi; //监听所有的事件
- 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]]]])); } }
- },
- cb: function (UTP) { //所有事件监听回调
- (this.cf[UTP]) && (this.cf[UTP])(); //回调函数
- return true;
- },
- getType: function (UTF) { //获取属性
- return this.vi[this.attr[UTF] || UTF];
- },
- set: function (UTP, UV) { //设置值
- var i, _UAE = this.attr, _USE = UTP; (U.Ut.isString(UTP)) && (_USE = {}, _USE[UTP] = UV);
- for (i in _USE) { this.vi[(_UAE[i] || i)] = _USE[i]; }
- },
- exec: function (UTF) { //执行获取
- return this[UTF] ? this[UTF]() : this.vi[UTF];
- },
- next: function () { //上一片
- 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); }
- },
- lower: function () { //下一篇片
- 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); }
- },
- isPlay: function (UTF, UDOD) { //判断是否允许播放该格式
- return (UDOD || this.vi).canPlayType(this.type[UTF.toLowerCase()]);
- },
- play: function (UTF) { //播放和暂停
- this.vi[UTF ? "play" : "pause"]();
- },
- backRate: function (UVE) { //播放速度
- this.vi.playbackRate = UVE;
- },
- error: function (UE) { //发生错误
- var _UDE = ["", "网络异常", "解码失败", "URL无效"];
- (!UE.code) && (U.Alert(_UDE[UE.code]));
- },
- fullScreen: function () {//视频全屏
- var _funcname = U.M.GetFullSreeenName("requestFullScreen"); //全屏函数名
- if (_funcname != null)
- this.vi[_funcname](); //执行全屏函数
- },
- fullScreen: function () {//取消视频全屏
- U.M.cancelfullScreen();
- }
- }
|