bookmarker.getState(function(state){ // Check if there are filters in the bookmark var filters = state.allFilters; if(filters != undefined) { // Iterate over all filters and find ones that no longer match their bookmarked categorical/numeric type var switchedVariables = []; var switchedVariableNames = []; for(var i=0; i < filters.length; i++) { var filter = filters[i]; var switchedToCategorical = category_columns.indexOf(filter.index) > -1 && filter.type == 'numeric'; var switchedToNumeric = category_columns.indexOf(filter.index) == -1 && filter.type == 'category'; if(switchedToCategorical || switchedToNumeric) { switchedVariables.push(i); switchedVariableNames.push(filter.name); } } if(switchedVariables.length) { // Alert user var message = "You made changes to the Categorial attribute of the following variables: "; message += switchedVariableNames.join(", "); message += ". If you continue, filters for these variables will be reset. Do you want to continue?"; dialog.confirm({ title: "Reset Filters?", message: message, ok: function() { save_new_parameters(); } }); } else { save_new_parameters(); } } else { save_new_parameters(); } function save_new_parameters(){ client.put_model_parameter({ mid: component._id, aid: "input-columns", value: input_columns, input: true, success: function() { client.put_model_parameter({ mid: component._id, aid: "output-columns", value: output_columns, input: true, success: function() { client.put_model_parameter({ mid: component._id, aid: "rating-columns", value: rating_columns, input: true, success: function() { client.put_model_parameter({ mid: component._id, aid: "category-columns", value: category_columns, input: true, success: function() { client.put_model_parameter({ mid: component._id, aid: "image-columns", value: image_columns, input: true, success: function() { document.location.reload(true); } }); } }); } }); } }); } }); } });
component.back = function() { var target = component.tab(); // Ask user if they want to cancel their compute job if(component.tab() == 7 && component.matrix_type() == 'compute') { dialog.confirm({ title: 'Stop Computing Distances?', message: 'To go back, you need to stop the compute distances job. Do you want to stop this job and go back?', ok: function(){ // Stop the compute job var contextData = ko.contextFor(document.getElementsByClassName('slycat-remote-interface')[0]).$data; var sid = contextData.remote.sid(); var jid = contextData.jid(); if(jid > -1 && sid !== null) { client.post_cancel_job({ sid: sid, jid: jid, success: function(){ go_back(); }, error: function(){ go_back(); } }); } else { go_back(); } }, cancel: function(){ return; } }); function go_back(){ target--; target--; component.tab(target); } } else { // Skip Select Table tabs if we are local if(component.tab() == 2 && component.ps_type() == 'local') { target--; } // Skip Compute Distances tab if we are on Select Distances tab else if(component.tab() == 6) { target--; target--; } // Skip Select Distances and Compute Distances tabs if we are doing local matrix else if(component.tab() == 7 && component.matrix_type() == 'local') { target--; target--; target--; } target--; component.tab(target); } };