Monday, May 14, 2012

Applescript editor not responding

I did the following script in order to identify itunes songs that doesn't have artwork. It's based on other script that I found in net.



tell application "iTunes"
repeat with a in every track of playlist "Library"
if not (exists (artwork 1 of a)) then
add (get location of a) to (playlist "noart")
end if
end repeat
end tell


It seems to be working, it compiles well, and because I can that it in event log windows:



tell application "iTunes"
count every track of playlist "Library"
--> 10684
exists artwork 1 of item 1 of every track of playlist "Library"
--> true
exists artwork 1 of item 2 of every track of playlist "Library"
--> true


But after 4 hundred tracks, it starts to run slowly, and applescript stops responding after one thousand tracks.



I thought that maybe I could be exhausting my mac memory, but in Activity Monitor, I can see that Applescript is consuming 100% CPU and less than 50MB of memory. I'm running macos 10.7.4 on a macbook pro (i7 with 4GB ram).



As you can see my itunes library has 10684 tracks. It's not a small library, but it's not a huge one.



Does anyone has any advice? Or a script to identify tracks without artwork?



TIA,



Bob





How i run cygwin using java program?

I have installed cygwin on window to start crawling. It work well.
Now i want to run cygwin and run a crawl program at starting of cygwin using java program code.



If you provide some code for it ,it will be great help for me.





Way to simulate class categorization in Java

Some programming languages have the feature of adding "Categories" to classes (for example Objective-C), this means, adding new functionality to a class without subclassing.



I really find it useful, but I can't imagine a way of simulating this feature in Java.



So the question is:



How would look an elegant pattern to simulate class categories in Java? What I'm really looking for is achieving the same effect rather of making it the same way.





combo box drop down is not working even after I changed the height in designer

I am trying to give a fix for a combo box drop down list, since its not listing down properly .Only one item is being shown in the list rest all you can see by using arrow keys. I increased the height in designer too, anyways that is not the issue, why because its listing down in some machines and the same version is not working on my machine. I used the DDX_Control to assign this control to a variable.
Do we need to consider any other things which can impact the drop down list??



environment : vs2008, windows 7





How to convert com.google.appengine.api.datastore.Entity to my Entity Object?

Why I get an casting error when I try to get some database object using com.google.appengine.api.datastore.Query



For example:
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Query q = new Query("User");



PreparedQuery pq = datastore.prepare(q);

for (Entity entity : pq.asIterable()) {
User myUser = (User)entity;
}




Halftone Images In Python

I am working on a project that requires me to separate out each color in a CYMK image and generate a halftone image that will be printed on a special halftone printer. The method used is analogues to silk screening in that the process is almost identical. Take a photo and break out each color channel. Then produce a screen for the half tone. Each color screen must have it's screen skewed by 15-45 (adjustable) degrees. Dot size and LPI must be calculated from user configurable values to achieve different effects. This process I am told is used in silk screening but I have been unable to locate any information that explains CYMK halftoning. I find plenty for reducing to a single color and generating new print style b/w halftone image.



I would guess that I need to: 1. split the file into it's color channels. 2. generate a monochrome halftone image for that channel. 3. Skew the resultant halftone image by the number of degrees * channel number. Does anyone know if this is the correct approach?



Does anyone know of any existing python code for this? Or of any good explanations for this process or algorithms?





Spring RMI: handleRemoteConnectFailure

I have a RMI client/server configuration created with Spring 3.0.



When client and server run on the same machine at the url:



  rmi://localhost:1099/myService


everything is ok. When I run the client on a different machine (server run now on 192.168.1.67) and the client "points" to:



  rmi://192.168.1.67:1099/myService 


I can see this error message from the client:



  org.spring...RmiClientInterceptor handlerRemoteConnectFailure. 
