@ -4,7 +4,6 @@
var $ = require ( 'jquery' )
var $ = require ( 'jquery' )
var base64 = require ( 'js-base64' ) . Base64
var base64 = require ( 'js-base64' ) . Base64
var utils = require ( './app/utils' )
var QueryParams = require ( './app/query-params' )
var QueryParams = require ( './app/query-params' )
var queryParams = new QueryParams ( )
var queryParams = new QueryParams ( )
var GistHandler = require ( './app/gist-handler' )
var GistHandler = require ( './app/gist-handler' )
@ -45,11 +44,10 @@ var run = function () {
function loadFiles ( files ) {
function loadFiles ( files ) {
for ( var f in files ) {
for ( var f in files ) {
var key = utils . fileKey ( f )
storage . loadFile ( f , files [ f ] . content )
var content = files [ f ] . content
storage . loadFile ( key , content )
}
}
editor . setCacheFile ( utils . fileKey ( Object . keys ( files ) [ 0 ] ) )
// Set the first file as current tab
editor . setCacheFile ( Object . keys ( files ) [ 0 ] )
updateFiles ( )
updateFiles ( )
}
}
@ -100,7 +98,7 @@ var run = function () {
function check ( key ) {
function check ( key ) {
chrome . storage . sync . get ( key , function ( resp ) {
chrome . storage . sync . get ( key , function ( resp ) {
console . log ( 'comparing to cloud' , key , resp )
console . log ( 'comparing to cloud' , key , resp )
if ( typeof resp [ key ] !== 'undefined' && obj [ key ] !== resp [ key ] && confirm ( 'Overwrite "' + utils . fileNameFromKey ( key ) + '"? Click Ok to overwrite local file with file from cloud. Cancel will push your local file to the cloud.' ) ) {
if ( typeof resp [ key ] !== 'undefined' && obj [ key ] !== resp [ key ] && confirm ( 'Overwrite "' + key + '"? Click Ok to overwrite local file with file from cloud. Cancel will push your local file to the cloud.' ) ) {
console . log ( 'Overwriting' , key )
console . log ( 'Overwriting' , key )
storage . set ( key , resp [ key ] )
storage . set ( key , resp [ key ] )
updateFiles ( )
updateFiles ( )
@ -120,9 +118,6 @@ var run = function () {
for ( var y in storage . keys ( ) ) {
for ( var y in storage . keys ( ) ) {
console . log ( 'checking' , y )
console . log ( 'checking' , y )
obj [ y ] = storage . get ( y )
obj [ y ] = storage . get ( y )
if ( ! utils . isCachedFile ( y ) ) {
continue
}
count ++
count ++
check ( y )
check ( y )
}
}
@ -246,9 +241,9 @@ var run = function () {
editor . hasFile ( newName )
editor . hasFile ( newName )
? 'Are you sure you want to overwrite: ' + newName + ' with ' + originalName + '?'
? 'Are you sure you want to overwrite: ' + newName + ' with ' + originalName + '?'
: 'Are you sure you want to rename: ' + originalName + ' to ' + newName + '?' ) ) {
: 'Are you sure you want to rename: ' + originalName + ' to ' + newName + '?' ) ) {
storage . rename ( utils . fileKey ( originalName ) , utils . fileKey ( newName ) )
storage . rename ( originalName , newName )
editor . renameSession ( utils . fileKey ( originalName ) , utils . fileKey ( newName ) )
editor . renameSession ( originalName , newName )
editor . setCacheFile ( utils . fileKey ( newName ) )
editor . setCacheFile ( newName )
}
}
updateFiles ( )
updateFiles ( )
@ -263,16 +258,16 @@ var run = function () {
var name = $ ( this ) . parent ( ) . find ( '.name' ) . text ( )
var name = $ ( this ) . parent ( ) . find ( '.name' ) . text ( )
if ( confirm ( 'Are you sure you want to remove: ' + name + ' from local storage?' ) ) {
if ( confirm ( 'Are you sure you want to remove: ' + name + ' from local storage?' ) ) {
storage . remove ( utils . fileKey ( name ) )
storage . remove ( name )
editor . removeSession ( utils . fileKey ( name ) )
editor . removeSession ( name )
editor . setNextFile ( utils . fileKey ( name ) )
editor . setNextFile ( name )
updateFiles ( )
updateFiles ( )
}
}
return false
return false
} )
} )
function swicthToFile ( file ) {
function swicthToFile ( file ) {
editor . setCacheFile ( utils . fileKey ( file ) )
editor . setCacheFile ( file )
updateFiles ( )
updateFiles ( )
}
}
@ -290,12 +285,12 @@ var run = function () {
$ ( '#output' ) . empty ( )
$ ( '#output' ) . empty ( )
for ( var f in files ) {
for ( var f in files ) {
var name = utils . fileNameFromKey ( files [ f ] )
var name = files [ f ]
$filesEl . append ( $ ( '<li class="file"><span class="name">' + name + '</span><span class="remove"><i class="fa fa-close"></i></span></li>' ) )
$filesEl . append ( $ ( '<li class="file"><span class="name">' + name + '</span><span class="remove"><i class="fa fa-close"></i></span></li>' ) )
}
}
if ( editor . cacheFileIsPresent ( ) ) {
if ( editor . cacheFileIsPresent ( ) ) {
var currentFileName = utils . fileNameFromKey ( editor . getCacheFile ( ) )
var currentFileName = editor . getCacheFile ( )
var active = $ ( '#files .file' ) . filter ( function ( ) { return $ ( this ) . find ( '.name' ) . text ( ) === currentFileName } )
var active = $ ( '#files .file' ) . filter ( function ( ) { return $ ( this ) . find ( '.name' ) . text ( ) === currentFileName } )
active . addClass ( 'active' )
active . addClass ( 'active' )
editor . resetSession ( )
editor . resetSession ( )
@ -369,7 +364,6 @@ var run = function () {
// ----------------- resizeable ui ---------------
// ----------------- resizeable ui ---------------
var EDITOR _SIZE _KEY = 'editor-size-cache'
var EDITOR _WINDOW _SIZE = 'editorWindowSize'
var EDITOR _WINDOW _SIZE = 'editorWindowSize'
var dragging = false
var dragging = false
@ -413,14 +407,6 @@ var run = function () {
}
}
} )
} )
// convert old browser-solidity
if ( storage . exists ( EDITOR _SIZE _KEY ) ) {
if ( ! config . exists ( EDITOR _WINDOW _SIZE ) ) {
config . set ( EDITOR _WINDOW _SIZE , storage . get ( EDITOR _SIZE _KEY ) )
}
storage . remove ( EDITOR _SIZE _KEY )
}
if ( config . exists ( EDITOR _WINDOW _SIZE ) ) {
if ( config . exists ( EDITOR _WINDOW _SIZE ) ) {
setEditorSize ( config . get ( EDITOR _WINDOW _SIZE ) )
setEditorSize ( config . get ( EDITOR _WINDOW _SIZE ) )
} else {
} else {
@ -536,7 +522,7 @@ var run = function () {
function runCompiler ( ) {
function runCompiler ( ) {
var files = { }
var files = { }
var target = utils . fileNameFromKey ( editor . getCacheFile ( ) )
var target = editor . getCacheFile ( )
files [ target ] = editor . getValue ( )
files [ target ] = editor . getValue ( )