text:
package android.support.database.sqlite;

import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.database.Session;
import android.support.database.core.SQLiteSession;
import android.support.database.util.TableUtils;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by yexiaokang on 2017/8/17.
 */

public abstract class AnnotationSQLiteHelper extends SQLiteOpenHelper {

    private Class<?>[] mClasses;
    private Session mSession;
    private final Lock mLock = new ReentrantLock();

    public AnnotationSQLiteHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version,
                                  Class<?>[] classes) {
        super(context, name, factory, version);
        mClasses = classes;
    }

    public AnnotationSQLiteHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version,
                                  DatabaseErrorHandler errorHandler, Class<?>[] classes) {
        super(context, name, factory, version, errorHandler);
        mClasses = classes;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        TableUtils.createTables(db, mClasses);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

    @Override
    public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        TableUtils.dropTables(db, mClasses);
    }

    public Session getSession() {
        final Lock lock = this.mLock;
        lock.lock();
        try {
            if (mSession == null) {
                mSession = new SQLiteSession(this);
            }
            return mSession;
        } finally {
            lock.unlock();
        }
    }

    protected final void debug(Class<?>[] classes) {
        TableUtils.createTables(null, classes);
    }
}


text:
/*globals showDriverDetailsPanel showDriverAprroveRejectPanel msgObj*/
/* global new_block,formatDate, randStr, bag, $, clear_blocks, document, WebSocket, escapeHtml, window , testing*/

//part1.js
var ws = {};
var bgcolors = ["whitebg", "blackbg", "redbg", "greenbg", "bluebg", "purplebg", "pinkbg", "orangebg", "yellowbg"];

