<commit_before>@extends('backend/layouts/admin')

@section('scripts')
<script src="//cdn.jsdelivr.net/typeahead.js/0.9.3/typeahead.min.js" type="text/javascript"></script>
<script src="/assets/js/nestedSortable/jquery-sortable.js" type="text/javascript"></script>
<script src="http://twitter.github.com/hogan.js/builds/2.0.0/hogan-2.0.0.js"></script>
<script>



	$( document ).ready(function( $ ) {
		// var MyEngine = {
		// 	compile: function(template) {
		// 		console.log(template);
		// 		return {
		// 			render: function(context) {
		// 				return template.replace(/\{\{(\w+)\}\}/g, function (match,p1) { return context[p1]; });
		// 			}
		// 		};
		// 	}
		// };

		$('.typeahead').typeahead({
				prefetch: '/allusers'
			});

		$('#owner').focus()
		.keypress(function(e){
			var code = e.keyCode || e.which;
			if(code == 13) { //Enter keycode
				e.preventDefault();
				getUserInfo()

			}
		})

		$(".btn-getUserInfo").click(function(e){
			e.preventDefault();
			getUserInfo();
		})
		
		
		function getUserInfo(){
			$id = /\w+:(\d+)/gi.exec($("#owner").val())[1]
			// console.log($id);
			var cpaData;
			var assetData;
			var assetOrgainizerHtml = $('<div class="asset-orgainizer"><div class="organization-container"> <div class="toolbar"> <span><i class="fa fa-plus collection-add"></i></span> <span><i class="fa fa-minus collection-remove"></i></span> <span><i class="fa fa-arrows-v"></i></span> </div> <div class="organization-list"> <ol id="organization"></ol> </div> </div></div>');

			$.ajax({
				url: "/cpa/"+$id,
				dataType: "json",
				success:function(data){
					cpaData = data;
				}
			}).promise().done(function () {
				console.log($.type(cpaData));

				cpaDataFlag = $.type(cpaData) === "array";
				if (cpaDataFlag) {
					// assetOrgainizerHtml.append("<div class='organization-container'><div class='toolbar'><span><i class='fa fa-plus collection-add'></i></span><span><i class='fa fa-minus collection-remove'></i></span><span><i class='fa fa-arrows-v'></i></span></div><div class='organization-list'><ol id='organization'  class=''></ol></div></div>")

					$.each(cpaData, function(index, collection){
						assetOrgainizerHtml.find('#organization')
						.append('<li class="collection" data-collection-id="'+collection.id+'">'+collection.name+'<span><i class="fa fa-plus playlist-add"></i></span> <span><i class="fa fa-minus playlist-remove"></i></span> <hr> <ol> </ol> </li>')

						
						$.each(collection.playlists, function(index, playlist){
							console.log(playlist)

							assetOrgainizerHtml.find("[data-collection-id="+collection.id+"] ol").append("<li class='playlist' data-playlist-id='"+playlist.id+"'>"+playlist.name+" <ol></ol></li>")





							if (playlist.assets) {
								$.each(playlist.assets, function(index, asset){
									console.log(asset)

									assetOrgainizerHtml.find("[data-playlist-id="+playlist.id+"]")
									.append('<li class="asset" data-asset-id="'+asset.id+'">'+asset.name+'</li>')

								});
							};
						});
						
						if (collection.assets) {	
							$.each(collection.assets, function(index, asset){
								console.log(asset)


								
							});
						}
					});
				};
				


				
				$(".asset-orgainizer").replaceWith(assetOrgainizerHtml);
			});






		}




		$('.collection-add').live("click",function(e){
			$(e.target).closest('.organization-container').find('#organization')
			.prepend($('<li class="collection collection-new"><input class="input" type="text" placeholder="Collection Name" /><ol></ol></li>'));
		});
		$('.collection-remove').live( "click",function(e){
			$(e.target).closest('.organization-container').find('.collection-new:last')
			.remove();
		});

		$('.playlist-add').live( "click",function(e){
			$(e.target).closest('.collection').find("ol:first")
			.prepend($('<li class="playlist playlist-new "><input class="input" type="text" placeholder="Playlist Name"/><ol></ol></li>'));
		});

		$('.playlist-remove').live( "click",function(e){
			$(e.target).closest('.collection').find('.playlist-new:last').remove();
		});

		// CPA list
		$("#organization").sortable({
		// group: 'asset-orgainizer'

		})
	});
</script>
@stop

@section('css')
   <link href="/assets/js/nestedSortable/default.css" rel="stylesheet" type="text/css"/>
   <link href="/assets/css/typeahead.css" rel="stylesheet" type="text/css"/>
@stop

@section('content')
{{Breadcrumbs::render('createAsset')}}
<div class="page-header">
	<h1>
		Upload Asset for user

		<div class="pull-right">
			<a href="{{ route('assets') }}" class="btn btn-small btn-inverse"><i class="icon-circle-arrow-left icon-white"></i> Back</a>
		</div>
	</h1>
</div>


<form method="POST" action="{{action('AssetsController@store')}}" accept-charset="UTF-8" class="form-horizontal">



		<div class="row">
			<div class="col-md-4">
			 <div class="form-group">
				 <label class="control-label col-md-3">Owner</label>
					<div>
						<input id="owner" type="text" class="typeahead"> 
						<button  class="btn-getUserInfo btn btn-success">GO</button>
					</div><commit_msg>fix OL:first issue<commit_after>@extends('backend/layouts/admin')

