Get ALL Raphael IDs on a paper - raphael

Is there a way in Raphael JS to get ALL Raphael Element IDs so I can bulk update?
For example I'd like to do something like:
var allIDs = paper.getById(*);
for (var t=0; t<allIDs.length; t++)
{
paper.getById(allIDs[t]).attr({/* something */});
}
Any ideas? Thanks!

Looks like it was simpler than I thought!
paper.forEach(function (el)
{
console.log(el.id);
});

Related

Access has Many via foreach in computed property in ember

So I've got a hasMany defined as so
quests: DS.hasMany('quest')
I have a property that is supposed to go through each quest and work out the total.
The function looks like this,
questXP: function() {
var amount = 0;
this.get('quests').forEach(function(item)
{
console.log(item.get('xpReward'));
amount += parseInt(item.get('xpReward'));
});
return amount;
}.property('quests'),
I've tried adding async: true to the hasMany but it stops the forEach from working at all. At the moment it loops 3 times(I have 3 quests) but it isn't able to access any of the quest's properties.
My thought is it's related to the fact that the quests are still being loaded.
Any ideas on what I'm doing wrong?
Your computed property depends of each xpReward property. So you need to use quests.#each.xpReward istead of quests.
questXP: function() {
var amount = 0;
this.get('quests').forEach(function(item)
{
console.log(item.get('xpReward'));
amount += parseInt(item.get('xpReward'));
});
return amount;
}.property('quests.#each.xpReward'),

How to proccess code in template

i have a problem, i want to proccess with first element in foreach loop in template as PHP code example:
<?php
$i=0;
foreach($items as $rs){
if($i==0){
echo "first";
}else{
echo "not first";
}
}
?>
Pls help me in template Meteor. Thank you so much
I'm not too sure what you mean without some code of what you want to do, but I think you mean that you want to do something to the first item in a handlebars loop? If its that let me try and give it a shot:
This is a little tricky as the version of handlebars shipped with meteor does not yet do this so you need to do it manually.
Use index values in the transform
Template.hello.items = function() {
var i = 0;
return Items.find({}, { transform: function(doc) {
i++;
if(i==1) doc.first = true;
return doc;
}});
}
So this adds a virtual first field in your document if its the first one
Your html loop
{{#each items}}
{{#if first}}
This is the first item
{{/if}}
....
{{/each}}

Why can't I delete a property in a map function, in CouchDB?

I've got a view and a map function, in CouchDB. I'm simply iterating over some values in an array, an emitting them individually. I'd like to exclude a property of the documents that I am emitting, though. I was hoping to just call delete on it, but that doesn't appear to be doing anything. The value is still emitted with the property. Is this a limitation in order to keep indexing fast? My map function looks like this:
function(doc) {
if (doc.type == 'user' && doc.spaces) {
doc.spaces.forEach(function (space) {
if (space.tokens) {
space.tokens.forEach(function (token) {
emit(token.token, space);
});
}
});
}
}
Where I emit space, I'd like to delete the tokens property of it, before emitting. I don't want to expose other tokens in this data. So, I modified to code to look like this, with no luck. It still emits the full document, with tokens intact:
function(doc) {
if (doc.type == 'user' && doc.spaces) {
doc.spaces.forEach(function (space) {
if (space.tokens) {
var tokens = space.tokens;
delete space.tokens;
tokens.forEach(function (token) {
emit(token.token, space);
});
}
});
}
}
It happened the same trouble for me, now. And I was search the topic. But unfortunately, the other answer was not useful for me. Because, CouchDB is not SQL, documents has a different properties. Therefore I cannot emit with a specific properties.
After thinking, I hit on an idea for the problem. It is there:
function( doc )
{
// Remove a `seal` in the doc using a deep-copy technique.
var tmp = JSON.parse( JSON.stringify( doc ) );
// We can `delete` a property as we like!
delete tmp._rev;
// Emit `tmp`.
emit( null, tmp );
}
We've been bitten by this problem as well.
We worked around it by creating a new object and emitting that instead:
emit(token.token, {
name : space.name,
id : space.id
etc : etc
}
We found that was the best way anyway as most of the time there was no need to emit complete (child) documents and only what was required.

jQuery Equal Height Columns

http://shoes4school.project-x.me/get-involved.html
Can someone please tell me what i'm doing wrong the the jQuery column faux... I can not get it to work after trying several different methods...
The code i'm using is... my url is above
$j(".content-block").height(Math.max($("#right").height(), $(".content-block").height()));
How to faux columns on webpage
(function($){
// add a new method to JQuery
$.fn.equalHeight = function() {
// find the tallest height in the collection
// that was passed in (.column)
tallest = 0;
this.each(function(){
thisHeight = $(this).height();
if( thisHeight > tallest)
tallest = thisHeight;
});
// set each items height to use the tallest value found
this.each(function(){
$(this).height(tallest);
});
}
})(jQuery);
Firebug show this error :
preloadImages is not defined
preloadImages([

How do I refresh a TMS layer in OpenLayers?

I have a TMS layer that looks something like this:
var v = 1;
my_tms = new OpenLayers.Layer.TMS(
"My TMS",
"my_mapserver.php?v="+my_var+"&",
{ transparent: 'true', type:'png', getURL:get_my_url }
);
Where my_mapserver.php returns map tiles according to the value of v.
The app allows users to change v, and I simply want to refresh the my_tms layer, however, so far the only way I can get it to refresh is by destroying the map and recreating it.
I thought I could just do something like this:
v = 2;
my_tms = new OpenLayers.Layer.TMS(
"My TMS",
"my_mapserver.php?v="+my_var+"&",
{ transparent: 'true', type:'png', getURL:get_my_url }
);
my_tms.redraw();
However, these tiles are not getting requested when I redraw().
Any help is appreciated.
As TMS layers inherits from Grid layer you could try to call clearGrid() method to remove all existing tiles and then spiralTileLoad() to load new ones.
layer.redraw();, OpenLayers.Strategy.Refresh and clearGrid() didn't help me in reloading tiles of OpenLayers.Layer.TMS layer in OpenLayers 2.13.1, but helped:
layer.mergeNewParams({});