Web Development Questions That Don't Need Their Own Thread v2
3,079 replies, posted
We have a popup player so you can listen to us in your browser and i though it would be a nice feature to have if you could read the song title even if the window is in the background and you only see the tab.
Try this.
[code]function stateChanged() {
if (xmlhttp.readyState==4) {
var songtitle = xmlhttp.resposneText;
document.getElementById('songtitle').textContent = songtitle;
updateTitle(songtitle);
}
}
var titlePosition;
var titleText;
function updateTitle(title) {
if (title !== undefined) {
// Reset position
// Set the new text
titleText = title;
titlePosition = 0;
var maxWidth = Math.round(window.innerWidth/10); // Dynamic width adjustment
if (titleText.length > maxWidth) {
document.title = titleText.substr(0, maxWidth);
setTimeout(arguments.callee, 3000);
} else {
// No need for loop, just set and done.
document.title = titleText;
}
// Wait 2 seconds this time
return;
}
// Dynamic width adjustment
var maxWidth = Math.round(window.innerWidth/10);
// No need for the ellipsis, most browsers do that already.
document.title = titleText.substr(titlePosition, maxWidth);
if (titlePosition > titleText.length - maxWidth) {
titlePosition = 0;
setTimeout(arguments.callee, 3000);
} else {
titlePosition++;
setTimeout(arguments.callee, 800);
}
return
}[/code]
It's my first time doing something like this, and I have to say it was quite fun. It'll adjust the scrolling distance depending on window width, and it works quite efficiently.
Wow, thank you, but it seems to come up with the same error i encounted earlier already:
[img]http://localhostr.com/files/9BFrH5u/fuckinghelljs.png[/img]
Goddamn Javascript.
[QUOTE=Tu154M;30455389]Wow, thank you, but it seems to come up with the same error i encounted earlier already:
[img]http://localhostr.com/files/9BFrH5u/fuckinghelljs.png[/img]
Goddamn Javascript.[/QUOTE]
What debugger is that?
Opera error console
If you need to use sleep you're doing it wrong. use setTimeout
As explained earlier i've tried that already and the functions kinda did not want to work together.
Is a facepunch radio [i]really[/i] necessary?
[QUOTE=alphaspida;30456755]Is a facepunch radio [i]really[/i] necessary?[/QUOTE]
Nope, but we're doing it anyway.
[QUOTE=Tu154M;30455389]Wow, thank you, but it seems to come up with the same error i encounted earlier already:
[img]http://localhostr.com/files/9BFrH5u/fuckinghelljs.png[/img]
Goddamn Javascript.[/QUOTE]
:doh:
var songtitle = xmlhttp.resposneText;
[b]resposne[/b]
Replace the current statChanged function with this one. At testing time, I only tested the updateTitle function.
[code]function stateChanged() {
if (xmlhttp.readyState==4) {
var songtitle = xmlhttp.resposneText;
document.getElementById('songtitle').textContent = songtitle;
updateTitle(songtitle);
}
}
[/code]
[QUOTE=jaybuz;30449131]OSX has all the good programs.[/quote]
To be honest, I miss HeidiSQL. It's by far the best MySQL client I've ever used.
[quote]Is it hard to make a hackintosh?[/quote]
nope
Im currently using zWamp and I just wondered whats the best apache2 mod_ for python?
A while back I installed mod_python on to a virtual server running fresh apache and it worked fine, but I have been reading and lots of people suggest to use something like mod_wsgi
Is this a good html template?
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="author" content="">
<title></title>
<!-- <base href="">
-->
<link rel="stylesheet" type="text/css" media="screen" href="css/stylesheet.css">
<!-- <link rel="alternative stylesheet" type="text/css" media="screen" href="css/accessibility.css">
-->
<link rel="icon" type="image/x-icon" href="favicon.ico">
<!-- <script type="text/javascript" src="js/global.js">
</script> -->
<!-- <script type="text/javascript" src="js/#.js">
</script> -->
</head>
<body>
</body>
</html>[/code]
Not sure if it missing any declarations or anything.
And whats the best type of DOCTYPE to use?
Or does it really depend on what type of site? (obviously it depends a bit or else they wouldn't have made more than one)
[QUOTE=only;30520001]argh, i don't know how i fucked this up so badly, could someone look at this? it's a short sinatra/ruby hello world app, and i can't deploy it to heroku for some odd reason
here's the source (~4kb) [url]https://github.com/zreidell/thisapp[/url]
here are heroku's logs: [url]http://pastebin.com/nGv0qP89[/url]
I hope someone could look at this for me, i have no clue what i'm doing and it's probably a simple mistake.
thanks[/QUOTE]
[QUOTE=only;30523215]argh, i don't know how i fucked this up so badly, could someone look at this? it's a short sinatra/ruby hello world app, and i can't deploy it to heroku for some odd reason
here's the source (~4kb) [url]https://github.com/zreidell/thisapp[/url]
here are heroku's logs: [url]http://pastebin.com/nGv0qP89[/url]
I hope someone could look at this for me, i have no clue what i'm doing and it's probably a simple mistake.
thanks[/QUOTE]
[url=http://devcenter.heroku.com/articles/ruby]Use Bundler[/url].
[QUOTE=vepa;30525202][url=http://devcenter.heroku.com/articles/ruby]Use Bundler[/url].[/QUOTE]
Okay, that worked. Thanks!
[QUOTE=Richy19;30522776]Is this a good html template?
[code]
-snipity-
[/code]
Not sure if it missing any declarations or anything.
And whats the best type of DOCTYPE to use?
Or does it really depend on what type of site? (obviously it depends a bit or else they wouldn't have made more than one)[/QUOTE]
I'd use the [url=http://html5boilerplate.com]HTML5 Boiler Plate[/url].
[QUOTE=deadeye536;30525551]I'd use the [url=http://html5boilerplate.com]HTML5 Boiler Plate[/url].[/QUOTE]
Is that HTML5 only? or am I missing something?
I know HTML is just new tags and you dont have to use them but I want to keep compatibility with non HTML5 browsers
[QUOTE=Richy19;30525708]Is that HTML5 only? or am I missing something?
I know HTML is just new tags and you dont have to use them but I want to keep compatibility with non HTML5 browsers[/QUOTE]
It works perfectly fine on older browsers, even IE6.
[QUOTE=deadeye536;30525776]It works perfectly fine on older browsers, even IE6.[/QUOTE]
Really?
So I take it its just the new tags like the video tags that dont work in older versions?
[QUOTE=Richy19;30525922]Really?
So I take it its just the new tags like the video tags that dont work in older versions?[/QUOTE]
The only HTML5 included in the Boiler Plate by default are structure tags, and the CSS reset takes care of backwards support for all the structure tags. Any tags that use new features (audio, video, new form features, etc) won't work on older browsers.
[QUOTE=Richy19;30525922]Really?
So I take it its just the new tags like the video tags that dont work in older versions?[/QUOTE]
It'll work the same way <object> will if the browser can't understand it, by falling back to the embedded content (Most likely a message telling them to update their browser)
Im using the html5 boiler plate as suggested.
I was wondering if it would cause any loss in performance or loading time to split the template into various parts:
header.php
main.php
footer.php
that way I include header and footer in each php page and I only have to change the contents of main.php
[QUOTE=Richy19;30546528]Im using the html5 boiler plate as suggested.
I was wondering if it would cause any loss in performance or loading time to split the template into various parts:
header.php
main.php
footer.php
that way I include header and footer in each php page and I only have to change the contents of main.php[/QUOTE]
Computers are fast, you'll be fine, don't worry.
Right now, I have a javascript script that changes the string of an <a> tag, the only problem is that the div where the <a> tag is in, is dynamic.
[QUOTE=vexx21322;30554073]Right now, I have a javascript script that changes the string of an <a> tag, the only problem is that the div where the <a> tag is in, is dynamic.[/QUOTE]
give the <a> tag an id or class that identifies it, and target the tag using javascript; I don't think it'll matter what the parent is as long as you don't identify using it.
[html]
<script>
function changeClass() {
document.getElementsByClassName("stuff")[0].setAttribute("class","bob");
return true;
}
function aTagClick() {
document.getElementById("atag").innerHTML="clicked!";
}
</script>
...
<a onclick="changeClass();">Change Class</a>
<div class="stuff">
<a onclick="aTagClick();">click me!</a>
</div>
[/html]
a small example, using native javascript.
hmng, is this the correct way to use @import with css?
@import url("./custom.css");
its not working
[QUOTE=Richy19;30563738]hmng, is this the correct way to use @import with css?
@import url("./custom.css");
its not working[/QUOTE]
Don't use import. It throws concurrent resource requests out the window (you cannot start downloading one css file until you can actually get the stylesheet that imports it), and some browsers are very unreliable in the way they're handled (i.e. - importing resources in a different order than what was declared). Use <link> tags instead.
[QUOTE=StinkyJoe;30546649]Computers are fast, you'll be fine, don't worry.[/QUOTE]
To add to this: Imagine how many files the client's computer has to read every time it loads a page and all the rendering it has to do. Still doesn't take any perceptible time.
Can anyone recommend where I should look (preferably online) for learning PHP OOP basics? I've looked around and most places are "here do this" instead of actually explaining what I'm doing.
Sorry, you need to Log In to post a reply to this thread.