Explorar o código

improved user interface

Gerald %!s(int64=11) %!d(string=hai) anos
pai
achega
04c8dcda6e

+ 2 - 2
_locales/cs/messages.json

@@ -103,7 +103,7 @@
 		"message": "Nový",
 		"description": "Button to create a new script."
 	},
-	"anchorUpdateAll": {
+	"buttonUpdateAll": {
 		"message": "Zkontrolovat aktualizace",
 		"description": "Check all scripts for updates."
 	},
@@ -303,7 +303,7 @@
 		"message": "Odstranit",
 		"description": "Button to remove a script."
 	},
-	"anchorUpdate": {
+	"buttonUpdate": {
 		"message": "Zkontrolovat aktualizace",
 		"description": "Check a script for updates."
 	},

+ 2 - 2
_locales/en/messages.json

@@ -103,7 +103,7 @@
 		"message": "New",
 		"description": "Button to create a new script."
 	},
-	"anchorUpdateAll": {
+	"buttonUpdateAll": {
 		"message": "Check all for updates",
 		"description": "Check all scripts for updates."
 	},
@@ -303,7 +303,7 @@
 		"message": "Remove",
 		"description": "Button to remove a script."
 	},
-	"anchorUpdate": {
+	"buttonUpdate": {
 		"message": "Check for updates",
 		"description": "Check a script for updates."
 	},

+ 2 - 2
_locales/pl/messages.json

@@ -103,7 +103,7 @@
 		"message": "Nowy skrypt",
 		"description": "Button to create a new script."
 	},
-	"anchorUpdateAll": {
+	"buttonUpdateAll": {
 		"message": "Sprawdź aktualizacje dla wszystkich skryptów",
 		"description": "Check all scripts for updates."
 	},
@@ -303,7 +303,7 @@
 		"message": "Usuń skrypt",
 		"description": "Button to remove a script."
 	},
-	"anchorUpdate": {
+	"buttonUpdate": {
 		"message": "Sprawdź aktualizację/e skryptu",
 		"description": "Check a script for updates."
 	},

+ 2 - 2
_locales/ru/messages.json

@@ -103,7 +103,7 @@
 		"message": "Создать",
 		"description": "Button to create a new script."
 	},
-	"anchorUpdateAll": {
+	"buttonUpdateAll": {
 		"message": "Проверить обновления скриптов",
 		"description": "Check all scripts for updates."
 	},
@@ -303,7 +303,7 @@
 		"message": "Удалить",
 		"description": "Button to remove a script."
 	},
-	"anchorUpdate": {
+	"buttonUpdate": {
 		"message": "Проверить обновления",
 		"description": "Check a script for updates."
 	},

+ 2 - 2
_locales/zh/messages.json

@@ -103,7 +103,7 @@
 		"message": "新建",
 		"description": "Button to create a new script."
 	},
-	"anchorUpdateAll": {
+	"buttonUpdateAll": {
 		"message": "全部更新",
 		"description": "Check all scripts for updates."
 	},
@@ -303,7 +303,7 @@
 		"message": "移除",
 		"description": "Button to remove a script."
 	},
-	"anchorUpdate": {
+	"buttonUpdate": {
 		"message": "查找更新",
 		"description": "Check a script for updates."
 	},

+ 32 - 29
background.js

@@ -323,17 +323,20 @@ function updateItem(r){
 }
 function queryScript(id,meta,callback){
 	var o=db.transaction('scripts').objectStore('scripts');
+	function finish(r){
+		if(!r) r=newScript();
+		if(callback) callback(r);
+	}
 	function queryMeta() {
 		var uri=getNameURI({id:'',meta:meta});
 		if(uri!='::') o.index('uri').get(uri).onsuccess=function(e){
-			var r=e.target.result;
-			if(r) callback(r); else callback(newScript());
-		}; else callback(newScript());
+			finish(e.target.result);
+		}; else finish();
 	}
 	function queryId() {
 		if(id) o.get(id).onsuccess=function(e){
 			var r=e.target.result;
-			if(r) callback(r); else queryMeta();
+			if(r) finish(r); else queryMeta();
 		}; else queryMeta();
 	}
 	queryId();
@@ -568,31 +571,6 @@ chrome.runtime.onConnect.addListener(function(p){
 	port=p;
 	p.onDisconnect.addListener(function(){port=null;});
 });
-chrome.runtime.onMessage.addListener(function(req,src,callback) {
-	var maps={
-		NewScript:function(o,src,callback){callback(newScript());},
-		RemoveScript: removeScript,
-		GetData: getData,
-		GetInjected: getInjected,
-		CheckUpdate: checkUpdate,
-		CheckUpdateAll: checkUpdateAll,
-		SaveScript: saveScript,
-		UpdateMeta: updateMeta,
-		SetValue: setValue,
-		GetOption: getOption,
-		SetOption: setOption,
-		ExportZip: exportZip,
-		ParseScript: parseScript,
-		GetScript: getScript,	// for user edit
-		GetMetas: getMetas,	// for popup menu
-		AutoUpdate: autoUpdate,
-		Vacuum: vacuum,
-		Move: move,
-		ParseMeta: function(o,src,callback){callback(parseMeta(o));},
-	},f=maps[req.cmd];
-	if(f) f(req.data,src,callback);
-	return true;
-});
 var settings={};
 initSettings();
 initDb(function(){
@@ -614,6 +592,31 @@ initDb(function(){
 			}
 		};
 	});
+	chrome.runtime.onMessage.addListener(function(req,src,callback) {
+		var maps={
+			NewScript:function(o,src,callback){callback(newScript());},
+			RemoveScript: removeScript,
+			GetData: getData,
+			GetInjected: getInjected,
+			CheckUpdate: checkUpdate,
+			CheckUpdateAll: checkUpdateAll,
+			SaveScript: saveScript,
+			UpdateMeta: updateMeta,
+			SetValue: setValue,
+			GetOption: getOption,
+			SetOption: setOption,
+			ExportZip: exportZip,
+			ParseScript: parseScript,
+			GetScript: getScript,	// for user edit
+			GetMetas: getMetas,	// for popup menu
+			AutoUpdate: autoUpdate,
+			Vacuum: vacuum,
+			Move: move,
+			ParseMeta: function(o,src,callback){callback(parseMeta(o));},
+		},f=maps[req.cmd];
+		if(f) f(req.data,src,callback);
+		return true;
+	});
 	chrome.browserAction.setIcon({path:'images/icon19'+(settings.isApplied?'':'w')+'.png'});
 	setTimeout(autoCheck,2e4);
 });

