Tampilkan postingan dengan label Javascript. Tampilkan semua postingan
Tampilkan postingan dengan label Javascript. Tampilkan semua postingan

Sabtu, 10 Maret 2018

Asynchronous Loading of External Javascript

View Article

INTRODUCTION

Loading of external javascript resources (libraries, plugins, widgets) should be done asynchronously, in a non-blocking manner, so the load time of your web-page will not be affected. Thus other resources like images and CSS are not blocked from loading.

HTML5 WAY

In the past that was possible with help of thedefer attribute, later HTML5 spec introduce the async attribute.
<script src="//code.jquery.com/jquery-1.11.0.min.js" async>
</script>

PROGRAMATICALLY WAY

Dynamically you can create script tag and inject it into the DOM.
<script type="text/javascript">
(function() {
var script = document.createElement("script");
script.type = "text/javascript";
script.async = true;
script.src = "//code.jquery.com/jquery-1.11.0.min.js";
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script);
})();
</script>

YOU NEED A CALLBACK?

Often we need to know when the script is loaded, and when we are ready to use it. That's why we need a callback function. Also you can think about it as a dependency manager.
<script type="text/javascript">
function loadScript(url, callback) {
var script = document.createElement("script");
script.type = "text/javascript";
script.async = true;
if (script.readyState) {
script.onreadystatechange = function () {
if (script.readyState == "loaded" || script.readyState == "complete") {
script.onreadystatechange = null;
if (callback && typeof callback === "function") {
callback();
}
}
};
} else {
script.onload = function () {
if (callback && typeof callback === "function") {
callback();
}
};
}
script.src = url;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script);
}
// How to use it
loadScript("//code.jquery.com/jquery-1.11.0.min.js", function () {
// jQuery was loaded
loadScript("//code.jquery.com/ui/1.10.4/jquery-ui.min.js");
});
</script>

ECMASCRIPT 2017 (ES8) WAY

