Search in sources :

Example 21 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class GridView method writePicture.

// --------------------------------------------------------------------------
protected boolean writePicture(int parent, int picture_id, Request request) throws IOException {
    try {
        selectByID(picture_id);
    } catch (RuntimeException e) {
        return false;
    }
    Timestamp timestamp = m_data.getTimestamp("_timestamp_");
    HTMLWriter writer = request.writer;
    if (m_show_links_to_bordering_pictures) {
        writer.write("<table width=\"100%\"><tr><td width=\"10%\">");
        writeLinkToBorderingPicture(parent, timestamp, true, request);
        writer.write("</td><td align=\"center\"><table><tr><td align=\"center\">");
    }
    if (m_files.m_use_titles)
        writer.tag("h2", m_data.getString("title"));
    if (m_show_links_to_bordering_pictures)
        writer.write("</td></tr><tr><td>");
    writer.img(m_data.getString("filename"), m_path);
    if (m_show_links_to_bordering_pictures) {
        writer.write("</td></tr></table></td><td width=\"10%\" align=\"right\">");
        writeLinkToBorderingPicture(parent, timestamp, false, request);
        writer.write("</td></tr></table>");
    }
    return true;
}
Also used : HTMLWriter(web.HTMLWriter) Timestamp(java.sql.Timestamp)

Example 22 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class MeetingInputRenderer method writeInput.

