autoEdit 2 Documentation
1.0.6
1.0.6
  • Introduction
  • Overview
    • Intro
      • High-level overview of the parts
      • from 1.0.5 to 1.0.6
      • Project folder structure
    • Support the project
  • Transcriptions
    • Transcriptions intro
    • Transcription json
    • Transcriber
      • audio to video
      • STT sdks
        • IBM Watson STT
        • Gentle STT
        • Pocketsphinx
    • Read metadata
    • Video preview conversion
    • Hypertranscript
  • Papercuts
    • Papercuts
      • Selections
      • Annotations
      • Tags
  • Paper-edit
    • Paper-edit
      • Paper-edit json
      • search-filter
      • drag-and-drop
      • video-preview
  • Export
    • Export
      • EDL export
      • XML export
  • Appendix
    • Dev configuration
    • Deployment/build
      • Deployment/build for Max OS X
      • Deployment / Build for Linux
      • Deployment / Build for Windows
    • Dependencies
    • Current db setup
    • EDL Format
    • Reusable components
    • Prerequisites
    • JQuery and NWJS Packaging
    • Roadmap
      • Paper-editing Roadmap
      • Extra Features Roadmap
      • Future Roadmap
        • Live video editing
        • Social Media Export
        • Translate transcriptions
        • Web app
          • Multi-user collaboration
        • Searchable Editable Archive
        • NLP insights
        • Slack/Chat bot integration
        • Interactive dev tool
        • Phone mms integration with twillio
        • B-roll computational photography
    • Paper-editing Roadmap
    • Testing
    • Updating automated documentation
    • History of autoEdit versions over time
    • ffmpeg and ffprobe in electron
  • Appendix - Data structures
    • IBM Watson json specs
    • Gentle Json transcription specs
    • Pocketsphinx results
    • autoEdit transcription Json
  • QA List
    • QA Intro
    • QA Launch App
    • QA Transcriptions
    • QA Paperedits
    • QA Export
  • Methods
    • Example: Defining Methods
  • Adobe Panel
    • autoEdit Adobe CEP Panel dev setup
    • autoEdit Adobe CEP Panel integration overview
    • Adobe CEP Jsx functions for autoEdit adobe Panel
Powered by GitBook
On this page
  1. Appendix

JQuery and NWJS Packaging

it seems like that you need to use libraries that require JQuery, such as bootstrap js or backnone.

if you just use standard html src

it might trigger an error saying that js is nto defined.

Solution is to include jquery using js and adding it to the dom, and use a callabck to add other library that need it as dependency once done.

Issue Jquery not loading in nwjs once is packaged for deployment and can’t figure out why.

For reproducing the issue,I boiled it down to a minimal repo

Download this repo [url coming soon]

npm start

you see "Added using jquery"

because in index.html there is

$("#main").html("Added using jquery")

if you do node deploy.js you see "Default html text"

which is the html in index, which mean jquery did not substitute the text in main

  <div id="main" class="container-fluid">
   <p>Default html text</p>
  </div><!-- container-fluid -->

if you look at the error in console in the packaged version

Uncaught ReferenceError: $ is not defined

is the main error.

Earlier solution, was bit of callback hell to make sure the script are loaded in the right order.

//loads scripts dynamically adding them to the body of the page
function loadExtScript(src, callback) {
  var s = document.createElement('script');
  s.src = src;
  document.body.appendChild(s);

  s.onload = function () {
    // if loaded...call the callback
    if(callback){callback(s)}
  }
}

/**
* To make sure scripts are deployed int he right order when NWJS is packaged, a little bit of callbacl hell.
*/
loadExtScript("vendor/jquery.min.js",function(script){
    //set jquery for bootstrap 
     window.jQuery = window.$ ;

     loadExtScript("vendor/bootstrap-3.3.6-dist/js/bootstrap.js",function(){

       loadExtScript("vendor/underscore-min.js",function(){
          loadExtScript("vendor/backbone-min.js",function(){
            //app.js backbone files 
           loadExtScript("js/models/transcription.js",function(){
               loadExtScript("js/collections/transcriptions.js",function(){
                 loadExtScript("js/views/transcription_index.js",function(){
                     loadExtScript("js/views/transcription_show.js",function(){
                        loadExtScript("js/views/transcription_form.js",function(){
                          loadExtScript("js/router.js",function(){
                               console.log("loaded stuff")
                          }) 
                        }) 
                    }) 
                  }) 
                })
            })
         })
      })
  })
})

--> UPDATE: Current solution as to 1.0.5 version is to use browserify to bundle the client side js together. This also ensures that they are loaded in the right order.

JQuery

jquery.min.1.12.4.js seems to hit the sweet spot between being compatible with NWJS, Bootstrap, and having the .find() that has been used in the client side and is not supported in previous versions.

PreviousPrerequisitesNextRoadmap

Last updated 6 years ago