User Tools

Site Tools


script_template

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
script_template [2015/04/11 01:27]
cdfa [Script code]
script_template [2015/05/05 20:27] (current)
trianguloy
Line 1: Line 1:
 ====== About the script ====== ====== 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! +  * Purpose : explain what the script ​does 
-  * Author : cdfa +  * Author : who wrote this script 
-  * Link: none yet+  * Link: if needed, you may add a link here 
 ====== How to use the script ====== ====== 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"​) +Explain everything needed to use the script, ​whether some item configuration need to be done beforeon which event to trigger the script, ​and so on
-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>​+
  
 +====== Script code ======
 <sxh javascript>​ <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 { +//New tag, line completion and colors. ​ 
-      br = new BufferedReader(new FileReader(file)); +//The previous one was <​code>​ script(); </​code>​ 
-      var line+//remove those lines and write here your script 
 +yourJavaScriptCodeHere();​
  
-      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>​ </​sxh>​
script_template.1428715628.txt.gz · Last modified: 2015/04/11 01:27 by cdfa