?

Log in

Javascript's Journal
 
[Most Recent Entries] [Calendar View] [Friends]

Below are the 20 most recent journal entries recorded in Javascript's LiveJournal:

[ << Previous 20 ]
Tuesday, March 29th, 2011
9:54 am
[zyada]
Javascript vs. css
Is there any way to determine what the body text(foreground) color is in javascript, if you are using css to set the text color?

Look at the select_die function
Friday, March 25th, 2011
4:19 pm
[zyada]
This is really a basic html question, but could anyone tell me why there is so much white space between the title of this page and the images right below it?

http://zyada-stuff.com/ThirtyDots/ThirtyDots.php

And yes, I know that using tables for layout is eeeeeevil, but it is faster to code for simple layouts.
Monday, November 15th, 2010
2:38 pm
[someprivatetime]
Is this acceptable code to redirect mobile users?
After looking through many pages showing fairly large chunks of JS code (of which I am not fluent) I found this very very short code block which appears to work after a quick test from a Desktop and Mobile device. Is this good enough to use for a non-enterprise site?

<script>

if (navigator.userAgent.indexOf("Mobile") != -1) {
            window.location = "http://Domain.com/mobile.html"
            }
else {
    <!--Do nothing, remain on page-->
}

</script>


Thanks for any help! :)
Monday, November 8th, 2010
11:44 pm
[hipmaestro]
Thursday, October 21st, 2010
4:00 pm
[munchmo]
Need help with javascript
I have a form that has some fields that are being dynamically generated through javascript. This form goes through a validation process and I want to make sure that the fields that are generated dynamically are actually being filled in. The problecm is, it doesn't appear to be able to do that.Look at my code behind the cutCollapse )
Saturday, September 25th, 2010
11:34 pm
[etaranov]
Is there a way to enter password in protected video on Vimeo
I want to protect my videos on Vimeo using password, but allow users of my site to watch embedded videos without entering password. Is there a way to send keypress events to enter password in onLoad page event? 
Friday, September 24th, 2010
1:52 am
[hipmaestro]
Monday, September 6th, 2010
11:05 pm
[zyada]
Help with variable scope?
I have a variable that I want to retain its value between function calls. The page is here: http://zyada-stuff.com/SpreadingRoots/temp.html

The function is an event listener, and the variable is map_marker0. If I could get the variable to retain its value between calls, line #45 would erase the marker so that it could be reset to a new spot. Right now, the page just creates a new marker.
Tuesday, August 24th, 2010
6:46 pm
[perkov]
JavaScript. 2 issues
Hello.
I'm a newbie in JavaScript (and jQuery, too).
I've got some little troubles with it.

First. I'd love to know how to obtain an ID of clicked element inside click event handler.
According to the book "Learning jQuery" by Jonathan Chaffer and Karl Swedberg, I gotta use "this.id" construction.
Perhaps this book is little outdated because it doesn't work under jQuery 1.4.2.
Calling "alert(this.id);" in the event handler is resulting in "undefined" message.

Second. I'm trying to figure out how to attach a click event handler to the element created dynamically by script.
The following line of code is resulting in new unclickable picture on my page:
myDiv.innerHTML = myDiv.innerHTML + '<img alt="" class="Pics" src="img2.jpg" onclick="return ClickIMG()" />';
This problem is not being solved by using the code like this: $('.Pics').Click('ClickIMG').

