User Tools

Site Tools


script_dynamic_calendar_icon

====== About the script ====== * Purpose : Change the icon of an item related to the current day * Author : [[https://plus.google.com/u/1/105066926163073195690|TrianguloY]] * Link: https://plus.google.com/+TrianguloY/posts/hLS4NMCxUaH (with video with instructions) ====== How to use the script ====== The instructions are: (watch the video included in the link for better understanding) * Change in the script the label of the item, by default it is 'Calendar' * By default it shows the day, change the 'month' variable to true to show the month * Open the icon picker (just choose an icon of an item), then search for the item you want. If it support a dynamic calendar, you will find 31 icon, all the same but with different numbers. Just long press the one with the number 1 a toast will say that the data was copied. You can press back now to cancel. * In the script, where it says, paste that data. * Set the script in the resumed event of the container with the item. It is now ready to use. Note: if it don't work, paste that data I mentioned in the google+ post (link before). Due to the long variety of icon packs I couldn't test all. Another note: it only updates the icon when the day/month change, if you want to force it (because you changed the icon or whatever) run the script from the item. ====== Script code ====== <sxh javascript> //go to the icon picker and search the 31 items. Long click the first one (it will be copied) and paste it here between the brackets var link = [ ] //This is the label of the item to put the icon to var labelName = "Calendar"; //write true to set the calendar based on the month. By default it's false: based on the day var month=false; //end of config if(link.length==0){alert("follow the instructions and paste the icon properties in the script");return;} LL.bindClass("java.util.Calendar"); var now=Calendar.getInstance().get(month?Calendar.MONTH:Calendar.DAY_OF_MONTH); if(month)now++; //only when change, or run from item if(now.toString()==LL.getScriptTag()&&LL.getEvent().getSource()!="MENU_ITEM")return; LL.setScriptTag(now); var iconPackName = link[0]; var prefixName = link[1].substring(0,link[1].length-1); var item=LL.getEvent().getContainer().getItemByLabel(labelName); if(item==null){alert("no item found, make sure the label is the same as in the script"); return;} var icon=LL.createImage(iconPackName,prefixName+now); if(icon==null){alert("no icon found, make sure the pasted data is right and the icon pack have it");return;} item.setCustomIcon(icon); </sxh>

script_dynamic_calendar_icon.txt · Last modified: 2018/08/14 16:51 by f43nd1r