#StackBounty: #sharepoint-online #jquery #html-form-web-part Submit item on select INSTEAD of button click in HTML Form WP Autocomplete…

Bounty: 50

Below is a script I have loaded into an HTML Form Web Part Filter. It is autopopulated with list items from a list called ‘Companies’. I want the list item to be submitted upon select INSTEAD of the users having to select the item from dropdown, and then hit the ‘submit’ button. New to development, so thanks for being patient if this is an obvious or easy fix. Thanks for your help!

  
// Settings 
var url = "https:///_vti_bin/listdata.svc/Companies()";  
var field = "Title";  

// Onload  
$(document).ready(function () {  
$("#mytags").autocomplete({  
    source: function (req, add) {  
        var suggestions = search(req.term, url, field);  
        add(suggestions);  
    }  
});  
});  



// Search all the listitems by using the REST Service  
// Value is the text that needs to be used in the query  
// listurl is the listdata.svc url withouth the filter params  
// field is the name of the field where the value in exists  
function search(value, listurl, field) {  
    var coll = new Array();  
    var url =  
        listurl + "?$filter=startswith(" + field + ",'" + value + "')";  

$.ajax({  
    cache: true,  
    type: "GET",  
    async: false,  
    dataType: "json",  
    url: url,  
    success: function (data) {  
        var results = data.d.results;  
        for (att in results) {  
            var object = results[att];  
            for (attt in object) {  
                if (attt == field) {  
                    coll.push(object[attt]);  
                    }  
                }  
            }  
        }  
    });  
    return coll  
}  
  


Get this bounty!!!

#StackBounty: #2013 #javascript #jquery #jslink #client-side-rendering Unable to write a jslink which defines a default values for my D…

Bounty: 100

I am working on a list view, where i have a choice column named TrackingStatus. Now for this choice column i defined the default value to be In Progress from the site columns settings.

But i have noticed that inside the Quick edit grid the default value for the TrackingStatus column will not be rendered (unlike inside the built-in create and edit forms).. so i tried to implement the default values using JS Link as follow:

I upload the following script inside my site collection:

(function () {
    alert("1");
    var overrideContext= {};

    overrideContext.Templates = overrideContext.Templates || {};

    overrideContext.Templates.Fields = {
        "TrackingStatus": {
            "View": function (ctx) {if(ctx.CurrentItem.your_column == "")
        return "In Progress";
}
        }
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);

})();

Then I edit my list view WebPart and I provide the following to reference the above JSlink under the WebPart Miscellaneous section.:

~sitecollection/Resources/defaultvalues.js

But the JS Link is not having any effect in respect to applying default values for my column, although when I checked the page source I can see that the defaultvalues.js is being loaded and i got the alert(1) which I intentionally added inside the JS Link.

How can I define default values for my choices columns inside the Quick Edit grid?


Get this bounty!!!

#StackBounty: #javascript #jquery #html #image How to check width and height from all images has been called by jquery?

Bounty: 50

i have a problem on jquery image, which i need validate all image has been clicked or show with jquery

here is my code, how i add new images and show the images


