cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Untitled

A Pen By Captain Anonymous

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
                                          
<html>
<head>
    <title>Qismo Widget Sample</title>
    <link rel="stylesheet" type="text/css" href="https://qiscus-sdk.s3-ap-southeast-1.amazonaws.com/web/v2.5.11/qiscus-sdk.2.5.11.css">
</head>
<body>
<div id="qiscus-widget"></div>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script src="https://qiscus-sdk.s3-ap-southeast-1.amazonaws.com/web/v2.5.11/qiscus-sdk.2.5.11.js"></script>
<script>
    $(function () {
        // Required vars. Suggested to put all vars in the env vars
      
      var userID = null
      var userName = null
      var ls = JSON.parse(localStorage.getItem('data'));
      if (ls !== null) {
        userID = ls.user_id
        userName = ls.user_name
      } else {
        var randomID = null;
        var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
        for (var i = 0; i < 5; i++)
        randomID += possible.charAt(Math.floor(Math.random() * 
        possible.length));
          var randomKey = Date.now();
          var userData = {
            user_id : randomID + '@guestqiscus.com',
            user_name : 'Guest - ' + randomKey
          }
          localStorage.setItem('data', JSON.stringify(userData));
          userID = userData.user_id
          userName = userData.user_name
        }
      
        var baseURL = 'https://qismo.herokuapp.com'
            appId = 'rus-2xgngx0zigegfxyk4',
            userId = userID;

        // Initiate Qiscus User
        var initUser = $.post(`${baseURL}/api/v1/qiscus/initiate_chat`,
            {
                'app_id'  : appId,
                'user_id' : userId,
                'name'    : userName
            }
        );

        initUser.done(function (data) {
            var roomId = data.data.room_id;
            var password = data.data.sdk_user.password;
            var sdkEmail = data.data.sdk_user.email;
            QiscusSDK.core.init({
                AppId: appId,
                options: {
                    loginSuccessCallback: function (userData) {
                        QiscusSDK.core.UI.chatGroup(roomId);
                    }
                }
            });
            // live avatar from https://www.flaticon.com/free-icons/user-avatar_117234
            QiscusSDK.core.setUser(sdkEmail, password, userName, 'https://image.flaticon.com/icons/svg/145/145867.svg');
            QiscusSDK.render();
        });
    });
</script>
</body>
</html>

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console