User Tools

Site Tools


script_external_editor_script_importer

**This is an old revision of the document!** ----

A PCRE internal error occured. This might be caused by a faulty plugin

====== About the script ====== * Purpose : automatically import .js files elsewhere on your device into lightning launcher when they have changed. This allows you to use external script editors! * Author : cdfa * Link: none yet ====== How to use the script ====== Recommended to run the script on resumed event of the container which is your test environment, but you can use it really anytime anywhere. ====== Script code ====== <code> //Old tag var scriptFolder = "/storage/emulated/0/LightningLauncher/script"; LL.bindClass("java.lang.StringBuilder") LL.bindClass("java.io.FileReader") LL.bindClass("java.io.BufferedReader") LL.bindClass("java.io.File") LL.bindClass("java.text.SimpleDateFormat") scriptNames = [] folder = new File(scriptFolder) files = folder.listFiles() for(i=0;i<files.length;i++){ name = files[i].getName() length = name.length if(name.substring(length-3,length)==".js"){ scriptNames[scriptNames.length] = name } } for(i=0;i<scriptNames.length;i++){ var script=LL.getScriptByName(scriptNames[i].substring(0,scriptNames[i].length-3)); file = new File(scriptFolder,scriptNames[i]) lmdate = file.lastModified() tagdate = script.getTag("lmdate") if(lmdate>tagdate||typeof tagdate == "undefined"){ text = new StringBuilder(); try { br = new BufferedReader(new FileReader(file)); var line while ((line = br.readLine()) != null) { text.append(line); text.append('\n'); } br.close(); script.setText(text); date = new Date() script.setTag("lmdate",date.getTime()) } catch (err) { throw(err) } } } </code> <sxh javascript> //New tag, line completion and colors var scriptFolder = "/storage/emulated/0/LightningLauncher/script"; LL.bindClass("java.lang.StringBuilder") LL.bindClass("java.io.FileReader") LL.bindClass("java.io.BufferedReader") LL.bindClass("java.io.File") LL.bindClass("java.text.SimpleDateFormat") scriptNames = [] folder = new File(scriptFolder) files = folder.listFiles() for(i=0;i<files.length;i++){ name = files[i].getName() length = name.length if(name.substring(length-3,length)==".js"){ scriptNames[scriptNames.length] = name } } for(i=0;i<scriptNames.length;i++){ var script=LL.getScriptByName(scriptNames[i].substring(0,scriptNames[i].length-3)); file = new File(scriptFolder,scriptNames[i]) lmdate = file.lastModified() tagdate = script.getTag("lmdate") if(lmdate>tagdate||typeof tagdate == "undefined"){ text = new StringBuilder(); try { br = new BufferedReader(new FileReader(file)); var line while ((line = br.readLine()) != null) { text.append(line); text.append('\n'); } br.close(); script.setText(text); date = new Date() script.setTag("lmdate",date.getTime()) } catch (err) { throw(err) } } } </sxh>

script_external_editor_script_importer.1428717389.txt.gz · Last modified: 2015/04/11 01:56 by cdfa