Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: tools/chrome_extensions/open_my_editor/ext/cs-content.js

Issue 2720793005: Add Open my editor (Closed)
Patch Set: change python2 to python Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/chrome_extensions/open_my_editor/ext/cs-content.js
diff --git a/tools/chrome_extensions/open_my_editor/ext/cs-content.js b/tools/chrome_extensions/open_my_editor/ext/cs-content.js
new file mode 100644
index 0000000000000000000000000000000000000000..7df1b85b8dab838558c602ef49ce9a3f7a840147
--- /dev/null
+++ b/tools/chrome_extensions/open_my_editor/ext/cs-content.js
@@ -0,0 +1,28 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// For cs.chromium.org
+
+let line = 0;
+
+document.addEventListener('mousedown', (event) => {
+ // right click
+ if (event.button == 2) {
+ let element = event.target;
+ while (element != null && element.tagName == 'SPAN') {
+ if (element.className == 'stx-line') {
+ line = parseInt(element.id.split('_')[1]);
+ break;
+ } else {
+ element = element.parentElement;
+ }
+ }
+ }
+}, true);
+
+chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
+ if (request == 'getLine') {
+ sendResponse({line: line});
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698