Basic bookmarklet help - bookmarklet

I want to create a bookmarklet that sets the page to be editable, that is, to run this code:
javascript:document.body.contentEditable=true;
When I made a bookmark of that, I could see that the page becomes editable very briefly and then the whole thing is replaced with the word "true".

Bookmarklets have to evaluate to void for the browser stay on the same page. Just end it with a void(0):
javascript:document.body.contentEditable=true;void(0);

After a bit of random trial and error, I found that this worked:
javascript:(function() { document.body.contentEditable=true; })()
Are there any other ways?

Some sites suggest that you use document.designMode=’on’, but that doesn't work for me.
Regardless, your revised scripts works fine.

Related

MVC3 How to implement result browser like twitter/facebook do it (without paging)

I'm looking for leads on how to implement a (search-)result browser without using paging. But more like how twitter/facebook do it.
At first only 10 or so results need to be displayed but when scrolling down, more results (if any) should be added asynchronously. I've found examples with a [more] button at the end but I would like the browser to automatically fetch more when the bottom of the pane is reached.
I'm having trouble finding the right examples. Probably because I don't know what keywords to google on...
Hope you can help me out in the right direction!
Kind regards,
Paul
I advise you read following article regarding this subject:
Infinite Scroll in ASP.NET MVC
There is also a sample application available here.
Refer to the Replace paging with jQuery and subsonic continuous scrolling method blog post.
Have a look at the following pages:
On Scroll down how to make ajax call and get the respone data
create-a-dynamic-scrolling-content-box-using-ajax
I believe that should help you!

Building an add-on to hide a <div> block on an HTML page

There's a webpage with something annoying on it which I'd like to hide every time I visit it. I thought a good way to do this would be to make an add-on for Firefox.
I've never done this before, and came across the web-based Firefox add-on builder. I'm not too sure where to go from here though. I know it should be quite easy to do this though. I suppose all I need to do is check if a block with a certain id is used on a website, and if it is, then delete/hide it from my view.
Is that the best way to do about this? If not, what do you suggest? If so, can you give me any tips to help me accomplish this?
Right, I got it:
Using just a standalone Firefox Add-On use the following code:
exports.main = function() {
var pageMod = require("page-mod");
pageMod.PageMod({
include: "*.ca",
contentScriptWhen: 'end',
contentScript: 'document.getElementById("DIVID").style.visibility="hidden";'
});
};
Just replace DIVID with whatever you want.
Similarly, in Greasemonkey, just add this to the script:
document.getElementById('DIVID').style.visibility='hidden';
The only reason I didn't want to use Greasemonkey is that it isn't as easy to share. But it's convenience can't be beat!
Install the latest FF
Install the latest AdBlock Plus
Go to the website right click on specific element and then Inspect Element(Q)
Right bottom corner there is Hide with ABP(AdBlock Plus) button, click on it, then Add Element Hiding Rule
You can just use GreaseMonkey which is a very useful plugin for firefox. You can write your own script in JavaScript which operates on the page.
However, chances are that someone might have already written a script for the site in question that you can install from the http://userscripts.org/ repository.
In well-formed HTML, any particular value for the id attribute should occur at most once in a document. If your mission is to seek and destroy a recurring phenomenon, it might be labeled (if at all) with a class. This is the case with Twitter's "promoted tweets", for example.
var promotedTweets = document.getElementsByClassName("promoted-tweet");
for (k=0; k<promotedTweets.length; k++) {
promotedTweets[k].parentNode.removeChild(promotedTweets[k]);
}
Wouldn't Adblock Plus do the trick here? You can feed it an element hiding rule (based on the class or ID attribute) on any given website, if I recall correctly.
I used the up-and-coming jpm tool to write this, and incorporated the suggestions here. It is specifically for filtering certain div tags here on StackOverflow—how fitting. The code and the xpi add-on file is at Github.
An alternative in Firefox is to create a userContent.css file and add css which hides the div.
See https://superuser.com/a/319322/ and note the comment which points out that "Starting with Firefox 69, you need to set the toolkit.legacyUserProfileCustomizations.stylesheets preference to true".

CEWP to show images (HTML) works until I use grouping. Then I see the DIV tag

