$(document).ready(function(){
var assets = $.parseJSON('[{"Type":"Boat","Name":"Name","Official_Number":"Number","Length":78,"Breadth":34,"Depth":10,"Gross_Tons":222,"HP":2000,"Engine":"Engine","Built":2016,"Status":"Standby"},{"Type":"Barge","Name":"Name","Official_Number":"Number","Length":297.5,"Width":54,"Depth":12,"BBL":30000,"Heater":"Heater","Built":2015,"Status":"Standby"}]');
$.each(assets, function(index, value) {
var dom = jQuery('<div/>', {
class: value.Type.toLowerCase(),
style: 'cursor: move; margin-bottom: 0.5em;'
});
if (value.Type === 'Boat') {
dom.addClass('bg-success');
// Name
jQuery('<p>', {
class: 'font-weight-bold text-center',
text: value.Name
}).appendTo(dom);
// Official Number, Length, Breadth, and Depth
jQuery('<p>', {
class: 'text-center',
style: 'padding: 0; margin: 0;',
text: 'Official #' + value.Official_Number + ' ' + value.Length + "'x'" + value.Breadth + "'x'" + value.Depth + "'"
}).appendTo(dom);
// Gross Tons and HP
jQuery('<p>', {
class: 'text-center',
style: 'padding: 0; margin: 0;',
text: 'Gross Tons ' + value.Gross_Tons + ' | ' + value.HP + 'HP'
}).appendTo(dom);
// Engine and Built
jQuery('<p>', {
class: 'text-center',
style: 'padding: 0; margin: 0;',
text: value.Engine + ' Built in ' + value.Built
}).appendTo(dom);
} else {
dom.addClass('bg-danger');
// Name
jQuery('<p>', {
class: 'font-weight-bold text-center',
text: value.Name
}).appendTo(dom);
// Official Number, Length, Width, and Depth
jQuery('<p>', {
class: 'text-center',
style: 'padding: 0; margin: 0;',
text: 'Official #' + value.Official_Number + ' ' + value.Length + "'x'" + value.Width + "'x'" + value.Depth + "'"
}).appendTo(dom);
// Capacity and Built
jQuery('<p>', {
class: 'text-center',
style: 'padding: 0; margin: 0;',
text: value.Capacity + ' BBL | ' + ' Built in ' + value.Built
}).appendTo(dom);
// Heater
jQuery('<p>', {
class: 'text-center',
style: 'padding: 0; margin: 0;',
text: value.Heater
}).appendTo(dom);
}
$('.' + value.Type.toLowerCase() + '.' + value.Status.toLowerCase()).append(dom);
});
$(".col.boat").sortable({
coectWith: ".col.boat, .col.pair"
});
$(".col.barge").sortable({
coectWith: ".col.barge, .col.pair"
});
});
برچسب:
نویسنده: آیلین رضوانی