SHARE
TWEET

Untitled

a guest Jan 11th, 2017 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Alert List */
  2. function retrieve_alerts() {
  3.     var client_context = new SP.ClientContext.get_current();
  4.     var current_list = client_context.get_site().get_rootWeb().get_lists().getByTitle("Alerts");
  5.     var caml_query = new SP.CamlQuery();
  6.     var alert_xml = "<View><Query><Where><Eq><FieldRef Name=\"DisplayStatus\" /><Value Type=\"Choice\">Yes</Value></Eq></Where><OrderBy><FieldRef Name=\"StatusLevel\" Ascending=\"False\" /></OrderBy></Query></View>";
  7.     caml_query.set_viewXml(alert_xml);
  8.     this.list_item = current_list.getItems(caml_query);
  9.     client_context.load(list_item);
  10.     client_context.executeQueryAsync(Function.createDelegate(this, this.retrieve_alerts_succeeded), Function.createDelegate(this, this.retrieve_alerts_failed));
  11. }
  12.  
  13. function retrieve_alerts_succeeded(sender, args) {
  14.     var list_item_info = "";
  15.     var list_item_enum = list_item.getEnumerator();
  16.     while (list_item_enum.moveNext()) {
  17.         var current_list_item = list_item_enum.get_current();
  18.         var ai_title = current_list_item.get_item('Title');
  19.         var ai_description = current_list_item.get_item('AlertDescription');
  20.         var ai_see_more = current_list_item.get_item('SeeMoreLink');
  21.         var ai_status_level = current_list_item.get_item('StatusLevel');
  22.         var ai_type = '';
  23.         var ai_type_class = '';
  24.         var ai_see_more_url = '';
  25.         var ai_see_more_link = '';
  26.         if (ai_see_more != null) {
  27.             ai_see_more_url = ai_see_more.get_url();
  28.             ai_see_more_link = '<br /><a href="' + ai_see_more_url + '">Read More &raquo;</a>';
  29.         } else {
  30.             ai_see_more_link = '';
  31.         }
  32.         if (ai_status_level.indexOf("INFO") > -1) {
  33.             ai_type = "Info";
  34.             ai_type_class = "alert-bgcolor-info";
  35.         } else if (ai_status_level.indexOf("WARNING") > -1) {
  36.             ai_type = "Warning";
  37.             ai_type_class = "alert-bgcolor-warning";
  38.         } else if (ai_status_level.indexOf("SEVERE") > -1) {
  39.             ai_type = "Severe";
  40.             ai_type_class = "alert-bgcolor-severe";
  41.         }
  42.         var list_item_info = '<div class="alert-wrapper">' +
  43.             '  <div class=' + ai_type_class + '>' +
  44.             '    <div class="alert-type">' +
  45.             '      <p class="alert-type-icon"><img src="/Style%20Library/VCS-Assets/imgs/banner-' + ai_type.toLowerCase() + '.png" alt="Alert Icon - ' + ai_type + '" class="alert-icon" /></p>' +
  46.             '      <p class="alert-type-text">' + ai_type.toUpperCase() + '</p>' +
  47.             '    </div>' +
  48.             '    <div class="alert-text">' +
  49.             '      <p class="alert-text-title">' + ai_title + '</p>' +
  50.             '      <p class="alert-text-description">' + ai_description + ai_see_more_link + '</p>' +
  51.             '    </div>' +
  52.             '  </div>' +
  53.             '</div>';
  54.         $("#db-body").prepend(list_item_info).fadeIn("fast");
  55.         $(".alert-wrapper").fadeIn("fast");
  56.     }
  57. }
  58.  
  59. function retrieve_alerts_failed(sender, args) {
  60.     console.log("Request failed. " + args.get_message() + "\n" + args.get_stackTrace());
  61. }
  62. ExecuteOrDelayUntilScriptLoaded(retrieve_alerts, "sp.js");
  63.  
  64. /* Footer List */
  65. function retrieve_footer() {
  66.     var client_context = new SP.ClientContext.get_current();
  67.     var footer_list = client_context.get_site().get_rootWeb().get_lists().getByTitle("footerLinks");
  68.     var caml_query = new SP.CamlQuery();
  69.     var footer_xml = "<View><Query><OrderBy><FieldRef Name=\"Title\" ascending=\"true\" /></OrderBy></Query></View>";
  70.     caml_query.set_viewXml(footer_xml);
  71.     this.footer_list_item = footer_list.getItems(caml_query);
  72.     client_context.load(footer_list_item, "Include(URL, ColumnCategory, Order1, Title, Window)");
  73.     client_context.executeQueryAsync(Function.createDelegate(this, this.retrieve_footer_succeeded), Function.createDelegate(this, this.retrieve_footer_failed));
  74. }
  75.  
  76. function retrieve_footer_succeeded(sender, args) {
  77.     var footer_links_enum = this.footer_list_item.getEnumerator();
  78.     while (footer_links_enum.moveNext()) {
  79.         var footer_links_item = footer_links_enum.get_current();
  80.         var column_category = footer_links_item.get_item("ColumnCategory");
  81.         var link = footer_links_item.get_item("URL");
  82.         var link_url = link.get_url();
  83.         var link_title = footer_links_item.get_item("Title");
  84.         var new_window = footer_links_item.get_item("Window");
  85.         var target = "";
  86.         if (new_window == true) {
  87.             target = '" target="_blank">';
  88.         } else {
  89.             target = '">';
  90.         }
  91.         if (column_category.indexOf("Quick Links") > -1) {
  92.             $("#footer-item-list-1").append('<li><a href="' + link_url + target + link_title + '</a></li>');
  93.         } else if (column_category.indexOf("Departments") > -1) {
  94.             $("#footer-item-list-2").append('<li><a href="' + link_url + target + link_title + '</a></li>');
  95.         } else if (column_category.indexOf("Financial Information") > -1) {
  96.             $("#footer-item-list-3").append('<li><a href="' + link_url + target + link_title + '</a></li>');
  97.         } else if (column_category.indexOf("Contact Us") > -1) {
  98.             $("#footer-item-list-4").append('<li><a href="' + link_url + target + link_title + '</a></li>');
  99.         } else if (column_category.indexOf("Copyright Text") > -1) {
  100.             $(".copyright-text").append(link_title);
  101.         }
  102.     }
  103. }
  104.  
  105. function retrieve_footer_failed(sender, args) {
  106.     console.log("Request failed. " + args.get_message() + "\n" + args.get_stackTrace());
  107. }
  108. SP.SOD.executeFunc("sp.js", "SP.ClientContext", retrieve_footer);
  109.  
  110. /* Tool Box List */
  111. if ($('#toolbox').length) {
  112.     var cN_toolbox;
  113.     //var n$_toolbox;
  114.     var toolbox_item_enum;
  115.  
  116.     function retrieve_toolbox() {
  117.         var ctx_toolbox = new SP.ClientContext.get_current();
  118.         var toolbox_list = ctx_toolbox.get_web().get_lists().getByTitle("Toolbox Links");
  119.         var caml_query_toolbox = new SP.CamlQuery();
  120.         caml_query_toolbox.set_viewXml("<View><Query><OrderBy><FieldRef Name=\"Title\" Ascending=\"TRUE\" /></OrderBy></Query></View>");
  121.         this.toolbox_items = toolbox_list.getItems(caml_query_toolbox);
  122.         ctx_toolbox.load(this.toolbox_items, "Include(Title, URL, Category, Open_x0020_in_x0020_New_x0020_Wi)");
  123.         ctx_toolbox.executeQueryAsync(Function.createDelegate(this, this.retrieve_toolbox_succeeded), Function.createDelegate(this, this.retrieve_toolbox_failed));
  124.     }
  125.  
  126.     function retrieve_toolbox_succeeded(sender, args) {
  127.         toolbox_item_enum = this.toolbox_items.getEnumerator();
  128.         while (toolbox_item_enum.moveNext()) {
  129.             var toolbox_item = toolbox_item_enum.get_current();
  130.             var toolbox_item_category = toolbox_item.get_item("Category");
  131.             var toolbox_item_title = toolbox_item.get_item("Title");
  132.             var toolbox_item_url = toolbox_item.get_item("URL").get_url();
  133.             var toolbox_item_target_blank = toolbox_item.get_item("Open_x0020_in_x0020_New_x0020_Wi");
  134.             var target = "";
  135.             if (toolbox_item_category == "Tab1") {
  136.                 if (toolbox_item_target_blank == true) {
  137.                     target = "\" target=\"_blank\">";
  138.                 } else {
  139.                     target = "\">";
  140.                 }
  141.                 $("#toolbox-item1 UL").append("<li><a href=\"" + toolbox_item_url + target + toolbox_item_title + "</a></li>");
  142.             } else if (toolbox_item_category == "Tab2") {
  143.                 if (toolbox_item_target_blank == true) {
  144.                     target = "\" target=\"_blank\">";
  145.                 } else {
  146.                     target = "\">";
  147.                 }
  148.                 $("#toolbox-item2 UL").append("<li><a href=\"" + toolbox_item_url + target + toolbox_item_title + "</a></li>");
  149.             }
  150.         }
  151.     }
  152.  
  153.     function retrieve_toolbox_failed(sender, args) {
  154.         console.log("Request failed. " + args.get_message() + "\n" + args.get_stackTrace());
  155.     }
  156.     ExecuteOrDelayUntilScriptLoaded(retrieve_toolbox, "sp.js");
  157.  
  158.     $(document).ready(function() {
  159.         $("#toolbox").tabs();
  160.     });
  161. }
RAW Paste Data
Top