https://wiki.greasespot.net/api.php?action=feedcontributions&user=TrashF&feedformat=atomGreaseSpot Wiki - User contributions [en]2024-03-29T05:36:51ZUser contributionsMediaWiki 1.41.0https://wiki.greasespot.net/index.php?title=Talk:Code_snippets&diff=3796Talk:Code snippets2009-05-24T17:20:03Z<p>TrashF: </p>
<hr />
<div>== jQuery problems? ==<br />
Anyone else getting only "$ is not defined" when trying the example jQuery script? The other (older) method works, though. --[[User:TrashF|TrashF]] 13:20, 24 May 2009 (EDT)<br />
<br />
== July 8 2007 ==<br />
Edit undone. 146.151.111.140, it looks like you deleted about 3 quarters of the page, so i undid your change. This does mean that you will have to make the intended changes again...<br />
<br />
== Restructure? ==<br />
<br />
This page is rather messy. Does anyone have ideas for how to better structure this information? --[[User:Henrik|Henrik]] 05:48, 5 June 2007 (EDT)<br />
<br />
It is getting a bit big, perhaps separating it out into different pages, each with a short explanation, the code and some examples. The main page would just have the links and a one line description. Also some more logical categories could help. --[[User:Alien scum|Alien scum]] 18:43, 6 June 2007 (EDT)<br />
<br />
== array.forEach in XPath example ==<br />
<br />
Re: http://wiki.greasespot.net/index.php?title=Code_Snippets&diff=prev&oldid=1784<br />
<br />
Restored that example, it works fine (using Fx 2) without Prototype. See e.g. http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach.<br />
<br />
Just try it:<br />
<br />
// ==UserScript==<br />
// @name Example<br />
// @namespace wiki<br />
// @include *<br />
// ==/UserScript==<br />
<br />
function $x(p, context) {<br />
if (!context) context = document;<br />
var i, arr = [], xpr = document.evaluate(p, context, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);<br />
for (i = 0; item = xpr.snapshotItem(i); i++) arr.push(item);<br />
return arr;<br />
}<br />
<br />
var i, paragraphs = $x("//p"); <br />
paragraphs.forEach(function(paragraph) { // Loop over every paragraph <br />
paragraph.innerHTML = "Halloa!"; <br />
});<br />
<br />
--[[User:81.225.78.185|81.225.78.185]] 18:18, 25 March 2007 (EDT)<br />
<br />
<br />
<br />
== Make script accessible to Firebug ==<br />
<br />
How can I use this script and how does it work?</div>TrashF