<commit_before><!DOCTYPE html>
<html lang="en">
<head>
	<title>Spark Sample Application - Show My Assets - gallery view</title>
	<meta charset="utf-8">

	<!-- fonts -->
	<link href='//fonts.googleapis.com/css?family=Open+Sans:300,600,400' rel='stylesheet' type='text/css'>

	<!-- Bootstrap core CSS -->
	<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">

	<!-- Common styles -->
	<link href="../../../assets/css/common.css" rel="stylesheet">

	<style>
		.modal-header {
			position: relative;
			padding: 8px 20px;
		}

		.modal-header .layouts {
			position: absolute;
			right: 0;
			background-color: #ffffff;
			padding-left: 10px;
		}

		.modal-header .layouts a {
			border-left: 1px solid lightgrey;
			margin-left: 6px;
			padding: 4px 0 0 10px;
		}

		#empty-assets {
			background-color: #F8F8F8;
			text-align: center;
		}

		#empty-assets p {
			padding: 20px 0;
			color: darkgray;
		}

		#empty-assets a {
			margin: 20px 0;
		}

		.dropdown i {
			cursor: pointer;
			position: absolute;
			left: -10px;
		}

		.si-asset-icon {
			margin-right: 8px;
		}

		.box {
			margin-bottom: 20px;
			height: 190px;
		}

		.text a {
			padding: 8px;
			display: block;
			color: #333333;
		}

		.text a:hover {
			color: #333333;
		}

		.text .si-asset-icon {
			margin-right: 10px;
		}

		#assets-gallery {
			padding-top: 20px;
			overflow-y: auto;
			height: 460px;
		}

	</style>

</head>

<body>
<div class="container">

	<div class="spinner"></div>

	<div class="hidden" id="assets">
		<div id="assets-gallery">

		</div>
	</div>

	<div class="hidden" id="empty-assets">
		<p>Assets are objects referencing all the files and data related to a 3D model.<br/>
			They are equivelent to a project or a folder with metadata.
		</p>

		<div class="img">
			<img src="../../../assets/img/my_assets_illustration.png" alt="my assets illustrations"/>
		</div>
		<a class="spark_btn" href="../create-asset/">Create your first Asset</a>
	</div>

</div>
<!-- /container -->


<script type="text/javascript" charset="utf-8" src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" charset="utf-8"
        src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

<!-- common scripts -->
<script type="text/javascript" charset="utf-8" src="../../../assets/scripts/common.js"></script>

<!-- spark sdk -->
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/config/Constants.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/utilities/Helpers.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/Request.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/Client.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/drive/Members.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/drive/Assets.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/drive/Files.js"></script>

<!-- OR use the minified version
<script type="text/javascript" charset="utf-8" src="//spark-dev-portal-stg.s3.amazonaws.com/sdk/autodesk-spark-sdk-latest.min.js"></script>
-->

<!-- your config file -->
<script type="text/javascript" charset="utf-8" src="../../../assets/scripts/config.js"></script>

<!-- Enable broadcasting events and logging requests to top window -->
<script type="text/javascript" charset="utf-8" src="../../../plugins/broadcaster/eventBroadcaster.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../plugins/ajaxlogger/ajaxCallListener.js"></script>

<script>

	//log http requests
	ajaxCallListenerFromIframe();


	//Init the Spark Client
	var APP_KEY = CLIENT_ID || '',
			GUEST_TOKEN_URL = GUEST_TOKEN_URL || 'http://localhost:3000/guest_token',
			ACCESS_TOKEN_URL = ACCESS_TOKEN_URL || 'http://localhost:3000/access_token';

	ADSKSpark.Client.initialize(APP_KEY,// Your app key
			GUEST_TOKEN_URL,// The guest token endpoint that is implemented by your server (i.e. http://example.com/guest_token)
			ACCESS_TOKEN_URL,// The access token endpoint that is implemented by your server (i.e. http://example.com/access_token)
			ADSKSpark.Constants.API_HOST_SANDBOX // api host - production or sandbox
	);


	/**
	 * Loop through the gallery
	 * @param index
	 * @param item
	 */
	function loopGallery(index, item) {
		var imgUrlRow, imgUrlThumb;
		imgUrlRow = imgUrlThumb = item.thumb_path_prefix;
		if (imgUrlRow.indexOf('FullPreview/') < 0) {
			imgUrlThumb += 'Medium.jpg';
		}

		var box = $('<div class="col-xs-3 box box-' + index + '"></div>');
		var view = $('<div class="view thumb"></div>');
		var text = $('<div class="text"><a title="' + item.asset_name + '" href="../show-asset/index.html?assetId=' + item.asset_id + '">' +
		'<i class="spark_icon si-asset-icon"></i>' + common.maxLength(item.asset_name, 7) + '</a></div>');

		$('#assets-gallery').append(box);
		box.append(view);

		view.prepend('<img class="img" src="' + imgUrlThumb + '" alt="' + item.asset_name + '"/>');
		box.append(text);
	}

	function loadAssets(page,conditions){
		conditions = conditions || {};
		conditions.limit = 24;
		conditions.offset = 24*(page-1);

		return ADSKSpark.Assets.getPublicAssetsByConditions(conditions).then(function (response) {
			console.info('my assets:', response);
			$('#assetsTbody').empty();

			if (response.count) {
				$('#assets').removeClass('hidden');

				$.each(response.assets, function (index, item) {
					loopGallery(index, item);
				});
			} else {
				$('#empty-assets').removeClass('hidden');<commit_msg>load more assets in 1 call<commit_after><!DOCTYPE html>
<html lang="en">
<head>
	<title>Spark Sample Application - Show My Assets - gallery view</title>
	<meta charset="utf-8">

	<!-- fonts -->
	<link href='//fonts.googleapis.com/css?family=Open+Sans:300,600,400' rel='stylesheet' type='text/css'>

	<!-- Bootstrap core CSS -->
	<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">

	<!-- Common styles -->
	<link href="../../../assets/css/common.css" rel="stylesheet">

	<style>
		.modal-header {
			position: relative;
			padding: 8px 20px;
		}

		.modal-header .layouts {
			position: absolute;
			right: 0;
			background-color: #ffffff;
			padding-left: 10px;
		}

		.modal-header .layouts a {
			border-left: 1px solid lightgrey;
			margin-left: 6px;
			padding: 4px 0 0 10px;
		}

		#empty-assets {
			background-color: #F8F8F8;
			text-align: center;
		}

		#empty-assets p {
			padding: 20px 0;
			color: darkgray;
		}

		#empty-assets a {
			margin: 20px 0;
		}

		.dropdown i {
			cursor: pointer;
			position: absolute;
			left: -10px;
		}

		.si-asset-icon {
			margin-right: 8px;
		}

		.box {
			margin-bottom: 20px;
			height: 190px;
		}

		.text a {
			padding: 8px;
			display: block;
			color: #333333;
		}

		.text a:hover {
			color: #333333;
		}

		.text .si-asset-icon {
			margin-right: 10px;
		}

		#assets-gallery {
			padding-top: 20px;
			overflow-y: auto;
			height: 460px;
		}

	</style>

