Skip to content

Instantly share code, notes, and snippets.

@acid
Created July 13, 2010 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acid/474609 to your computer and use it in GitHub Desktop.
Save acid/474609 to your computer and use it in GitHub Desktop.
addWorksListener($('.commodity_works'));
function addWorksListener (obj) {
obj.change(function () {
if ( $('.commodity_works').size() == 1 ) {
var id = $('#commodity_works').val();
pasteDataFromWork(id);
} else {
$('.commodity_works').each( function() {
$.getJSON( 'http://fileservr.technoload.abc:3000/works/' + $(this).val() + '/filetype.json', function (data,result) {
if ( result == 'success') {
if ( type == '' ) {
type = data.filetype.title;
}
if ( type != data.filetype.title ) {
type = false ;
}
type_check_iterations = type_check_iterations + 1;
if ( type_check_iterations == $('.commodity_works').length ) {
if ( (type == '') || (type == false ) ) {
alert ('#{ t("fileservr.commodities.new.noConversionOfDifferentTypes") }');
} else {
switch (type) {
case 'audio':
$('#resolution').html('#{ escape_javascript( render :partial => "resolutions", :locals => { :type => 'audio' } ) }');
break;
case 'video':
$('#resolution').html('#{ escape_javascript( render :partial => "resolutions", :locals => { :type => 'video' } ) }');
break;
case 'image':
$('#resolution').html('yeahaw!');
break;
}
}
type = '';
changePreviews();
}
}
});
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment