| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1565 人关注过本帖
标题:求教用js搭建web实验
只看楼主 加入收藏
xushan14
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-6-25
结帖率:0
收藏
已结贴  问题点数:20 回复次数:8 
求教用js搭建web实验
请大神教javascript! 我要学一些很简单的js搭建的心理学实验,我已经有模板code了,给我解释一下各行code的用法就好了。

本人坐标美国,文科在读博士,刚在codecademy上自学了一点html/css和js的基础,还有很多不懂!可以email或者google hangout,skype进行教学。可以付费,我也可以帮改英语作业英语论文或者美国申请资料等。拜托拜托各位高手!导师要我暑假就要学起来了,零基础自学鸭梨山大~~我的邮箱是xushan14@

导师给我的html code 如下:(没错难度就是这么低我都不懂:( )

<!DOCTYPE html>
<html>
    <head>
        <title>Dynamic Multitasking</title>
        <script src="http://ajax. is a library of function code -->
         <script src="scripts/jspsych.js"></script> <!--specifies the URL of an external script file.-->
        <script src="scripts/plugins/jspsych-text.js"></script><!--??-->
        <script src="mtfood v6.js" type="text/javascript"></script><!--why link four files?-->
        <link href="experiment.css" type="text/css" rel="stylesheet"></link>        
        <!-- Load the jspsych library and plugins -->
    </head>
    <body>
        <div id="jspsych_target"></div>
    </body>
    <script type="text/javascript">

// best to store the randomized images in this section and then feed into jspsych

        // *************************  IMG trial  ******************************************
var junk_src = "Junk Food Items/"; //from here is js code? this is an an external script file?
var health_src = "Health Food Items/";//this we can put words before src e.g. health_src =  

    var health_img = [health_src+"h1-fruitSalad-ok.jpg",
    health_src+"h2-yogurtMuesli-ok.jpg",
    health_src+"h3-citrusCup-ok.jpg",
    health_src+"h4-applechips-ok.jpg",
    health_src+"h5-oatmeal-ok.jpg"];
   
    var junk_img  = [junk_src+"j1-applePie-ok.jpg",
    junk_src+"j2-iceCream-ok.jpg",
    junk_src+"j3-citrusCake-ok.jpg",
    junk_src+"j4-potatoChips-ok.jpg",
    junk_src+"j5-waffles-ok.jpg"];
   
    function randomize_stimuli(array1,array2){// function to randomize stimuli
        var matrix = [];//?
        var x = 0;//?
        var n=0;//?
        for(var i=0; i<array1.length; i++) {// create matrix to store the stimuli for each condition
            for(var j=0; j<array2.length; j++){
                matrix[n] = new Array(2);//?
                x = Math.floor((Math.random() * 2)+1);//random number between 1 and 2 to determine left or right presentation of img, math.floor means round a number downward to its nearest integer
                if(x==1){
                    matrix[n][0] = array1[i];//?
                    matrix[n][1] = array2[j];//?
                }
                else if(x==2){
                    matrix[n][1] = array1[i];//?
                    matrix[n][0] = array2[j];//?
                }
                    n=n+1;//?
            }
        }
        //shuffle stimuli ****what is this for???
                var m = matrix.length, t, tt, d;//???
                // While there remain elements to shuffle…
                while (m) {
                // Pick a remaining element…
                d = Math.floor(Math.random() * m--);
                // And swap it with the current element.
                t = matrix[m][0]; //?
                tt = matrix[m][1];//?
                matrix[m][0] = matrix[d][0]; //?
                matrix[m][1] = matrix[d][1]; //?
                matrix[d][0]= t; //?
                matrix[d][1]= tt; //?
                }               
        return matrix;
    } //?the set of codes?
    var img = randomize_stimuli(health_img,junk_img);
   
   
    var debrief = "<div id='instructions'><p>Thank you for " +
            "participating!  Press enter to see the data.</p></div>";
   
    var cent_block = { //?
        type: "mtfood",//?
        stim: img //?
    };//?
    var debrief_block = {
                type: "text",
                text: [debrief]
            };
    // an array of paths to images that need to be loaded
jsPsych.preloadImages(img, function(){ startExperiment(); });

function startExperiment(){
    jsPsych.init({
            display_element: $('#jspsych_target'),
            experiment_structure: [cent_block,debrief_block],
            on_finish: function(data) {
                $("#jspsych_target").append($('<pre>', {
                    html: jsPsych.dataAsCSV()
                }));
                jsPsych.saveCSVdata("data.csv");

            }
        });
}
        
    </script>
   
</html>
--
搜索更多相关主题的帖子: javascript google 英语论文 英语作业 心理学 
2015-06-25 23:06
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
收藏
得分:5 
花点钱找人做一个罢
2015-06-25 23:43
xushan14
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-6-25
收藏
得分:0 
回复 2楼 zklhp
我也是这么想的呀!我导师非得让我说,然后我想技多不压身,但是时间有点紧。我实在是太菜了~
2015-06-26 00:01
xushan14
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-6-25
收藏
得分:0 
回复 3楼 xushan14
非得让我学。
2015-06-26 00:01
xushan14
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-6-25
收藏
得分:0 
回复 2楼 zklhp
一般做一个这样的web实验,得多少钱啊?
2015-06-26 00:06
hu9jj
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:红土地
等 级:贵宾
威 望:400
帖 子:11771
专家分:43421
注 册:2006-5-13
收藏
得分:5 
一个暑假的时间也足够弄懂一楼的代码了。

活到老,学到老!http://www.(该域名已经被ISP盗卖了)E-mail:hu-jj@
2015-06-26 06:46
xushan14
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-6-25
收藏
得分:0 
回复 6楼 hu9jj
我自己查了一天,差不多能搞懂html这个的code了,问题是还有5个其他的更长更不懂的文件呢,我就被吓坏了!想找个人来每个礼拜帮我解答一下疑惑。
2015-06-26 10:24
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:5 
总体来说,这个代码就是用jquery做的,加上一些jquery插件,楼主放的js里并没有什么高深的技术,只是简单的调用了jsPsych这个jquery插件里的两个方法

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2015-06-26 12:49
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:5 
回复 6楼 hu9jj
一个暑假?

你混哪个大学的?

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-06-29 08:31
快速回复:求教用js搭建web实验
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019428 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved