Skip to content

Javscript

Siqi Tian edited this page Jul 3, 2016 · 1 revision

media/js/ Contains Javascript files.

File Description
*.min.js Vendor libraries (Bootstrap, jQuery, fullcalendar, Moment, Head.load).
suit/ Vendor of django-suit scripts. Only *.min.js are used.

public/ Public Javascript files.

File Description
ga.js Local copy of Google Analytics script.
load.js Loads vendor libraries using CDN, or fallback to local files. Similar to media/js/admin/load.js.
menu.js Main script for the public pages, switching page without reloading. Works in similar way as media/js/admin/menu.js.

group/ Group Javascript files.

File Description
gapi.js Uses gviz-api.py. Makes AJAX calls to /group/dash/, which passes through src/views.py to dash() in src/dash.py. Data is retrieved from cache/. For /group/aws/ and /group/git/, it renders the HTML backbone first, then query data for each entry.
home.js Makes AJAX calls to /group/dash/schedule/, which passes to schedule_dash() in src/views.py for recent events. Also retrieves Slack presence via /group/dash/slack/.
load.js Loads vendor libraries using CDN, or fallback to local files. Similar to media/js/admin/load.js.
menu.js Main script for the group app, switching page without reloading. Works in similar way as media/js/admin/menu.js.
email.js, upload.js Handles POST calls for member email to admin and upload archive presentations. Makes AJAX to /group/email_admin/ and /group/archive/upload/, which passes to user_email() and user_upload() in src/views.py.

admin/ Admin Javascript files.

File Description
_*.js Vendor libraries for django-suit and django-filemanager.
apache.js Makes AJAX calls to /admin/stat/apache/, which passes through src/admin.py to restyle_apache() in src/console.py. The page refreshes every 3 seconds by setTimeout().
clock.js Displays real-time clock on navigation bar.
doc.js Used by /admin/man/ and /admin/ref/ pages for scrollSpy side-bar resizing according to window.width().
gapi.js Uses gviz-api.py (not Google Analytics API) for /admin/aws/, /admin/ga/, and /admin/git/ page dashboard. Makes AJAX calls to /admin/stat/(aws
group.js Used by /admin/auth/user/ page to render config/group.conf on the page. Makes AJAX calls to /admin/dash/group/, which passes to get_dash() in src/admin.py.
home.js Makes AJAX calls to /admin/stat/sys/, /admin/stat/backup/ and /admin/stat/ver/. Additionally, makes AJAX calls to /admin/backup/form/, which passes through src/admin.py to get_backup_form() in src/console.py; and /admin/dash/dash/, which passes to get_dash() in src/admin.py.
load.js Loads vendor libraries using CDN, or fallback to local files. Uses head.load library. It checks jQuery availability from https://cdnjs.com/ first, and decides CDN availability and saves to app.isCDN. Uses head.test() to dynamically load all Javascript dependencies.All Javascript files should be loaded from here, i.e. no more <script> tag in HTML!
menu.js Main script for the admin app, switching page without reloading.
app.fnOnLoad initiates the view with animation;
app.fnNavCollapse controls navigation bar behavior on resize;
app.fnChangeLocation updates the app.href and reloads the page content (excluding navigation). Calls app.fnChangeView;
app.fnChangeView updates side navigation highlighting, calls app.fnParseLocation and app.fnChangeBreadcrumb, runs page.js for new content, and calls app.callbackChangeView if defined;
app.fnChangeBreadcrumb updates breadcrumb banner for each page;
app.fnParseLocation figures out the current page path and stores to app.key and app.page.
Note that the window.resize() methods use setTimeout() to prevent overlapping trigger of the event that results in delay in updating the view.
page.js Formats menu (sidebar, navbar, breadcrumb, highlighting, collapsing), and Date/Time <input> for admin pages. Loads required additional <script> for pages. Called by menu.js.
table.js Injection of Javascript to format table (column width and icon for <th>).
util.js Used by /admin/backup/, /admin/bot/, and /admin/export/ pages. Makes AJAX calls to /admin/stat/backup/ and /admin/stat/ver/, which passes to get_ver() in src/admin.py. Controls page behavior and responses.

Clone this wiki locally