// =================================================================================
// On Load
// =================================================================================
$(document).on("ready", function() {
	connect_to_server();
	$("input[name=\"name\"]").val("r" + randStr(6));

	// =================================================================================
	// jQuery UI Events
	// =================================================================================
	$("#submit").click(function(){
		console.log("creating marble");
		var obj = 	{
						type: "create",
						name: $("input[name=\"name\"]").val().replace(" ", ""),
						color: $(".colorSelected").attr("color"),
						size: $("select[name=\"size\"]").val(),
						user: $("select[name=\"user\"]").val(),
						v: 1
					};
		if(obj.user && obj.name && obj.color){
			console.log("creating marble, sending", obj);
			ws.send(JSON.stringify(obj));
			showHomePanel();
			$(".colorValue").html("Color");											//reset
			for(var i in bgcolors) $(".createball").removeClass(bgcolors[i]);		//reset
			$(".createball").css("border", "2px dashed #fff");						//reset
		}
			return false;
		});

	$("#loginuser").click(function(){
		console.log('Inside login user click');
		var obj = 	{
						type: 'loginuser',
						loginusername: $("input[name=\"loginusername\"]").val().replace(" ", ""),
						loginpassword: $("input[name=\"loginpassword\"]").val().replace(" ", ""),
						v: 1
					};
	if(obj.loginusername && obj.loginpassword){
			console.log('sending login details for validation', obj);
			ws.send(JSON.stringify(obj));
			console.log('login details sent to ws for validation', obj);
//			showHomePanel();
//			$('.colorValue').html('Color');											//reset
//			for(var i in bgcolors) $('.createball').removeClass(bgcolors[i]);		//reset
//			$('.createball').css('border', '2px dashed #fff');						//reset
		}
//		$("#signupPanel").fadeIn(300);
//		$("#loginuserPanel").hide();

//		var driverlistobj = 	{
//				type: "listdriver",
//				v: 1
//			};
//
//		console.log("listing drivers, sending", driverlistobj);
//		ws.send(JSON.stringify(driverlistobj));
//		function onMessage(msg){
//		try{
//			var msgObj = JSON.parse(msg.data);
//
//			if(msgObj.msg === "driverslist"){
//				console.log("Status", msgObj.eachdriver.status);
//				if(msgObj.eachdriver.status == "P"){
//				build_driver(msgObj.eachdriver);
//			}
//
//			}
//
//		}
//		catch(e){
//			console.log("ERROR", e);
//			}
//
//	}
//
//		$("#driverdetailsPanel").hide();
//		showDriverPendingListPanel();
//		$("#loginuserPanel").hide();
//}
//	else {
//	 	console.log("checking up driver logging-1");
//		var checkdriverobj = {
//					type: "checkdriverdetails",
//						checkdriveremail: $("input[name=\"username\"]").val().replace(" ", ""),
//						v: 1
//					};
////		if(obj.user && obj.name && obj.color){
//			console.log("doing sign up, sending", checkdriverobj);
//			ws.send(JSON.stringify(checkdriverobj));
//
//			function onMessage(msg){
//		try{
//			var msgObj = JSON.parse(msg.data);
//
//			if(msgObj.msg === "driver"){
//				console.log("rec", msgObj.msg, msgObj.driver);
//				//build_ball(msgObj.marble);
//				$("input[name=\"driverdetailsemail\"]").val(msgObj.driver.email);
//				$("input[name=\"driverdetailspassword\"]").val(msgObj.driver.password);
//				//showDriverDetailsPanel();
//			}
//		}
//
//	catch(e){
//			console.log("ERROR", e);
//
//			}
//		}
//
//
//			console.log("checking up driver logging");
//			console.log("obj.username", obj.username);
//	 		console.log("msgObj.driver.email" ,msgObj.driver.email);
//	 		console.log("obj.password", obj.password);
//	 		console.log("msgObj.password" ,msgObj.driver.password);
//			if (obj.username === msgObj.driver.email && obj.password === msgObj.driver.password) {
//				$("input[name=\"userrole\"]").val("Driver Logged In");
//				showDriverDetailsPanel();
//				$("#loginuserPanel").hide();
//
//			}
//			else{
//				console.log("NOt a driver");
//	    		}
//	}

	 return false;
	});

	$("#logoutuserLink").click(function(){

		//$("#loginwrap").empty();
		//showLoginUserPanel();
		$("input[name=\"userrole\"]").val("");
		$("input[name=\"loginusername\"]").val("");
		$("input[name=\"loginpassword\"]").val("");
		showLoginUserPanel();

		return false;
	});

	$("#signup").click(function(){
		console.log("Signing up driver");
		var driverobj = {
						type: "signup",
						firstname: $("input[name=\"firstname\"]").val().replace(" ", ""),
						lastname: $("input[name=\"lastname\"]").val().replace(" ", ""),
						email: $("input[name=\"email\"]").val().replace(" ", ""),
						mobile: $("input[name=\"mobile\"]").val().replace(" ", ""),
						password: $("input[name=\"password\"]").val().replace(" ", ""),
						street: $("input[name=\"street\"]").val().replace(" ", ""),
						city: $("input[name=\"city\"]").val().replace(" ", ""),
						state: $("input[name=\"state\"]").val().replace(" ", ""),
						zip: $("input[name=\"zip\"]").val().replace(" ", ""),
						v: 1
					};
//		if(obj.user && obj.name && obj.color){
			console.log("doing sign up, sending", driverobj);
			ws.send(JSON.stringify(driverobj));
			//			showHomePanel();
//			$('.colorValue').html('Color');											//reset
//			for(var i in bgcolors) $('.createball').removeClass(bgcolors[i]);		//reset
//			$('.createball').css('border', '2px dashed #fff');						//reset
//		}

//		showHomePanel();
	$("#loginuserPanel").fadeIn(300);
	$("#signupPanel").hide();
	//	showDriverPendingListPanel();

		return false;
	});

	$("#approvedriver").click(function(){
		console.log("approving driver");
		var driverobj = 	{
						type: "updateapprovereject",
						firstname: $("input[name=\"driverdetailsfirstname\"]").val().replace(" ", ""),
						lastname: $("input[name=\"driverdetailslastname\"]").val().replace(" ", ""),
						email: $("input[name=\"driverdetailsemail\"]").val().replace(" ", ""),
						mobile: $("input[name=\"driverdetailsmobile\"]").val().replace(" ", ""),
						password: $("input[name=\"driverdetailspassword\"]").val().replace(" ", ""),
						street: $("input[name=\"driverdetailsstreet\"]").val().replace(" ", ""),
						city: $("input[name=\"driverdetailscity\"]").val().replace(" ", ""),
						state: $("input[name=\"driverdetailsstate\"]").val().replace(" ", ""),
						zip: $("input[name=\"driverdetailszip\"]").val().replace(" ", ""),
						status: "A",
						v: 1
					};

					console.log("approverejectdriver"+driverobj);
//		if(obj.user && obj.name && obj.color){
			console.log("approve, sending", driverobj);
			ws.send(JSON.stringify(driverobj));

//			now listing approved drivers
//			var driverlistobj = 	{
//					type: "listdriver",
//					v: 1
//				};
//
//			console.log("listing drivers, sending", driverlistobj);
//			ws.send(JSON.stringify(driverlistobj));

			$("#driverapproverejectPanel").hide();
			$("#drlistwrapa").empty();
			showDriverApprovalListPanel();

//			showHomePanel();
//			$('.colorValue').html('Color');											//reset
//			for(var i in bgcolors) $('.createball').removeClass(bgcolors[i]);		//reset
//			$('.createball').css('border', '2px dashed #fff');						//reset
//		}

//           var driverlistobj = 	{
//				type: "listdriver",
//				v: 1
//			};
//
//		console.log("listing drivers, sending", driverlistobj);
//		ws.send(JSON.stringify(driverlistobj));
//		function onMessage(msg){
//		try{
//			var msgObj = JSON.parse(msg.data);
//			if(msgObj.marble){
//				console.log("rec", msgObj.msg, msgObj);
//				build_ball(msgObj.marble);
//			}
//			if(msgObj.msg === "driverslist"){
//				console.log("Status", msgObj.eachdriver.status);
//				if(msgObj.eachdriver.status == "A"){
//				build_drivera(msgObj.eachdriver);
//			}
//
//				//$("#driverdetailslist").append(msgObj.eachdriver.email +"
");
//				//showDriverApprovalListPanel();
//			}
//			else if(msgObj.msg === "chainstats"){
//				console.log("rec", msgObj.msg, ": ledger blockheight", msgObj.chainstats.height, "block", msgObj.blockstats.height);
//				if(msgObj.blockstats && msgObj.blockstats.transactions) {
//                    var e = formatDate(msgObj.blockstats.transactions[0].timestamp.seconds * 1000, "%M/%d/%Y  %I:%m%P");
//                    $("#blockdate").html("TIME  " + e + " UTC");
//                    var temp =  {
//                        id: msgObj.blockstats.height,
//                        blockstats: msgObj.blockstats
//                    };
//                    new_block(temp);								//send to blockchain.js
//				}
//			}
//			else console.log("rec", msgObj.msg, msgObj);
//		}
//		catch(e){
//			console.log("ERROR", e);
//		}
//	}

//		showDriverApprovalListPanel();

		//$("#driverapprovallistPanel").hide();

		return false;
	});

	$("#approverejecteddriver").click(function(){
		console.log("approving driver");
		var driverobj = 	{
						type: "updateapprovereject",
						firstname: $("input[name=\"driverdetailsfirstname\"]").val().replace(" ", ""),
						lastname: $("input[name=\"driverdetailslastname\"]").val().replace(" ", ""),
						email: $("input[name=\"driverdetailsemail\"]").val().replace(" ", ""),
						mobile: $("input[name=\"driverdetailsmobile\"]").val().replace(" ", ""),
						password: $("input[name=\"driverdetailspassword\"]").val().replace(" ", ""),
						street: $("input[name=\"driverdetailsstreet\"]").val().replace(" ", ""),
						city: $("input[name=\"driverdetailscity\"]").val().replace(" ", ""),
						state: $("input[name=\"driverdetailsstate\"]").val().replace(" ", ""),
						zip: $("input[name=\"driverdetailszip\"]").val().replace(" ", ""),
						status: "A",
						v: 1
					};

					console.log("approverejectdriver"+driverobj);
//		if(obj.user && obj.name && obj.color){
			console.log("approve, sending", driverobj);
			ws.send(JSON.stringify(driverobj));

//			now listing approved drivers
//			var driverlistobj = 	{
//					type: "listdriver",
//					v: 1
//				};
//
//			console.log("listing drivers, sending", driverlistobj);
//			ws.send(JSON.stringify(driverlistobj));

			$("#driverrejectshowPanel").hide();
			$("#drlistwrapa").empty();
			showDriverApprovalListPanel();

//			showHomePanel();
//			$('.colorValue').html('Color');											//reset
//			for(var i in bgcolors) $('.createball').removeClass(bgcolors[i]);		//reset
//			$('.createball').css('border', '2px dashed #fff');						//reset
//		}

//           var driverlistobj = 	{
//				type: "listdriver",
//				v: 1
//			};
//
//		console.log("listing drivers, sending", driverlistobj);
//		ws.send(JSON.stringify(driverlistobj));
//		function onMessage(msg){
//		try{
//			var msgObj = JSON.parse(msg.data);
//			if(msgObj.marble){
//				console.log("rec", msgObj.msg, msgObj);
//				build_ball(msgObj.marble);
//			}
//			if(msgObj.msg === "driverslist"){
//				console.log("Status", msgObj.eachdriver.status);
//				if(msgObj.eachdriver.status == "A"){
//				build_drivera(msgObj.eachdriver);
//			}
//
//				//$("#driverdetailslist").append(msgObj.eachdriver.email +"
");
//				//showDriverApprovalListPanel();
//			}
//			else if(msgObj.msg === "chainstats"){
//				console.log("rec", msgObj.msg, ": ledger blockheight", msgObj.chainstats.height, "block", msgObj.blockstats.height);
//				if(msgObj.blockstats && msgObj.blockstats.transactions) {
//                    var e = formatDate(msgObj.blockstats.transactions[0].timestamp.seconds * 1000, "%M/%d/%Y  %I:%m%P");
//                    $("#blockdate").html("TIME  " + e + " UTC");
//                    var temp =  {
//                        id: msgObj.blockstats.height,
//                        blockstats: msgObj.blockstats
//                    };
//                    new_block(temp);								//send to blockchain.js
//				}
//			}
//			else console.log("rec", msgObj.msg, msgObj);
//		}
//		catch(e){
//			console.log("ERROR", e);
//		}
//	}

//		showDriverApprovalListPanel();

		//$("#driverapprovallistPanel").hide();

		return false;
	});

          //$("#driverapproverejectsuccessPanel").fadeIn(300);
		 // $("#driverapproverejectPanel").hide();
			//$("#createPanel").hide();
			//$("#signupPanel").hide();
		//	$("#driverapprovallistPanel").hide();
		//	$("#checkdriverPanel").hide();

		//var part = window.location.pathname.substring(0,3);
		//window.history.pushState({},"", part + "/driverdetails");

		//return false;
	//});

$("#rejectdriver").click(function(){
		console.log("Rejecting driver");
		var driverobj = 	{
						type: "updateapprovereject",
						firstname: $("input[name=\"driverdetailsfirstname\"]").val().replace(" ", ""),
						lastname: $("input[name=\"driverdetailslastname\"]").val().replace(" ", ""),
						email: $("input[name=\"driverdetailsemail\"]").val().replace(" ", ""),
						mobile: $("input[name=\"driverdetailsmobile\"]").val().replace(" ", ""),
						password: $("input[name=\"driverdetailspassword\"]").val().replace(" ", ""),
						street: $("input[name=\"driverdetailsstreet\"]").val().replace(" ", ""),
						city: $("input[name=\"driverdetailscity\"]").val().replace(" ", ""),
						state: $("input[name=\"driverdetailsstate\"]").val().replace(" ", ""),
						zip: $("input[name=\"driverdetailszip\"]").val().replace(" ", ""),
						status:"R",
						v: 1
					};

					console.log("approverejectdriver"+ driverobj.status);
//		if(obj.user && obj.name && obj.color){
			console.log("Rejecting driver, sending", driverobj);
			 ws.send(JSON.stringify(driverobj));

//			showHomePanel();
//			$('.colorValue').html('Color');											//reset
//			for(var i in bgcolors) $('.createball').removeClass(bgcolors[i]);		//reset
//			$('.createball').css('border', '2px dashed #fff');						//reset
//		}

//var driverlistobj = 	{
//				type: "listdriver",
//				v: 1
//			};
//
//		console.log("listing drivers, sending", driverlistobj);
//		ws.send(JSON.stringify(driverlistobj));

//		function onMessage(msg){
//		try{
//			var msgObj = JSON.parse(msg.data);
//			if(msgObj.marble){
//				console.log("rec", msgObj.msg, msgObj);
//				build_ball(msgObj.marble);
//			}
//			if(msgObj.msg === "driverslist"){
//				console.log("Status", msgObj.eachdriver.status);
//				if(msgObj.eachdriver.status == "R"){
//				build_driverr(msgObj.eachdriver);
//			}
//
//				//$("#driverdetailslist").append(msgObj.eachdriver.email +"
");
//				//showDriverApprovalListPanel();
//			}
//			else if(msgObj.msg === "chainstats"){
//				console.log("rec", msgObj.msg, ": ledger blockheight", msgObj.chainstats.height, "block", msgObj.blockstats.height);
//				if(msgObj.blockstats && msgObj.blockstats.transactions) {
//                    var e = formatDate(msgObj.blockstats.transactions[0].timestamp.seconds * 1000, "%M/%d/%Y  %I:%m%P");
//                    $("#blockdate").html("TIME  " + e + " UTC");
//                    var temp =  {
//                        id: msgObj.blockstats.height,
//                        blockstats: msgObj.blockstats
//                    };
//                    new_block(temp);								//send to blockchain.js
//				}
//			}
//			else console.log("rec", msgObj.msg, msgObj);
//		}
//		catch(e){
//			console.log("ERROR", e);
//		}
//	}

		$("#drlistwrapr").empty();
		showDriverRejectListPanel();
	    $("#driverapproverejectPanel").hide();

		return false;
	});

$("#rejectapproveddriver").click(function(){
	console.log("Rejecting driver");
	var driverobj = 	{
					type: "updateapprovereject",
					firstname: $("input[name=\"driverdetailsfirstname\"]").val().replace(" ", ""),
					lastname: $("input[name=\"driverdetailslastname\"]").val().replace(" ", ""),
					email: $("input[name=\"driverdetailsemail\"]").val().replace(" ", ""),
					mobile: $("input[name=\"driverdetailsmobile\"]").val().replace(" ", ""),
					password: $("input[name=\"driverdetailspassword\"]").val().replace(" ", ""),
					street: $("input[name=\"driverdetailsstreet\"]").val().replace(" ", ""),
					city: $("input[name=\"driverdetailscity\"]").val().replace(" ", ""),
					state: $("input[name=\"driverdetailsstate\"]").val().replace(" ", ""),
					zip: $("input[name=\"driverdetailszip\"]").val().replace(" ", ""),
					status:"R",
					v: 1
				};

				console.log("approverejectdriver"+ driverobj.status);
//	if(obj.user && obj.name && obj.color){
		console.log("Rejecting driver, sending", driverobj);
		 ws.send(JSON.stringify(driverobj));

//		showHomePanel();
//		$('.colorValue').html('Color');											//reset
//		for(var i in bgcolors) $('.createball').removeClass(bgcolors[i]);		//reset
//		$('.createball').css('border', '2px dashed #fff');						//reset
//	}

//var driverlistobj = 	{
//			type: "listdriver",
//			v: 1
//		};
//
//	console.log("listing drivers, sending", driverlistobj);
//	ws.send(JSON.stringify(driverlistobj));

//	function onMessage(msg){
//	try{
//		var msgObj = JSON.parse(msg.data);
//		if(msgObj.marble){
//			console.log("rec", msgObj.msg, msgObj);
//			build_ball(msgObj.marble);
//		}
//		if(msgObj.msg === "driverslist"){
//			console.log("Status", msgObj.eachdriver.status);
//			if(msgObj.eachdriver.status == "R"){
//			build_driverr(msgObj.eachdriver);
//		}
//
//			//$("#driverdetailslist").append(msgObj.eachdriver.email +"
");
//			//showDriverApprovalListPanel();
//		}
//		else if(msgObj.msg === "chainstats"){
//			console.log("rec", msgObj.msg, ": ledger blockheight", msgObj.chainstats.height, "block", msgObj.blockstats.height);
//			if(msgObj.blockstats && msgObj.blockstats.transactions) {
//                var e = formatDate(msgObj.blockstats.transactions[0].timestamp.seconds * 1000, "%M/%d/%Y  %I:%m%P");
//                $("#blockdate").html("TIME  " + e + " UTC");
//                var temp =  {
//                    id: msgObj.blockstats.height,
//                    blockstats: msgObj.blockstats
//                };
//                new_block(temp);								//send to blockchain.js
//			}
//		}
//		else console.log("rec", msgObj.msg, msgObj);
//	}
//	catch(e){
//		console.log("ERROR", e);
//	}
//}

	$("#drlistwrapr").empty();
	showDriverRejectListPanel();
    $("#driverapproverejectPanel").hide();
    $("#driverapproveshowPanel").hide();

	return false;
});

		//$("#driverapproverejectsuccessPanel").fadeIn(300);
		//$("#driverapproverejectPanel").hide();
		//	$("#createPanel").hide();
	//		$("#signupPanel").hide();
		//	$("#driverapprovallistPanel").hide();
		//	$("#checkdriverPanel").hide();

	//	var part = window.location.pathname.substring(0,3);
		//window.history.pushState({},"", part + "/driverdetails");

		//return false;
	//});

$("#updatedriver").click(function(){
		console.log("Updating driver");
		var driverobj = 	{
						type: "updatedriverdetails",
						firstname: $("input[name=\"driverdetailsfirstname\"]").val().replace(" ", ""),
						lastname: $("input[name=\"driverdetailslastname\"]").val().replace(" ", ""),
						email: $("input[name=\"driverdetailsemail\"]").val().replace(" ", ""),
						mobile: $("input[name=\"driverdetailsmobile\"]").val().replace(" ", ""),
						password: $("input[name=\"driverdetailspassword\"]").val().replace(" ", ""),
						street: $("input[name=\"driverdetailsstreet\"]").val().replace(" ", ""),
						city: $("input[name=\"driverdetailscity\"]").val().replace(" ", ""),
						state: $("input[name=\"driverdetailsstate\"]").val().replace(" ", ""),
						zip: $("input[name=\"driverdetailszip\"]").val().replace(" ", ""),
						status:"P",
						v: 1
					};

					console.log("updatedriver"+ driverobj.status);
//		if(obj.user && obj.name && obj.color){
			console.log("Update, sending", driverobj);
			ws.send(JSON.stringify(driverobj));
//			showHomePanel();
//			$('.colorValue').html('Color');											//reset
//			for(var i in bgcolors) $('.createball').removeClass(bgcolors[i]);		//reset
//			$('.createball').css('border', '2px dashed #fff');						//reset
//		}
		$("#driverapproverejectsuccessPanel").fadeIn(300);
		$("#driverapproverejectPanel").hide();
			$("#createPanel").hide();
			$("#signupPanel").hide();
			$("#driverapprovallistPanel").hide();
			$("#checkdriverPanel").hide();
			$("#driverdetailsPanel").hide();

		var part = window.location.pathname.substring(0,3);
		window.history.pushState({},"", part + "/driverdetails");

		return false;
	});

	$("#checkdriverdetails").click(function(){

		console.log("checking up driver");

		if($("input[name=\"checkdriveremail\"]").val()=="admin@hertz.com")
		{
			$("#checkdriverPanel").hide();
			$("#noaccessPanel").fadeIn(300);

		}else
		{
			var checkdriverobj = {
						type: "checkdriverdetails",
						checkdriveremail: $("input[name=\"checkdriveremail\"]").val().replace(" ", ""),
						v: 1
					};
//		if(obj.user && obj.name && obj.color){
			//console.log('doing sign up, sending', driverobj);
			ws.send(JSON.stringify(checkdriverobj));
			showDriverDetailsPanel();
//			showHomePanel();
//			$('.colorValue').html('Color');											//reset
//			for(var i in bgcolors) $('.createball').removeClass(bgcolors[i]);		//reset
//			$('.createball').css('border', '2px dashed #fff');						//reset
//		}

		//var	driverdetailsmail=$('input[name="checkdriveremail"]').val().replace(' ', '');

		//$('input[name="driverdetailsemail"]').val(driverdetailsmail);
		//showDriverDetailsPanel();
		}

		return false;
	});

//	$("#modifydriver").click(function(){
//		console.log("pulling up the driver to modify");
//		var checkdriverobj = {
//						type: "checkdriverdetails",
//						checkdriveremail: $("input[name=\"modifydriveremail\"]").val().replace(" ", ""),
//						v: 1
//					};
////		if(obj.user && obj.name && obj.color){
//			//console.log('doing sign up, sending', driverobj);
//			ws.send(JSON.stringify(checkdriverobj));
//			showDriverDetailsPanel();
////			showHomePanel();
////			$('.colorValue').html('Color');											//reset
////			for(var i in bgcolors) $('.createball').removeClass(bgcolors[i]);		//reset
////			$('.createball').css('border', '2px dashed #fff');						//reset
////		}
//
//		//var	driverdetailsmail=$('input[name="checkdriveremail"]').val().replace(' ', '');
//
//		//$('input[name="driverdetailsemail"]').val(driverdetailsmail);
//		showDriverDetailsPanel();
//
//		return false;
//	});
//
//

	$("#homeLink").click(function(){
		showHomePanel();
	});

	$("#loginuserLink").click(function(){
		//$("#loginwrap").empty();
		$("input[name=\"userrole\"]").val("");
		$("input[name=\"loginusername\"]").val("");
		$("input[name=\"loginpassword\"]").val("");
		showLoginUserPanel();
		//$("input[name=\"userrole\"]").val("");
	});

	$("#signupLink").click(function(){
		$("#signupwrap").empty();
		$("input[name=\"firstname\"]").val("");
			$("input[name=\"lastname\"]").val("");
			$("input[name=\"email\"]").val("");
			$("input[name=\"mobile\"]").val("");
			$("input[name=\"password\"]").val("");
			$("input[name=\"street\"]").val("");
			$("input[name=\"city\"]").val("");
			$("input[name=\"state\"]").val("");
			$("input[name=\"zip\"]").val("");
		showSignupPanel();
	});

	$("#createLink").click(function(){
		$("input[name=\"name\"]").val("r" + randStr(6));
	});

	$("#checkdriverLink").click(function(){
		showcheckdriverPanel();
	});

//	$("#modifydriverLink").click(function(){
//		if($("input[name=\"userrole\"]").val() === "Driver"){
//			//if(bag.ssn.loginresult === "Driver"){
//
//				$("#noaccessPanel").fadeIn(300);
//
//			}
//			else if($("input[name=\"userrole\"]").val() === "")
//			{
//				$("#noaccessPanel").fadeIn(300);
//			}
//			else if($("input[name=\"userrole\"]").val() === "LoginFailure")
//			{
//				$("#noaccessPanel").fadeIn(300);
//			}
//			else {
//
//				$("#modifydriverPanel").fadeIn(300);
//				$("#createPanel").hide();
//				$("#signupPanel").hide();
//				$("#checkdriverPanel").hide();
//				$("#driverpendinglistPanel").hide();
//				$("#driverrejectlistPanel").hide();
//				$("#driverapprovallistPanel").hide();
//
//			}
//	});

	$("#driverdetailsLink").click(function(){
		showDriverDetailsPanel();
	});

	$("#pendingdriverlistLink").click(function(){
		if($("input[name=\"userrole\"]").val() === "Driver"){
		//if(bag.ssn.loginresult === "Driver"){

			$("#noaccessPanel").fadeIn(300);

		}
		else if($("input[name=\"userrole\"]").val() === "")
		{
			$("#noaccessPanel").fadeIn(300);
		}
		else if($("input[name=\"userrole\"]").val() === "LoginFailure")
		{
			$("#noaccessPanel").fadeIn(300);
		}
		else {

		//ws.send(JSON.stringify({type: 'chainstats', v:1}));
		console.log("Retrieve list of drivers");
		$("#drlistwrap").empty();

		var driverlistobj = 	{
				type: "listdriver",
				v: 1
			};

		console.log("listing drivers, sending", driverlistobj);
		ws.send(JSON.stringify(driverlistobj));
		showDriverPendingListPanel();
		}
	});

	$("#approvaldriverlistLink").click(function(){
		if($("input[name=\"userrole\"]").val() === "Driver"){

			$("#noaccessPanel").fadeIn(300);

		}else if($("input[name=\"userrole\"]").val() === "LoginFailure")
		{
			$("#noaccessPanel").fadeIn(300);
		}else if ($("input[name=\"userrole\"]").val() === "")
		{
			$("#noaccessPanel").fadeIn(300);
		}else {
		//ws.send(JSON.stringify({type: 'chainstats', v:1}));
		console.log("Retrieve list of drivers");
		$("#drlistwrapa").empty();

		var driverlistobj = 	{
				type: "listdriver",
				v: 1
			};

		console.log("listing drivers, sending", driverlistobj);
		ws.send(JSON.stringify(driverlistobj));
		showDriverApprovalListPanel();
	}

	});

	$("#rejectdriverlistLink").click(function(){

		if($("input[name=\"userrole\"]").val() === "Driver"){

			$("#noaccessPanel").fadeIn(300);
		}else if ($("input[name=\"userrole\"]").val() === "")
		{
			$("#noaccessPanel").fadeIn(300);
		}else if($("input[name=\"userrole\"]").val() === "LoginFailure")
		{
			$("#noaccessPanel").fadeIn(300);
		}else {
		//ws.send(JSON.stringify({type: 'chainstats', v:1}));
		console.log("Retrieve list of drivers");
		$("#drlistwrapr").empty();

		var driverlistobj = 	{
				type: "listdriver",
				v: 1
			};

		console.log("listing drivers, sending", driverlistobj);
		ws.send(JSON.stringify(driverlistobj));
		showDriverRejectListPanel();

	}

	});

	//marble color picker
	$(document).on("click", ".colorInput", function(){
		$(".colorOptionsWrap").hide();											//hide any others
		$(this).parent().find(".colorOptionsWrap").show();
	});
	$(document).on("click", ".colorOption", function(){
		var color = $(this).attr("color");
		var html = "";

		$(this).parent().parent().find(".colorValue").html(html);
		$(this).parent().hide();

		for(var i in bgcolors) $(".createball").removeClass(bgcolors[i]);			//remove prev color
		$(".createball").css("border", "0").addClass(color + "bg");				//set new color
	});

	//drag and drop marble
	$("#user2wrap, #user1wrap, #trashbin").sortable({connectWith: ".sortable"}).disableSelection();
	$("#user2wrap").droppable({drop:
		function( event, ui ) {
			var user = $(ui.draggable).attr("user");
			if(user.toLowerCase() != bag.setup.USER2){
				$(ui.draggable).addClass("invalid");
				transfer($(ui.draggable).attr("id"), bag.setup.USER2);
			}
		}
	});
	$("#user1wrap").droppable({drop:
		function( event, ui ) {
			var user = $(ui.draggable).attr("user");
			if(user.toLowerCase() != bag.setup.USER1){
				$(ui.draggable).addClass("invalid");
				transfer($(ui.draggable).attr("id"), bag.setup.USER1);
			}
		}
	});
	$("#trashbin").droppable({drop:
		function( event, ui ) {
			var id = $(ui.draggable).attr("id");
			if(id){
				console.log("removing marble", id);
				var obj = 	{
								type: "remove",
								name: id,
								v: 1
							};
				ws.send(JSON.stringify(obj));
				$(ui.draggable).fadeOut();
				setTimeout(function(){
					$(ui.draggable).remove();
				}, 300);
				showHomePanel();
			}
		}
	});

	// =================================================================================
	// Helper Fun
	// ================================================================================
	//show admin panel page
	function showHomePanel(){
		$("#homePanel").fadeIn(300);
		$("#createPanel").hide();
		$("#signupPanel").hide();

		var part = window.location.pathname.substring(0,3);
		window.history.pushState({},"", part + "/home");						//put it in url so we can f5

		console.log("getting new balls");
		setTimeout(function(){
			$("#user1wrap").html("");											//reset the panel
			$("#user2wrap").html("");
			ws.send(JSON.stringify({type: "get", v: 1}));						//need to wait a bit
			ws.send(JSON.stringify({type: "chainstats", v: 1}));
		}, 1000);
	}

	function showLoginUserPanel(){
		$("#loginuserPanel").fadeIn(300);
		$("#createPanel").hide();
		$("#signupPanel").hide();
		//$('#createPanel').hide();

		var part = window.location.pathname.substring(0,3);
		window.history.pushState({},"", part + "/loginuser");

	}

	function showDriverDetailsPanel(){
		$("#drvdwrap").empty();
		$("#driverdetailsPanel").fadeIn(300);
		$("#createPanel").hide();
		$("#signupPanel").hide();
		//$('#home').hide();
		$("#checkdriverPanel").hide();

		var part = window.location.pathname.substring(0,3);
		window.history.pushState({},"", part + "/driverdetails");
	}

 function showDriverPendingListPanel(){

		$("#driverpendinglistPanel").fadeIn(300);
		$("#createPanel").hide();
		$("#signupPanel").hide();
		//$('#home').hide();
		$("#checkdriverPanel").hide();
		$("#driverrejectlistPanel").hide();
		$("#driverapprovallistPanel").hide();

		var part = window.location.pathname.substring(0,3);
		window.history.pushState({},"", part + "/pendingdrivers");

	}

	function showDriverApprovalListPanel(){

		$("#driverapprovallistPanel").fadeIn(300);
			$("#createPanel").hide();
			$("#signupPanel").hide();
			//$("#driverapprovallistPanel").hide();
			$("#checkdriverPanel").hide();
			$("#driverpendinglistPanel").hide();
			$("#driverrejectlistPanel").hide();

		var part = window.location.pathname.substring(0,3);
		//window.history.pushState({},"", part + "/driverdetails");
		window.history.pushState({},"", part + "/approvedrivers");
	}

 function showDriverRejectListPanel(){

			$("#driverrejectlistPanel").fadeIn(300);
			$("#createPanel").hide();
			$("#signupPanel").hide();
		//	$("#driverapprovallistPanel").hide();
			$("#checkdriverPanel").hide();
			$("#driverpendinglistPanel").hide();
			$("#driverapprovallistPanel").hide();

		var part = window.location.pathname.substring(0,3);
		window.history.pushState({},"", part + "/rejectdrivers");

		//window.history.pushState({},"", part + "/dirverapprovallist");
	}

	function showcheckdriverPanel(){

		if($("input[name=\"userrole\"]").val() === "Driver"){
			//if(bag.ssn.loginresult === "Driver"){

				$("#noaccessPanel").fadeIn(300);

			}
			else if($("input[name=\"userrole\"]").val() === "")
			{
				$("#noaccessPanel").fadeIn(300);
			}
			else if($("input[name=\"userrole\"]").val() === "LoginFailure")
			{
				$("#noaccessPanel").fadeIn(300);
			}
			else {

					$("#checkdriverPanel").fadeIn(300);
					$("#createPanel").hide();
					$("#signupPanel").hide();
					$("#driverdetailsPanel").hide();
					//$('#homePanel').hide();

					var part = window.location.pathname.substring(0,3);
					window.history.pushState({},"", part + "/checkdriver");
			}//put it in url so we can f5

//		console.log('getting list of drivers');
//		setTimeout(function(){
//		//	$('#user1wrap').html('');											//reset the panel
//		//	$('#user2wrap').html('');
//		//	ws.send(JSON.stringify({type: 'get', v: 1}));						//need to wait a bit
//		//	ws.send(JSON.stringify({type: 'chainstats', v: 1}));
//
//									//need to wait a bit
//
//		}, 1000);
	}

	//show Signup panel page
	function showSignupPanel(){
		$("#signupPanel").fadeIn(300);
		$("#createPanel").hide();
		$("#loginuserPanel").hide();
		//$('#createPanel').hide();

		var part = window.location.pathname.substring(0,4);
		window.history.pushState({},"", part + "/signup");						//put it in url so we can f5
	}

	//show Signup panel page
	function showSucessPanel(){
		$("#driverapproverejectsuccessPanel").fade(300);

		$("#driverapproverejectPanel").hide();
			$("#createPanel").hide();
			$("#signupPanel").hide();
			$("#driverapprovallistPanel").hide();
			$("#checkdriverPanel").hide();

		var part = window.location.pathname.substring(0,3);
		window.history.pushState({},"", part + "/driverdetails");

	}

	//transfer selected ball to user
	function transfer(marbleName, user){
		if(marbleName){
			console.log("transfering", marbleName);
			var obj = 	{
							type: "transfer",
							name: marbleName,
							user: user,
							v: 1
						};
			ws.send(JSON.stringify(obj));
			showHomePanel();
		}
	}
});

