« first day (2350 days earlier)      last day (2613 days later) » 

12:00 PM
Look at the example I linked you earlier - the function isVisible() is executed by the following 2 lines of code
 
Oh I found it out, there was a line of code right below it which triggered it, thanks!
Another thing:
	document.body.addEventListener("fbody", fbody());
It says:ReferenceError: fbody is not defined[Learn More]
 
hi, jquery users...one question...while making plugins we find a pattern like so: $.fn.foo = function() {}...question is...when does foo get appended to the jQuery object?
 
	function fbody(event){
	body = event.target.textContent;
	nbody.textContent = body;
	}
It is actually a function so why is fbody "not defined"?
 
@Useraro Presumable it's outside the scope of the first line
 
@KendallFrey In layman words?
I'm checking the scope section at w3schools again though
 
12:08 PM
You don't know what scope means?
 
well, that's pure bad luck: i.imgur.com/kDAWKHn.mp4
 
@Useraro here is a free hint: w3school should be the last place you look for ANY information
 
w3schools alarm
 
Yes the issue about local vs global variables
How could it be outside of the scope of the first line?
Neither is inside a function
So they're global variables and thus have global scope, right?
 
It could be in a different file
that isn't loaded yet
 
12:10 PM
It's all in a single html actually
 
different script element then, you hack
 
I mean, I want to make it easy to use so it must all be in a single html :)
Oh, yes it is in a different script element
 
<script>
foo();
</script>
<script>
function foo() {
  console.log('hello world');
}
</script>
foo not defined ^
probably something like this you have?
 
@Useraro I want my code to be easy to use, so I separate it into different files for SOC
 
yess, yes.
 
12:13 PM
@rlemon Just like that, yes
 
well, that's your problem.
 
The document is loaded from top to bottom
 
^
 
it won't have access to scripts that aren't loaded
 
each script tag is parsed then executed before the next
 
12:13 PM
@KendallFrey I have hours rather than days or weeks of experience, it'll be a while until I need someone else to use it and it'd be a mess to flip from file to file. But later on I might separate it better yes.
@KendallFrey I thought it all loaded at once! Makes sense
 
it's probably best to avoid running any script until after the whole document has been loaded
window.onload and all that jazz
 
or just put everything in a bundle at the end of the body
starlig.ht/about Xfce4 for windows.
cc @Loktar
 
Ever since W10 anniversary, Cygwin is synonymous with hack in my mind
 
One question:
	document.body.addEventListener("click", fbody());
Does the "click" make any sense?
 
12:18 PM
what does fbody() return
because that's what you're applying
 
That's irrelevant but thanks for pointing it out, I just want to know about the "click"
 
function foo() { return 123 }
foo() // is 123
foo // is the function
 
If I used "clic" what would it mean?
 
nothing
 
@Useraro There are a bunch of strings that are known event types
 
12:19 PM
you're listening for a 'click' event
 
I want to make it so the event it listens to is a click, so if I write "click" when I click that's the event?
Ohhh
Makes sense!
Thanks
 
you can have custom events and listen for a 'clic' event.
but that would be for a later lesson
 
No problem
Now I have this function:
	var body;
	var nbody = document.getElementById("body");
	document.body.addEventListener("click", fbody);
	function fbody(event){
	body = event.target.textContent;
	nbody.textContent = body;
	}
It's a mess i know, sorry for that
It says that: TypeError: nbody is null
 
do you have an element with id="body" ??
 
Lemme check but I think so
 
12:21 PM
does it appear before the <script> tag in the <body>?
 
Yes
It appears after thes script tag
Wait
 
then the script tag is ran before the element is parsed
hence, it is null.
 
The id="body" appears at a script at the bottom
Thanks!
 
That's one of the reasons to run your code after the document is loaded
 
Gonna fix it
It works now!
Thanks
Would this function work?
if("Body selection".style != "none"){
	document.body.addEventListener("click", fbody);
	}
	else console.log(2)
The idea is that when the div with the id "Body selection" (sorry for the terrible id) has the style of "none", the console would give a log of 2
 
