PluginProjectWeb.py

changeset 3
e478a359e1fb
parent 1
e3a92a671aa5
child 4
6438afaad632
--- a/PluginProjectWeb.py	Wed Dec 31 19:16:39 2014 +0100
+++ b/PluginProjectWeb.py	Wed Dec 31 20:38:35 2014 +0100
@@ -178,6 +178,8 @@
         # TODO: add our actions here
         self.__html5ToCss3Act = self.__menu.addAction(self.tr(
             "HTML5 to CSS3"), self.__htm5ToCss3)
+        self.__html5ToJsAct = self.__menu.addAction(self.tr(
+            "HTML5 to JavaScript"), self.__htm5ToJs)
         
         self.__menu.aboutToShow.connect(self.__menuAboutToShow)
     
@@ -190,6 +192,8 @@
         
         self.__html5ToCss3Act.setEnabled(
             selectionAvailable and BeautifulSoupAvailable)
+        self.__html5ToJsAct.setEnabled(
+            selectionAvailable and BeautifulSoupAvailable)
     
     def __populateMenu(self, name, menu):
         """
@@ -254,7 +258,6 @@
         """
         Private slot handling the HTML5 to CSS3 conversion.
         """
-        # TODO: implement this
         from ProjectWeb.Html5ToCss3Converter import Html5ToCss3Converter
         vm = e5App().getObject("ViewManager")
         editor = vm.activeWindow()
@@ -269,3 +272,22 @@
             newEditor = vm.activeWindow()
             newEditor.setText(css3)
             newEditor.setLanguage("dummy.css")
+    
+    def __htm5ToJs(self):
+        """
+        Private slot handling the HTML5 to JavaScript conversion.
+        """
+        from ProjectWeb.Html5ToJsConverter import Html5ToJsConverter
+        vm = e5App().getObject("ViewManager")
+        editor = vm.activeWindow()
+        html = editor.selectedText()
+        
+        converter = Html5ToJsConverter(html)
+        
+        js = converter.getJavaScript()
+        
+        if js:
+            vm.newEditor()
+            newEditor = vm.activeWindow()
+            newEditor.setText(js)
+            newEditor.setLanguage("dummy.js")

eric ide

mercurial