Reduce JavaScript function duplication and collect file groups into subfolders
I'd like to reduce the duplication of the same JavaScript in multiple files.
I'd also like to create some sub-folders within js
to group together code for different things.
Comments (19)
-
reporter -
Hi @dplatten - is there going to be any more work on this issue for 0.8.0? Is it complete, or should it be pushed to the next version?
-
reporter I've tried to use Pycharm's refactor function to move JavaScript files into subfolders, such as "charts" and "skin-dose-map", but unfortunately this process doesn't update the paths in the associated templates. I'm not sure why. Unless someone knows of a way to easily do this I think we should park this for the next release, as I don't want to manually update each reference to the JavaScript files if I move them.
-
Works for me. I'll have a go and you can see what you think.
-
Attempt at moving the charts related javascript files into subfolder. Refs
#536→ <<cset 0f67cd7af36b>>
-
I think that works, although having pushed a copy to testing one of the charts that happened to be selected doesn't seem to be returning. This search/these charts don't return the study frequency pie chart.
It does come up with this error in the console:
Uncaught TypeError: Cannot read property '0' of null at sortByName (http://testing.openrem.org/static/js/sorting.js:10:22) at Array.sort (native) at updateFrequencyChart (http://testing.openrem.org/static/js/charts/chartUpdateData.js:145:18) at Object.success (http://testing.openrem.org/static/js/ctChartAjax.js:81:17) at j (http://testing.openrem.org/static/js/jquery-1.11.0.min.js:2:27136) at Object.fireWith [as resolveWith] (http://testing.openrem.org/static/js/jquery-1.11.0.min.js:2:27949) at x (http://testing.openrem.org/static/js/jquery-1.11.0.min.js:4:22244) at XMLHttpRequest.b (http://testing.openrem.org/static/js/jquery-1.11.0.min.js:4:26298) sortByName @ sorting.js:10 updateFrequencyChart @ chartUpdateData.js:145 success @ ctChartAjax.js:81 j @ jquery-1.11.0.min.js:2 fireWith @ jquery-1.11.0.min.js:2 x @ jquery-1.11.0.min.js:4 b @ jquery-1.11.0.min.js:4 XMLHttpRequest.send (async) send @ jquery-1.11.0.min.js:4 ajax @ jquery-1.11.0.min.js:4 (anonymous) @ ctChartAjax.js:15 j @ jquery-1.11.0.min.js:2 fireWith @ jquery-1.11.0.min.js:2 ready @ jquery-1.11.0.min.js:2 K @ jquery-1.11.0.min.js:2
I don't know if this is related to moving the files. I suspect not?
-
You can see what was changed here: https://bitbucket.org/openrem/openrem/branch/issue536movejavascript#diff
-
reporter @edmcdonagh thanks for this. The pie chart works for me (after a SHIFT+F5 to force a complete re-load).
-
reporter I was also going to put the skin dose map JavaScript into its own folder...
-
Good. If you have time, I did it as follows. Otherwise I'll try and do it tonight.
- opened each of the files to be moved
- In the cookie trail style file path bit at the top, right click, refactor, move.
- added
/charts
to the path
It would probably work if you right click on the file in project structure view or what ever is called.
-
reporter OK - will do. It seems to work for me in Pycharm at home, but not on my version at work.
-
reporter -
Is this ready to be merged in @dplatten?
-
reporter I just wondered if a couple more JavaScript files could be deleted? npm.js, response.min.js and respond.min.js. I don't know what they're for.
-
They are bootstrap files. I think they relate to making it look ok-ish on older IE browsers.
-
I'm going to merge it in for now. Do you want it closed or not? My preference would be to close it and create another for any more js improvements.
-
Merged in issue536movejavascript (pull request #156)
Issue536movejavascript
Refs
#536but not closed pending @dplatten's judgement→ <<cset db15be5cf1b1>>
-
reporter - changed status to resolved
-
Added ref
#536to changes→ <<cset 50e12bb67bd5>>
- Log in to comment
Changed CT filtered page to only show
Hide
,Show
andToggle
series buttons if there is more than one series on the chart. Also implemented code so that only one of theHide all
orShow all
buttons is showing at any one time. Also moved a couple of duplicate JavaScript functions to a file. References issue#537and#536→ <<cset d91da62cbabf>>