12:27 PM
if("Body selection".style != "none"){
is nonsense
 
Sorry
The id of the div is "Body selection"
 
afaik ids can't have spaces
 
Oh, not even between quotes?
 
Wait..
You need to spend more time learning.
 
@Useraro what he means is that strings don't have styles. elements do
 
12:29 PM
(I'm having lunch now but I'll be back in a while, I'll read your messages later). I meant the div with that id, not the id itself!
Also I'm trying to learn and practise at the same time, sorry
(I'll be back in 20 min, sorry)
 
can't practise without learning
 
there is no spoon
 
if this is a element shouldnt it rather be if("#Body selection".style != "none") ?
And please use CamelCase instead of spaces if these are Ids and if you use mean the body tag then you should use singlequotes
 
@TheOddCoder Welcome to the JavaScript chat! Please review the room rules. Pleasedon't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
4 mins ago, by Kendall Frey
@Useraro what he means is that strings don't have styles. elements do
 
12:35 PM
Do you guys know how to make the div stop at the exact position specified?
the longer the distance the bigger the error
 
I think it's hilarious that one person interpreted a string as an id, while another interpreted it as a selector, and both were basing that on invisible code their brain added
 
I just called it nonsense
 
indeed : )
oh I see: .2
 
.2?
as far as I could tell that option is never used
I had to change the timing in the method itself.
but that is just to make the demo smaller
aint nobody got time to scroll to 4800
the trick is to progress the box to limit - stepDistance, then as a final step just set the position to the final position
because there will have been +- half a step deviation, before the ending, it should look fluid
 
Yep I just checked. XD
Yep, thats what I did initially but I removed it again because I wasnt sure if it was a "hack"
I thought there was a way to actually make sure we can do all that during the calculation. Doesnt really matter anymore though. Thanks buddy : )
 
12:46 PM
Mathematical hash in Javascript function();
how to do that
 
new ME already at discounts (which is true)
 
@arjunkori +42
 
@arjunkori What part don't you know how to do?
 
@arjunkori what's a mathematical hash?
 
@littlepootis like regular hash, but only smoked by people who can tell you at least 100 digits of pi
 
12:53 PM
I can give you 100 digits of pi. Not the first 100, mind you.
 
hur hur hur
it only counts if you can tell me the number AND position
 
Ok I'm back
 
hi Back, I'm rlemon.
 
hi rlmon I'm stupidsayswhat
 
a) you already told me your name was back
b) I have no idea who rlmon is
c) tis a silly name
 
1:00 PM
@rlmon you show him how silly my back is
So I have this thing now:
	if(bodySelection.style != "none"){
	document.body.addEventListener("click", fbody);
	}
	else console.log(2)
Camelcase now
There's also this function above it all:
function show(hidden, shown) {
document.getElementById(shown).style.display='block';
document.getElementById(hidden).style.display='none';
return false;
}
 
1 message moved to Trash can
@Useraro Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
So when a div is hidden it's style becomes 'none', right?
Then shouldn't the code above make it so that the eventlistener is disabled?
 
visibility: hidden;
Checkmate
 
Wait how do I do that?
Where I put that?
@Ben Do I substitute style.display by visibility:hidden?
 
@BenFortune also, no I don't
 
1:10 PM
@rlemon Okay :(
Is relay the word I'm looking for?
 
Depends on what you mean.
 
Phone > ZeroW > Car bluetooth, forwarding A2DP
 
So the zerow is a proxy for bt?
 
Pretty much
It may need modifying along the way, fuck knows how
Car works with call audio, but not music for some reason
 
@Useraro you need to delve into the docs. element.style.display means that you're changing the "display" CSS property of the element. If you want to use another CSS property, check for another name. visibility: hidden means in js element.style.visibility = 'hidden';
 
1:15 PM
Last resort is a new radio with a CANBUS adapter
 
@KarelG
Just figured that out, thanks!
Here's the updated formula which doesn't work either:
	if(bodySelection.style.display != "none"){
	document.body.addEventListener("click", fbody);
	}
	else console.log(2)
 
1 message moved to Trash can
@Useraro Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
what's "bodySelection" ?
 
It's the ID of a div
 
no document.getElementById(...) ?
 
1:17 PM
When the div has the display of "non" I want the eventlistener to stop working
"none"*
 
but you cannot click with a mouse on an element that has display: none
 
getelementbyid would give me the content of the div, not the fact that it has a display of none
 
...
 
Exactly, when the display is OTHER than none, I want it to work, otherwise I want it to not work
And give me the console log of 2 instead
That's where the != comes from
 
1:18 PM
we're trying to help you but you aren't really reading
 
Sorry I'm trying :(
 
you can only call .style on a HTMLElement object
 
Oh
But it is a div, so it should work right?
 
and that is obtained when using document.getElementById or document.querySelector
 
	<div id='bodySelection'>
Oh
Something like this but well-written?
	if(documentGetElementById(bodySelection.style).display != "none"){
	document.body.addEventListener("click", fbody);
	}
	else console.log(2)
 
1:21 PM
......
 
It's horribly written I know, sorry
 
it's even incorrect
 
I just want that when the display of the div "bodyselection" is "none" the console gives me "2" as log
Also I know it's incorrect I just wanted to know if the gocumentGetElementById was to be put in that general area
 
1) you have <div id='bodySelection'>
2) find the element first: const el = document.getElementById('bodySelection');
3) you want to style it
4) style the selected element: el.style.<CSS property> = <CSS value>
---> you want to check display ? use  el.style.display !== or === <value>

