**This is an old revision of the document!** ----
====== About the script ====== * Purpose : This script is a multifunctional tool to do or show a lot of stuff * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] * Current Version : 1.3 * Link : https://plus.google.com/115366157037831519359/posts/fQwfu5AUj5m ====== Changelog ====== * Version 1.0 (20/7/2014): initial release in wiki * Version 1.1 (21/7/2014): replaced move item script with trianguloY's solution. * Version 1.2 (25/7/2014): replaced change home page with move pages to extend functionality, sorted choices on script-side * Version 1.2.1 (26/7/2014): added Intent to Item details * Version 1.3 (28/7/2014): fix: no touch data in swipe event, add resize, add save, add containers ID ====== How to use the script ====== * enable the script in any menu or event you want to run it ====== Current functionality ====== * Show Event related parameters * Show Container related parameters * Show Item related parameters * Attach/Detach all Items * Resize all detached items * Delete all Items * Move (a) specific page(s) to another position. This can be used to change the home page by selecting all items * Reset Tag * Reset Tool © by trianguloY * save all Layout changes ====== Issues and hints ====== * Find the hidden treasure :D //please report all bugs in the g+ community// ====== Script ====== <sxh javascript;>var choice=parseInt(prompt("What do you want to do?\n1 - Show Event related parameters\n2 - Show Container related parameters\n3 - Show Item related parameters\n4 - Attach/Detach all Items\n5- Resize all detached Items\n6 - Delete all Items\n7 - Move Pages\n8 - Reset Tag\n9 - Reset Tool © by trianguloY\n10 - Save changes","")); switch(choice) { case 1: var e=LL.getEvent(); try { e.getTouchScreenX(); var ok=true; } catch(Exception) { var ok=false; } alert("Source: "+e.getSource()+"\nDate: "+e.getDate()+"\nContainer: "+e.getContainer()+"\nItem: "+e.getItem()+(ok?("\nTouch: "+e.getTouchX()+","+e.getTouchY()+"\nTouch (Screen): "+e.getTouchScreenX()+","+e.getTouchScreenY()):"")); break; case 2: var c=LL.getEvent().getContainer(); var t=c.getType(); alert("Type: "+t+"\nName/Label: "+(t=="Desktop"?c.getName():c.getOpener().getLabel())+"\nID: "+c.getId()+"\nTag: "+c.getTag()+"\nSize: "+c.getWidth()+","+c.getHeight()+"\nBoundingbox: "+c.getBoundingBox()+"\nCell Size: "+c.getCellWidth()+","+c.getCellHeight()+"\nCurrent Position: "+c.getPositionX()+","+c.getPositionY()+"\nCurrent Scale: "+c.getPositionScale()+"\nItems: "+c.getItems()); break; case 3: var i=LL.getEvent().getItem(); alert(i==null?"no item found":"Label: "+i.getLabel()+"\nType: "+i.getType()+"\nTag: "+i.getTag()+"\nID: "+i.getId()+"\nSize: "+i.getWidth()+","+i.getHeight()+"\nPosition: "+i.getPositionX()+","+i.getPositionY()+"\nScale: "+i.getScaleX()+","+i.getScaleY()+"\nAngle: "+i.getRotation()+"\nCenter: "+center(i)+(i.getType()=="Shortcut"?"\nIntent:"+i.getIntent():"")); break; case 4: var items=LL.getEvent().getContainer().getItems(); var togrid=confirm("Attach? if not, detach"); for(x=0;x<items.length;x++) { var i=items.getAt(x); i.getProperties().edit().setBoolean("i.onGrid",togrid).commit(); } break; case 5: try { var s=JSON.parse("["+prompt("which size? (input like width,height)","")+"]"); var items=LL.getEvent().getContainer().getItems(); for(var a=0;a<items.length;a++) items.getAt(a).setSize(s[0],s[1]); } catch(Exception) { Android.makeNewToast("Invalid input",true).show(); } break; case 6: if(confirm("Are you sure?")) { var c=LL.getEvent().getContainer(); var i=c.getItems(); for(a=0;a<i.length;a++) c.removeItem(i.getAt(a)); } case 7: var cont=LL.getEvent().getContainer(); var items=cont.getItems(); var cwidth=cont.getWidth(); var cheight=cont.getHeight(); var cellsFloatX=cwidth/cont.getCellWidth(); var cellsFloatY=cheight/cont.getCellHeight(); var cellsX=Math.round(cellsFloatX); var cellsY=Math.round(cellsFloatY); if(Math.abs(cellsFloatX-cellsX)>0.00001) if(!confirm("Warning, the cells don't fill the screen as an exact horizontal number.\nDo you want to continue?"))return; if(Math.abs(cellsFloatY-cellsY)>0.00001) if(!confirm("Warning, the cells don't fill the screen as an exact vertical number.\nDo you want to continue?"))return; try { var s=prompt("Which page do you want to move? (* for all) input has to be x,y (e.g. *,* for all pages)","").split(","); var move=JSON.parse("[\""+s[0]+"\",\""+s[1]+"\"]"); var done=true; } catch(Exception) { var done=false; } if(!done||move==null||move[0]==null||(move[0]!="*"&&isNaN(parseInt(move[0])))||move[1]==null||(move[1]!="*"&&isNaN(parseInt(move[1])))) { Android.makeNewToast("Invalid input",true).show(); return; } if(move[0]!="*")move[0]=parseInt(move[0]); if(move[1]!="*")move[1]=parseInt(move[1]); try { var dist=JSON.parse("["+prompt("How far do you want to move? input has to be x,y (e.g. 1,0 for one page right)","")+"]"); var done=true; } catch(Exception) { var done=false; } if(!done||dist==null||dist[0]==null||isNaN(dist[0])||dist[1]==null||isNaN(dist[1])) { Android.makeNewToast("Invalid input",true).show(); return; } if(dist[0]==0&&dist[1]==0)return; for(var i=items.getLength()-1;i>=0;--i) { var item=items.getAt(i); var pos=[item.getPositionX(),item.getPositionY()]; if((move[0]=="*"||(pos[0]>cwidth*move[0]&&pos[0]<cwidth*(move[0]+1)))&&(move[1]=="*"||(pos[1]>cheight*move[1]&&pos[1]<cheight*(move[1]+1)))) { var prop=item.getProperties(); var xx=1,yy=1; var pinmode=prop.getString("i.pinMode"); if(pinmode[0]=="X")xx=0; if(pinmode.indexOf("Y")!=-1)yy=0; if(prop.getBoolean("i.onGrid")) { var cell=item.getCell(); item.setCell(cell.getLeft()+cellsX*dist[0]*xx,cell.getTop()+cellsY*dist[1]*yy,cell.getRight()+cellsX*dist[0]*xx,cell.getBottom()+cellsY*dist[1]*yy); } else {item.setPosition(pos[0]+cwidth*dist[0]*xx,pos[1]+cheight*dist[1]*yy); } } } LL.save(); break; case 8: var d=LL.getEvent().getContainer(); var i=LL.getEvent().getItem();(i!=null?i:d).setTag(null); Android.makeNewToast((i==null?"container":"item")+"s tag resetted.",false).show(); break; case 9: var cont=LL.getEvent().getContainer(); var items=cont.getItems(); var bools=[];bools[0]=confirm("Reset cell? (only grid items) [0,0]"); bools[1]=confirm("Reset position? (only free items) [0,0] "); bools[2]=confirm("Reset rotation? (only free items) [0]"); bools[3]=confirm("Reset scale? (only free items) [1,1]"); bools[4]=confirm("Reset skew? (only free items) [0,0]"); bools[5]=confirm("Reset size? (only free items) [cell size]"); bools[6]=confirm("Reset visibility? [true]"); for(var i=0;i<items.getLength();++i) { var t=items.getAt(i); if(bools[0])t.setCell(0,0,1,1); if(bools[1])t.setPosition(0,0); if(bools[2])t.setRotation(0); if(bools[3])t.setScale(1,1); if(bools[4])t.setSkew(0,0); if(bools[5])t.setSize(cont.getCellWidth(),cont.getCellHeight()); if(bools[6])t.setVisibility(true); } break; case 10: LL.save(); break; case 42: alert("You found the hidden treasure!\n (_) \n (___) \n (___) \n (___) \n /\\__/---\\__/\\ \n \\_°_¤-¤_°_/ \n \\ __°__ / \n |\\_--_/| \n [|\\_/|] \n [|[¤]|] \n [|:¤:|] \n [::¤::] \n [|:¤:|] \n [|:¤:|] \n [|[¤]|] \n [|[¤]|] \n ||[¤]|| \n \\|[•]|/ \n \\[•]/ \n \\./ \n ' "); default: Android.makeNewToast("illegal input: "+choice,false).show(); break; } function center(item) { var r=item.getRotation()*Math.PI/180; var sin=Math.abs(Math.sin(r)); var cos=Math.abs(Math.cos(r)); var w=item.getWidth()*item.getScaleX(); var h=item.getHeight()*item.getScaleY(); return[item.getPositionX()+(w*cos+h*sin)*0.5,item.getPositionY()+(h*cos+w*sin)*0.5]; } </sxh>