JQuery :: Cache The Sizzle Parsed Strings?

Apr 21, 2010

The scenario would be something like checking if an element fulfills some complex conditions, something like if(myElement.is('div.someClass[someAttribute], td.someOtherClass[someAttribute]')) ... . Is there a way to parse that string only once, maybe create some sort of "compiled" version of the check, cache it, then give it to is ? Or does jQuery cache the string after parsing it once so I don't have to do anything?

View 3 Replies


ADVERTISEMENT

JQuery :: Frameworks Using Sizzle Selector Engine?

Feb 2, 2010

I am just curious. It seems at this point of time Sizzle rules. Still I would like to know what other frameworks are using.

View 1 Replies View Related

JQuery :: Embed Data Parsed From URL Into HTML?

Feb 15, 2011

I'm trying to grab a variable from a URL and dynamically embed it into HTML code. So for instance, if I own the site test.com and I enterideo=bunny.mp4&height=720&width=480",I want the returned page to be an embedded video of bunny.mp4 at the height and width specified. I know the embed code, I just need to know how to parse the URL and write it inside of the HTML.

View 11 Replies View Related

Cached Javascript .js Files Parsed

May 30, 2007

Lets say you have a 1000 line javascript file which is linked to an everyday html file. The browser is set, by default, cache the linked javascript file (after downloading and interpreting it).

But once it's cached and put into a temp directory on the client's computer, is the cached file in an already parsed format? Or something relative? Or is it in the same format as it was on the server-side? This would mean that the .js file is parsed each time the exact same way (as long as the file itself is not changed, deleted, or renewed on the server-side).

View 2 Replies View Related

Removing A XML File That Has Been Parsed Via Ajax?

Dec 14, 2007

how to remove an XML file that I have parsed. My goal is to be able to add n number of XML files and have the ability to remove a parsed file. So, my question is, how can I remove the file I have just parsed? Code:

View 1 Replies View Related

Custome Date Object With PHP-like Text-parsed Output

Dec 6, 2002

Well, this is acutally a couple different scripts. First is the custom date object myDate which retrieves pretty much every value that you'd need from a date and sets it as a property. If no argument is supplied, the current time and date is used. If you do supply an argument, you can send an existing javascript Date object, or a string that is compatible with declaring a normal javascript Date object.

The 2nd part of this script is the method getDate (and some accompanying String methods) that allow you to retrieve the date as a string by passing it a format string just like the PHP date() (http://www.php.net/manual/en/function.date.php) function accepts. The code posted below includes sufficient (I think) examples to help you understand what is going on. You will notice that I didn't duplicate EVERY code over from PHP, and a few are slightly different. Those that I left out I felt weren't very necessary, or I didn't feel like doing the algorithm for them :D.

Both myDateObj.getDate() and PHP's date() allow you to include text into the string that you don't want parsed, but each handles it differently. In PHP, you need to escape characters normally with a backslash. For getDate you need to proceed each character with a pipe "|". So, instead of$dateStr = date("Day z");as it would be in PHP, you would usevar d = new myDate();
var dateStr = d.getDate("D|a|y| z");There are more examples of how this works below.

Note: There is also a nice arrayReplace() method for strings that is handy for doing multiple replace() operations all at once, so I guess this is really like 3 handy scripts ;)

<html>
<head>
<title>test</title>
<meta http-equiv="expires" content="0">
<script type="text/javascript">

/*** First Part of Script, the custom date object ***/