Callback functions runs the world of JavaScript before the advent of ECMAScript 2017 that standardized the use of async/await in conjunction with Promises (part of ECMAScript 2015).
<script type="text/javascript">
async function loadScripts (scripts) {

function get (src) {
return new Promise(function (resolve, reject) {
var el = document.createElement("script");
el.async = true;
el.addEventListener("load", function () {
resolve(src);
}, false);
el.addEventListener("error", function () {
reject(src);
}, false);
el.src = src;
(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(el);
});
}

const myPromises = scripts.map(async function (script, index) {
return await get(script);
});

return await Promise.all(myPromises);
}

// How to use it
loadScripts([
"https://static.zinoui.com/1.5/compiled/zino.svg.min.js",
"https://static.zinoui.com/libs/jquery/jquery.min.js"
]).then(function () {
return loadScripts(["https://static.zinoui.com/1.5/compiled/zino.chart.min.js"]);
}).then(function () {
$("#chart").zinoChart(settings);
});
</script>
Asynchronous Loading of External Javascript Written By Dimitar Ivanov On Asynchronous Loading of External Javascript. Posted on: June 11, 2014

Jumat, 09 Februari 2018

JavaScript Call Random CSS file

View Article
Someone talk to stack overflow like this :

I am trying to rotate random CSS sheets via JS - I have the following script but when I am using it - it doesnt seem to work ?

function getRand(){
return Math.round(Math.random()*(css.length-1));
}
var css = new Array(
'<link rel="stylesheet" type="text/css" href="css/1.css">',
'<link rel="stylesheet" type="text/css" href="css/2.css">',
'<link rel="stylesheet" type="text/css" href="css/3.css">',
'<link rel="stylesheet" type="text/css" href="css/4.css">'
);
rand = getRand();
document.write(css[rand]);

Appreciate any help?


ask and Answer
The best answer is : Try to create the link element programmatically and appending it to the head
function applyRandCSS(){
var css = ["css/1.css", "css/2.css", "css/3.css", "css/4.css"];
var randomFile = css[Math.round(Math.random()*(css.length-1))];
var ss = document.createElement("link");

ss.type = "text/css";
ss.rel = "stylesheet";
ss.href = randomFile;

document.getElementsByTagName("head")[0].appendChild(ss);
}

Senin, 29 Januari 2018

Easy Way of Adding Pin It Buttons in Images

View Article

Function of this button to directly input images in your blog to your Pinterest account. How it works from the Button share Pin It this is the button will appear when you focus the cursor on each image in the blog.

Easy Way of Adding Pin It Buttons in Images

The trick is very easy, here you just need to add the code below before the body cover code </ body> or before the head cover code in the template </ head>
Before adding this code make sure that in your blog template you have added jquery library link

<script async='' data-pin-color='white' data-pin-hover='true' src='//assets.pinterest.com/js/pinit.js'/>
Here is a display demo of this Pin It button. DEMO

Selasa, 26 Desember 2017

(JS) Javascript Function Remove Slash From String

View Article
JavaScript Function
All I needed was to expel every single forward slice in a string utilizing Javascript.
Remove Forward Slash (/) Using JavaScript Function
function FSlash(func){
var x = func,
   n = x.replace(/\//g,'');
return n
 }
//Usage Using Variable
var nx = "4x/4/4/5/6/7//532///45/";
//Call Variable Into Function Name
   document.write(FSlash(nx));
//You can combine from function too
Demo : CodePen
The vital part to note here is the consistent articulation /\//g. The bit of the string you need supplanting is composed between the first and last forward cuts – so on the off chance that you needed the word 'work area' supplanted you would compose/work area/g.

As the character we need to expel is an uncommon case you need to escape it utilizing an oblique punctuation line, generally the code will read the twofold forward cut as a remark thus quit preparing the line.

At last, the g implies apply the substitution internationally to the string with the goal that all occasions of the substring are supplanted.
Remove Back Slash (\) Using JavaScript Function
function BSlash(func){
var x = func,
   n = x.replace(/\\/g, '')
return n
 }
//Usage Using Variable
var nx = "Dev : \D\i\m\a\s\Www.webmanajemen.xyz";
//Call Variable Into Function Name
   document.write(BSlash(nx));
//You can combine from function too
Demo : JsFiddle
so an article about "JS Function Remove Slash From String" today. I hope this helps.

Selasa, 12 Desember 2017

Update Code Widget Dan Template Untuk Simple Safelink Converter

View Article
Untuk Cara Instal, Deskripsi, Dan Cara Penerapan Klik Disini (Cara Membuat Simple Safelink Converter)

Update code Safelink Converter untuk Widget Atau Template/Theme

Tambahan : Protected Links
<script type='text/javascript' async='async'>
var myArray = ['https://www.webmanajemen.xyz/p/redirect.html?u=', 'https://www.webmanajemen.xyz/p/advertisement.html?u=', 'http://www.webmanajemen.xyz/p/advertise.html?u='];
var safelink = myArray[Math.floor(Math.random() * myArray.length)];
var protectedLinks = /(bing.com|google|linkedin.com|facebook|manajemen|safelink|pinterest|digg.com|twitter|codepen.io|blogger.com|ask.com|DOMAINKAMU.COM)/
$( 'a' ).each(function() {
if (this.href.match( protectedLinks ) ){
$(this).attr("href", $(this).attr("href")+'?success');
//$(this).addClass('w3-text-green'); //Add Class On Internal Links
} else {
$(this).attr("href", safelink+encodeURIComponent($(this).attr("href")+'?utm=web-manajemen.blogspot.com'));
//$(this).addClass('w3-text-red'); //Add Class On External Links
}
});
</script>
ubah DOMAINKAMU.COM dengan domain kamu. Untuk menambahkan lebih dari 1 domain, kasih separator |. Misal domain.com|domain.me|domain.net
Untuk Kode Halaman Bisa menggunakan kode terupdate sebelumnya di Update Code Safelink Converter 12 Des 2017

Senin, 11 Desember 2017

Update Code Safelink Converter Untuk Halaman 12 Desember 2017

View Article
Untuk Cara Instal, Deskripsi, Dan Cara Penerapan Klik Disini (Cara Membuat Simple Safelink Converter)

Code Untuk Di Halaman Safelink

<script type="text/javascript" async>
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}

var count = 11;
var queryU = getQueryVariable('u');
var redirect = decodeURIComponent(queryU);
var noprotocol = redirect.replace(/(^\w+:|^)\/\//, '');

function countDown(){
var timer = document.getElementById("timer");
var done = document.getElementById("done");
var ket = document.getElementById("ket");
if(count > 0){
count--;
timer.innerHTML = "<div id='timer' class='w3-center w3-panel w3-light-grey'>Your Link Will Be Appears In <b>"+count+"</b> Seconds.</div>";
setTimeout("countDown()", 1000);
}else{
document.getElementById("progressBar").style.display = "none";
timer.innerHTML = "<div id='timer' class='w3-center w3-panel w3-light-grey'>Your Link Already Appeared, <b>Scroll Down</b> To View.</div>";
done.innerHTML = "<div id='nots' class='w3-center w3-light-grey w3-display-inline-block'><i class='fa fa-arrow-right' aria-hidden='true'></i> <a href='"+redirect+"' class='w3-btn w3-green'>Download Now (This Your Link) <i class=\"fa fa-download\" aria-hidden=\"true\"></i></a> <i class='fa fa-arrow-left' aria-hidden='true'></i></div>";
ket.innerHTML = "<div class='w3-panel w3-green w3-card-4 w3-center'>Your Destination Is <pre>"+redirect+"</pre></div>";
}
}
</script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7975270895217217"
data-ad-slot="5315452541"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<span id="timer">
<script>
countDown();</script>
</span>
<div id="progressBar">
<div></div>
</div>
<ins class="adsbygoogle"
style="display:block"
data-ad-format="autorelaxed"
data-ad-client="ca-pub-7975270895217217"
data-ad-slot="6234751119"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7975270895217217"
data-ad-slot="7267894124"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<span id="done"></span>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7975270895217217"
data-ad-slot="2600604346"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<span id="ket"></span>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-7975270895217217" data-ad-slot="7382733759"></ins><script>(adsbygoogle=window.adsbygoogle || []).push({});</script><link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet" /><style>#progressBar {
width: 90%;
margin: 10px auto;
height: 22px;
background-color: #0A5F44;
}

#progressBar div {
height: 100%;
text-align: right;
padding: 0 10px;
line-height: 22px; /* same as #progressBar height if we want text middle aligned */
width: 0;
background-color: #CBEA00;
box-sizing: border-box;
}</style><script>function progress(timeleft, timetotal, $element) {
var progressBarWidth = timeleft * $element.width() / timetotal;
$element.find('div').animate({ width: progressBarWidth }, timeleft == timetotal ? 0 : 1000, 'linear').html(timeleft + " secs");
if(timeleft > 0) {
setTimeout(function() {
progress(timeleft - 1, timetotal, $element);
}, 1000);
}
};

