Inserting Scribd & Issuu Docs
Posted December 6th 2011, 3:39pm
This is an example where you can use a customised BBCode to get almost anything not available by default in FM
With this code you can be able to embed documents of largest streaming document libraries namely Scribd & Issuu. While this tutorials is a must have for teacher/students like us you can also embed fashion magz/Pc magz & what not write in your posts WITHOUT enabling HTML for users.

Limitation: Customised BBcode like in the following example if occur twice in one post willnt work :(

demo1: http://engineering.forumotion.info/t20p ... -tester#62
demo2: http://engineering.forumotion.info/t20p ... -tester#66
test: http://jsfiddle.net/defencedog/4hRh2/
here is the code with explanation:

//FM Issu/Scribd docs FINAL
var source='Distribution/Editing of this code is allowed but the source(s) must be mentioned. http://www.diondesigns.org & http://lgforum.forumotion.co.uk ';
$('.postbody div').each(function() {
var divs = $(this);
for (var d = 0; d < divs.length; ++d) {
var div = divs[d];
var hasDocS = div.innerHTML.split("[doc]");
var hasDocI = div.innerHTML.split("[docis]");
if (hasDocI.length == 3) {
// so that should give us three "chunks" in the array:
// [0]: anything before the first [doc] var IcontA
// [1]: stuff between the [doc] and [doc]
// [2]: anything after the last [doc] var IcontB
// yes, it's possible for both 0 and 2 to contain blank strings...that's okay
var urlI = hasDocI[1];
var IcontA = hasDocI[0];
var IcontB = hasDocI[2];
div.innerHTML = '<div style="float:right;color:red;font-size:8px;font-weight:bold;">DO NOT QUOTE THIS POST ENTIRELY. IT WILL DRAIN BANDWIDTH!!</div><br>' + IcontA + '<center><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" style="width:420px;height:272px" ><param name="allowfullscreen" value="true"/><param name="menu" value="false"/><param name="wmode" value="transparent"/><embed src="http://static.issuu.com/webembed/viewers/style1/v2/IssuuReader.swf" type="application/x-shockwave-flash" allowfullscreen="true" menu="false" wmode="transparent" style="width:420px;height:272px" flashvars="mode=mini&backgroundColor=%23222222&' + urlI + '" /></object></center>' + IcontB + ' ';
} else if (hasDocS.length == 3) {
var urlS = hasDocS[1];
var ScontA = hasDocS[0];
var ScontB = hasDocS[2];
div.innerHTML = '<div style="float:right;color:red;font-size:8px;font-weight:bold;">DO NOT QUOTE THIS POST ENTIRELY. IT WILL DRAIN BANDWIDTH!!</div><br>' + ScontA + '<iframe class="scribd_iframe_embed" ' + urlS + ' data-auto-height="true" data-aspect-ratio="" scrolling="no" ' + ' width="100%" height="600" frameborder="0"></iframe>' + ScontB + ' ';
}
}
});


In the above example two customised BBcodes are introduced namely [doc] & [docis] & each one has a loop which contains the necessary action to be taken if that BBcode occurs in a message.

The above tutorial will have more benefit if we provide some user interface (buttons or something ) that when clicked insert our customised BBcodes
I prefer including those in 'Others' dropdown list of editor

$(function() {
$('#other').prepend('<button title="Insert Scribd Doc" onclick="ddinsert(\'[doc]\',\'[doc]\');selectWysiwyg(this, \'other\');return false; " class="">Scribd</button><br> <button title="Insert Issuu Doc" onclick="ddinsert(\'[docis]\',\'[docis]\');selectWysiwyg(this, \'other\');return false; " class="">Issuu</button><br> ');
});


[align=center]Remember to include source in the code[/align][b]
φ
Posts: 163
Joined: August 5th 2011, 11:00pm
Location: Pakistan
Likes Given: 34
Likes Received: 3
Inserting Scribd & Issuu Docs
Posted December 6th 2011, 3:42pm
Dion can you look at the limitation that I mentioned above, have no ideas how to overcome it, do reply.
http://jsfiddle.net/defencedog/4hRh2/16/

see the third html .postbody in this fiddle which have both customised tags occurring simultaneously in one post but only one BBcode is operated one that comes first in if(){}
φ
Posts: 163
Joined: August 5th 2011, 11:00pm
Location: Pakistan
Likes Given: 34
Likes Received: 3
Inserting Scribd & Issuu Docs
Posted December 12th 2011, 4:47am
plz someone giv an idea..
φ
Posts: 163
Joined: August 5th 2011, 11:00pm
Location: Pakistan
Likes Given: 34
Likes Received: 3

Who is online

Users browsing this forum: No registered users and 0 guests