Eck Reading List

SP Snippets

Project: 

SharePoint

Read Status: 

Active Reference

CDN:

<script type="text/javascript"
   src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</script>

 

/* --------------------------------  Redirect old page to new page  ----------------------- */

<style type="text/css">
.redirect {padding:100px 300px;font-weight:900;text-align:center;}
</style>
<script type="text/javascript">
// Redirect old page to new page
var URL="http://collaboration-vcds.forces.mil.ca/sites/CDA/COS/Lists/CDA_CCIR_Tra...",timer=0,current="none",popup="",msg="",img="";
if (popup) alert(popup);
var d=new Date(),a=document.getElementById("aspnetForm"),b=document.getElementsByTagName("body")[0],c=document.createElement("div"),i=document.createElement("img"),t=document.createElement("div");
a.style.display=current;c.className="redirect";i.src=img;c.appendChild(i);c.appendChild(t);b.insertBefore(c,a);
function wait(){var tleft=Math.round(timer-(new Date())/1000+d/1000);if (tleft>0) {t.innerHTML="<p>"+msg+"</p><p>Wait for "+tleft+" second(s) or <a href='"+URL+"'>click here</a> to be redirected.</p>";setTimeout("wait()",1000);}else {t.innerHTML="<p>Redirecting</p>";window.location.href=URL;}}
wait();
</script>

/*--------  Fool SP2010 into thinking it's running IE10 (or use a respond.JS that pretty well does it too ) -------------*/

   <!-- Drop me in a CEWP for Bootstrap JS -->
  <!-- When testing a CDN load be very careful with versioning! -->
  <script src="/sites/CDA_Sandbox/SiteAssets/js/jquery-1.12.3.min.js" type="text/javascript"></script>

  <script type="text/javascript">
 if($('meta[http-equiv=X-UA-Compatible]', top.document).attr('content')!='IE=10')
 {
  // alert('adjusting IE compatibility');
  $('meta[http-equiv="X-UA-Compatible"]', top.document).attr('content', 'IE=10');
  $('meta[http-equiv="X-UA-Compatible"]').attr('content', 'IE=10');
  $('#FRAMEID',window.parent.document).attr('src',$('#FRAMEID',window.parent.document).attr('src'));
 }
 </script>

 /* --------------------------------  Check Mandatory ----------------------- */

    <!-- Script to check mandatory fields on related documents for Governance Meetings
         Add to CEWP as /sites/CDA/Style%20Library/checkMandatoryFieldsMeetingDocs.txt -->

     <!-- There was a permission issue with this script. Regular users failed at
          var value2 = $("select[title='GMC'] option:selected").text();

          Change Permissions:
          NT AUTHORITY\authenticated users      Domain Group   Contribute (-)
     -->

<script src="/sites/CDA/Style%20Library/jquery-1.12.3.min.js" type="text/javascript"></script>



<script type="text/javascript">
    $(document).ready(function () {
       // var value = $("select[title='AgendaItem'] option:selected").text();
        // alert(value);
        var value2 = $("select[title='GMC'] option:selected").text();
        // alert(value2);
    });
</script>

<script type="text/javascript">
// SPFunction
function PreSaveAction()
{
//    debugger;
// alert('Inside');
 //  var value = $("select[title='AgendaItem'] option:selected").text();
   var value2 = $("select[title='GMC'] option:selected").text();
   // alert("Agenda item " + value);
  //  alert("GMC " + value2);
 //  if(value == "(None)" && value2 == "(None)")
  if(value2 == "(None)")
   {
      alert("You did not select a 'GMC' meeting to associate this document to.");
      var r=confirm("Are you sure to you want to Save an orphaned document?");
      if (r==false)
          {
         //  var statusfocus = $(":input[title='AgendaItem']");
         //  statusfocus .focus();
           var statusfocus2 = $(":input[title='GMC']");
           statusfocus2 .focus();
           return false;
          }
    else
    {
    // alert('Return true1');
    //   return true;
        }
   }
  // alert('Return true2');
   return true;
}
</script>
/*----------------------------------Replace word on form -------------------------------*/

<script type="text/javascript"
   src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</script>
<script type="text/javascript">
  $(window).load(function () {
    $('#idHomePageNewAnnouncement').each(function() {
        var text = $(this).text();
        $(this).text(text.replace('Add new announcement', 'Add new agenda item'));
    });
       });
</script>

/* --------------------------------  Hide pesky fields using SPUtility ----------------------- */

    <!-- Include this file in a Content Editor Web Part on Dispay and Edit forms. -->
    <!-- ADD TO: DispForm.aspx for the List CDA CCIR Tracker -->
    <!-- ADD TO: EditForm.aspx for the List CDA CCIR Tracker -->
    <!-- /sites/CDA/Style%20Library/CCIR-Tracker-hide-fields.txt -->


        <script src="/sites/CDA/Style%20Library/jquery-1.12.3.min.js" type="text/javascript"></script>
        <script src="/sites/CDA/Style%20Library/sputility.js" type="text/javascript"></script>
        <script>
        $(window).load(function () {

       // alert('GCalendar DispForm.aspx and EditForm.aspx hide fields AND ???');
        SPUtility.GetSPField('Run Workflow').Hide();

       });
    </script>

 /* -------------------------------- Display ID on Disp and Edit forms ----------------------- */

 <!-- To provide display ID on Disp and Edit forms Include this file in a Form Web Parts ie Default Display Form.
     and yes use the .txt extension. -->
<!-- /sites/CDA/Style%20Library/DisplayID.txt -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">