x) summarize: <element>.style.<CSS property>
 
@Useraro stop giving us nonsense
read a book or something
 
1:24 PM
@rlemon I'm just trying to learn! Sorry!
 
after that i won't help ya if you're still failing. Most of us have to figure out the js concepts at their own
 
@Useraro you're going about it the wrong way
blindly typing code that makes no sense will not help you learn
 
@KarelG Ok I'll try to figure out what you've written, thanks!
 
even rlemon didn't had much aid in the past when he was scripting for the first time
 
in PHP, 4 mins ago, by Saitama
umm... is there any way I can attach my own handler to the websocket stream (for this chat)
ideas ^ ? :D
 
1:34 PM
@Saitama just make a new connection
 
I just use a mutation observer
 
new connection for wss, mutation observer if you just wanna hook to the dom
 
@rlemon mm... sounds good..
 
@rlemon Doesn't it detect that you're already connected and tells you "nope"?
 
@MadaraUchiha if you stack too many it can close a connection
but most often it 'just works'
remember my star/flag monitor?
 
1:36 PM
Yeah
 
yea it just posted to get an auth token, then made a new wss connection
    function connect() {
        $.post('/ws-auth', fkey({
            roomid: 17
        })).done(function (data) {
            url = data.url;
            if (report) console.log('Connected');
            poll();
        });
    }

    function poll() {
        socket = new WebSocket(url + '?l=' + Date.now());
        socket.onmessage = ondata;
        socket.onclose = onclose;
    }

    function ondata(data) {
        var frame = JSON.parse(data.data);
        for (var room in frame) {
            if ('e' in frame[room]) {
juicy bits from that script
 
@rlemon this should help!! arigato rlemon-sama
 
you can have multiple tabs on this chat, so another connection is probably ok
 
1:58 PM
interface Foo {
    bar: string;
    baz: {
        jimbo: string; // TS accepts ; or , for inner types. which is 'correct' ?
    };
}
 
hah, works. You can now control the animation by specifying the seconds. You think its a bit hacky? jsfiddle.net/7eb7u7a3/1
ok nevermind. It doesnt work xD
 
@KendallFrey @SterlingArcher i.imgur.com/xKbuDQG.png
2
 
oh godf
you won't see such thing here, where i live. We are more ... civilized.
 
you just torture people by overfeeding them with fries
 
user2620028
@Shrek not at midnight lol
 
2:12 PM
function start(){
		var inputColor = prompt("Enter a color name for the " + "background of the links", "");
		document.a.setAttribute("style", "background-color: " + inputColor);

	}
window.addEventListener("load", start, false);

why doesn't document.a.setAttribute work?
trying to make the background color of links change
 
@Mosho This: gist.github.com/luggage66/d4285cab6c4aece72d4073dd2e3a4125 Typscript looks for those types in the JSX namespace. Normally @types/react defines them so you get type checking. I put the file I just linked in a sub-directory that has all my non-react JSX use so that it'll stop telling my my other tags aren't valid React tags
That what I came up with for a minimal "any" for using JSX. based on TS docs and @types/react code
 
@Hello use <your element>.style.backgroundColor = <color value> instead
attribute is really different
 
@Luggage if I make a new project, and define "jsxFactory": "h", I get no complaints about tags
as long as h is defined
 
@Mosho you're using implicit any
 
it might have just been because I have @types/react, then
 
2:15 PM
and none of them are typed
 
since all my complaints were react-related.
 
@ssube yes, that's what I said in my previous message on the subject
 
@Luggage if react is missing or not included, it defaults to any, it just doesn't complain until you enable warnings
 
well, i have a mixed react / other codebase and want react typings 90% of the time
 
@Mosho yes, but it only does that because you've disabled type checking, which is a bad thing
 
2:16 PM
as long as we don't need typing beyond the tags not throwing errors
no I didn't
you have no typing for props
but that's it
 
src/client <- all react
src/reports <- all my other JSX thing
 
props, elements, etc
 
I'd like to one day make a proper typing for my library so I get auto-complete. When that day comes, i wonder how I use @types/react and @types/luggage-thing at the same time...
But I'll deal with that later.
 
@ssube elements?
 
@Luggage it's mostly a matter of includes
 
2:17 PM
@KarelG Thanks! this is for homework and my rubric said The script must use DOM’s links collection to give a background color all the links on the page

so I wanted to use document.a.etc
 
@Mosho yeah, elements. Most of the JSX types are about the element, not the component (because React cares far more about the elements). You omit those, it defaults to any. You omit component types, it complains.
 
but what do you mean by elements?
 
react elements? the output of the components? that's what it calls them
 
you mean the output of react.createElement?
 
you may want to read up on how react works
 
2:19 PM
@ssube :|
fu
 
backs away
 
the react docs talk about most of this, they just hide it really well and try to keep you focused on the high-level stuff
 
I fully aware of anything within react and @types/react, I'm just trying to understand what you are saying
 
the element returned from createElement is mostly an opaque object your don't interact with
 
yes, that's what I was thinking
 
2:22 PM
@Luggage typically, unless you're implementing react :(
 
who cares about it
 
except to may look at .props or .children when using children as configuration (e.g. react-router)
 
if you're trying to render those elements in TS, you need types for them, and jfc are the @types/react ones fucky
 
and .type
 
the actual necessary parts of the element interface are pretty interesting, though
it's just the tree building and event emitter stuff from the DOM, essentially
 
2:23 PM
types/react is mostly Ok (but I'm new, i might not know how fucky it is). My only issue is that @types/react defines a global JSX namespace that typescript uses, regardless of your jsxFactory configuration
 
@ssube you don't need types if they are any
 
so I needed to replace it with something that was closer to 'any'.
 
@Luggage it's fine to use, it's just weird to extend
they have a lot of internal stuff that is public and you have to implement if you simply extend their interfaces
you can cherry pick some of the base interfaces, lifecycle and another, and implement those to build react-compatible components
or rather, components that output react-compatible elements
 
I have very rarely interacted with the react elements returned from JSX
 
well, to be react compatible with goes through react (but not reactDOM).
 
2:25 PM
but the point of the whole discussion was avoiding compilation errors using just jsxFactory
 
hooking blessed up to React was fucking fascinating with all the internals I had to figure out
 
My code is react-like. similar api to react, but it's NOT react at all. not one bit.
I thought yours may be some react?
 
it implements the react interfaces
because blessed uses a tree of widgets
 
anywho .can't wait to turn it into a real react renderer on fiber.
 
I just had to make the elements look enough like the DOM and react kind of takes over from there
yeah, fiber will let me rip out 80% of that code :D
 
2:27 PM
I tried with current react, but react and react-dom were still so tied together..
 
I've been refactoring to use DI more correctly already and it's so fun to rip out huge complicated init methods
 
actually i have react and my own mixed.
<block>
    <ReactSvgWrapper cssPath="./src/reports/chart1.css" widthInInches={8} heightInInches={2}>
        <AccuracyBarChart data={data.rows.map(row => ({
            key: row.key,
            changes: 0 + (row.added + row.overturned),
            totalWorksheets: 0 + (row.added + row.overturned + row.confirmed),
            percentage: 1 - (0 + (row.added + row.overturned)) / (0 + (row.added + row.overturned + row.confirmed))
        }))} />
    </ReactSvgWrapper>
</block>
 
it's all about the elements you output :)
 
AccuracyBarChart is an actual react component rendering svg. <block> is a primitive element of my own thing and ReactSvgWrapper does what it says on the tin
 
github.com/Flipboard/react-canvas has something similar
 
2:30 PM
ReactSvgWrapper basically ReactDOM.renderString()s the react bit
 
user2620028
windows phone is a more popular platform to develop with than wordpress according to the survey :/
 
you just switch to their components and the top-most ones returns a real DOM element, so react sort of lets their elements take over from there
it calls the lifecycle events on the element, regardless of what those do, so you can have a container component and your own completely un-DOM-related ones to mount within it
 
hm
My challenge is to turn this whole spec into a typing for my library: w3.org/TR/xsl
I've extracted all attributes names already to do transformations on them (some attributes have . in them which isn't valid in jsx)
 
you need all of XSL?
 
XSL-FO
related to, but it not XSL
 
2:34 PM
ok
 
xsl does tranforms, XSL-FO is an html-like document describing a printed document
xsl-fo is the original intended OUTPUT for xsl
fo = formatting objects
 
but it's in the same spec?
 
@Hello document.querySelectorAll('a') or document.getElementsByTagName('a') (which is blergh) Then use a for loop (or use ES6 .forEach if you are allowed to use ES6+)
 
if you look at the table of contents you'll see if abour formatting, not transforming
 
ES6 .forEach?
 
2:35 PM
the title is misleading
 
nice 😃 @KarelG I was thinking, why wouldn't documents.links work?
 
yeah. You could get a very simple working version by taking the title and contents section.
you should be able to parse contents into a TS interface for props
 
it doesn't have much uses if you store all tags in a collection
@littlepootis document.querySelectorAll(...).forEach is ES6
(to bypass it, use array.from before)
 
the constraints, though, I have no idea
 
yea. that doc is available in xml, too.
 
2:37 PM
I don't think document.links returns the same thing as document.getElementsByTagName('a')
 
oh really?
 
@KarelG that's weird
 
@Luggage can you, and I'm somewhat serious here, use XSL to turn it into the code?
it's the textbook case for XSLT
 
That was my original idea, but that xml version is not THAT structured. it's more like an xml version of the PAGE
 
2:38 PM
aw damn
 
but still, the xml structure will help a bit
 
@littlepootis No, it's equivalent to document.querySelectorAll('a[href],area')
 
@KarelG Isn't that part of the DOM?
 
I mean, if you can get a machine-readable contents for each node, that might be enough
 
i can be wrong ... Edge doesn't support it
// checks
 
2:38 PM
You're talking about the iteration protocol (I think)
And yes, it's relatively new.
 
yea, that will be my way of approaching it when I do, try to get as much info out automatically as I can.
 
@KarelG it's DOM, not ES
just saying :>
 
you're right :)
 
@MadaraUchiha ah, gtk
 
2:40 PM
right now my JSX -> FO workflow is nice, for me, but would I could see a future dev saying "wtf?"
 
what's FO
 
but if i can get some typings and intellisense.. that'll go a long way toward making it more acceptable.
 
Formatting Objects
 
formatting objects. an xml format for describing print flow layouts. you can make very detailed PDF
 
@BenFortune i dont think that worked :0
 
2:41 PM
@Mosho "F*** off"
 
JSX doesn't get enough use outside of React imo
 
@MadaraUchiha that's not very nice
 
writing a JSX -> Ansible tool is still on my todo list :p
 
A sample of my output (de-identified) drive.google.com/file/d/…
Yes, that's Roboto and Roboto Slab :)
 
2:44 PM
reports for days
 
@Luggage you know that's pretty interesting
 
that's pretty sweet though, that whole PDF is from JSX?
 
Are you being sarcastic?
 
we had to make all the app I'm working on print-friendly
 
or, will be
 
2:45 PM
it was hell
 
yes, that whole pdf is jsx. the jsx is just a templating for fo (which is very html-like)
and I use apache FOP to process that into PDF
 
write, like unix tools output latex
 
(available in all major linux distros, also for windows)
 
that's definitely the best way to go about print, I've never seen xsl-fo used
 
There are also commercial FO processors, but apache FOP has worked for me.
 
2:46 PM
have you guys ever stopped to think about how mountains are not just funny..
they're hill areas.
 
who was complaining about vscode not having project tabs the other day? nurgo-software.com/products/tidytabs
 
@ssube That's great if you're on Windows
 
I can tab notepad.exe?
 
apparently. That's pretty much notepad++ right there
 
2:51 PM
:D
 
except for supporting /n and syntax highlighting and.. eveything else
 
> You are attempting to access a forbidden site.
da fuq man
 
forbidden, huh? it's probably cause they make windows shell extensions
those are pretty bad for sekyuritah
 
@ssube Could have been me
 
well, if you're bored one day, aquasnap is pretty nice (I use it to make windows essentially a tiled wm) and that other tool might be cool too
 
2:59 PM
Why is the developer survey so focused on gender, and ethnicity?
 
because that's the hotter topic on twitter
 

« first day (2350 days earlier)      last day (2613 days later) »