执行javascript时Eval()出错

时间:2014-01-11 09:25:34

标签: javascript jquery

我正在尝试使用open id selectorAPI为我的应用程序创建sprites。 他们有JS file从Image magic获取帮助来创建精灵图像。

我已按照说明操作并尝试使用此命令运行JS文件

wscript generate-sprite.js

Error Screen Shot

但我得到了以下错误。任何人都可以帮我理解问题吗? JS文件的某些部分

JS文件

var imagemagick = 'C:/Program Files/ImageMagick-6.6.5-Q16/';

var locale = 'en';
if (WScript.Arguments.length == 0) {
        // assuming english locale
} else {
        locale = WScript.Arguments(0);
}

var fso = new ActiveXObject('Scripting.FileSystemObject');

var s;
var f = fso.OpenTextFile('js/openid-' + locale + '.js');
try {
        s = f.ReadAll();
} finally {
        f.Close();
}
var openid = {};
eval(s);

eval is on line35 in that script

OpenID的en.js

/*
    Simple OpenID Plugin
    http://code.google.com/p/openid-selector/

    This code is licensed under the New BSD License.
*/

var providers_large = {
    BD : {
     name: 'BD',
     url: "BD"
   },
    GOOGLE : {
        name : 'Google',
        url : 'GOOGLE'
    },
    FACEBOOK : {
     name: 'Facebook',
     url: "FACEBOOK"
   },

   MSN : {
     name: 'MSN',
     url: "MSN"
   }

var providers_small = {
    livejournal : {
        name : 'LiveJournal',
        label : 'Enter your Livejournal username.',
        url : 'http://{username}.livejournal.com/'
    },
    /* flickr: {
        name: 'Flickr',        
        label: 'Enter your Flickr username.',
        url: 'http://flickr.com/{username}/'
    }, */
    /* technorati: {
        name: 'Technorati',
        label: 'Enter your Technorati username.',
        url: 'http://technorati.com/people/technorati/{username}/'
    }, */
    wordpress : {
        name : 'Wordpress',
        label : 'Enter your Wordpress.com username.',
        url : 'http://{username}.wordpress.com/'
    },
    blogger : {
        name : 'Blogger',
        label : 'Your Blogger account',
        url : 'http://{username}.blogspot.com/'
    },
    verisign : {
        name : 'Verisign',
        label : 'Your Verisign username',
        url : 'http://{username}.pip.verisignlabs.com/'
    },
    /* vidoop: {
        name: 'Vidoop',
        label: 'Your Vidoop username',
        url: 'http://{username}.myvidoop.com/'
    }, */
    /* launchpad: {
        name: 'Launchpad',
        label: 'Your Launchpad username',
        url: 'https://launchpad.net/~{username}'
    }, */
    claimid : {
        name : 'ClaimID',
        label : 'Your ClaimID username',
        url : 'http://claimid.com/{username}'
    },
    clickpass : {
        name : 'ClickPass',
        label : 'Enter your ClickPass username',
        url : 'http://clickpass.com/public/{username}'
    },
    google_profile : {
        name : 'Google Profile',
        label : 'Enter your Google Profile username',
        url : 'http://www.google.com/profiles/{username}'
    }
};

openid.locale = 'en';
openid.sprite = 'en'; // reused in german& japan localization
openid.demo_text = 'In client demo mode. Normally would have submitted OpenID:';
openid.signin_text = 'Sign-In';
openid.image_title = 'log in with {provider}';

3 个答案:

答案 0 :(得分:3)

js/openid-en.js中显然有一个结束括号:

var providers_large = {
    BD : {
     name: 'BD',
     url: "BD"
   },
    GOOGLE : {
        name : 'Google',
        url : 'GOOGLE'
    },
    FACEBOOK : {
     name: 'Facebook',
     url: "FACEBOOK"
   },

   MSN : {
     name: 'MSN',
     url: "MSN"
   }
// There should be a closing bracket here!

答案 1 :(得分:0)

var providers_large = {
    BD : {
     name: 'BD',
     url: "BD"
   },
    GOOGLE : {
        name : 'Google',
        url : 'GOOGLE'
    },
    FACEBOOK : {
     name: 'Facebook',
     url: "FACEBOOK"
   },

   MSN : {
     name: 'MSN',
     url: "MSN"
   }
 };

你错过了最后一次'};'

答案 2 :(得分:0)

在这里缺少一个结束花括号:

var providers_large = {
    BD : {
     name: 'BD',
     url: "BD"
   },
    GOOGLE : {
        name : 'Google',
        url : 'GOOGLE'
    },
    FACEBOOK : {
     name: 'Facebook',
     url: "FACEBOOK"
   },

   MSN : {
     name: 'MSN',
     url: "MSN"
   }
}; // Added! :)

希望这有帮助!