function myDate(dateStr) {
if (typeof dateStr != 'undefined') {
var d = new Date(dateStr);
this.dateString = dateStr;
}
else if (typeof dateStr == 'object')
var d = dateStr;
else
var d = new Date();
var months = ['January','February','March','April','May','June','July','August','September','October','November',' December'];
var weekDays = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
var monthDays = [31,28,31,30,31,30,31,31,30,31,30,31];

this.epoch = d.getTime();
this.epochS = Math.round(this.epoch / 1000);
this.year4 = d.getFullYear();
this.year2 = parseInt(this.year4.toString().substring(2));
this.leap = (this.year4 % 400 == 0) ? true : (this.year4 % 4 == 0 && this.year4 % 100 != 0) ? true : false;
if (this.leap) monthDays[1]++;
this.mnth = d.getMonth();
this.month = this.mnth + 1;
this.month_2 = leadingZero(this.month);
this.monthName = months[this.mnth];
this.monthNameShort = this.monthName.substring(0,3);
this.days = monthDays[this.mnth];
this.dy = d.getDay();
this.day = this.dy + 1;
this.dayName = weekDays[this.dy];
this.dayNameShort = this.dayName.substring(0,3);
this.date = d.getDate();
this.date_2 = leadingZero(this.date);
this.suffix = (this.date % 10 == 1 ) ? "st" : (this.date % 10 == 2) ? "nd" : (this.date % 10 == 3) ? "rd" : "th";
this.hours24 = d.getHours();
this.hours24_2 = leadingZero(this.hours24)
this.hours12 = (this.hours24 == 0) ? 12 : (this.hours24 > 12) ? this.hours24-12 : this.hours24;
this.hours12_2 = leadingZero(this.hours12);
this.minutes = d.getMinutes();
this.minutes_2 = leadingZero(this.minutes);
this.seconds = d.getSeconds();
this.seconds_2 = leadingZero(this.seconds);
this.millis = d.getMilliseconds();
this.ampm = (this.hours24 == 0) ? "am" : (this.hours24 >= 12) ? "pm" : "am";
this.GMTstring = d.toGMTString();
this.offset = d.getTimezoneOffset();

function leadingZero(num) {
return (num < 10) ? "0" + num : num.toString();
}
}

myDate.prototype.getDayOfYear = function() {
var total = 0;
var monthDays = [31,28,31,30,31,30,31,31,30,31,30,31];
if (this.leap) monthDays[1]++;
for (var i=0; i<this.mnth; total += monthDays[i++]) {}
total += this.date;
return total;
}

/*** Second part of script, the PHP-like parsed output ***/

myDate.prototype.getDate = function(str) {
var p = ['a','A','B','d','D','F','g','G','h','H','i','I','j','l','L','m','M','n','O','r','s','S','t','T','U', 'w','W','Y','y','z','Z'];
var r = new Array();
var i = 0;
var delChar = "|";
var sNull = "null".delimit(delChar)
r[i++] = this.ampm.delimit(delChar);
r[i++] = this.ampm.toUpperCase().delimit(delChar);
r[i++] = sNull;
r[i++] = this.date_2;
r[i++] = this.dayNameShort.delimit(delChar);
r[i++] = this.monthName.delimit(delChar);
r[i++] = this.hours12;
r[i++] = this.hours24;
r[i++] = this.hours12_2;
r[i++] = this.hours24_2;
r[i++] = this.minutes_2;
r[i++] = sNull;
r[i++] = this.date;
r[i++] = this.dayName.delimit(delChar);
r[i++] = (this.leap)?1:0;
r[i++] = this.month_2;
r[i++] = this.monthNameShort.delimit(delChar);
r[i++] = this.month;
r[i++] = this.offset;
r[i++] = this.GMTstring.delimit(delChar);
r[i++] = this.seconds_2;
r[i++] = this.suffix.delimit(delChar);
r[i++] = this.days;
r[i++] = sNull;
r[i++] = this.epochS;
r[i++] = this.dy;
r[i++] = sNull;
r[i++] = this.year4;
r[i++] = this.year2;
r[i++] = this.getDayOfYear();
r[i++] = sNull;
for (i=0; i<p.length; i++)
p[i] = "/" + p[i] + "(?!|)/g";
return str.arrayReplace(p, r).replace(/|/g,"");
}

