From: <dos...@us...> - 2014-09-26 21:02:56
|
Revision: 4884 http://sourceforge.net/p/mp-plugins/code/4884 Author: doskabouter Date: 2014-09-26 21:02:46 +0000 (Fri, 26 Sep 2014) Log Message: ----------- Added option for previous and next pages Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs 2014-09-26 21:02:46 UTC (rev 4884) @@ -39,10 +39,17 @@ private const string btwebId = "btweb_id"; - public static void AddLinksToPage(GeckoDocument document) + private static string previousUrl; + private static string nextUrl; + + public static Tuple<string, string> AddLinksToPage(GeckoDocument document, Settings settings) { + previousUrl = null; + nextUrl = null; + int maxId = GetMaxId(document); - AddLinksToPage(document, maxId + 1); + AddLinksToPage(document, maxId + 1, settings); + return new Tuple<string, string>(previousUrl, nextUrl); } public static GeckoHtmlElement GetElement(string linkId, GeckoDocument document) @@ -96,8 +103,16 @@ return new Point(0, 0); } - private static int AddLinksToPage(GeckoDocument document, int id) + private static void Check(GeckoAnchorElement element, string[] tags, ref string url) { + if (String.IsNullOrEmpty(url)) + foreach (string tag in tags) + if (element.TextContent.ToUpperInvariant().Contains(tag.ToUpperInvariant())) + url = element.Href; + } + + private static int AddLinksToPage(GeckoDocument document, int id, Settings settings) + { Dictionary<string, int> hrefs = new Dictionary<string, int>(); GeckoElementCollection links = document.Links; MyLog.debug("page links cnt : " + links.Count<GeckoHtmlElement>()); @@ -131,6 +146,12 @@ newId = id++; hrefs.Add(url, newId); } + + if (!String.IsNullOrEmpty(url) && element is GeckoAnchorElement) + { + Check((GeckoAnchorElement)element, settings.PreviousTags, ref previousUrl); + Check((GeckoAnchorElement)element, settings.NextTags, ref nextUrl); + } } else newId = id++; @@ -264,7 +285,7 @@ GeckoElementCollection iframes = document.GetElementsByTagName("iframe"); MyLog.debug("page iframes cnt : " + iframes.Count<GeckoHtmlElement>()); foreach (GeckoIFrameElement element in iframes) - id = AddLinksToPage(element.ContentDocument, id); + id = AddLinksToPage(element.ContentDocument, id, settings); return id; } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2014-09-26 21:02:46 UTC (rev 4884) @@ -81,6 +81,8 @@ private bool clickFromPlugin = false; private bool aeroDisabled = false; + private Tuple<string, string> prevNextUrls; + #region Constants public const int PluginWindowId = 54537689; #endregion @@ -659,6 +661,19 @@ return; #endregion } + + if (prevNextUrls != null) + switch (action.wID) + { + case Action.ActionType.ACTION_PREV_CHAPTER: + if (!String.IsNullOrEmpty(prevNextUrls.Item1)) + webBrowser.Navigate(prevNextUrls.Item1); + return; + case Action.ActionType.ACTION_NEXT_CHAPTER: + if (!String.IsNullOrEmpty(prevNextUrls.Item2)) + webBrowser.Navigate(prevNextUrls.Item2); + return; + } base.OnAction(action); } @@ -893,7 +908,7 @@ #endregion if (!settings.UseMouse) - DomHelper.AddLinksToPage(webBrowser.Document); + prevNextUrls = DomHelper.AddLinksToPage(webBrowser.Document, settings); #region reset zoom if (settings.ZoomPage) Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs 2014-09-26 21:02:46 UTC (rev 4884) @@ -52,6 +52,8 @@ public GUIFacadeControl.Layout View { get; set; } public string UserAgent { get; set; } + public string[] PreviousTags; + public string[] NextTags; private const string section = "btWeb"; #region Singleton @@ -73,6 +75,16 @@ Path.Combine("Windows", "xulrunner")); } + public static string TagsToString(string[] tags) + { + return String.Join(";", tags); + } + + public static string[] StringToTags(string tags) + { + return tags.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + } + private void LoadFromXml() { string dir = Config.GetFolder(Config.Dir.Config); @@ -110,6 +122,9 @@ LastUrl = xmlreader.GetValueAsString(section, "lastUrl", string.Empty); UserAgent = xmlreader.GetValueAsString(section, "useragent", string.Empty); + PreviousTags = StringToTags(xmlreader.GetValueAsString(section, "previousTags", string.Empty)); + NextTags = StringToTags(xmlreader.GetValueAsString(section, "nextTags", string.Empty)); + UseProxy = xmlreader.GetValueAsBool(section, "proxy", false); Server = xmlreader.GetValueAsString(section, "proxy_server", "127.0.0.1"); Port = xmlreader.GetValueAsInt(section, "proxy_port", 8888); @@ -174,6 +189,9 @@ xmlwriter.SetValue(section, "bookmark", View); xmlwriter.SetValue(section, "useragent", UserAgent); + xmlwriter.SetValue(section, "previousTags", TagsToString(PreviousTags)); + xmlwriter.SetValue(section, "nextTags", TagsToString(NextTags)); + xmlwriter.SetValueAsBool(section, "proxy", UseProxy); xmlwriter.SetValue(section, "proxy_server", Server); xmlwriter.SetValue(section, "proxy_port", Port); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2014-09-26 21:02:46 UTC (rev 4884) @@ -131,6 +131,11 @@ this.label1 = new System.Windows.Forms.Label(); this.cmbConfirmLink = new System.Windows.Forms.ComboBox(); this.chkRemote = new System.Windows.Forms.CheckBox(); + this.tabPage6 = new System.Windows.Forms.TabPage(); + this.textBoxNext = new System.Windows.Forms.TextBox(); + this.label39 = new System.Windows.Forms.Label(); + this.textBoxPrevious = new System.Windows.Forms.TextBox(); + this.label38 = new System.Windows.Forms.Label(); this.label15 = new System.Windows.Forms.Label(); this.label16 = new System.Windows.Forms.Label(); this.label17 = new System.Windows.Forms.Label(); @@ -142,6 +147,7 @@ this.label22 = new System.Windows.Forms.Label(); this.comboBox4 = new System.Windows.Forms.ComboBox(); this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.contextMenuStrip1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); @@ -1300,6 +1306,58 @@ this.chkRemote.Text = "Show diagnose on status bar"; this.chkRemote.UseVisualStyleBackColor = true; // + // tabPage6 + // + this.tabPage6.Controls.Add(this.textBoxNext); + this.tabPage6.Controls.Add(this.label39); + this.tabPage6.Controls.Add(this.textBoxPrevious); + this.tabPage6.Controls.Add(this.label38); + this.tabPage6.Location = new System.Drawing.Point(4, 25); + this.tabPage6.Name = "tabPage6"; + this.tabPage6.Padding = new System.Windows.Forms.Padding(3); + this.tabPage6.Size = new System.Drawing.Size(562, 476); + this.tabPage6.TabIndex = 5; + this.tabPage6.Text = "Prev/Next"; + this.tabPage6.UseVisualStyleBackColor = true; + // + // textBoxNext + // + this.textBoxNext.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxNext.Location = new System.Drawing.Point(9, 91); + this.textBoxNext.Name = "textBoxNext"; + this.textBoxNext.Size = new System.Drawing.Size(547, 22); + this.textBoxNext.TabIndex = 3; + this.toolTip1.SetToolTip(this.textBoxNext, "Values must be separated by \";\""); + // + // label39 + // + this.label39.AutoSize = true; + this.label39.Location = new System.Drawing.Point(6, 72); + this.label39.Name = "label39"; + this.label39.Size = new System.Drawing.Size(64, 16); + this.label39.TabIndex = 2; + this.label39.Text = "Next tags"; + // + // textBoxPrevious + // + this.textBoxPrevious.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxPrevious.Location = new System.Drawing.Point(9, 33); + this.textBoxPrevious.Name = "textBoxPrevious"; + this.textBoxPrevious.Size = new System.Drawing.Size(547, 22); + this.textBoxPrevious.TabIndex = 1; + this.toolTip1.SetToolTip(this.textBoxPrevious, "Values must be separated by \";\""); + // + // label38 + // + this.label38.AutoSize = true; + this.label38.Location = new System.Drawing.Point(6, 14); + this.label38.Name = "label38"; + this.label38.Size = new System.Drawing.Size(90, 16); + this.label38.TabIndex = 0; + this.label38.Text = "Previous tags"; + // // label15 // this.label15.AutoSize = true; @@ -1452,6 +1510,8 @@ this.groupBox10.PerformLayout(); this.groupBox9.ResumeLayout(false); this.groupBox9.PerformLayout(); + this.tabPage6.ResumeLayout(false); + this.tabPage6.PerformLayout(); this.ResumeLayout(false); } @@ -1570,5 +1630,11 @@ private System.Windows.Forms.ComboBox cmbUserAgent; private System.Windows.Forms.CheckBox cbOverrideUserAgent; private System.Windows.Forms.CheckBox chkDisableAero; + private System.Windows.Forms.TabPage tabPage6; + private System.Windows.Forms.TextBox textBoxNext; + private System.Windows.Forms.Label label39; + private System.Windows.Forms.TextBox textBoxPrevious; + private System.Windows.Forms.Label label38; + private System.Windows.Forms.ToolTip toolTip1; } } \ No newline at end of file Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2014-09-26 21:02:46 UTC (rev 4884) @@ -502,6 +502,9 @@ cmbUserAgent.Text = settings.UserAgent; cbOverrideUserAgent.Checked = !String.IsNullOrEmpty(cmbUserAgent.Text); + textBoxPrevious.Text = Settings.TagsToString(settings.PreviousTags); + textBoxNext.Text = Settings.TagsToString(settings.NextTags); + chkProxy.Checked = settings.UseProxy; txtHttpServer.Text = settings.Server; txtHttpPort.Text = settings.Port.ToString(); @@ -543,6 +546,9 @@ else settings.UserAgent = String.Empty; + settings.PreviousTags = Settings.StringToTags(textBoxPrevious.Text); + settings.NextTags = Settings.StringToTags(textBoxNext.Text); + settings.UseProxy = chkProxy.Checked; settings.Server = txtHttpServer.Text; settings.Port = Int32.Parse(txtHttpPort.Text); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2014-09-26 21:02:46 UTC (rev 4884) @@ -112,12 +112,12 @@ <value>2.0</value> </resheader> <resheader name="reader"> - <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> - <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> - <metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>180, 22</value> </metadata> <data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64"> @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABM - CgAAAk1TRnQBSQFMAgEBAwEAAUgBAQFIAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CgAAAk1TRnQBSQFMAgEBAwEAAVgBAQFYAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -172,10 +172,16 @@ Cw== </value> </data> - <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>26, 16</value> </metadata> - <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>285, 22</value> + </metadata> + <metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>285, 22</value> + </metadata> + <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>46</value> </metadata> </root> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |