This commit is contained in:
Liang Ding 2014-12-30 16:51:19 +08:00
parent 8d0ae1d7d1
commit 3de0437227
9 changed files with 52 additions and 7 deletions

View File

@ -49,7 +49,9 @@ func GetOutline(w http.ResponseWriter, r *http.Request) {
fset := token.NewFileSet() fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "", code, 0) f, err := parser.ParseFile(fset, "", code, 0)
if err != nil { if err != nil {
panic(err) data["succ"] = false
return
} }
//ast.Print(fset, f) //ast.Print(fset, f)

View File

@ -161,5 +161,6 @@
"change_avatar": "Avatar modify go", "change_avatar": "Avatar modify go",
"open": "Open", "open": "Open",
"pricing": "Pricing", "pricing": "Pricing",
"search_no_match": "No matching files were found." "search_no_match": "No matching files were found.",
"outline": "Outline"
} }

View File

@ -161,5 +161,6 @@
"change_avatar": "アバターの変更は行く", "change_avatar": "アバターの変更は行く",
"open": "オープン", "open": "オープン",
"pricing": "价格", "pricing": "价格",
"search_no_match": "一致するファイルが見つかりませんでした。" "search_no_match": "一致するファイルが見つかりませんでした。",
"outline": "アウトライン"
} }

View File

@ -161,5 +161,6 @@
"change_avatar": "头像修改请到", "change_avatar": "头像修改请到",
"open": "打开", "open": "打开",
"pricing": "价格", "pricing": "价格",
"search_no_match": "没有发现匹配的文件。" "search_no_match": "没有发现匹配的文件。",
"outline": "大纲"
} }

View File

@ -161,5 +161,6 @@
"change_avatar": "頭像修改請到", "change_avatar": "頭像修改請到",
"open": "打開", "open": "打開",
"pricing": "價格", "pricing": "價格",
"search_no_match": "沒有發現匹配的文件。" "search_no_match": "沒有發現匹配的文件。",
"outline": "大綱"
} }

View File

@ -646,7 +646,7 @@ var editors = {
+ data[i].line + '" data-ch="' + data[i].ch + '"> (' + data[i].line + ':' + data[i].line + '" data-ch="' + data[i].ch + '"> (' + data[i].line + ':'
+ data[i].ch + ')</i></span></li>'; + data[i].ch + ')</i></span></li>';
} }
if (data.length === 0) { if (data.length === 0) {
searcHTML += '<li>' + config.label.search_no_match + '</li>'; searcHTML += '<li>' + config.label.search_no_match + '</li>';
} }

View File

@ -51,12 +51,17 @@ var hotkeys = {
$("#files").focus(); $("#files").focus();
} }
}, },
// Ctrl-2
goOutline: { goOutline: {
ctrlKey: true, ctrlKey: true,
altKey: false, altKey: false,
shiftKey: false, shiftKey: false,
which: 50, which: 50,
fun: function () { fun: function () {
if (!wide.curEditor) {
return;
}
var request = newWideRequest(); var request = newWideRequest();
request.code = wide.curEditor.getValue(); request.code = wide.curEditor.getValue();

View File

@ -512,7 +512,6 @@ var wide = {
request.file = path; request.file = path;
request.code = editor.getValue(); request.code = editor.getValue();
request.nextCmd = ""; // build only, no following operation request.nextCmd = ""; // build only, no following operation
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: config.context + '/build', url: config.context + '/build',
@ -524,6 +523,24 @@ var wide = {
success: function (data) { success: function (data) {
} }
}); });
// refresh outline
var request = newWideRequest();
request.code = wide.curEditor.getValue();
$.ajax({
type: 'POST',
url: config.context + '/outline',
data: JSON.stringify(request),
dataType: "json",
success: function (data) {
if (!data.succ) {
return;
}
$("#outline").html(JSON.stringify(data));
}
});
return; return;
} }

View File

@ -462,6 +462,23 @@
<div class="tabs"></div> <div class="tabs"></div>
<div class="tabs-panel"></div> <div class="tabs-panel"></div>
</div> </div>
<!--
TODO: https://github.com/b3log/wide/issues/199
<div style="height: 70%;position: absolute;right: 0;background-color: #FFF;width: 20%;">
<span title="{{.i18n.min}}" class="font-ico ico-min"></span>
<div class="tabs">
<div class="current">
<span title="{{.i18n.outline}}">{{.i18n.outline}}</span>
</div>
</div>
<div class="tabs-panel">
<div id="outline">
this is outline
</div>
</div>
</div>
-->
<div class="bottom-window-group"> <div class="bottom-window-group">
<span title="{{.i18n.min}}" class="font-ico ico-min"></span> <span title="{{.i18n.min}}" class="font-ico ico-min"></span>