You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@whimsical.apache.org by sebb <se...@gmail.com> on 2018/08/16 11:42:08 UTC
Re: [whimsy] 02/02: appease Chrome by converting the spreadsheet a
byte at a time
On 16 August 2018 at 03:38, <ru...@apache.org> wrote:
> This is an automated email from the ASF dual-hosted git repository.
>
> rubys pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/whimsy.git
>
> commit 46058b1e8baff80c75ea72f5b79f2f23af2e87a5
> Author: Sam Ruby <ru...@intertwingly.net>
> AuthorDate: Wed Aug 15 22:37:52 2018 -0400
>
> appease Chrome by converting the spreadsheet a byte at a time
Where code does something unusual, it's helpful to document it locally
rather than relying on someone reading the commit log.
Otherwise a later maintainer may revert the change, as it looks inefficient.
==
I view commit comments as ephemeral: they should help reviewers
understand why the change was made, and make it easy to find changes
in history.
Code comments are for long-term maintenance and understanding.
> ---
> www/board/agenda/views/buttons/post.js.rb | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/www/board/agenda/views/buttons/post.js.rb b/www/board/agenda/views/buttons/post.js.rb
> index b0ccfce..4a6f5b9 100644
> --- a/www/board/agenda/views/buttons/post.js.rb
> +++ b/www/board/agenda/views/buttons/post.js.rb
> @@ -551,9 +551,13 @@ class Post < Vue
>
> reader = FileReader.new
> def reader.onload(event)
> - result = event.target.result
> - base64 = btoa(String.fromCharCode(*Uint8Array.new(result)))
> - post 'financials', spreadsheet: base64 do |response|
Needs a comment here.
> + bytes = Uint8Array.new(event.target.result)
> + binary = ''
> + for i in 0...bytes.byteLength
> + binary += String.fromCharCode(bytes[i])
> + end
> +
> + post 'financials', spreadsheet: btoa(binary) do |response|
> report = @report
> report += "\n" if report and not report.end_with? "\n"
> report += "\n" if report
>