// =================================================================================
// Socket Stuff
// =================================================================================
function connect_to_server(){
	var connected = false;

    // Redirect https requests to http so the server can handle them
    if(this.location.href.indexOf("https://") > -1) {
        this.location.href = this.location.href.replace("https://", "http://");
    }

	connect();

	function connect(){
		var wsUri = "ws://" + document.location.hostname + ":" + document.location.port;
		console.log("Connectiong to websocket", wsUri);

		ws = new WebSocket(wsUri);
		ws.onopen = function(evt) { onOpen(evt); };
		ws.onclose = function(evt) { onClose(evt); };
		ws.onmessage = function(evt) { onMessage(evt); };
		ws.onerror = function(evt) { onError(evt); };
	}

	function onOpen(evt){
		console.log("WS CONNECTED");
		connected = true;
		clear_blocks();
		$("#errorNotificationPanel").fadeOut();
		ws.send(JSON.stringify({type: "get", v:1}));
		ws.send(JSON.stringify({type: "chainstats", v:1}));
	}

	function onClose(evt){
		console.log("WS DISCONNECTED", evt);
		connected = false;
		setTimeout(function(){ connect(); }, 5000);					//try again one more time, server restarts are quick
	}

	function onMessage(msg){
		try{
			var msgObj = JSON.parse(msg.data);
			if(msgObj.marble){
				console.log("rec", msgObj.msg, msgObj);
				build_ball(msgObj.marble);
			}
			if(msgObj.msg === "checklogin"){
				console.log("Logged in user details", msgObj.msg, msgObj.driver);

				if(msgObj.authentication === "failure")
					{
						//bag.ssn.loginresult="LoginFailure";
						$("input[name=\"userrole\"]").val("LoginFailure");
					}

				if(msgObj.authentication === "success")
				{
					if(msgObj.driver.email==="admin@fleetchain.com")
						{

							//bag.ssn.loginresult="Uber Admin";
							$("input[name=\"userrole\"]").val("Uber Admin");

							$("#loginuserPanel").hide();
							$("#driverpendinglistPanel").fadeIn(300);

							//show pending driver list
							//ws.send(JSON.stringify({type: 'chainstats', v:1}));
							console.log("Retrieve list of drivers");
							$("#drlistwrap").empty();

							var pendingdriverlistobj = {
									type: "listdriver",
									v: 1
								};

							console.log("listing drivers, sending", pendingdriverlistobj);
							ws.send(JSON.stringify(pendingdriverlistobj));
							//showDriverPendingListPanel();

						}
					else
						{

							//bag.ssn.loginresult="Driver";
							$("input[name=\"userrole\"]").val("Driver");

							//show driver details
							$("input[name=\"driverdetailsemail\"]").val(msgObj.driver.email);
							$("input[name=\"driverdetailsfirstname\"]").val(msgObj.driver.firstname);
							$("input[name=\"driverdetailslastname\"]").val(msgObj.driver.lastname);
							$("input[name=\"driverdetailsmobile\"]").val(msgObj.driver.mobile);
							$("input[name=\"driverdetailspassword\"]").val(msgObj.driver.password);
							$("input[name=\"driverdetailsstreet\"]").val(msgObj.driver.street);
							$("input[name=\"driverdetailscity\"]").val(msgObj.driver.city);
							$("input[name=\"driverdetailsstate\"]").val(msgObj.driver.state);
							$("input[name=\"driverdetailszip\"]").val(msgObj.driver.zip);
							$("input[name=\"driverdetailsstatus\"]").val(msgObj.driver.status);

							$("#loginuserPanel").hide();
							$("#driverdetailsPanel").fadeIn(300);
//							$("#createPanel").hide();
//							$("#signupPanel").hide();
//							$("#driverpendinglistPanel").hide();
//							$("#checkdriverPanel").hide();
//							$("#driverrejectlistPanel").hide();
//							$("#driverapprovallistPanel").hide();

						}

				}

				//showDriverDetailsPanel();
			}
			if(msgObj.msg === "driver"){
				console.log("rec", msgObj.msg, msgObj.driver);

				//build_ball(msgObj.marble);
				$("input[name=\"driverdetailsemail\"]").val(msgObj.driver.email);
				$("input[name=\"driverdetailsfirstname\"]").val(msgObj.driver.firstname);
				$("input[name=\"driverdetailslastname\"]").val(msgObj.driver.lastname);
				$("input[name=\"driverdetailsmobile\"]").val(msgObj.driver.mobile);
				$("input[name=\"driverdetailspassword\"]").val(msgObj.driver.password);
				$("input[name=\"driverdetailsstreet\"]").val(msgObj.driver.street);
				$("input[name=\"driverdetailscity\"]").val(msgObj.driver.city);
				$("input[name=\"driverdetailsstate\"]").val(msgObj.driver.state);
				$("input[name=\"driverdetailszip\"]").val(msgObj.driver.zip);
				$("input[name=\"driverdetailsstatus\"]").val(msgObj.driver.status);
				//showDriverDetailsPanel();
			}
			if(msgObj.msg === "driverslist"){
				console.log("Status", msgObj.eachdriver.status);

				if(msgObj.eachdriver.email=="admin@fleetchain.com")
				{

				}else if (msgObj.eachdriver.email=="admin@hertz.com")
				{

				}else
				{
					if(msgObj.eachdriver.status == "P"){
						build_driver(msgObj.eachdriver);
					}

					if(msgObj.eachdriver.status == "A"){
						build_drivera(msgObj.eachdriver);
					}

					if(msgObj.eachdriver.status == "R"){
						build_driverr(msgObj.eachdriver);
					}
				}

				//$("#driverdetailslist").append(msgObj.eachdriver.email +"
");
				//showDriverApprovalListPanel();
			}
			else if(msgObj.msg === "chainstats"){
				console.log("rec", msgObj.msg, ": ledger blockheight", msgObj.chainstats.height, "block", msgObj.blockstats.height);
				if(msgObj.blockstats && msgObj.blockstats.transactions) {
                    var e = formatDate(msgObj.blockstats.transactions[0].timestamp.seconds * 1000, "%M/%d/%Y  %I:%m%P");
                    $("#blockdate").html("TIME  " + e + " UTC");
                    var temp =  {
                        id: msgObj.blockstats.height,
                        blockstats: msgObj.blockstats
                    };
                    new_block(temp);								//send to blockchain.js
				}
			}
			else console.log("rec", msgObj.msg, msgObj);
		}
		catch(e){
			console.log("ERROR", e);
		}
	}

	function onError(evt){
		console.log("ERROR ", evt);
		if(!connected && bag.e == null){											//don't overwrite an error message
			$("#errorName").html("Warning");
			$("#errorNoticeText").html("Waiting on the node server to open up so we can talk to the blockchain. ");
			$("#errorNoticeText").append("This app is likely still starting up. ");
			$("#errorNoticeText").append("Check the server logs if this message does not go away in 1 minute. ");
			$("#errorNotificationPanel").fadeIn();
		}
	}
}