I'm fairly new to Share Point so forgive me if this is to easy for you guys, but I could not seem to find the answer anywhere and I am rather stumped.
I am currently trying to make a website to track if particular tasks go over their due date. I have a calculated column that leaves a DIV tag to the image of a red/yellow/green circle which is displayed by the javascript for a Content Editor Web Part (CEWP) made by Christophe on his site here:
http://blog.pathtosharepoint.com/2008/09/01/using-calculated-columns-to-write-html/
I was able to put his code into the CEWP and everything looks great when it is in a standard list.
But I want a web part version of this on the homepage for easy view. When I make the web part (of a view grouping by the image tag) and place on the main site all I see is the DIV tag! I made sure to put an identical CEWP on the homepage as well but i get as grouping:
+[columnName] : DIV>img title=blahblahblah>/DIV> (2)
Needles to say when I expand this it stays the same for all entries below
Any Ideas?
Thanks for your time :D
Nobody has responded, but I found the answer so hopefully this will save someone the hours of grief I had. This will seem ridiculous but just go with it.
In the calculated column instead of returning the type as text, return it as a currency. Sounds ridiculous BUT IT WORKS!!

How to put space in tab title in dojo?

i am using dojo toolkit with php codeigniter 2.1.0 and i want to put space in tab name wherever necessary.
Anyone has any solution??
My code is :
<div id="setupParty" data-dojo-type="dijit.MenuItem"
onclick="addPartyTab('AddParty');">Manage <u>P</u>arty</div
If i will directly write as :
<div id="setupParty" data-dojo-type="dijit.MenuItem"
onclick="addPartyTab('Add Party');">Manage <u>P</u>arty</div
then it throws error
I want my tab to be displayed with name as "Add Party"
can anyone suggest me solution for this???
Thanx in advance
What error does it throw?
how does the code in addPartyTab look like?
The following should work in any case:
onclick="addPartyTab('Add Party');">
However, this may not be an ideal solution. You need to look into your addPartyTab function to first, ensure the text with embedded space is coming through fine (and i dont see any reason why it shouldnt) and then examine the code in that function to ensure it is being processed correctly - i suspect somewhere in there you will find why it is breaking.
In general, you can set title on a dijit tab (which is typically a contentpane) directly even if the title contains spaces without any issue. Following is a typical way of doing it:
dijit.byId("myTabContentPane").set("title", "Add Party - Hurray!");
where myTabContentPane is the id of the contentpane that makes up that tab

Asp.Net MVC 3 - #Html.Action won't render/return any HTML

I've been moving a fairly new project from ViewPages to Razor today, and all seems to be going well. Except I'm trying to use Html.Action to render a user control and it won't render anything.
So I have a Shared/_Layout.cshtml file which is referenced in Home/Index.cshtml
Index.cshtml has the following:
<article>
#Html.Action("LatestBlogsMainPanelWidget", "Blogs")
...
</article>
I've put traps in the BlogsController, so I know that's being requested. I also know that a model is being returned, that the LatestBlogsMainPanelWidget is being found by the view engine, and even some dummy Razor syntax code is being run:
#{
var s = "hello";
}
but the plain html in this file isn't making it to the browser. I've tried other (previously working) partials too and they won't appear either (view source on the page confirms it's not there).
I've also tried substituting for
#{ Html.RenderAction(...); } without success. HTML either side of the #Html.Action is appearing, so I know Index.cshtml is displaying properly.
Even more strangely the _Layout file also has Html.Action commands and they do appear fine.
I'm really not sure what else to check, or how to confirm that the pipeline is getting the HTML. Can anyone help at all?
Thanks!
Put a Layout = null on the partial view and it will work fine.
Try this:
#{Html.RenderAction("LatestBlogsMainPanelWidget", "Blogs");}
The brain is a funny thing, and despite spending several hours on this yesterday, it took my dog waking me up in the middle of the night for a wee for my subconscious to stumble upon the answer.
If this had anyone else stumped, I'm not surprised. I hadn't mentioned because it hadn't dawned on me that I was using a partial-level caching system similar to one designed by Steve Sanderson. It suddenly struck me that this could be the cause, since to the best of my knowledge Razor pages go through far less pipeline processing than WebForm pages. The caching filter is probably not doing what it needs to do, or at the right time.
I've confirmed that commenting out the OutputCache filter on the Actions in question has fixed the problem.
I've no idea if this issue is true of the page-level caching as it's not something I find useful.
While searching solutions for this issue, I have find out three measure issues for not proper rendering of Html.Action and Html.RenderAction. Please verify have you done below things properly or not.
In your PartialView or View you have defined #{Layout = null;}.
Use return PartialView instead of View .
Decorate your action with [ChildActionOnly] attributes.
I hope by applying above all steps you can solve your issues.

Resources