Could not connect to Rmi Service [rmi://192.1681.67:1099/myService]


The server is configured in this way:



    <bean id="myService" class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="service" ref="myService"/>
<property name="serviceInterface" value="org.myapp.MyService"/>
<property name="serviceName" value="myService"/>
<property name="alwaysCreateRegistry" value="true"/>
</bean>

<bean id="myService" class="org.myapp.MyServiceImpl" />


and the client:



    RmiProxyFactoryBean rpfb = new RmiProxyFactoryBean();
rpfb.setServiceInterface(MyService.class);
rpfb.setLookupStubOnStartup(true);
rpfb.setRefreshStubOnConnectFailure(true);
RMICustomClientSocketFactory socketFactory = new RMICustomClientSocketFactory();
socketFactory.setTimeout(5000);
rpfb.setRegistryClientSocketFactory(socketFactory);
rpfb.setServiceUrl(getRmiUrl(address, port));
rpfb.afterPropertiesSet();


I checked with a sniffer the port 1099 of the server, and when the client starts its process I can see some data "dispatched" on the server side:



 JRMI..K
...192.168.1.65..
..192.168.1.65....
P....w"..........................D.M...;.t..myService
Q....w.....e...7B+@5..s}.....5org.springframework.remoting.rmi.RmiInvocationHandlerpxr..java.lang.reflect.Proxy.'. ..C....L..ht.%Ljava/lang/reflect/InvocationHandler;pxpsr.-java.rmi.server.RemoteObjectInvocationHandler...........pxr..java.rmi.server.RemoteObject.a...a3....pxpw2.
UnicastRef..127.0.1.1..../.T~.X.....e...7B+@5...x
R
S
T...e...7B+@5..


My question is: Why if client & server run on the same machine, everything is ok but on different machines I get this problem? and how to fix it?



My Answer:



I run the server on windows and client on linux (ubuntu) and everything was ok.
When I run the server on linux and client on windows I get the problem.



My fix is running the server with: -Djava.rmi.server.hostname=192.168.1.67 on Linux.





Using Loaders managing Cursors

I write an Android app and asking myself how to manage cursors. I know how to get data through a cursor back from the database. I don't want to handle the lifecycle of these cursors by myself.
For Android 2.x and below I used, according to the Android API, methods like managedQuery and startManagingCursor. These methods are now deprecated. Instead of these methods I should use the Loader class for example (CursorLoader). As far as I know CursorLoader must be backed by a ContentProvider. The Android SDK recommends ContentProvider only if I want to share my data. But I just want to write a simple app, where no data should be shared.
In all my research I just find tutorials about Loaders in combination with ContentProvider. The SDK says that I can also write my own Loader over the class AsyncTaskLoader. Does someone already have some experience how to implement such a Loader? Are there any best practices? Are there any good tuturials how to implement such a Loader?
Or is it just better to implement a ContentProvider, so I can use the CursorLoader (this means a lot of work for just having a managed cursor)?





Split a sentence/string in to words using Jquery

I have a sentece/H1 and I need this to split so that it would look like below



Original state



<h1>This is the heading </h1>


after



<h1>This <br> 
is <br>
the <br>
heading </h1>




how to annotate an entity with a list of itself in it using Hibernate Annotation

I have a category entity that has a category as parent and a list of category as child. here's it's declaration:



@Entity
@Table(name="CATEGORYENTITY")
public class CategoryEntity extends BaseEntity<Long> {
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue
@Column(name="ID")
private Long id;

@Column(name="NAME")
private String name;

@Column(name="VIEWSCOUNT")
private Integer viewsCount;

@OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
@JoinColumn(name="CATEGORY_ID")
private List<CategoryEntity> childCategories;

@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="CATEGORY_ID")
private CategoryEntity parent;

setters and getters...


It works fine when saving and updating but when try to get all of the categories... for each child returns a parent too!!! I mean if i have a mainCat and this mainCat has 4 child for example, when getting all categories from db, it returns all of the four child and surprisingly 4 mainCat... the weird part is that returned objects are correct and their properties are set correct and 4 mainCat are same!!! what should I do?





How to return "text/html" content for AJAX call using a template engine in sinatra?

SO, I have a problem with Ajax (using JQuery) and Sinatra.



I have a route:



get '/ajx' do
content_type 'text/html', :charset => 'utf-8'
slim :mypartitial, :layout => false
end


which is to be called via Ajax "GET":



  $(document).ready(function() {
$('#vars').click(function(event){
$.ajax({
type: "GET",
url: "/ajx",
data: "",
success: function(data) {
$("#result").html(data)
}
});
});
});


But I get no html output and nothing is rendered. I suppose the problem is here



 slim :mypartitial, :layout => false


but I have no idea how to return a valid html still using the template engine.





error upload file with node.js

app.js

var formidable = require('formidable')
, http = require('http')
, util = require('util');



