Site Notice

hello, world

Difference between revisions of "Github CDN"

From Project-EPB Commons
([InPageEdit] 没有编辑摘要)
([InPageEdit] 没有编辑摘要)
(One intermediate revision by the same user not shown)
Line 5: Line 5:
  
 
== 调用 ==
 
== 调用 ==
<html><pre id="show">https://cdn.jsdelivr.net/gh/<span id="user">dragon-fish</span>/<span id="repo">inpageedit-v2</span>/<span id="version">master</span>/<span id="file">script.js</span></pre>
+
<input id="show" readonly onclick="this.selected = true" style="width:96%">https://cdn.jsdelivr.net/gh/dragon-fish/inpageedit-v2@master/script.js</input>
 
<form class="in-page-edit" id="myForm" onkeyup="getlink()">
 
<form class="in-page-edit" id="myForm" onkeyup="getlink()">
 
<label>用户:<br/><input name="user" value="dragon-fish"/></label><br/>
 
<label>用户:<br/><input name="user" value="dragon-fish"/></label><br/>
Line 13: Line 13:
 
</form>
 
</form>
 
<script>
 
<script>
function getlink(){
+
function getlink() {
 
   var formData = '?' + $('#myForm').serialize();
 
   var formData = '?' + $('#myForm').serialize();
   var para = function(a){return mw.util.getParamValue(a,formData)};
+
   var para = function (i) { return mw.util.getParamValue(i, formData) };
   $('#show > span').text(function(){
+
   var url = 'https://cdn.jsdelivr.net/gh';
    var $this = $(this),
+
  url += '/' + para('user');
      id = $this.attr('id');
+
  url += '/' + para('repo');
    return para(id);
+
  if (para('version') !== '') url += '/' + para('version');
   });
+
   url += '/' + file;
};
+
  $('#show').val(url);
 +
}
 
</script>
 
</script>
 
</html>
 
</html>

Revision as of 01:10, 15 August 2020

jsDeliver

用法

https://cdn.jsdelivr.net/gh/用户/仓库@分支/文件名

调用

<input id="show" readonly onclick="this.selected = true" style="width:96%">https://cdn.jsdelivr.net/gh/dragon-fish/inpageedit-v2@master/script.js</input> <form class="in-page-edit" id="myForm" onkeyup="getlink()"> <label>用户:
<input name="user" value="dragon-fish"/></label>
<label>仓库:
<input name="repo" value="inpageedit-v2"/></label>
<label>分支:
<input name="version" value="master"/></label>
<label>文件:
<input name="file" value="script.js"/></label> </form> <script> function getlink() {

 var formData = '?' + $('#myForm').serialize();
 var para = function (i) { return mw.util.getParamValue(i, formData) };
 var url = 'https://cdn.jsdelivr.net/gh';
 url += '/' + para('user');
 url += '/' + para('repo');
 if (para('version') !== ) url += '/' + para('version');
 url += '/' + file;
 $('#show').val(url);

} </script> </html>