New wiki-page
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
<noinclude>__NOTOC__
This is just a little widget to prove how we code, this text will be visible when you "look" at the widget
</noinclude>
<includeonly>
<script type="text/javascript">
<script type="text/javascript">
var text = '<!--{$text}-->';  
 
var colour = '<!--{$colour}-->';  
 
document.write('So I need to send the message' + text + '<br />');  
var colour ='<!--{$colour|escape:'quotes'|default:red}-->'; //If there is no colour well set it to red
document.write('And I will use the colour ' + colour + '<br />');  
var message = '<!--{$message|escape:'quotes'}-->'; //We should have a message
document.write('I wrote something!!!');
var divid = '<!--{$divid|escape:'quotes'}-->'; //Remove quotes
//Thats all the user input
 
$.getJSON("http://v-ghost.port0.org:8081/dbfswiki/api.php?action=browsebysubject&subject=Usermessages&format=json", function(data) {
      $(data.query.data).each(function(key, data){
            if(( data.property == message )){
              var text=data.dataitem[0].item.split('_').join(' '); // get rid of _
                document.getElementById(divid).innerHTML = '<H3>' + message + ' from ' + wgSiteName + '<br>' + text ;
              document.getElementById(divid).style.backgroundColor = colour;
                //And because we are (kind of) web developing, we'll apply the pretty box css to our box
                document.getElementById(divid).className = 'prettybox' ;
            }
      });
});
 
//Yes, I know, this is a ridiculously problematic way to so something really simple, but we want to change the above to call SMWAPI next iteration.
 
/*
wgSiteName is the preset variable we spoke of, and yes, it is a ridicolous way of addressing a JSON object, but this is about how to do MediaWiki javasctipt, not how to use JSON. Now lets do some CSS to our div
*/
              //document.getElementById(divid).innerHTML = '<H3>' + message + ' from ' + wgSiteName + '<br>' + text ;  
 
 
 
</script>
</script>
</includeonly>

Revision as of 08:21, 14 August 2017

<script type="text/javascript">


var colour =; //If there is no colour well set it to red var message = ; //We should have a message var divid = ; //Remove quotes //Thats all the user input

$.getJSON("http://v-ghost.port0.org:8081/dbfswiki/api.php?action=browsebysubject&subject=Usermessages&format=json", function(data) {

     $(data.query.data).each(function(key, data){
           if(( data.property == message )){
              var text=data.dataitem[0].item.split('_').join(' '); // get rid of _

document.getElementById(divid).innerHTML = '

' + message + ' from ' + wgSiteName + '
' + text ; document.getElementById(divid).style.backgroundColor = colour; //And because we are (kind of) web developing, we'll apply the pretty box css to our box document.getElementById(divid).className = 'prettybox' ; } }); }); //Yes, I know, this is a ridiculously problematic way to so something really simple, but we want to change the above to call SMWAPI next iteration. /* wgSiteName is the preset variable we spoke of, and yes, it is a ridicolous way of addressing a JSON object, but this is about how to do MediaWiki javasctipt, not how to use JSON. Now lets do some CSS to our div
  • /
//document.getElementById(divid).innerHTML = '

' + message + ' from ' + wgSiteName + '
' + text ; </script>