Author Topic: Apps with and without <app_type>app</app_type>  (Read 2199 times)

scw2wi

  • Jr. Member
  • *
  • Posts: 71
Apps with and without <app_type>app</app_type>
« on: March 01, 2016, 12:52:09 AM »
What does the node <app_type> mean in XML file of apps?

I have developed my first app without this node and it was working fine.
Like in the app "Image Files" I have directly put IMatch variables in HTML code.

e.g.
<td>{File.MD.XMP::dc\title\Title\0|default:No Title}</td>

Then I came to know that my function onIMatchEvent(Params) is never called.
On change of file selection scope always onLoad() is called instead.

When I add <app_type>app</app_type> to my xml file,
onIMatchEvent is called as expected when a selection is changed
(and also when window is resized, but that's another story),
and onLoad is only called when the App is really loaded now.

But IMatch variables in HTML code are not working any longer with this node <app_type>.
They are not replaced by content, they are just show as the original string,
so instead of the title the window shows this string: {File.MD.XMP::dc\title\Title\0|default:No Title}

Is there any error in my understanding or is this the expected behavior?

Walter

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 31580
Re: Apps with and without <app_type>app</app_type>
« Reply #1 on: March 01, 2016, 08:24:55 AM »
There are HTML templates (simple) and Apps (more powerful but also more complex).

I have explained all this at great length in the App help topic. In short:

When you use a HTML template, it is loaded every time the selection changes. Basically, IMatch loads your HTML, replaces the variables and displays the result. This is done every time the selection changes. This is an easy way to setup simple information displays, without any further need for JavaScript. But it's also very limited.

The HTML of an app is loaded once and then events are sent whenever something in IMatch changes. The app is supposed to react on these events, e.g. by refreshing what is displayed. IMatch loads the HTML code of the app "as-is", without replacing variables. You can use the methods provided by the IMatch JavaScript classes to parse variables yourself, mix it freely with JavaScript etc.

See the App help topic and the example apps shipping with IMatch.

scw2wi

  • Jr. Member
  • *
  • Posts: 71
Re: Apps with and without <app_type>app</app_type>
« Reply #2 on: March 01, 2016, 09:27:13 PM »
Thank you Mario.

Yes it is explained in very detail in the Help and I don't know why I did not understand that description, but now it's clear.

I am using a simple template for filling a lot of metadata fields, but now I need to save the status from one selection to the other.
So I see 2 options now, rewriting the code for filling all metadata fields by JavaScript or to save the info I need to keep.

The main limitation of the simple template seems to be that it cannot keep internal states because it's always reloaded.
But I can use the same IMatch objects in JavaScript that I can use in Apps.

I think I will go with the second option.

Walter

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 31580
Re: Apps with and without <app_type>app</app_type>
« Reply #3 on: March 01, 2016, 10:24:17 PM »
Quote
The main limitation of the simple template seems to be that it cannot keep internal states because it's always reloaded.

Precisely.
Saving internal states or anything via JavaScript requires an app.

The HTML templates are for cases where a user knows a bit about HTML and just wants to quickly create a custom metadata display. No programming required.

Check out the many apps included in IMatch to see how it works and to get some code for copy and paste. I added a lot of comments, to help users to write their first app with only a bit of effort.

scw2wi

  • Jr. Member
  • *
  • Posts: 71
Re: Apps with and without <app_type>app</app_type>
« Reply #4 on: March 02, 2016, 08:47:34 PM »
The example apps are very helpfull, I would say that my first app consists of 99% code copied from somewhere else.
Unfortunately I have never developed javascript apps before and without that many good examples it would be absolutely impossible for me.
Beside my error about not knowing the difference between templates and apps I am making more progress than I would have expected in that short time.
When I'm finished I will provide my app here, it might be usefull for others also.

Walter

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 31580
Re: Apps with and without <app_type>app</app_type>
« Reply #5 on: March 03, 2016, 08:56:17 AM »
Quote
The example apps are very helpfull, I would say that my first app consists of 99% code copied from somewhere else.

That's normal. When you start programming, you look at best practices and samples available on the net, and then use bits and pieces to create your own app.

sinus

  • Global Moderator
  • *****
  • Posts: 4707
  • IMatch-User since 2001 (IMatch 3.6)
Re: Apps with and without <app_type>app</app_type>
« Reply #6 on: March 03, 2016, 10:47:43 AM »
The example apps are very helpfull, I would say that my first app consists of 99% code copied from somewhere else.
Unfortunately I have never developed javascript apps before and without that many good examples it would be absolutely impossible for me.
Beside my error about not knowing the difference between templates and apps I am making more progress than I would have expected in that short time.
When I'm finished I will provide my app here, it might be usefull for others also.

Walter

Thanks, Walter, in advance.
It is always useful to see, how other does scripting, specially for beginners like me.
Best wishes from Switzerland! :-)
Markus

scw2wi

  • Jr. Member
  • *
  • Posts: 71
Re: Apps with and without <app_type>app</app_type>
« Reply #7 on: March 03, 2016, 09:25:45 PM »
Sinus, I'm sorry, in advance.
I am also a beginner ... but it is amazing,
for nearly every question I can find a solution in one of the app examples.

My app will mainly provide two features.
First is it a translation of the very good app "Collapsible Metadata Viewer II" from John Zeman
but replacing the Canon specific tags by Nikon tags.
Secondly will it provide a copy/paste feature of selected XMP-tags.

With IMatch it is only possible to copy all shown tags of the tag-panel,
but I wanted to copy only selected tags instead off all
and since it would take too long to configure reduced tag-panels just for copy/paste tasks
I had the idea to implement this feature in a dedicated app.
Copy/Paste is already working but the select feature is still missing,
and since I'm a beginner it takes time, but also makes fun.

Walter