app.get('/song/add', function(req, res){

res.writeHead(200, {'content-type': 'text/html'});
res.end(
'<form action="/song/upload" enctype="multipart/form-data" method="post">'+
'<input type="text" name="title"><br>'+
'<input type="file" name="upload" multiple="multiple"><br>'+
'<input type="submit" value="Upload">'+
'</form>'
);
});
app.post('/song/upload', function(req, res){

var form = new formidable.IncomingForm();
form.parse(req, function(err, fields, files) {
res.writeHead(200, {'content-type': 'text/plain'});
res.write('received upload:\n\n');
res.end(util.inspect({fields: fields, files: files}));
});
return;
});


Now when I try uploading the file, the browser just keep loading forever.....





Simple connection between an int and QComboBox?

Somehow I feel really silly to ask this question, but I just spent 2 hours reading this site and other sources of information, and I only find complicated solutions, while I strongly believe there must be a really simple one for my problem.



In TCL/TK for example, I can define a variable and bind it to a combobox in 2 lines of code. Similarly in Qt/C++, I have an int defined in one of my classes, and I want the QCombobox to set that int to the number (index) of the selected element.



Do I really have to delve in the depths of model/view and its classes to achieve this?





remount /system on rooted Archos 80 g9

On archos g9 there is an ext4 filesystem for /, and no separate filesystem for /system. Tablet is temporary rooted and ics is installed



After adb remount I get something strange like (I am unable to test it now):



Adb remount error: Remount successful


When I try to remount "/" from adb shell it doesn't work either. But I really need to put apps to /system/app to test them with system level privelegies (not 3rd party app).
Is there any way to do that on rooted archos g9?



Thanks





Result of `rake routes` in ruby script

rake routes is very slow (30s in my computer) but I need it for routing spec.



So, is there a way to get all routes like rake routes? (or how rake routes works?)



I use Rails 3 and all I have seen is for Rails 3, and I found nothing I can use in the rails doc.





Merge two files of different lengths in Python

I have two files with with the same number of columns, but a different number of rows. One file is a list of timestamps and a list of words, the second file is a list of timestamps with a list of sounds in each of the words, i.e.,:



9640 12783 she
12783 17103 had
...


and:



9640 11240 sh
11240 12783 iy
12783 14078 hv
14078 16157 ae
16157 16880 dcl
16880 17103 d
...


I want to merge these two files and create a list of entries with the word as one value, and the phonetic transcription as the other, i.e.,:



[['she', 'sh iy']
['had', 'hv ae dcl d']
...


I'm a complete Python (and programming) noob, but my original idea was to do this by searching the second file for the second field in the first file, and then appending them into a list. I tried doing it this way:



word = open('SA1.WRD','r')
phone = open('SA1.PHN','r')
word_phone = []

for line in word.readlines():
words = line.split()
word = words[2]
word_phone.append(word)

for line in phone.readlines():
phones = line.split()
phone = phones[2]
if int(phones[1]) <= int(words[1]):
word_phone.append(phone)

print word_phone


This is the output:



['she', 'had', 'your', 'dark', 'suit', 'in', 'greasy', 'wash', 'water', 'all', 'year', 'sh', 'iy', 'hv', 'ae', 'dcl', 'd', 'y', 'er', 'dcl', 'd', 'aa', 'r', 'kcl', 'k', 's', 'uw', 'dx', 'ih', 'ng', 'gcl', 'g', 'r', 'iy', 's', 'iy', 'w', 'aa', 'sh', 'epi', 'w', 'aa', 'dx', 'er', 'q', 'ao', 'l', 'y', 'iy', 'axr']


As I said, I'm a total noob, and some suggestions would be very helpful.





Transmit data to client on specific page, based on SQL Server column or row update

I want to achieve something specific using ASP.NET and SQL Server. Let's for example that I have several pages, each one with each own identification (ie. id=1, id=5). Furthermore, let's assume that for each one of those id I have a row in the database:



for example:



Row 1:



id = 1



name = myname1



Row 2:



id = 2



name = myname2



What I want to do is that when the specific row or even a specific value in a column changes, it will trigger an event that can send a specific data to ONLY those clients that are visiting the page with a specific id that was changed.



for example: if row 1 column name changed from 'name1' to 'name2', and the ID of the primary key is 5, I want all those who visit the page with id=5 to recieve an event in the client side.



I want to prevent myself for developing a client code that will contentiously send requests to a webservice and query that specific row by id to see if it was update or a specific column value was changed.



I am developing my app using ASP.NET 4.5.



Thanks





Account activation by email

There have been lots of discussion on this topic in this forum but they cover php,joomla,wodpress mainly.



I am making a website for my project using jsp where i am sending the registration mail confirmation through the help of gmail sendmail service.If I wanted to send an account activation link to a person who registered on my website in my home-machine, how would this procedure work???
Also any link that can help me do this using jsp only?



Lastly, which one is better-sending an activation link or a security code to make registration valid???





Is a SSL'ed JSON API that uses cookies for authentication and nonces generally secure?

If I build an SSL'ed API that authenticates with a session ID held within a cookie, adds a nonce as a query parameter, and always responds with a JSON 'Object' response (as opposed to a JSONP-style response with a callback), is it secure in general, and in particular against XSRF?



The intent with such an API to only have it available to pages on my own domain, and to be free to expose private data (such as username and emails) through this API (but not be consumable by other domains)--and retain a reasonable amount of simplicity for developers on the team.



Let me at least share what I understand about this approach, and why I think it's secure. Please enlight me if wrong!:




  • A <script> tag dropped on a 3rd-party domain to our site would send my cookies, but would not be able to parse the JSON object response (and the response would always deliberately be a JSON object at the top level). Also, I need to make sure that API calls that affect state on the server are all protected by non-GET method access, because <script> tags must use GET and so can not cause havok by attempt to call state-changing calls (in other words, the API would be adherent to REST in so far as HTTP methods go). Also, I deliberately do not support JSONP because it would be a security hole.

  • Man-in-the-middle used to hijack cookies (the session) is not a concern because I'm using SSL with valid certificates.

  • Replay attacks are a temporally limited concern because of the use of a nonce will limit how long one could send in a replay of an HTTPS request, because the server will make sure that the API call is only valid for a small amount of time in a typical nonce-validating way.

  • XMLHttpRequest can not make cross-domain calls, so it can't request anything from my site.

  • CORS (Cross ORigin Resource Sharing) is not of concern because I don't have a crossdomain.xml file or any other advertisement of cross-domain support associated with HTML 5.

  • An iframe in a 3rd-party site doesn't matter because even though it can load my page graphically, the host site can't access any data within that iframe, and because I've made no attempt to support cross-domain iframe communication (so they can attempt to set # on the iframe URL like folks do to enable communication between cross-domain iframes, but my page won't be responsive to it).