I think these issues are quite common and can be easily solved.
So you probably can help me.
Thank you.
Friday, July 16th, 2010
3:30 am
[sweetsdecline]
Using Javascript to search a share point list
I found this code a while ago that creates a drop down search box that will search a sharepoint list. I am extremely new to this so I am clueless in how I can modify this code to suit my needs. The code redirects to the same page with querystring data added to the URL. I was able to modify the drop down list and I changed the Column names to match the columns in my list. I changed to column names because it wasnt returning any records and I believe it is because it is referencing the columns that dont match my list. Once I did that it didnt work, It wouldnt return any records. I have a feeling it is because of this piece of code:
<script type="text/javascript">
 function RedirectUrl() {
 var tb = document.getElementById("tbSearch").value;
 var cs = document.getElementById("sfield").value;
 var url = "";

 if (tb != "") {
  if (cs == "Column5" || cs == "Column6"){
  url = "FilterField1=" + cs + "&FilterValue1=" + tb;
  window.location.href = "AllItems.aspx?" + url;
  }
  


I dont understand why it is referencing just Column5 and Column6. The rest of the code is under the cut. I have played with this all night and forgot where I found it so I cant go back and ask the person who created it. If anyone could shed some light on this and help I would be very happy.

Read more...Collapse )

Current Mood: embarrassed
Monday, April 5th, 2010
11:10 pm
[hipmaestro]
Nibbler: Multi-Base Encoder Generator
Recently, I was as surprised as you will no doubt be, to discover that there didn’t seem to be a Base32 encoder for JavaScript! There are lots of Base64 encoders out there (and just as many for Hexadecimal), but Base32 seems to be a pretty small niche.

So I decided to write my own, and about half-way through, it evolved from a Base32 encoder to a multi-base encoder:

http://www.tumuski.com/2010/04/nibbler/
Friday, March 26th, 2010
10:03 pm
[zyada]
Knowing just enough to be dangerous
I have a php script that is generating a page with Google maps on it. I've extracted the html and placed it here.


The code I'm trying to figure out is in the initialize function. When the user right clicks on the map, it places a marker there. I've got that working.

What I want to do next is if the user right clicks on another spot, the first marker is removed and a new marker is put into place. What I've got right now doesn't look like it realizes that a marker has already been created.

Here's the code I'm working on:

function initialize() {
if (GBrowserIsCompatible()) {

var map0 = new GMap2(document.getElementById("map_canvas_0"));
map0.setCenter(new GLatLng(31.25044240, -99.25060610), 6);
map0.setUIToDefault();
GEvent.addListener(map0,"singlerightclick", function(point, src, overlay){
var cur_ll = map0.fromContainerPixelToLatLng(point);
if (typeof map_marker0 != "undefined" )
{
removeOverlay(map_marker0)
alert("there's already one marker out there!");
}
var map_marker0 = map0.addOverlay(new GMarker(cur_ll, {draggable: true}));
} );


Also, the listener function for the event is inline because that's how their example is - is it possible to put this function outside of the addListener call?
Wednesday, March 10th, 2010
7:33 pm
[may_cat_ghost]
flowchart
Hi there!
I need to write some kind of advanced flowchart editor in javascript.  Frankly, I am weak in javascript, so I'm searching for help :) 

I thought of using SVG for graphics and JQuery.svg as support in coding... But still have some troubles.

Maybee you have some examples of realizing flowchart editor (or some kind of graph editor) in javascript? It would really help!
Any kind of algorithms description is welcome too! I mean algorithms of flowchart//graph viewing, not working with data.

p.s.
sorry for bad english :)
Tuesday, March 2nd, 2010
2:34 pm
[codeytime]
Drag and Drop in Mootools
I'm writing my first class using Mootools, building off a class called Drag.Ghost [link] (which itself inherts from Drag.Move; Drag.Ghost -> Drag.Move -> Drag)

Since I want this to be reusable and multi-purpose, I want to define custom behaviors within the class itself rather than within each page which is the usual, idiomatic way. That is, I want to define the drag, drop, move, etc handlers within the class rather than pass them as parameters to an instance of the class

The problem is, I can't manage to set these handlers. They never fire at all (again, the class itself and the idiomatic way works fine)

My version of the class:



Drag fires, but drop, enter, and leave do not (adding a console.log call to drag produces a message in Firebug. The others do not)

Drag is an event of the base Drag class while drop, enter, and leave are events on Drag.Move, so I'm thinking that might have something to do with it.

I have plenty of experience with OOP and a fair bit with JS specifically, but I'm unclear how things work in Mootools yet. I didn't see any references to, say, needing to explicitly call the superclass, but there's apparently something wrong with this subclass preventing it from passing on events belonging to its direct parent. Or maybe not. I'm stumped.

And here's how I'm calling it in the document HEAD section (which I'm sure is unneeded, but sometimes I miss the simplest things...)



xpost: javascript webdesign
Wednesday, January 27th, 2010
6:35 am
[switchstatement]
jquery, ajax, and waiting until data is fully loaded
We have this little image gallery thing built with jquery. It fetches a page that selects some random images and writes some html, then updates the html in the image gallery container. It's supposed to work like this:

- button clicked
- fetch page
- data received
- old stuff fades out
- new stuff fades in

The images loaded are really big (they're coming from a photographer and we have no control over the file size), so what's happening is the "new stuff fades in," event is occurring while the images are still loading, and it looks kind of dumb. This is a simplified version that just loads one random image:

    <script type="text/javascript">
    $(document).ready(function() {
        $("#nextButton").click(function() {
            $('#an_image').fadeOut('fast', function() {
                $.get('./image_swap.php?n=1&node=117', function(data) {
                    $('#an_image').html(data);
                    //i've tried timeouts here, but it's imprecise
                    $('#an_image').fadeIn("slow");
                });
            });
        });
    });


I've tried rearranging the nesting, thinking putting everything else under $.get('./image_swap.php?n=1&node=117', function(data) {...} would cause the callbacks to not happen until the data was loaded, but it's somehow even worse that way.

Is there a way to have jquery fetch the new page and not do anything else until the contents (specifically, the images) have fully loaded? Given their size and number, pre-loading the images in the background isn't really an option.
Thursday, January 21st, 2010
11:58 am
[zyada]
I found some code to do an auto-fill on a field, but I'm having some problems and I don't understand why.

What the form is supposed to do, is for every location entry field, an up arrow should bring up a list of possible values. However, this is only happening on the first field, not on the subsequent ones.

The code is being generated by a php script, so every instance of the text entry field should be identical, which makes this problem even more confusing. I've saved a copy of the generated html that you can access here: http://zyada-stuff.com/SpreadingRoots/temp.html

Also, is this showing "a" as an option for anyone else? It should be two options: Fort Worth, TX and Tascosa, TX
Wednesday, January 20th, 2010
6:27 pm
[zyada]
This may be a basic html question, but is there a way to make a text entry field autofill, like Google does?
Tuesday, January 5th, 2010
7:11 pm
[toygasm]
Making a wordpress header slide left?
I need help with coding. I've recently designed a blog on Wordpress and it has to get up before Friday. I'm having troubles with making my header slide to the left (I have 4 headers and I want them to slide). I've been trying for about 3 days now.
I know I have to install and upload that JQuery plugin thing, but even though I installed and have been trying, it hasn't been working for me. Can anyone help me out?
Tuesday, December 22nd, 2009
11:38 am
[pkbarbiedoll]
Javascript variable names & arrays (variable variables?)
I wrote a function to select one of an array of checkboxes. The form name, checkbox name, and value to be checked is passed. If I hardcode the form name, it works great. I want to make the function flexible to reuse in other situations, so the form name needs to be a variable.

EDITED - problem solved. If anyone needs this feel free to use or improve.

Scope:
Will toggle checkbox matching a certain value in an array of checkboxes. Similar to the "select all" but it just selects one. It's designed to be invoked with onClick from the checkbox description. See below....

Javascript:


Usage:
Friday, October 16th, 2009
5:00 pm
[hipmaestro]
Simple Interfaciness in JavaScript
This script provides some simple interface-like behavior in JavaScript, by asserting that a given constructor must produce objects that have certain members.
http://www.tumuski.com/2009/10/simple-interfaciness-in-javascript/
[ << Previous 20 ]
About LiveJournal.com