Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Try pulling the config from the two possible locations
Browse files Browse the repository at this point in the history
@TrystanLea mentions that `config.js` has been renamed.

We'll use both names so the app works on multiple versions.

https://community.openenergymonitor.org/t/emoncms-v11-stable-release/19862/10
  • Loading branch information
MyForest authored Mar 4, 2022
1 parent ba0c625 commit 286ab37
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions mmspheatpump.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
?>

<link href="<?php echo $path; ?>Modules/app/Views/css/config.css?v=<?php echo $v; ?>" rel="stylesheet">
<link href="<?php echo $path; ?>Modules/app/Views/css/appconf.js?v=<?php echo $v; ?>" rel="stylesheet">
<link href="<?php echo $path; ?>Modules/app/Views/css/light.css?v=<?php echo $v; ?>" rel="stylesheet">

<script type="text/javascript" src="<?php echo $path; ?>Modules/app/Lib/config.js?v=<?php echo $v; ?>"></script>
Expand Down

4 comments on commit 286ab37

@MrTimbones
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erm... looks like you've mixed javascript with stylesheets. Did you mean to add appconf.js after line 11 instead?

@MyForest
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @MrTimbones

How does this grab you?

f461e17

@MrTimbones
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll do.

You could go one step further and check which file exists and only write out that one script:

<?php if (file_exists("Modules/app/Lib/appconf.js")) { ?>
<script type="text/javascript" src="<?php echo $path; ?>Modules/app/Lib/appconf.js?v=<?php echo $v; ?>"></script>
<?php } else { ?>
<script type="text/javascript" src="<?php echo $path; ?>Modules/app/Lib/config.js?v=<?php echo $v; ?>"></script>
<?php } ?>

Or, if you prefer something more concise: (merging php into preceding block)

<?php
    $configJs = file_exists("Modules/app/Lib/appconf.js") ? 'appconf.js' : 'config.js';
?>
...
<script type="text/javascript" src="<?php echo $path; ?>Modules/app/Lib/<?php echo $configJs; ?>?v=<?php echo $v; ?>"></script>

...but this is probably more trouble than it's worth.

@MyForest
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, without having something to test it with I'm mostly hoping that the scripts keep working with the older versions and every time I make it more complicated I know it's more likely to trip up.

I've had as much as 8 years support for old versions of my software at work and that's why they call it work :)

Please sign in to comment.