// =================================================================================
//	UI Building
// =================================================================================
function build_ball(data){
	var html = "";
	var colorClass = "";
	var size = "fa-5x";

	data.name = escapeHtml(data.name);
	data.color = escapeHtml(data.color);
	data.user = escapeHtml(data.user);

	console.log("got a marble: ", data.color);
	if(!$("#" + data.name).length){								//only populate if it doesn't exists
		if(data.size == 16) size = "fa-3x";
		if(data.color) colorClass = data.color.toLowerCase();

		html += "";
		if(data.user && data.user.toLowerCase() == bag.setup.USER1){
			$("#user1wrap").append(html);
		}
		else{
			$("#user2wrap").append(html);
		}
	}
	return html;
}

function build_driver(data){
	var html = "";
	var colorClass = "";
	var size = "12";

	data.firstname = escapeHtml(data.firstname);
	data.lastname = escapeHtml(data.lastname);
	data.email = escapeHtml(data.email);
	data.password = escapeHtml(data.password);

	console.log("Got a driver: ", data.email);
	//if(!$('#' + data.email).length){								//only populate if it doesn't exists
		//if(data.size == 16) size = '12';
		//if(data.color) colorClass = data.color.toLowerCase();

		//html += '';

		html += "
" + data.firstname + "	" + data.lastname + "	" + data.email + "
" ;

		$("#drlistwrap").append(html);
	//}

	console.log("driverlist message ", html);
//	showDriverListPanel();

	return html;
}

