3/3/2010 10:17:50 AM
bingoor something more descriptive, evenlike a class called "limited" plus a numberlike "limited50words"and you can parse out all classes beginning with "limited"get the words or characters limiti mean classes are your foundation hereeven multiple classesclass="limited words" etc.[Edited on March 3, 2010 at 10:24 AM. Reason : ook]
3/3/2010 10:21:32 AM
^ because it validates anyway...i would think calling a class that doesn't exist is worse than using an attribute that doesn't exist when it doesn't throw any validation flags
3/3/2010 10:22:51 AM
i don't think you understand the point of classesthey are the core of html4+ extensibilitya class is not an object (or element, if you like) that does or does not existit's just a way to classify and address elements[Edited on March 3, 2010 at 10:26 AM. Reason : ...]
3/3/2010 10:23:57 AM
This is what I was getting at
3/3/2010 10:31:42 AM
that's a good point...i realize HTML 5 is a ways off, but since the textarea element will support the maxlength attribute (IIRC) then and it doesn't cause any validation problems now, not sure why i WOULDN'T do it this way...if it validates, what difference does it make?you are also right in that i didn't (don't) think of classes that way...i'll think about itin any case, this discussion doesn't contribute anything to my question...whether i waste more code parsing the text or continue to use my not-invalid markup, the jquery issue is still there
3/3/2010 10:39:46 AM
well just consider thiseven standards-compliant browsers don't consistently handle invalid attributes on elements that don't support themso using classes instead will give you more predictable and controllable results in circumstances where the user agent for whatever reason doesn't render the document as you intendede.g. the user has javascript turned offand html5 is not going to make classes obsoleteanyway your issue will be easier to troubleshoot if you provide the actual content, your expected result, and the result you actually got[Edited on March 3, 2010 at 10:44 AM. Reason : ...]
3/3/2010 10:43:44 AM
3/3/2010 10:45:57 AM
Need some help, if anyone can take a look.I am combining a few jquery plugins/widgits/whatever ....http://eventscream.com/clients/calendar.phpWhen you unclick on "All Day?" at the right hand side, a div is unhidden, which has the start time and end time.When you put your cursor in "start time" text field, a drop down/select box appears ... but it shows up at the top left of the webpage.Its been doing this ever since I added the datepicker widget to the page, and I cant figure out what is causing this to happen.Any help is appreciated.
3/5/2010 8:33:39 AM
well i was all set to open firebug to inspect the elementbut you have one of those gay fucking anti-right-click scriptsso no go[Edited on March 5, 2010 at 8:52 AM. Reason : though it's probably a relative vs. absolute positioning issue]
3/5/2010 8:52:07 AM
Ah ... sorry .. was playing with that crap, and didnt turn it off... Its off now, in case you are willing to give it a second look.
3/5/2010 9:02:49 AM
in timePicker.js
$tpDiv.appendTo('body').css({'top':elmOffset.top, 'left':elmOffset.left}).hide();
3/5/2010 9:07:08 AM
I guess because when looking for a time selector, this already did some of the basic stuff I wanted it to do ... just looks like junk in that its a select box.I am looking at another option as well ... but havent decided if its adds any "ease of use" yethttp://www.jnathanson.com/index.cfm?page=jquery/clockpick/ClockPickupdate: Fixed by unhiding that <p> element from the get-go ... I guess since it was in a display:none element at run time, it just wrote the new div and appended it to the top left of the page instead of the top left of where the element appeared ... Know of a quick way to workaround that dynamically in the script?[Edited on March 5, 2010 at 9:21 AM. Reason : update]
3/5/2010 9:12:41 AM
You basically just need to change the timePicker script a bit so that it appends that $tpDiv to the element that called the function rather than to the body element. You will probably need to tweak the offsets, but there it is.
3/5/2010 9:20:36 AM
bump
8/17/2011 3:08:11 PM
^ thanks!when i list images within a specific div, i want to append the image source to refer to the smaller version...for example:
<div class="goobers"><img src="/images/mikeandike.jpg" /></div><div class="goobers"><img src="/images/redhots.gif" /></div>
<div class="goobers"><img src="/images/mikeandike_small.jpg" /></div><div class="goobers"><img src="/images/redhots_small.gif" /></div>
$(document).ready(function() {$(".goobers img").attr("src",$(this).replace(".","_small."));});
8/17/2011 3:08:45 PM
This looks like a job for find/replace
8/17/2011 4:01:15 PM
^^ Use .split instead, then append between the last split and the rest.(pseudocode below).split(foo);for(i to foo.length-1) foostring+=foo[i];footstring+= "_small"+foo[foo.length];
8/17/2011 4:19:50 PM
$('.goobers. img').each(function(){ $(this).attr('src', $(this).attr('src').replace(/\.([^\.]+)$/, "_small.$1"));});[Edited on August 17, 2011 at 4:24 PM. Reason : The solution to this, and every problem, is "regular expressions"]
8/17/2011 4:21:23 PM
ahh, wasn't sure if the standard JS .replace supported regex strings.How performant is regex in javacript?
8/17/2011 4:31:43 PM
USE PERL!!!!!!OMGWTFBBQ!
8/17/2011 4:33:24 PM
8/17/2011 5:24:46 PM
^I was referring to our two solutions. Unless JS does some really damn good runtime optimization of regexes, it's probably considerably faster to use a split + iterate + join approach.(this is btw a theoretical question, in any normal volume web service it probably doesnt make any difference at all)
8/17/2011 9:34:15 PM
If we're really looking for speed, it's probably quicker to use lastIndexOf() and substring().Realistically, I don't think it makes a huge difference in speed, unless you're using IE6 on a P3.
8/17/2011 10:23:06 PM
8/18/2011 8:16:57 AM
Just a typo. No period needed.
8/18/2011 8:29:57 AM
if you're already using a js framework, worrying about the performance hit of .replace() is silly
8/18/2011 8:52:45 AM
3/21/2012 9:26:14 AM
okay, so an outside group developed some data logging software to run with some customized equipment that we have...i suppose "data logging" isn't really correct, though, as nothing is loggedthey've provided me with some jQuery to output the data on demand (it's simply for display purposes), but i would like to start dumping that data into a databasethey cannot (will not) provide the data in any other way (ie. simply dump the data into the database at a given interval)...i can only run the jQuery to get the values, so i was thinking of running a cron at a given interval and passing the data from jQuery to a PHP script that would in turn insert the info into a tablei realize that this is far from ideal, but it's what i've got to work with...so what's the best method? something like the below for the .js file
$.get("putindatabase.php",{value1:"mydata",value2:+info.type,value3:+info.title,value4:+info.value});
$value1 = $_GET['value1'];$value2 = $_GET['value2'];$value3 = $_GET['value3'];$value4 = $_GET['value4'];$query = "INSERT INTO table (value1, value2, value3, value4) VALUES ('$value1', '$value2', '$value3', '$value4')";
3/21/2012 10:09:04 AM
I'm confused. Where do value1,etc... come from. Could you do a curl on the PHP endpoint and get the data?[Edited on March 21, 2012 at 11:53 AM. Reason : a]
3/21/2012 11:50:51 AM
^^There's a lot easier way to do this on the fly.Your PHP script works as is (but remove the .get)On the jQuery side, simply add a command to initiate a post http://api.jquery.com/jQuery.post/So whenever the data is displayed, there's a postback to store it in the db.Your way as-is will also work, if the data is really just being stored for backup/future consumption rather than immediate reuse. (And your choice is much less taxing on bandwidth and the db as well).
3/21/2012 12:34:56 PM
cron's not going to execute javascriptif they gave you the jquery to output the data, presumably there's an ajax call in there somewhere to retrieve it from where they are generating itjust parse/cron that
3/21/2012 1:15:30 PM
^
3/21/2012 1:46:30 PM
function getData() { $.ajax({ type: "GET", url: "http://stinkycheese.net:1234/api/bananaphone", contentType: "application/json; charset=utf-8", data: {dataTypes:['value1_total','value2_total','value3_total','value4_total']}, dataType: 'json', success: function(json_data) { if(json_data) { var datastuff = json_data.results; $.post(this,{postdata:datastuff},function(data){ alert(data); }); } }, });}$(document).ready(function() { getData();});
<?php // get and display json data$oystersandwich = json_decode($_GET['data']);echo $oystersandwich;?>
3/22/2012 9:29:06 AM
"in the body" of what?This isn't a jQuery problem. Curl the URL they gave you with PHP. Take results and put them into database.Nothing client-side required.
3/22/2012 10:25:45 AM
What the fuck
3/22/2012 2:42:48 PM
^^Looks like the best option to me.
3/22/2012 5:24:15 PM
Stein is right, I was being dumb.Just pull http://stinkycheese.net:1234/api/bananaphone straight into your PHP script, there's no purpose to using jQuery on the client as an intermediary.
3/22/2012 5:32:14 PM
url="http://stinkycheese.net:1234/api/bananaphone";curl -d "`curl $url`" $urlShould work.
3/22/2012 6:01:42 PM
so yeah, cURL was exactly what i needed...i just didn't know it this is a stupid question, but i'm happy to admit that i know little about json objects and would appreciate any help...my string looks like this (though much MUCH longer):
{"results":[{"id":{"value":"abcd-1234-efgh-5678"},"name":"whatever.booger.bananaphone","point":{"id":{"value":"ijkl-9012-mnop-3456"},"name":"applesauce_nom"},"radioactive":false,"entity":{"id":{"value":"abcd-1234-efgh-5678"},"types":["Analog","Point"],"name":"whatever.booger.bananaphone"},"type":"ANALOG","unit":"kilogram"}]}
4/2/2012 3:36:22 PM
In whatever language you are using: object.results[0].nameAssuming you want the first element of the results array.
4/2/2012 6:53:39 PM
^ i don't...i want to get the value of all "points" with name "whatever.booger.bananaphone"
4/3/2012 8:15:02 AM
Get this: http://nodejs.org/bananaphone.js:
fs = require('fs');json_str = fs.readFileSync('/dev/stdin');obj = eval(json_str);function filter(items,fn) { var results = []; for(var i = 0; i<items.length; i++) { var item = items[i]; if(fn(item)) results.push(item); } return results;}objects_i_want = filter(obj,function(item) { if(name === 'whatever.booger.bananaphone') return true; });
4/3/2012 10:20:17 AM
i have a slew of yes/no radio buttons...when you click "yes" (value of 1) it shows a hidden div using the code below:
$(':radio').change(function() { var name = $(this).attr("name"); if($(this).val() === "1") { $('#'+name).show("1000"); } else { $('#'+name).hide("1000"); }});
$('.select-all').click(function() { var name = $(this).attr("name"); $('.'+name).each(function() { if($(this).val() === '1') { $(this).prop('checked', true); }; });});
2/18/2014 2:32:54 PM
change $(this).prop('checked', true); to $(this).prop('checked', true).trigger('change');
2/18/2014 2:48:38 PM
perfect! repped...?seriously, thanks! EDIT: the clear function isn't taking it
$('.select-clear').click(function() { var name = $(this).attr("name"); $('.'+name).each(function() { $(this).prop('checked', false).trigger('change'); });});
2/18/2014 2:50:56 PM
i'd change if($(this).val() === "1") to if($(this).prop('checked')) and see if that does anything[Edited on February 18, 2014 at 2:58 PM. Reason : in the change handler]
2/18/2014 2:57:42 PM
no dice...it just breaks the "all yes" functionality
2/18/2014 3:04:43 PM
Any of you guys use angular?Been coding in that a lot lately in conjunction with lowdash & underscore
2/18/2014 3:22:29 PM
^ couple posts in message_topic.aspx?topic=640853
2/18/2014 4:00:02 PM