diff --git a/app/controllers/HomeController.coffee b/app/controllers/HomeController.coffee index 2b5fef8..6f5c7a4 100644 --- a/app/controllers/HomeController.coffee +++ b/app/controllers/HomeController.coffee @@ -13,19 +13,19 @@ class HomeController extends Spine.Site Institute.bind 'refresh', @render Project.on 'fetch', @render - + render: => totalStats = Institute.allStats() transcriptions = Project.current?.classification_count - progress = ((Project.current?.classification_count / (totalStats.total * 10)) * 100).toPrecision(3) user_count = Project.current?.user_count || 0 @html require('views/home/splash')() @append require('views/home/stats') + archiveCount: if Archive.count() > 0 then Archive.count() else 'loading' transcriptions: @formatNumber(transcriptions) || 'loading' - progress: unless progress is 'NaN' or progress is 'Infinity' then progress else 'loading' + #progress: unless progress is 'NaN' or progress is 'Infinity' then progress else 'loading' users: @formatNumber user_count @append require('views/home/content') diff --git a/app/controllers/archives/item.coffee b/app/controllers/archives/item.coffee index 868ca6b..654894b 100644 --- a/app/controllers/archives/item.coffee +++ b/app/controllers/archives/item.coffee @@ -2,6 +2,7 @@ Project = require 'zooniverse/models/project' Archive = require 'models/Archive' Badges = require 'models/Badge' +$ = window.jQuery class ArchivesItem extends Spine.Site className: 'ArchivesItem' @@ -29,12 +30,27 @@ class ArchivesItem extends Spine.Site super render: => + if @currentArchive? @html require('/views/archives/archiveShow') archive: @currentArchive user_count: @formatNumber Project.current?.user_count || 0 badges: Badges.badgesForProject(@currentArchive.slug()) - else + if @currentArchive.complete() + @disableStartTranscribing() + else @html require('/views/archives/archiveNotFound')() + disableStartTranscribing: => + btnStartTranscribing = $("#a-btn-start-transcribing") + btnStartTranscribing.addClass("disabled") + btnStartTranscribing.attr("disabled", true) + btnStartTranscribing.attr("href", "/") + btnStartTranscribing.text("No active images") + btnStartTranscribing.on( "click", (e) -> + e.preventDefault() + e.stopImmediatePropagation + ) + + module.exports = ArchivesItem \ No newline at end of file diff --git a/app/controllers/archives/list.coffee b/app/controllers/archives/list.coffee index 3051d72..92d927b 100644 --- a/app/controllers/archives/list.coffee +++ b/app/controllers/archives/list.coffee @@ -25,8 +25,8 @@ class ArchivesList extends Spine.Site $(e.currentTarget).find('.translucent-box:not(.disable)').stop().animate {top: 0}, {duration: 200} hideListDetails: (e) => - $(e.currentTarget).find('.translucent-box').stop().animate {top: '160px'}, {duration: 200} - + $(e.currentTarget).find('.translucent-box').stop().animate {top: '185px'}, {duration: 200} + render: (options = undefined) => archives = Archive.filter(options) diff --git a/app/controllers/interfaces.coffee b/app/controllers/interfaces.coffee index ac871a4..cb352cc 100644 --- a/app/controllers/interfaces.coffee +++ b/app/controllers/interfaces.coffee @@ -1,6 +1,8 @@ Archive = require 'models/Archive' +Institute = require 'models/Institute' Subject = require 'zooniverse/models/subject' User = require 'zooniverse/models/user' +Project = require 'zooniverse/models/project' class InterfaceController extends Spine.Controller preferences: {} @@ -41,18 +43,27 @@ class InterfaceController extends Spine.Controller saveClassification: (data) => @classification.annotate({step: annotation.stepTitle, value: annotation.value}) for annotation in data.toJSON() - # Sigh - # done = => - # unless User.current then return - # badges = User.current.badges - # userFetch = User.fetch() - - # userFetch.done => - # User.current.badges = badges - # @archive.checkBadges() - - @classification.send() - + + done = => + #throttle to allow async POST to suceed on backend before refresh of other data + setTimeout => + #refresh other data + Institute.fetch() + Project.fetch() + + #refresh User data, primarily to up the badges + unless User.current then return + badges = User.current.badges + userFetch = User.fetch() + + userFetch.done => + User.current.badges = badges + @archive?.checkBadges() + + , 500 + + @classification.send done + Subject.next() skipClassification: => diff --git a/app/models/Archive.coffee b/app/models/Archive.coffee index da38af8..b8ab0b5 100644 --- a/app/models/Archive.coffee +++ b/app/models/Archive.coffee @@ -8,6 +8,8 @@ class Archive extends Spine.Model @configure 'Archive', 'group_id', 'classification_count', 'name', 'metadata', 'complete', 'stats', 'categories' @belongsTo 'institute', 'models/Institute' @hasMany 'badges', 'models/Badge' + COMPLETION_FACTOR: 4 + classification_count: 0 @findBySlug: (slug) -> result = @select (archive) -> @@ -20,9 +22,7 @@ class Archive extends Spine.Model archive.categories.indexOf(params.type) != -1 or archive.categories.indexOf(_.str.capitalize(params.type)) != -1 else @all() - - classification_count: 0 - + addBadges: => for badge in badgeDefinitions if badge.collection is @slug() @@ -41,12 +41,24 @@ class Archive extends Spine.Model slug: -> (@name.replace /\s/g, "_").toLowerCase() - complete: => - @progress() is 100 - + transcriptions_needed: => + @stats.total * @COMPLETION_FACTOR + + # progress_strict reflects that historically the completion criteria changed + # from 10 to 4 transcriptions per image + progress_strict: => + unless @stats? then return 0 + Math.ceil ( (@stats.complete / @stats.total) * 100) + + # however in order to display a number that prgress reflects real time transcriptions + # we are displaying this number progress: => unless @stats? then return 0 - Math.ceil ((@stats.complete / @stats.total) * 100) + result = Math.ceil ( (@classification_count / @transcriptions_needed() ) * 100) + if result > 100 + return 100 + else + return result recordsComplete: => @formatNumber @stats.complete @@ -54,6 +66,10 @@ class Archive extends Spine.Model total: => @formatNumber @stats.total + complete: => + unless @stats? then return 0 + (@stats.complete is @stats.total) + # Private formatNumber: (n) -> return n unless n diff --git a/app/views/archives/archive.eco b/app/views/archives/archive.eco index c815824..771bdd2 100644 --- a/app/views/archives/archive.eco +++ b/app/views/archives/archive.eco @@ -2,10 +2,11 @@
  • -
    -
    - <%= @archive.progress() %>% -
    +

    + <% if @archive.complete(): %> + Check back. We'll load more images soon! + <% end %> +

    <%= @archive.metadata.snippet %> Check out this collection diff --git a/app/views/archives/archiveShow.eco b/app/views/archives/archiveShow.eco index 2909c5d..2f9e3db 100644 --- a/app/views/archives/archiveShow.eco +++ b/app/views/archives/archiveShow.eco @@ -2,52 +2,59 @@

    <%= @archive.institute().name %>

    <%= @archive.name %>

    + <% unless @archive.complete(): %>
    - <% unless @archive.progress() is 100: %> - START TRANSCRIBING - <% end %> -
    - <%= @archive.progress() %>% - DONE -
    + START TRANSCRIBING
    + <% end %>
    -
    -

    <%- @archive.metadata.description %>

    -
    -
    -
    -
      - <% if @archive.metadata.start_date and @archive.metadata.end_date: %> -
    • TEMPORAL RANGE<%= @archive.metadata.start_date %> / <%= @archive.metadata.end_date %>
    • - <% end %> - - <% if @archive.metadata.regions: %> -
    • GEOGRAPHIC CONTEXT <%= @archive.metadata.regions.join(" | ") %>
    • - <% end %> - -
    • TAXONOMIC COVERAGE<%= @archive.categories.join(" | ") %>
    • +
      + +
        + <% if @archive.metadata.start_date and @archive.metadata.end_date: %>
      • - PROGRESS - <%- @archive.recordsComplete() %> / <%- @archive.total() %> - -
        -
        - <%= @archive.progress() %>% - -
        + TEMPORAL RANGE<%= @archive.metadata.start_date %> / <%= @archive.metadata.end_date %>
      • - -
      - <% unless @archive.progress() is 100: %> - START TRANSCRIBING <% end %> -
      + <% if @archive.metadata.regions: %> +
    • GEOGRAPHIC CONTEXT <%= @archive.metadata.regions.join(" | ") %>
    • + <% end %> + +
    • TAXONOMIC COVERAGE<%= @archive.categories.join(" | ") %>
    • +
    • +
      + PROGRESS + Total Images: <%- @archive.total() %> + Active Images: <%- @archive.stats.active %> + Complete Images: <%- @archive.stats.complete %> +
      +
    • +
    • + + <%- @archive.classification_count %> / <%- @archive.transcriptions_needed() %> transcriptions needed. + +
      +
      + <%= @archive.progress() %>% +
      +
    • +
    • + <%# see dynamic logic on ArchiveItem.render() when archive is complete %> + START TRANSCRIBING +
    • +
    • + Notes on our numbers. +
    • +
    +
    +
    +

    <%- @archive.metadata.description %>

    @@ -82,7 +89,7 @@
  • AVG. DIFFICULTY<%= @archive.metadata.difficulty %>
  • - <% unless @archive.progress() is 100: %> + <% unless @archive.complete(): %>