Following the guide on managing javascript in Drupal 7 I added a "myjs.js" file in my sites/all/themes/mytheme/js folder, and included a line in the mytheme.info file (scripts[] = js/myjs.js). When I view page source on my site I can see the file is loaded.
Following a number of issues, I tried to back out of this. I removed the scripts[] line in the mytheme.info file, and deleted the js file from the js folder. So, theoretically, my drupal 7 site should have no knowledge of my custom js file, right?
Well, after numerous clearing of caches, hard reload of browser, even stop/restart my xampp server, whenever I view source on my site I see that file is still referenced as being loaded.
Must be a database thing? Where else would Drupal store and therefore persist my reference?
I also tried adding a new js file in the .info file (e.g., "js/newjs.js") and after clearing cache I never see the new file. Only the old, original file is there.
I'm using a bootstrap subtheme, and have checked both bootstrap.info and of course mytheme.info and there is NO reference to the myjs.js file anywhere.
This is exasperating. Any thoughts where I might look (database record, e.g.,).
THanks.
Found the problem. I'm using AMPP as localhost server. When I first set this up I installed the D7 on my D: drive...or so I thought. I'm not sure exactly how AMPP works but I found there is another installation on my C drive in the Systems folder. Therefore, I have two installs, and thought I was working on the D drive version all this time. Oddly, both of them are "almost" in synch....so at some point recently the D drive version was running, but now it's the C. I never did a restore so have no idea whether the C drive is/was a "clone" of the D drive install. Whatever. Feel so stooopid. I guess the key learning is when everything should be working but isn't, and if odd things are happening, look for the simple-stoopid things you might have done. Chris G was almost on point...I had uploaded the js and .info files, but to the D drive!
Related
Please read carefully before marking as dupe.
I want to read a javascript file on frontend. The javascript file is obviously being used as a script on the webpage. I want to read that javascript file as text, and verify if correct version of it is being loaded in the browser. From different chunks of text in the js file, I can identify what version is actually being used in the end user's browser. The js file is main.js which is generated by angular build.
I know we can do something like creating a global variable for version or some mature version management. But currently, on production site, that will mean a new release, which is couple of months from now. Only option I have right now is html/js page, which can be directly served from production site, without waiting for new release.
So my question is, is it possible we can read a javascript file as text in hmtl/js code in the browser.
an idea can be :
use fetch api to get a container that can be use to async load the script
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
use text() method which return a promise to get text content
fetch('http://localhost:8100/scripts.js').then((res) => res.text()).then(scriptContent => {
// scriptContent contain the content of your script
// if (scriptContent.includes('version : 1.1.1')
console.log(scriptContent);
});
this is absolutely not an efficient way, but since you want to work without any new version release or working with a version management system
here is the thing
assume file's checksum (md5 sha125 or anything) of V1.0 equals X and you will calculate before the coding part.
if checksum(X) != X{
location.reload()
}
would help for a security features too since it's an important project.
another way of controlling this situation is changing the main.js file's name if it is possible.
I included a lot of background information to help you answer this question, however you can skip down to the heading called 'Questions' to skip to the main point.
Background
I'm new to using Cordova, and I'm new to an existing Cordova project I want to further develop. As a result, when I look at the project files, I am not sure what are choices made by the previous developers and what are choices made automatically by Cordova. I suspect that Cordova generates a lot of files that are not created by the application developers because in my case there are over 7900 files including source code and README's, and the application was previously (to my knowledge at least) developed by only one person.
While many questions could be asked from that perspective, I would like to narrow in on a specific question to avoid being too broad. I've noted that are many files within the path structure called index.js.
$ find . -name "index.js"
./platforms/android/app/build/intermediates/assets/debug/www/js/index.js
./platforms/android/app/src/main/assets/www/js/index.js
./platforms/android/cordova/node_modules/balanced-match/index.js
./platforms/android/cordova/node_modules/os-tmpdir/index.js
./platforms/android/cordova/node_modules/concat-map/index.js
./platforms/android/cordova/node_modules/properties-parser/index.js
./platforms/android/cordova/node_modules/elementtree/lib/parsers/index.js
./platforms/android/cordova/node_modules/os-homedir/index.js
./platforms/android/cordova/node_modules/xmlbuilder/lib/index.js
./platforms/android/cordova/node_modules/ansi/examples/beep/index.js
./platforms/android/cordova/node_modules/ansi/examples/progress/index.js
./platforms/android/cordova/node_modules/ansi/examples/clear/index.js
./platforms/android/cordova/node_modules/path-is-absolute/index.js
./platforms/android/cordova/node_modules/brace-expansion/index.js
./platforms/android/cordova/node_modules/sax/test/index.js
./platforms/android/cordova/node_modules/android-versions/index.js
./platforms/android/cordova/node_modules/lodash/index.js
./platforms/android/cordova/node_modules/cordova-registry-mapper/index.js
./www/js/index.js
./node_modules/objectorarray/index.js
./node_modules/es-abstract/index.js
./node_modules/es-abstract/test/index.js
./node_modules/isexe/index.js
./node_modules/balanced-match/index.js
./node_modules/object-keys/index.js
./node_modules/object-keys/test/index.js
./node_modules/has/src/index.js
./node_modules/has/test/index.js
./node_modules/semver/test/index.js
./node_modules/string.prototype.trim/index.js
./node_modules/string.prototype.trim/test/index.js
./node_modules/cordova-plugin-file/src/blackberry10/index.js
./node_modules/jsonfile/index.js
./node_modules/fs-extra/lib/ensure/index.js
./node_modules/fs-extra/lib/remove/index.js
./node_modules/fs-extra/lib/move/index.js
./node_modules/fs-extra/lib/output/index.js
./node_modules/fs-extra/lib/copy-sync/index.js
./node_modules/fs-extra/lib/fs/index.js
./node_modules/fs-extra/lib/empty/index.js
./node_modules/fs-extra/lib/index.js
./node_modules/fs-extra/lib/path-exists/index.js
./node_modules/fs-extra/lib/copy/index.js
./node_modules/fs-extra/lib/move-sync/index.js
./node_modules/fs-extra/lib/json/index.js
./node_modules/fs-extra/lib/mkdirs/index.js
./node_modules/concat-map/index.js
./node_modules/elementtree/lib/parsers/index.js
./node_modules/fs.realpath/index.js
./node_modules/plist/index.js
./node_modules/path-key/index.js
./node_modules/xmlbuilder/lib/index.js
./node_modules/ansi/examples/beep/index.js
./node_modules/ansi/examples/progress/index.js
./node_modules/ansi/examples/clear/index.js
./node_modules/cordova-android/node_modules/balanced-match/index.js
./node_modules/cordova-android/node_modules/os-tmpdir/index.js
./node_modules/cordova-android/node_modules/concat-map/index.js
./node_modules/cordova-android/node_modules/properties-parser/index.js
./node_modules/cordova-android/node_modules/elementtree/lib/parsers/index.js
./node_modules/cordova-android/node_modules/os-homedir/index.js
./node_modules/cordova-android/node_modules/xmlbuilder/lib/index.js
./node_modules/cordova-android/node_modules/ansi/examples/beep/index.js
./node_modules/cordova-android/node_modules/ansi/examples/progress/index.js
./node_modules/cordova-android/node_modules/ansi/examples/clear/index.js
./node_modules/cordova-android/node_modules/path-is-absolute/index.js
./node_modules/cordova-android/node_modules/brace-expansion/index.js
./node_modules/cordova-android/node_modules/sax/test/index.js
./node_modules/cordova-android/node_modules/android-versions/index.js
./node_modules/cordova-android/node_modules/lodash/index.js
./node_modules/cordova-android/node_modules/cordova-registry-mapper/index.js
./node_modules/cordova-android/bin/templates/project/assets/www/js/index.js
./node_modules/for-each/index.js
./node_modules/tape/index.js
./node_modules/path-is-absolute/index.js
./node_modules/brace-expansion/index.js
./node_modules/deep-equal/index.js
./node_modules/has-symbols/index.js
./node_modules/has-symbols/test/index.js
./node_modules/shebang-regex/index.js
./node_modules/is-callable/index.js
./node_modules/through/index.js
./node_modules/through/test/index.js
./node_modules/resumer/index.js
./node_modules/resolve/index.js
./node_modules/resolve/test/resolver/dot_main/index.js
./node_modules/resolve/test/resolver/multirepo/packages/package-b/index.js
./node_modules/resolve/test/resolver/multirepo/packages/package-a/index.js
./node_modules/resolve/test/resolver/quux/foo/index.js
./node_modules/resolve/test/resolver/incorrect_main/index.js
./node_modules/resolve/test/resolver/same_names/foo/index.js
./node_modules/resolve/test/resolver/dot_slash_main/index.js
./node_modules/resolve/test/shadowed_core/node_modules/util/index.js
./node_modules/resolve/test/node_path/x/ccc/index.js
./node_modules/resolve/test/node_path/x/aaa/index.js
./node_modules/resolve/test/node_path/y/ccc/index.js
./node_modules/resolve/test/node_path/y/bbb/index.js
./node_modules/resolve/test/module_dir/ymodules/aaa/index.js
./node_modules/resolve/test/module_dir/xmodules/aaa/index.js
./node_modules/resolve/test/precedence/aaa/index.js
./node_modules/resolve/test/dotdot/abc/index.js
./node_modules/resolve/test/dotdot/index.js
./node_modules/function-bind/index.js
./node_modules/function-bind/test/index.js
./node_modules/shebang-command/index.js
./node_modules/minimist/index.js
./node_modules/cordova-plugin-network-information/src/blackberry10/index.js
./node_modules/cross-spawn/index.js
./node_modules/es-to-primitive/index.js
./node_modules/es-to-primitive/test/index.js
./node_modules/strip-bom/index.js
./node_modules/is-date-object/index.js
./node_modules/path-parse/index.js
./node_modules/is-symbol/index.js
./node_modules/is-symbol/test/index.js
./node_modules/base64-js/index.js
./node_modules/node-version-compare/index.js
./node_modules/node-version-compare/test/index.js
./node_modules/universalify/index.js
./node_modules/define-properties/index.js
./node_modules/define-properties/test/index.js
./node_modules/nice-try/src/index.js
./node_modules/defined/index.js
./node_modules/object-inspect/index.js
./node_modules/is-regex/index.js
./plugins/cordova-plugin-file/src/blackberry10/index.js
./plugins/cordova-plugin-network-information/src/blackberry10/index.js
It would be extremely broad and impractical to question what each and every one of these identically-named files are for, and some may be inanswerable if their existence depends on design choices of the previous developers of this project. Fortunately, I can be more specific than that. I have an issue to debug, and with a specific search string related to the bug, I was able to find that specific files named index.js contained that string.
$ grep -ril "<search_string>" .
./platforms/android/app/build/intermediates/assets/debug/www/js/index.js
./platforms/android/app/src/main/assets/www/js/index.js
./www/js/index.js
And to clarify further, while not being the only files returned by grep, these three index.js files were the only files that appeared to be relevant to my bug. I then used cmp to compare these three files, and I found that they're mutually identical (not shown since cmp by default only prints output when there is a difference).
There seems to be some confusion about the importance of ./www/js/index.js, but it also seems to be the case that I should prefer to edit ./www/js/index.js rather than ./platforms/android/app/src/main/assets/www/js/index.js because ./platforms/android/app/src/main/assets/www/js/index.js is automatically generated by Cordova according to this post. This suggest that ./www/js/index.js is not automatically generated, although this still leaves open whether ./platforms/android/app/build/intermediates/assets/debug/www/js/index.js is automatically generated. Given that build is in the path of ./platforms/android/app/build/intermediates/assets/debug/www/js/index.js, I suspect that this is a file automatically generated when the command cordova build android is run. This leads me to the suspicion that I should edit ./www/js/index.js and not the other two of these three files.
Questions
I'm really asking 3 questions in one post, however since their scope and background are nearly identical I would prefer to keep them together for context.
Which of the three index.js should be edited in developing an application with Cordova?
./platforms/android/app/build/intermediates/assets/debug/www/js/index.js
./platforms/android/app/src/main/assets/www/js/index.js
./www/js/index.js
The three index.js files mentioned in Question 1 are identical. Why do each of these identical copies exist?
There are non-identical files named index.js in a Cordova project. Why are they all called the same name if they are non-identical in content?
You should edit /www/js/index.js.
The other two files are created during the build process. A built Cordova app will have all www folder contents inside an android app structure, that's why they are inside /platforms/android/app/src/main/
The other index.js files are there because it's a Node.js pattern
I am working to edit the month view of "The Events Calendar" in Wordpress. I cannot seem to figure out which files contain the relevant markup. The file structure seems to make sense, however, when I edit anything with /month no changes reflect.
The File Structure
Core Plugin Files
.../plugins/the-events-calendar/src/views/
Here we have several folders with the different views. One of which is "month" and, according to the documentation, contains the files I wish to edit.
Theme Files
.../mytheme/tribe-events/
This is the folder the documentation told me to create to place edited templates in.
The Fubar
When i follow the documentation for editing a single event located in /list everything works as expected. All I need to do is create a subfolder in mytheme/tribe-events/list and put a new file within to override the original.
When I repeat these same steps in order to edit a file within /month view things are different. For some reason none of my changes work. Outside of the /month folder in /views there is a month.php file which contains the following...
do_action( 'tribe_events_before_template' );
// Title Bar
tribe_get_template_part( 'month/title-bar' );
// Tribe Bar
tribe_get_template_part( 'modules/bar' );
// - My Custom Code -
write_log('This Log Works');
// Main Events Content
tribe_get_template_part( 'month/content' );
do_action( 'tribe_events_after_template' );
Note: write_log() is a function I use in php for debugging. It's essentially a console.log but appends the data to the end of the error.log file which i have being read by a terminal. I do not believe the issue is with this function as I have tested other methods.
The "month" file echoes my log just fine. However, when I add the same log into any of the files it is pulling from the 'month/' directory I get nothing. I went through every file in the subdirectories and added a log and realized that they all work except any file within /month
I thought maybe the issue was with the plugins' "tribe_get_template_part()" function pointing to the wrong place so I decided to eliminate the "am i making this child plugin right" variables and just start editing the plugin files directly. But I get the exact same behavior. I got so desperate that I deleted the entire /months folder from the plugin and the calendar still worked!
So obviously I am really missing something but currently I am at a loss.
This documentation is what I've been following to figure this out.
https://support.theeventscalendar.com/153124-Themers-Guide
The only thing I can think of at this point is that the javascript templating system built into the plugin is working some hidden magic but the fact that I can delete the entire months folder leaves me at a loss.
For anyone struggling with this still, I also had the same issue and solved it by disabling the Month View Cache under Event Settings > Display. Screenshot:
So i am making a mobile app. in this app, on my main screen, i have a button that when clicked it will load another frame, or js file. this i know how to do but when pressing the button it gives me an error, "cant find file". after 3 hours of web searching i have tried changing the path names to every possible combination and moveing the file around. after doing so i came to realize that next to the new file i created, or any new file i create, there is an "*" and a question mark. for example if i make a new file called login.js it will show up on the explorer window as *?login.js, where the question mark is much smaller symbol. Is there a manifest i must add it to, like in netbeans, because it seems as if there is an error in the file but it is empty.
function signup(e){
var menu = Ti.UI.createWindow({
url: 'Main-Menu.js'
});
menu.open();
}
i also did: Titanium.include('/controllers/Main-Menu.js');
but always getting the same error, the JS file is in my apps controller folder.
This *? indication comes from the git plugin that is shipped with Titanium Studio. It indicates that the file is not commited.
To answer your "can't find file" - question, I need to know some more details about your environment (target platform, sdk version, example code, ...)
I'm currently stumped about a problem I'm facing where I can't reference functions and variables from one JavaScript file to the next. I've tried adding all of the JavaScript files as a library in File->Settings->JavaScript->Libraries but with no success - I still get the gray underline for references with, for instance, a hover-over message that reads "Unresolved function or method ".
The strange thing is if I move a copy of the JavaScript files outside of the subversioned project directory and then add that project-external reference to File->Settings->JavaScript->Libraries then the references are found but this solution is not satisfactory because these JavaScript files are updated via subversioning daily (we're in development)
Does anybody have any insight to my problem? If I am not going about this the right way then let me know. What I ultimately want to be able to do is reference variables and functions from specfic JavaScript files across all my JavaScript files so that I can easily follow references (ctrl+leftclick) to insure the parts are fitting together properly.
Thanks!
(P.S. I'm using PyCharm 2.5)