progress(10, 10, $('#progressBar'));
</script>
Edit Sesuka Kalian. Donasi dengan iklan adsense saya ya hehe

Code Untuk Di Widget atau Template Diatas </body>


Update Code Untuk Widget/Template Dengan Tambahan Protected Links : Update Code Widget Dan Template Untuk Simple Safelink Converter (Klik Disini)

<script async type='text/javascript'>
//*<![CDATA[*//
var myArray = ['https://www.webmanajemen.xyz/p/redirect.html?u=', 'https://www.webmanajemen.xyz/p/advertisement.html?u=', 'http://www.webmanajemen.xyz/p/advertise.html?u='];
var safelink = myArray[Math.floor(Math.random() * myArray.length)];
$( 'a' ).each(function() {
if( location.hostname === this.hostname || !this.hostname.length ) {
$(this).attr("href", $(this).attr("href")+'?success');
//$(this).addClass('local btn btn-success text-white w3-btn w3-green w3-text-white');
} else {
$(this).attr("href", safelink+encodeURIComponent($(this).attr("href")+'?utm=web-manajemen.blogspot.com'));
//$(this).addClass('external btn-danger text-white btn w3-btn w3-red w3-text-white');
}
});
//*]]>*//
</script>
Ganti URL dengan URL halaman safelink kalian

Rabu, 06 Desember 2017

Random Posts Widget Blogger

View Article

How to create random posts widget blogger (simple and stylish).


1. Login to dashboard blogger -> navigate to layout tab -> create widget html/javascript -> insert this code to the widget.

<style scoped='' type="text/css">
#arlina-random ul{list-style:none;margin:0;padding:0}#arlina-random li{display:block;clear:both;overflow:hidden;list-style:none;border-bottom:1px solid #e3e3e3;word-break:break-word;padding:10px 0;margin:0;}
#arlina-random li:last-child{border-bottom:0;}
#arlina-random li a{color:#444;}#arlina-random li a:hover{color:#444;text-decoration:underline}
</style>
<div id='arlina-random'>Memuat...</div>
<script>
//<![CDATA[
// Random Post Widget
var homePage = 'https://www.web-development.cf',
    maxResults = 10,
    containerId = 'arlina-random';