function showdriverdetails(email){
	console.log("After hyperlink cliuck" + email);
	var checkdriverobj = {
						type: "checkdriverdetails",
						checkdriveremail:email,
						v: 1
					};
//		if(obj.user && obj.name && obj.color){
			//console.log('doing sign up, sending', driverobj);
			ws.send(JSON.stringify(checkdriverobj));
			$("#driverapproverejectPanel").fadeIn(300);
			$("#createPanel").hide();
			$("#signupPanel").hide();
			$("#driverpendinglistPanel").hide();
			$("#checkdriverPanel").hide();
			$("#driverrejectlistPanel").hide();
			$("#driverapprovallistPanel").hide();

		var part = window.location.pathname.substring(0,3);
		window.history.pushState({},"", part + "/driverdetails");
}

function showdriverdetailsapprove(email){
	console.log("After hyperlink cliuck" + email);
	var checkdriverobj = {
						type: "checkdriverdetails",
						checkdriveremail:email,
						v: 1
					};
//		if(obj.user && obj.name && obj.color){
			//console.log('doing sign up, sending', driverobj);
			ws.send(JSON.stringify(checkdriverobj));
			$("#driverapproveshowPanel").fadeIn(300);
			$("#driverapproverejectPanel").hide();
			$("#driverrejectshowPanel").hide();
			$("#createPanel").hide();
			$("#signupPanel").hide();
			$("#driverpendinglistPanel").hide();
			$("#checkdriverPanel").hide();
			$("#driverrejectlistPanel").hide();
			$("#driverapprovallistPanel").hide();

		var part = window.location.pathname.substring(0,3);
		window.history.pushState({},"", part + "/approvedriverdetails");
}

