Changeset 18692
- Timestamp:
- 09/03/08 01:46:18 (4 months ago)
- Files:
-
- 1 modified
-
lang/javascript/userscripts/poptip.user.js (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/userscripts/poptip.user.js
r18671 r18692 31 31 20080824 0.0.10 Error handling (HTTP error / HTML node error) 32 32 Add a rule (Tabelog) 33 20080824 0.1.0 XSLT option for popup area 34 35 == TODO == 36 + Write some XSLT examples 37 + Change the icon to smaller one 38 + Re-create as a Firefox extension 33 39 34 40 */ 35 41 36 var VERSION = '0. 0.10';42 var VERSION = '0.1.0'; 37 43 var DEFAULT_DELAY_MSEC = 400; 38 44 var HIDE_DELAY_MSEC = 400; … … 40 46 var ERROR_MESSAGE_POPUP_ELEMENT_EMPTY = 'Error : No such node'; 41 47 var ERROR_MESSAGE_HTTP = 'HTTP Error'; 42 43 var popupTil = null;44 45 48 46 49 // == IMAGE == … … 166 169 linkElement: '//a[@class="keyword"]', 167 170 popupElement: '//div[@class="box-curve-bar"]//div[@class="section"]', 168 delay: 1 000,169 stripe: true,171 delay: 1500, 172 stripe: false, 170 173 style: { 171 174 fontSize: '80%', … … 339 342 border: '1px solid #444' 340 343 } 344 }, 345 { 346 description: 'XSLT Example', 347 url: '^http://www\\.example\\.com/.*', 348 linkElement: 'id("hoge")', 349 popupElement: 'id("fuga")', 350 disabled: true, 351 xslt : <><![CDATA[<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> 352 <xsl:output method='html'/> 353 <xsl:template match='/'> 354 <div>EXAMPLE</div> 355 </xsl:template> 356 </xsl:stylesheet> 357 ]]></> 341 358 } 342 359 … … 427 444 style:SITEINFO[i].style, 428 445 containerHTML:SITEINFO[i].containerHTML, 446 xslt:SITEINFO[i].xslt, 429 447 delay:SITEINFO[i].delay 430 448 }); … … 477 495 if (http.status == 200) { 478 496 var elementList = getElementsByXPath(popupElementXPath, xml); 479 480 if (elementList.length > 0) { 497 if (option.xslt) { 498 // apply XSLT stylesheet 499 var template = new XSLTProcessor(); 500 var stylesheet = createXsltDocumtntByString(option.xslt); 501 template.importStylesheet (stylesheet.documentElement.firstChild); 502 var result = template.transformToFragment(xml, document); 503 elmContainer.appendChild(result); 504 } else if (elementList.length > 0) { 481 505 // "popupElement" found 482 506 if (option.containerHTML) { … … 506 530 popupAreaObj.append(elmContainer); 507 531 popupAreaObj.show(targetElement); 508 } catch (ex) {} 532 } catch (ex) { 533 } 509 534 } 510 535 }; … … 567 592 568 593 /* 569 Utilities (cited from AutoPagerize)594 Utilities 570 595 */ 571 596 function createXsltDocumtntByString(str) { 597 var htmlDoc = document.implementation.createDocument(null, 'html', null); 598 var range = document.createRange(); 599 range.selectNodeContents(htmlDoc.documentElement); 600 htmlDoc.documentElement.appendChild(range.createContextualFragment(str)); 601 return htmlDoc; 602 } 603 604 /* 605 cited from AutoPagerize 606 */ 572 607 function createHTMLDocumentByString(str) { 573 608 var html = str.replace(/^[\s\S]*?<html(?:\s[^>]*)?>\s*|\s*<\/html\s*>[\S\s]*$/ig, '');
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)