Jump to content

justsomeguy

Moderator
  • Posts

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Posts posted by justsomeguy

  1. Look:

    $('body, html').animate({scrollTop: $('#your_tutor').offset().top},800);

    You are targeting 2 elements.  The body element, and the html element.  You are telling it to animate scroll both of them at the same time.  I have no idea what the browser is going to do when jQuery tries to animate the window scrolling of 2 elements.

    That's what I'm talking about.

  2. Are you suggesting another way to expose a hidden div that does not use Javascript?

    There's probably a way to use CSS only to do a transition, but no, I wasn't suggesting not using Javascript.

    Have you tried your mobile device.

    No.  Maybe it reacts differently to trying to animate scroll two elements at the same time.

    Yes, if one waits in a non-mobile environment the problem does correct itself, but internet users are generally impatient and demand perfection.

    I know.  I see the fact that it doesn't do it if you wait as a symptom or clue to what the problem is, and my guess, again, is trying to scroll two elements at the same time.

  3. It seems like the animation doesn't finish for a while, maybe because you're trying to simultaneously scroll 2 elements.  If you wait before scrolling it's fine.

    Quote

    You may observe this phenomenon by clicking on the link And, more... after opening to the GC Tutor item from either the navigation bar on the Grammar Captive mainpage or the Grammar Captive subdomain tutor.grammarcaptive.com.

    Are you unable to link directly to specific parts of your site because you're loading everything with Javascript?

  4. removing the checked option from the html part results in a wrong designed button.

    You have CSS targeting only the checked button.

    using the <form> tag makes only the unchecked button clickable.

    That's how radio buttons work, you can only select one of them.

  5. If I use wget with that it gives me a 403 response, you want people to help you get around Apple's authentication?  If you want to distribute Apple's software, then contact Apple and tell them you want to distribute their software.

  6. which means the value when defined as static will no change right!

    No, that's not what it means.  It means that the variable persists its value even across different function executions.  It means that each time that function runs, the variable has the value from the last time it ran.  If you don't want a value to ever change then use a constant.

  7. I'm using source code as it's normally used by programmers.  You write Javascript source code, and then use NPM to build the final package, just like you would use a compiler to compile C code into an executable.  Here's the source for one of my components that's using react:

    import React from 'react'
    
    import StudentLayout from 'components/StudentLayout'
    
    export default class MainAppLayout extends React.Component {
        constructor(props) {
            super()
            this.state = {
                LMSuser: props.LMSuser
            }
        }
    
        render() {
            return (
                (
                    <div style={{margin: "10px"}}><StudentLayout LMSuser={this.state.LMSuser} /></div>
                )
            )
        }
    }

    It imports another package and another component, and exports a class for this component with constructor and render methods.  NPM takes all of the source code for all of the components and packages you're using and produces a single deliverable that is the actual runnable Javascript for the project. Here's the source code for another component:

    import React from 'react'
    import $ from 'jquery'
    
    import { Link, IndexLink } from 'react-router'
    
    import Msg from 'components/Msg'
    import Messages from 'components/Messages'
    import PageNav from 'components/PageNav'
    import Footer from 'components/Footer'
    import MainAppLayout from 'components/MainAppLayout'
    import getMuiTheme from 'material-ui/styles/getMuiTheme'
    
    
    import {Card, CardActions, CardHeader, CardMedia, CardTitle, CardText} from 'material-ui/Card'
    import FlatButton from 'material-ui/FlatButton'
    import defaultTheme from 'themes/defaultTheme'
    import muiThemeable from 'material-ui/styles/muiThemeable'
    import CircularProgress from 'material-ui/CircularProgress'
    import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
    import Chip from 'material-ui/Chip'
    import Avatar from 'material-ui/Avatar'
    import SocialPerson from 'material-ui/svg-icons/social/person'
    import { white } from 'material-ui/styles/colors'
    
    
    import * as Actions from 'actions/Actions'
    import Store from 'stores/Store'
    import MsgStore from 'stores/MsgStore'
    
    
    export default class Layout extends React.Component {
        constructor() {
            super();
            this.state = {
                apiAvailable : true,
                haveUser: false
            }
        }
        componentDidUpdate() {
            //componentHandler.upgradeDom()
        }
        componentWillMount = () => {
            this.getLMSUser();
        }
        getLMSUser = () => {
            this.userXHR = $.ajax({
                method: "POST",
                url: "lms.php",
                dataType: "json",
                data: {mode: "getUser"}
            }).done( (data) => {
                if (!data.username) {
                    MsgStore.createMsg({message: 'You are not logged in.', type: "popup"})
                    return;
                }
                Actions.saveLMSUser(data)
                this.setState({LMSuser: data, haveUser: true})
            })
            .fail( (xhr, status, err) => {
                    if(err != 'abort'){
                    //MsgStore.createMsg({message: err})
                    alert('Error contacting server')
                }
            })
        }
        handleSubmit = () => {
            let api = typeof(Novus) !== 'undefined' ? Novus.api.base.split('/rest')[0] : null
            window.location.assign(api)
        }
        render() {
            let displayWidth = $(window).width()
            const theme = defaultTheme()
            const { apiAvailable, haveUser } = this.state
            const styles = {
                loader: {
                    width: '100%',
                    textAlign: 'center',
                    marginTop: "400px",
                }
            }
    
            return (
                (apiAvailable && haveUser) ?
                <MuiThemeProvider muiTheme={getMuiTheme(theme)}>
                    <div>
                        <PageNav muiTheme={getMuiTheme(theme)}/>
                        <MainAppLayout muiTheme={getMuiTheme(theme)} LMSuser={this.state.LMSuser}/>
                        <Footer muiTheme={getMuiTheme(theme)}/>
                        <Msg displayWidth={500} />
                    </div>
                </MuiThemeProvider>
                :
                <MuiThemeProvider muiTheme={getMuiTheme(theme)}>
                    <div style={styles.loader}>
                        <div style={styles.loader}>Veeco FSA Tool</div>
                        <Msg />
                    </div>
                </MuiThemeProvider>
            )
        }
    }

    If you just tell a browser to load that it's not going to know what you're doing.  That's the source code, not the built project.

  8. I don't have an example of running a SQLite pragma, but if you do some research I'm sure you'll find examples.  It should return a result set of columns that you can use to determine if the column you want is already part of the table.

  9. SQLIte does not have if statements.  It also does not have an information_schema database.  It seems like you found something that works in MySQL and you're assuming that it's also going to work in any other database, and that's not true.

    It looks like you need to use the table_info pragma to get information about a table, which will return one record per column in the table.  Look through those results to see if the column exists and then alter the table if not.

    https://www.sqlite.org/pragma.html#pragma_table_info

  10. In Javascript, all strings are internally treated as UTF-16 strings:

    http://ecma-international.org/ecma-262/5.1/#sec-8.4

    http://speakingjs.com/es5/ch24.html

    When a String contains actual textual data, each element is considered to be a single UTF-16 code unit. Whether or not this is the actual storage format of a String, the characters within a String are numbered by their initial code unit element position as though they were represented using UTF-16. All operations on Strings (except as otherwise stated) treat them as sequences of undifferentiated 16-bit unsigned integers; they do not ensure the resulting String is in normalised form, nor do they ensure language-sensitive results.

    • Thanks 1
  11. You can get the length of a string, although you haven't said which database you're using so we don't know what's available to you.  Regardless, it looks like you have a field where you're storing multiple pieces of data, and you're figuring out the reason why it's not a good idea to do that. If the different parts of that string are each significant then they should be in their own fields.

  12. Yes, I can cleanse at the point of input, but how do I write the regex for my two examples:

    I'm not sure why you're trying to filter out all apostrophes at all, because your problem is not apostrophes, but an obvious pattern would be an apostrophe that does not follow a letter.

  13. I doubt that someone is typing "&quot" into a search field somewhere, so that data is getting messed up somewhere along the way.  Ideally you would find where and fix it there so that the data can be normalized to start with.  Terms shouldn't be repeated just because they have extra punctuation.  Otherwise, before the data gets added to the database try to clean it up by looking for those specific terms and removing them.

  14. Indeed, I am finding it difficult to remove HTML entities like &#309;  and &quot;.

    How come, what's the difficulty?  Is the  problem that the escape sequences seem to be missing the terminating semicolon?  Can you figure out why that is?  If you're only seeing specific sequences then you could just look for those specifically and remove them.

  15. I'm not sure what your specific problem is.

    I would not store any version of a password in a cookie though, even if it's hashed.  Just store a user ID and a token.  Generate a new token for every request, so that each token is only used once.  When you check the cookies to validate the user, compare the cookie token with the token in the database for that user, and if it's correct generate a new cookie, save it in the database, and update the cookie.  Use single-use tokens instead of saving personal details in the cookie.

  16. It might not be possible to support very old browsers, it depends what they allow.  I know that some sites used to use a Flash movie to do copying.  Old IE that supports ActiveX may be able to use an ActiveX control to support copying.  At some point you need to just draw the line though.  My company doesn't even fix bugs on unsupported IE browsers for free any more, if a customer finds a bug that is only in an unsupported version of IE we bill them for the bug fix if they want us to do it.  It was a good day when we could make that decision.  We'll fix any bugs that show up in a current browser version, but when Microsoft stopped supporting IE we did too.

  17. How would you go about cleansing the data of the &quot, &#039, and &quotperson before the list is created?  It appears to require some sort of REGEX expression.

    You could use a regex, you could also use str_replace to just replace specific characters.

    Where would you cleanse the data?

    It depends if you want to save the original data or not.  If you don't care about the data before it gets cleaned, then clean it before you save it.

×
×
  • Create New...