JavaScript 语法错误

标签 javascript syntax syntax-error

我在第 13 行遇到语法错误... 第 13 行:

"c001": {type:"tool", id: "webconference", name:"Web Conference Tool"}, // web conference

你能帮我解决这个问题吗? :) 谢谢。

//assuming jquery exists

/* notes:
    a lot of the functions need to either return jQuery or jQuery.ib, and if jQuery.ib then I need a .stop() function that returns jQuery 

*/



(function(){
    jQuery.fn.extend({ibSetup: function(){
        toolmap: {
            "c001": {type:"tool", id: "webconference", name:"Web Conference Tool"},             // web conference 
            "c002": {type:"alias", "main": "c001"},         // web conference yearly
            "c024": {type:"tool", id: "webconference-package", name:"Web Conference tool"}, // web conference tool package version 
            "c0something": {type:"tool", id:"webconference-premium", name:"Premium Web conference Tool"}, // premium wc

            "c053": {type:"alias", "main":"c024"},          // signature bronze (wc tool)
            "c075": {type:"alias", "main":"c024"},          // signature bronze (wc tool) quarterly
            "c054": {type:"alias", "main":"c024"},          // signature bronze (wc tool) yearly

            "c004": {type:"tool", id: "template", name:"Template Tool"},                // template tool
            "c008": {type:"alias", "main":"c004"},          // template tool yearly 

            //check quantity on these;
            "c018": {type:"tool", id: "template-extrauser", quantity:1, name:"Template Tool Extra User"},       // template tool 1st extra user - $12.47
            "c019": {type:"tool", id: "template-extrauser", quantity:"check", name:"Template Tool Extra User", "extends":"c018"},   // template tool additional users - $10.00

            "c020": {type:"tool", id: "businessresponder", name:"Business Responder Tool"},             // business responder tool
            "c021": {type:"alias", "main":"c020"},          // business responder tool yearly

            "c005": {type:"tool", id: "volumemarketing", name:"Volume Marketing Tool"},             // volume marketing tool


            //packages:
            "c025": {type:"package", tools:["c024","c004","c020"], name:"USABG Starter Package"},   // USABG Starter Package: GUESSED AT TOOLS

            "c077": {type:"package", tools:["c004","c020","c005"], name:"Ultimate Template Package"},   // ultimate template: ett, br, marketing

            "c027": {type:"package", tools:["c024","c004","c020"], name:"Essential Silver Package"},    // silver package: wc, ett, br
            "c075": {type:"alias", "main":"c027"},              // sp quarterly
            "c076": {type:"alias", "main":"c027"},              // sp semi-annually
            "c028": {type:"alias", "main":"c027"},              // sp yearly, 

            "c050": {type:"alias", "main":"c027"},              // sig sp, 
            "c051": {type:"alias", "main":"c027"},              // sig sp semi-annually, 
            "c080": {type:"alias", "main":"c027"},              // sig sp quarterly, 
            "c052": {type:"alias", "main":"c027"},              // sig sp yearly; 

            "c023": {type:"package", tools:["c024","c004","c020"], name:"Vital Gold Package"},  // gold package: silver + subsite (and this script doesn't do the websites.. yet.)
            "c073": {type:"alias", "main":"c023"},              // gp quarterly
            "c074": {type:"alias", "main":"c023"},              // gp semi-annually
            "c030": {type:"alias", "main":"c023"},              // gp yearly

            "c031": {type:"alias", "main":"c023"},              // sig gp 
            "c081": {type:"alias", "main":"c023"},              // sig gp quarterly
            "c039": {type:"alias", "main":"c023"},              // sig gp semi-annually
            "c032": {type:"alias", "main":"c023"},              // sig gp yearly

            "c022": {type:"package", tools:["c024","c004","c020","c005"], name:"Full Platinum Package"}, // platinum package: silver + website + volume marketing tool
            "c071": {type:"alias", "main":"c022"},              // pp quarterly
            "c072": {type:"alias", "main":"c022"},              // pp semi-annually
            "c029": {type:"alias", "main":"c022"},              // pp yearly

            "c***": {type:"manual", name:""}                // other tool template
        },
        tools: [],
        cookies: {
            "salutation": "",
            "fname": "",
            "lname": "",
            "email": "",
            "password" : "",
            "title": "",
            "company": "", 
            "address": "", 
            "address2": "",         // may not exist!
            "city": "", 
            "state": "", 
            "zip": "", 
            "phone": "", 
            "tollfree": "", 
            "cell": "", 
            "fax": "",  
            "website": "", 
            "country": "", 
            "dob": "", 
            "spouse": "", 
            "spousedob": "", 
            "repnum": "" //otherwise refered to as repid; may not exist
        },
        getTool: function(partno){
            if(typeof toolmap[partno] == "undefined") return false;
            else if(toolmap[partno].type == "alias") partno = toolmap[partno].main;
            return toolmap[partno];
        },
        getToolString: function(partno,qty) 
        {
            var str = "";
            var amp = false;
            function makeStringPiece(partno){
                var tool=getTool(partno);
                if(!tool) return false;
                if(tool.type=="package") {
                    for(i in tool.tools){
                        str += makeStringPiece(tool.tools[i]);
                    }
                }
                else{
                    this.amp ? str += "&" : this.amp = true;
                    str += "tool[]="+tool.id; //"+this.counter+"
                    this.counter++;
                    if(tool.quantity) { 
                        str += "&" + tool.quantity=="check" ? this.qty : tool.qty;
                    }
                }
            };
            makeString(partno);
            return str;
        },

        //filter and foreach from http://eloquentjavascript.net/
        filter: function (array, test) {
            var result = [];
            forEach(array, function (element) {
            if (test(element))
                result.push(element);
            });
            return result;
        },
        forEach: function(array, action) {
          for (var i = 0; i < array.length; i++)
            action(array[i]);
        },

        readTools: function(){
            for(partno in toolmap){ //I might need to change this to use .each()
                var t = readCookie(partno)
                if(t) tools.push(t);
            };
        },
        readUser: function(){
            for(name in cookies){
                cookies[name] = readCookie(name);
            }
        },

        createCookie: function(name,value,days) {
            if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
            }
            else var expires = "";
            document.cookie = name+"="+value+expires+"; path=/";
        },

        readCookie: function(name) {
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
            }
            return null;
        },

        eraseCookie: function(name) {
            createCookie(name,"",-1);
        }

    }}); //close function, close extend object, close extend()
})(); // close and execute my anonymous function

最佳答案

JSLint 提示第 12 行

当我尝试改变时:

toolmap: {

至:

toolmap = {

这似乎解决了问题。

关于JavaScript 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3495056/

相关文章:

javascript - 验证码成功后执行JQuery替换div内容

javascript - 当我们从下拉菜单中选择一个选项时动态添加输入类型

php - 如何使用include函数通过php变量将数据库查询的结果返回到另一个页面

assembly - ARM 汇编语法样式

javascript - 以编程方式运行时未找到 Node 依赖项

javascript - 滚动后更改 Bootstrap 导航栏品牌 Logo 图像的最佳方法?

失败函数的 C++ while 语句?

wordpress - PHPStorm 和 WordPress 项目错误

MySQL 存储过程 Case 语句语法错误 - 续 2

python - 解决了: Why does importing a Python library throw a syntax error?