+ 6 - 5
options.css

@@ -23,13 +23,14 @@ fieldset.title{border:none;border-top:1px solid silver;margin:20px 0 0;}
 #sList>div.disabled .name{color:blueviolet;}
 #sList>div.disabled .icon{opacity:0.5;}
 #sList>div.moving{background:lightgreen;border:1px outset gray;cursor:move;}
-#sList .name{margin-left:60px;margin-right:10px;font-weight:bold;font-size:120%;}
-#sList .support{margin-right:10px;width:16px;height:16px;border-radius:8px;background-color:green;color:white;text-align:center;display:inline-block;text-decoration:none;font-size:12px;}
+#sList .name{font-weight:bold;font-size:120%;}
+#sList .support{width:16px;height:16px;border-radius:8px;background-color:green;color:white;text-align:center;display:inline-block;text-decoration:none;font-size:12px;}
 #sList .support.hide{display:none;}
 #sList .icon{top:1em;width:40px;height:40px;margin:2px;position:absolute;}
-#sList .version{margin-right:10px;}
-#sList .descrip{margin-left:60px;}
-#sList .move{cursor:move;margin-left:20px;color:gray;font-size:150%;}
+#sList .descrip{margin-left:60px;min-height:1em;max-height:4.5em;overflow-y:auto;}
+#sList .move{cursor:move;color:gray;font-size:150%;}
+#sList .panelH{margin-left:60px;margin-right:20px;}
+#sList .panelH>*{display:inline-block;margin-right:10px;}
 #sList .panelT{position:absolute;top:10px;right:10px;}
 
 /* Editor */

+ 2 - 2
options.html

@@ -13,7 +13,7 @@
 		<div class=main>
 			<div class=sidebar>
 				<img src=images/icon128.png>
-				<h1 data-i18n=extName></h1>
+				<h2 data-i18n=extName></h2>
 				<p>2013-2014</p>
 				<hr>
 				<div class=sidemenu>
@@ -27,7 +27,7 @@
 					<tr>
 						<td>
 							<button id=bNew data-i18n=buttonNew></button>
-							<button id=bUpdate data-i18n=anchorUpdateAll></button>
+							<button id=bUpdate data-i18n=buttonUpdateAll></button>
 							<a href=https://greasyfork.org/scripts target=_blank data-i18n=anchorGetMoreScripts></a>
 						</td>
 					</tr>

+ 7 - 5
options.js

@@ -47,10 +47,12 @@ function modifyItem(r){
 function loadItem(o,r){
 	var d=o.div,n=o.obj;if(!r) r={id:n.id};
 	d.innerHTML='<img class=icon>'
-	+'<a class="name ellipsis" target=_blank></a>'
-	+'<a class="support hide" target=_blank>?</a>'
-	+'<span class=version>'+(n.meta.version?'v'+n.meta.version:'')+'</span>'
-	+'<span class=author></span>'
+	+'<div class=panelH>'
+		+'<a class="name ellipsis" target=_blank></a>'
+		+'<a class="support hide" target=_blank>?</a>'
+		+'<span class=version>'+(n.meta.version?'v'+n.meta.version:'')+'</span>'
+		+'<span class=author></span>'
+	+'</div>'
 	+'<div class=panelT>'
 		+'<span class=move data=move>&equiv;</span>'
 	+'</div>'
@@ -59,7 +61,7 @@ function loadItem(o,r){
 		+'<button data=edit>'+_('buttonEdit')+'</button> '
 		+'<button data=enable class=enable></button> '
 		+'<button data=remove>'+_('buttonRemove')+'</button> '
-		+(allowUpdate(n)?'<button data=update class=update>'+_('anchorUpdate')+'</button> ':'')
+		+(allowUpdate(n)?'<button data=update class=update>'+_('buttonUpdate')+'</button> ':'')
 		+'<span class=message></span>'
 	+'</div>';
 	modifyItem(r);