Friday, August 1, 2014

sharepoint 2013 Create Custom List in javascript (CSOM)

var clientContext;
var listCreationInfo;
var web;
var list;


clientContext = SP.ClientContext.get_current();
    web = clientContext.get_web();
    listCreationInfo = new SP.ListCreationInformation();
    listCreationInfo.set_title("Use");
    listCreationInfo.set_templateType(SP.ListTemplateType.genericList);
    list = web.get_lists().add(listCreationInfo);

    clientContext.load(list);

    clientContext.executeQueryAsync(
 function () { alert("Success!") },
 function () { alert("Request failed") }
);

Application Architecture Diagram Sample 3


Wednesday, July 30, 2014

jQuery Zebra Stripes


<html>
<head>
<title>jQuery Zebra Stripes</title>
</head>
<script src="http://www.mkyong.com/wp-content/uploads/jQuery/jquery-1.3.2.min.js" type="text/javascript"></script>

 <script type="text/javascript">
      $(function() {
        $("table tr:nth-child(even)").addClass("striped");
      });
    </script>

    <style type="text/css">
      body,td {
        font-size: 10pt;
      }
      table {
        background-color: black;
        border: 1px black solid;
        border-collapse: collapse;
      }
      th {
        border: 1px outset silver;
        background-color: maroon;
        color: white;
      }
      tr {
        background-color: white;
        margin: 1px;
      }
      tr.striped {
        background-color: coral;
      }
      td {
        padding: 1px 8px;
      }
    </style>


<body>
    <table>
<tr>
        <th>ID</th>
        <th>Fruit</th>
        <th>Price</th>
      </tr>
<tr>
        <td>1</td>
        <td>Apple</td>
        <td>0.60</td>
      </tr>
<tr>
        <td>2</td>
        <td>Orange</td>
        <td>0.50</td>
      </tr>
<tr>
        <td>3</td>
        <td>Banana</td>
        <td>0.10</td>
      </tr>
<tr>
        <td>4</td>
        <td>strawberry</td>
        <td>0.05</td>
      </tr>
<tr>
        <td>5</td>
        <td>carrot</td>
        <td>0.10</td>
      </tr>
</table>
</body>
</html></div>

jQuery Zebra Stripes
ID Fruit Price
1 Apple 0.60
2 Orange 0.50
3 Banana 0.10
4 strawberry 0.05
5 carrot 0.10

SEPARATE JAVASCRIPT FUNCTIONALITY into a “behavioural layer,”

Never include Javascript events as inline attributes. This practice should be completely wiped from your mind.
<a onclick="doSomething()" href="#">Click!</a>
All Javascript behaviours should be included in external script files and linked to the document with a <script> tag in the head of the page. So, the anchor tag would appear like this:
<a href="backuplink.html" class="doSomething">Click!</a>
And the Javascript inside the myscript.js file would contain something like this:
$('a.doSomething').click(function(){
 // Do something here!
 alert('You did something, woo hoo!');
});

Monday, July 28, 2014

Test if Internet Explorer is used and get its version number

// use the class
if(Browser.Version() <8) {
 // make crazy IE shit
}

var Browser = {
    Version: function(){
        var version = 999; // we assume a sane browser
        if (navigator.appVersion.indexOf("MSIE") != -1)
            // bah, IE again, lets downgrade version number
            version = parseFloat(navigator.appVersion.split("MSIE")[1]);
        return version;
    }
}