6 Star 0 Fork 0

hi / webCollection

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webCollectionBase.js 109.55 KB
一键复制 编辑 原始数据 按行查看 历史
xiexin 提交于 2021-03-08 10:57 . fix(ip域名)添加不成功的问题
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037
//+-----------------------global varribles------------------------------
var U = undefined;
var i = window.location.href.indexOf(".com");
var g_domainURL = window.location.href.substring(0, i + 4) + "webcollection/";
var B = {}; //B is the namespace of base classes.
if (typeof g === undefined) {
var g = {};
}
g.config = {
"backgoundColor": "#ffffff",
"headBackgroundColor": '#629444'
};
g.DomainSuf = (function () {
var exp = /(?:http:\/\/)?(?:(\w+)\.)?(?:(\w+)\.)(\w+)/g;
var match = exp.exec(window.location.href);
var i = window.location.href.indexOf(".com");
if (match == undefined || match[1] == undefined) {
var t = (/\/\/\w+/).exec(window.location.href)[0];
return t.substring(2, t.length);
} else {
return match[1];
}
})();
g.mainDomain = (function () {
try {
var t = (/(\w+\.){1}.[a-zA-Z0-9_-]+\//).exec(window.location.href)[0];
return t.substring(0, t.length - 1);
} catch (ex) {
return '';
}
})();
g.dragEle = U;
g.dragData = undefined;
g.files = [];
g.initialOffsetX = 0; //the offset between the lefttop of the ele and the position of the mouse
g.initialOffsetY = 0;
g.mainTableWidth = (function () { //适应屏幕
if (Sys.isMiniScreen) {
var a = Math.min(window.screen.width, window.screen.height),
b = Math.min(window.availWidth, window.availHeight);
if (a < 540) return window.screen.width - 80;
if (Math.abs(a - 540) < Math.abs(b - 540)) {
return window.screen.width * 0.8 - 50;
} else {
return window.screen.availWidth * 0.8 - 50;
}
} else {
return window.screen.width * 0.4 + 300;
}
})();
//alert(window.screen.width + " " + window.screen.availWidth + " " + g.mainTableWidth);
g.volatileArray = [];
g.dataWebTable = [];
g.WebTable = [];
g.Category = [];
g.state = {};
g.subdir = "";
g.state.isOperable = false; //
g.state["search"] = false;
g.state.haveLogined = false; //在此次登录前是否已经登录。
g.state.isHostEUser = function () { //当前用户就是主人 E:equil
if (g.user == U) return false;
if (!g.user.username) return false;
return (g.user.username.toLowerCase() == g.DomainSuf);
};
g.initialState = function () {
if (g.subdir == "main") {
if (g.state.isHostEUser()) {
g.state.isOperable = true;
}
} else if (g.subdir == "private") {
g.state.isOperable = true;
} else {
g.state.isOperable = false;
}
};
g.returnFalse = function () {
return false;
};
g.getPrivateData = function (paraStr) //获取私有数据
{
g.subdir = "private";
g.initialState();
var t = $('privateID');
if (t != undefined) {
$('privateID').style.backgroundColor = "#54C11A";
}
$('hostID').style.backgroundColor = "";
$('publicID').style.backgroundColor = "";
var getDataURL = g.domainDirectory + "/SendDataToClient.aspx?owner=0&&flag=private&&paraStr=" + paraStr +"&&freshParam=" + (new Date).getTime();
sendAndGetData(true, getDataURL, function (resTxt) {
g.dataWebTable["main"] = eval('(' + resTxt + ')');
g.page.bindData(g.dataWebTable["main"]);
g.page.createDom();
g.page.refresh();
});
};
g.getMainData = function (paraStr) //获取用户主数据
{
g.subdir = "main";
g.initialState();
var t = $('privateID');
if (t != undefined) {
$('privateID').style.backgroundColor = "";
}
$('hostID').style.backgroundColor = "#54C11A";
$('publicID').style.backgroundColor = "";
var getDataURL = g.URI.protocol + '://' + g.URI.authority + "/SendDataToClient.aspx?owner=0&&flag=main&&paraStr=" + paraStr +"&&freshParam=" + (new Date).getTime();
sendAndGetData(true, getDataURL, function (resTxt) {
g.dataWebTable["main"] = eval('(' + resTxt + ')');
g.page.bindData(g.dataWebTable["main"]);
g.page.createDom();
g.page.refresh();
});
};
g.getPublicData = function (paraStr) //获取公共数据
{
g.subdir = "public";
g.initialState();
var t = $('privateID');
if (t != undefined) {
t.style.backgroundColor = "";
//_.setUserInfo();
}
$('hostID').style.backgroundColor = "";
$('publicID').style.backgroundColor = "#54C11A";
var getDataURL = g.domainDirectory + "/SendDataToClient.aspx?owner=0&&flag=public&&paraStr=" + paraStr+"&&freshParam=" + (new Date).getTime();
sendAndGetData(true, getDataURL, function (resTxt) {
g.dataWebTable["main"] = eval('(' + resTxt + ')');
g.page.bindData(g.dataWebTable["main"]);
g.page.createDom();
g.page.refresh();
});
};
if (g.user == undefined) {
g.user = new User(lib.cookie.get("username"));
}
g.disLoginAndRegister = function () { //显示'登录与注册'界面,并获取相关类。
g.lightOn = new LightOn($('light'));
return g.LightOn;
};
g.tip = (function () {
var unique;
function constructor() {
var ele = $CE("DIV");
$SA(ele, "style", "left: 50%;transform: translateX(-50%);position: fixed;text-align:center;background-color:yellow;top:0px;padding: 0 20px;z-index:9;opacity:.70;moz-opacity:0.7;filter:alpha(opacity=40);");
document.body.appendChild(ele);
return ele;
}
return {
getInstance: function () {
if (!unique) {
unique = constructor();
}
return unique;
},
display: function () { //(msg,q) q表示时间延迟.
var t = this.getInstance();
//t.style.top = (document.body.scrollTop || document.documentElement.scrollTop) + "px";
jQuery(t).append(arguments[0] + "<div style='font-size: 14px;'>✔</div>");
var sec = 5000;
if (arguments.length > 1) {
sec = arguments[1] * 1000;
}
setTimeout(function () {
if (U != t.parentNode) t.parentNode.removeChild(t);
unique = U;
}, sec);
},
clear: function () {
if (unique != U) unique.parentNode.removeChild(unique);
}
}
})();
function stopEvent(e) {
if (!e) e = window.event;
if (e.stopPropagation) {
e.stopPropagation();
} else {
e.cancelBubble = true;
}
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
}
function voidFun() {
if (!e) e = lib.getEvent();
e = EventUtil.formatEvent(e);
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
return false;
}
window.onresize = function () {
g.page.refresh(); //当窗口改变时,重新布局.
};
if (!Array.prototype.forEach) {
Array.prototype.forEach = function (fun /*, thisp*/ ) {
var len = this.length;
if (typeof fun != "function")
throw new TypeError();
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in this)
fun.call(thisp, this[i], i, this);
}
};
}
/** 公共代码 ***/
// IE浏览器的Array对象缺少indexOf方法,加到原型对象上
if (!Array.indexOf) {
Array.prototype.indexOf = function (obj) {
for (var i = 0; i < this.length; i++) {
if (this[i] == obj) {
return i;
}
}
return -1;
}
}
// 绑定事件响应
Object.prototype.on = function (type, callback) {
if (this.attachEvent) {
this.attachEvent("on" + type, callback);
} else if (this.addEventListener) {
this.addEventListener(type, callback, false);
}
}
// 解除事件响应
Object.prototype.off = function (type, callback) {
if (this.attachEvent) {
this.detachEvent("on" + type, callback);
} else if (this.addEventListener) {
this.removeEventListener(type, callback, false);
}
}
//解决IE的Object.prototype的BUG
if (!document.on) {
document.on = Object.prototype.on;
document.off = Object.prototype.off;
}
// 简化对象获取方法
function $(obj) {
if (typeof obj == "string") {
obj = document.getElementById(obj);
}
//解决IE的Object.prototype的BUG
if (obj && !obj.on) {
obj.on = Object.prototype.on;
obj.off = Object.prototype.off;
}
return obj;
}
function u(p) {
return (p == U) ? true : false;
}
function funForWebEleDblclick() //准备编辑web元素.
{
var t = new EditWeb(getDataByMouse(g.mouseEvent).webData);
}
function oneLayerClone(source) {
var tmp = {};
for (var i in source) {
tmp[i] = source[i];
}
return tmp;
}
function arrayContainer(p) { //a class
var _ = this;
_.arr = [];
_.length = p;
_.push = function (value) {
_.arr.push(value);
if (_.arr.length > _.length) {
_.arr.splice(0, 1);
}
};
_.clear = function () {
_.arr.length = 0;
};
}
//+--------------------event handler------------------------------------
var eventHandler = {
eventType: -1,
isMove: false,
g_eventArray: new arrayContainer(10),
paramForMousedown: U,
paramForMouseup: U,
paramForClick: U,
paramForDblclick: U,
funForMousedown: U,
funForMouseup: U,
funForClick: U,
funForDblclick: U,
invokeFun: function () {
eventHandler.getEvent();
switch (eventHandler.eventType) {
case 0: //down
if (!u(eventHandler.funForMousedown)) {
eventHandler.funForMousedown();
}
break;
case 1: //up
if (eventHandler.funForMouseup) {
eventHandler.funForMouseup();
eventHandler.funForMouseup = null;
}
break;
case 2: //click
if (eventHandler.funForClick) //eventHandler.funForClick isn't null
{
eventHandler.funForClick();
eventHandler.funForClick = null;
}
break;
case 3: //dblclick
if (eventHandler.funForDblclick) {
eventHandler.funForDblclick();
eventHandler.funForDblclick = null;
}
break;
case 4: //
break;
}
},
fun_onmousemove: function () {
g.mouseEvent = oneLayerClone(lib.formatEvent(arguments[0]));
if (!u(g.WebActive) && g.WebActive.isLMousedown == 1) {
eventHandler.g_eventArray.push(g.mouseEvent);
setTimeout(eventHandler.setMoveToTrue, 1000);
eventHandler.eventType = 4;
}
},
setMoveToTrue: function () {
g.WebActive.isLMousedown = 0; //tag the left mouse to "up" after 1000 milliseconds.
},
fun_onmousedown: function (evt) {
g.mouseEvent = lib.formatEvent(evt);
var trigger = g.mouseEvent.target;
switch (trigger.getAttribute("eleFlag")) {
case "webEle":
break;
default:
break;
}
if (trigger.tagName == "TD") { //if the trigger is row element.
specialEffect.m(trigger.parentNode, lib.formatEvent(evt));
return;
} else {
}
eventHandler.g_eventArray.push(g.mouseEvent);
setTimeout(eventHandler.invokeFun, 400);
stopEvent(g.mouseEvent);
},
fun_onmouseup: function () {
g.mouseEvent = oneLayerClone(lib.formatEvent(arguments[0]));
eventHandler.g_eventArray.push(g.mouseEvent);
},
fun_onclick: function () {
var trigger = lib.formatEvent(arguments[0]).target;
switch (trigger.getAttribute("eleFlag")) {
case "webEle": //the object is a "web"
eventHandler.funForClick = funForWebEleClick;
break;
case "CateNameEle": //the object is a category name
eventHandler.funForClick = funForCateEleClick;
break;
default:
break;
}
g.mouseEvent = oneLayerClone(lib.formatEvent(arguments[0]));
eventHandler.g_eventArray.push(g.mouseEvent);
},
fun_ondblclick: function () {
switch (lib.formatEvent(arguments[0]).target.eleFlag) {
case "CateNameEle":
eventHandler.funForDblclick = funForCateEleDblclick;
break;
default:
break;
}
g.mouseEvent = oneLayerClone(lib.formatEvent(arguments[0]));
eventHandler.g_eventArray.push(g.mouseEvent);
},
reseteventType: function () {
eventHandler.eventType = -1;
eventHandler.g_eventArray.clear();
},
getEvent: function () { //determine the event of "dblclick" "click" "mousedown" "mouseup" "mousemove".
if (eventHandler.isMove == true) {
eventHandler.isMove = false;
eventHandler.eventType = -1;
return;
}
if (eventHandler.g_eventArray.arr.length < 1) return;
var firstTime = eventHandler.g_eventArray.arr[0].time;
for (var i = 0; i < eventHandler.g_eventArray.arr.length && eventHandler.g_eventArray.arr[i].time > firstTime - 800; i++) {
if (eventHandler.g_eventArray.arr[i].type == "dblclick") {
eventHandler.eventType = 3;
eventHandler.g_eventArray.clear();
return;
}
}
for (var i = 0; i < eventHandler.g_eventArray.arr.length && eventHandler.g_eventArray.arr[i].time > firstTime - 800; i++) {
if (eventHandler.g_eventArray.arr[i].type == "click") {
eventHandler.eventType = 2;
eventHandler.g_eventArray.clear();
return;
}
}
for (var i = 0; i < eventHandler.g_eventArray.arr.length && eventHandler.g_eventArray.arr[i].time > firstTime - 800; i++) {
if (eventHandler.g_eventArray.arr[i].type == "mousemove") {
eventHandler.eventType = 4;
eventHandler.g_eventArray.clear();
return;
}
}
if (eventHandler.g_eventArray.arr[0].type == "mouseup") {
eventHandler.eventType = 1;
}
if (eventHandler.g_eventArray.arr[0].type == "mousedown") {
eventHandler.eventType = 0;
}
eventHandler.g_eventArray.clear();
},
displayEventType: function () {
eventHandler.getEvent();
document.getElementById("result").innerHTML += "<br/>Event Type:" + eventHandler.eventType;
}
}
//+----------------------specialEffect---------------------------------
var SpecialEffect = function () {
var _ = this;
_.placeElement = function (fromElement, preFromElement, elementContainer, eventType) {
if (eventType == event.type) {
g.elementDragClass.drag.ele.removeNode(true);
if (elementContainer.clientLeft < event.x && event.x < elementContainer.clientLeft + elementContainer.clientWidth && elementContainer.clientTop < event.y && event.y < elementContainer.clientTop + elementContainer.clientHeight) {
elementContainer.appendChild(g.elementDragClass.saved.ele);
close(g.elementDragClass.source.ele);
} else {
g.elementDragClass.source.ele.style.cssText = g.elementDragClass.saved.ele.style.cssText;
}
}
};
_.m = function (p, e) { //drag the row of a category and webs.
if (e.target.tagName != "TD") return;
g.elementDragClass = new ThreeDomEleClass(p, p.cloneNode(true), p.cloneNode(true));
if (u(g.elementDragClass) || u(g.elementDragClass.drag.ele)) return;
g.tableRowWeb = getDataByMouse(e);
if (u(g.tableRowWeb.rowData)) {
return;
}
var dragTableDiv = $CE("DIV"); //create a DIV element to contain the table. It can be dragged.
var dragTable = g.tableRowWeb.tableData.E.cloneNode(false);
dragTable.appendChild(g.elementDragClass.drag.ele);
lib.dom.clearChildren(dragTableDiv);
dragTableDiv.appendChild(dragTable);
dragTableDiv.innerHTML = dragTableDiv.innerHTML;
dragTableDiv.firstChild.className = "noRound";
dragTableDiv.style.display = "inline";
dragTableDiv.style.position = "absolute";
dragTableDiv.style.cursor = "move";
dragTableDiv.style.width = g.tableRowWeb.rowData.RecRight - g.tableRowWeb.rowData.RecLeft + 'px';
var startX = findPos(p).absoluteLeft;
var startY = e.clientY;
var origY = g.elementDragClass.source.ele.offsetTop;
var deltaY = startY - origY;
//alert("006;");
iDiffX = e.clientX - g.tableRowWeb.rowData.RecLeft;
iDiffY = e.clientY - g.tableRowWeb.rowData.RecTop;
// g.elementDragClass.source.ele.style.visibility = "hidden";
if (dragTableDiv.style.left == "") {
dragTableDiv.style.left = e.clientX - iDiffX + "px";
dragTableDiv.style.top = e.clientY - iDiffY + "px";
}
g.elementDragClass.drag.ele = document.body.appendChild(dragTableDiv);
if (document.addEventListener) {
document.onmousemove = moveHandler;
document.onmouseup = upHandler;
} else if (document.attachEvent) {
dragTableDiv.setCapture();
dragTableDiv.onmousemove = moveHandler;
dragTableDiv.onmouseup = upHandler;
dragTableDiv.onlosecapture = upHandler;
} else {
var oldmovehandler = document.onmousemove;
var olduphandler = document.onmouseup;
document.onmousemove = moveHandler;
document.onmouseup = upHandler;
}
function moveHandler(e) { //moving
if (!e) {
e = lib.getEvent();
}
e = EventUtil.formatEvent(e);
dragTableDiv.style.left = e.clientX - iDiffX + "px";
dragTableDiv.style.top = e.clientY - iDiffY + "px";
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
}
function upHandler(e) //edit after moving
{
if (!e) e = lib.getEvent();
var tmpIDs = g.elementDragClass.source.ele.getAttribute("relationalID").split("-");
var tmpWebRow = g.page.$(tmpIDs[0]).$(tmpIDs[1]);
tmpWebRow.dragEle = dragTableDiv;
tmpWebRow.funForLMouseUpAfterMoveWhileDown();
if (document.removEventListener) {
document.onmouseup = null;
document.onmousemove = null;
document.removeEventListener("mouseup", upHandler, true);
document.removeEventListener("mousemove", moveHandler, true);
} else if (document.detachEvent) {
dragTableDiv.onlosecapture = null;
dragTableDiv.onmouseup = null;
dragTableDiv.onmousemove = null;
dragTableDiv.releaseCapture();
} else {
document.onmouseup = olduphandler;
document.onmousemove = oldmovehandler;
}
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
}
};
}
//++---------------------------------------------------------------
var specialEffect = new SpecialEffect();
//+-----------------------------------------
function ThreeDomEleClass(a, b, c) // the data structure of the web to be dragged.
{
var _ = this;
_.source = {
ele: a,
parent: _
};
_.saved = {
ele: b,
parent: _
};
_.drag = {
ele: c,
parent: _
};
_.empty = function () {
if (U != _.source.ele) _.source.ele.outerHTML = "";
if (U != _.saved.ele) _.saved.ele.outerHTML = "";
if (U != _.drag.ele) _.drag.ele.outerHTML = "";
}
}
// base class
function Region() {
var _ = this;
_.RecLeft = 0;
_.RecTop = 0;
_.RecRight = 0;
_.RecBottom = 0;
//set the rectangle of every web element.
_.setRec = function (p, q, right, bottom) {
_.RecLeft = p;
_.RecTop = q;
_.RecRight = right;
_.RecBottom = bottom;
};
_.setRecByEle = function () {
_.RecLeft = 0;
_.RecTop = 0;
_.RecRight = 0;
_.RecBottom = 0;
var t = _.E;
if (t.offsetParent) {
while (1) {
_.RecLeft += t.offsetLeft;
_.RecTop += t.offsetTop;
if (!t.offsetParent) {
break;
} else if (t.offsetParent.style.position == "absolute") {
_.RecLeft += t.offsetParent.offsetLeft;
_.RecTop += t.offsetParent.offsetTop;
break;
}
t = t.offsetParent;
}
} else if (t.x && t.y) {
_.RecLeft += t.x;
_.RecTop += t.y;
}
_.RecRight = _.RecLeft + _.E.offsetWidth;
_.RecBottom = _.RecTop + _.E.offsetHeight;
return _;
};
_.refresh = function () {
_.setRecByEle();
var childEles = _.Webs || _.Categories || _.Tables;
if (u(childEles)) {
return _;
}
for (var i = 0; i < childEles.length; i++) {
childEles[i].refresh();
}
return _;
};
//judge
_.isOver = function (x, y) {
try {
return (x > _.RecLeft && x < _.RecRight && y > _.RecTop && y < _.RecBottom) ? true : false;
} catch (e) {
return false;
}
};
_.isOverEvent = function (p) {
var t = lib.formatEvent(p);
return _.isOver(t.pageX, t.pageY);
};
}
//message data structure
function message(from, to, owner, content, webTable) {
this.from = from;
this.to = to;
this.owner = owner;
this.content = content;
this.webTable = webTable;
this.isRead = 0; //0 stands for being unread; 1 stands for being unread.
}
//user data structure
function User(p, q, image) {
var _ = this;
_.username = (!!p) ? p.toLowerCase() : p;
_.email = q;
_.image = image;
_.messages = [];
_.friend = [];
/*
example: if(false == g.user.isLogined()){
var tmp = g.disLoginAndRegister();
//do something else.
}
*/
_.isLogined = function () { //判断是否已经登录:是则返回true。
if (_.username == U) {
return false;
} else {
return true;
}
};
_.logOut = function () {
lib.cookie.clear("username", "/");
_.username = U;
_.setUserInfo();
g.getMainData(); //禁止查看私人数据,因此显示主人数据。
};
_.logIn = function () {
};
_.sendMessage = function () {};
_.getMessage = function () {
};
_.setUserInfo = function () {
if (U != _.username) {
lib.cookie.set("username", _.username, 30, "/", true);
if (g.state.haveLogined == false) {
g.tool.menu.insertItem(1, "<a id='userID' href='javascript:g.goUserPage();'>" + _.username + "</a>");
g.tool.menu.insertItem(2, "<a href='javascript:g.user.logOut();'>" + lan["loginOut"] + "</a>");
+ g.tool.menu.insertItem(3, "<a id='privateID' href='#" + paraStr+"/private'>" + lan["21"] + "</a>");
} else { //if(g.state.haveLogined == true) 如果已经有用户登录,则更新当前用户名。
g.tool.menu.updateItem(1, "<a id='userID' href='javascript:g.goUserPage();'>" + _.username + "</a>");
}
g.state.haveLogined = true;
} else {
if ($("userID") != U) { //如果不加这个判断会删除其它菜单项。
g.tool.menu.removeItemByIndex(1);
g.tool.menu.removeItemByIndex(1);
g.tool.menu.removeItemByIndex(1);
}
g.state.haveLogined = false;
}
}
}
function Friend(p_ele) {
var _ = this;
_.ele = p_ele;
_.users = [];
_.AddUser = function (p_user) {
_.users.push(p_user);
};
_.DelUser = function (p_user) {
for (var i = 0; i < _.users.length; i++) {
if (p_user === _.users[i]) {
_.users.splice(i, 1);
return;
}
}
};
_.DisUser = function () { //显示好友用户。
var tmp = [];
for (var i = 0; i < _.users.length; i++) {
tmp.push(_.users[i].username);
}
document.body.appendChild(lib.dom.createTable(tmp, "friendID"));
};
}
//绑定document.body的onmousemove事件。
function MoveEle(e) {
}
document.body.onmousemove = function () {
if (g.dragData == undefined) {
var e = lib.formatEvent();
var target = e.target;
var tripData = getDataByMouse(e);
if (!tripData) {
return;
}
var currentData = tripData.webData || tripData.rowData || tripData.tableData;
if (currentData != undefined) {
if (currentData.isLDown == false)
return;
//计算拖动距离。
var distance = Math.sqrt(Math.pow((e.x - currentData.firLDownClientX), 2) + Math.pow((e.y - currentData.firLDownClientY), 2));
//如果鼠标左键是按下状态,且拖动较大距离,则表明是拖动事件。
if (distance > 5) {
console.log(g.dragData);
if (g.dragData == undefined) { //start dragging.
currentData.funForStartLMouseMoveWhileDown();
}
}
}
} else {
g.dragData.funForLMouseMoveWhileDown();
}
};
function EventForEle(p) {
var _ = this;
_.EleToEvent = p.E;
_.isLDown = false; //鼠标左键是否被按下
_.isRDown = false; //鼠标右键是否被按下
_.isLMoveWhileDown = false; //鼠标左键是否在被按住拖动.
_.firRDownT = null; //鼠标右键被按下的时间
_.firRUpT = null; //鼠标右键被放起的时间
_.isDbClick = 0; //鼠标左键是否被双击.
_.firClickTime = null; //第一次单击的时间
_.secClickTime = null; //第二次单击的时间,可以根据时间差_.secClickTime-_.firClickTime判断鼠标事件是"一般单击"还是"双击"
//鼠标位置相对所在元素顶点的
_.firLDownClientX = 0; //鼠标左键第一次被按下所在的位置
_.firLDownClientY = 0;
_.firLDownT = null;
_.firUpT = null;
_.timeFunName = null;
_.active_element;
_.bIsMSIE;
_.isLButton = function (e) {
if (navigator.userAgent.indexOf("MSIE") > 0)
return lib.getEvent().button == 1; //IE中左键标记为1
else
return lib.getEvent().button == 0; //Firefox中左键标记为0
};
_.isRButton = function () {
if (navigator.userAgent.indexOf("MSIE")) //is IE
return lib.getEvent().button == 2;
else
return lib.getEvent().button == 2;
};
//任务1,当鼠标移至此元素区域内时,此事件发生;
_.EleToEvent.onmouseover = function () {
return false;
};
//任务2,当鼠标离开此元素区域内时,此事件发生;
_.EleToEvent.onmouseout = function () {
return false;
};
//任务3,在此元素区域中,当鼠标左键按住不放时,调用functioin funcAMouseOn(){//do something}。
_.funcAMouseOn = function () {
};
_.EleToEvent.onmousedown = function () {
var e = lib.getEvent();
if (_.isLButton(e)) {
_.firLDownT = new Date();
_.isLDown = true;
_.firLDownClientX = e.clientX; //记录第一次按下鼠标的位置,用于判断是否为移动事件,当幅度>5px判定为移动.
_.firLDownClientY = e.clientY;
_.funcAMouseOn(e);
} else if (_.isRButton(lib.getEvent())) {
_.isRDown = true;
_.firRDownT = new Date();
}
return false; //阻止消息向外层元素传播.
};
//任务5,在此元素区域中,当鼠标左键按住一段时间后放开时,调用functioin funcBLeftMouseUp(){//do something}。
_.funcBLeftMouseUp = function () {
//"调用funcBLeftMouseUp";
if (_.isLMoveWhileDown == true) { //如果按住移动元素后放开
_.isLMoveWhileDown = false;
p.funForLMouseUpAfterMoveWhileDown();
} else { //如果按住元素静止一段时间后放开
p.funForLMouseUp();
}
_.isFirstMousedownMove = false; //恢复到初始标识状态。
};
_.funcBRightClick = function () {
//调用funForRMouseClick
p.funForRMouseClick(); //鼠标右键单击.
};
//_.a.onmouseup=function(){if(_.isLDown)_.funcBLeftMouseUp();_.isLDown=false;} ;
_.EleToEvent.onmouseup = function () {
if (_.isLButton(lib.getEvent())) {
_.firUpT = new Date(); //记录左键第一次放开的时间.
if (_.isLDown) _.funcBLeftMouseUp();
_.isLDown = false;
} else if (_.isRButton(lib.getEvent())) {
_.firRUpT = new Date();
if (_.isRDown && (_.firRUpT.getTime() - _.firRDownT.getTime() < 200)) {
_.funcBRightClick();
_.isRDown = false;
}
}
return false; //阻止消息向外层元素传播.
};
if (window.attachEvent) {
_.active_element = document.activeElement;
_.bIsMSIE = true;
document.onfocusout = function () {
if (_.bIsMSIE && (_.active_element != document.activeElement)) {
_.active_element = document.activeElement;
} else {
if (_.isLDown) _.funcBLeftMouseUp();
_.isLDown = false;
}
};
} else {
window.onblur = function () {
if (_.isLDown) _.funcBLeftMouseUp();
_.isLDown = false;
return false; //阻止消息向外层元素传播.
};
}
//任务6,在此元素区域中,当单击鼠标左键时,调用functioin funcBLeftClick(){//do something}。
// _.funcBLeftClick = function () {
// //调用funcBLeftClick";
// p.funForLMouseClick();
// };
_.EleToEvent.onclick = function () {
clearTimeout(_.timeFunName);
_.timeFunName = setTimeout(function () {
if (_.isDbClick == 0 && _.firUpT && _.firUpT && _.firUpT.getTime() - _.firLDownT.getTime() < 500) { //如果不是双击事件时,且按下左键与放开左键的时间间隔小于500ms,则认定为单击事件.
// _.funcBLeftClick();
}
_.isDbClick = 0;
}, 300); //在单击事件完成300ms后,判断此事件是单击还是双击.
return false; //阻止消息向外层元素传播.
};
_.funcBLeftDbClick = function () {
//"调用funForLMouseDblclick";
if (p.funForLMouseDblclick)
p.funForLMouseDblclick();
};
_.EleToEvent.ondblclick = function () {
_.isDbClick = 1;
_.funcBLeftDbClick();
return false; //阻止消息向外层元素传播.
};
}
//-----------------------------------------------------------
//+-------------------------class web------------------------
B.Web = function (p, q, Link, Note, Cate, Cr, Key, Lans, tagName, parent) //Flag 1
{
Region.call(this); //inherit from the Class Region
if (B.WebBase != U) {
B.WebBase.call(this);
}
var _ = this;
_.ID = p.toString();
_.Name = q;
_.Link = Link || "";
_.Note = Note || '';
_.Cate = Cate; //category.
_.Cr = Cr; //creator
_.Key = Key;
_.Lans = Lans; //languages
_.E = document.createDocumentFragment();
_.EditEle = U; // the element of editting the "web" data.
_.ShowDeleteEle = $CE("DIV");
_.isSelected = false;
_.isLMousedown = 0; //while the left mouse is pressed down and haven't been released.
_.ContainerFlag = 0;
_.Parent = parent;
_.isFirstMousedownMove = false;
_.initialOffsetX = 0; //the offset between the lefttop of the ele and the position of the mouse
_.initialOffsetY = 0;
_.c = function () {
if (!!_.Link) { //_.Link is not null.
_.E = $CE("SPAN");
if (_.Link.match(/(http|https|ftp|mms|rtsp|gopher|socks4|socks5|thunder|flashget|qqdl):\/\/.*/)) {
// _.E.href = _.Link;
_.E.href = 'javascript:;'
} else if (_.Link.match(/[\w-]+(\.[\w-]+)+([\w.,@?^=%&amp;:\/~+#-]*[\w@?^=%&amp;\/~+#-])?/)) {
_.E.href = 'javascript:;'
} else {
_.E.href = 'javascript:;'
}
} else {
_.E = $CE("SPAN");
}
$SA(_.E, "id", "webElement2010" + _.ID);
$SA(_.E, "Link", _.Link);
$SA(_.E, "Note", _.Note);
$SA(_.E, "Cate", _.Cate);
$SA(_.E, "eleFlag", "webEle");
_.E.onselectstart = function () {
return false;
};
_.E.title = _.Note;
jQuery(_.E).addClass('web_page_table_row_a_middle');
_.E.innerHTML = _.Name;
var timerId = ''
_.E.addEventListener("click", function () {
console.log(timerId)
if (timerId) {
console.log(2222)
clearTimeout(timerId)
timerId = ''
new EditWeb(_);
} else {
console.log(11111)
timerId = setTimeout(function() {
timerId = ''
if(/^((?!http).)+\..+/.test(_.Link)) {
window.open('http://' + _.Link, '_blank').location;
} else {
window.open(_.Link, '_blank').location;
}
}, 1000);
}
})
// _.E.addEventListener("dbclick", function () {
// console.log(2211)
// })
_.funForLMouseDown = function () {};
_.funForLMouseUp = function () {};
// _.funForLMouseClick = function () {
// console.log(1)
// if (Sys.isMiniScreen) {
// // 显示下垂式编辑框
// var webDialogTag = document.createElement('div');
// webDialog.innerHTML = "<a href='" + this.Link + "'>open</a><br/>";
// webDialog.innerHTML += "title: <input type='text' value='" + this.Name + "'/><br/>";
// webDialog.innerHTML += "link: <input type='text' value='" + this.Link + "'/><br/>";
// webDialog.innerHTML += "note: <input type='text' value='" + this.Note + "'/><br/>";
// webDialog.innerHTML += "<input type='button' value='Save'/><input type='button' value='Canceal'/>";
// web.DialogTag.cssText = "position : absolute; z-Index : 10; left : 0px; top : 0px; width : 100%; height : 100%;";
// document.body.appendChild(webDialogTag);
// } else {
// if (_.Link.match(/(http|https|ftp|mms|rtsp|gopher|socks4|socks5|thunder|flashget|qqdl):\/\/.*/)) {
// (new ForceWindow()).open(_.Link);
// } else if (_.Link.match(/[\w-]+(\.[\w-]+)+([\w.,@?^=%&amp;:\/~+#-]*[\w@?^=%&amp;\/~+#-])?/)) {
// (new ForceWindow()).open('http://' + _.Link);
// } else {
// (new ForceWindow()).open(_.Link);
// }
// }
// _.Parent.handleLastOperateWeb(_); //显示或隐藏当前Web.
// };
// _.funForLMouseDblclick = function () {
// var t = new EditWeb(_);
// console.log(2)
// };
_.funForStartLMouseMoveWhileDown = function () { //开始移动。
g.dragData = _;
var e = lib.getEvent();
_.isLMoveWhileDown = true;
_.isFirstMousedownMove = true;
g.initialOffsetX = _.initialOffsetX = e.clientX - _.RecLeft;
g.initialOffsetY = _.initialOffsetY = e.clientY - _.RecTop;
_.dragWeb = _.E.cloneNode(true);
_.dragWeb.id = "drag" + _.ID;
_.E.style.position = "absolute";
_.E.parentNode.insertBefore(_.dragWeb, _.E);
var maskLayer;
if (U == $("maskeLayer")) {
var maskLayer = $CE("div");
maskLayer.id = "maskeLayer";
lib.dom.setStyle(maskLayer, "position:absolute;z-Index:8;background-color:red;opacity:.50;moz-opacity:0.5;filter:alpha(opacity=30);");
maskLayer.style.width = _.E.style.width;
maskLayer.style.height = _.E.style.height;
maskLayer.style.cursor = "move";
_.E.appendChild(maskLayer);
} else {
maskLayer = $("maskeLayer");
}
try {
maskLayer.setCapture();
} catch (ex) {};
//_.Ele才是被拖动的元素.
g.elementDragClass = new ThreeDomEleClass(_.E, _.dragWeb, _.dragWeb); //????
maskLayer.style.left = _.E.style.left = (e.clientX - _.initialOffsetX) + "px";
maskLayer.style.top = _.E.style.top = (e.clientY - _.initialOffsetY) + "px";
_.E.style.borderStyle = "dashed";
_.E.style.borderWidth = "thin";
_.E.style.cursor = "move";
_.E.style.zIndex = 3;
};
_.funForLMouseMoveWhileDown = function () { //处于移动中。
var e = lib.getEvent();
_.E.style.left = (e.clientX - _.initialOffsetX) + "px";
_.E.style.top = (e.clientY - _.initialOffsetY) + "px";
};
_.funForRMouseDown = function () {};
_.funForRMouseUp = function () {};
_.funForRMouseClick = function () {};
_.funForRMouseDblclick = function () {};
_.funForRMouseMoveWhileDown = function () {};
_.funForMouseMoveWithoutDown = function () {};
_.funForLMouseUpAfterMoveWhileDown = function () { //tmp:t,a,
//<----state----
g.dragData = undefined;
_.isFirstMousedownMove = false; //恢复到初始标识状态。
//----state---->
_.E.position = "";
var maskLayer = $("maskeLayer");
if (maskLayer.parentNode) {
maskLayer.parentNode.removeChild(maskLayer);
}
var index = -1;
var t = $("drag" + _.ID); //拖动完毕,删除被复制的移动元素_.Ele.cloneNode(true);
if (t != null) {
lib.dom.setStyle(_.E, t.style.cssText); //将被拖动元素的css恢复到初始状态。
t.parentNode.removeChild(t);
}
//start
var e = lib.getEvent();
if (u(g.elementDragClass)) { //在鼠标左键单击web时,此条件为真.
return;
}
if (u(g.elementDragClass.drag)) { //在鼠标左键单击web时,此条件为真.
return;
}
if (g.elementDragClass.drag.ele.parentNode != null) {
g.elementDragClass.drag.ele.parentNode.removeChild(g.elementDragClass.drag.ele);
}
g.tableRowWeb = getDataByMouse(e); //放开鼠标时所在位置的table、row、web数据
_.E.style.visibility = "";
if (!u(g.tableRowWeb.tableData) && !u(g.tableRowWeb.tableData.selectWeb)) {
g.tableRowWeb.tableData.selectWeb.n();
if (!u(g.tableRowWeb.tableData.selectWebRow)) {
g.tableRowWeb.tableData.selectWebRow.delButton.style.visibility = "hidden";
}
}
if (!u(g.tableRowWeb.rowData))
g.tableRowWeb.tableData.selectWebRow = g.tableRowWeb.rowData; //鼠标移动后放开左键时所在的WebRow
if (!u(g.tableRowWeb.tableData)) {
if (!u(g.tableRowWeb.rowData)) {
if (g.elementDragClass.source.ele.parentNode != null) {
g.elementDragClass.source.ele.parentNode.removeChild(g.elementDragClass.source.ele);
}
if (!u(g.tableRowWeb.webData)) {
g.tableRowWeb.webData.isLMousedown = 0; //[0,*1]-tag: the left mouse is lost or up
g.selectedData.resume();
if (g.tableRowWeb.webData.ID != _.ID) { //如果插入其它元素位置上.
index = lib.data.getOrder(g.tableRowWeb.rowData.Webs, g.tableRowWeb.webData);
_.moveWebItem(g.tableRowWeb.rowData, index); //添加web
} else {
_.Parent.d();
}
} else { //when g.tableRowWeb.webData == undefined
var b = _.Parent; //don't remove
var index = g.tableRowWeb.rowData.Webs.length;
_.moveWebItem(g.tableRowWeb.rowData, index); //添加web
}
if (g.tableRowWeb.rowData.ID != _.Parent.ID) { //当前web所在的row改变了
_.n(); //原来位置所在row隐藏x
lib.dom.setStyle(_.Parent.delButton, "cursor:default;visibility:hidden;");
}
_.Parent = g.tableRowWeb.rowData;
} else { // when (g.tableRowWeb.rowData == undefined)
//do nothing.
}
} else { //g.tableRowWeb.tableData == undefined
}
g.elementDragClass = U;
//end
_.Parent.handleLastOperateWeb(_); //显示或隐藏当前Web.
};
//----------<a> attribute--------------
if (Sys.isMiniScreen || navigator.userAgent.match(/iPad/i)) //如果屏幕很小或者是ipad用户
{
// do nothing
} else {
EventForEle.call(_, {
"E": _.E,
"funForLMouseDown": _.funForLMouseDown,
"funForLMouseUp": _.funForLMouseUp,
// "funForLMouseClick": _.funForLMouseClick,
// "funForLMouseDblclick": _.funForLMouseDblclick,
"funForLMouseMoveWhileDown": _.funForLMouseMoveWhileDown,
"funForRMouseDown": _.funForRMouseDown,
"funForRMouseUp": _.funForRMouseUp,
"funForRMouseClick": _.funForRMouseClick,
"funForRMouseDblclick": _.funForRMouseDblclick,
"funForRMouseMoveWhileDown": _.funForRMouseMoveWhileDown,
"funForMouseMoveWithoutDown": _.funForMouseMoveWithoutDown,
"funForLMouseUpAfterMoveWhileDown": _.funForLMouseUpAfterMoveWhileDown
}); //inherit from the Class EventForWeb.
}
return _;
};
}
//*-----------------------------------------------------
//+--------------------class WebRow---------------------
B.WebRow = function (p, q, parent, webIDHTML, numDisFirst) {
var _ = this;
Region.call(_); //inherit from the Class Region
if (B.WebRowBase != U) {
B.WebRowBase.call(this);
}
_.ID = p.toString();
_.CateName = q;
_.webIDHTML = webIDHTML;
_.numDisFirst = numDisFirst;
_.E = document.createDocumentFragment();
_.dragEle = U;
_.CateNameEle = U;
_.addButton = $CE("A");
_.delButton = $CE("A");
_.delRowButton = $CE("A"); // delete a row.
_.leftArrow = $CE("A");
_.rightArrow = $CE("A");
_.editAndAddEle = $CE("DIV");
_.editCateNameEle = U; //edit the category's name.
_.lastOperateWeb = U;
_.Parent = parent;
_.initialOffsetX = 0;
_.initialOffsetY = 0;
_.isFirstMousedownMove = false;
_.websIndex = [];
_.Webs = [];
_.dragTableDiv = {};
_.lastDisWeb = {}; //在最后显示的web
_.contentWidth = 998 - 12 - 12; // width - paddingLeft - paddingRight
_.previousArrowsWidth = 50;
_.nextArrowsWidth = 25;
_.addButtonWidth = 11;
_.deleteButtonWidth = 10;
_.handleLastOperateWeb = function (_web) {
if (u(_web.Parent.lastOperateWeb)) { //如果以前没有选定任何元素,则突出显示当前元素,打开"x"..
_web.Parent.lastOperateWeb = _web;
_web.m();
lib.dom.setStyle(_web.Parent.delButton, "cursor:default;");
} else if (_web.Parent.lastOperateWeb === _web) { //如果以前选定了当前元素,则不突出显示当前元素,关闭"x".
_web.Parent.lastOperateWeb = U;
_web.n();
lib.dom.setStyle(_web.Parent.delButton, "cursor:default;visibility:hidden;");
} else { //如果以前选定了本RowWeb中的其它元素,则不突出显示以前元素而是突出显示当前元素,打开"x".
_web.Parent.lastOperateWeb.n();
_web.Parent.lastOperateWeb = _web;
_web.m();
lib.dom.setStyle(_web.Parent.delButton, "cursor:default;");
}
};
_.s = function (p) {
if (u(p))
return;
if (__typeof__(p) === 'String') {
p = eval('(' + p + ')');
}
//++-----create the mapping table--------------
var tmpWebs;
if (u(p.Mrowwebs)) { //如果没有子元素
} else { //如果有子元素
if (u(p.Mrowwebs.web.length)) { //如果只有一个元素
tmpWebs = [];
tmpWebs.push(p.Mrowwebs.web);
} else { ////如果有多个个元素
tmpWebs = p.Mrowwebs.web;
}
for (var i = 0; i < tmpWebs.length; i++) {
var tmpA = new B.Web(tmpWebs[i].ID,
tmpWebs[i].Name,
tmpWebs[i].Link,
tmpWebs[i].Note,
tmpWebs[i].Cate,
tmpWebs[i].Cr,
tmpWebs[i].Key,
tmpWebs[i].Lans,
"A",
_);
_.Webs.push(tmpA);
}
}
};
_.funForMouseOver = function () {
if (0 < _.numDisFirst) { //if there is items hidening at the left .
_.leftArrow.style.visibility = "";
}
var tmpIndex = lib.data.getOrder(_.Webs, _.lastDisWeb);
if (tmpIndex < _.Webs.length - 1) { //if there is items hidening at the right.
_.rightArrow.style.display = "";
}
_.addButton.style.display = "";
_.delRowButton.style.display = "";
};
_.funForMouseOut = function () {
_.leftArrow.style.visibility = "hidden";
_.rightArrow.style.display = "none";
_.addButton.style.display = "none";
_.delRowButton.style.display = "none";
};
_.c = function () { //tmp:a,b,c,
var a = $CE("td");
a.id = _.ID.toString();;
$SA(a, "relationalID", _.Parent.ID + "-" + _.ID);
jQuery(a).addClass('web_page_table_row_middle');
_.CateNameEle = $CE("A");
_.CateNameEle.innerHTML = _.CateName;
$SA(_.CateNameEle, "Link", g.domainDirectory + "/" + _.CateName);
$SA(_.CateNameEle, "ParentID", _.ID);
$SA(_.CateNameEle, "eleFlag", "CateNameEle");
$SA(_.CateNameEle, "class", "web_page_table_row_middle_crh");
//lib.dom.setStyle(_.CateNameEle, "margin-right:60px;color:#686868;cursor:default;font-size: 14px;"); 2020-3-27
a.appendChild(_.CateNameEle);
_.leftArrow.innerHTML = "<div class='leftArr' style='display:inline-block;height:0px;line-height:0px;;border:6px solid #000;border-color:transparent #629444 transparent transparent;'>&nbsp;&nbsp;</div>";
$SA(_.leftArrow, "id", "lfArrow" + _.ID);
$SA(_.leftArrow, "ParentID", _.ID);
$SA(_.leftArrow, "title", "previous links");
_.leftArrow.onclick = function () { // goPrevious; // addWeb is a function.
// 当numDisFirst为0时,表示显示了第一个链接,把“左移”按钮置为失效
if (_.numDisFirst === 0) {
return;
}
var preWeb = _.getFWebFromPreRow(_.Webs[_.numDisFirst]);
_.numDisFirst = lib.data.getOrder(_.Webs, preWeb);
var t = "{'action':'numDisFirst','data':{'table':{'ID':'" + _.Parent.ID + "','row':{'ID':'" + _.ID + "','numDisFirst':'" + _.numDisFirst + "'}}}}";
g.ComWithServer.add(g.URI.protocol + '://' + g.URI.authority + "/ResAddApp.aspx?paraStr=" + paraStr +"&flag=" + g.subdir, t);
g.ComWithServer.startSend(); //将信息发往服务器.
_.d();
_.refresh(); //如果不记录位置数据,拖动将不正常.offset为0
};
lib.dom.setStyle(_.leftArrow, "cursor:default;visibility:hidden;");
a.appendChild(_.leftArrow);
var title = "";
var b = lib.dom.getOffsetWidth(_.CateName) + _.previousArrowsWidth;
var k = g.mainTableWidth / 1068;
if (Sys.isMiniScreen) {
k = g.mainTableWidth / 450;
}
for (var i = 0; i < _.Webs.length; i++) {
if (i < _.numDisFirst) {} else {
var c = _.Webs[i];
if (u(c.Name)) continue;
var webOffsetWidth = lib.dom.getOffsetWidth(c.Name) + 30;
// 累计多个链接的宽度和
if (b + webOffsetWidth + _.nextArrowsWidth + _.addButtonWidth + _.deleteButtonWidth < _.contentWidth || lib.browser.isMobile) { //显示10个link (2020手机浏览器全部显示)
if (u(c.Name)) alert("");
b = b + webOffsetWidth;
// console.log(c.Name + ': ' + b);
c.Parent = _;
a.appendChild(c.c().E);
_.lastDisWeb = c;
}
}
}
_.rightArrow.innerHTML = "&nbsp;&nbsp;<div style='display:inline-block;height:0px;line-height:0px;border:6px solid #000;border-color:transparent transparent transparent #629444;'></div>&nbsp;";
$SA(_.rightArrow, "id", "rtArrow" + _.ID);
$SA(_.rightArrow, "ParentID", _.ID);
$SA(_.rightArrow, "title", "next links2");
_.rightArrow.onclick = function () {
var tmpIndex = lib.data.getOrder(_.Webs, _.lastDisWeb);
if (tmpIndex < _.Webs.length - 1) {
_.numDisFirst = tmpIndex + 1;
var t = "{'action':'numDisFirst','data':{'table':{'ID':'" + _.Parent.ID + "','row':{'ID':'" + _.ID + "','numDisFirst':'" + _.numDisFirst + "'}}}}";
g.ComWithServer.add(g.URI.protocol + '://' + g.URI.authority + "/ResAddApp.aspx?paraStr=" + paraStr+"&flag=" + g.subdir, t);
g.ComWithServer.startSend(); //将信息发往服务器.
_.d();
_.refresh();
} else {
return;
}
}; //goNext; // addWeb is a function.
lib.dom.setStyle(_.rightArrow, "cursor:default;display:none;");
a.appendChild(_.rightArrow);
// _.addButton.innerHTML = "<div id='add" + _.ID + "' ParentID='" + _.ID + "' relationalID='" + _.Parent.ID + "-" + _.ID + "' style=''>+</div>";
_.addButton.innerHTML = "+"
_.addButton.setAttribute('class', 'plus');
_.addButton.setAttribute('id', 'id' + _.ID)
_.addButton.setAttribute('ParentID', _.ID)
_.addButton.setAttribute('relationalID', _.Parent.ID + "-" + _.ID)
$SA(_.addButton, "title", "Add a link");
_.addButton.onclick = addWeb; // addWeb is a function.
lib.dom.setStyle(_.addButton, "color:#55A520;cursor:default;display:none;");
//document.writeln("isMobile: " + lib.browser.isMobile);
if (g.state.isOperable && lib.browser.isMobile) { //如果是当前用户的网页,并且是手机浏览器,则不显示.
_.addButton.style.display = "";
}
a.appendChild(_.addButton);
if (g.state.isOperable) { //如果用户登录则显示X.
_.delButton.innerHTML = "x";
}
$SA(_.delButton, "id", "delete" + _.ID);
$SA(_.delButton, "ParentID", _.ID);
$SA(_.delButton, "title", "Delete a link");
_.delButton.onclick = function () {
_.h();
lib.dom.setStyle(_.delButton, "cursor:default;display:none;");
};
lib.dom.setStyle(_.delButton, "cursor:default;display:none;");
a.appendChild(_.delButton);
lib.dom.clearChildren(_.E); //如果有子节点,清除子节点.如果不清除子节点可能会重复添加了节点.
if (_.E.parentNode == U) {
_.E = $CE("TR");
}
lib.dom.setStyle(_.E, "background-color:#fff;height:30px;");
$SA(_.E, "relationalID", _.Parent.ID + "-" + _.ID);
_.E.appendChild(a);
if (g.state.isOperable) { //如果用户登录则显示X.
_.delRowButton.onclick = deleteRow;
$SA(_.delRowButton, "title", "Delete this row");
}
_.delRowButton.setAttribute('class', 'wsd')
$SA(_.delRowButton, "id", "deleteRow" + _.ID);
$SA(_.delRowButton, "relationalID", _.Parent.ID + "-" + _.ID);
lib.dom.setStyle(_.delRowButton, "color:#55A520;cursor:default;margin-right:4px");
_.delRowButton.style.display = "none";
var tmp = $CE("td");
lib.dom.setStyle(tmp, "border-top:solid 2px #FFF;border-bottom:solid 2px #FFF;");
tmp.style.width = "10px";
tmp.appendChild(_.delRowButton);
_.E.appendChild(tmp);
_.E.onmousedown = function (p) {
var isLButton;
if (navigator.userAgent.indexOf("MSIE") > 0)
isLButton = (lib.getEvent().button == 1); //IE中左键标记为1
else
isLButton = (lib.getEvent().button == 0); //Firefox中左键标记为0
if (isLButton) {
eventHandler.fun_onmousedown(p);
}
};
_.E.onmouseover = _.funForMouseOver;
_.E.onmouseout = _.funForMouseOut;
$SA(_.E, "id", _.ID);
$SA(_.E, "ParentID", _.Parent.ID);
_.funForLMouseDown = function () {};
_.funForLMouseUp = function () {};
_.funForLMouseClick = function () {
open(_.CateNameEle.getAttribute("Link"));
};
_.funForLMouseDblclick = function () {
if (U != _.editCateNameEle && U != _.editCateNameEle.parentNode) {
_.editCateNameEle.parentNode.removeChild(_.editCateNameEle);
}
_.editCateNameEle = $CE("DIV");
_.editCateNameEle.innerHTML = "<input id='cateNameInputID' style='border: 0;font-size: 14px;height: 100%;' type='text' value='" + _.CateName + "' size='" + lib.data.getStrLength(_.CateName) + "' onkeydown='closeCateNameEditor(this)'/><span style=' display: inline-block;background: #cdcbcb;height: 15px;width: 15px;color: #fff;border-radius: 50%;line-height: 14px;font-size: 12px;text-align: center;position: absolute;right: 0px;top: 50%;transform: translateY(-50%);' onclick='closeCateNameEditor(this)'>x</span>";
$SA(_.editCateNameEle, "relationalID", _.Parent.ID + "-" + _.ID);
$SA(_.editCateNameEle, "style", " height: 23px; line-height: 20px; padding-right: 15px;border: 1px solid #629444; border-left: 5px solid #629444; border-radius: 5px; padding-left: 5px;display:inline;background-color: #fff;borderStyle:solid;borderWidth:1px;borderColor:#5858FA;position:absolute;");
addEleAround(_.CateNameEle, _.editCateNameEle, "same");
$("cateNameInputID").focus();
_.CateNameEle.style.visibility = "hidden";
};
_.funForStartLMouseMoveWhileDown = function () { //开始移动。
//<----state----
_.isFirstMousedownMove = true;
//----state---->
var e = lib.getEvent();
_.initialOffsetX = e.x - _.RecLeft;
_.initialOffsetY = e.y - _.RecTop;
_.dragEle = $CE("DIV"); //create a DIV element to contain the table. It can be dragged.
var dragTable = _.Parent.E.cloneNode(false);
var hiddenEle = _.E.cloneNode(true);
// hiddenEle.style.visibility = "hidden";
_.E.parentNode.insertBefore(hiddenEle, _.E);
dragTable.appendChild(_.E);
_.dragEle.appendChild(dragTable);
_.dragEle.style.position = "absolute";
_.E.style.cursor = "move";
document.body.appendChild(_.dragEle);
};
_.funForLMouseMoveWhileDown = function () { //当拖动某行的标题时,会运行。
var e = lib.getEvent();
_.dragEle.style.left = (e.x - _.initialOffsetX) + "px";
_.dragEle.style.top = (e.y - _.initialOffsetY) + "px";
};
_.funForRMouseDown = function () {};
_.funForRMouseUp = function () {};
_.funForRMouseClick = function () {};
_.funForRMouseDblclick = function () {};
_.funForRMouseMoveWhileDown = function () {};
_.funForMouseMoveWithoutDown = function () {};
_.funForLMouseUpAfterMoveWhileDown = function () { //t,a,b,
g.dragEle = U;
g.initialOffsetX = 0;
g.initialOffsetY = 0;
var e = lib.formatEvent(lib.getEvent());
_.isFirstMousedownMove = false; //恢复到初始标识状态。
_.E.style.position = "";
var stillData = getDataByMouse(e);
var webRowE = stillData.rowData; //鼠标处的静止的webRow
if (!u(webRowE)) {
//exchange the two rows' position.
var tmpCates = webRowE.Parent.Categories;
var k = lib.data.getOrder(tmpCates, webRowE); //鼠标处的静止的WebRow的索引位置
var i = lib.data.getOrder(_.Parent.Categories, _); //获取移动的_paraWebRow的索引位置
var stillRowMiddleX = (_.RecLeft + _.RecRight) / 2; //获取移动的_paraWebRow的原处的坐标
var t = 0; //偏移量.
if ((findPos(_.dragEle).absoluteTop + _.dragEle.clientHeight / 2) > ((_.RecTop + _.RecBottom) / 2)) { //如果是想下移动
t++;
} else {
//do nothing.
}
var a = k + t;
_.moveRowItem(stillData.tableData, a);
} else if (stillData.tableData != U && stillData.rowData == U) {
_.moveRowItem(stillData.tableData, 0);
} else {
//do nothing.
}
_.Parent.d(); //未测试。
_.dragEle.parentNode.removeChild(_.dragEle);
_.E.onmousedown = eventHandler.fun_onmousedown;
};
EventForEle.call(_, {
"E": _.CateNameEle,
"funForLMouseDown": _.funForLMouseDown,
"funForLMouseUp": _.funForLMouseUp,
"funForLMouseClick": _.funForLMouseClick,
"funForLMouseDblclick": _.funForLMouseDblclick,
"funForLMouseMoveWhileDown": _.funForLMouseMoveWhileDown,
"funForRMouseDown": _.funForRMouseDown,
"funForRMouseUp": _.funForRMouseUp,
"funForRMouseClick": _.funForRMouseClick,
"funForRMouseDblclick": _.funForRMouseDblclick,
"funForRMouseMoveWhileDown": _.funForRMouseMoveWhileDown,
"funForMouseMoveWithoutDown": _.funForMouseMoveWithoutDown,
"funForLMouseUpAfterMoveWhileDown": _.funForLMouseUpAfterMoveWhileDown
}); //inherit from the Class EventForWeb.
return _;
};
}
//+--------------------------------------------------
B.WebTable = function (p, q, containerEle, Parent) {
var _ = this;
Region.call(_); //inherit from the Class Region
if (B.WebTableBase != U) {
B.WebTableBase.call(this);
}
_.ID = p.toString();
_.Name = q;
_.Parent = Parent;
_.Categories = [];
_.outerHTML = U;
_.E = document.createDocumentFragment();
_.Container = containerEle;
_.titleEle = $CE("A");
_.editTableTitleEle = U;
_.delTableButton = $CE("A");
_.headEle = U; //头元素
_.TBodyEle = U;
_.selectWeb = U;
_.selectWebRow = U;
_.lastOperateRow = U; //record the category which was operated.
_.inicialOffsetX = {};
_.inicialOffsetY = {};
_.isFirstMousedownMove = false;
d_queren_g = function () {
_.f();
var index = _.Parent.Tables.indexOf(_)
_.Parent.deleteDataAndDom(index);
_.Parent.refresh();
}
var d_del_i = 0;
_.g = function () {
document.getElementById("duihuakuang").style.display = "block";
// localStorage.setItem('type_active', 1);
d_del_i = lib.data.getOrder(_.Parent.Tables, _);
};
_.m = function () {
if (!+"\v1") {
return _.TBodyEle;
} else {
return _.E;
}
};
_.c = function () { //tmp:t
_.E = $CE("table");
if (Sys.isMiniScreen) {
lib.dom.setStyle(_.E, "width:100%;");
// lib.dom.setStyle(_.E, "width:" + (g.mainTableWidth) + "px;");
} else {
lib.dom.setStyle(_.E, "width:100%;");
// lib.dom.setStyle(_.E, "width:" + g.mainTableWidth + "px;");
}
_.E.className += "roundTable";
if (!+"\v1") {
this.TBodyEle = $CE("TBODY");
}
tmpTr = $CE("TR"); //头元素
_.headEle = tmpTd = $CE("TD");
$SA(_.headEle, "colspan", "2");
tmpTr.appendChild(tmpTd);
if (g.state.isOperable) { //如果用户登录则显示X.
_.delTableButton.onclick = _.g;
} else {
_.delTableButton.onclick = function () {
_.addTableToUser();
};
}
_.delTableButton.setAttribute('class', 'wsd');
$SA(_.delTableButton, "title", "Delete this table");
$SA(_.delTableButton, "id", "deleteTable" + _.ID);
$SA(_.delTableButton, "ParentID", _.ID);
$SA(_.delTableButton, "relationalID", _.ID);
jQuery(_.delTableButton).addClass('web_page_table_btn_deleteTable');
_.titleEle.innerHTML = u(_.Name) ? "." : _.Name;
_.titleEle.ondblclick = _.h;
_.headEle.appendChild(_.titleEle);
_.headEle.appendChild(_.delTableButton);
_.headEle.style.backgroundColor = g.config.headBackgroundColor;
_.headEle.className += "tableTitle";
_.m().appendChild(tmpTr);
for (var i = 0; i < _.Categories.length; i++) {
_.Categories[i].Parent = _;
_.m().appendChild(_.Categories[i].c().E);
}
tmpTr = $CE("TR");
tmpTd = $CE("TD");
jQuery(tmpTd).addClass('web_page_table_row_last');
tmpTd.innerHTML = "<a title='Add a table' relationalID='" + _.ID + "' class='addTableButton' onclick='editAddTable(this);'>" + lan["addTable"] + "</a>" + "<a title='Add a category' relationalID='" + _.ID + "' style='cursor:default;float:right;background-color:#629444;width:15px; height:15px; line-height:14px;text-align:center; margin-top:3px;' onclick='g.editAddCategory(this);'>+</a>";
$SA(tmpTd, "colspan", "2");
tmpTr.appendChild(tmpTd);
_.m().appendChild(tmpTr);
if (!+"\v1") {
_.E.appendChild(_.TBodyEle);
}
_.funForLMouseDown = function () {
};
_.funForLMouseUp = function () {
};
_.funForLMouseClick = function () {};
_.funForLMouseDblclick = function () {};
_.funForStartLMouseMoveWhileDown = function () {
//<----state----
_.isLMoveWhileDown = true
_.isFirstMousedownMove = true;
//----state---->
g.dragData = _;
e = lib.getEvent();
_.inicialOffsetX = e.clientX - _.RecLeft;
_.inicialOffsetY = e.clientY - _.RecTop;
var t = _.E.cloneNode(true);
var tmpNextEle = _.E.nextSibling;
if (u(tmpNextEle)) {
_.Container.appendChild(t);
} else {
_.Container.insertBefore(t, tmpNextEle);
}
t.id = "drag" + _.ID;
// t.style.visibility = "hidden";
_.E.style.position = "absolute";
_.E.style.cursor = "move";
_.E.style.margin = "0px"; //将margin值设为0,防止相对鼠标的偏移。
};
_.funForLMouseMoveWhileDown = function () {
e = lib.getEvent();
_.E.style.left = e.clientX - _.inicialOffsetX + "px";
_.E.style.top = e.clientY - _.inicialOffsetY + "px";
};
_.funForRMouseDown = function () {};
_.funForRMouseUp = function () {};
_.funForRMouseClick = function () {};
_.funForRMouseDblclick = function () {};
_.funForRMouseMoveWhileDown = function () {};
_.funForMouseMoveWithoutDown = function () {};
_.funForLMouseUpAfterMoveWhileDown = function () {
//<----state----
_.isLMoveWhileDown = false;
//----state---->
g.dragData = undefined;
var a = (findPos(_.E).absoluteTop + _.E.clientHeight / 2); //放在此,先保存位置
e = lib.getEvent();
g.tableRowWeb = getDataByMouse(e);
var t = $("drag" + _.ID);
t.parentNode.removeChild(t);
_.E.style.cursor = "default";
_.E.style.position = "";
_.E.style.margin = "10px 0px 10px 0px"; //将margin值恢复原状。 index.css .roundTable margin:10px 0px 10px 0px;
if (!u(g.tableRowWeb.tableData)) {
if (g.tableRowWeb.tableData.ID != _.ID) {
var k = lib.data.getOrder(g.tableRowWeb.tableData.Parent.Tables, g.tableRowWeb.tableData);
var i = lib.data.getOrder(_.Parent.Tables, _);
var tmpAdd = 0; //偏移量.
var b = ((_.RecTop + _.RecBottom) / 2);
if (a > b) { //如果是想下移动
tmpAdd++;
} else {
//do nothing.
}
var tmpIndex = k + tmpAdd;
_.moveTableItem(_.Parent, tmpIndex);
}
}
};
EventForEle.call(_, {
"E": _.headEle,
"funForLMouseDown": _.funForLMouseDown,
"funForLMouseUp": _.funForLMouseUp,
"funForLMouseClick": _.funForLMouseClick,
"funForLMouseDblclick": _.funForLMouseDblclick,
"funForLMouseMoveWhileDown": _.funForLMouseMoveWhileDown,
"funForRMouseDown": _.funForRMouseDown,
"funForRMouseUp": _.funForRMouseUp,
"funForRMouseClick": _.funForRMouseClick,
"funForRMouseDblclick": _.funForRMouseDblclick,
"funForRMouseMoveWhileDown": _.funForRMouseMoveWhileDown,
"funForMouseMoveWithoutDown": _.funForMouseMoveWithoutDown,
"funForLMouseUpAfterMoveWhileDown": _.funForLMouseUpAfterMoveWhileDown
}); //inherit from the Class EventForWeb.
return _;
};
_.h = function () {
_.editTableTitleEle = $CE("DIV");
//_.editTableTitleEle.onmousemove = function () { var e = lib.getEvent(); e = EventUtil.formatEvent(e); if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = true; return false; };
_.editTableTitleEle.innerHTML = "<input id='tableNameInputID' style='outline:none;border: none;max-width: 900px' type='text' value='" + (_.Name || ".") + "' size='" + (u(_.Name) ? 5 : lib.data.getStrLength(_.Name)) + "' onkeydown='closeTableTitleEditor(this)'/><span style='cursor:default;width: 14px;height: 14px;background-image: url(\"image/3.png\");background-repeat: no-repeat;border-radius: 50%;background-color: #dcdcdc;background-position: center;background-size: 130% 130%;display: inline-block;margin-right: 3px' onclick='closeTableTitleEditor(this)'></span>";
$SA(_.editTableTitleEle, "ParentID", _.ID);
$SA(_.editTableTitleEle, "style", "display:flex;padding:2px;background-color:#fff;border-radius:5px;borderStyle:solid;borderWidth:1px;borderColor:#5858FA;position:absolute;border: 1px solid #629444;text-indent:10px;");
addEleAround(_.titleEle, _.editTableTitleEle, "same");
$("tableNameInputID").focus();
_.titleEle.style.visibility = "hidden";
};
_.s = function (p) { //tmp:t,
if (u(p))
return;
if (__typeof__(p) === 'String') {
p = eval('(' + p + ')');
}
if (u(p.Mrows)) {
return;
}
var t = p.Mrows.row;
if (u(t.length)) {
t = [];
t.push(p.Mrows.row);
}
for (var i = 0; i < t.length; i++) {
var tmpA = new B.WebRow(t[i].Id, t[i].Ct, _, "", t[i].NumDisFirst);
_.Categories.push(tmpA);
tmpA.s(t[i]);
}
};
}
//*--------------------------------------------------
B.Page = function () {
var _ = this;
Region.call(_); //inherit from the Class Region
if (B.PageBase != U) {
B.PageBase.call(this);
}
_.Model = {};
_.Model.Tables = []; //working...
_.E = _.Container = $("tdA");
_.addTable = function () {
};
_.l = function () { //tmp:t,
var t = new B.Page();
for (var i = 0; i < _.Tables.length; i++) {
t.Tables.push(_.Tables[i].l());
}
return t;
};
_.bindData = function (p) { //tmp:t,a, import Data to the table
if (u(p))
return;
if (__typeof__(p) === 'String') {
p = eval('(' + p + ')');
}
_.ID = p.page.Id;
var t = p.page.Mtables.table;
if (u(t.length)) {
t = [];
t.push(p.page.Mtables.table);
}
_.Tables = []; //将Tables数据清空.
for (var i = 0; i < t.length; i++) {
var a = new B.WebTable(t[i].Id, t[i].Name, $("tdA"), _);
_.Tables.push(a);
a.s(t[i]);
}
};
_.createDom = function () {
_.E.innerHTML = ""; //清空子元素
if (_.Tables == null) {
return;
}
for (var i = 0; i < _.Tables.length; i++) {
_.E.appendChild(_.Tables[i].c().E);
}
return _;
};
_.d = function () { //tmp:t,
var t = _.Container;
if (U != t) {
while (t.childNodes.length >= 1) {
t.removeChild(t.firstChild);
}
for (var i = 0; i < _.Tables.length; i++) {
var ele = _.Tables[i].c().E;
_.Container.appendChild(ele);
}
return _;
}
};
_.deleteDataAndDom = function(index) {
// 先删除节点
_.deleteDom(index);
_.deleteData(index);
}
_.deleteData = function(index) {
_.Tables.splice(index, 1);
}
_.deleteDom = function(index) {
_.Container.removeChild(_.Tables[index].E);
}
_.$ = function (p) {
for (var i = 0; i < _.Tables.length; i++) {
if (p == _.Tables[i].ID) {
return _.Tables[i];
}
}
};
}
//+---------------------------------------------------
function getWebFromTablesByID(id, webTables) {
for (var k in webTables) {
if (__typeof__(k) == "WebTable") {
for (var i = 0; i < webTables[k].Categories.length; i++) {
var tmpCate = webTables[k].Categories[i];
for (var j = 0; j < tmpCate.Webs.length; j++) {
if (tmpCate.Webs[j].ID == id) {
return tmpCate.Webs[j];
}
}
}
}
}
}
//*---------------------------------------------------
//+---------------------------------------------------
function getWebByIDWithPre(id, _webTable) {
var preString = "webElement2010";
id = id.substring(preString.length, id.length);
return getWebByID(id, _webTable);
}
//*---------------------------------------------------
//+---------------------------------------------------
function getWebByMose(e) {
for (var k in g.WebTable) {
for (var i = 0; i < g.WebTable[k].Categories.length; i++) {
for (var j = 0, tmpCate = g.WebTable["First"].Categories[i]; j < tmpCate.Webs.length; j++) {
var tmpWeb = tmpCate.Webs[j];
if (tmpWeb.ID == g.elementDragClass.source.ele.getAttribute("ID") && tmpWeb.isOver(e.pageX, e.pageY)) { //edit
return tmpWeb;
}
}
}
}
}
//*---------------------------------------------------
//+---------------------------------------------------
function getDataByMouse(e) //获得鼠标移动后,鼠标所在位置的web元素,不包括被拖动的web元素.
{
var tableData = U;
var rowData = U;
var webData = U;
var isFirst = U;
if (!g.page) {
return;
}
var tmpTables = g.page.Tables;
for (var i in tmpTables) {
if (tmpTables[i].isOverEvent && tmpTables[i].isOverEvent(e)) {
tableData = tmpTables[i];
for (var j = 0; j < tableData.Categories.length; j++) {
if (tableData.Categories[j].isOverEvent(e)) {
rowData = tableData.Categories[j];
for (var k = 0; k < rowData.Webs.length; k++) {
if (rowData.Webs[k].isOverEvent(e)) {
webData = rowData.Webs[k];
break;
}
}
if (rowData.Webs.length > 0 && e.clientX < rowData.Webs[0].RecLeft) {
isFirst = true;
}
break;
}
}
break;
}
}
return {
"tableData": tableData,
"rowData": rowData,
"webData": webData,
"isFirst": isFirst
};
}
//*---------------------------------------------------
function addTable(value) { //tmp:t,a,
if (lib.getEvent().keyCode == 13 || value.type != "text") {
var con = $("addTableID");
var t = con.getElementsByTagName("INPUT")[0];
if (validateInput(t, /^\s*$/g) == false) {
return;
}
var relationalID = con.getAttribute("relationalID");
var tableName = t.value;
var a = new B.WebTable((new Date).getTime() + "TB", tableName, $("tdA"), g.page);
var index = lib.data.getOrder(g.page.Tables, g.page.$(relationalID)) + 1;
a.Parent.Tables.splice(index, 0, a);
a.a(index);
a.Parent.d();
// a.Parent.r();
close(con);
g.tip.display("正在处理数据...");
}
}
//*---------------------------------------------------
//+---------------------------------------------------
function addEleAround(oldEle, newEle, orientation) //orientation: topleft, topright, righttop, rightbottom, bottomright, bottomleft, leftbottom, lefttop, same.
{
document.body.appendChild(newEle);
var newLeft = newEle.offsetLeft;
var newTop = newEle.offsetTop;
var pos = findPos(oldEle);
switch (orientation) {
case "topleft":
newEle.style.left = pos.absoluteLeft + "px";
newEle.style.top = (pos.absoluteTop - newEle.offsetHeight) + "px";
break;
case "topright":
newEle.style.left = (pos.absoluteLeft + oldEle.offsetWidth - newEle.offsetWidth) + "px";
newEle.style.top = (pos.absoluteTop - newEle.offsetHeight) + "px";
break;
case "righttop":
newEle.style.left = (pos.absoluteTop + oldEle.offsetWidth) + "px";
newEle.style.top = pos.absoluteTop + "px";
break;
case "rightbottom":
newEle.style.left = (pos.absoluteLeft - newEle.offsetWidth) + "px";
newEle.style.top = (pos.absoluteTop + oldEle.offsetHeight - newEle.offsetHeight) + "px";
break;
case "bottomright":
newEle.style.left = (pos.absoluteLeft + oldEle.offsetWidth - newEle.offsetWidth) + "px";
newEle.style.top = (pos.absoluteTop + oldEle.offsetHeight) + "px";
break;
case "bottomleft":
newEle.style.left = pos.absoluteLeft + "px";
newEle.style.top = (pos.absoluteTop + oldEle.offsetHeight) + "px";
break;
case "leftbottom":
newEle.style.left = (pos.absoluteLeft - newEle.offsetWidth) + "px";
newEle.style.top = (pos.absoluteTop + oldEle.offsetHeight - newEle.offsetHeight) + "px";
break;
case "lefttop":
newEle.style.left = (pos.absoluteLeft - newEle.offsetWidth) + "px";
newEle.style.top = pos.absoluteTop + "px";
break;
case "same":
newEle.style.left = pos.absoluteLeft + "px";
newEle.style.top = pos.absoluteTop + "px";
break;
}
return newEle;
}
//*---------------------------------------------------
//+----------------set attribute----------------------
function $SA() {
var tmp = arguments[0];
if (typeof tmpTagname === 'string') {
return $(tmp).setAttribute(arguments[1], arguments[2]);
} else {
return tmp.setAttribute(arguments[1], arguments[2]);
}
}
//*---------------------------------------------------
//+----------------create element---------------------
function $CE() {
var tmpTagname = arguments[0];
if (typeof tmpTagname === 'string') {
return document.createElement(tmpTagname);
}
}
//*---------------------------------------------------
//function webClose(value) {
// closeWindow(value.parentNode);
//}
function webClose(value) {
// 2020 ~
if (lib.browser.isMobile && value.parentNode && value.parentNode.parentNode) {
closeWindow(value.parentNode.parentNode);
} else {
closeWindow(value.parentNode);
}
}
function showDeleteWeb(value) {
var tmp = value.getAttribute("ID");
g.volatileArray["showDeleteWeb"] = new settimeoutData(4000, tmp)
setTimeout(delayShowDeleteWeb, 2000);
}
function delayShowDeleteWeb() {
if (!g.volatileArray["showDeleteWeb"])
return;
var tmpWeb = getWebByIDWithPre(g.volatileArray["showDeleteWeb"].argument);
delete g.volatileArray["showDeleteWeb"];
tmpWeb.k(tmpWeb);
}
function deleteWeb() //tmp:t,a,b,
{
var a = lib.formatEvent().target.getAttribute("relationalID").split("-");
var t = g.page.$(a[0]).$(a[1]);
lib.dom.setStyle(t.delButton, "cursor:default;visibility:hidden;");
for (var i = 0; i < t.Webs.length; i++) {
if (t.Webs[i].ID == t.Parent.selectWeb.ID) {
t.Webs.splice(i, 1);
t.d();
t.r();
t.lastOperateWeb = t.Parent.selectWeb;
break;
}
}
}
function EditWeb(p) //argument:tableRowWebData
{
var _ = this;
Region.call(_); //inherit from the Class Region
_.E = $CE("DIV");
_.E.className = "div_editor_modify";
if (typeof p == 'undefined') return;
var a = g.mouseEvent;
_.ID = "editor" + p.ID;
$SA(_.E, "id", _.ID);
$SA(_.E, "NameSourceValue", p.Name);
$SA(_.E, "LinkSourceValue", p.Link);
$SA(_.E, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
var tmpEle = $CE("INPUT");
tmpEle.type = "text";
tmpEle.value = p.Name;
tmpEle.size = p.Name.length + 1;
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
jQuery(tmpEle).addClass('input_editor_modify');
tmpEle.onkeydown = editorSaveAndClose;
var tmpText = document.createTextNode(lan["title"]);
jQuery(tmpText).wrap('<div class="label"></div>')
_.E.appendChild(tmpText);
_.E.appendChild(tmpEle);
tmpEle = $CE("INPUT");
tmpEle.type = "text";
tmpEle.value = p.Link;
tmpEle.size = p.Link.length || 5;
tmpEle.onkeydown = editorSaveAndClose;
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
jQuery(tmpEle).addClass('input_editor_modify');
var tmpText = document.createTextNode(lan["link"]);
jQuery(tmpText).wrap('<div class="label"></div>')
_.E.appendChild(tmpText);
_.E.appendChild(tmpEle);
tmpEle = $CE("INPUT");
tmpEle.value = p.Note;
if (p.Note == null) {
tmpEle.size = 10;
} else {
tmpEle.size = p.Note.length + 2;
}
tmpEle.onkeydown = editorSaveAndClose;
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
jQuery(tmpEle).addClass('input_editor_modify');
var tmpText = document.createTextNode(lan["note"]);
jQuery(tmpText).wrap('<div class="label"></div>')
_.E.appendChild(tmpText);
_.E.appendChild(tmpEle);
tmpEle = $CE("INPUT");
$SA(tmpEle, "type", "button");
$SA(tmpEle, "class", "btn");
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
tmpEle.onclick = editorSaveAndClose;
tmpEle.value = lan["save"];
_.E.appendChild(tmpEle);
tmpEle = $CE("INPUT");
$SA(tmpEle, "type", "button");
$SA(tmpEle, "class", "btn");
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
tmpEle.onclick = editorCancel;
tmpEle.value = lan["reset"];
_.E.appendChild(tmpEle);
tmpEle = $CE("INPUT");
$SA(tmpEle, "type", "button");
$SA(tmpEle, "class", "btn");
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
tmpEle.onclick = deleteWebTwo;
tmpEle.value = lan["delete"];
_.E.appendChild(tmpEle);
tmpEle = $CE("SPAN");
$SA(tmpEle, "style", "padding: 5px;position: absolute;right: 10px;top: 0px;font-size: 22px;");
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
tmpEle.onclick = editorSaveAndClose;
tmpEle.innerHTML = "x";
_.E.appendChild(tmpEle);
_.E = p.Parent.Parent.Parent.E.appendChild(_.E);
p.EditEle = _.E; //
_.setRecByEle();
var width = _.RecRight - _.RecLeft;
var height = _.RecBottom - _.RecTop;
if (p.RecLeft + width > document.body.scrollLeft + document.body.offsetWidth) {
if (p.RecRight - width < document.body.scrollLeft) {
_.E.style.left = document.body.scrollLeft + "px";
} else {
_.E.style.left = (p.RecRight - width) + "px";
}
} else {
_.E.style.left = p.RecLeft + "px";
}
_.E.style.top = (p.RecTop - height) + "px";
}
function closeCateNameEditor(p) //After editting the category's name, close the div and submit the data.
{
var tmpNameObj = p.parentNode.getElementsByTagName("INPUT")[0];
p.size = lib.data.getStrLength(tmpNameObj.value);
if (lib.getEvent().keyCode == 13 || p.type != "text") {
if (validateInput(tmpNameObj, /^\s*$/g, "Error") == false) {
return;
}
var tmpIDArray = p.parentNode.getAttribute("relationalID").split("-");
var tmpTable = g.page.$(tmpIDArray[0]);
var a = tmpTable.$(tmpIDArray[1]);
a.CateName = tmpNameObj.value;
a.CateNameEle.innerHTML = a.CateName;
a.CateNameEle.style.visibility = "";
p.parentNode.parentNode.removeChild(p.parentNode);
a.Parent.lastOperateRow = a;
a.u();
a.refresh();
}
}
//+---------------add a table to the page--------------
function editAddTable(value) { //WebTable(ID,Name,containerEle,Parent) tmp:t,
var t = $CE("DIV");
t.id = "addTableID";
$SA(t, "relationalID", value.getAttribute("relationalID"));
t.style.position = "absolute";
t.style.backgroundColor = "#fff";
t.style.borderStyle = "solid";
t.style.borderWidth = "1px";
t.style.borderColor = "#629444";
t.style.width = "285px";
t.innerHTML = "<table style='width:100%;'>" +
"<tr><td><span class='wsd' style='position: absolute;top: 9px;right: 13px;font-size: 14px;' onclick='closeWindow(this.parentNode.parentNode.parentNode);'></span></td></tr>" +
"<tr class='label'><td>" + lan["25"] + "</td></tr>" +
"<tr><td class='inputWrapper'><input type='text' onfocus='resumeStyle(this)' onkeydown='addTable(this)'/></td>" +
"<td class='btnWrapper'><input type='button' class='btn' value='" + lan["save"] + "' onclick='addTable(this)'/></tr>" +
"<tr class='label'><td>" + lan["28"] + "</td></tr>" +
"<tr><td class='inputWrapper'><input id='websiteID' type='text'/></td>" +
"<td class='btnWrapper'><input type='button' class='btn' onclick='g.craw(0)' value='" + lan["26"] + "'/></td>" +
"<tr class='label'><td>" + lan["27"] + "</td></tr>" +
"<tr><td><textarea id='webdataID'></textarea></td>" +
"<td class='btnWrapper'><input type='button' class='btn' onclick='g.craw(1)' value='" + lan["26"] + "'/></td>"
addEleAround(value, t, "same");
}
function closeTableTitleEditor(p) //tmp:t,
{
if (lib.getEvent().keyCode == 13 || p.type != "text") {
var t = g.page.$(p.parentNode.getAttribute("ParentID"));
t.Name = p.parentNode.getElementsByTagName("INPUT")[0].value;
t.titleEle.innerHTML = t.Name;
t.titleEle.style.visibility = "";
p.parentNode.parentNode.removeChild(p.parentNode);
t.u();
t.r();
}
}
x_queren_g = function () {
for (var i = 0; i < x_q_tmpCate.length; i++) {
if (x_q_tmpCate[i].ID == x_q_a.ID) {
x_q_tmpCate.splice(i, 1);
x_q_a.Parent.d();
x_q_a.Parent.refresh();
x_q_a.Parent.lastOperateRow = x_q_a;
break;
}
}
x_q_a.f();
}
var x_q_tmpCate;
var x_q_a;
function deleteRow() //tmp:t, 如果移动到weblazy.js中会出现错误("没有定义").
{
//localStorage.setItem("type_active", 2);
document.getElementById("duihuakuang").style.display = "block";
var t = lib.formatEvent(arguments[0]).target.getAttribute("relationalID").split("-");
var tmpTable = g.page.$(t[0]);
x_q_a = tmpTable.$(t[1]);
x_q_tmpCate = x_q_a.Parent.Categories;
}
function editorSaveAndClose() //value is this 如果移动到weblazy.js中会出现错误("没有定义").
{
var e = lib.formatEvent(arguments[0]);
if (e.keyCode == 13 || e.target.type != "text") {
var relationalIDs = e.target.getAttribute("relationalID").split("-");
var tableID = relationalIDs[0];
var rowID = relationalIDs[1];
var webID = relationalIDs[2];
var table = lib.data.getObByAttribute(g.page.Tables, "ID", tableID);
var row = lib.data.getObByAttribute(table.Categories, "ID", rowID);
var tmpWeb = row.$(webID);
var tmpEle = $("editor" + webID); // an instance's ID is "editor3"
var tmpObjs = tmpEle.getElementsByTagName("INPUT");
if (validateInput(tmpObjs[0], /^\s*$/g, "Error") == false) {
return;
}
tmpWeb.Name = tmpObjs[0].value;
tmpWeb.Link = tmpObjs[1].value;
tmpWeb.Note = tmpObjs[2].value;
tmpWeb.i();
tmpWeb.h(tmpWeb);
tmpEle.parentNode.removeChild(tmpEle);
tmpWeb.EditEle = U;
}
}
function editorCancel(value) {
var t = $("editor" + lib.formatEvent(arguments[0]).target.getAttribute("relationalID").split("-")[2]);
t.getElementsByTagName("INPUT")[0].value = t.getAttribute("NameSourceValue");
t.getElementsByTagName("INPUT")[1].value = t.getAttribute("LinkSourceValue");
}
function deleteWebTwo() {
var t = lib.formatEvent(arguments[0]).target.getAttribute("relationalID").split("-");
var tmpTable = g.page.$(t[0]);
var tmpRow = tmpTable.$(t[1]);
var tmpWeb = tmpRow.$(t[2]);
// 向服务发送删除数据
tmpWeb.g();
if (!tmpWeb.EditEle.parentNode) {
debugger;
}
tmpWeb.EditEle.parentNode.removeChild(tmpWeb.EditEle);
tmpWeb.EditEle = U;
};
function editorDelete(value) { //delete the "Web".
//send data to the server.
var tmpParentID = value.getAttribute("ParentID"); //get the id of the parent dom of the editor.
var tmpEle = $(tmpParentID); // an instance's ID is "editor3"
var tmpWebID = tmpParentID.substring(6, tmpParentID.length); // remove the string "editor"
var tmpID = "webElement2010" + tmpWebID;
var tmpWeb = getWebByIDWithPre(tmpID);
var tmpRow = tmpWeb.Parent;
lib.dom.setStyle(tmpRow.delButton, "cursor:default;visibility:hidden;");
for (var i = 0; i < tmpRow.Webs.length; i++) {
if (tmpRow.Webs[i].ID == tmpWebID) {
tmpRow.Webs.splice(i, 1);
tmpRow.d();
tmpRow.r();
tmpRow.lastOperateWeb = tmpWeb;
break;
}
}
tmpEle.parentNode.removeChild(tmpEle); //delete the editor.
tmpWeb.EditEle = U;
}
//+---------------global function-------------------------
function findPos(obj) {
if (u(obj))
return;
var curleft = curtop = 0;
if (obj.offsetParent) {
while (1) {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
if (!obj.offsetParent) {
break;
}
if (obj.style.position == "absolution") {
break;
}
obj = obj.offsetParent;
}
} else if (obj.x && obj.y) {
cureft += obj.x;
curtop += obj.y;
}
return {
"absoluteLeft": curleft,
"absoluteTop": curtop
};
}
//*-------------------------------------------------------
/**
* 定义ForceWindow类构造函数
* 无参数
* 无返回值
*/
function ForceWindow() {
this.r = document.documentElement;
this.f = $CE("FORM");
this.f.target = "_blank";
this.f.method = "post";
this.r.insertBefore(this.f, this.r.childNodes[0]);
}
/**
* 定义open方法
* 参数sUrl:字符串,要打开窗口的URL。
* 无返回值
*/
ForceWindow.prototype.open = function (sUrl) {
this.f.action = sUrl;
this.f.submit();
}
/**
* 实例化一个ForceWindow对象并做为window对象的一个子对象以方便调用
* 定义后可以这样来使用:window.force.open("URL");
*/
window.force = new ForceWindow();
Object.prototype.Serialize = function () {
var type = __typeof__(this);
switch (type) {
case 'Array': {
var strArray = '[';
for (var i = 0; i < this.length; ++i) {
var value = '';
if (this[i]) {
value = this[i].Serialize();
}
strArray += value + ',';
}
if (strArray.charAt(strArray.length - 1) == ',') {
strArray = strArray.substr(0, strArray.length - 1);
}
strArray += ']';
return strArray;
}
case 'Date': {
return 'new Date(' + this.getTime() + ')';
}
case 'Boolean':
case 'Function':
case 'Number':
return this.toString();
case 'String': {
return '"' + this.toString() + '"';
}
default: {
var serialize = '{';
for (var key in this) {
if (key == 'Serialize') continue;
var subserialize = 'null';
if (!u(this[key])) {
subserialize = this[key].Serialize();
}
serialize += '\r\n' + key + ' : ' + subserialize + ',';
}
if (serialize.charAt(serialize.length - 1) == ',') {
serialize = serialize.substr(0, serialize.length - 1);
}
serialize += '\r\n}';
return serialize;
}
}
};
function __typeof__(p) //p:p
{
if (p && p.constructor) {
var a = p.constructor.toString();
return a.substr(0, a.indexOf('(')).replace('function', '').replace(/(^\s*)|(\s*$)/ig, '');
}
return typeof (p);
}
function close(value) {
if (value == null || u(value) || u(value.parentNode)) return;
value.parentNode.removeChild(value);
}
function closeWindow(value) {
if (u(value.parentNode)) {
return;
}
value.parentNode.removeChild(value);
jQuery('#addTableID').remove()
}
function validateInput(obj, reg, msg) {
if (obj.value == "" || reg.test(obj.value)) {
obj.style.color = "Red";
obj.value = (u(msg)) ? lan["29"] : msg;
return false;
}
return true;
}
function resumeStyle(obj, uselessMSG) {
obj.style.color = "#000000";
}
function addWeb() {
var trigger = lib.formatEvent(arguments[0]).target;
var tmpIDs = trigger.getAttribute("relationalID").split("-");
var webRow = g.page.$(tmpIDs[0]).$(tmpIDs[1]);
if (webRow.editAndAddEle.parentNode == null || webRow.editAndAddEle.parentNode.parentNode == null) {
webRow.n();
} else {
closeWindow(webRow.editAndAddEle);
}
}
function addWebAndClose(p) //add the web to WebRow after editting the data. working 99
{
var evt = lib.getEvent();
var pageX=evt.pageX;
var pageY=evt.pageY;
if (evt.keyCode == 13 || p.type != "text") {
if (false == g.user.isLogined()) {
var tmp = g.disLoginAndRegister();
return;
}
var relationalIDs = p.getAttribute("relationalID").split("-");
var t = $("editAndAddEleID" + relationalIDs[1]);
var webRow = lib.data.getObByAttribute(g.page.Tables, "ID", relationalIDs[0]).$(relationalIDs[1]);
var tmpInputEles = t.getElementsByTagName("INPUT");
if (validateInput(tmpInputEles[0], /^\s*$/g) == false) {
tmpInputEles[0].value = lan["31"];
}
var scrollTop=document.documentElement.scrollTop;
var tmpName = tmpInputEles[0].value.length > 60 ? tmpInputEles[0].value.substr(0, 57) + "..." : tmpInputEles[0].value;
webRow.o(new B.Web((new Date).getTime() + "Web", tmpName, tmpInputEles[1].value, tmpInputEles[2].value, webRow.CateName, "48778", tmpInputEles[2].value, ["cn", "en"], "A"), webRow.Webs.length); //(ID, Name,Link, Note, Cate, Cr, Key,Lans,tagName)
document.documentElement.scrollTop=scrollTop
closeWindow(t);
}
};
function addCategory(value) {
var tmpEve = lib.getEvent();
if (tmpEve.keyCode == 13 || value.type != "text") {
var tmpNameObj = value.parentNode.getElementsByTagName("INPUT")[0];
if (validateInput(tmpNameObj, /^\s*$/g) == false) {
return;
}
var cateName = tmpNameObj.value;
var newRow = new B.WebRow((new Date).getTime() + "CATE", cateName, g.page.$(value.parentNode.getAttribute("relationalID")), "");
newRow.Parent.Categories.push(newRow);
newRow.Parent.Parent.d();
newRow.Parent.Parent.refresh();
close(value.parentNode);
newRow.Parent.lastOperateRow = newRow;
newRow.a(newRow.Parent.Categories.length);
}
}
function LightOn(ele) {
lib.transparentDiv.on(); //把div添加到body
var contentDiv = $CE("div"); //创建内容div
//计算顶部位置值
var winH;
if (window.innerHeight) { // all except IE
winH = window.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
// IE 6 Strict Mode
winH = document.documentElement.clientHeight;
} else if (document.body) { // other
winH = document.body.clientHeight;
}
var top = parseInt(parseInt(winH * 0.25) + (document.body.scrollTop || document.documentElement.scrollTop));
contentDiv.style.width = "368px"; //宽度
// contentDiv.style.height = "423px";
contentDiv.style.background = "url(image/login_bg.png) 0 0/100% 100% no-repeat;"
contentDiv.id = "contentDiv"; //设置id
//计算左边位置
var left = Math.ceil(((document.body.scrollWidth) - parseInt(contentDiv.style.width.replace('px', ''))) / 2) + document.body.scrollLeft;
contentDiv.style.top = top + "px"; //设置顶部边距
contentDiv.style.left = left + "px"; //设置左边距
jQuery(contentDiv).addClass('dialog_sign');
contentDiv.innerHTML = lib.loginModule(); //把内容窗体添加到contentDiv
document.body.appendChild(contentDiv); //把div添加到body
if ($("UsernameID").value == "")
$("UsernameID").focus();
else
$("PasswordID").focus();
//所有的Select控件设为不可见
var arr = document.getElementsByTagName("select");
var i = 0;
while (i < arr.length) {
arr[i].style.visibility = "hidden";
i++;
}
//清除关机效果
this.cancle = function () {
if (!u($("transparentDiv"))) {
document.body.removeChild($("transparentDiv"));
}
var tmp = $("contentDiv");
tmp.parentNode.removeChild(tmp);
var arr = document.getElementsByTagName("select");
var i = 0;
//把所有的select控件设为可见
while (i < arr.length) {
arr[i].style.visibility = "visible";
i++;
}
}
}
function stringDom(dom) {
var o = document.createElement("div");
o.appendChild(dom);
return o.innerHTML
}
function EditWeb(p) //argument:tableRowWebData
{
var _ = this;
Region.call(_); //inherit from the Class Region
_.E = $CE("DIV");
_.E.className = "div_editor_modify";
if (typeof p == 'undefined') return;
var a = g.mouseEvent;
_.ID = "editor" + p.ID;
$SA(_.E, "id", _.ID);
$SA(_.E, "NameSourceValue", p.Name);
$SA(_.E, "LinkSourceValue", p.Link);
$SA(_.E, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
var tmpEle = $CE("INPUT");
tmpEle.type = "text";
tmpEle.value = p.Name;
tmpEle.size = p.Name.length + 1;
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
jQuery(tmpEle).addClass('input_editor_modify');
tmpEle.onkeydown = editorSaveAndClose;
var tmpText = document.createTextNode(lan["title"]);
tmpText = '<div class="label">' + stringDom(tmpText) + '</div>'
jQuery(_.E).append(tmpText);
_.E.appendChild(tmpEle);
tmpEle = $CE("INPUT");
tmpEle.type = "text";
tmpEle.value = p.Link;
tmpEle.size = p.Link.length || 5;
tmpEle.onkeydown = editorSaveAndClose;
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
jQuery(tmpEle).addClass('input_editor_modify');
var tmpText = document.createTextNode(lan["link"]);
tmpText = '<div class="label">' + stringDom(tmpText) + '</div>'
jQuery(_.E).append(tmpText);
_.E.appendChild(tmpEle);
tmpEle = $CE("INPUT");
tmpEle.value = p.Note;
if (p.Note == null) {
tmpEle.size = 10;
} else {
tmpEle.size = p.Note.length + 2;
}
tmpEle.onkeydown = editorSaveAndClose;
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
jQuery(tmpEle).addClass('input_editor_modify');
var tmpText = document.createTextNode(lan["note"]);
tmpText = '<div class="label">' + stringDom(tmpText) + '</div>'
jQuery(_.E).append(tmpText);
_.E.appendChild(tmpEle);
var tempWrap = $CE("div");
$SA(tempWrap, "class", "btnWrap");
tmpEle = $CE("INPUT");
$SA(tmpEle, "type", "button");
$SA(tmpEle, "class", "btn");
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
tmpEle.onclick = editorSaveAndClose;
tmpEle.value = lan["save"];
tempWrap.appendChild(tmpEle)
// _.E.appendChild(tmpEle);
tmpEle = $CE("INPUT");
$SA(tmpEle, "type", "button");
$SA(tmpEle, "class", "btn");
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
tmpEle.onclick = editorCancel;
tmpEle.value = lan["reset"];
tempWrap.appendChild(tmpEle)
// _.E.appendChild(tmpEle);
tmpEle = $CE("INPUT");
$SA(tmpEle, "type", "button");
$SA(tmpEle, "class", "btn");
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
tmpEle.onclick = deleteWebTwo;
tmpEle.value = lan["delete"];
tempWrap.appendChild(tmpEle)
jQuery(_.E).append(tempWrap);
tmpEle = $CE("SPAN");
$SA(tmpEle, "style", "position: absolute;top: 10px;right: 13px;");
$SA(tmpEle, "relationalID", p.Parent.Parent.ID + "-" + p.Parent.ID + "-" + p.ID);
tmpEle.onclick = editorSaveAndClose;
tmpEle.setAttribute('class', 'wsd');
_.E.appendChild(tmpEle);
_.E = p.Parent.Parent.Parent.E.appendChild(_.E);
if (!_.E) {
debugger;
}
p.EditEle = _.E; //
_.setRecByEle();
var width = _.RecRight - _.RecLeft;
var height = _.RecBottom - _.RecTop;
if (p.RecLeft + width > document.body.scrollLeft + document.body.offsetWidth) {
if (p.RecRight - width < document.body.scrollLeft) {
_.E.style.left = document.body.scrollLeft + "px";
} else {
_.E.style.left = (p.RecRight - width) + "px";
}
} else {
_.E.style.left = p.RecLeft + "px";
}
_.E.style.top = (p.RecTop - height) + "px";
}
// 登录弹框
function LightOn(ele) {
lib.transparentDiv.on(); //把div添加到body
var contentDiv = $CE("div"); //创建内容div
//计算顶部位置值
var winH;
if (window.innerHeight) { // all except IE
winH = window.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
// IE 6 Strict Mode
winH = document.documentElement.clientHeight;
} else if (document.body) { // other
winH = document.body.clientHeight;
}
var top = parseInt(parseInt(winH * 0.25) + (document.body.scrollTop || document.documentElement.scrollTop));
contentDiv.id = "contentDiv"; //设置id
contentDiv.style.width = "368px"; //宽度
// contentDiv.style.height = "423px";
contentDiv.style.background = "url('image/login_bg.png') 0 0/cover no-repeat"
//计算左边位置
// var left = Math.ceil(((document.body.scrollWidth) - parseInt(contentDiv.style.width.replace('px', ''))) / 2) + document.body.scrollLeft;
contentDiv.style.top = top + "px"; //设置顶部边距
contentDiv.style.left = "50%"; //设置左边距
contentDiv.style.transform = 'translateX(-50%)';
jQuery(contentDiv).addClass('dialog_sign');
contentDiv.innerHTML = lib.loginModule(); //把内容窗体添加到contentDiv
document.body.appendChild(contentDiv); //把div添加到bodyn
if ($("UsernameID").value == "")
$("UsernameID").focus();
else
$("PasswordID").focus();
//所有的Select控件设为不可见
var arr = document.getElementsByTagName("select");
var i = 0;
while (i < arr.length) {
arr[i].style.visibility = "hidden";
i++;
}
//清除关机效果
this.cancle = function () {
if (!u($("transparentDiv"))) {
document.body.removeChild($("transparentDiv"));
}
var tmp = $("contentDiv");
tmp.parentNode.removeChild(tmp);
var arr = document.getElementsByTagName("select");
var i = 0;
//把所有的select控件设为可见
while (i < arr.length) {
arr[i].style.visibility = "visible";
i++;
}
}
}
function lightboxSetBlack(ele) {
var scrW;
var scrH;
if (window.innerHeight && window.scrollMaxY) {
// Mozilla
scrW = window.innerWidth + window.scrollMaxX;
scrH = window.innerHeight + window.scrollMaxY;
} else if (document.documentElement && document.documentElement.clientHeight) {
// IE 6 Strict Mode
scrW = document.documentElement.clientWidth;
scrH = document.documentElement.clientHeight;
} else if (document.body) {
// IE Mac
scrW = document.body.clientWidth;
scrH = document.body.clientHeight;
}
ele.style.display = "block";
ele.style.width = scrW;
ele.style.height = scrH;
}
//------------------------- sign on ------ sign in--------------------
function hideTab(ele) {
ele.style.display = 'none';
}
function minimize(ele) {
ele.style.width = 0;
ele.style.height = 0;
}
function signOnOrSignIn(index) {
var signonTab = $("signonTab");
var signinTab = $("signinTab");
if (index == 1) {
signinTab.style.display = "";
signonTab.style.display = "none";
} else {
signinTab.style.display = "none";
signonTab.style.display = "";
}
}
function showTab(tabHeadId, tabContentId) {
var tabDiv = document.getElementById("light");
var taContents = tabDiv.childNodes;
for (var i = 0; i < taContents.length; i++) {
if (taContents[i].id != null && taContents[i].id != 'tabsHead') {
taContents[i].style.display = 'none';
}
}
var contentDiv = document.getElementById('contentDiv')
if (tabContentId == 'tabContent1') {
contentDiv.style.background = "url('image/login_bg.png') 0 0/100% 100% no-repeat"
} else if (tabContentId == 'tabContent2') {
contentDiv.style.background = "url('image/register_bg.png') 0 0/100% 100% no-repeat"
}
document.getElementById(tabContentId).style.display = 'block';
var ele_tabsHead = document.getElementById('tabsHead');
var tabHeads = ele_tabsHead.getElementsByTagName('a');
for (var i = 0; i < tabHeads.length; i++) {
tabHeads[i].className = 'tabs';
}
jQuery('#' + tabHeadId).addClass('curtab').siblings().removeClass('curtab')
// document.getElementById(tabHeadId).className = 'curtab';
document.getElementById(tabHeadId).blur();
}
// ----------------------- begin router ---------------------------------------
var paraStr='';
function f_check_IP(ip) {
var re = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;//正则表达式
if (re.test(ip)) {
if (RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256 && RegExp.$4 < 256)
return true;
}
return false;
//return true;
}
function Router(){
this.routes={};
this.currentURL='';
}
Router.prototype.route = function(path,callback){
this.routes[path] = callback || function(){};
}
Router.prototype.refresh = function () {
var requestUrl = "";
if (f_check_IP(location.hostname)) {
requestUrl = location.hash.slice(1);
var indexOfStr = requestUrl.lastIndexOf("/");
paraStr = requestUrl.substring(0, indexOfStr);
}
else {
requestUrl = location.hash.slice(1) || '/main';
}
//var indexOfStr = requestUrl.lastIndexOf("/");
//paraStr = requestUrl.substring(0, indexOfStr);
//this.currentURL = requestUrl.substring(indexOfStr);
this.currentURL = requestUrl;
this.routes[this.currentURL](paraStr);
}
Router.prototype.init = function () {
window.addEventListener('load',this.refresh.bind(this),false);
window.addEventListener('hashchange',this.refresh.bind(this),false);
}
window.Router = new Router();
if (f_check_IP(location.hostname)) {
requestUrl = location.hash.slice(1);
var indexOfStr = requestUrl.lastIndexOf("/");
paraStr = requestUrl.substring(0, indexOfStr);
Router.route(paraStr+'/main', function (paraStr) {
g.getMainData(paraStr);
})
Router.route(paraStr +'/private', function (paraStr) {
g.getPrivateData(paraStr);
})
Router.route(paraStr + '/public', function (paraStr) {
g.getPublicData(paraStr);
});
var h = $('hostID');
if (h != undefined) {
h.href ="#"+paraStr + '/main';
}
var p = $('publicID');
if (p != undefined) {
p.href = "#" +paraStr + '/public';
}
lib.cookie.set("username", paraStr, 30, "/", true);
}
else {
Router.route('/main', function (paraStr) {
g.getMainData(paraStr);
})
Router.route('/private', function (paraStr) {
g.getPrivateData(paraStr);
})
Router.route('/public', function (paraStr) {
g.getPublicData(paraStr);
})
var h = $('hostID');
if (h != undefined) {
h.href ='#/main';
}
var p = $('publicID');
if (p != undefined) {
p.href ='#/public';
}
}
window.Router.init();
// --------------------------- end router ------------------------------
//测试运行
function testFunc() {
g.fun();
}
function lazyLoad() {
tmpUrl = g.domainDirectory + "/weblazy.js";
sendAndGetData(true, tmpUrl, function (_resData) {
eval(_resData);
});
}
1
https://gitee.com/yanglihao2006/webCollection.git
git@gitee.com:yanglihao2006/webCollection.git
yanglihao2006
webCollection
webCollection
master

搜索帮助