{"id":2945,"date":"2014-06-23T16:30:59","date_gmt":"2014-06-23T14:30:59","guid":{"rendered":"http:\/\/xn--okazwoka-bpb.pl\/?p=2945"},"modified":"2014-06-24T08:57:31","modified_gmt":"2014-06-24T06:57:31","slug":"seo-spiner-w-htmljavascript-bez-php","status":"publish","type":"post","link":"http:\/\/xn--okazwoka-bpb.pl\/index.php\/2014\/06\/23\/seo-spiner-w-htmljavascript-bez-php\/","title":{"rendered":"SEO Spiner w HTML+javascript (bez PHP)"},"content":{"rendered":"<p>W pracy zwi\u0105zanej z SEO (katalogowanie, uzupe\u0142nianie zaplecza) niezmiernie cz\u0119sto tworzy si\u0119 teksty z synonimami typu <em>&#8222;{Bardzo|Niezwykle} {mi\u0142o|fajnie} {Ci\u0119|Ciebie} {jest|by\u0142o} {pozna\u0107|spotka\u0107}.&#8221;<\/em> Super fajna sprawa, ale jak tu na szybko wygenerowa\u0107 z tego tekst? Z pomoc\u0105 przychodzi oto prosty skrypt napisany w js no i oczywi\u015bie z elementami html. Kod skryptu zamieszczam poni\u017cej. A demo znajduje si\u0119 na stronie <a href=\/spiner.html target=_BLANK>okazw\u0142oka.pl\/spiner.html<\/a><!--more--><\/p>\n<p>KOD:<\/p>\n<div class=\"codecolorer-container text solarized-light\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<br \/>50<br \/>51<br \/>52<br \/>53<br \/>54<br \/>55<br \/>56<br \/>57<br \/>58<br \/>59<br \/>60<br \/>61<br \/>62<br \/>63<br \/>64<br \/>65<br \/>66<br \/>67<br \/>68<br \/>69<br \/>70<br \/>71<br \/>72<br \/>73<br \/>74<br \/>75<br \/>76<br \/>77<br \/>78<br \/>79<br \/>80<br \/>81<br \/>82<br \/><\/div><\/td><td><div class=\"text codecolorer\">&lt;!DOCTYPE html PUBLIC &quot;-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN&quot; &quot;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd&quot;&gt;<br \/>\n&lt;html xmlns=&quot;http:\/\/www.w3.org\/1999\/xhtml&quot;&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;title&gt;Article Spinner&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;div style=&quot;min-height:500px;&quot;&gt;<br \/>\n&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; border=&quot;0&quot; align=&quot;center&quot; width=&quot;800px&quot;&gt;<br \/>\n&nbsp; &nbsp; &lt;tr&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Spyntax content:&lt;br \/&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;textarea id=&quot;textSpin&quot; rows=&quot;10&quot; style=&quot;width:100%;&quot;&gt;&lt;\/textarea&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input id=&quot;chkNewLine&quot; type=&quot;checkbox&quot; \/&gt;Convert newline to &amp;ltbr \/&amp;gt<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/td&gt;<br \/>\n&nbsp; &nbsp; &lt;\/tr&gt;<br \/>\n&nbsp; &nbsp; &lt;tr&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input id=&quot;inpSpin&quot; type=&quot;button&quot; value=&quot;Next Spun&quot; onclick=&quot;Spin();&quot; \/&gt; &lt;input id=&quot;inpHtml&quot; type=&quot;button&quot; value=&quot;Html Code&quot; onclick=&quot;Html(this);&quot; style=&quot;display:none;&quot; \/&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/td&gt;<br \/>\n&nbsp; &nbsp; &lt;\/tr&gt;<br \/>\n&nbsp; &nbsp; &lt;tr&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;textarea id=&quot;textHtml&quot; rows=&quot;10&quot; style=&quot;width:100%;display:none;&quot;&gt;&lt;\/textarea&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label id=&quot;lblSpin&quot;&gt;&lt;\/label&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/td&gt;<br \/>\n&nbsp; &nbsp; &lt;\/tr&gt; &nbsp; &nbsp;<br \/>\n&lt;\/table&gt; <br \/>\n&lt;\/div&gt;<br \/>\n&lt;div style=&quot;text-align:center;&quot;&gt;Provided by &lt;a href=&quot;http:\/\/www.weontech.com&quot;&gt;www.WeOnTech.com&lt;\/a&gt; - &nbsp;Auto Blog Network - Blog Post SEO - LinkWheel SEO&lt;\/div&gt; &nbsp; &nbsp; &nbsp;<br \/>\n&lt;script type=&quot;text\/javascript&quot;&gt;<br \/>\n&nbsp; &nbsp; function Html(obj) {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; if (obj.value == 'Html Code') {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&quot;textHtml&quot;).value = document.getElementById(&quot;lblSpin&quot;).innerHTML;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&quot;textHtml&quot;).style.display = &quot;block&quot;;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&quot;lblSpin&quot;).style.display = &quot;none&quot;;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&quot;inpHtml&quot;).value = &quot;Preview&quot;;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; else {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&quot;textHtml&quot;).style.display = &quot;none&quot;;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&quot;lblSpin&quot;).style.display = &quot;block&quot;;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&quot;inpHtml&quot;).value = &quot;Html Code&quot;;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; function Spin() {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; var content = document.getElementById(&quot;textSpin&quot;).value.trim();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; if (content == &quot;&quot;) {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert(&quot;Please input spyntax content!&quot;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; else if (content.split(&quot;{&quot;).length != content.split(&quot;}&quot;).length) {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert(&quot;Incorrect spyntax in content! Please re-check it!&quot;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; else {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (document.getElementById(&quot;chkNewLine&quot;).checked) {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var regX = \/\\n\/gi;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; content = content.replace(regX, &quot;&lt;br \/&gt;&quot;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&quot;lblSpin&quot;).innerHTML = GetSpinContent(content);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&quot;inpHtml&quot;).style.display = &quot;&quot;;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (document.getElementById(&quot;inpHtml&quot;).value == &quot;Preview&quot;)<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&quot;textHtml&quot;).value = document.getElementById(&quot;lblSpin&quot;).innerHTML;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp;<br \/>\n&nbsp; &nbsp; function GetSpinContent(text) {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; var result = text;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; var reg = new RegExp(\/{([^{}]*)\\}\/i);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; while (matches = reg.exec(result)) {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var array = new Array();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array = matches[1].split('|');<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = result.replace(matches[0], array[Math.floor(Math.random() * array.length)]);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; reg = new RegExp(\/\\{\\{([\\s\\S]*?)\\}\\}\/i);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; while (match = reg.exec(result)) {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var array = new Array();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array = match[1].split('||');<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = result.replace(match[0], array[Math.floor(Math.random() * array.length)]);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; return result;<br \/>\n&nbsp; &nbsp; } <br \/>\n&lt;\/script&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n","protected":false},"excerpt":{"rendered":"<p>W pracy zwi\u0105zanej z SEO (katalogowanie, uzupe\u0142nianie zaplecza) niezmiernie cz\u0119sto tworzy si\u0119 teksty z synonimami typu &#8222;{Bardzo|Niezwykle} {mi\u0142o|fajnie}&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[83],"tags":[],"_links":{"self":[{"href":"http:\/\/xn--okazwoka-bpb.pl\/index.php\/wp-json\/wp\/v2\/posts\/2945"}],"collection":[{"href":"http:\/\/xn--okazwoka-bpb.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xn--okazwoka-bpb.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xn--okazwoka-bpb.pl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xn--okazwoka-bpb.pl\/index.php\/wp-json\/wp\/v2\/comments?post=2945"}],"version-history":[{"count":7,"href":"http:\/\/xn--okazwoka-bpb.pl\/index.php\/wp-json\/wp\/v2\/posts\/2945\/revisions"}],"predecessor-version":[{"id":2952,"href":"http:\/\/xn--okazwoka-bpb.pl\/index.php\/wp-json\/wp\/v2\/posts\/2945\/revisions\/2952"}],"wp:attachment":[{"href":"http:\/\/xn--okazwoka-bpb.pl\/index.php\/wp-json\/wp\/v2\/media?parent=2945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xn--okazwoka-bpb.pl\/index.php\/wp-json\/wp\/v2\/categories?post=2945"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xn--okazwoka-bpb.pl\/index.php\/wp-json\/wp\/v2\/tags?post=2945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}