Current scripts
From Fiamma
Jump to navigationJump to search
Script one, adding links:
var str = document.title; var res = str.replace("|", "-"); res = res.replace("#", "-"); res = res.replace("<", "("); res = res.replace(">", ")"); res = res.replace("[", "("); res = res.replace("]", ")"); res = res.replace("{", "("); res = res.replace("}", ")"); window.open('http://pchr8.net/f/index.php?title='+encodeURIComponent(res)+'&action=edit&preload=Template:NewLink&preloadparams[]='+encodeURIComponent(location.href)+'&preloadparams[]='+encodeURIComponent(res)) javascript:var str = document.title; var res = str.replace("|", "-"); res = res.replace("#", "-"); res = res.replace("<", "("); res = res.replace(">", ")"); res = res.replace("[", "("); res = res.replace("]", ")"); res = res.replace("{", "("); res = res.replace("}", ")"); window.open('http://pchr8.net/f/index.php?title='+encodeURIComponent(res)+'&action=edit&preload=Template:NewLink&preloadparams[]='+encodeURIComponent(location.href)+'&preloadparams[]='+encodeURIComponent(res))
Script two, formatting:
var lines = ''; var lines = $('#wpTextbox1').val().split('\n'); for (i=0; i<7; i++) { if (typeof lines[i] == 'undefined') {lines[i]='';} } if (!ValidURL(lines[0])) {alert(lines[0]+" doesn't look like a valid URL.")}; if (lines[1]=='') {lines[1]=lines[0]}; if (lines[2]=='') {lines[2]='5'}; if (lines[3]=='') {lines[3]='5'}; if (parseInt(lines[2]) > 10 || parseInt(lines[2])<0 || isNaN(lines[2])) { alert(lines[2]+'is not a valid value, setting to default 5'); lines[2]='5'; } if (parseInt(lines[3]) > 10 || parseInt(lines[3])<0 || isNaN(lines[3])) { alert(lines[3]+'is not a valid value, setting to default 5'); lines[3]='5'; } var keywords="\n{{#set:\n"; keywords+="k="; keywords+=lines[5]; keywords+="\n|+sep=, }}\n"; var categories="\n"; for (i=0; i<lines.length-7; i++){ categories+="[[Category: "; categories+=lines[i+7]; categories+="]]\n"; } var text="{{B|\n"+lines[0]+"\n|"+lines[1]+"\n|"+lines[2]+"\n|"+lines[3]; if (lines[4]!='') text+="\n|"+lines[4]; text+="\n}}"; text+=keywords; text+=categories; var field = document.getElementById('wpTextbox1'); var textArray = field.value.split("\n"); textArray.splice(0, lines.length); textArray[0] = text; field.value = textArray.join("\n"); function ValidURL(str) { var pattern = new RegExp('^(https?:\\/\\/)?'+ '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|'+ '((\\d{1,3}\\.){3}\\d{1,3}))'+ '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ '(\\?[;&a-z\\d%_.~+=-]*)?'+ '(\\#[-a-z\\d_]*)?$','i'); return pattern.test(str); } javascript:var lines = ''; var lines = $('#wpTextbox1').val().split('\n'); for (i=0; i<7; i++) { if (typeof lines[i] == 'undefined') {lines[i]='';} } if (!ValidURL(lines[0])) {alert(lines[0]+" doesn't look like a valid URL.")}; if (lines[1]=='') {lines[1]=lines[0]}; if (lines[2]=='') {lines[2]='5'}; if (lines[3]=='') {lines[3]='5'}; if (parseInt(lines[2]) > 10 || parseInt(lines[2])<0 || isNaN(lines[2])) { alert(lines[2]+'is not a valid value, setting to default 5'); lines[2]='5'; } if (parseInt(lines[3]) > 10 || parseInt(lines[3])<0 || isNaN(lines[3])) { alert(lines[3]+'is not a valid value, setting to default 5'); lines[3]='5'; } var keywords="\n{{#set:\n"; keywords+="k="; keywords+=lines[5]; keywords+="\n|+sep=, }}\n"; var categories="\n"; for (i=0; i<lines.length-7; i++){ categories+="[[Category: "; categories+=lines[i+7]; categories+="]]\n"; } var text="{{B|\n"+lines[0]+"\n|"+lines[1]+"\n|"+lines[2]+"\n|"+lines[3]; if (lines[4]!='') text+="\n|"+lines[4]; text+="\n}}"; text+=keywords; text+=categories; var field = document.getElementById('wpTextbox1'); var textArray = field.value.split("\n"); textArray.splice(0, lines.length); textArray[0] = text; field.value = textArray.join("\n"); function ValidURL(str) { var pattern = new RegExp('^(https?:\\/\\/)?'+ '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|'+ '((\\d{1,3}\\.){3}\\d{1,3}))'+ '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ '(\\?[;&a-z\\d%_.~+=-]*)?'+ '(\\#[-a-z\\d_]*)?$','i'); return pattern.test(str); }