use pure JS to insert diff in the page

This commit is contained in:
Rodrigo Fernandes 2014-09-03 00:25:23 +01:00
parent fde1df3a6a
commit 05dbc0ec30

View file

@ -13,46 +13,54 @@
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="style.css">
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript" src="diff2html.js"></script> <script type="text/javascript" src="diff2html.js"></script>
<script> <script>
var exInput = 'diff --git a/components/enginePlugins/src/main/scala/metrics/Tools.scala b/components/enginePlugins/src/main/scala/metrics/Tools.scala\n' + var exInput = 'diff --git a/src/app/language/en.json b/src/app/language/en.json\n' +
'index c68cfb8..a1edc93 100644\n' + 'index ccf92c9..68b8345 100644\n' +
'--- a/components/enginePlugins/src/main/scala/metrics/Tools.scala\n' + '--- a/src/app/language/en.json\n' +
'+++ b/components/enginePlugins/src/main/scala/metrics/Tools.scala\n' + '+++ b/src/app/language/en.json\n' +
'@@ -1,6 +1,7 @@\n' + '@@ -270,5 +270,6 @@\n' +
'package metrics\n' + ' "Open Item Details": "Open Item Details",\n' +
' \n' + ' "Add Item to Favorites": "Add Item to Favorites",\n' +
'import java.io\n' + ' "Mark as Seen": "Mark as Seen",\n' +
'{+import java.nio.file.Files._+}\n' + ' "Open Settings": "Open Settings"{+,+}\n' +
' \n' + '{+ "Custom...": "Custom..."+}\n' +
'import framework.common.Logger.LoggerSystem\n' + '}\n' +
'import org.apache.commons.io.FileUtils\n' + 'diff --git a/src/app/language/fr.json b/src/app/language/fr.json\n' +
'@@ -43,7 +44,7 @@ object Tools {\n' + 'index 9c773c5..8fb637a 100644\n' +
' }\n' + '--- a/src/app/language/fr.json\n' +
' \n' + '+++ b/src/app/language/fr.json\n' +
' def withTempDir[A](block: io.File => A): A = {\n' + '@@ -266,5 +266,6 @@\n' +
' val dir = [-io.File.-]createTemp[-F-]{+D+}i[-l-]{+r+}e{+ctory+}("codacy"[-, "-]{+)+}.t[-mp")-]{+oFile+}\n' + ' "Add Item to Favorites": "Ajouter aux favoris",\n' +
' \n' + ' "Mark as Seen": "Marquer comme vu",\n' +
' val res = block(dir)\n' + ' "Open this screen": "Afficher cette page",\n' +
' FileUtils.deleteDirectory(dir)\n' + ' "Open Settings": "Ouvrir les Réglages"{+,+}\n' +
'diff --git a/components/enginePlugins/src/main/scala/metrics/js/Plato.scala b/components/enginePlugins/src/main/scala/metrics/js/Plato.scala\n' + '{+ "Custom...": "Ajouter un fichier..."+}\n' +
'index 5935d36..4e7e085 100644\n' + '}\n' +
'--- a/components/enginePlugins/src/main/scala/metrics/js/Plato.scala\n' + 'diff --git a/src/app/vendor/videojsplugins.js b/src/app/vendor/videojsplugins.js\n' +
'+++ b/components/enginePlugins/src/main/scala/metrics/js/Plato.scala\n' + 'index 10856e3..892b7ca 100644\n' +
'@@ -24,7 +24,7 @@ object Plato extends PlatoReads {\n' + '--- a/src/app/vendor/videojsplugins.js\n' +
' withTempDir {\n' + '+++ b/src/app/vendor/videojsplugins.js\n' +
' outputDirectory =>\n' + '@@ -83,7 +83,7 @@ videojs.plugin(\'customSubtitles\', function() {\n' +
' runTool(directory, files, outputDirectory) match {\n' + ' options[\'track\'] = {\n' +
' case ({+Some(+}_{+)+}, tmpFileMapper) =>\n' + ' kind: function() { return \'subtitles\'; },\n' +
' val fileFolders = new io.File(outputDirectory, "files")\n' + ' player: player,\n' +
' \n' + ' label: function(){ return [-\'-]{+i18n.__("+}Custom...[-\'-]{+")+} },\n' +
' fileFolders.list().flatMap {'; ' dflt: function(){ return false; },\n' +
' mode: function(){ return false; }\n' +
' };\n' +
'@@ -107,7 +107,7 @@ videojs.plugin(\'customSubtitles\', function() {\n' +
'\n' +
' CustomTrackMenuItem.prototype.loadSubtitle = function(filePath) {\n' +
' // TODO Delete old track\n' +
' this.track = this.player_.addTextTrack(\'subtitles\', [-\'-]{+i18n.__("+}Custom...[-\'-]{+")+}, \'00\', { src: filePath });\n' +
' vjs.TextTrackMenuItem.prototype.onClick.call(this); // redirect to TextTrackMenuItem.onClick\n' +
' }\n';
$(document).ready(function () { document.onreadystatechange = function () {
var content = Diff2Html.getPrettyHtmlFromDiff(exInput); var content = Diff2Html.getPrettyHtmlFromDiff(exInput);
$("body").html(content); document.getElementsByTagName('body')[0].innerHTML = content;
}); }
</script> </script>
</head> </head>