true_image = false;
var _URL = window.URL || window.webkitURL;
$(document).ready(function(){

    var abc = 0;
    var wrapper         = $(".images");
    var add_button      = $("#add_more");

    var x = 1;
    $(add_button).click(function(){

        x++;
            $(wrapper).append('
" class="remove_field">
'); }); $(wrapper).on("click",".remove_field", function(e){ e.preventDefault(); $(this).parent('div').remove(); x--; }); $('body').on('change', '#file_input', function() { var image ; if (this.files && this.files[0]) { image = new Image; image.onload =function() { console.log("width : "+this.width+" height: "+this.height); if(this.width
"); var reader = new FileReader(); reader.onload = imageIsLoaded; reader.readAsDataURL(this.files[0]); $(this).hide(); $("#abcd" + abc).append($("", { id: 'img', src: '', alt: 'delete' }).click(function() { $(this).parent().parent().remove(); if(($('#file_input').val()) == undefined){ $(wrapper).append('
'); } })); } } }); function imageIsLoaded(e) { $('#previewimg' + abc).attr('src', e.target.result); $('.remove_field').hide(); }; $('body').on('click', '.images_view', function() { abc += 1; var cover = false; var image_id = this.id; $('.images_view').filter(function( index ) { if($( this ).attr( "id" ) === image_id){ $(this).parent().find('#file_input').attr('name','cover'); $(this).parent().find('#cover').remove(); $(this).parent().append("Cover"); }else{ $(this).parent().find('#file_input').attr('name','file[]'); $(this).parent().find('#cover').remove(); } }) }); });

from the above code, i trying to upload multi images so i add a button, and after it was clicked a new <input id="file_input" class="images_file" type="file" name="file[]"/> will be added, than after an images has been selected it could show the images. i want trying to validate the file is an image file, width and height on the image

my problem are, if i selected the false image (not in criteria) the button will be disabled but if in the next select, i choose the true image the button back to normal. I know this will happen because i don’t check the old images that has been selected before, and that is my problem i don’t know how to check it.

guys can you help me how to solve the problem?


Get this bounty!!!

#StackBounty: Lazy load content of slides inside carousel (content is oEmbeds/iframes)

Bounty: 100

I am loading in ajax a modal/popin with a Bootstrap carousel in which each slide is (not an image as in many question about lazy loading) but an iframe from oEmbed from various social networks (facebook, instagram, twitter, …).

The issue is that when I click the button that laods the modal, ALL the slides content get loaded, that is to say 15 to 20 oembeds(eahc of them loading content tetx, image and and javascript…).

I would like to be clever about it and only “lazy loading” slide by slide or even smarter 3 slides by 3 slides.

I am just also mentioning for the sake of information that I am using scrollMonitor and Hubspot Messenger. But i’d rather use Bootstrap slide events to trigger the apparition/load of each slide or any suggestion you would have.

I’m using ruby on rails as back end language

The url of the oEmbed programmatically change as they are inputed from a Admin Backoffice and change on each Article/page but you’ll find below an example :

Page.html

//button to click to make modal appear
<a class="btn btn-primary" onclick="loadModal()" id="socialStoryModal">
      load modal
</a>

Load Modal with Hubspot Messenger in page.js

function loadModal() {  
      var msg;
      msg = Messenger().post({
        message:  'modal.html.erb',/see below the carousel
        showCloseButton: true,
        hideAfter: false
      }); 
    }

modal.html.erb
= Modal with the carousel and the social embeds (here can be up to 50 of them)

I’ve seen tons of libraries to lazy load images and even sometimes scripts/iframes but they all need to have directly add certain classes I n the block, which is of no help for me as I use oembed above and I have nowhere to put these lazy classes.

I need to make it work with these oEmbeds iframes.


Get this bounty!!!

Fetch GET parameters in JS/jQuery

If you have a URL with some GET parameters as follows:

www.test.com/t.html?a=1&b=3&c=m2-m3-m4-m5 

and need to get the values of each parameters then below is a nifty piece of code solving your requirement.

JavaScript has nothing built in for handling query string parameters.

You could access location.search, which would give you from the ? character on to the end of the URL or the start of the fragment identifier (#foo), whichever comes first.

You can then access QueryString.c

System Design Interview Prep Material

System design is a very broad topic. Even a software engineer with many years of working experience at top IT company may not be an expert on system design. If you want to become an expert, you need to read many books, articles, and solve real large scale system design problems. This repository only teaches you to handle the system design interview with a systematic approach in a short time. You can dive into each topic if you have time. Of course, welcome to add your thoughts!

Table of Contents

System Design Interview Tips:

  • Clarify the constraints and identify the user cases Spend a few minutes questioning the interviewer and agreeing on the scope of the system. Remember to make sure you know all the requirements the interviewer didn’t tell your about in the beginning. User cases indicate the main functions of the system, and constraints list the scale of the system such as requests per second, requests types, data written per second, data read per second.
  • High-level architecture design Sketch the important components and the connections between them, but don’t go into some details. Usually, a scalable system includes web server (load balancer), service (service partition), database (master/slave database cluster plug cache).
  • Component design For each component, you need to write the specific APIs for each component. You may need to finish the detailed OOD design for a particular function. You may also need to design the database schema for the database.

Basic Knowledge about System Design:

Here are some articles about system design related topics.

Of course, if you want to dive into system related topics, here is a good collection of reading list about services-engineering, and a good collection of material about distributed systems.

Company Engineering Blogs:

If you are going to have an onsite with a company, you should read their engineering blog.

Products and Systems:

The following papers/articles/slides can help you to understand the general design idea of different real products and systems.

Hot Questions and Reference:

There are some good references for each question. The references here are slides and articles.
Design a CDN network Reference:

Design a Google document system Reference:

Design a random ID generation system Reference:

Design a key-value database Reference:

Design the Facebook news feed function Reference:

Design the Facebook timeline function Reference:

Design a function to return the top k requests during past time interval Reference:

Design an online multiplayer card game Reference:

Design a graph search function Reference:

Design a picture sharing system Reference:

Design a search engine Reference:

Design a recommendition system Reference:

Design a tinyurl system Reference:

Design a garbage collection system Reference:

Design a scalable web crawling system Reference:

Design the Facebook chat function Reference:

Design a trending topic system Reference:

Design a cache system Reference:

Good Books:

Object Oriented Design:

Tips for OOD Interview

Clarify the scenario, write out user cases Use case is a description of sequences of events that, taken together, lead to a system doing something useful. Who is going to use it and how they are going to use it. The system may be very simple or very complicated. Special system requirements such as multi-threading, read or write oriented.
Define objects Map identity to class: one scenario for one class, each core object in this scenario for one class. Consider the relationships among classes: certain class must have unique instance, one object has many other objects (composition), one object is another object (inheritance). Identify attributes for each class: change noun to variable and action to methods. Use design patterns such that it can be reused in multiple applications.

Useful Websites

Original Source

jSoup: Java HTML Parser

jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods.

jsoup implements the WHATWG HTML5 specification, and parses HTML to the same DOM as modern browsers do.

  • scrape and parse HTML from a URL, file, or string
  • find and extract data, using DOM traversal or CSS selectors
  • manipulate the HTML elements, attributes, and text
  • clean user-submitted content against a safe white-list, to prevent XSS attacks
  • output tidy HTML

jsoup is designed to deal with all varieties of HTML found in the wild; from pristine and validating, to invalid tag-soup; jsoup will create a sensible parse tree.

Example

Fetch the Wikipedia homepage, parse it to a DOM, and select the headlines from theIn the news section into a list of Elements (online sample):

Document doc = Jsoup.connect("http://en.wikipedia.org/").get();
Elements newsHeadlines = doc.select("#mp-itn b a");

Open source

jsoup is an open source project distributed under the liberal MIT license. The source code is available at GitHub.

Getting started

  1. Download the jsoup jar (version 1.8.3)
  2. Read the cookbook introduction
  3. Enjoy!

Resources

Color Thief

A script for grabbing the color palette from an image.
Uses JavaScript and the canvas tag to make it happen.

How to use

Get the dominant color from an image

var colorThief = new ColorThief();
colorThief.getColor(sourceImage);
getColor(sourceImage[, quality])
returns {r: num, g: num, b: num}

Build a color palette from an image

In this example, we build an 8 color palette.

var colorThief = new ColorThief();
colorThief.getPalette(sourceImage, 8);
getPalette(sourceImage[, colorCount, quality])
returns [ [num, num, num], [num, num, num], ... ]

Demo More from Original Author

JQuery not working in wordpress

Since WordPress version 2.x, jQuery is a build-in JavaScript library, explicitly include the jQuery library into WordPress is not necessary.

$(document).ready(function(){
  alert('test');
});

the above code will be giving an error in the console of your code:

$ is undefined

In WordPress, the $() syntax is always used by other scripting library, and causing the conflict issue and fail to call the jQuery function. You should use jQuery() instead…

jQuery(document).ready(function(){
  alert('test');
});

Alternatively, you can use noConflict()

$j=jQuery.noConflict();

// Use jQuery via $j(...)
$j(document).ready(function(){
  alert('test');
});

P.S jQuery.noConflict();http://wordpress.org/support/topic/141394

Never use jQuery handy function $() in WordPress plugin. You have to use jQuery() or jQuery.noConflict() to work between jQuery and WordPress.

Source