From 6376a6e97d51372ce4d77eaec96b2309da7d7f53 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 14 Jan 2015 08:21:47 -0500 Subject: [PATCH] feature(edward) mv sha from edit --- lib/client/edit.js | 21 ++------------------- lib/client/edward.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 71f15bf1..2b70a951 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -104,7 +104,7 @@ var CloudCmd, Util, DOM, CloudFunc, io, ace, Zip, Format, MenuIO, edward, restaf edward.setValue(value); - sha(function(error, hash) { + edward.sha(function(error, hash) { DOM.saveDataToStorage(name, value, hash); edward .clearSelection() @@ -440,23 +440,6 @@ var CloudCmd, Util, DOM, CloudFunc, io, ace, Zip, Format, MenuIO, edward, restaf }); } - function sha(callback) { - var dir = '/modules/jsSHA/', - url = dir + 'src/sha1.js'; - - DOM.load.js(url, function() { - var shaObj, hash, error, - value = edward.getValue(); - - error = exec.try(function() { - shaObj = new window.jsSHA(value, 'TEXT'); - hash = shaObj.getHash('SHA-1', 'HEX'); - }); - - callback(error, hash); - }); - } - function setJsHintConfig(callback) { var JSHINT_PATH = CloudCmd.PREFIX + '/.jshintrc', func = function() { @@ -513,7 +496,7 @@ var CloudCmd, Util, DOM, CloudFunc, io, ace, Zip, Format, MenuIO, edward, restaf } else { Edit.showMessage(text); - sha(function(error, hash) { + edward.sha(function(error, hash) { if (error) console.error(error); diff --git a/lib/client/edward.js b/lib/client/edward.js index 32510946..84ca7ddd 100644 --- a/lib/client/edward.js +++ b/lib/client/edward.js @@ -151,6 +151,23 @@ var join, ace, Util, DOM; }, HIDE_TIME); }; + edward.sha = function(callback) { + var dir = '/modules/jsSHA/', + url = dir + 'src/sha1.js'; + + load.js(url, function() { + var shaObj, hash, error, + value = edward.getValue(); + + error = exec.try(function() { + shaObj = new window.jsSHA(value, 'TEXT'); + hash = shaObj.getHash('SHA-1', 'HEX'); + }); + + callback(error, hash); + }); + }; + function onDrop(event) { var reader, files, onLoad = function(event) {