$(function() {
    // Get the ID from the query string
    var id = getQueryString()["ID"];

    // Find the form's main table
    var table = $('table.ms-formtable');

    // Add a row with the ID in
    table.prepend("<tr><td class='ms-formlabel'><h3 class='ms-standardheader'>ID</h3></td>" +
                "<td class='ms-formbody'>" + id + "&nbsp;</td></tr>");
    })

function getQueryString() {
    var assoc = new Array();
    var queryString = unescape(location.search.substring(1));
    var keyValues = queryString.split('&');
    for (var i in keyValues) {
    var key = keyValues[i].split('=');
    assoc[key[0]] = key[1];
    }
    return assoc;
}
</script>

 /* -------------------------------- Prepopulated form with assigned text ----------------------- */

     <!-- Add to CEWP as /sites/CDA/Style%20Library/prepopulate.txt -->
    <script src="/sites/CDA/Style%20Library/jquery-1.12.3.min.js" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function () {

            // where ta refers to TextArea
            jah = ' a. What: <br /> b. Where: <br /> c. When: <br /> d. Who: <br /> e. Why: <br /> f. Action Taken: <br /> g. Misc: <br /> h. Lead Agency: <br /> i. Was media informed? <br />';
            var ta = document.getElementById('ctl00_m_g_629ea4bb_2e7b_4222_821a_42c78860720f_ctl00_ctl05_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_TextField');
            ta.value = jah;

           // For example if you want to do something with the editform
           $(ta).val($(ta).val()+'j. Was PAO notified?');


    });
</script>

 /* -------------------------------------  FILTER Search ------------------------------- */

<!--
    ****************** DEPENDENT LIBRARIES ***************************
    - jQuery is the JavaScript library that reduces the amount of code needed.
-->

<script type="text/javascript"
   src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</script>
<!-- Add to CEWP as:
  /sites/CDA/Style%20Library/FilterSearch.txt
-->

<!--
    ****************** SCRIPT CONTENT ********************************
-->

<script type="text/javascript">

    //Define a function to assist in filtering.
    jQuery.expr[':'].Contains = function(a,i,m){
        return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
    };

    //This is the webpart for the list or library. Uncomment and add extra webParts when needed.
    var webPartID2 = "WebPartWPQ2";
    var webPartID3 = "WebPartWPQ3";
    var webPartID4 = "WebPartWPQ4";
    var webPartID5 = "WebPartWPQ5";
    var webPartID6 = "WebPartWPQ6";
    var webPartID7 = "WebPartWPQ7";
    var webPartID8 = "WebPartWPQ8";
    var webPartID9 = "WebPartWPQ9";


    $(document).ready(function(){
        //This section enables the instant search filter - note that you need to
        // have a textbox with the id below for this to work.  In this case, our
        // id is "instant".
        //
        //The keyup() function fires whenever the user releases a key (so, when they type).
        $("#instant").keyup(function() {
                  var txt = $("#instant").val();

            if (txt) {
                     $("#"+webPartID2).find("tr.ms-itmhover:not(:Contains("+txt+"))").hide();
                    $("#"+webPartID2).find("tr.ms-itmhover:Contains("+txt+")").show();
                $("#"+webPartID3).find("tr.ms-itmhover:not(:Contains("+txt+"))").hide();
                    $("#"+webPartID3).find("tr.ms-itmhover:Contains("+txt+")").show();
                        $("#"+webPartID4).find("tr.ms-itmhover:not(:Contains("+txt+"))").hide();
                    $("#"+webPartID4).find("tr.ms-itmhover:Contains("+txt+")").show();
                $("#"+webPartID5).find("tr.ms-itmhover:not(:Contains("+txt+"))").hide();
                    $("#"+webPartID5).find("tr.ms-itmhover:Contains("+txt+")").show();
                $("#"+webPartID6).find("tr.ms-itmhover:not(:Contains("+txt+"))").hide();
                    $("#"+webPartID6).find("tr.ms-itmhover:Contains("+txt+")").show();
                        $("#"+webPartID7).find("tr.ms-itmhover:not(:Contains("+txt+"))").hide();
                    $("#"+webPartID7).find("tr.ms-itmhover:Contains("+txt+")").show();
                $("#"+webPartID8).find("tr.ms-itmhover:not(:Contains("+txt+"))").hide();
                    $("#"+webPartID8).find("tr.ms-itmhover:Contains("+txt+")").show();
                        $("#"+webPartID9).find("tr.ms-itmhover:not(:Contains("+txt+"))").hide();
                    $("#"+webPartID9).find("tr.ms-itmhover:Contains("+txt+")").show();
                } else {
                     $("#"+webPartID2).find("tr.ms-itmhover").show();
                    $("#"+webPartID3).find("tr.ms-itmhover").show();
                    $("#"+webPartID4).find("tr.ms-itmhover").show();
                $("#"+webPartID5).find("tr.ms-itmhover").show();
                    $("#"+webPartID6).find("tr.ms-itmhover").show();
                $("#"+webPartID7).find("tr.ms-itmhover").show();
                $("#"+webPartID8).find("tr.ms-itmhover").show();
                $("#"+webPartID9).find("tr.ms-itmhover").show();

                }
        });
          });

</script>


<!--
    ****************** HTML CONTENT ***********************************
-->

<div id='intro'>
    <h3>Filter visible results:</h3>
</div>

<div>
    Filter: <input type="text" id="instant" name="filename" placeholder="Type here to filter..." size="40">
</div>