SweetAlerts - 加载一次

时间:2017-01-16 22:10:33

标签: javascript cookies

我想知道是否有办法加载带有cookie的SweetAlert ONCE。我尝试了多种方法,但他们大多没有工作,因为我是新手。这是我没有cookie的代码......

-

<script>
  src="https://code.jquery.com/jquery-2.2.4.js"
  integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI="
  crossorigin="anonymous"></script>
<script src="dist/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="dist/sweetalert.css">
#test


<body>


  <script>
swal({
  title: "District Closed",
  text: "Severe snow is causing major accidents and is unsafe for our students and staff. The district is closed including schools & offices, updates will be posted here. This popup closes fifteen (15) seconds after loading the page or clicking the status button.",
  timer: 15000,
  type: "error",
  showConfirmButton: false
});
</script>

</body>

(如果您运行代码段,上面的代码将无效,因为与SweetAlerts相关的文件托管在我自己的网站上)

1 个答案:

答案 0 :(得分:0)

您可以使用窗口的本地存储属性

本地存储警报项的值为0,然后显示甜警报

var builder = require('botbuilder');
module.exports = function (session) {
    // var customMessage = new builder.Message(session)
    // .text("Hello!")
    // .textFormat("plain")
    // .textLocale("en-us");
    var card = {
        'contentType': 'application/vnd.microsoft.card.adaptive',
        'content': {
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
            "type": "AdaptiveCard",
            "version": "1.0",
            "body": [
                        {
                            "type": "ColumnSet",
                            "columns": [
                                {
                                    "type": "Column",
                                    "items": [
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Title",
                                            "wrap": true
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueName",
                                            "placeholder": "Issue Title"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Description",
                                            "wrap": true
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueDescription",
                                            "placeholder": "Issue Description",
                                            "style": "Email"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Issue Type"
                                        },
                                        {
                                            "type": "Input.ChoiceSet",
                                            "id": "issueType",
                                            "placeholder": "Placeholder text",
                                            "choices": [
                                                {
                                                    "title": "Bug",
                                                    "value": "Bug"
                                                },
                                                {
                                                    "title": "Task",
                                                    "value": "Task"
                                                },
                                                {
                                                    "title": "Improvement",
                                                    "value": "Improvement"
                                                },
                                                {
                                                    "title": "New Feature",
                                                    "value": "New Feature"
                                                }
                                            ],
                                            "style": "expanded"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Assignee"
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueAssignee",
                                            "placeholder": "Assigne Username"
                                        }
                                    ],
                                    "width": 2
                                }
                            ]
                        }
                    ],
                    "actions": [
                        {
                            "type": "Action.Submit",
                            "id": "submitBtn",
                            "title": "Submit",
                            "data":{
                                "type":"support"
                            }
                        }
                    ]
                }
    };
    var customMessage = new builder.Message(session)
            .addAttachment(card);
// console.log(session);
session.send(customMessage);
session.endDialog();
};