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

current root path predefined variable #202

Closed
cordovapolymer opened this issue Aug 24, 2016 · 4 comments
Closed

current root path predefined variable #202

cordovapolymer opened this issue Aug 24, 2016 · 4 comments

Comments

@cordovapolymer
Copy link

cordovapolymer commented Aug 24, 2016

It would be great to have a predefined variable with current application root path, so it can be used for loading assets with javascript, like cordova plugin file does.
This #170 pull request introduces a method to get current version name, it would be nice if you could extend it.

@cordovapolymer cordovapolymer changed the title current run path predefined variable current root path predefined variable Aug 24, 2016
@cordovapolymer
Copy link
Author

cordovapolymer commented Aug 25, 2016

Here is the solution which I'm currently using:

          function absScriptLoc(filename) {
            var scriptElements = document.getElementsByTagName('script');
            for (var i = 0; i < scriptElements.length; i++) {
              var source = scriptElements[i].src;
              if (source.indexOf(filename) > -1) {
                var location = source.substring(0, source.indexOf(filename)) + filename;
                return location;
              }
            }
            return false;
          }
          var myAbsScriptLoc = absScriptLoc('chcp.js');
          var myAbsRootPath = myAbsScriptLoc.replace("plugins/cordova-hot-code-push-plugin/www/chcp.js", "");  ```

@nikDemyankov
Copy link
Member

Thanks for the suggestion! Have you tried to load assets by relative path instead of full path? Also, if assets are not in manifest - I think you can load them from the bundled assets.

@cordovapolymer
Copy link
Author

Thanks for the suggestion! Have you tried to load assets by relative path instead of full path?

yes, I tried everything!

Also, if assets are not in manifest - I think you can load them from the bundled assets.

They are in manifest as I'm currently updating whole app with chcp. I think I will use your suggestion to bundle most of the assets in future, to save space, thanks.

@nordnet-deprecation-bot
Copy link
Contributor

👋 Hi! Thank you for your interest in this repo.

😢 We are not using nordnet/cordova-hot-code-push anymore, and we lack the manpower and the experience needed to maintain it. We are aware of the inconveniece that this may cause you. Feel free to use it as is, or create your own fork.

🔒 This will now be closed & locked.

ℹ️ Please see #371 for more information.

@nordnet nordnet locked and limited conversation to collaborators Sep 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants