enesser / vCards-js

Create vCards to import contacts into Outlook, iOS, Mac OS, and Android devices from your website or application.
MIT License
419 stars 154 forks source link

tests.js:5: Uncaught ReferenceError: require is not defined #21

Closed pacificsoftdevld closed 7 years ago

pacificsoftdevld commented 7 years ago

Hi. Thanks for your plugin! But when i clone it. In my for folder, it hasn't any example. I created index.html and implement tests.js into it. But it appeared a error. Can you show how to use your plugin? Sorry because i am a beginner. Thanks for you support! :D

enesser commented 7 years ago

This module is written in CommonJS format and works with Node.

You can run the examples in the README file using node yourfile.js once Node is installed.

If you want to get the code running in the browser instead of on a server, you can use this module with Browserify, but you'll only be able to use the toString() function instead of being able to save to a file.

I could make this module work more easily with the browser out of the box, but I don't know if that's a popular use case or not. I'll have to see if that's something my users want.

Let me know if that is enough information or if you need more help.

Thanks!

pacificsoftdevld commented 7 years ago

Thanks for your help!

I'm not using Node. In my case, i only need get name and tel of user and create a vCard. I found suitable function with me. `var vCard = (function () { var start = "BEGIN:VCARD\nVERSION:3.0"; var end = "END:VCARD"; var data = "";

        var init = function() {
            data = "";
        };

        var name = function (surname, lastname) {
            data += "N:" + lastname + ';' + surname;
            data += "\n";
            data += "FN:" + surname + ' ' + lastname;
            data += "\n";
        };

        var cell = function (cell) {
            data += "TEL;TYPE=CELL:" + cell;
            data += "\n";
        };

        var work = function (work) {
            data += "TEL;TYPE=WORK,VOICE:" + work;
            data += "\n";
        };

        var other = function (work) {
            data += "TEL;TYPE=OTHER:" + work;
            data += "\n";
        };

        var email = function (email) {
            data += "EMAIL;TYPE=PREF,INTERNET:" + email;
            data += "\n";
        };

        var get = function () {
            return start + '\n' + data + end;
        };

        return {
            init:init,
            name:name,
            cell:cell,
            work:work,
            other:other,
            email:email,
            get:get
        }
    });

` I will bookmark your extension. In the future, i will use it.

Thanks.