Skip to content

Commit

Permalink
Merge pull request #196 from wooey/js-cleanup
Browse files Browse the repository at this point in the history
Cleanup unused js and fix some minor issues
  • Loading branch information
Chris7 committed Dec 7, 2017
2 parents 363ff13 + f4a81bf commit 772c4bd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 45 deletions.
12 changes: 8 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ environment:
DJANGO: "Django==1.7.*"
- PYTHON: "C:/Python27"
DJANGO: "Django==1.8.*"

# keep this to just maintain the latest version
- PYTHON: "C:/Python27"
DJANGO: "Django"
DJANGO: "Django==1.9.*"
- PYTHON: "C:/Python27"
DJANGO: "Django==1.10.*"

# The latest version of Django is no longer python2 compatible
#- PYTHON: "C:/Python27"
# DJANGO: "Django"

- PYTHON: "C:/Python34"
DJANGO: "Django==1.7.*"
Expand Down Expand Up @@ -41,8 +45,8 @@ init:
install:
- ps: (new-object net.webclient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', 'C:/get-pip.py')
- "%PYTHON%/python.exe C:/get-pip.py"
- "%PYTHON%/Scripts/pip.exe install %DJANGO%"
- "%PYTHON%/Scripts/pip.exe install -r requirements.txt"
- "%PYTHON%/Scripts/pip.exe install --upgrade %DJANGO%"
- "%PYTHON%/Scripts/pip.exe install -e ."
# setup our path to include python scripts
- cmd: SET PATH=%PATH%;%PYTHON%/Scripts
Expand Down
43 changes: 3 additions & 40 deletions wooey/templates/wooey/scripts/script_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ <h3 id="wooey-script-title">{{ script.script_name }}</h3>
$(wooey_multiple_selector).parent().each(
function(element, value){
var $wooey_multiples = $(value).find(wooey_multiple_selector);
if($wooey_multiples.length != 1) {
if($wooey_multiples.length !== 1) {
for (var i = 0; i < $wooey_multiples.length; i++) {
var $remove_button = removeMultiInput();
$remove_button.appendTo($wooey_multiples[i]);
Expand All @@ -151,15 +151,15 @@ <h3 id="wooey-script-title">{{ script.script_name }}</h3>
var $containers = $this.siblings(wooey_multiple_selector);
// check the choice limit, are we at it?
var choice_limit = $this.data(wooey_choice_limit);
if(choice_limit && ($containers.length == choice_limit)){
if(choice_limit && ($containers.length === choice_limit)){
// give a notice
maxChoices($this);
return;
}

var $container = $containers.first();
// if the container doesn't have a remove button since it's the first one, add one
if($container.find(wooey_remove_selector).length == 0){
if($container.find(wooey_remove_selector).length === 0){
removeMultiInput().appendTo($container);
}
var $new_target = $container.clone();
Expand Down Expand Up @@ -204,49 +204,12 @@ <h3 id="wooey-script-title">{{ script.script_name }}</h3>
return $remove_input;
};

var loadWooeyScript = function(url, params, form){
$.get(url, params, function(data){
form.attr('action', data.action);
var $wooey_tabs = form.find('#wooey-script-tabs');
var $wooey_content = form.find('#wooey-script-content');
for(var i=0;i<data.groups.length;i++){
$wooey_tabs.append('<li class="wooey-dynamic-tabs" role="presentation"><a href="#wooey_dynamic_tab'+i+'" aria-controls="profile" role="tab" data-toggle="tab">'+data.groups[i].group_name+'</a></li>');
var new_panel = $('<div role="tabpanel" class="tab-pane wooey-dynamic-tabs" id="wooey_dynamic_tab'+i+'"></div>');
new_panel.html(data.groups[i].form);
$wooey_content.append(new_panel);
}
var $first = $('a[href="#wooey_dynamic_tab0"]');
if($first.length)
$first.trigger('click');
initializeWooeyScript();
}, "json");
};

var updateScriptInfo = function(url){
// set the details of what script we clicked
$('.wooey-dynamic-tabs').remove();
var $scriptBox = $("a[data-href='"+url+"']");
var title = $scriptBox.find('.wooey-script-title').text();
var desc = $scriptBox.find('.wooey-script-description').text();
$('#wooey-script-description').text(desc);
var $title = $('#wooey-script-title');
$title.text(title);
var currentTop = $(document).scrollTop();
var scriptTop = $title.closest('.center-div').offset().top;
if (currentTop > scriptTop)
window.scrollTo(0, scriptTop);
};

{% if job_info %}
// Track file changes
$("input:file").change(function (){
var fileName = $(this).val();
filesUploaded[$(this).attr('name')] = fileName;
});
var $jobform = $('#wooey-job-form');
updateScriptInfo('{{ job_info.data_url }}');
loadWooeyScript('{{ job_info.url }}', {job_id: '{{ job_info.job_id }}'}, $jobform);
$jobform.find('#wooey_clone_job_id').val("{{ job_info.job_id }}");
{% endif %}
initializeWooeyScript();

Expand Down
2 changes: 1 addition & 1 deletion wooey/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_context_data(self, **kwargs):
if job_id:
job = WooeyJob.objects.get(pk=job_id)
if job.user is None or (self.request.user.is_authenticated() and job.user == self.request.user):
context['job_info'] = {'job_id': job_id, 'url': job.get_resubmit_url(), 'data_url': job.script_version.script.get_url()}
context['job_info'] = {'job_id': job_id}

for i in job.get_parameters():
value = i.value
Expand Down

0 comments on commit 772c4bd

Please sign in to comment.