« first day (2176 days earlier)      last day (2997 days later) » 

14:00
It sounds like they are trying to use the kernel as an ingredient in cooking.
ever heard of Chef?
Yes.
@Luggage js can though
I am playing with ansible as we speak, but do you have a strong case for chef? I'm all ears.
14:02
I don't
If I'm moving js code from a view to a new separate filed referenced instead in the page.
Can I just paste that code into the new file and reference it in the view via a script tag?
Or do I need to place the js in an anonymous function?
perhaps.
if you are using no other bundler / module tools, then an anonymous function can use useful to prevent global variables.
but I'd look at having that done automatically to all JS files (a build step) instead of doing it manually.
you dig?
ok didn't know that was a thing
so the bundler will handle that, must check
14:08
most do or have an option.
well, most that I have used, which is just a few
ok it seems I have syntax errors pasting the script into a new file
don't think it needs to be surrounded by script tag in a js file?
correct.
or maybe
Also, if you escape anything, like < then you don't need to here.
ok not 100% why I'm getting syntax errors then
14:10
does your editor tell you? if not, use something liek eslint
or paste into the eslint webpage, i think it has an online tool
Upgrading to iOS10. Let's see if it's good
pasted into the online tool, doesn't seem to like @ symbol
because I'm doing things like:
var epridAppList = @Html.Raw(Json.Encode(Model.Applications));
yea, that's Razor.
not JS.
it's c#, actually
yeah it is
I'm referencing some c# list past into the view from my js
What I did there was have JUST that data in a <script> tag
14:12
not possible then to separate the js from the view?
<script>var page_data = @Html.Raw(Json.Encode(Model.Applications));</script>
<Script src="./pageScript.js></script>
then the rest of the script, with no razor, can be separate
oh ok
what about in a ajax post
url: "@(Url.Action("EmailAndSubmit", "Create"))",
that should be fine?
For that, I make a JS version of Url.Action() that would output similar URLs as the C# versiob.
ok any chance of sharing that?
:P
It's in my code back at Xerox and I don't work there anymore.
14:16
ah ok is there any benefit to separating the js in the view at all?
may leave it as is
Yea.
thanks for advice anyways
guess this is a unique case since I'm using razor in the js
It's not unique
* Keeping JS separate helps organize
* opens the door for using things like require.js, webpack, etc
and using babel..
Hi all. What is a good fn to replace underscore's isNumber function with in es6?
14:19
may give it another try, found something for url.action
Another choice is to just parse things like a record id out of the url. That's how some apps work anyway.
5
Q: How to call URL action in MVC with javascript function?

gardarvalurI´m trying to render url action with javascript in an MVC project. I capture an event on my page which calls this function but I´m not sure how to call this certain URL. Can anyone help me please? :) function onDropDownChange(e) { var url = '/Home/Index/' + e.value; //What now...? } ...

yea, url.action just returns a url as a string. You can make one up in a few lines of code
@SterlingArcher Yea, but I need it to work with floating point ;-)
14:20
btw this script tag is added to the page using the script, not the script file itself?
<script>var page_data = @Html.Raw(Json.Encode(Model.Applications));</script>
I found that one already
controller + '/' + action or some shit
!Number.IsNan
that script tag must be in the .cshtml
Will Number.isFinite work better @rlemon?
14:21
What's the case
Number.isNaN('a') returns false
@rlemon Monetary values
I'm reaching the end of my memory. I haven't used Razor in over 2 years.
dollars and cents
function isNumeric(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}
and I smoked the rest away
14:22
@SterlingArcher Yea, but then there is the new Number version of those functions.
That do stuff a lil differently
!Number.isNaN(Number(input));
Number.isFinite vs isFinite os a lil different
!!> Number.isNaN('a')
@SterlingArcher false
da fuq how is that false
14:23
!!> !Number.isNaN(Number('1.a'));
@Neal false
@rlemon ^
fail
wait
ahh i am confused lol
In this case, wouldn't I need to pass the page_data var into the page script?
!!> !Number.isNaN(Number('1.14159'));
<script>var page_data = @Html.Raw(Json.Encode(Model.Applications));</script>
<script type="text/javascript" src="@Url.Content("/Scripts/View_Scripts/CreateEscalation.js")"></script>
14:23
@Neal true
Hmmm But I dont want strings to be evaled as numbers @rlemon
so fucking change it neal
Only numbers as numbers.
you know js
ha
14:24
god dammit why are you so vampy sometimes
Yea, mostly es5-
numbers haven't really changed
For some reason underscore uses a weird way to type check numbers
  _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) {
    _['is' + name] = function(obj) {
      return toString.call(obj) === '[object ' + name + ']';
    };
  });