String.prototype.arrayReplace = function(arrP, arrR) {
var p, s = this;
for (var i=0; i<arrP.length; i++) {
var flags = arrP[i].substring(arrP[i].lastIndexOf("/")+1);
var regex = arrP[i].substring(1,arrP[i].lastIndexOf("/"));
p = new RegExp(regex, flags);
s = s.replace(p, arrR[i]);
}
return s;
}

String.prototype.delimit = function(char) {
var s = "";
for (var i=0; i<this.length; i++) {
s += this.charAt(i) + char;
}
return s;
}

</script>
</head>

<body>

<script type="text/javascript">

/*** Example using current date/time ***/

var md1 = new myDate();
document.write(md1.getDate("l jS of F Y h:i:s A")+"<br>");
document.write(md1.getDate("T|o|d|a|y| i|s| m.d.y")+"<br>");
document.write(md1.getDate("D M j G:i:s Y")+"<br>");
document.write("It " + (md1.leap?"is":"is not") + " a leap year<br>");
document.write("The unix epoch occurred " + md1.epochS + " seconds ago");
document.write("<hr>");

/*** Example using javascript Date object as argument ***/

var d1 = new Date(2000, 01, 02, 15, 15, 15);
var md2 = new myDate(d1);
document.write(md2.getDate("l jS of F Y h:i:s A")+"<br>");
document.write(md2.getDate("T|o|d|a|y| i|s| m.d.y")+"<br>");
document.write(md2.getDate("D M j G:i:s Y")+"<br>");
document.write("It " + (md2.leap?"is":"is not") + " a leap year<br>");
document.write("The unix epoch occurred " + md2.epochS + " seconds ago");
document.write("<hr>");

/*** Example using Date object compatible string as argument ***/

var md3 = new myDate("December 10, 1978 12:23:00");
document.write(md3.getDate("l jS of F Y h:i:s A")+"<br>");
document.write(md3.getDate("T|o|d|a|y| i|s| m.d.y")+"<br>");
document.write(md3.getDate("D M j G:i:s Y")+"<br>");
document.write("It " + (md3.leap?"is":"is not") + " a leap year<br>");
document.write("The unix epoch occurred " + md3.epochS + " seconds ago");
</script>
</body>
</html>

View 4 Replies View Related

Strings Not Replacing Strings

Sep 25, 2007

I've been learning javascript for about a week and I'm really struggling right now. This is a homework assignment to help in learning loops and arrays.

What I want to happen is when a form button is hit it will replace the array from the one previous instead of just adding to it. Hopefully that makes sense. What do I need to do? here's my code....

View 1 Replies View Related

JQuery :: How To Cache Data

Aug 6, 2011

I am sorry if this has been asked already. I searched but could not find a suitable answer.I am making a simple RSS reader (using jquery mobile) and I need to be able to cache the resulted feed.To understand better let me explain alittle. I have a page where the users selects the desired category. After that he is taken to a different page where the titles of news are. here the feed is read for the first time. When the user click on a title he is taken to another page where I want to display the content of the selected news article.Sincethe feed was already retrieved on the previous page, I want to be able to cache it so that it won't be retrieved again.Any idea how I best do this?

View 4 Replies View Related

JQuery :: Cannot Find Way To Cache Content

Nov 14, 2011

I have a DOM manipulated page - manipulated with jQuery.The user follows a link on this page - but when he uses the back button all the previous JSON data is lost and the original (unmanipulated) static page is shown.This is putting a *STOP* on our project.I cannot find a way to cache the content - have tried headers and mod_cache in apache... it still simply shows the original page.To make things worse different browsers give different results.

View 1 Replies View Related

JQuery :: Check Whether An Image Is In The Cache?

Apr 2, 2011

When using the function to switch images as shown below, I want to check if the image is already in the cache to prevent showing the css .loading class. The .complete() object just made a lot of trouble but I couldn't use it probably. The switchImage Function is fired when pressing a thumbnail or a prev/next button.Is their any solution to check whether the image/url I want to load is already in the cache?

[Code]...

View 2 Replies View Related

JQuery :: $load- Images In Cache?

Aug 20, 2009

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>

