Оставлю для памяти – это только комменты к драфту запускателя яваскрипт-приложений – подгружает их, окна там переключает, состояния сохраняет. Запускатель работает по урлу в браузере, причём это всё синхронный реентерантный код, несколько сот строк.
//check url //parse url //combine 3+params if any into array //check lock, return state if unsolicited reenter //register only allowed if same app and same db //preconditions met? //############################ switch db //db accessible? //db ui container exists? //is db starters already loaded? //'preload' field processing, obsolete //loading templates if any //sorting and merging appkeys //loading apps //if app is not presented try to find it in acl'ed attaches //if still no app try to load it from public /app repo //check if loaded //render db main template //if no menubar for app, render it //render app methods list //############################ end switch db //############################ // appswitch //app exists? //if we have saved state //copy params //try to switch on default db app //no default app for db exists? //container exists? //init done? // end appswitch ############################ //############################ //Method exec //guess method to exec //only in there were no initialization //method exist? //try to find other method //we may have somth in app state //list? //update? //any functions at all? //if we found method and we were called to guess params – may be some are stored? //end method guess //method invoke //really need invocation? //remember all opened db/apps //show all appropriate divs //try to invoke //end invoke //end method exec ############################ //check if we have some params scheduled by reenterant calls //save states //hide prev state divs //recalc current state fields // SETS STATE finally ) //show divs //save states again //set app menu state //set db menu state //end up
UPD. Тут надо добавить, что на общую логику меня натолкнуло наблюдение за работой аэропорта.