@Override
public boolean writeInput(View view, Form form, ColumnBase<?> column, View.Mode mode, String default_value, Request request) throws IOException {
    if (mode != View.Mode.ADD_FORM && mode != View.Mode.EDIT_FORM)
        return false;
    HTMLWriter writer = request.writer;
    writer.setAttribute("id", "days_id");
    if (mode == View.Mode.EDIT_FORM)
        writer.hiddenInput("days", view.data().getString(column.getName()));
    else
        writer.hiddenInput("days", "");
    writer.setAttribute("id", "many_days_id");
    String many_days = null;
    if (mode == View.Mode.EDIT_FORM) {
        many_days = request.db.lookupString("days", "meeting_people", "meetings_id=" + view.data().getInt("id") + " AND people_id=" + request.getUser().getId());
        writer.hiddenInput("many_days", many_days);
    } else
        writer.hiddenInput("many_days", "");
    writer.write("<div id=\"meeting_div\"><ol style=\"width:400px\"><li>add days that will contain times that people are available. days can be named anything, e.g. Mondays, Tuesdays, 1/3/2011, 3rd Fridays, etc.</li><li>select the times for each day that will be avaiable for others to choose from when setting their availability. click and drag sections on red times to change them to green.</li><li>click + above or below each day if you need earlier or later times.</li><li>click save when done and then click \"set times\" if you are one of the people trying to find common available times.</li><ol></div>");
    writer.scriptOpen();
    writer.write("meeting=new Meeting(");
    writer.write(mode == View.Mode.ADD_FORM ? 0 : 1);
    writer.write(",$('meeting_div'),$('days_id'),$('many_days_id'),[");
    if (mode == View.Mode.EDIT_FORM) {
        ResultSet rs = request.db.select("SELECT days FROM meeting_people WHERE meetings_id=" + view.data().getString("id") + " AND people_id!=" + request.getUser().getId());
        try {
            while (rs.next()) {
                if (!rs.isFirst())
                    writer.write(',');
                writer.write('\'');
                writer.write(rs.getString(1));
                writer.write('\'');
            }
            rs.getStatement().close();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
    writer.write("]);");
    // if (mode == View.DB_Mode.EDIT)
    // if (view.getInt("_owner_") == request.getUser().getId()) {
    // writer.write("meeting.rebuild();");
    // writer.write("function show_overlap(event){" +
    // "var t=window.event?window.event.srcElement:event.target;" +
    // "var d=$('meeting_days');" +
    // "if(t.checked)" +
    // "d.value=meeting.getDays();" +
    // "meeting.empty();" +
    // "if(t.checked){" +
    // "meeting.calcStartFinish(d.value);" +
    // "meeting.buildDays(d.value,1);");
    // try {
    // ResultSet rs = request.db.select("SELECT days FROM meeting_people WHERE meetings_id=" + view.getString("id"));
    // int num_people = 1;
    // while (rs.next()) {
    // writer.write("meeting.selectDays('");
    // writer.write(rs.getString(1));
    // writer.write("',true);");
    // ++num_people;
    // }
    // writer.write(
    // "}else\n" +
    // "meeting.rebuild();" +
    // "$('add_span').style.visibility=t.checked?'hidden':'visible';" +
    // "};");
    // writer.write("var num_people=");
    // writer.write(num_people);
    // rs.getStatement().close();
    // } catch (SQLException e) {
    // throw new RuntimeException(e);
    // }
    // } else {
    // String one_days = view.getString(column.getName());
    // writer.write("meeting.calcStartFinish('");
    // writer.write(one_days);
    // writer.write("');");
    // writer.write("meeting.buildDays('");
    // writer.write(one_days);
    // writer.write("',0);");
    // if (many_days != null)
    // writer.write("meeting.selectDays($('many_days_id').value,false);");
    // writer.write("$('add_span').style.visibility='hidden';");
    // }
    writer.scriptClose();
    writer.write("<p id=\"legend\" style=\"font-size:9pt;display:none\"><span id=\"abox\" style=\"border-left:12px solid;height:0px\">&nbsp;</span> available&nbsp;&nbsp;&nbsp;" + "<span id=\"ubox\" style=\"border-left:12px solid;height:0px\"></span> unavailable<br />" + "click and drag to select available times</p>");
    writer.js("$('abox').style.borderColor=meeting.colors[1];$('ubox').style.borderColor=meeting.colors[0];");
    if (mode == View.Mode.EDIT_FORM && view.data().getInt("_owner_") == request.getUser().getId()) {
        writer.write("<p>");
        writer.radioButtonInline("db_mmode", "set my times", null, true, "meeting.setMode(1)");
        writer.nbsp();
        writer.radioButtonInline("db_mmode", "view overlapping times", null, false, "meeting.setMode(2)");
        writer.nbsp();
        writer.radioButtonInline("db_mmode", "edit available times", null, false, "meeting.setMode(0)");
        writer.write("</p>");
    }
    return true;
}
Also used : HTMLWriter(web.HTMLWriter) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet)

Example 23 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class PicturesNewsItem method write.

// --------------------------------------------------------------------------
@Override
public void write(Calendar now) throws IOException {
    HTMLWriter writer = m_request.writer;
    writer.write("<div id=\"ni").write(m_news_id).write("\" class=\"news_item\"><div>");
    writeHeader(now, writer);
    int num_pictures = m_item_ids.size();
    if (num_pictures > 1)
        masonry(2);
    else {
        int item_id = m_item_ids.get(0);
        String[] image = m_request.db.readRow(new Select("file,caption,_owner_").from("pictures").whereIdEquals(item_id));
        writer.write("\n<img src=\"").write(m_request.getContext()).write("/pictures/thumbs/").write(image[0]).write("\" onclick=\"Gallery.setFiles(['").write(image[0]).write("'],[").write(item_id).write("],[").jsString(Pictures.buildTitle(Integer.toString(item_id), image[1], m_request.site.lookupName(Integer.parseInt(image[2]), m_request.db), null).replace("\"", "&quot;")).write("]);Gallery.open(0);\" style=\"cursor:pointer;\"/>");
    }
    writer.write("</div>");
    Likes.write(m_provider, m_item_id, m_request);
    Comments.writeComments(m_provider.getTable(), m_item_id, m_request);
    writer.write("</div>");
}
Also used : HTMLWriter(web.HTMLWriter) Select(db.Select)

Example 24 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class NewsFeed method writeEditForm.

// --------------------------------------------------------------------------
@Override
public void writeEditForm(int item_id, int news_id, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    writer.write("<div class=\"status\">");
    writer.setAttribute("rows", "2");
    writer.textAreaExpanding("post", "width:100%", request.db.lookupString(new Select("text").from(m_table).whereIdEquals(item_id)), false);
    writer.js("Dialog.top().add_ok('Save',function(){XHR_post(context+'/NewsFeed/" + item_id + "/update','text='+encodeURIComponent($('post').value),function(){replace_news_item(" + news_id + ")})});");
}
Also used : HTMLWriter(web.HTMLWriter) Select(db.Select)

Example 25 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class NewsItem method write.

// --------------------------------------------------------------------------
public void write(Calendar now) throws IOException {
    HTMLWriter writer = m_request.writer;
    writer.write("<div id=\"ni").write(m_news_id).write("\" class=\"news_item\"><div>");
    writeHeader(now, writer);
    m_provider.writeItem(m_item_id, m_request);
    writer.write("</div>");
    Likes.write(m_provider, m_item_id, m_request);
    Comments.writeComments(m_provider.getTable(), m_item_id, m_request);
    writer.write("</div>");
}
Also used : HTMLWriter(web.HTMLWriter)

Aggregations

HTMLWriter (web.HTMLWriter)109 Select (db.Select)18 SQLException (java.sql.SQLException)16 ResultSet (java.sql.ResultSet)14 Table (web.Table)12 JDBCTable (db.JDBCTable)10 Person (app.Person)7 Calendar (java.util.Calendar)7 ArrayList (java.util.ArrayList)6 JDBCColumn (db.JDBCColumn)5 View (db.View)5 DBObject (db.DBObject)4 Form (db.Form)4 File (java.io.File)4 AdminTask (web.AdminTask)4 FilePathStringBuilder (web.FilePathStringBuilder)4 Select (web.Select)4 Mode (db.View.Mode)3 IOException (java.io.IOException)3 NumberFormat (java.text.NumberFormat)3