<body bgcolor="#ffffff" text="#000066"> I'm working with some large images that are in markup but being
processed into queued animations. If image is already loaded but I call $load will it pull image from
browser cache? I want to use the success to do some size processing

View 1 Replies View Related

JQuery :: Can't Run Code To Test Html5 Cache / Fix It?

Oct 25, 2010

I found some code on this site to test and display the html5 caching process, but it doesn't seem to work when using jquery.

I get an error [code]...

View 1 Replies View Related

JQuery :: Remove/Disable Cache In Ajax Load?

May 7, 2011

I want to remove/refresh the cache in Ajax load .. Here is the method i used for Ajax Load..

var $tabs = $('#tabs').tabs({
tabTemplate: '<li><a href="<%= "#"%>{href}"><%= "#"%>{label}</a> <span class="ui-icon ui-icon-close">Remove Tab</span></li>',
add: function(event, ui) {

[Code]....

View 1 Replies View Related

JQuery :: Getting Attr With Strings That Contain?

Jan 11, 2012

If the element i'm getting has an attr that contains string like this....

<span names="Joes|Joe's">Joes|Joe's</span>

When we get the contents of attr st, there is an error because of the ' in they're.

View 3 Replies View Related

JQuery :: Concatenate Two Strings Or Variables?

Jul 27, 2011

i have the following code:

var myHeight = $(".sidebar").outerHeight(true); /* returns Height */
alert(myHeight); /* returns an integer e.g. 500 */
var addPixels = "px"; /* String variable with value "px" */
$(".text").css({"padding-bottom":myHeight}); /* myHeight = 500 NOT 500px */

[Code]....

View 4 Replies View Related

JQuery :: Converting Objects To Strings?

Jun 16, 2009

I have the following code, which I am trying to pass in 5 variables.

<script type="text/javascript">
$(function(){
$('#DrainStackDiameter').change(function(){

[code]....

View 2 Replies View Related

JQuery :: Highlight Certain Text Strings?

Jul 3, 2010

What I want to do specifically is add a CSS class to strings that start with an @ symbol. I can't seem to find any examples online and I haven't had enough experience with jquery to figure this out on my own.

I want it to highlight either the first word only, or just the line that the @ symbol is found on.

View 8 Replies View Related

JQuery :: Use Strings In An Array As Selectors?

Sep 9, 2011

The follow jQuery code doesn't work. Does that mean jQuery doesn't support such a usage?

Code JavaScript:
var selectors = ['#header', '#content', '#footer'];
$(selectors.join(',')).addClass("new");

View 3 Replies View Related

Jquery :: Jcarousel Gallery - Get A Screencap - Image Occurs Frequently After Clearing The Cache In Safari

Mar 12, 2011

Here is a link to my gallery: [URL] Here is a screencap of my problem: [URL] This just seems to randomly happen sometimes, and I can't figure out why. Very rarely, it will be one or two of the thumbnails that's lower, but I didn't get a screencap and haven't been able to get it to happen again. The problem with the main image occurs frequently after clearing the cache in Safari. I'm totally stumped, because other times it loads just fine, and seems to always be fine when the page is reloaded or a thumbnail is clicked.

View 2 Replies View Related

JQuery :: Dynamic JSON Variable Strings?

Apr 18, 2010

I have variables coming in from JSON files via AJAX calls. Each file will have 3 variables for different background colours. Depending on which button is clicked the background will change colour to the value specified in the JSON file.

[Code]...

View 1 Replies View Related

JQuery :: Hiding Single Strings On A Page?

Apr 20, 2010

Is there a simple way to just hide some text in a page? Browsing the documentation I found the .hide() function. But how can I tell jQuery to hide all occurrences of a specific string? If I use the :contains() Selector I can find the text but can only hide the element that contains the text not just the text.

View 2 Replies View Related

JQuery :: Add A Function To Appended Html Strings?

Oct 7, 2011

I want to create a questions creation page. It has a Question Text Box and a Add Button.When users press the add button, there will be a newQuestion Text Box and a new Add Button appear in the next line. But the old Add Button will become a Delete Button and change its functionality.[code]I put all the Add Buttons and Minus Buttons into two different classes, ".buttonPlus" and ".buttonMinus".The .buttonPlus works well when the line is added by the main html. But it fails to work when it is added by the .append() function. It simply adds the .buttonPlus's CSS code to its button, but the$(".buttonPlus").click(function (event) {...} is NOT attached to the new buttonPlus.

View 1 Replies View Related

JQuery :: Script Not Supporting Massive Strings

Oct 27, 2011

I'm programming a function that breaks a massive string (2 million + characters) into "manageable" chunks of 500,000 characters. The function goes as follows [code]...

As you can see, everything should work fine, and the function should return a stringified json array (which would be parsed and sent to a server) but the loop stops after the first interval. When I decrease the length of "v" using substr to 5 characters, the loop works fine. What could the problem be?

View 3 Replies View Related

JQuery :: Strings - Extract Data From A Textfield ?

Mar 31, 2010

To manipulate strings, but forexample when Iam programming an event with jquery and extract data from a textfield for example I can,t do this var msg=msg.subtring(0,5);

Or for example this does not work->

View 2 Replies View Related

JQuery :: 1.4 Slower Than 1.3x When Using Append Or Html With Large Strings?

Jan 18, 2010

I've been using jquery for some time, and was very excited about the improvements in jquery 1.4 I have found however, that in one particular instance, jquery 1.4 seems to be performing slower than 1.3x, to the point that it has forced me to downgrade the script. I use jquery heavily throughout my web application; in this particular case, when a very large block of html consisting of a bunch of <tr>s is .appended (or .htmled, tried both) to a table, jquery 1.4 in firefox will give the "unresponsive script" error, prompting the user to stop, debug, or continue. The same block of html works perfectly fine in jquery 1.32 (and quite fast too). I haven't had time to do too much experimentation, as this is in a production environment, and thus downgrading was necessary as it was breaking the page, but I would love to figure out why this is happening so that I may optimize the code sometime in the near future. Have the improvements to .html resulted in code that causes higher cpu usage, or that would have a much higher overhead on longer strings? I've commented much of the code around the call, so that it pretty much consists of an ajax call that returns a chunk of html, which is inserted to a table (that I first empty). I thought it might be something with event bindings that occur after the insertion, but removal of these event bindings does not resolve the unresponsive script error. It seems the .html or .append is doing it. Note that this code, as is, works perfectly in jquery 1.3, even with event bindings, etc.

Does anyone have any ideas? My next step was going to be to try returning the entire table including the <table> tags, and doing a replace instead of an append, but if anyone has other suggestions to try, please let me know. Also, just as an aside, what do you guys consider the 'best practice' to be when returning dynamic data for a table (server side sorting, filtering etc from a db) ? Do you return just the data in json, and repeatedly clone a row element, replacing the values in each row (thus decreasing the size of the ajax call, but increasing the client side processing), or return the full html, and replace the innerHTML of the table?

View 2 Replies View Related

Using Document.Writeln After Document Is Parsed

Oct 28, 2009

I have three files:

HTML file (default.htm)

Code:
<body>
THE QUICK BROWN FOX JUMPED OVER THE LAZY OLD DOG
<script type="text/javascript" src="testing.js"></script>

[Code]....

When I run the above files the original text on default.htm is wiped and replaced by the document.writeln text in test2.js. What I wanted to happen was for this text to be added to the default.htm page (and not wipe what was already there). I believe this is because the htm file has already parsed.

I know people say you should use innerHTML and not document.write or document.writeln. Unfortunately, I have no control over the contents of the first file (default.htm) or the third file (test2.js) but the content in test2.js will always be in either document.write or document.writeln format. So I cannot use innerHTML.

My problem is how can I (from within the second file, testing.js) ensure that the page is not parsed before the third file has finished.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved