js/main.js
author Mahlon E. Smith <mahlon@martini.nu>
Mon, 09 Feb 2015 09:20:01 -0800
changeset 0 52d30e6014a0
permissions -rw-r--r--
Initial commit. Experimental cross-platform frontend for yubikey programming.


var Y = global.Y;

// Main behavior.
//
$( window ).ready( function() {
	Y.window.main = Y.gui.Window.get();
	setupWindowEvents();

	$( 'button.info' ).click(function() {
		Y.yubiexec( 'ykinfo', ['-a'] );
   	});

	$( 'button.console' ).click(function() {
		Y.window.main.showDevTools();
   	});

	Y.callback( 'ykinfo' ).add( function() {
		$( '.version' ).html( Y.keyinfo.version );
		$( '.serial' ).html( Y.keyinfo.serial );
		$( '.programming_sequence' ).html( Y.keyinfo.programming_sequence );
		$( '.slot1' ).html( Y.keyinfo.slot1_status ? 'Configured' : 'Clear' );
		$( '.slot2' ).html( 'Clear' );
	});

	Y.callback( 'ykinfo-error' ).add( function(data) {
		$( '#info' ).html( data.toString() );
	});
});


// Default event actions for the main window.
//
var setupWindowEvents = function() {
	// Shut down the application if the main window is closed.
	Y.window.main.on( 'closed', function() { process.exit() });
	Y.disableDragDrop( window );
};