</head>

<body>
<div class="container">

	<div class="spinner"></div>

	<div class="hidden" id="assets">
		<div id="assets-gallery">

		</div>
	</div>

	<div class="hidden" id="empty-assets">
		<p>Assets are objects referencing all the files and data related to a 3D model.<br/>
			They are equivelent to a project or a folder with metadata.
		</p>

		<div class="img">
			<img src="../../../assets/img/my_assets_illustration.png" alt="my assets illustrations"/>
		</div>
		<a class="spark_btn" href="../create-asset/">Create your first Asset</a>
	</div>

</div>
<!-- /container -->


<script type="text/javascript" charset="utf-8" src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" charset="utf-8"
        src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

<!-- common scripts -->
<script type="text/javascript" charset="utf-8" src="../../../assets/scripts/common.js"></script>

<!-- spark sdk -->
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/config/Constants.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/utilities/Helpers.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/Request.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/Client.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/drive/Members.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/drive/Assets.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../vendor/spark-js-sdk/sdk/src/drive/Files.js"></script>

<!-- OR use the minified version
<script type="text/javascript" charset="utf-8" src="//spark-dev-portal-stg.s3.amazonaws.com/sdk/autodesk-spark-sdk-latest.min.js"></script>
-->

<!-- your config file -->
<script type="text/javascript" charset="utf-8" src="../../../assets/scripts/config.js"></script>

<!-- Enable broadcasting events and logging requests to top window -->
<script type="text/javascript" charset="utf-8" src="../../../plugins/broadcaster/eventBroadcaster.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../plugins/ajaxlogger/ajaxCallListener.js"></script>

<script>

	//log http requests
	ajaxCallListenerFromIframe();


	//Init the Spark Client
	var APP_KEY = CLIENT_ID || '',
			GUEST_TOKEN_URL = GUEST_TOKEN_URL || 'http://localhost:3000/guest_token',
			ACCESS_TOKEN_URL = ACCESS_TOKEN_URL || 'http://localhost:3000/access_token';

	ADSKSpark.Client.initialize(APP_KEY,// Your app key
			GUEST_TOKEN_URL,// The guest token endpoint that is implemented by your server (i.e. http://example.com/guest_token)
			ACCESS_TOKEN_URL,// The access token endpoint that is implemented by your server (i.e. http://example.com/access_token)
			ADSKSpark.Constants.API_HOST_SANDBOX // api host - production or sandbox
	);


	/**
	 * Loop through the gallery
	 * @param index
	 * @param item
	 */
	function loopGallery(index, item) {
		var imgUrlRow, imgUrlThumb;
		imgUrlRow = imgUrlThumb = item.thumb_path_prefix;
		if (imgUrlRow.indexOf('FullPreview/') < 0) {
			imgUrlThumb += 'Medium.jpg';
		}

		var box = $('<div class="col-xs-3 box box-' + index + '"></div>');
		var view = $('<div class="view thumb"></div>');
		var text = $('<div class="text"><a title="' + item.asset_name + '" href="../show-asset/index.html?assetId=' + item.asset_id + '">' +
		'<i class="spark_icon si-asset-icon"></i>' + common.maxLength(item.asset_name, 7) + '</a></div>');

		$('#assets-gallery').append(box);
		box.append(view);

		view.prepend('<img class="img" src="' + imgUrlThumb + '" alt="' + item.asset_name + '"/>');
		box.append(text);
	}

	function loadAssets(page,conditions){
		conditions = conditions || {};
		conditions.limit = 48;
		conditions.offset = 48*(page-1);

		return ADSKSpark.Assets.getPublicAssetsByConditions(conditions).then(function (response) {
			console.info('my assets:', response);
			$('#assetsTbody').empty();

			if (response.count) {
				$('#assets').removeClass('hidden');

				$.each(response.assets, function (index, item) {
					loopGallery(index, item);
				});
			} else {
				$('#empty-assets').removeClass('hidden');
{'fraction_non_alphanumeric': 0.20229369664568422, 'fraction_numerical': 0.017504527032853323, 'mean_word_length': 3.5093312597200623, 'pattern_counts': {'":': 0, '<': 165, '<?xml version=': 0, '>': 163, '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': '2130221', 'n_tokens_mistral': 4521, 'n_tokens_neox': 3917, 'n_words': 790}