User Tools

Site Tools


script_fading_page_bookmark

====== About the script ====== * Purpose : This script will allow you to set up page bookmarks, which won't scroll but instead fade * Author : F43nd1r * Current Version : 1.1 * Link : https://plus.google.com/110839325256080910341/posts/6ap4YGPEJy3 * Video : https://plus.google.com/115366157037831519359/posts/QjcaoeFJeU3 ====== Changelog ====== * Version 1.0 (13/7/2014): initial release in wiki * Version 1.1 (16/7/2014): fix for startpage is the same as destinationpage and fix for x or y pinned items ====== How to use the script ====== * create a shortcut to the script and tap it * Scroll to the page you want the shortcut to point at * Run the script from menu (you have to enable that in script editor) * Use your nice new fading bookmark by tapping the shortcut ====== Issues and hints ====== * you can reset a shortcut by deleting its tag //please report all bugs in the g+ community// ====== Script code ====== <sxh javascript;>//config var speed=50;//lower is faster, 1 for instant, 255 for slowest //endconfig var e=LL.getEvent(); var c=e.getContainer(); var i=e.getItem()||c.getItemById(parseInt(LL.getScriptTag())); if(e.getSource()!="SHORTCUT") { if(i!=null) { i.setTag(JSON.stringify([Math.round(c.getPositionX()/c.getWidth())*c.getWidth(),Math.round(c.getPositionY()/c.getHeight())*c.getHeight()])); Android.makeNewToast("Page saved.",false).show(); LL.setScriptTag(null); } else Android.makeNewToast("Error: No shortcut selected.\nTap on the shortcut first.",false).show(); return; } if(i.getTag()==null) { LL.setScriptTag(i.getId()); Android.makeNewToast("Shortcut selected.\nNow launch the script from menu where you want the shortcut to point at",false).show(); return; } var goTo=JSON.parse(i.getTag()); var start=[Math.round(c.getPositionX()/c.getWidth())*c.getWidth(),Math.round(c.getPositionY()/c.getHeight())*c.getHeight()]; c.setPosition(start[0],start[1]); if(goTo[0]==start[0]&&goTo[1]==start[1])return; var dwidth=c.getWidth(); var dheight=c.getHeight(); var page0=[]; var page1=[]; var counter=[0,0]; var items=c.getItems(); var zorder=items.length; for(a=0;a<items.length;a++) { var item=items.getAt(a); var pin=item.getProperties() .getString("i.pinMode"); if(pin=="NONE"||(goTo[0]!=start[0]&&pin=="Y")||(goTo[1]!=start[1]&&pin=="X")) { var x=item.getPositionX(); var y=item.getPositionY(); if(x>=start[0]&&x<start[0]+dwidth&&y>=start[1]&&y<start[1]+dheight) { page0[counter[0]]=item; counter[0]++; zorder=Math.min(zorder,c.getItemZIndex(item.getId())); } else if(x>=goTo[0]&&x<goTo[0]+dwidth&&y>=goTo[1]&&y<goTo[1]+dheight) { page1[counter[1]]=item; counter[1]++; } } } page0.length=counter[0]; page1.length=counter[1]; for(a=0;a<page1.length;a++) { var item=page1[a]; var x=(item.getPositionX()%dwidth+ dwidth)%dwidth; var y=((item.getPositionY()%dheight +dheight)%dheight); item.getProperties().edit().setInteger("i.alpha",255).commit(); if(item.getProperties().getBoolean("i.onGrid")) { var cell=item.getCell(); item.setCell(cell.getLeft()-Math.round((goTo[0]-start[0])/c.getCellWidth()),cell.getTop()-Math.round((goTo[1]-start[1])/c.getCellHeight()), cell.getRight()-Math.round((goTo[0]-start[0])/c.getCellWidth()),cell.getBottom()-Math.round((goTo[1]-start[1])/c.getCellHeight())); } else item.setPosition(start[0]+x,start[1]+y); if(c.getItemZIndex(item)>=zorder)c.setItemZIndex(item,0); } var diff=0; LL.writeToLogFile(page0+"\n"+page1,false); step(); function step() { diff+=255/speed; if(diff<255) { for(a=0;a<page1.length;a++) { var item=page1[a]; item.getProperties().edit().setInteger("i.alpha",diff).commit(); } for(a=0;a<page0.length;a++) { var item=page0[a]; item.getProperties().edit().setInteger("i.alpha",255-diff).commit(); } setTimeout(step,0); } else { for(a=0;a<page1.length;a++) { var item=page1[a]; var x=(item.getPositionX()%dwidth+ dwidth)%dwidth; var y=((item.getPositionY()%dheight +dheight)%dheight); item.getProperties().edit().setInteger("i.alpha",255).commit(); if(item.getProperties().getBoolean("i.onGrid")) { var cell=item.getCell(); item.setCell(cell.getLeft()+Math.round((goTo[0]-start[0])/c.getCellWidth()),cell.getTop()+Math.round((goTo[1]-start[1])/c.getCellHeight()), cell.getRight()+Math.round((goTo[0]-start[0])/c.getCellWidth()),cell.getBottom()+Math.round((goTo[1]-start[1])/c.getCellHeight())); } else item.setPosition(goTo[0]+x,goTo[1]+y); } c.setPosition(goTo[0],goTo[1],1,false); for(a=0;a<page0.length;a++) { var item=page0[a]; item.getProperties().edit().setInteger("i.alpha",255).commit(); } } } </sxh>

script_fading_page_bookmark.txt · Last modified: 2016/06/28 12:20 by f43nd1r