Reduce JavaScript function duplication and collect file groups into subfolders

Issue #536 resolved
David Platten
created an issue

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)

  1. David Platten reporter

    Changed CT filtered page to only show Hide, Show and Toggle series buttons if there is more than one series on the chart. Also implemented code so that only one of the Hide all or Show all buttons is showing at any one time. Also moved a couple of duplicate JavaScript functions to a file. References issue #537 and #536

    → <<cset d91da62cbabf>>

  2. David Platten 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.

  3. Ed McDonagh

    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?

  4. Ed McDonagh

    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.

  5. Log in to comment