(function (window, $) { function submitJob(userId, syncOptions, form) { if (!userId) { throw new Error('userId cannot be null'); } if (!syncOptions) { throw new Error('syncOptions cannot be null'); } if (!form) { throw new Error('form cannot be null'); } var target = $('#selectSyncTarget', form).val(); if (!target) { Dashboard.alert(Globalize.translate('MessagePleaseSelectDeviceToSyncTo')); return; } var options = { userId: userId, TargetId: target, Quality: $('#selectQuality', form).val() || null, Name: $('#txtSyncJobName', form).val(), SyncNewContent: $('#chkSyncNewContent', form).checked(), UnwatchedOnly: $('#chkUnwatchedOnly', form).checked(), ItemLimit: $('#txtItemLimit').val() || null, ParentId: syncOptions.ParentId, Category: syncOptions.Category }; if (syncOptions.items && syncOptions.items.length) { options.ItemIds = (syncOptions.items || []).map(function (i) { return i.Id || i; }).join(','); } ApiClient.ajax({ type: "POST", url: ApiClient.getUrl("Sync/Jobs"), data: JSON.stringify(options), contentType: "application/json" }).done(function () { $('.syncPanel').panel('close'); $(window.SyncManager).trigger('jobsubmit'); Dashboard.alert(Globalize.translate('MessageSyncJobCreated')); }); } function showSyncMenu(options) { var userId = Dashboard.getCurrentUserId(); ApiClient.getJSON(ApiClient.getUrl('Sync/Options', { UserId: userId, ItemIds: (options.items || []).map(function (i) { return i.Id || i; }).join(','), ParentId: options.ParentId, Category: options.Category })).done(function (result) { var targets = result.Targets; var html = '