Custom BBCode preview not working!


#1

Hello,

Need help with my BBcode. The Problem in preview doesn´t work but it work´s when posted.

// [DECK]...[/DECK]
Discourse.Dialect.replaceBlock({
  start: /(\[deck\])([\s\S]*)/igm,
  stop: /\[\/deck\]/igm,
  rawContents: true,

  emitter: function(blockContents) {
  	var inner = blockContents.join("\n");
	var ergebnis = inner.match(/(^.*$)/gm);
	var card = new Array();
	for (var i in ergebnis)
	{
		card[i] = '<a href="'+"http://magiccards.info/query?q="+ergebnis[i].replace(/(^\d*\s*)/g,"").replace(/(\s)/g, "%20")+'">'+ergebnis[i]+'</a>';
	}
	var inner2 = card.join("\n");
	return ['div', inner2];
  }
});

(Régis Hanol) #2

Are there any JavaScript errors in the console while you have the composer open?


#3

Yes,

Uncaught TypeError: undefined is not a function linked me to this Code:

card[i] = '<a href="'+"http://magiccards.info/query?q="+ergebnis[i].replace(/(^\d*\s*)/g,"").replace(/(\s)/g, "%20")+'">'+ergebnis[i]+'</a>';

(Sam Saffron) #4

can you make a post with the exact code here, it does look like a bug.


#5

Here are the Code on Github

exact code?

The first linked me to a .js this is the line that be highlighted [JavaScript] }),e.getJSON("https://gdata.youtube.com/feeds/api/videos/"+c+"?v=2&alt=json",fun - Pastebin.com

The second


Here no Erros when not in the Editor.

need you more?


(Kane York) #6

Here’s the error:

for (var item in collection) {
    ..... collection[item] .....
}

Replace that with:

collection.forEach(function(item) {
    ..... item .....
});

#8

It work´s! Thank you all!


(Régis Hanol) #9