EDIT:
A nonce would also protect against even GET requests (i.e., <script> tags) as russau says. In thinking on that specifically, I like the idea of asking for a nonce in a 'POST' API call that is not itself nonce protected; it should be the case that only XmlHTTPRequest's on the same domain can then generate a nonce to begin with. This seems to be a simple way of making the generation of nonce's developer-friendly. (i.e., nothing server-side for the website/javascript developers--just ask for your nonce from the same API you are using to develop against, and make requests with that nonce until you get a 'bad nonce' response--then ask for a new one, and repeat.





Footer not 100% in IE

I'm still learning HTML5 so I understand I need the shim in there, so it's there and I've testing my site out on many difference platforms & browsers, both on windows and mac and seems the only thing that's preventing me from launching my site is the footer script in IE. I have the shim, so shouldn't the work?



It's not spanning 100% when I'm telling it to. It works beautifully in all browsers but IE. It's also not spanning across on mobile devices. Are both of these cause by the lack of one snippet of code?



HTML



<footer>
<ul class="footer-widgets">
<li class="widget3"><h6>Testimonials</h6>
<p>When I first came to Amber about creating a website for my business I wasn't sure what to expect. After working with her I've found that the whole experience is easy and a lot less expensive then I was previously quoted by another company. She described each step that was required for my projects and worked hard to bring my vision to life.</p>

<p>Amber Goodwin is a very creative &amp; passionate individual with an appetite for design, I would recommend her for any and all your business branding needs!</p>
<a href="http://www.nuggetcity.com">WWW.NUGGETCITY.COM</a>
</li>

<li class="widget4"><h6>Contact</h6>
<p class="footer-title">Are you looking for a new website?</br>Need to update your existing one?</br>Or just need some information?</p>
<img src="img/title-footer-call.jpg" border="0" usemap="#Map">
<map name="Map">
<area shape="rect" coords="-1,0,114,39" href="mailto:info@ambergoodwin.com" target="_blank">
</map>

</ul>

<div id="footer-bottom">
<p>&copy; 2012 AMBER GOODWIN | Creative &amp; Fresh Designs</p>
</div>
</footer>


CSS



footer { width: 100%; height: 500px; background: url(img/BG-footer.jpg) repeat-x; background-color: #211e1b; clear: both; color: #b1b1b1; }

.footer-widgets { width: 905px; margin: 0 auto; padding: 0px; padding-top: 70px; }
.footer-widgets p { width: 94%; }
.footer-widgets a { text-decoration: underline; color: #f8d54b; }
.footer-widgets a:hover { text-decoration: none; color: #f8d54b; }
.footer-widgets li { height: auto; list-style-image: none; list-style-type: none; float: left; color: #b1b1b1;}
.footer-widgets li ul li {color: #fff; margin-left: -50px; margin-top: -15px;}
.footer-widgets li h2 { font-size: 1.4em; font-weight: normal; letter-spacing: 1px; line-height: 30px; text-align: left; }

.widget1 { width: 289px; }
.widget2 { width: 608px; }
.widget3 { width: 580px; }
.widget4 { width: 316px; }
.widget4 p { width: 100%; }


#footer-bottom { width: 100%; height: 50px; padding-bottom: 20px; background-color: #1a1715; border-top: 2px solid #272322; color: #fff; display: block; margin-top: 400px; }
#footer-bottom p { width: 600px; margin-left: 370px; height: 30px; font-size: 1em; line-height: 25px; color: #eee; margin-top: 20px; /*margin-top: 60px;*/ position: absolute;left: 50%; margin-left: -450px;}


HEAD SECTION



<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<title>Amber Goodwin | Graphic & Web Designer based in the Okanagan Valley </title>
<meta name="description" content="">
<meta name="author" content="Amber Goodwin">

<meta name="viewport" content="width=device-width,initial-scale=1">


<link rel="stylesheet" href="style.css">
<link href="lightbox.css" rel="stylesheet">

<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->


You can view the working site here.



This is what it looks like in IE
enter image description here



I bet there is just one thing I'm missing that will fix this eh? Any advice and help is, as always appreciated. Thanks!





how get all routes in my rails application?

can I get all routes in my rails application? I need an output like rake routes and put the result in an array.



Is it possible?, how?



Thanks!





Mercurial hook not executing properly

This should be a very simple thing to have run, but for some reason it won't work with my Mercurial repository. All I want is for the remote repo to automatically run hg update whenever someone pushes to it. So I have this in my .hg/hgrc file:



[hook]
changegroup = hg update


Simple, right? But for some reason, this never executes. I also tried writing a shell script that did this. .hg/hgrc looked like this:



[hooks]
changegroup = /home/marc/bin/hg-update


and hg-update looked like this:



#!/bin/sh
hg help >> /home/marc/works.txt;
hg update >> /home/marc/works.txt;
exit 0;


But again, this doesn't update. The contents of hg help are written out to works.txt, but nothing is written out for hg update. Is there something obvious I'm missing here? This has been plaguing me for days and I just can't seem to get it to work.



Update



Okay so again, using the -v switch on the command line from my workstation pushing to the remote repo doesn't print any verbose messages even when I have those echo lines in .hg/hgrc. However, when I do a push from a clone of the repo on the same filesystem (I'm logged in via SSH), this is what I get:




bash-3.00$ hg -v push ../test-repo/
pushing to ../test-repo/
searching for changes
1 changesets found
running hook prechangegroup: echo "Remote repo is at `hg tip -q`"
echo "Remote repo wdir is at `hg parents -q`"
Remote repo is at 821:1f2656753c98
Remote repo wdir is at 821:1f2656753c98
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
running hook changegroup: echo "Updating.... `hg update -v`"
echo "Remote repo is at `hg tip -q`"
echo "Remote repo wdir is at `hg parents -q`"
Updating.... resolving manifests
getting license.txt
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Remote repo is at 822:389a6c7276c6
Remote repo wdir is at 822:389a6c7276c6


So it works, but again only when I push from the same filesystem. It doesn't work if I try pushing to the repo from another workstation over the network.





Changing TabView: Resize TabView & Window

I made an application which have a preferences window with 2 tabs.
The first tab have a lots of prefs settings in it, but the second one is very small...



I'd like that the tabview & the window resize when we switch between these 2 tabs.



I act like that, but it doesn't seems to work, when I switch view the "Networks settings" tab is being reduced and disapear (like if the height was going from origin to 0 with animation).



Here is my code (.m):



- (void)tabView:(NSTabView *)tabView
didSelectTabViewItem:(NSTabViewItem *)tabViewItem
{
NSRect frame;
int height;

if ([[tabViewItem identifier] isEqualTo:@"Panel settings"]) {
height = 400;

} else if ([[tabViewItem identifier] isEqualTo:@"Network settings"]) {
height = 200;

}

frame = [[tabView window] frame];

frame.size.height = height;
frame.origin.y += height;

[[tabView window] setFrame:frame display:YES animate:YES];
}


Note that I linked the tab view to delegate.
My window is linked to the NSWindow * PrefWindow referencing outlet.



Thanks for your help!





How to get the CSS rules compatible with a node?

It's possible to know what CSS rules is applied to a specific node?



Example:



<div class="test-node">
<strong>Test</strong>
</div>


And the CSS rules:



div           { color: blue }
div:hover { color: green; }
.test-node { font-weight: bold; }

div > strong { color: red; }


So, the div node is affected by two rules div and .test-node and the div:hover if hover node only. The strong node is affected by div and div:hover rule, because it is inner a div, but the color property is overwrited by your own rule div > strong (example http://jsfiddle.net/yyf9v/).



Basically I need discovery how I can do the samething that Chrome Inspector does in javascript. If you use Chrome, go to Inspector (CTRL + Shift + J, Elements and select a node). You will se a Styles tab, that show element.style rule (attribute style basically) and the Matched CSS Rules... I need this!





Android dynamic background

I am somewhat of a new android developer and have a question regarding changing the background dynamically at runtime.



What I want to do is set a background color in a LinearLayout Tag, and later change that background color in my activity class. This code below is not working. Am I missing something or is this the wrong approach for trying to change the background color in a linear layout



LinearLayout lv = (LinearLayout)findViewById(R.id.ChoiceLayout);
lv.setBackgroundColor(0x000080);


Thanks in advance





Is there a way to make "rake routes" look better?

I am always forced to make my terminal window two dual monitors wide just to see read them right. I'm not a stickler for buttery GUI's, but this is bordering retarded.



Is there a pretty print for this command?





How to request a random row in SQL?

What is the best way to request a random row in pure SQL?





jQuery and MooTools Conflict

Okay, so I got jQuery to get along with MooTools with one script, by adding this at the top of the jQuery script:



var $j = jQuery.noConflict();


and then replacing every:



$(


with



$j(


But how would you get MooTools to like the following script that using jQuery??



Thanks in advance for any input,



Tracy



//Fade In Content Viewer: By JavaScript Kit: http://www.javascriptkit.com

var fadecontentviewer={
csszindex: 100,
fade:function($allcontents, togglerid, selected, speed){
var selected=parseInt(selected)
var $togglerdiv=$("#"+togglerid)
var $target=$allcontents.eq(selected)
if ($target.length==0){ //if no content exists at this index position (ie: stemming from redundant pagination link)
alert("No content exists at page number "+selected+"!")
return
}
if ($togglerdiv.attr('lastselected')==null || parseInt($togglerdiv.attr('lastselected'))!=selected){
var $toc=$("#"+togglerid+" .toc")
var $selectedlink=$toc.eq(selected)
$("#"+togglerid+" .next").attr('nextpage', (selected<$allcontents.length-1)? selected+1+'pg' : 0+'pg')
$("#"+togglerid+" .prev").attr('previouspage', (selected==0)? $allcontents.length-1+'pg' : selected-1+'pg')
$target.css({zIndex: this.csszindex++, visibility: 'visible'})
$target.hide()
$target.fadeIn(speed)
$toc.removeClass('selected')
$selectedlink.addClass('selected')
$togglerdiv.attr('lastselected', selected+'pg')
}
},

setuptoggler:function($allcontents, togglerid, speed){
var $toc=$("#"+togglerid+" .toc")
$toc.each(function(index){
$(this).attr('pagenumber', index+'pg')
})

var $next=$("#"+togglerid+" .next")
var $prev=$("#"+togglerid+" .prev")
$next.click(function(){
fadecontentviewer.fade($allcontents, togglerid, $(this).attr('nextpage'), speed)
return false
})
$prev.click(function(){
fadecontentviewer.fade($allcontents, togglerid, $(this).attr('previouspage'), speed)
return false
})
$toc.click(function(){
fadecontentviewer.fade($allcontents, togglerid, $(this).attr('pagenumber'), speed)
return false
})
},

init:function(fadeid, contentclass, togglerid, selected, speed){
$(document).ready(function(){
var faderheight=$("#"+fadeid).height()
var $fadecontents=$("#"+fadeid+" ."+contentclass)
$fadecontents.css({top: 0, left: 0, height: faderheight, visibility: 'hidden'})
fadecontentviewer.setuptoggler($fadecontents, togglerid, speed)
setTimeout(function(){fadecontentviewer.fade($fadecontents, togglerid, selected, speed)}, 100)
$(window).bind('unload', function(){ //clean up
$("#"+togglerid+" .toc").unbind('click')
$("#"+togglerid+" .next", "#"+togglerid+" .prev").unbind('click')
})
})
}
}




setInterval(funtion(),time) change time on runtime

i want to change setInterval funtion time when my code is running.



i try this



<script type="text/javascript">
$(function () {
var timer;
function come() { alert("here"); }
timer = setInterval(come, 0);
clearInterval(timer);
timer = setInterval(come, 10000);
});
</script>


first SetInterval not work!!





Type Error when using prototypes

I'm just getting started on Prototypes, and I'm trying to test different things on a website I'm developing. But I stumbled upon an error and I'm not sure why, because I was using that property before and it worked.



I ain't no experienced JavaScript developer, I'm still learning, but here's what I got:



var defaults = {
local_storage_key : "Cluster",
plugin_navigation : ".navigation",
plugin_wrapper : "content-wrapper",
iqns_class : ".iqn"
}

var Clusters = function(environment, options){

this.options = $.extend({}, defaults, options);

this.environment = environment;

this.viewport = $(window);

this.viewport_width = this.viewport.width();
this.viewport_height = this.viewport.height();

this.data_key = this.options.local_storage_key;

this.iqns_class = this.viewport.find(this.options.iqns_class);

this.iqn = this.iqns_class.parent();

this.shop_initiated = false;

this.plugin_navigation = this.options.plugin_navigation;

this.plugin_wrapper = this.options.plugin_wrapper;

this.initiate_plugin(this.plugin_navigation, {
containerID : this.plugin_wrapper,
first : false,
previous : false,
next : false,
last : false,
startPage : this.get_local_storage_data(),
perPage : 6,
midRange : 15,
startRange : 1,
endRange : 1,
keyBrowse : false,
scrollBrowse: false,
pause : 0,
clickStop : true,
delay : 50,
direction : "auto",
animation : "fadeInUp",
links : "title",
fallback : 1000,
minHeight : true,
callback : function(pages) {
this.set_local_storage_data(pages.current);
}
});

this.initiate_auxiliars();

this.set_environment();

};

Clusters.prototype.set_local_storage_data = function(data_val) {
return localStorage.setItem(this.data_key, data_val);
};

Clusters.prototype.get_local_storage_data = function() {
return +(localStorage.getItem(this.data_key) || 1);
};

Clusters.prototype.shop_iqns_selected_class = function() {
var self = this;
if (this.viewport_width < 980) {
$(this.iqns_class).each(function(index, element) {
var element = $(element);
$(self.iqn).on('click', function() {
if (element.hasClass('selected')) {
element.removeClass('selected');
} else {
element.addClass('selected');
}
});
});
}
}

Clusters.prototype.initiate_plugin = function(plugin_navigation, plugin_options) {
return $(plugin_navigation).jPages(plugin_options);
}

Clusters.prototype.initiate_auxiliars = function() {
return this.shop_iqns_selected_class();
}

Clusters.prototype.set_environment = function() {
if(this.environment == "Development") {
less.env = "development";
less.watch();
}
}

var cluster = new Clusters("Development");


I'm sure there's something I'm doing wrong or misunderstood about Prototyping, because otherwise I wouldn't get any errors. I'm just asking for some opinions or some directions on what I'm doing wrong, and what I should do or shouldn't do.



This is the error I get:



Uncaught TypeError: Object #<Object> has no method 'set_local_storage_data' on line 53