function showdriverdetailsreject(email){
	console.log("After hyperlink cliuck" + email);
	var checkdriverobj = {
						type: "checkdriverdetails",
						checkdriveremail:email,
						v: 1
					};
//		if(obj.user && obj.name && obj.color){
			//console.log('doing sign up, sending', driverobj);
			ws.send(JSON.stringify(checkdriverobj));
	        $("#driverrejectshowPanel").fadeIn(300);
			$("#driverapproveshowPanel").hide();
			$("#createPanel").hide();
			$("#signupPanel").hide();
			$("#driverpendinglistPanel").hide();
			$("#checkdriverPanel").hide();
			$("#driverrejectlistPanel").hide();
			$("#driverapprovallistPanel").hide();

		var part = window.location.pathname.substring(0,3);
		window.history.pushState({},"", part + "/rejectdriverdetails");
}

function build_drivera(data){
	var html = "";
	var colorClass = "";
	var size = "12";

	data.firstname = escapeHtml(data.firstname);
	data.lastname = escapeHtml(data.lastname);
	data.email = escapeHtml(data.email);
	data.password = escapeHtml(data.password);

	console.log("Got a driver approved: ", data.email);
	//if(!$('#' + data.email).length){								//only populate if it doesn't exists
		//if(data.size == 16) size = '12';
		//if(data.color) colorClass = data.color.toLowerCase();

		//html += '';

			html += "
" + data.firstname + "	" + data.lastname + "	" + data.email + "
" ;

		$("#drlistwrapa").append(html);
	//}

	console.log("driverlist message approved ", html);
//	showDriverListPanel();

	return html;
}

function build_driverr(data){
	var html = "";
	var colorClass = "";
	var size = "12";

	data.firstname = escapeHtml(data.firstname);
	data.lastname = escapeHtml(data.lastname);
	data.email = escapeHtml(data.email);
	data.password = escapeHtml(data.password);

	console.log("Got a rejected driver: ", data.email);
	//if(!$('#' + data.email).length){								//only populate if it doesn't exists
		//if(data.size == 16) size = '12';
		//if(data.color) colorClass = data.color.toLowerCase();

		//html += '';

			html += "
" + data.firstname + "	" + data.lastname + "	" + data.email + "
" ;
		$("#drlistwrapr").append(html);
	//}

	console.log("driverlist message rejected ", html);
//	showDriverListPanel();

	return html;
}

redpajama_set_name: RedPajamaGithub


text:
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';

import { InventoryTransactionsComponent } from './inventory-transactions.component';
import { RouterTestingModule } from '@angular/router/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatDialogModule } from '@angular/material/dialog';
import { MatTableModule } from '@angular/material/table';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MockAllowedDirective } from '../allowed.directive.mock';

