java and gadgets

hi all ,

i have tried to insert some javascript inside the gadget.js, just to make a clock working up a background table element.

It works well with a iframe, but the script does'nt work inside the js file.

Is there a special way to include directly javascript in th js file, because the usal way does'nt work.

thank you for helping me

albidochon



Answer this question

java and gadgets

  • em325409

    Wow, that's ... messy.

    Some suggestions:

    • Don't use window.onload. It's not going to work. Instead, set up your HTML in initialize() and then directly call goforit(). Or don't even bother with goforit() and set your interval for getthedate() right at the end of initialize().
    • Why are you defining goforit() and getthedate() in the scope of initialize() They should be class-level.
    • When you're setting p_elSource.innerHTML, you've got some bad string handling. Specifically, your string is wrapped by single quotes (') but you use single quotes inside as well (to set attributes on your input tag. That should result in a syntax error.

  • RajDas

    Can you clarify what you mean by "insert some javascript" Maybe post your code Web gadgets are 100% javascript, so I don't understand how you could have problems adding javascript code to javascript code.
  • anilpatel32

    hi toddos,

    thank's for your help...

    I just simplifie the js for the code of the clock, whitout backrground, and thinghs like this...;

    // JavaScript Document
    registerNamespace("albidochon.gadgetfran1");
    albidochon.gadgetfran1.dolphin = function(p_elSource, p_args, p_namespace)
    {
    albidochon.gadgetfran1.dolphin.initializeBase(this, arguments);

    var m_this = this;
    var m_el = p_elSource;
    var m_module = p_args.module;
    var m_iframe = null;


    this.initialize = function(p_objScope)

    {

    var dayarray=new Array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
    var montharray=new Array("Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre");
    function getthedate() {
    var mydate=new Date();
    var year=mydate.getFullYear();
    if (year < 1000) {year+=1900;}
    var day=mydate.getDay();
    var month=mydate.getMonth();
    var daym=mydate.getDate();
    if (daym<10) {daym="0"+daym;}
    var hours=mydate.getHours();
    var minutes=mydate.getMinutes();
    var seconds=mydate.getSeconds();
    {
    d = new Date();
    Time24H = new Date();
    Time24H.setTime(d.getTime() + (d.getTimezoneOffset()*60000) + 3600000);
    InternetTime = Math.round((Time24H.getHours()*60+Time24H.getMinutes()) / 1.44);
    }
    if (hours==0) {hours=12;}
    if (minutes<=9) {minutes="0"+minutes;}
    if (seconds<=9) {seconds="0"+seconds;}
    var cdate=dayarray[day]+" "+daym+" "+montharray[month]+" "+year+"-"+hours+":"+minutes+":"+seconds+"";
    document.getElementById('clock').value=cdate;
    }
    function goforit(){
    setInterval("getthedate()",1000);}
    window.onload=goforit


    albidochon.gadgetfran1.dolphin.getBaseMethod( this, "initialize", "Web.Bindings.Base").call(this, p_objScope);


    p_elSource.innerHTML =
    '<table border="0">' +
    '<tr>' +
    '<td style="height:170px">' +'</td>' +
    '</tr>' +
    '<tr>' +
    '<td align="center">' +
    '<input type='text' id='clock' name='clock' size=40 class='class1' style="width:180px;">' +
    '</td>' +
    '</tr>' +
    </table>' ;


    };
    albidochon.gadgetfran1.dolphin.registerBaseMethod(this, "initialize");
    this.dispose = function(p_blnUnload)
    {

    m_this = null;
    m_el = null;
    m_module = null;
    m_iframe = null;


    albidochon.gadgetfran1.dolphin.getBaseMethod(this, "dispose", "Web.Bindings.Base").call(this, p_blnUnload);
    };
    };
    albidochon.gadgetfran1.dolphin.registerClass("albidochon.gadgetfran1.dolphin", "Web.Bindings.Base");

    It works well in an iframe, but not inside the js, i just have to add the css in a stylesheet external file, or all of this in the same html file.

    albidochon


  • java and gadgets