[mashup-dev] svn commit r9583 - in trunk/mashup/java/modules/www: .
js/wso2
svn at wso2.org
svn at wso2.org
Thu Nov 8 10:10:59 PST 2007
Author: tyrell
Date: Thu Nov 8 10:10:51 2007
New Revision: 9583
Modified:
trunk/mashup/java/modules/www/js/wso2/scraper.js
trunk/mashup/java/modules/www/scraper.html
Log:
Adding file support
Modified: trunk/mashup/java/modules/www/js/wso2/scraper.js
==============================================================================
--- trunk/mashup/java/modules/www/js/wso2/scraper.js (original)
+++ trunk/mashup/java/modules/www/js/wso2/scraper.js Thu Nov 8 10:10:51 2007
@@ -20,6 +20,10 @@
var xpathExpressionCount = 0;
+var urlCount = 0;
+
+var currentUrlVariable = "";
+
wso2.mashup.Scraper = function() {
};
@@ -40,7 +44,10 @@
wso2.mashup.Scraper.currURL = url;
//Adding html-xml tag with the given url
- scraperConfig.appendChild(new XML("<var-def name='page'><html-to-xml><http method='get' url='" + url + "'/></html-to-xml></var-def>"));
+ currentUrlVariable = "page_" + ++urlCount;
+ scraperConfig.appendChild(new XML("<var-def name='" + currentUrlVariable +
+ "'><html-to-xml><http method='get' url='" + url +
+ "'/></html-to-xml></var-def>"));
scraperConfigTextArea.value = scraperConfig;
wso2.mashup.services.getUrlContents(url, navigator.userAgent, getUrlContentsCallback);
@@ -176,7 +183,8 @@
//Adding the xpath expression to the scraper config and ypdating the text area.
scraperConfig = new XML(scraperConfigTextArea.value);
- scraperConfig.appendChild(new XML('<xpath expression="' + xpath + '"><var name="page"/></xpath>'));
+ scraperConfig.appendChild(new XML('<xpath expression="' + xpath + '"><var name="' +
+ currentUrlVariable + '"/></xpath>'));
scraperConfigTextArea.value = scraperConfig;
var sEle;
@@ -204,29 +212,29 @@
scraperConfigTextArea.selectionEnd);
};
-wso2.mashup.Scraper.SurroundWith = function (elem, tag) {
- if (elem.isTextEdit && elem.caretPos) {
- elem.caretPos.text += wordInsert;
- } else if (elem.selectionStart || (elem.selectionStart == '0')) {
- var before = elem.value.substring(0, elem.selectionStart);
- var after = elem.value.substring(elem.selectionEnd, elem.value.length);
- var selText = elem.value.substring(elem.selectionStart, elem.selectionEnd);
+wso2.mashup.Scraper.SurroundWith = function (tag) {
+ if (scraperConfigTextArea.isTextEdit && scraperConfigTextArea.caretPos) {
+ scraperConfigTextArea.caretPos.text += wordInsert;
+ } else if (scraperConfigTextArea.selectionStart ||
+ (scraperConfigTextArea.selectionStart == '0')) {
+ var before = scraperConfigTextArea.value.substring(0, scraperConfigTextArea.selectionStart);
+ var after = scraperConfigTextArea.value.substring(scraperConfigTextArea.selectionEnd, scraperConfigTextArea.value.length);
+ var selText = scraperConfigTextArea.value.substring(scraperConfigTextArea.selectionStart, scraperConfigTextArea.selectionEnd);
if (tag == "empty") {
- elem.value = before + "<empty>" + selText + "</empty>" + after;
+ scraperConfigTextArea.value = before + "<empty>" + selText + "</empty>" + after;
} else if (tag == "text") {
- elem.value = before + "<text>" + selText + "</text>" + after;
+ scraperConfigTextArea.value = before + "<text>" + selText + "</text>" + after;
+ } else if (tag == "file") {
+ scraperConfigTextArea.value = before +
+ '<file action="file_action" path="file_path" type="file_type" charset="UTF-8">' +
+ selText + "</file>" + after;
}
}
};
-
-wso2.mashup.Scraper.wrapSelectedWithEmpty = function() {
- wso2.mashup.Scraper.SurroundWith(scraperConfigTextArea, "empty");
-};
-
-wso2.mashup.Scraper.wrapSelectedWithText = function() {
- wso2.mashup.Scraper.SurroundWith(scraperConfigTextArea, "text");
-};
-
+wso2.mashup.Scraper.addHttpRequest = function () {
+ scraperConfig.prependChild(new XML('<http url="url-to-fetch" method="post" charset="UTF-8" cookie-policy="cookie_policy" username="username" password="password"></http>'));
+ scraperConfigTextArea.value = scraperConfig;
+};
\ No newline at end of file
Modified: trunk/mashup/java/modules/www/scraper.html
==============================================================================
--- trunk/mashup/java/modules/www/scraper.html (original)
+++ trunk/mashup/java/modules/www/scraper.html Thu Nov 8 10:10:51 2007
@@ -112,10 +112,10 @@
<br>
<br>
<div id="tool-bar">Tool Bar<br>
- <input type="button" value="<empty></empty>" onclick="wso2.mashup.Scraper.wrapSelectedWithEmpty();">
- <input type="button" value="<text></text>" onclick="wso2.mashup.Scraper.wrapSelectedWithText();">
- <input type="button" value="Button" onclick="return false;">
- <input type="button" value="Button" onclick="return false;">
+ <input type="button" value="Surround with <empty></empty>" onclick="wso2.mashup.Scraper.SurroundWith('empty');">
+ <input type="button" value="Surround with <text></text>" onclick="wso2.mashup.Scraper.SurroundWith('text');">
+ <input type="button" value="Surround with <file></file>" onclick="wso2.mashup.Scraper.SurroundWith('file');">
+ <input type="button" value="Add HTTP request" onclick="wso2.mashup.Scraper.addHttpRequest();">
<input type="button" value="Button" onclick="return false;">
<input type="button" value="Button" onclick="return false;">
</div>
More information about the Mashup-dev
mailing list