Javascript client sharepoint object model -- ECMA

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
function checkForEnter(event) {
        if (event.keyCode == 13) { //按下回车
            var videocomments = $("#newcomments").val();
            if (videocomments != ‘‘) {
                $("#divToDisplay").show("slow");
                $("#divToDisplay").html(‘‘);
                var addnewcomment;
                getWebUserData();
                var videotitle = $("input[id$=txtVideoTitle]").val();
                var KvideoId = $("input[id$=txtVideoid]").val();
                var taskList = web.get_lists().getByTitle(‘Cosmo Video Comments‘);
                context.load(taskList);
                var CommentItemInfo = new SP.ListItemCreationInformation();
                var query = new SP.CamlQuery();
                var queryxml = "<View><Query><Where><Eq><FieldRef Name=‘MediaID‘ /><Value Type=‘Text‘>" + KvideoId + "</Value></Eq></Where></Query></View>";
                query.set_viewXml(queryxml);
                var collItem = taskList.getItems(query);
                context.load(collItem);
                context.executeQueryAsync(onQuerySucceeded, onQueryFailed);
  
                function onQuerySucceeded(sender, args) {
                    var itemCount = collItem.get_count();
                    var listEnumerator = collItem.getEnumerator();
                    if (itemCount == 0) {
  
                        var myDate = new Date();
                        var CommentItemInfo = new SP.ListItemCreationInformation();
                        addnewcomment = taskList.addItem(CommentItemInfo);
                        addnewcomment.set_item(‘Title‘, videotitle);
                        addnewcomment.set_item(‘MediaID‘, KvideoId);
                        var month = myDate.getMonth() + 1;
                        com = videocomments + "\n\r\n" + username + "\n\r\n" + month + ‘/‘ + myDate.getDate() + ‘/‘ + myDate.getFullYear() + ‘\r\n\r‘;
                        addnewcomment.set_item(‘Comments‘, com);
                        $("#newcomments").val(‘‘);
                        addnewcomment.update();
                        context.load(addnewcomment);
                        context.executeQueryAsync(addTaskSuccess, addTaskFailure);
                        function addTaskSuccess(sender, args) {
                            GetListData();
                        }
                        function addTaskFailure(sender, args) {
                            alert(‘Failed to add new task. \nError: ‘ + args.get_message() + ‘\nStackTrace: ‘ + args.get_stackTrace());
                        }
                    }
                    else {
                        var myDate = new Date();
                        var month = myDate.getMonth() + 1;
                        while (listEnumerator.moveNext()) {
                            var oListItem = listEnumerator.get_current();
                            var com = oListItem.get_item(‘Comments‘).toString();
                            com = com + videocomments + "\n\r\n" + username + "\n\r\n" + month + ‘/‘ + myDate.getDate() + ‘/‘ + myDate.getFullYear() + ‘\r\n\r‘;
                            oListItem.set_item(‘Comments‘, com);
                            $("#newcomments").val(‘‘);
                            oListItem.update();
                            context.load(oListItem);
                            context.executeQueryAsync(updateTaskSuccess, updateTaskFailure);
                            function updateTaskSuccess(sender, args) {
                                GetListData();
                            }
                            function updateTaskFailure(sender, args) {
                                alert(‘Failed to update task. \nError: ‘ + args.get_message() + ‘\nStackTrace: ‘ + args.get_stackTrace());
                            }
                        }
                    }
  
                }
                function onQueryFailed(sender, args) {
                    alert(‘Request failed‘ + args.get_message() + ‘\n‘ + arg.get_stackTrace());
                }
            }
            else {
                alert(‘Please enter comments‘);
            }
            return false;
        }
    }

  

Javascript client sharepoint object model -- ECMA,布布扣,bubuko.com

Javascript client sharepoint object model -- ECMA

上一篇:java package and import


下一篇:C#调用dll(C++(Win32))时的类型转换总结(转)