How do Craigslist and others insert <br> when users hit the return key in their posts? - line-breaks

When I post something to Craigslist or to select other websites, I hit the return key twice to start a new paragraph. I don't need to manually insert line-break elements. Craigslist has code which recognizes the double tap of the carriage Return key as the start of a new paragraph and inserts the break elements for me. How do they do that? Would like to create a website which allows non-technical users to submit multi-paragraph entries without using a stitch of html. Have not succeeded in finding anything online. Would appreciate if someone could point me in the right direction. Thank you.

I'd imagine they'd use something like nl2br()
http://www.php.net/manual/en/function.nl2br.php

Related

Customer Cheating Paypal API deleting table items. (CFML)

I just had a customer go through some extensive steps in order to delete items prior to submitting the html form to try and avoid/delete line items that pertain to shipping. What they did was in the inspection part of chrome the opened the table and deleted the line items so when it transferred to Paypal they did not show up.
My question is how do I go about preventing this, I know they spent some time trying to figure it out.
The site is written mostly in CFML as I have a pretty good understanding from a previous job of mine, but I am having issues and want to prevent this from happening in the future.
Thanks for the help

Input list of items from user

I have a website with a form where users can type a free text in a textarea. I allow them to use Markdown but most of them don't use it and they usually publish crappy content, even after seeing a preview of the end result :-(
Given that most users enumerate things (job requirements) in that textarea I'm thinking that it would be great if I could somehow "force" them to create a list of items. Also, I think it would be valuable to provide them with some visual feedback while they are typing. For example, displaying some bullet points close to each item of the list they are creating and creating a new bullet point when they hit enter.
So basically, I would like to transform a textarea in a WYSIWYG editor that only allows users to create a list of items.
Any ideas?
Take your pick:
https://github.com/cheeaun/mooeditable/wiki/Alternative-Javascript-WYSIWYG-editors
These can all be configured to only allow for bullets.
Your answer lies here:
As soon as a user focuses the textarea field, a bullet will appear. With every Enter key, a new bullet will show.
Also, a user can delete the bullet if not required and continue with normal text.
http://jsfiddle.net/abhiagrawal87/m39xt
Sample snippet:
$(".todolist").focus(function() {
if(document.getElementById('todolist').value === ''){
document.getElementById('todolist').value +='• ';
}
});

How to create a custom view of a SharePoint list item for printing

I have been searching the internet all day for something I think is pretty simple. I found one solution here that would work for me but there are a couple of problems.
It seems that solution only works for items that were created in the list before the CEWP was added. Otherwise it will just show the form but none of the data that was entered for a new item. I think this has to do with the calculated field but I am honestly too new to SharePoint to know for sure.
The other thing that is not ideal with this solution is, it still prints the header of the site. My internet explorer is also printing only on the first page and the second page is blank. Works fine in chrome so that isn't a big deal at the moment, as it could be something with my computer itself causing that.
I have seen many people looking for a solution online to print the form and the current list item data but always hit a dead end. I would love for there to be a print button in the ribbon but at this point I would totally settle for just a blank page with the form populated with the list data from a single item on my list. Any help would be greatly appreciated as I am at the end of my rope with this. Thanks!
Basically you need to write a special CSS file for PRINT alone where you will be hiding all the unwanted ELEMENTS.
<LINK REL="stylesheet" TYPE="text/css" MEDIA="print" HREF="foo.css">
Inside this foo.css, you can write classes to hide required stuff. Like below you can hide the RIBBON by saying
#RibbonContainer
{
display:none;
}
Left Navigation :
#s4-leftpanel
{
display:none;
}

how to make next/previous buttons to toggle between gql query results

Say I have a website that has 100 products. Then this is filtered down to 5 sections containing 20 products each. If you were in one of the sections that contained 20 products (e.g. toys), what would be the optimal method to display only 5 toys per page. At the bottom of the list would be next/previous buttons to show the next/previous set of 5 toys.
A better analogy would be google search. There are millions of results but only ~10 are shown at a given time.
So right now I'm using google app engine (python) and django templates. One way I thought of to remedy this problem would be making all the query results go into a div which could then be modified through javascript to give a similar effect. However, if someone were to click their browser's back button, they wouldn't go where they originally came from.
Thanks in advance. Any help would be useful...I don't know what this technique is called so google hasn't been really useful :(
Edit: based on responses, I found my question was solved here: How to use cursor() for pagination?
Look into query cursors. Thay are made to be serialized and sent to client, to be used in creating "next" and "previous" paging requests.
NOTE: don't use offset on queries. This can be VERY expensive, as it actually fetches (and charges) all entities up to offset+limit position, but returns to application only limit results.
I'm not sure that putting all the results as hidden content in the HTML and manipulating it using JS is a very good idea if you might have a large result set (think about what happened if Google used this approach). There's also the back functionality issue that you've mentioned.
So, as for querying a wanted "results page" each time, I think the Google's GQL Reference might help you, take a look specifically at the LIMIT clause, it can help you create the paging mechanism you're looking for by supplying it with the number of items-per-page you want as "count" and the numbers of items-previously-viewed as "offset" (0 at first call).
As for displaying, I think that the Google Images / Facebook News Feed approach might also be interesting to think about (loading on scroll instead of paging), but that's a matter of your personal choice :)
Hope this helps, good luck!
EDIT: After reading Peter's answer, I found it much more efficient to use cursors for pagination, a good reference is given in his answer.

Multiple like buttons on blog page acting as one button despite separate anchor names

I have added facebook like buttons to each entry on my blog - although I have given each entry it's own URL by including an anchor name, clicking Like on one adds to the like count of all of them. Any advice on how to sort this?
An example of the code is:
Well my initial guess is that Facebook ignores the anchor. You could try passing a parameter, e.g.
www.example.com/myblog.html?entry=1#entry1
www.example.com/myblog.html?entry=2#entry2
Good luck