User Tools

Site Tools


script_minimalistic_page_indicator

====== About the script ====== * Purpose : Change the label of an item to make a page indicator * Author : [[https://plus.google.com/u/1/105066926163073195690|TrianguloY]] * Link: https://plus.google.com/u/1/105066926163073195690/posts/6UtcUamShm3 (With video) ====== How to use the script ====== Important: due to the custom characters I use, the maximum number of pages is 10. However you can change the character as you wish. Instructions: * Copy/paste this script as a new one * Set it to run in the 'position change' event of the desktop * place an item (recommend: shortcut to 'do nothing' and pinned) and label it 'indicator'. * [Recommended] Check the snap to pages and uncheck 'fit desktop to items' in scrolling options. It automatically adapts to the desktop, for this reason the home page may not be the number 1. ====== Script code ====== <sxh javascript> //The special characters var fill = "➊❷❸❹❺❻❼❽❾❿"; var empty = "①②③④⑤⑥⑦⑧⑨⑩"; //Vars var cont = LL.getEvent().getContainer(); var width=cont.getWidth(); var left = Math.round(cont.getBoundingBox().getLeft()/width); var right = Math.round(cont.getBoundingBox().getRight()/width)-1; var page = Math.round(cont.getPositionX()/width); //With zoom --> no page selected if(cont.getPositionScale()!=1) page=NaN; var ind = ""; var flag=false; //if more pages, just show "..." if(right-left+1>empty.length){ right=left+empty.length-1; flag=true; } //indicator for(var i=0;i<=right-left;++i)ind+=(left+i==page?fill[i]:empty[i]); if(flag)ind+="..."; //apply try{ item=cont.getItemByLabel("indicator").setLabel(ind); }catch(e){ alert("Item not found. You need to label an item 'indicator'"); } </sxh>

script_minimalistic_page_indicator.txt · Last modified: 2014/10/19 15:27 by trianguloy