describe('InventoryTransactionsComponent', () => {
  let component: InventoryTransactionsComponent;
  let fixture: ComponentFixture<InventoryTransactionsComponent>;

  beforeEach(waitForAsync(() => {
    TestBed.configureTestingModule({
      declarations: [ InventoryTransactionsComponent, MockAllowedDirective ],
      imports: [
        HttpClientTestingModule,
        MatButtonModule,
        MatCardModule,
        MatDialogModule,
        MatTableModule,
        MatIconModule,
        MatProgressSpinnerModule,
        RouterTestingModule,
      ],
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(InventoryTransactionsComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis
{
    /// <summary>
    /// Represents the results of running a generation pass over a set of <see cref="ISourceGenerator"/>s.
    /// </summary>
    public class GeneratorDriverRunResult
    {
        private ImmutableArray<Diagnostic> _lazyDiagnostics;

        private ImmutableArray<SyntaxTree> _lazyGeneratedTrees;

        internal GeneratorDriverRunResult(ImmutableArray<GeneratorRunResult> results)
        {
            this.Results = results;
        }

        /// <summary>
        /// The individual result of each <see cref="ISourceGenerator"/> that was run in this generator pass, one per generator.
        /// </summary>
        public ImmutableArray<GeneratorRunResult> Results { get; }

        /// <summary>
        /// The <see cref="Diagnostic"/>s produced by all generators run during this generation pass.
        /// </summary>
        /// <remarks>
        /// This is equivalent to the union of all <see cref="GeneratorRunResult.Diagnostics"/> in <see cref="Results"/>.
        /// </remarks>
        public ImmutableArray<Diagnostic> Diagnostics
        {
            get
            {
                if (_lazyDiagnostics.IsDefault)
                {
                    ImmutableInterlocked.InterlockedInitialize(ref _lazyDiagnostics, Results.SelectMany(r => r.Diagnostics).ToImmutableArray());
                }
                return _lazyDiagnostics;
            }
        }

        /// <summary>
        /// The <see cref="SyntaxTree"/>s produced during this generation pass by parsing each <see cref="SourceText"/> added by each generator.
        /// </summary>
        /// <remarks>
        /// This is equivalent to the union of all <see cref="GeneratedSourceResult.SyntaxTree"/>s in each <see cref="GeneratorRunResult.GeneratedSources"/> in each <see cref="Results"/>
        /// </remarks>
        public ImmutableArray<SyntaxTree> GeneratedTrees
        {
            get
            {
                if (_lazyGeneratedTrees.IsDefault)
                {
                    ImmutableInterlocked.InterlockedInitialize(ref _lazyGeneratedTrees, Results.SelectMany(r => r.GeneratedSources.Select(g => g.SyntaxTree)).ToImmutableArray());
                }
                return _lazyGeneratedTrees;
            }
        }
    }

    /// <summary>
    /// Represents the results of a single <see cref="ISourceGenerator"/> generation pass.
    /// </summary>
    public readonly struct GeneratorRunResult
    {
        internal GeneratorRunResult(ISourceGenerator generator, ImmutableArray<GeneratedSourceResult> generatedSources, ImmutableArray<Diagnostic> diagnostics, Exception? exception)
        {
            Debug.Assert(exception is null || (generatedSources.IsEmpty && diagnostics.Length == 1));

            this.Generator = generator;
            this.GeneratedSources = generatedSources;
            this.Diagnostics = diagnostics;
            this.Exception = exception;
        }

        /// <summary>
        /// The <see cref="ISourceGenerator"/> that produced this result.
        /// </summary>
        public ISourceGenerator Generator { get; }

        /// <summary>
        /// The sources that were added by <see cref="Generator"/> during the generation pass this result represents.
        /// </summary>
        public ImmutableArray<GeneratedSourceResult> GeneratedSources { get; }

        /// <summary>
        /// A collection of <see cref="Diagnostic"/>s reported by <see cref="Generator"/>
        /// </summary>
        /// <remarks>
        /// When generation fails due to an <see cref="Exception"/> being thrown, a single diagnostic is added
        /// to represent the failure. Any generator reported diagnostics up to the failure point are not included.
        /// </remarks>
        public ImmutableArray<Diagnostic> Diagnostics { get; }

        /// <summary>
        /// An <see cref="System.Exception"/> instance that was thrown by the generator, or <c>null</c> if the generator completed without error.
        /// </summary>
        /// <remarks>
        /// When this property has a value, <see cref="GeneratedSources"/> property is guaranteed to be empty, and the <see cref="Diagnostics"/>
        /// collection will contain a single diagnostic indicating that the generator failed.
        /// </remarks>
        public Exception? Exception { get; }
    }

    /// <summary>
    /// Represents the results of an <see cref="ISourceGenerator"/> calling <see cref="GeneratorExecutionContext.AddSource(string, SourceText)"/>.
    /// </summary>
    /// <remarks>
    /// This contains the original <see cref="SourceText"/> added by the generator, along with the parsed representation of that text in <see cref="SyntaxTree"/>.
    /// </remarks>
    public readonly struct GeneratedSourceResult
    {
        internal GeneratedSourceResult(SyntaxTree tree, SourceText text, string hintName)
        {
            this.SyntaxTree = tree;
            this.SourceText = text;
            this.HintName = hintName;
        }

        /// <summary>
        /// The <see cref="SyntaxTree"/> that was produced from parsing the <see cref="GeneratedSourceResult.SourceText"/>.
        /// </summary>
        public SyntaxTree SyntaxTree { get; }

        /// <summary>
        /// The <see cref="SourceText"/> that was added by the generator.
        /// </summary>
        public SourceText SourceText { get; }

        /// <summary>
        /// An identifier provided by the generator that identifies the added <see cref="SourceText"/>.
        /// </summary>
        public string HintName { get; }
    }
}


text:
/**
 * @fileoverview OpenPGP Context WebWorker bootstrap file.
 */

goog.provide('e2email.worker.bootstrap');

goog.require('e2e.async.Result');
goog.require('e2e.async.WorkerSelf');
goog.require('e2e.openpgp.ContextImpl');
goog.require('e2e.openpgp.ContextService');
goog.require('e2email.worker.IndexedDbStorage');

/**
 * Bootstrap function for the code in the Web Worker.
 */
e2email.worker.bootstrap = function() {
  var contextPromise = new e2e.async.Result();
  new e2email.worker.IndexedDbStorage('keyring', function(storage) {
    contextPromise.callback(new e2e.openpgp.ContextImpl(storage));
  });
  var workerPeer = new e2e.async.WorkerSelf();
  e2e.openpgp.ContextService.launch(workerPeer, contextPromise);
};

e2email.worker.bootstrap();


text:
package org.nd4j.linalg.api.ops.impl.transforms.custom;

import org.nd4j.autodiff.samediff.SDVariable;
import org.nd4j.autodiff.samediff.SameDiff;
import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.ops.DynamicCustomOp;

import java.util.Arrays;
import java.util.List;

public class ListDiff extends DynamicCustomOp {

    public ListDiff() {
        //
    }

    public ListDiff(SameDiff sd, SDVariable x, SDVariable y){
        super(sd, new SDVariable[]{x, y});
    }

    @Override
    public String tensorflowName() {
        return "ListDiff";  //Note: Seems to be renamed to tf.setdiff1d in public API?
    }

    @Override
    public String opName() {
        return "listdiff";
    }

    @Override
    public List<SDVariable> doDiff(List<SDVariable> f1) {
        throw new UnsupportedOperationException();
    }

    @Override
    public List<DataType> calculateOutputDataTypes(List<DataType> inputDataTypes){
        //TODO make this configurable
        return Arrays.asList(inputDataTypes.get(0), DataType.INT);
    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZyGames.Framework.Common.Configuration;

namespace ZyGames.Framework.Game.Config
{
    /// <summary>
    ///
    /// </summary>
    public class AppServerSection : ConfigSection
    {
        /// <summary>
        /// init
        /// </summary>
        public AppServerSection()
        {
            ProductCode = ConfigUtils.GetSetting("Product.Code", 1);
            ProductName = ConfigUtils.GetSetting("Product.Name", "Game");
            ProductServerId = ConfigUtils.GetSetting("Product.ServerId", 1);
            UserLoginDecodeKey = ConfigUtils.GetSetting("Product.ClientDesDeKey", "");
            ClientVersion = new Version(1, 0, 0);
            Version ver;
            if (Version.TryParse(ConfigUtils.GetSetting("Product.ClientVersion", "1.0.0"), out ver))
            {
                ClientVersion = ver;
            }

            PublishType = ConfigUtils.GetSetting("PublishType", "Release");
            ActionTimeOut = ConfigUtils.GetSetting("ActionTimeOut", 500);
            LanguageTypeName = ConfigUtils.GetSetting("Game.Language.TypeName", "Game.src.Locale.DefaultLanguage");

            ActionTypeName = ConfigUtils.GetSetting("Game.Action.TypeName");
            if (string.IsNullOrEmpty(ActionTypeName))
            {
                string assemblyName = ConfigUtils.GetSetting("Game.Action.AssemblyName", "GameServer.CsScript");
                if (!string.IsNullOrEmpty(assemblyName))
                {
                    ActionTypeName = assemblyName + ".Action.Action{0}," + assemblyName;
                }
            }
            ScriptTypeName = ConfigUtils.GetSetting("Game.Action.Script.TypeName", "Game.Script.Action{0}");
            EntityAssemblyName = ConfigUtils.GetSetting("Game.Entity.AssemblyName");
            DecodeFuncTypeName = ConfigUtils.GetSetting("Game.Script.DecodeFunc.TypeName", "");
            RemoteTypeName = ConfigUtils.GetSetting("Game.Remote.Script.TypeName", "Game.Script.Remote.{0}");
            AccountServerUrl = ConfigUtils.GetSetting("AccountServerUrl", "");
        }

        /// <summary>
        /// Game product code
        /// </summary>
        public int ProductCode { get; set; }
        /// <summary>
        ///
        /// </summary>
        public string ProductName { get; set; }
        /// <summary>
        ///
        /// </summary>
        public int ProductServerId { get; set; }

        /// <summary>
        /// Client ver
        /// </summary>
        public Version ClientVersion { get; set; }

        /// <summary>
        /// user login decode password key.
        /// </summary>
        public string UserLoginDecodeKey { get; set; }

        /// <summary>
        /// user encode password key to db.
        /// </summary>
        [Obsolete("Sns no use")]
        public string UserEncodeKey { get; set; }

        /// <summary>
        ///
        /// </summary>
        public string PublishType { get; set; }

        /// <summary>
        ///
        /// </summary>
        public int ActionTimeOut { get; set; }

        /// <summary>
        ///
        /// </summary>
        public string LanguageTypeName { get; set; }
        /// <summary>
        ///
        /// </summary>
        public string ActionTypeName { get; set; }

        /// <summary>
        ///
        /// </summary>
        public string RemoteTypeName { get; set; }
        /// <summary>
        ///
        /// </summary>
        public string DecodeFuncTypeName { get; set; }
        /// <summary>
        ///
        /// </summary>
        public string EntityAssemblyName { get; set; }
        /// <summary>
        ///
        /// </summary>
        public string ScriptTypeName { get; set; }
        /// <summary>
        ///
        /// </summary>
        public string AccountServerUrl { get; set; }

    }
}


text:
package org.kuali.rice.kim.api.type;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.apache.commons.lang.StringUtils;
import org.kuali.rice.core.api.CoreConstants;
import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
import org.kuali.rice.core.api.mo.ModelBuilder;
import org.kuali.rice.kim.api.KimConstants;
import org.w3c.dom.Element;

/**
 * An immutable representation of a {@link KimTypeContract}.
 *
 *
To construct an instance of a KimType, use the {@link KimType.Builder} class.

 *
 * @see KimTypeContract
 */
@XmlRootElement(name = KimType.Constants.ROOT_ELEMENT_NAME)
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = KimType.Constants.TYPE_NAME, propOrder = {
        KimType.Elements.ID,
        KimType.Elements.SERVICE_NAME,
        KimType.Elements.NAMESPACE_CODE,
        KimType.Elements.NAME,
        KimType.Elements.ATTRIBUTE_DEFNS,
        KimType.Elements.ACTIVE,
        CoreConstants.CommonElements.VERSION_NUMBER,
        CoreConstants.CommonElements.OBJECT_ID,
        CoreConstants.CommonElements.FUTURE_ELEMENTS
})
public final class KimType extends AbstractDataTransferObject implements KimTypeContract {
    private static final long serialVersionUID = 1L;

    @XmlElement(name = KimType.Elements.ID, required = false)
    private final String id;

    @XmlElement(name = KimType.Elements.SERVICE_NAME, required = false)
    private final String serviceName;

    @XmlElement(name = KimType.Elements.NAMESPACE_CODE, required = false)
    private final String namespaceCode;

    @XmlElement(name = KimType.Elements.NAME, required = false)
    private final String name;

    @XmlElementWrapper(name = Elements.ATTRIBUTE_DEFNS, required = false)
    @XmlElement(name = KimType.Elements.ATTRIBUTE_DEFN, required = false)
    private final List<KimTypeAttribute> attributeDefinitions;

    @XmlElement(name = KimType.Elements.ACTIVE, required = false)
    private final boolean active;

    @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
    private final Long versionNumber;

    @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
    private final String objectId;

    @SuppressWarnings("unused")
    @XmlAnyElement
    private final Collection<Element> _futureElements = null;

    /**
     * This constructor should never be called except during JAXB unmarshalling.
     */
    private KimType() {
        this.id = null;
        this.serviceName = null;
        this.namespaceCode = null;
        this.name = null;
        this.attributeDefinitions = Collections.<KimTypeAttribute>emptyList();
        this.active = false;
        this.versionNumber = Long.valueOf(1L);
        this.objectId = null;
    }

    private KimType(Builder builder) {
        this.id = builder.getId();
        this.serviceName = builder.getServiceName();
        this.namespaceCode = builder.getNamespaceCode();
        this.name = builder.getName();
        final List<KimTypeAttribute> temp = new ArrayList<KimTypeAttribute>();
        for (KimTypeAttribute.Builder attr : builder.getAttributeDefinitions()) {
            //associate each attribute with this kimType's id
            attr.setKimTypeId(this.id);
            temp.add(attr.build());
        }
        this.attributeDefinitions = Collections.unmodifiableList(temp);

        this.active = builder.isActive();
        this.versionNumber = builder.getVersionNumber();
        this.objectId = builder.getObjectId();
    }

    /**
     * Gets the KimTypeAttribute matching the id of it's KimAttribute.  If no attribute definition exists with that
     * id then null is returned.
     *
     *

     * If multiple exist with the same id then the first match is returned.  Since id
     * is supposed to be unique this should not be a problem in practice.
     *

     *
     * @param id the KimTypeAttribute.KimAttribute's id
     * @return the KimTypeAttribute or null
     * @throws IllegalArgumentException if the id is blank
     */
    public KimTypeAttribute getAttributeDefinitionById(String id) {
        if (StringUtils.isBlank(id)) {
            throw new IllegalArgumentException("id is blank");
        }

        if (this.attributeDefinitions != null) {
            for (KimTypeAttribute att : this.attributeDefinitions) {
                if (att != null && att.getKimAttribute() != null
                        && id.equals(att.getKimAttribute().getId())) {
                    return att;
                }
            }
        }
		return null;
	}

    /**
     * Gets the KimTypeAttribute matching the name of it's KimAttribute.  If no attribute definition exists with that
     * name then null is returned.
     *
     *

     * If multiple exist with the same name then the first match is returned.  Since name
     * is supposed to be unique this should not be a problem in practice.
     *

     *
     * @param name the KimTypeAttribute's name
     * @return the KimTypeAttribute or null
     * @throws IllegalArgumentException if the name is blank
     */
	public KimTypeAttribute getAttributeDefinitionByName(String name) {
        if (StringUtils.isBlank(name)) {
            throw new IllegalArgumentException("name is blank");
        }

        if (this.attributeDefinitions != null) {
            for (KimTypeAttribute att : this.attributeDefinitions) {
                if (att != null && att.getKimAttribute() != null
                        && name.equals(att.getKimAttribute().getAttributeName())) {
                    return att;
                }
            }
        }
		return null;
	}

    @Override
    public String getId() {
        return id;
    }

    @Override
    public String getServiceName() {
        return serviceName;
    }

    @Override
    public String getNamespaceCode() {
        return namespaceCode;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public List<KimTypeAttribute> getAttributeDefinitions() {
        return attributeDefinitions;
    }

    @Override
    public boolean isActive() {
        return active;
    }

    @Override
    public Long getVersionNumber() {
        return versionNumber;
    }

    @Override
    public String getObjectId() {
        return objectId;
    }

    /**
     * This builder constructs an KimType enforcing the constraints of the {@link KimTypeContract}.
     */
    public static final class Builder implements KimTypeContract, ModelBuilder, Serializable {
        private String id;
        private String serviceName;
        private String namespaceCode;
        private String name;
        private List<KimTypeAttribute.Builder> attributeDefinitions = new ArrayList<KimTypeAttribute.Builder>();
        private boolean active;
        private Long versionNumber;
        private String objectId;

        private Builder() {
        }

        /**
         * creates a KimType with the required fields.
         */
        public static Builder create() {
            return new Builder();
        }

        /**
         * creates a KimType from an existing {@link KimTypeContract}.
         */
        public static Builder create(KimTypeContract contract) {
        	if (contract == null) {
        		throw new IllegalArgumentException("contract was null");
        	}
            Builder builder = new Builder();
            builder.setId(contract.getId());
            builder.setServiceName(contract.getServiceName());
            builder.setNamespaceCode(contract.getNamespaceCode());
            builder.setName(contract.getName());

            if (contract.getAttributeDefinitions() != null) {
                final List<KimTypeAttribute.Builder> temp = new ArrayList<KimTypeAttribute.Builder>();
                for (KimTypeAttributeContract attr : contract.getAttributeDefinitions()) {
                    if ( attr != null ) {
                        temp.add(KimTypeAttribute.Builder.create(attr));
                    }
                }

                builder.setAttributeDefinitions(Collections.unmodifiableList(temp));
            }

            builder.setActive(contract.isActive());
            builder.setVersionNumber(contract.getVersionNumber());
            builder.setObjectId(contract.getObjectId());
            return builder;
        }

        @Override
        public String getId() {
            return id;
        }

        public void setId(final String id) {
            this.id = id;
        }

        @Override
        public String getServiceName() {
            return serviceName;
        }

        public void setServiceName(final String serviceName) {
            this.serviceName = serviceName;
        }

        @Override
        public String getNamespaceCode() {
            return namespaceCode;
        }

        public void setNamespaceCode(final String namespaceCode) {
            this.namespaceCode = namespaceCode;
        }

        @Override
        public String getName() {
            return name;
        }

        public void setName(final String name) {
            this.name = name;
        }

        @Override
        public List<KimTypeAttribute.Builder> getAttributeDefinitions() {
            return attributeDefinitions;
        }

        public void setAttributeDefinitions(final List<KimTypeAttribute.Builder> attributeDefinitions) {
            if (attributeDefinitions == null) {
                throw new IllegalArgumentException("attributeDefinitions is null");
            }

            this.attributeDefinitions = attributeDefinitions;
        }

        @Override
        public boolean isActive() {
            return active;
        }

        public void setActive(final boolean active) {
            this.active = active;
        }

        @Override
        public Long getVersionNumber() {
            return versionNumber;
        }

        public void setVersionNumber(final Long versionNumber) {
            this.versionNumber = versionNumber;
        }

        @Override
        public String getObjectId() {
            return objectId;
        }

        public void setObjectId(final String objectId) {
            this.objectId = objectId;
        }

        @Override
        public KimType build() {
            return new KimType(this);
        }
    }

    /**
     * Defines some internal constants used on this class.
     */
    static class Constants {
        static final String ROOT_ELEMENT_NAME = "kimType";
        static final String TYPE_NAME = "KimTypeType";
    }

    /**
     * A private class which exposes constants which define the XML element names to use
     * when this object is marshalled to XML.
     */
    static class Elements {
        static final String ID = "id";
        static final String SERVICE_NAME = "serviceName";
        static final String NAMESPACE_CODE = "namespaceCode";
        static final String NAME = "name";
        static final String ATTRIBUTE_DEFNS = "attributeDefinitions";
        static final String ATTRIBUTE_DEFN = "attributeDefinition";
        static final String ACTIVE = "active";
    }

    public static class Cache {
        public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + KimType.Constants.TYPE_NAME;
    }
}