@section('scripts')
<script src="//cdn.jsdelivr.net/typeahead.js/0.9.3/typeahead.min.js" type="text/javascript"></script>
<script src="/assets/js/nestedSortable/jquery-sortable.js" type="text/javascript"></script>
<script src="http://twitter.github.com/hogan.js/builds/2.0.0/hogan-2.0.0.js"></script>
<script>



	$( document ).ready(function( $ ) {
		// var MyEngine = {
		// 	compile: function(template) {
		// 		console.log(template);
		// 		return {
		// 			render: function(context) {
		// 				return template.replace(/\{\{(\w+)\}\}/g, function (match,p1) { return context[p1]; });
		// 			}
		// 		};
		// 	}
		// };

		$('.typeahead').typeahead({
				prefetch: '/allusers'
			});

		$('#owner').focus()
		.keypress(function(e){
			var code = e.keyCode || e.which;
			if(code == 13) { //Enter keycode
				e.preventDefault();
				getUserInfo()

			}
		})

		$(".btn-getUserInfo").click(function(e){
			e.preventDefault();
			getUserInfo();
		})


		function getUserInfo(){
			$id = /\w+:(\d+)/gi.exec($("#owner").val())[1]
			// console.log($id);
			var cpaData;
			var assetData;
			var assetOrgainizerHtml = $('<div class="asset-orgainizer"><div class="organization-container"> <div class="toolbar"> <span><i class="fa fa-plus collection-add"></i></span> <span><i class="fa fa-minus collection-remove"></i></span> <span><i class="fa fa-arrows-v"></i></span> </div> <div class="organization-list"> <ol id="organization"></ol> </div> </div></div>');

			$.ajax({
				url: "/cpa/"+$id,
				dataType: "json",
				success:function(data){
					cpaData = data;
				}
			}).promise().done(function () {
				console.log($.type(cpaData));

				cpaDataFlag = $.type(cpaData) === "array";
				if (cpaDataFlag) {
					// assetOrgainizerHtml.append("<div class='organization-container'><div class='toolbar'><span><i class='fa fa-plus collection-add'></i></span><span><i class='fa fa-minus collection-remove'></i></span><span><i class='fa fa-arrows-v'></i></span></div><div class='organization-list'><ol id='organization'  class=''></ol></div></div>")

					$.each(cpaData, function(index, collection){
						assetOrgainizerHtml.find('#organization')
						.append('<li class="collection" data-collection-id="'+collection.id+'">'+collection.name+'<span><i class="fa fa-plus playlist-add"></i></span> <span><i class="fa fa-minus playlist-remove"></i></span> <hr> <ol> </ol> </li>')


						$.each(collection.playlists, function(index, playlist){
							console.log(playlist)

							assetOrgainizerHtml.find("[data-collection-id="+collection.id+"] ol:first").append("<li class='playlist' data-playlist-id='"+playlist.id+"'>"+playlist.name+" <ol></ol></li>")





							if (playlist.assets) {
								$.each(playlist.assets, function(index, asset){
									console.log(asset)

									assetOrgainizerHtml.find("[data-playlist-id="+playlist.id+"]")
									.append('<li class="asset" data-asset-id="'+asset.id+'">'+asset.name+'</li>')

								});
							};
						});

						if (collection.assets) {
							$.each(collection.assets, function(index, asset){
								console.log(asset)



							});
						}
					});
				};




				$(".asset-orgainizer").replaceWith(assetOrgainizerHtml);
			});






		}




		$('.collection-add').live("click",function(e){
			$(e.target).closest('.organization-container').find('#organization')
			.prepend($('<li class="collection collection-new"><input class="input" type="text" placeholder="Collection Name" /><ol></ol></li>'));
		});
		$('.collection-remove').live( "click",function(e){
			$(e.target).closest('.organization-container').find('.collection-new:last')
			.remove();
		});

		$('.playlist-add').live( "click",function(e){
			$(e.target).closest('.collection').find("ol:first")
			.prepend($('<li class="playlist playlist-new "><input class="input" type="text" placeholder="Playlist Name"/><ol></ol></li>'));
		});

		$('.playlist-remove').live( "click",function(e){
			$(e.target).closest('.collection').find('.playlist-new:last').remove();
		});

		// CPA list
		$("#organization").sortable({
		// group: 'asset-orgainizer'

		})
	});
</script>
@stop

@section('css')
   <link href="/assets/js/nestedSortable/default.css" rel="stylesheet" type="text/css"/>
   <link href="/assets/css/typeahead.css" rel="stylesheet" type="text/css"/>
@stop

@section('content')
{{Breadcrumbs::render('createAsset')}}
<div class="page-header">
	<h1>
		Upload Asset for user

		<div class="pull-right">
			<a href="{{ route('assets') }}" class="btn btn-small btn-inverse"><i class="icon-circle-arrow-left icon-white"></i> Back</a>
		</div>
	</h1>
</div>


<form method="POST" action="{{action('AssetsController@store')}}" accept-charset="UTF-8" class="form-horizontal">



		<div class="row">
			<div class="col-md-4">
			 <div class="form-group">
				 <label class="control-label col-md-3">Owner</label>
					<div>
						<input id="owner" type="text" class="typeahead">
						<button  class="btn-getUserInfo btn btn-success">GO</button>
					</div>
{'fraction_non_alphanumeric': 0.23646977342435935, 'fraction_numerical': 0.003759770456119521, 'mean_word_length': 3.7656765676567656, 'pattern_counts': {'":': 0, '<': 207, '<?xml version=': 0, '>': 207, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6707217', 'n_tokens_mistral': 4113, 'n_tokens_neox': 3431, 'n_words': 489}