====== Differences ====== This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
script_slideshow [2014/07/27 10:33] lm13 [About the script] |
script_slideshow [2016/06/28 12:16] (current) f43nd1r |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== About the script ====== | ====== About the script ====== | ||
| * Purpose : This script will make your Panel scroll automatically, like a slideshow | * Purpose : This script will make your Panel scroll automatically, like a slideshow | ||
| - | * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] | + | * Author : F43nd1r |
| * Idea : Pierre Hébert | * Idea : Pierre Hébert | ||
| - | * Current Version : 2.0 | + | * Current Version : 3.0 |
| * Link : https://plus.google.com/115366157037831519359/posts/84DvszxGQXA | * Link : https://plus.google.com/115366157037831519359/posts/84DvszxGQXA | ||
| * Video : https://plus.google.com/115366157037831519359/posts/9eUTw8cCCpi | * Video : https://plus.google.com/115366157037831519359/posts/9eUTw8cCCpi | ||
| Line 10: | Line 10: | ||
| * Version 1.0 (1/4/2014): initial release in wiki | * Version 1.0 (1/4/2014): initial release in wiki | ||
| * Version 2.0 (27/7/2014): complete new coded, only one Script | * Version 2.0 (27/7/2014): complete new coded, only one Script | ||
| + | * Version 3.0 (7/9/2014): added vertical support, added desktop support, switched from panelID to itemID | ||
| ====== How to use the script ====== | ====== How to use the script ====== | ||
| Line 26: | Line 27: | ||
| <sxh javascript;>//config | <sxh javascript;>//config | ||
| var waitingTime=3000;//time between page switches, in ms, not exact | var waitingTime=3000;//time between page switches, in ms, not exact | ||
| - | var panelID=0x040001;//if you take the ID from hierachy, put a '0x' in front of it | + | var itemID=0x000001;//if you take the ID from hierachy, put a '0x' in front of it, the ID of any item in the container |
| - | var notify=true;//mainly for debug, creates toasts with status | + | var notify=false;//mainly for debug, creates toasts with status |
| + | var vertical=false;//false for horizontal, true for vertical | ||
| //endconfig | //endconfig | ||
| Line 33: | Line 35: | ||
| if((typeof running==='undefined'||!running)) | if((typeof running==='undefined'||!running)) | ||
| { | { | ||
| - | var c=LL.getItemById(panelID).getContainer(); | + | var c=LL.getItemById(itemID).getParent(); |
| if(c==null) | if(c==null) | ||
| { | { | ||
| Line 50: | Line 52: | ||
| function start() | function start() | ||
| { | { | ||
| - | w=c.getWidth(); | + | if(!vertical) |
| - | if(w==0) | + | |
| { | { | ||
| - | setTimeout(start,50); | + | w=c.getWidth(); |
| - | return; | + | if(w==0) |
| + | { | ||
| + | setTimeout(start,50); | ||
| + | return; | ||
| + | } | ||
| + | box=c.getBoundingBox(); | ||
| + | l=box.getLeft(); | ||
| + | d=box.getRight()-l; | ||
| + | y=c.getPositionY(); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | h=c.getHeight(); | ||
| + | if(h==0) | ||
| + | { | ||
| + | setTimeout(start,50); | ||
| + | return; | ||
| + | } | ||
| + | box=c.getBoundingBox(); | ||
| + | t=box.getTop(); | ||
| + | b=box.getBottom()-t; | ||
| + | x=c.getPositionX(); | ||
| } | } | ||
| - | b=c.getBoundingBox(); | ||
| - | l=b.getLeft(); | ||
| - | d=b.getRight()-l; | ||
| - | y=c.getPositionY(); | ||
| if(notify)Android.makeNewToast("Slideshow started",true).show(); | if(notify)Android.makeNewToast("Slideshow started",true).show(); | ||
| step(); | step(); | ||
| Line 75: | Line 93: | ||
| if(a>=waitingTime) | if(a>=waitingTime) | ||
| { | { | ||
| - | var goTo=(Math.floor(c.getPositionX()/w)*w-l+w)%d+l; | + | var goTo=(!vertical?((Math.floor(c.getPositionX()/w)*w-l+w)%d+l):((Math.floor(c.getPositionY()/h)*h-t+h)%b+t)); |
| - | c.setPosition(goTo,y); | + | c.setPosition(vertical?x:goTo,!vertical?y:goTo); |
| a=0; | a=0; | ||
| } | } | ||
| setTimeout(step,1); | setTimeout(step,1); | ||
| - | } | + | } |
| </sxh> | </sxh> | ||