User Tools

Site Tools


plugins:own_javascript_plugin

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
Next revision Both sides next revision
plugins:own_javascript_plugin [2015/07/08 09:56]
84.181.12.30 [First Step:]
plugins:own_javascript_plugin [2017/09/18 18:52]
190.237.183.152 [How can you uninstall your plugin?] lvw.Show();
Line 59: Line 59:
  <p>Then you can create an instance of the plugin object when you need it like this:</p>  <p>Then you can create an instance of the plugin object when you need it like this:</p>
   
- <div class="samp">&nbsp;plg = app.CreateObject"MyPlugin" );</div>+ <div class="samp">&nbsp;plg = app.CreateMyPlugin();</div>
        
  <br>  <br>
Line 76: Line 76:
  &nbsp;&nbsp;lay.AddChild( btn );<br><br>  &nbsp;&nbsp;lay.AddChild( btn );<br><br>
  <b id="snip1"  style="font-size:100%">  <b id="snip1"  style="font-size:100%">
- &nbsp;&nbsp;plg = app.CreateObject"MyPlugin" );<br>+ &nbsp;&nbsp;plg = app.CreateMyPlugin();<br>
  </b><br>  </b><br>
  &nbsp;&nbsp;app.AddLayout( lay );<br>  &nbsp;&nbsp;app.AddLayout( lay );<br>
Line 107: Line 107:
  &nbsp;&nbsp;lay.AddChild( btn );<br><br>  &nbsp;&nbsp;lay.AddChild( btn );<br><br>
  <b id="snip2"  style="font-size:100%">  <b id="snip2"  style="font-size:100%">
- &nbsp;&nbsp;plg = app.CreateObject"MyPlugin" );<br>+ &nbsp;&nbsp;plg = app.CreateMyPlugin();<br>
  &nbsp;&nbsp;plg.SetOnMyReply( OnMyReply );<br>  &nbsp;&nbsp;plg.SetOnMyReply( OnMyReply );<br>
  </b><br>  </b><br>
Line 140: Line 140:
  
 <code Javascript MyPlugin.inc> <code Javascript MyPlugin.inc>
 +
 +app.CreateMyPlugin = function() 
 +
 +    return new MyPlugin();
 +}
  
 function MyPlugin() function MyPlugin()
Line 205: Line 210:
 =====How can you uninstall your plugin?===== =====How can you uninstall your plugin?=====
  
-(no answer at the moment)+There are two ways at the moment
 +You can download and run the following script if you want uninstall a plugin or you uninstall and reinstall Droidscript completely. Using the second option causes all your plugins to be uninstalled so you have to reinstall all plugins. 
 + 
 +<code javascript UninstallPlugin.js> 
 + 
 +//Called when application is started. 
 +function OnStart() 
 +
 +    //Create a layout with objects vertically centered. 
 +    lay = app.CreateLayout( "linear", "VCenter,FillXY" );     
 + 
 +    //Create a text label and add it to layout. 
 +    txt = app.CreateTextEdit( "" ); 
 +    txt.SetHint("Plugin to delete"
 +    lay.AddChild( txt ); 
 + 
 +    btn=app.CreateButton("Delete Plugin"); 
 +    btn.SetOnTouch(DeleteUserPlugin); 
 +    lay.AddChild(btn); 
 +     
 +    privFldr = app.GetPrivateFolder( "Plugins" ); 
 +    plgins = app.ListFolder(privFldr); 
 + 
 +    lvw = app.CreateListView( plgins, "Select a Plugin for uninstalling or press Back" ); 
 +    lvw.SetOnTouch( lvw_OnTouch ); 
 + 
 +    //Add layout to app.     
 +    app.AddLayout( lay ); 
 + 
 +    lvw.Show(); 
 +
 + 
 + 
 +function lvw_OnTouch( item ) 
 +
 +  txt.SetText( item ); 
 +
 + 
 + 
 +function DeleteUserPlugin() 
 +
 +    var plg = "" + txt.GetText() 
 +    if (plg == "") return; 
 +    plugDir = privFldr + "/" + plg.toLowerCase(); 
 +    if (app.FolderExists(plugDir)) 
 +    { 
 +       var list = app.ListFolder(plugDir); 
 +       var yesNo = app.CreateYesNoDialog( "Do you really want to uninstall the plugin " + txt.GetText() + "? \nThe following files or folders will be all deleted:\n\n" + list + "\n\nIt is no way for undo!"); 
 +       yesNo.SetOnTouch( yesNo_OnTouch ); 
 +       yesNo.Show(); 
 +    } 
 +
 + 
 + 
 +function yesNo_OnTouch( yesNoresult ) 
 +
 +    if( yesNoresult == "Yes" ) 
 +    {  
 +        app.DeleteFolder(plugDir); 
 +         
 +        app.Alert("Plugin " + txt.GetText() + " uninstalled!"); 
 +        txt.SetText(""); 
 +    } 
 +    else 
 +    { 
 +        app.ShowPopup("No changings!")
 +    } 
 +
 + 
 +</code> 
 + 
  
 ---- ----
plugins/own_javascript_plugin.txt · Last modified: 2019/09/17 15:35 (external edit)