forked from fixin.me/fixin.me
		
	Merging from main master to my repo master. #4
@ -132,28 +132,4 @@ module ApplicationHelper
 | 
				
			|||||||
  def disabled_attributes(disabled)
 | 
					  def disabled_attributes(disabled)
 | 
				
			||||||
    disabled ? {disabled: true, aria: {disabled: true}, tabindex: -1} : {}
 | 
					    disabled ? {disabled: true, aria: {disabled: true}, tabindex: -1} : {}
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					 | 
				
			||||||
  private
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  # Converts value to HTML formatted scientific notation
 | 
					 | 
				
			||||||
  def scientifize(d)
 | 
					 | 
				
			||||||
    sign, coefficient, base, exponent = d.split
 | 
					 | 
				
			||||||
    return 'NaN' unless sign
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    result = (sign == -1 ? '-' : '')
 | 
					 | 
				
			||||||
    unless coefficient == '1' && sign == 1
 | 
					 | 
				
			||||||
      if coefficient.length > 1
 | 
					 | 
				
			||||||
        result += coefficient.insert(1, '.')
 | 
					 | 
				
			||||||
      elsif
 | 
					 | 
				
			||||||
        result += coefficient
 | 
					 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
      if exponent != 1
 | 
					 | 
				
			||||||
        result += "×"
 | 
					 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
    if exponent != 1
 | 
					 | 
				
			||||||
      result += "10<sup>% d</sup>" % [exponent-1]
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
    result.html_safe
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@
 | 
				
			|||||||
      onclick: 'this.blur();', data: {turbo_stream: true} %>
 | 
					      onclick: 'this.blur();', data: {turbo_stream: true} %>
 | 
				
			||||||
  </td>
 | 
					  </td>
 | 
				
			||||||
  <td><%= unit.description %></td>
 | 
					  <td><%= unit.description %></td>
 | 
				
			||||||
  <td class="number"><%= scientifize(unit.multiplier) %></td>
 | 
					  <td class="number"><%= unit.multiplier.to_html %></td>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <% if current_user.at_least(:active) %>
 | 
					  <% if current_user.at_least(:active) %>
 | 
				
			||||||
    <td class="actions">
 | 
					    <td class="actions">
 | 
				
			||||||
 | 
				
			|||||||
@ -8,6 +8,28 @@ module FixinMe
 | 
				
			|||||||
        (coefficient.length > 1 ? coefficient.insert(1, '.') : coefficient) +
 | 
					        (coefficient.length > 1 ? coefficient.insert(1, '.') : coefficient) +
 | 
				
			||||||
        (exponent != 1 ? "e#{exponent-1}" : '')
 | 
					        (exponent != 1 ? "e#{exponent-1}" : '')
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Converts value to HTML formatted scientific notation
 | 
				
			||||||
 | 
					    def to_html
 | 
				
			||||||
 | 
					      sign, coefficient, base, exponent = split
 | 
				
			||||||
 | 
					      return 'NaN' unless sign
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      result = (sign == -1 ? '-' : '')
 | 
				
			||||||
 | 
					      unless coefficient == '1' && sign == 1
 | 
				
			||||||
 | 
					        if coefficient.length > 1
 | 
				
			||||||
 | 
					          result += coefficient.insert(1, '.')
 | 
				
			||||||
 | 
					        elsif
 | 
				
			||||||
 | 
					          result += coefficient
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        if exponent != 1
 | 
				
			||||||
 | 
					          result += "×"
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      if exponent != 1
 | 
				
			||||||
 | 
					        result += "10<sup>% d</sup>" % [exponent-1]
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      result.html_safe
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user