Jump to content

How to recompile javascript.xml?


AtariAge

Recommended Posts

I have a new forum running 4.3.5.  After having run 3.x on another site forever, everything is different!  When you click on the "Mark forum as read" icon next to a forum, on mobile devices it displays a popup to confirm this is what you want to do, and on desktop views it simply marks the forum as read.  Given these icons look identical to the icons displayed next to topics in a forum, yet behave in a COMPLETELY DIFFERENT fashion, I've had several people ask me why the hell the forum icon marks a forum as read, while in the topics view it brings you to the first unread post.  I have to agree.  

So, to help people not accidentally mark a forum as read, I want to display the same confirmation popup that is shown to mobile users.  I found the following code in /applications/core/data/javascript.xml in the function "markAsRead": 

			if( ips.utils.events.isTouchDevice() ) {
				ips.ui.alert.show( {
					type: 'confirm',
					icon: 'question',
					message: ips.getString('notificationMarkAsRead'),
					callbacks: {
						ok: function () {
							execMark();
						}
					}
				});
			} else {
				execMark();
			} 

This is obviously easy enough to change, but I do not know how to force this file to compile so the changes are updated wherever it's storing the compiled versions (appears to be in the /uploads directory, but I've also seen people mention they are stored in the database).  Can someone point me in the right direction to get changes to this file reflected on the live site? 

Thanks!

 ..Al

Link to comment
Share on other sites

10 hours ago, MIXOH said:

DB table core_javascript. But when you upgrade IPS this change may be lost

Yeah, that's not an ideal solution since it'll certainly be clobbered when I upgrade the software.  But good to know that's where it's stored, and I'll take a peek in there.  😄 Still would like to know how to know how to rebuild these XML files.  

9 hours ago, Stuart Silvester said:

The correct solution for changing something in an existing controller would be to use Mixins.

Thanks, Stuart!  Very interesting how extensible version 4.x of the software is.  I have quite a bit to learn, especially as there's various things I want to write once I get my main forum on 4.x (still on 3.4.x).  

I looked at the link you provided, and it's not clear to me where these "Mixins" files need to go and how to get the system to recognize them once you've put them wherever they need to go.  Do I need to have a board setup in development mode to do this?  I haven't done that yet for this forum. 

Thanks, 

 ..Al

Link to comment
Share on other sites

18 minutes ago, AtariAge said:

Still would like to know how to know how to rebuild these XML files.

This is not necessary, xml files are created during installation / update, the content (in particular js) is placed in the database, in the future the information from the database is additionally cached in datastore. Thus, even removal does not affect anything :smile:

Link to comment
Share on other sites

56 minutes ago, AtariAge said:

I looked at the link you provided, and it's not clear to me where these "Mixins" files need to go and how to get the system to recognize them once you've put them wherever they need to go.  Do I need to have a board setup in development mode to do this?  I haven't done that yet for this forum. 

You would include the mixins with a plugin you develop

(also see 'adding resources' in the menu)

I would recommend setting up a development install locally for writing your plugin. Don't use developer mode on your live site.

Link to comment
Share on other sites

Thanks again Stuart.  Yeah, I definitely would not setup developer mode on a live site.  Since it's a new forum (and thus small database and not many attachments/images yet), it'll be easy for me to setup a local development forum.  Didn't realize I would need to develop this as part of a plugin, that makes it a bit more complex.  Again, much learning to do. 

 ..Al

Link to comment
Share on other sites

As Stuart mentioned, the best route to go is...

1) Create a plugin. It doesn't have to necessarily do anything, but it will be a container for your custom javascript.
2) Add your mixin javascript file in the plugin (the documentation shows the appropriate location)
3) Then just install your plugin on your site when you're done and it will be retained during upgrades without having to worry about losing your changes

An alternative route would be to write the mixin and place it anywhere in your webspace, then add the appropriate <script> tag in your theme templates to load the javascript file. If you use the mixin autoloading functionality, you don't really need to do anything else, otherwise you can also optionally edit other templates to define when the mixin should be loaded with the controller (this is outlined in the mixin documentation).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...