function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}
function shuffleArray(arr) {
    var i = arr.length, j, temp;
    if (i === 0) return false;
    while (--i) {
        j = Math.floor(Math.random() * (i + 1));
        temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
    return arr;
}
function ArlinaRandomPosts(json) {
    var startIndex = getRandomInt(1, (json.feed.openSearch$totalResults.$t - maxResults));
    // console.log('Get the post feed start from ' + startIndex + ' until ' + (startIndex + maxResults));
    document.write('<scr' + 'ipt src="' + homePage + '/feeds/posts/summary?alt=json-in-script&orderby=updated&start-index=' + startIndex + '&max-results=' + maxResults + '&callback=randomPosts"></scr' + 'ipt>');
}
function randomPosts(json) {
    var link, ct = document.getElementById(containerId),
        entry = shuffleArray(json.feed.entry),
        skeleton = "<ul>";
    for (var i = 0, len = entry.length; i < len; i++) {
        for (var j = 0, jen = entry[i].link.length; j < jen; j++) {
            link = (entry[i].link[j].rel == "alternate") ? entry[i].link[j].href : '#';
        }
        skeleton += '<li><a href="' + link + '">' + entry[i].title.$t + '</a></li>';
    }
    ct.innerHTML = skeleton + '</ul>';
}
document.write('<scr' + 'ipt src="' + homePage + '/feeds/posts/summary?alt=json-in-script&max-results=0&callback=ArlinaRandomPosts"></scr' + 'ipt>');
//]]>
</script>

Change "https://www.web-development.cf" to your address blogs.
Change number "10" to your chances, it will display how much random posts will displayed in the widget.
Done.

Results



What this article help you ?. Please share this yeah !!...

Senin, 04 Desember 2017

Powerful Ways to Remove Active Links in Blog Comments

View Article
Link is active in the comment, what does it mean? An active link is a link that contains hyperlinks to point to a specific page or site.Means if combined, the meaning of the active link in the comment is the active link in the comment. Usually embedded by other blogger people or admins in the comments column as a response to the article in a blog post.
If there is an active link, is there any inactive link? Correct. Inactive links mean the opposite of active links. Physically, an inactive link when clicked using a mouse will not generate a new page. In contrast to active links. Clicking will redirect to a specific page according to the URL embedded in it.

Backlink effect

The blog walker or admin term used to make comments on other blogs, usually aim to get backlinks. They then insert a link to his blog on the comments they wrote. In addition, he also hopes to get a response from people who visit the blog.

Why was it removed

Then why do active links have to be deleted in comments? Will it damage or adversely affect the blog? Actually it can be said, Yes and it can be No. Why so, because it all depends on what active links are embedded in the comments. If the active link contains good links, for example, directing to sites that do not contain haram, such as porn, online gambling, money games and semisalnya, then no need to delete them. But if the active link contains promo or forbidden ads, so it's good to be deleted.

SEO SEO Effect

In terms of SEO blogs, the existence of active links are classified as spam will be very detrimental to the blog. The blog will be difficult to be crawled, because it is feared that the active link is inserted in damaged condition or even error. So reasonable, if when checking broken links in the blog, it turns out the most broken link is in the comments. This is why then the blogger admin limits and also disables the comment feature.
Therefore, this time I want to share 2 ways to remove the active link in the comments. That is first delete via blogger and second comment feature, conditioned that in the comment column can not be inserted active link. Here's more reviews.

How to remove active links in comments

Manually delete

1. Go to the blogger dashboard.
2. Select the Comments menu.Click Published.
3. Please click Remove content for all contents of the missing comment. Figure A is a comment that has not been in Remove, while picture B is the result of comments already in Remove.
In this way, the active links that are contained in the comments will automatically disappear following all the content of the comment. However, the commenter's name still appears in the comment field.
If you want to remove the whole, both the commenter and the content of his comment, then click Delete . While wanting to include it as a spam comment, please click Spam. Then the comment will go into a special folder, the Spam folder. It's located under the Published menu.

Automatic way

The purpose of this way is, make the comment field can not be inserted by the active link. Can only be filled by comments only.Here's how.
1. Go to the blogger dashboard.
2. Click Edit HTML in the Template menu.
3. Place the following code just below <head>.
<script src='http: //ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script>
4. Then place the following code above the code </head>
<script type='text/javascript'>
//<![CDATA[
$(function() {
$('#comments p').find('a').contents().unwrap();
});
//]]>
</script>
5. End with Save template.
In this way, then whenever anyone gives a comment on our blog, then anything inserted into it will not be active. This method is in addition to easy, also still in moderate category. That is, it still provides an opportunity for commenters to insert inactive links. And of course, inactive links will have no effect whatsoever for googlebot crawling. Because he is only rated as a plain text mode. This means safe for our blog.
Thus, two powerful ways can be used to remove active links in comments . Hopefully useful and good luck.