Google 个性化主页类似,如何保存最后的布局三
Google 个性化主页类似,如何保存最后的布局三
var Drag = {
dragged:false,
ao:null,
tdiv:null,
dragStart:function(){
Drag.ao = event.srcElement;
if((Drag.ao.tagName == "TD")||(Drag.ao.tagName == "TR")){
Drag.ao = Drag.ao.offsetParent;
Drag.ao.style.zIndex = 100;
}else{
return;
}
Drag.dragged = true;
Drag.tdiv = document.createElement("div");
Drag.tdiv.innerHTML = Drag.ao.outerHTML;
Drag.ao.style.border = "1px dashed blue";
Drag.tdiv.style.display = "block";
Drag.tdiv.style.position = "absolute";
Drag.tdiv.style.filter = "alpha(opacity = 70)";
Drag.tdiv.style.cursor = "move";
Drag.tdiv.style.border = "1px solid #000000";
Drag.tdiv.style.width = Drag.ao.offsetWidth;
Drag.tdiv.style.height = Drag.ao.offsetHeight;
Drag.tdiv.style.top = Drag.getInfo(Drag.ao).top;
Drag.tdiv.style.left = Drag.getInfo(Drag.ao).left;
document.body.appendChild(Drag.tdiv);
Drag.lastX = event.clientX;
Drag.lastY = event.clientY;
Drag.lastLeft = Drag.tdiv.style.left;
Drag.lastTop = Drag.tdiv.style.top;
}// end function dragStart()
,
draging:function(){//重要:判断MOUSE的位置
if(!Drag.dragged||Drag.ao == null) return;
var tX = event.clientX;
var tY = event.clientY;
Drag.tdiv.style.left = parseInt(Drag.lastLeft)+tX-Drag.lastX;
Drag.tdiv.style.top = parseInt(Drag.lastTop)+tY-Drag.lastY;
for(var i = 0;i
if(tX >= parentCell.left &&
tX tY >= parentCell.top &&
tY var subTables = parentTable.cells[i].getElementsByTagName("table");
if(subTables.length == 0){
if(tX >= parentCell.left &&
tX tY >= parentCell.top &&
tY parentTable.cells[i].appendChild(Drag.ao);
}
break;
}
for(var j = 0; j
if(tX >= subTable.left &&
tX tY >= subTable.top &&
tY parentTable.cells[i].insertBefore(Drag.ao,subTables[j]);
break;
}else{
parentTable.cells[i].appendChild(Drag.ao);
}
}
}
}
}// end function draging
,
dragEnd:function(){
if(!Drag.dragged) return;
Drag.dragged = false;
Drag.mm = Drag.repos(150,15);
Drag.ao.style.borderWidth = "0px";
//Drag.ao.style.borderTop = "1px solid #3366cc";
Drag.tdiv.style.borderWidth = "0px";
Drag.ao.style.zIndex = 1;
//alert(Drag.ao.outerHTML);
Drag.saveLayout();
displaySaveLayout();
}// end function dragEnd()
,
saveLayout:function()
{ // 把当前布局的位置放到 Cookie 里,按过 "保存页面布局" 后,存到后台
for(var i = 0;i
for(var j = 0;j
// i_cell index of parentTable
// j_node index of parentTable.rows[0][i].childNodes
setCookie(subTables[j].id+"pos",i+"::"+j+"::"+subTables[j].id);
}
}
}// end function saveLayout()
,
initTablePos:function()
{
// 先从 Cookie 里得到值, 如果得不到再到 DB 中挑资料.
var _tablepos = new Array();
var _dragTableHtmlArray = new Array(); // 存放 drag table 里的 html 代码
var _cookies = new Array();
var _c = 0;
// 先把画面上的内容拿到 Javascript 然后重新布局
for(var i = 0;i
for(var j = 0;j
_cookies[_c] = getCookie(subTables[j].id+"pos");
_dragTableHtmlArray[subTables[j].id] = subTables[j].outerHTML;
_c++;
}
if (_cookies.toString().indexOf("::") != -1)
{
parentTable.cells[i].innerHTML = ""; // 清除画面上拖动 Table
}
}
_cookies.sort(); // sort 后按顺序加入 innerHTML
if (_cookies.toString().indexOf("::") != -1)
{
for (var _k = 0 ; _k <_cookies.length> {
if (_cookies[_k] != null)
{
_tablepos = _cookies[_k].split("::");
//alert(_tablepos);
if (typeof(_tablepos) == "object")
{
//alert(_dragTableHtmlArray[_tablepos[2]]);
parentTable.cells[_tablepos[0]].innerHTML += _dragTableHtmlArray[_tablepos[2]];
//parentTable.cells[_tablepos[0]].innerText += _dragTableHtmlArray[_tablepos[2]];
}
}
}
}
//_cookies.sort();
//alert(_cookies);
_dragTableHtmlArray = null;// release memoery
}// end function initDragTablePos()
,
getInfo:function(o){//取得坐标
var to = new Object();
to.left = to.right = to.top = to.bottom = 0;
var twidth = o.offsetWidth;
var theight = o.offsetHeight;
while(o != document.body){
to.left += o.offsetLeft;
to.top += o.offsetTop;
o = o.offsetParent;
}
to.right = to.left+twidth;
to.bottom = to.top+theight;
return to;
}// end function getInfo()
,
repos:function(aa,ab){
var f = Drag.tdiv.filters.alpha.opacity;
var tl = parseInt(Drag.getInfo(Drag.tdiv).left);
var tt = parseInt(Drag.getInfo(Drag.tdiv).top);
var kl = (tl-Drag.getInfo(Drag.ao).left)/ab;
var kt = (tt-Drag.getInfo(Drag.ao).top)/ab;
var kf = f/ab;
return setInterval(
function(){
if(ab clearInterval(Drag.mm);
Drag.tdiv.removeNode(true);
Drag.ao = null;
return;
}
ab--;
tl -= kl;
tt -= kt;
f -= kf;
Drag.tdiv.style.left = parseInt(tl)+"px";
Drag.tdiv.style.top = parseInt(tt)+"px";
Drag.tdiv.filters.alpha.opacity = f;
}// end 动画效果
,aa/ab)
}// end function repos()
,
inint:function(){//初始化
Drag.initTablePos();
for(var i = 0;i
for(var j = 0;j
subTables[j].rows[0].className = "dragTR";
subTables[j].rows[0].attachEvent("onmousedown",Drag.dragStart);
}
}
document.onmousemove = Drag.draging;
document.onmouseup = Drag.dragEnd;
}// end function inint()
}//end of Object Drag
Drag.inint();

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Currently, four new Pixel smartphones are anticipated to land this autumn. To recap, the series is rumoured to feature thePixel 9 and Pixel 9 Pro at launch. However, the Pixel 9 Pro will be a rival to the iPhone 16 Pro rather than a Pixel 8 Pro (curr

Google has introduced DisplayPort Alternate Mode with the Pixel 8 series, and it's present on the newly launched Pixel 9 lineup. While it's mainly there to let you mirror the smartphone display with a connected screen, you can also use it for desktop

Google AI has started to provide developers with access to extended context windows and cost-saving features, starting with the Gemini 1.5 Pro large language model (LLM). Previously available through a waitlist, the full 2 million token context windo

Google recently responded to the performance concerns about the Tensor G4 of the Pixel 9 line. The company said that the SoC wasn't designed to beat benchmarks. Instead, the team focused on making it perform well in the areas where Google wants the c

Google's AI assistant, Gemini, is set to become even more capable, if the APK teardown of the latest update (v15.29.34.29 beta) is to be considered. The tech behemoth's new AI assistant could reportedly get several new extensions. These extensions wi

The Pixel 9 series is almost here, having been scheduled for an August 13 release. Based on recent rumours, the Pixel 9, Pixel 9 Pro and Pixel 9 Pro XL will mirror the Pixel 8 and Pixel 8 Pro (curr. $749 on Amazon) by starting with 128 GB of storage.

Google is roughly a fortnight away from fully revealing new hardware. As usual, countless sources have leaked details about new Pixel devices, whether that be the Pixel Watch 3, Pixel Buds Pro 2 or Pixel 9 smartphones. It also seems that the company

A few months have passed since Android Authority demonstrated a new Android desktop mode that Google had hidden away within Android 14 QPR3 Beta 2.1. Arriving hot on the heels of Google adding DisplayPort Alt Mode support for the Pixel 8 and Pixel 8
