class ShareModel
constructor: ->
questionaireView = new QuestionnaireView
@previewImages =
shareCurrent: -> ShareModel::getSingle(ModelView::getCurrentImage(),'current',questionaireView.weight(),questionaireView.weightUnits())
shareGoal: -> ShareModel::getSingle(ModelView::getGoalImage(),'goal',questionaireView.goal(),questionaireView.weightUnits())
shareSideBySide: -> ShareModel::getDualImage(questionaireView.weight(),questionaireView.goal(),questionaireView.weightUnits())
getSingle:(image,caption,weight,units) ->
url = "http://..."
url += "?current=#{image}"
url += "&template=single"
url += "&text=#{caption}"
url += "&weight=#{weight+units}"
getDualImage:(current,goal,units) ->
url = "http://..."
url += "?current=#{ModelView::getCurrentImage()}&goal=#{ModelView::getGoalImage()}"
url += "&template=side_by_side"
url += "¤t_weight=#{current+units}&goal_weight=#{goal+units}"
Next time, add a brief description of what the code actually does. Sure, we can read it, but it still leaves a lot of questions. For instance, the Anyway, here are some observations, but I don't know enough of the context to fully refactor your code.
As mentioned, I'd provide more code, but there's a lot that could be done differently, and I don't know enough of the context to know what will work, and what won't. | ||||
|