From d3edd458a07fea258b804a4d78cb7d0876af173e Mon Sep 17 00:00:00 2001 From: Rylan doherty Date: Sat, 27 Apr 2013 21:55:00 -0400 Subject: [PATCH] Split Files, New Icon, Create File some of daves work and some of mine. Got a file dialog for creating files. started to split up the JS file into 2 for simplicity, got an icon for playback. --- chrome/content/browserx.xul | 30 +++++++++--------- chrome/content/fireio.js | 59 +++++++++++++++++++++++++++++++++++ chrome/content/firerecord.js | 52 +++++++++++++++++++++--------- skin/play.png | Bin 0 -> 1089 bytes skin/record.png | Bin 0 -> 979 bytes 5 files changed, 112 insertions(+), 29 deletions(-) create mode 100644 chrome/content/fireio.js create mode 100644 skin/play.png create mode 100644 skin/record.png diff --git a/chrome/content/browserx.xul b/chrome/content/browserx.xul index 9e18a1f..3303b10 100644 --- a/chrome/content/browserx.xul +++ b/chrome/content/browserx.xul @@ -2,7 +2,8 @@ - + @@ -11,8 +12,10 @@ - + + @@ -27,17 +30,16 @@ - - - - - - - - - - - + + + + + + + diff --git a/chrome/content/fireio.js b/chrome/content/fireio.js new file mode 100644 index 0000000..624a2f8 --- /dev/null +++ b/chrome/content/fireio.js @@ -0,0 +1,59 @@ + +var io = { +openPath : function(){ + alert("test2"); + + const nsIFilePicker = Components.interfaces.nsIFilePicker; + + var fp = Components.classes["@mozilla.org/filepicker;1"] + .createInstance(nsIFilePicker); + fp.init(window, "Dialog Title", nsIFilePicker.modeOpen); + fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText); + + var rv = fp.show(); + if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) { + var file = fp.file; + // Get the path as string. Note that you usually won't + // need to work with the string paths. + var path = fp.file.path; + // work with returned nsILocalFile... + + } + return path; + }, +appendPath: function (path, contents) +{ + alert("appended File"); +var file1 = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); +file1.initWithPath(path); +//alert("append file nullcheck: "+file1.toString()); +var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream); +// use 0x02 | 0x10 to open file for appending. +foStream.init(file1, 0x02 | 0x10, 438, 0); +var converter = Components.classes["@mozilla.org/intl/converter-output-stream;1"]. + createInstance(Components.interfaces.nsIConverterOutputStream); +converter.init(foStream, "UTF-8", 0, 0); +converter.writeString(contents); +converter.close(); +}, + +newPath: function() { + const nsIFilePicker = Components.interfaces.nsIFilePicker; + +var fp = Components.classes["@mozilla.org/filepicker;1"] + .createInstance(nsIFilePicker); +fp.init(window, "Dialog Title", nsIFilePicker.modeSave); +fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText); + +var rv = fp.show(); +if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) { + var file = fp.file; + // Get the path as string. Note that you usually won't + // need to work with the string paths. + var path = fp.file.path; + // work with returned nsILocalFile... + +} +return path; +}, +} diff --git a/chrome/content/firerecord.js b/chrome/content/firerecord.js index bd9c658..567647c 100644 --- a/chrome/content/firerecord.js +++ b/chrome/content/firerecord.js @@ -19,6 +19,8 @@ var firerecord = function () { appcontent.addEventListener("DOMContentLoaded", firerecord.run, true); } }, + + //Rylan running: function (){ if(recordingx){ recordingx = false; @@ -35,7 +37,17 @@ var firerecord = function () { } }, - file: function(){ + openfile: function(){ + + path = io.openPath(); + + }, + newfile: function(){ + path = io.newPath(); + createFile(); + }, + //rylan + /*file: function(){ const nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"] @@ -52,7 +64,9 @@ var firerecord = function () { // work with returned nsILocalFile... } - }, + },*/ + + //rylan checkpage: function(readloc){ page = window.content.location.href; if (page != readloc){ @@ -61,6 +75,7 @@ var firerecord = function () { } }, + //rylan readr: function(){ var a= "http://rt.com/news/"; var b= "A"; @@ -73,6 +88,7 @@ var firerecord = function () { //setTimeout(function(){firerecord.fireExp();},8000); }, + //rylan nullCheck: function(elem){ if(!elem.href){ elem.href = "null"; @@ -121,7 +137,11 @@ var firerecord = function () { } return elem; - },/* + }, + + /* + + //rylan fireExp: function(){ var all = content.document.getElementsByTagName("A"); for (var i = 0; i < all.length; ++i) { @@ -133,6 +153,8 @@ var firerecord = function () { } } },*/ + + //rylan fire: function(b,c,d,e,f){ @@ -233,6 +255,8 @@ var firerecord = function () { } }, + + run : function () { var head = content.document.getElementsByTagName("head")[0], @@ -272,7 +296,7 @@ var firerecord = function () { case "INPUT": elm.className += ((elm.className.length > 0) ? " " : "") + "link-target-finder-selected"; - elm.addEventListener("click", handleType, false); + elm.addEventListener("keyup", handleType, false); break; case "A": @@ -316,8 +340,7 @@ var firerecord = function () { elm.addEventListener("click", handleEvent, false); break; case "TABLE": - info[1] = all[i].getAttribute("summmary"); - info[2] = all[i].getAttribute("caption"); + elm.className += ((elm.className.length > 0) ? " " : "") + "link-target-finder-selected"; elm.addEventListener("click", handleEvent, false); break; @@ -339,8 +362,7 @@ var firerecord = function () { }; - //Need to add author to this part... - //Need to add author to this part... + //rylan function handleEvent(e) { var targ; if (!e) { @@ -392,12 +414,12 @@ var firerecord = function () { taginfo[2] = targ.src; break; - case "INPUT": + /*case "INPUT": taginfo[1] = targ.name; taginfo[2] = targ.type; taginfo[3] = targ.value; - break; + break;*/ case "LINK": taginfo[1] = targ.href; taginfo[2] = targ.type; @@ -459,18 +481,18 @@ var firerecord = function () { var contents = taginfo.join(' :: ')+"\n"; - appendFile(window.content.location.href+"\n"); - appendFile(contents); + io.appendPath(path, window.content.location.href+"\n"); + io.appendPath(path, contents); e.cancelBubble = true; }; }(); -function createFile(contents) { +function createFile() { alert("created File"); var file1 = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); - file1.initWithPath("C:\\test\\" + "test.txt"); + file1.initWithPath(path); //alert("create file nullcheck" +file1.toString()); var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream); // use 0x02 | 0x10 to open file for appending. @@ -478,7 +500,7 @@ function createFile(contents) { var converter = Components.classes["@mozilla.org/intl/converter-output-stream;1"]. createInstance(Components.interfaces.nsIConverterOutputStream); converter.init(foStream, "UTF-8", 0, 0); - converter.writeString(contents.toString()); + converter.close(); // this closes foStream } diff --git a/skin/play.png b/skin/play.png new file mode 100644 index 0000000000000000000000000000000000000000..a0a95eb5edab7a56d636a4c9a5c69ced232cf43c GIT binary patch literal 1089 zcmV-H1it%;P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!T;6gLua9lbPOV4^1DG7z82Xw(bi@+|6w(f9@m;+0_BE;JHj+)*NnGE28# z^>Fa414PYKa?*27ch_I_S9Nubc{VxWr2}F+fEge=25i<#_3-%7E$VNbVT3$N`avcj6jEp_GFU=X|zJt4DW%BBHp#g1yhcBHFvkib z&3hN1jMB@qiT52myRD3zIVJW0Mq#KjmM6Kuy4Vh|{GiB4byT{x8S&5?+-oChi0ub_ z&`S06h{%4z&}SqhWJ)r?$1a`>i)F8uQRp?B0mDO;Tje|9u~KY+*JRglY{!7I5xbKQ z%E)TK4V2ogB-3uZ+`{T*(D=R^<-5Uvwo($Q9zHF0j|(guNl~8h*l|?MAmD?Hy?@SX z9*Bb9*mpZ0U&GSNgB~F_oaRDI62KY@+ov=E$PrpCrmDwU8@#_cbT4DT`23g{5=@|7 zQcfg2Rx7nQkfFZhWNh|9dpcvYrni})ebyQG2VPL_5W{jqi8BuH*xm$in4t7Y4Ko}04A<-R6@Umx$3~;IK>;Js z;Bf<8OZ-s1F-dx?#rGGB=g90Db$K1ViH0W*7=McxJ4Fz192fq zO}_uFuL@Xx+M+ftUa!j^#O@n(w<542nHXC4qJ!+YqSfqJY?gO{HTWoV6q>UuT0`HAs8PS7AsrkaBc@Z;-T-iz#fXQVMr zshepfoGObvG#rg0i9ijY@|HXL6B{+TQj&WuYU|>Du<{KXUt{@aHWPaxTt(D}W7ELU zIo7`;nO-R{>Tx2k7b|Q8rY=7u$w)L5_~$5_cH+LEQ2VMS!T^XqLeglzKKzf32zK3itEYPx#1ZP1_K>z@;j|==^1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