# HG changeset patch # User Nattee Niparnan # Date 2016-07-26 05:23:26 # Node ID 10160025d8ee0a8d40b517921f0d9f60d57b7cb6 # Parent f8d309d2e37ed5d5c0e1096c154075eaf245201e - countdown timer diff --git a/Gemfile b/Gemfile --- a/Gemfile +++ b/Gemfile @@ -47,6 +47,7 @@ gem 'jquery-ui-sass-rails' gem 'jquery-timepicker-addon-rails' gem 'jquery-tablesorter' +gem 'jquery-countdown-rails' #syntax highlighter gem 'rouge' diff --git a/Gemfile.lock b/Gemfile.lock --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,6 +71,7 @@ i18n (0.7.0) in_place_editing (1.2.0) journey (1.0.4) + jquery-countdown-rails (2.0.2) jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) @@ -182,6 +183,7 @@ haml haml-rails in_place_editing + jquery-countdown-rails jquery-rails jquery-tablesorter jquery-timepicker-addon-rails diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,7 +17,6 @@ //= require moment //= require bootstrap-sortable //= require select2 -//= require custom //= require ace-rails-ap //= require ace/mode-c_cpp //= require ace/mode-ruby @@ -25,7 +24,15 @@ //= require ace/mode-javascript //= require ace/mode-java //= require ace/theme-merbivore - +//= require custom +//= require jquery.countdown +//-------------- addition from local_jquery ----------- +//= require jquery.ui.datepicker +//= require jquery.ui.slider +//= require jquery-ui-timepicker-addon +//= require jquery-tablesorter +//= require best_in_place +//= require best_in_place.jquery-ui // since this is after blank line, it is not downloaded //x= require prototype diff --git a/app/assets/javascripts/custom.js.coffee b/app/assets/javascripts/custom.js.coffee --- a/app/assets/javascripts/custom.js.coffee +++ b/app/assets/javascripts/custom.js.coffee @@ -14,7 +14,7 @@ $ -> $(".select2").select2() #$(".bootstrap-switch").bootstrapSwitch() - $(".bootstrap-toggle").bootstrapToggle() + #$(".bootstrap-toggle").bootstrapToggle() $('.btn-file :file').on 'fileselect', (event, numFiles, label) -> input = $(this).parents('.input-group').find(':text') log = if numFiles > 1 then numFiles + ' files selected' else label @@ -38,10 +38,15 @@ target.text '...' return + #ace editor - e = ace.edit("editor") - e.setTheme('ace/theme/merbivore') - e.getSession().setTabSize(2) - e.getSession().setUseSoftTabs(true) + if $("#editor").length > 0 + e = ace.edit("editor") + e.setTheme('ace/theme/merbivore') + e.getSession().setTabSize(2) + e.getSession().setUseSoftTabs(true) + + #best in place + jQuery(".best_in_place").best_in_place() return diff --git a/app/assets/stylesheets/application.css.sass b/app/assets/stylesheets/application.css.sass --- a/app/assets/stylesheets/application.css.sass +++ b/app/assets/stylesheets/application.css.sass @@ -17,12 +17,12 @@ @import jquery.ui.all @import jquery.ui.core -@import jquery.ui.core @import jquery.ui.theme @import jquery.ui.datepicker @import jquery.ui.slider @import jquery-ui-timepicker-addon @import jquery-tablesorter/theme.metro-dark +@import jquery.countdown @import tablesorter-theme.cafe //bootstrap diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -134,6 +134,7 @@ end end + def user_title_bar(user) header = '' time_left = '' diff --git a/app/views/configurations/index.html.haml b/app/views/configurations/index.html.haml --- a/app/views/configurations/index.html.haml +++ b/app/views/configurations/index.html.haml @@ -1,5 +1,5 @@ -- content_for :header do - = javascript_include_tag 'local_jquery' +/- content_for :header do +/ = javascript_include_tag 'local_jquery' %h1 System configuration @@ -13,9 +13,11 @@ - @grader_configuration = conf %tr{:class => cycle("info-odd", "info-even")} %td - = in_place_editor_field :grader_configuration, :key, {}, :rows=>1 + /= in_place_editor_field :grader_configuration, :key, {}, :rows=>1 + = @grader_configuration.key %td - = in_place_editor_field :grader_configuration, :value_type, {}, :rows=>1 + /= in_place_editor_field :grader_configuration, :value_type, {}, :rows=>1 + = @grader_configuration.value_type %td = best_in_place @grader_configuration, :value, ok_button: "ok", cancel_button: "cancel" %td= conf.description diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -18,6 +18,19 @@ = add_menu("Self Test", 'test', 'index') - if GraderConfiguration['right.user_hall_of_fame'] = add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof') + / display MODE button (with countdown in contest mode) + - if GraderConfiguration.analysis_mode? + %div.navbar-btn.btn.btn-success#countdown= "ANALYSIS MODE" + - elsif GraderConfiguration.time_limit_mode? + - if @current_user.contest_finished? + %div.navbar-btn.btn.btn-danger#countdown= "Contest is over" + - elsif !@current_user.contest_started? + %div.navbar-btn.btn.btn-primary#countdown= (t 'title_bar.contest_not_started') + - else + %div.navbar-btn.btn.btn-primary#countdown asdf + :javascript + $("#countdown").countdown({until: "+#{@current_user.contest_time_left.to_i}s", layout: 'Time left: {hnn}:{mnn}:{snn}'}); + / admin section - if (@current_user!=nil) and (session[:admin]) %li.dropdown %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} @@ -45,8 +58,6 @@ =link_to "#{ungraded} backlogs!", grader_list_path, class: 'navbar-btn btn btn-default btn-warning', data: {toggle: 'tooltip'},title: 'Number of ungraded submission' - =link_to 'Contest Mode, time remain: 00:20:33',grader_list_path, - class: 'navbar-btn btn btn-primary' %ul.nav.navbar-nav.navbar-right = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help') diff --git a/app/views/user_admin/index.html.haml b/app/views/user_admin/index.html.haml --- a/app/views/user_admin/index.html.haml +++ b/app/views/user_admin/index.html.haml @@ -22,6 +22,28 @@ = text_field 'user', 'email', :size => 10,class: 'form-control' =submit_tag "Create", class: 'btn btn-primary' +.panel.panel-primary + .panel-title.panel-heading + Import from site management + .panel-body + = form_tag( {method: 'post',multipart: true, action: 'import'}, {class: 'form-inline'}) do + .form-group + = label_tag 'user_login', 'Login' + = text_field 'user', 'login', :size => 10,class: 'form-control' + .form-group + = label_tag 'user_full_name', 'Full Name' + = text_field 'user', 'full_name', :size => 10,class: 'form-control' + .form-group + = label_tag 'user_password', 'Password' + = text_field 'user', 'password', :size => 10,class: 'form-control' + .form-group + = label_tag 'user_password_confirmation', 'Confirm' + = text_field 'user', 'password_confirmation', :size => 10,class: 'form-control' + .form-group + = label_tag 'user_email', 'email' + = text_field 'user', 'email', :size => 10,class: 'form-control' + =submit_tag "Create", class: 'btn btn-primary' + .submitbox %b Import from site management = form_tag({:action => 'import'}, :multipart => true) do