I have several files I'm pulling minor text from (a single word most), and then stylizing that with another script.
Currently they load and display as they should. However, the text files update at random times, so I'd like them to be reloaded, and the subsequent script applied to them again. I've tried different setTimeout as well as setInterval commands, but I think the issue is my placement or use. After several hours of research I'm certain it's just the syntax that's out of place.
This runs locally but is pulled through a program that excecutes the script as if remote. (no cross domain issues)
Here's one example segment that pulls a file and loads to the html the subsequent script reads to display:
$(function follow_pull() {
$.ajax({
url : "most_recent_follower.txt",
dataType: "text",
success : function (data) {
$("#follow").append(data).serialize();
},
setTimeout(fuction(){
follow_pull()
}, 10000);
});
});
Here's the segment that loads those files into the script to display:
$(window).ready(function ledload() {
var options = {
pixelSize: 5,
stepDelay: 62,
horizontalPixelsCount:650,
verticalPixelsCount:5,
pixelRatio: 0.8,
pathToPixelImage: 'ticker/pixel.png',
backgroundColor: '#000',
disabledPixelColor : '#020202',
enabledPixelColor: '#ff522b'
};
$('.canvasld, .crl').leddisplay($.extend(options, {pixelSize: 3}));
},
setTimeout(fuction(){
ledload()
}, 10000););
Any direction is appreciated. I can post the entire file if need by, but I figured someone would get what I'm doing and know how to direct me best.
For context I'm using a script that takes the text, and makes it look like an LED and scrolls as if it's a ticker. This is being used for a broadcaster on Twitch.
So reviewing what you provided in your comment, I found a way to get it working. First, is the html below. Here are the differences:
<div class="led"></div>. I also gave the.crlcss to that element, and instead made.crlhavedisplay: none. This is because the.leddisplayfunction takes the element and replaces it with it's own HTML to render the LEDs. So you need to keep thedivyou are using to store your info separate from thedivyou are using to render it. (I would recommend just using JS variables to store that info, but I'm not trying to rewrite your code, just trying to get it working.).leddisplayyou can input the text you want as the second parameter of the function. You can see how I did that inpostload().append(). This adds to the divs, but you want to update them, so I replaced every.append()with.text()to replace the text rather than add on to it.leddisplayplugin doesn't have a way to update the led. So you have to'destroy'it, and then rerun it, as I have done in thesetTimeout()ofpostload(). But by itself, starts the scrolling all over again every 10 seconds. So what I do is track the current position, then after rerunning it, I resume the scrolling from there. However to make that work, I needed to update the plugin code. Below the HTML is the explanation for that.HTML:
Inside the plugin, look for
customMethodstowards the bottom. I added 2 more methods to it:getCurrentPositionandsetCurrentPosition, so it should look like this:jquery.leddisplay.js, customMethods:
After you make these changes, it should work as expected.