Seems odd
function isNumber(n) {
    return Math.floor(n) === +n;
}
for >0
should work fine
Fancy.
But then would fail for negative #s?
14:26
I'm sure you can figure out how to make it work with floats.
hmmm
to the lab!
!!> Object.prototype.toString.call(1)
!!> Object.prototype.toString.call('1.a')
@Neal "[object Number]"
Hmmm
@Neal "[object String]"
k underscores method could work
!!> Object.prototype.toString.call(3.14159)
14:28
@Neal "[object Number]"
function isNumber(n) {
    return typeof n !== 'string' && !isNaN(n);
}
console.log.apply(console, [1, 1.1, -1, 'a', '1.a', '123'].map(isNumber)) // true true true false false false
@rlemon let her be praised
!!> typeof {} !== 'string' && !isNaN({});
@Neal false
but really Neal, I am disappoint son. you have almost 100K rep and you're asking how to check if a number is a number.
14:29
cool
there are multiple SO posts about this
@rlemon Haha yea I know. I have read them all. Too many answers. overloaded. and I am on a time crunch :-(
Why are you checking if it's a string though?
he doesn't want strings to be numbers
for some reason
(if this is user input, he's boned and doesn't know it yet)
return typeof(x) === 'number' && !isNaN(x)
cause an array is not a string either
14:32
@rlemon Not user input. coming from API that does all the validation etc. I am just consuming the API
Trying to remove underscore where i do not need it and use native.
@rlemon
@JamieLester
If you do typeof [1] !== 'string' && !isNaN([1]) is true
I haven't figured out the chat yet lol
How do I put in code? XD
!!format
Format your code - hit Ctrl+K before sending and see the faq
14:34
inline code is wrapped in backtics
unnatural line breaks remove all formatting but fixed font
test `if
lemon` is correct
return typeof x === 'number' && !isNaN(x)
shazam
14:36
so I think my logic is screwed here. I'm trying to map the date column from an array to it's corresponding row in a table.
what ends up happening is that the first date value in the list gets assigned to every row for that column
@BrianJ There are no columns in an arrray...?
date value I mean
this for better context
iOS10 literally just killed my phone
ha
sucker
haha
14:38
100% battery to 0% and now it wont charge
don't buy iCrap
what version of iphone
I know the code to get the date value is correct just the iteration logic is wrong @JamieLester
@SterlingArcher come on over to Android
cheaper and more features
14:39
@SterlingArcher I am having charging issues as well. I did not think to attribute it to iOS10
@SterlingArcher LOL
Take that to iHelp.
@BrianJ The logic is wrong lol
My phone has been having severe battery issues. Something is wrong with the calibration. It will die at any % battery because it doesn't know it has battery. Won't turn back on till it's plugged in, then it turns on at the proper battery level
Guys, I suck at SVG... is it possible to, simply, create a 100x100 grid and draw text within it? It keeps drawing in weird positions, I think one of the "anchor points" is off
@SterlingArcher cheer up i.imgur.com/EmITaeb.gifv
and then buy an Android
14:41
for each TR, you're looping through this status array and setting the val to the last date in the status array that isn't null
@BrianJ I think if you look into jQuery's each(function (INDEX) {...}); you'll figure it out
I'm going to go to the verizon store and bitch
@SterlingArcher make sure to smash the fuck outta it
Oh thank god, it's turning on
Hey guys, do you know if i have to wait a moment after i update the html of an element before i can access said updated html?
@zack6849 Welcome to the JavaScript chat! Please review the room rules. Please don'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.
14:46
I'm restoring my phone this is bullshit
I have a script that posts to an api and updates the content of the element based off the response from the api
If i try and target elements that should have been added by the update on the line above, they don't appear to be working
code or gtfo
;)
incoming wall
do i need a specific tag for code formatting
or is it just plaintext anyways here
incoming set after ajax not in success
@zack6849 jsfiddle.net
14:49
JSFiddle won;t have much luck running the js
seeing as the api is internal only.
yea, and it won't run in here either
Are you referencing it in the success callback?
their code editor looks nicer
this is in the function: pste.pw/v/svaEvcCRZ9Uv8
and the problem is where
14:50
The html gets updated, but the if statement never executes.
		if($("#current_ibr_run").text() > $("#newest_ibr_run").text()){
you saying you always get the else?
the if statement checking if #current_ibr_run is older than #newest_ibr_run
Which if statement?
I don't get anything, i don't think. lol
Hmmm I have googled. Anyone have a good solution for replacing _.defaults from underscore. Their function seems too convoluted. That is the last underscore fn for me to replace.
14:51
@JamieLester so for each tr I'm looping through the list, if there is a date set it to the row in that index. Then onto the next one
@zack6849 what do you expect to happen, what happens.
and are there errors
like, when i run this same exact code from console
perhaps I just need an else clause to set it to null if there is not date value
@Neal Object.extend?
it returns true, so the if should be working.
it's supposed to unhide an element on the page
but it doesnt appear to
14:52
$("#vinfo_warning").show
you're missing ()
@rlemon Well No. I do not want to use Object assign, do I? That is what I replaced _.extend with
oh, that's because i was changing it to show lmao
sorry
oh. I guess it is reverse of assign
let me see if show and hide works alright
one moment
So instead of _.defaults(a, b) with will be Object.assign(b, a)
Hmmm
14:53
welp
show and hide fixed it
iunno what the problem with addclass and remove class was
idk, never used underscore
@JamieLester ok maybe the for on the list should be outside the tr. each
Object.extend(source, defaults); works deep
then pass in the index
?
thanks for the help anyways guys, i appreciate it
14:54
*(you provide object.extend)
@BrianJ you don't want to loop through the status array for each table row, you just want to index into the status array at the index of the table row
yeah
think I can give that a go
@BrianJ do not put a for loop around it lol
Post the link to your code again
but I need to pass in the index to .find right?
14:55
1 message moved to Trash can
@JamieLester Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
@Neal read my next message
Y U NO READ NEAL
@rlemon ahh missed that ;-( How would you do it then?
Object.extend = (d*/estination*/,s*/ource*/) => {
    for( let k of Object.keys(s) ) {
        const v = s[k];
        if( d.hasOwnProperty(k) && typeof d[k] === 'object' && typeof v === 'object' ) {
            Object.extend(d[k],v);
        } else {
            d[k] = v;
        }
    }
    return d;
}
I know I can write one. I am at a loss. The only thing I can think of is a reverse assign
1 message moved to Trash can
@JamieLester Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
14:58
$("tbody").find("tr").each(function(index) {
  var date = status[index]["IT_Date"];

  if(date!= null)
  {
    ... do something with the date here
  }
});
ok figured out the formatting
@rlemon What is the diff btw using that and using Object.assign all of the way down?
@JamieLester don't you need a for loop outside to pass in each index?
@BrianJ index of what?
assign doesn't deep clone iirc
the index of the list item?
14:59
@BrianJ no, the each function passes the index into it
what list item? you mean table row?
ahhhh
my bad
get it
Please read the documents lol
documentation*
@rlemon No I realize that. Hmmm true. So yours is a "deep" assign? (sort of)
assign also does crap with getters and setters
15:01
How do I use this in a MVC project: http://codepen.io/josemc/pen/Kwbapp?editors=1100
The Less CSS uses @ signs which makes my view believe it's C# code...
How so? @rlemon
read the docs Neal
I am.
It uses them. It uses getters and setters.
As in, it will set a value using a setter, not replace the setter.
@StemStep go look at how to convert less to css maybe
LESS is a css precompiler
15:03
ok within that if, when I do the following it is just setting the td with an inner input of class remediation-datepicker to that date value. Not every datepicker in the table rows?
$(this).find('input.it-datepicker').val(date_formatted);
@JamieLester
aka, I shud just download node.js on my server
no
you should look at what LESS is and how to use it
less === awesome
scss === awesomer
also scss
yea, that's fine. I don't see them as that difference, but I'd use scss for a new project just because it seems to be the current favorite.
15:06
there was a time when scss offered more features, so I started using it
now I'm pretty sure they are on par
Clearly im not understanding. :P
but my brain still says scss > less
or very very close
Not understanding what?
15:07
there is a compile step
you don't run LESS runtime unless you are prototyping
Less is to CSS what Typescript is to JS
yes working, thanks a lot @JamieLester
not understanding how to implement it into my MVC5 project @Luggage
neck deep and learning how to doggy paddle?
(not an insult)
Hmmm @rlemon it seems that your Object.extend does not accept multiple sources.
15:09
did you look at the code Neal?
it takes two arguments
god dammit are you fucking drunk today?
Would it be okay to edit MDN just because you can't understand the docs?
@rlemon Yes... but Object.assign can accept multiple ;-)
@rlemon 👍
15:10
@Neal it isn't object assign Neal.
Object.extend isn't even a thing
@rlemon ... I know..
@BrianJ it should
@Luggage how would you set defaults to an object (like underscore does with _.defaults)
_.defaults does not operate like Object.assign. _.defaults sets values if they are undefined. Object.assign sets values int he order you give it
so.. just put the defaults first
15:13
@Luggage he vamped about defaults so I suggested what I've done in the past. chat.stackoverflow.com/transcript/message/33196631#33196631
@Luggage That is what I thought. ok. But 1st with an empty object so that i dont overwrite my defaults, yea @Luggage ? :-)
first with whereever you want them to end up
if that's an empty object or some other target, only you can decide
e.g. Object.assign(this, ...)
guys is it possible to inline a CSS transform in react?
@Luggage So do you think this would be a suitable replacement?
export default function defaults (destination, ...sources) {
    return Object.assign({}, ...sources, destination);
}
class MyClass
{
    constructor(options) {
        Object.assign(this, this.constructor.defaults, options);
    }
}
MyClass.defaults = {
    foo: 42,
    bar: 43
}
15:17
Although I am not mutating the destination.
^^ this is something like that I do.
hmmm
Object.assign on this. Isn't that "dangerous"?
You may never know what is on the object.
new MyClass({ foo:666, jimbo: 1}) => { foo: 666, bar: 43, jimbo 1}
Does my solution work as a basic defaults @Luggage ? (or @rlemon if you are still interested)
no I lost interest a long time ago
15:18
I know because i made the object.. but Object.assign(this, ...) is SETTING properties on this. which is what I want to do
k. but in my case, will my fn work as expected?
I don't understand your solution.
blah. need to write tests...
What do you mean?
i mean.. i see whta it's doing, but I don;t know what semantics you desire. Only you do.
YOU have to determine if code does what YOU want
I pass in an object. and defaults that I want the object to have. Then it will return a new object with the defaults set, no?
15:20
You now know what Object.assign does so do what I do. Read the code, execute it in your mind and detemrine if you like the outcome
e.g. I have no idea why you aren't setting properties on destination. It's called destinateion but it's NOT a destination. so.. who knows if that's right
@Luggage ha, yea bad naming
I am not good @ coming up with var names.
What would be a better variable name there @Luggage ?
Name it after what you want it to represent.
Maybe "original"?
and the 2nd variable be defaults
Yea, that is what I will do.
15:32
why can't I use onDrag on a div in react? Do I need to do something special to make it draggable?
@corvid Does the div have the attribute draggable="true"?
... I'm dumb.
@corvid Nah. It happens to the best of us.
Nope.

« first day (2176 days earlier)      last day (2997 days later) »