**This is an old revision of the document!** ----
====== About the script ====== * Purpose : This script will fill any container with all of your apps, like an App Drawer * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] * Current Version : 2.1 * Link: https://plus.google.com/115366157037831519359/posts/4F9TpMfz2fv ====== Changelog ====== * Version 1.0 (18/7/2014): initial release in wiki * Version 1.1 (20/7/2014): added optional horizontal sorting * Version 2.0 (23/7/2014): Removed autovalues, due to an unfixable bug, added item remove and add again * Version 2.1 (28/8/2014): Sorting ignores Case ====== How to use the script ====== * Set the script in the resumed event of the container * configure what you want at the beginning of the script * enable the script for Lightning and item menu * if you don't want to see an app in the new app drawer, run this script from the item menu * to re-add items, run this script from lightning menu ====== Issues and Hints ====== * As the script is based on the original app drawer, you may have to load the original app drawer once to detect installed or uninstalled apps * first load may take some time * don't hide the icons in the original app drawer. * if you delete items in the normal way, it will cause an error //please report all bugs in the g+ community!// ====== Script ====== <sxh javascript;>//config var columns=5;//has to be an Integer >0 var rows=0;//has to be an Integer >=0, 0 for infinite //endconfig var e=LL.getEvent(); var c=e.getContainer(); var d=LL.getContainerById(99); var db=JSON.parse(c.getTag())||[]; if(e.getSource()=="MENU_ITEM") { if(db[0]==null) { alert("Error: database for this container not yet created!"); return; } var i=e.getItem(); var a=0; while(db[a][1]!=i.getId()||a==db.length)a++; if(a==db.length) { if(confirm("Item not in database.\n Delete anyway?"))c.removeItem(i); return; } db[a][1]=-1; c.removeItem(i); } if(e.getSource()=="MENU_APP") { if(db[0]==null) { alert("Error: database for this container not yet created!"); return; } var found=false; for(a=0;a<db.length;a++) { if(db[a][1]==-1) { var found=true; var item=LL.getItemById(db[a][0]); if(confirm("Recreate "+item.getLabel()+"?")) { var newItem=c.addShortcut(item.getLabel(),item.getIntent(),0,0); newItem.setDefaultIcon(item.getDefaultIcon()); db[a][1]=newItem.getId(); } } } if(!found)Android.makeNewToast("No deleted items found",true).show(); } var ditems=d.getItems(); for(a0=0;a0<ditems.length;a0++) resetTag(ditems.getAt(a0)); for(a1=0;a1<db.length;a1++) { if(LL.getItemById(db[a1][0])==null) { if(LL.getItemById(db[a1][1])!=null) c.removeItem(LL.getItemById(db[a1][1])); if(a1==db.length-1)db.pop(); else { db[a1]=db.pop(); a1--; } } else{ LL.getItemById(db[a1][0]).setTag("saved"); } } for(a2=0;a2<ditems.length;a2++) check(ditems.getAt(a2)); c.setTag(JSON.stringify(db)); var labels=[]; for(a4=0;a4<db.length;a4++)if(db[a4][1]!=-1)labels.push(LL.getItemById(db[a4][1]).getLabel()); labels.sort(noCaseSort); if(rows==0) for(a5=0;a5<labels.length;a5++) c.getItemByLabel(labels[a5]).setCell(a5%columns,Math.floor(a5/columns),a5%columns+1,Math.floor(a5/columns)+1); else for(a5=0;a5<labels.length;a5++) c.getItemByLabel(labels[a5]).setCell(a5%columns+columns*Math.floor(a5/(rows*columns)),Math.floor(a5/columns)-rows*Math.floor(a5/(rows*columns)),a5%columns+columns*Math.floor(a5/(rows*columns))+1,Math.floor(a5/columns)-rows*Math.floor(a5/(rows*columns))+1); LL.save(); function check(item) { if(item.getType()=="Folder") { var fitems=item.getContainer().getItems(); for(a3=0;a3<fitems.length;a3++) check(fitems.getAt(a3)); } else if(item.getTag()!="saved") { var newItem=c.addShortcut(item.getLabel(),item.getIntent(),0,0); newItem.setDefaultIcon(item.getDefaultIcon()); db.push([item.getId(),newItem.getId()]); } } function resetTag(item) { if(item.getType()=="Folder") { var fitems=item.getContainer().getItems(); for(a5=0;a5<fitems.length;a5++) resetTag(fitems.getAt(a5)); } else { item.setTag(null); } } function noCaseSort(a,b) { if(a.toLowerCase()>b.toLowerCase())return 1; if(a.toLowerCase()<b.toLowerCase())return -1; return 0; } </sxh>