JavaScript 语法错误

发布于 2024-09-14 17:33:29 字数 7981 浏览 6 评论 0原文

我在第 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

I am getting a syntax error on line 13...
line 13:

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

Can you help me fix this? :) Thanks.

//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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明明#如月 2024-09-21 17:33:29

JSLint 抱怨第 12

行当我尝试将: 更改

toolmap: {

为: 时,

toolmap = {

这似乎解决了问题。

JSLint complains about line 12

When I tried changing:

toolmap: {

to:

toolmap = {

that seemed to fix the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文