I am writing a Firefox Add-On that currently is depending on jQuery for the following things:
Selectors
Animations
A special .live("focus") hail-mary event-catching maneuver that happens to work with jQuery 1.4.2 (but not 1.4.4)
jQuery isn't well suited for functioning inside XUL, and it's a miracle we've gotten this far with it. We're trying to remove the jQuery requirements, the first two are easy (animations are simple, and we can use .querySelector() instead of jQuery), but the .live has proven impossible to do on our own. I've tried reading the source code, but I haven't been able to piece it apart.
What is the jQuery .live function doing? There's clearly a lot more going on than document.addEventListener("focus"/"focusin",function_to_pick_apart_events). What else is going on here?
Already checked exisitng questions for this, but didn't find an exact match.
My aim is to replace characters (like spaces) on a webpage with a small image using css.
Example:
<p><span>This is a text</span></p>
becomes:
<p><span>ThisIMGisIMGaIMGtext</span></p>
(where IMG stands for a visible image (middot-pic for a space f.e.))
I cannot think of a suitable css selector. But myabe one of you guys (or girls) know a solution. Is this possible at all?
Hi All,
i am using two frames in a page. Mainframe have a page with text box to get input and gives the result url.
Needs:
I want to show this page in the topframe.
I want to set focus to the text box control in the mainframe always. using the following code but giving null error.
parent.frames['mainFrame'].document.getElementById('form1:txtbox').focus();
<frameset rows="550,0" cols="1008" frameborder="NO" border="0" framespacing="0">
<frame src="" id="topFrame" target="topFrame" runat="server" scrolling="no"></frame>
<frame src="Search.aspx" runat="server" id="mainFrame"></frame>
</frameset>
I have the following code for writing draw calls to a "back buffer" canvas, then placing those in a main canvas using drawImage. This is for optimization purposes and to ensure all images get placed in sequence.
Before placing the buffer canvas on top of the main one, I'm using fillRect to create a dark-blue background on the main canvas.
However, the blue background is rendering after the sprites. This is unexpected, as I am making its fillRect call first.
Here is my code:
render: function() {
this.buffer.clearRect(0,0,this.w,this.h);
this.context.fillStyle = "#000044";
this.context.fillRect(0,0,this.w,this.h);
for (var i in this.renderQueue) {
for (var ii = 0; ii < this.renderQueue[i].length; ii++) {
sprite = this.renderQueue[i][ii];
// Draw it!
this.buffer.fillStyle = "green";
this.buffer.fillRect(sprite.x, sprite.y, sprite.w, sprite.h);
}
}
this.context.drawImage(this.bufferCanvas,0,0);
}
This also happens when I use fillRect on the buffer canvas, instead of the main one.
Changing the globalCompositeOperation between 'source-over' and 'destination-over' (for both contexts) does nothing to change this.
Paradoxically, if I instead place the blue fillRect inside the nested for loops with the other draw calls, it works as expected...
Thanks in advance!
I'm having an issue trying to get an accurate running total for my calculations. When you enter numbers into the input field I get an accurate total for that line item, but the grand total comes out to a higher number. Note that this is a dynamic form and that the id's will change depending on how many form fields I have added to the form. Also, I have it set to make the calculations onKeyUp for each input field instead of a calculate button.
The code that calculates a single item is this:
function calcLineItem(id) {
var id = $(id).attr("id");
var Item1 = $("#Item1" + id).val();
var Item2 = $("#Item2" + id).val();
var Item3 = $("#Item3" + id).val();
function calcTotal(Item1, Item2, Item3){
var total;
total = Math.round((Item1 * Item2) * Item3);
return total;
}
$("#total" + id).text(calcTotal(Item1, Item2, Item3));
calcAllFields();
}
This will give me the total of this particular input field. The function at the end, calcAllFields(), is supposed to do the calculations for all items in my form to give me the grand total of all input fields:
function calcAllFields(id) {
var id = $(id).attr("id");
$('#target1').text($("#total" + id).map(function() {
var currentValue = parseFloat(document.getElementById("currentTotal").value);
var newValue = parseFloat($("#total" + id).text());
var newTotal = currentValue + newValue;
document.getElementById("currentTotal").value = newTotal;
return newTotal;
}).get().join());
}
The variable currentTotal is getting its value from a hidden field on my form:
<input type="hidden" id="currentTotal" value="0">
As I enter numbers a field the calculation for that line will be accurate, but the grand total will be inaccurate because the value for currentTotal will continue to increment with every key stroke I make in the input field. Any ideas on how to avoid this from happening?
I need a little piece of advice.
I have a test page with 2 fields: word number and URL
Also i have a button Push.
When i push the button i want to open the specified URL (it's local html files) and highlight the word at the "word number" position
Of course the code must ignore element nodes (<p>,<b>,<table> and so on)
hello,
I cannot make the click() function work in IE7, for the tags links on the top of the page in this website: http://www.sanstitre.ch/drupal/portfolio?tid[0]=38
Everything works perfectly in other browsers and, the z-index of the header is bigger than the rest of the content.
thanks
Hi,
Actually i have iframe which has some important content in it ,but problem is that how can i have add content to my page in which that iframe resides.
Thanks
Hi all,
I am having an issue positioning a background image using the following jquery background position command in Firefox, Google Chrome, and Safari. The code works correctly in IE 8.
$('#element).css({ backgroundPosition: 'xpx ypx' });
The x position of the image is calculated dynamically based on window size and the y position is static. The css appears to be modified correctly, however, the background image I am attempting to overlay is absent. See jscript code below:
$(window).resize(function () {
// image positioning variables
var windowwidth = $(window).width();
var imgwidth = $('#imgFluid').width();
var offset = $('#divFluidBlur').offset();
// calculate and implement position
blurPositionLeft = (windowwidth - imgwidth) - offset.left;
$('#divFluidBlur').css({ backgroundPosition: blurPositionLeft + 'px' + ' 30px' });
// debug: display actual css Background Position of element to text box
$("#txtActualBackgroundpos").val(document.getElementById ("divFluidBlur").style.backgroundPosition);
Thanks in advance for your help,
Andrew
I have a search form with inputs and selects, and when any input/select is changed i run some js and then make an ajax query with jquery. I want to stop the user from making further changes to the form while the request is in progress, as at the moment they can initiate several remote searches at once, effectively causing a race between the different searches.
It seems like the best solution to this is to prevent the user from interacting with the form while waiting for the request to come back. At the moment i'm doing this in the dumbest way possible by hiding the form before making the ajax query and then showing it again on success/error. This solves the problem but looks horrible and isn't really acceptable. Is there another, better way to prevent interaction with the form? To make things more complicated, to allow nice-looking selects, the user actually interacts with spans which have js hooked up to them to tie them to the actual, hidden, selects. So, even though the spans aren't inputs, they are contained in the form and represent the actual interactive elements of the form.
Grateful for any advice - max. Here's what i'm doing now:
function submitQuestionSearchForm(){
//bunch of irrelevant stuff
var questionSearchForm = jQuery("#searchForm");
questionSearchForm.addClass("searching");
jQuery.ajax({
async: true,
data: jQuery.param(questionSearchForm.serializeArray()),
dataType: 'script',
type: 'get',
url: "/questions",
success: function(msg){
//more irrelevant stuff
questionSearchForm.removeClass("searching");
},
error: function(msg){
questionSearchForm.removeClass("searching");
}
});
return true;
}
> if (((test>=0) && (test<=90)) || ((test>270) && (test<=360))){n_y=1;}
> else {n_y=-1;}
I need the magnitude of trigonometric function in order to determine the sign of the trigonometric function for an angle falling into a particular quadrant.
My plan is to replace the code above with something equivalent.
Here is what I want to do in pseudo-code.
n_y = cos(test) / (magnitude of cos (test));
This will give me same thing. Abs() only takes integers. Any help is appreciated.
var obj = {},ar = [],nothing=null,empty=undefined,word ='string',headorTail = true;
console.log(typeof obj) //object
console.log(typeof ar)//object
console.log(typeof nothing)//object
console.log(typeof empty)//undefined
console.log(typeof word)//string
console.log(typeof headorTail)//boolean
But how can i get the type of obj,ar,nothing as "object, array,null" - what is the best way to achieve this?
I have a standard list...
<ul>
<li><a href="#">blah 1</a></li>
<li><a href="#">blah 2</a></li>
<li><a href="#">blah 3</a></li>
<li><a href="#">blah 4</a></li>
</ul>
And my jQuery:
$('ul li a').live('click', function() {
var parent = $(this).parent('li');
});
What I want to find out is the parent li's position in the list of the clicked link e.g. clicking on blah 3 would give me 2, blah 4 would give 3 etc.
Any ideas?
Hello all!
I have a small problem on IE browser (actually on Google Chrome too)
I have this js code
function createDoc(url) {
var xhttp = ajaxRequest();
var currentLocationBase = window.location.href;
currentLocationBase = currentLocationBase.substr(0,currentLocationBase.lastIndexOf("/") + 1);
var u = currentLocationBase + url;
xhttp.open("GET", u, false);
xhttp.send(null);
var xml = xhttp.responseXML;
return xml;
}
/**
* Builds an AJAX reques handler.
*
* @return The handler.
*/
function ajaxRequest() {
var xhttp = null;
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else if (window.ActiveXObject){
// Internet Explorer 5/6
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
} else {
}
return xhttp;
}
In Firefox this code works great, but not in IE and Google Chrome
Seems that the error is given at the line
xhttp.open("GET", u, false);
Can anyone help me to understand what i'm doing wrong?
Thanks
I'm using the following function to get a URL parameter.
function gup(name, url) {
name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');
var results = new RegExp('[\\?&]'+name+'=?([^&#]*)').exec(url || window.location.href);
return results == null ? null : results[1];
}
It works only if the parameter has a value, for example.
gup('a', 'http://example.com/page.php?a=1&b=2');
will return 1. But if I try
gup('a', 'http://example.com/page.php?a&b=2');
It returns null. I want it to return true because parameter "a" exists in that url, even though it has no value it's still there and gup() should return true. Could I get a bit of help rewriting this? I'm not that good with regex.
{"paging": {"pageNum":2,"action":"Next","type":"","availableCacheName":"getAllFunds","selectedCacheName":"","showFrom":101,"showTo":200,"totalRec":289,"pageSize":100},
"Data":[{"sourceCodeId":0,"radio_fund":"individua
l","availableFunds":[],"fundId":288,"searchName":[],"fundName":"Asian Equity Fund A Class Income","srcFundGrpId":"PGI","firstElement":0,"las
tElement":0,"totalElements":0,"pageList":[],"standardExtract":true}]
I have json file with above format with two fileds,one paging and one is Data array.
I able to retrieve values of paging,but i am not able to retrieve the values of data array with .each function of jquery.
Any suggestions or inputs really appreciated.
I have code like that:
var xPola = 10, //how many cols
yPola = 10, //how many cols
bokPola = 30, //size of cell
body = document.getElementsByTagName('body')[0];
var tablica = document.createElement('table');
body.appendChild(tablica);
for( var y = 0; y < yPola; y++ ) {
var rzad = document.createElement('tr');
tablica.appendChild(rzad);
for( var x = 0; x < xPola; x++ ) {
var pole = document.createElement('td');
pole.setAttribute('width', bokPola);
pole.setAttribute('height', bokPola);
rzad.appendChild(pole);
}
};
it works fine in FF, Chrome & Opera (it displays 10x10 table with 30px width&height rows). In IE nothing happens. I check in firebug lite and it is in HTML section, inside BODY tag but i see nothing. Whats wrong?
Hello all,
I have a form with a submit button. I have attached a click event to that submit button using JQuery. Once I did this my form wasn't submitting, I thought this was because of the event I added- if I remove that click event it submits the form successfully.
I have tried giving my form an id and calling the submit function but this was not successful either. What can I do?
$('#submit_gen').click(function() {
$('#genbtn').html('<img src="images/ajax-loader.gif" alt="loading" />');
$('#action_form').submit();
});
The HTML:
<form id="action_form" action="generate.php" method="post" enctype="multipart/form-data">
<input id="file_upload" type="file" name="upload" onchange="file_select();"/>
<input type="text" id="overlay_input">
<div id="genbtn" class="genbtn">
<input id="submit_gen" type="submit" value="Upload">
</div>
</form>
Thanks all
Heya,
I have just implemented the excellent jQuery UI autocomplete.
http://jqueryui.com/demos/autocomplete/
There is a strange bug in IE 8 (and maybe other versions).
When you select an item from the box of suggestions in IE 8 the cursor moves to the begining of the textbox before the suggested word which has just been inserted.
Firefox put the cursor after the inserted word.
Does anyone know of a fix for this?
Regards
Steve