瀏覽代碼

Show current tags

Kandrashin Denis 13 年之前
父節點
當前提交
a95fb63c2f
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      source/fb2main.cpp

+ 8 - 1
source/fb2main.cpp

@@ -476,7 +476,14 @@ void Fb2MainWindow::selectionChanged()
     actionTextSub->setChecked(textEdit->SubChecked());
     actionTextSup->setChecked(textEdit->SupChecked());
 
-    QString script = "document.getSelection().baseNode.parentNode.tagName";
+    QString script = "\
+    (f = function(node){\
+        var tag = node.tagName;\
+        if (tag == 'BODY') return '';\
+        if (tag == 'DIV') tag = node.getAttribute('CLASS');\
+        return f(node.parentNode) + '/' + tag;\
+    })(document.getSelection().baseNode.parentNode);";
+
     QString message = textEdit->page()->mainFrame()->evaluateJavaScript(script).toString();
     statusBar()->showMessage(message);
 }