Permalink
Browse files

Working on Google Chrome extension

  • Loading branch information...
1 parent 7f50f62 commit e317aa1636e88078accfe06363e0af47616a047e @sergeche committed Feb 9, 2011
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
+<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="chrome.extension,"/>
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
@@ -8,6 +9,6 @@
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="xmlview"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/xmlview/build/build.xml}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value=""/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>
View
@@ -12,7 +12,7 @@
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
- <triggers>full,incremental,</triggers>
+ <triggers>auto,full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
View
@@ -3,9 +3,13 @@ dist.css.dir=${dist.dir}/css
dist.css-full.dir=${dist.dir}/css-full
dist.js.dir=${dist.dir}/js
+dist.chrome.dir=${dist.dir}/chrome
+
js-src.dir=${basedir}/src
css-src.dir=${basedir}/css
+chrome-src.dir=${basedir}/extensions/chrome
+
webtasks.dir=${basedir}/ant-tools
webtasks.use-cc=false
force-rebuild=no
View
@@ -19,8 +19,9 @@
<file name="settings.js"/>
<file name="renderer.js"/>
<file name="search.js"/>
+ <file name="search_ui.js"/>
<file name="controller.js"/>
- <!-- <file name="dnd.js"/> -->
+ <file name="dnd.js"/>
</filelist>
<target name="compile.js" depends="init">
@@ -38,7 +39,27 @@
<compress-css dir="${css-src.dir}" todir="${dist.css.dir}" force="${force-rebuild}"/>
</target>
- <target name="compile" depends="compile.css, compile.js">
+ <target name="chrome.extension" depends="init" description="Build Google Chrome extension">
+ <mkdir dir="${dist.chrome.dir}"/>
+ <copy todir="${dist.chrome.dir}">
+ <fileset dir="${chrome-src.dir}"/>
+ </copy>
+ <concat destfile="${dist.chrome.dir}/xv.js">
+ <filelist dir="${js-src.dir}">
+ <file name="lib/underscore.js"/>
+ <file name="lib/js-signals.js"/>
+ <file name="signals.js"/>
+ <file name="utils.js"/>
+ <file name="dom.js"/>
+ <file name="settings.js"/>
+ <file name="renderer.js"/>
+ <file name="search.js"/>
+ <file name="controller.js"/>
+ </filelist>
+ </concat>
+ </target>
+
+ <target name="compile" depends="compile.css, compile.js, chrome.extension">
<copy file="${basedir}/xml-pretty-print.xslt" tofile="${dist.dir}/xmlview.xsl"/>
<echo>Build done</echo>
</target>
@@ -0,0 +1,3 @@
+<html>
+
+</html>
@@ -0,0 +1,26 @@
+function isXML(doc) {
+ return !(doc instanceof HTMLDocument || doc instanceof SVGDocument);
+}
+
+function canTransform() {
+ return document && isXML(document) && document.documentElement;
+}
+
+xv_dom.getByClass = function(class_name, context) {
+ return _.filter((context || document).getElementsByTagName('*'), function(n) {
+ return xv_dom.hasClass(n, class_name);
+ });
+};
+
+if (canTransform()) {
+ var html = xv_dom.fromHTML('<html><body>' +
+ '<div class="xv-source-pane"><div class="xv-source-pane-inner"></div></div>' +
+ '</body></html>');
+
+ var source_doc = document.documentElement;
+
+ var pi = document.createProcessingInstruction('xml-stylesheet', 'type="text/css" href="' + chrome.extension.getURL('xv.css') + '"');
+ document.insertBefore(pi, document.firstChild);
+
+ document.replaceChild(html, document.documentElement);
+}
@@ -0,0 +1,16 @@
+{
+ "name" : "XV",
+ "version" : "1.0",
+ "description" : "View XML files in Google Chrome",
+ "background_page": "background.html",
+ "permissions" : [
+ "tabs",
+ "http://*/*",
+ "https://*/*"
+ ],
+ "content_scripts": [{
+ "js": ["xv.js", "controller.js"],
+ "matches": ["http://*/*", "https://*/*", "file://*/*"],
+ "run_at": "document_end"
+ }]
+}
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit e317aa1

Please sign in to comment.