This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
plugins:own_javascript_plugin [2015/07/08 09:01] octazid [How can uninstall your plugin?] |
plugins:own_javascript_plugin [2019/09/17 15:35] (current) |
||
---|---|---|---|
Line 8: | Line 8: | ||
//Hi Guys, | //Hi Guys, | ||
- | For those of you that would like to have a go at creating pure JavaScript plugins for DroidScript, | + | For those of you that would like to have a go at creating pure JavaScript plugins for DroidScript, |
//You simply need to drop this zip file into a folder called / | //You simply need to drop this zip file into a folder called / | ||
When you come to renaming and making your own plugins, please make sure you use the same format and case for file names as those shown in this sample. | When you come to renaming and making your own plugins, please make sure you use the same format and case for file names as those shown in this sample. | ||
Line 15: | Line 15: | ||
(Note: You can make sub folders in the zip file for your documentation images etc if you like)// | (Note: You can make sub folders in the zip file for your documentation images etc if you like)// | ||
- | *(The Sample is a simple **Zip-File** with 4 files. You can find this files below. All you have to do is to Download the files. Put them in one folder and zip this folder.) | + | *(The Sample is a simple **Zip-File** with 4 files. You can find this files below. All you have to do is to Download the files. Put them in one folder and zip this folder, or download the complete zip file) |
---- | ---- | ||
Line 59: | Line 59: | ||
< | < | ||
- | <div class=" | + | <div class=" |
| | ||
< | < | ||
Line 76: | Line 76: | ||
& | & | ||
<b id=" | <b id=" | ||
- | & | + | & |
</ | </ | ||
& | & | ||
Line 107: | Line 107: | ||
& | & | ||
<b id=" | <b id=" | ||
- | & | + | & |
& | & | ||
</ | </ | ||
Line 140: | Line 140: | ||
<code Javascript MyPlugin.inc> | <code Javascript MyPlugin.inc> | ||
+ | |||
+ | app.CreateMyPlugin = function() | ||
+ | { | ||
+ | return new MyPlugin(); | ||
+ | } | ||
function MyPlugin() | function MyPlugin() | ||
Line 150: | Line 155: | ||
} | } | ||
- | | + | |
- | { | + | { |
this.callback( txt + " World!!", | this.callback( txt + " World!!", | ||
} | } | ||
- | | + | |
- | { | + | { |
this.callback = cb; | this.callback = cb; | ||
} | } | ||
Line 168: | Line 173: | ||
</ | </ | ||
- | * **File 4: A blanc jar-file | + | * **It is no longer necessary to add an empty jar-file |
- | + | ||
- | <code Java MyPlugin.jar> | + | |
- | + | ||
- | </ | + | |
Line 205: | Line 206: | ||
=====How can you uninstall your plugin? | =====How can you uninstall your plugin? | ||
- | (no answer | + | 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> | ||
+ | |||
+ | // | ||
+ | function OnStart() | ||
+ | { | ||
+ | // | ||
+ | lay = app.CreateLayout( " | ||
+ | |||
+ | // | ||
+ | txt = app.CreateTextEdit( "" | ||
+ | txt.SetHint(" | ||
+ | lay.AddChild( txt ); | ||
+ | |||
+ | btn=app.CreateButton(" | ||
+ | btn.SetOnTouch(DeleteUserPlugin); | ||
+ | lay.AddChild(btn); | ||
+ | |||
+ | privFldr = app.GetPrivateFolder( " | ||
+ | plgins = app.ListFolder(privFldr); | ||
+ | |||
+ | lvw = app.CreateListView( plgins, | ||
+ | lvw.SetOnTouch( lvw_OnTouch ); | ||
+ | |||
+ | // | ||
+ | app.AddLayout( lay ); | ||
+ | |||
+ | lvw.Show(); | ||
+ | } | ||
+ | |||
+ | |||
+ | function lvw_OnTouch( item ) | ||
+ | { | ||
+ | txt.SetText( item ); | ||
+ | } | ||
+ | |||
+ | |||
+ | function DeleteUserPlugin() | ||
+ | { | ||
+ | var plg = "" | ||
+ | if (plg == "" | ||
+ | plugDir = privFldr + "/" | ||
+ | if (app.FolderExists(plugDir)) | ||
+ | { | ||
+ | var list = app.ListFolder(plugDir); | ||
+ | var yesNo = app.CreateYesNoDialog( " | ||
+ | yesNo.SetOnTouch( yesNo_OnTouch ); | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | function yesNo_OnTouch( yesNoresult ) | ||
+ | { | ||
+ | if( yesNoresult == " | ||
+ | { | ||
+ | app.DeleteFolder(plugDir); | ||
+ | |||
+ | app.Alert(" | ||
+ | txt.SetText("" | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | app.ShowPopup(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
---- | ---- |